Add some logging for b/281514966

We suspect issues with (re-)loading comments in the comments model. We
some more logging for being able to root cause the issue next time. We
still don't have a reliable way to re-produce the issue at will.

Release-Notes: skip
Google-Bug-Id: b/281514966
Change-Id: Id348fa093dad9e72006fa6ebf47b5501bd233f65
diff --git a/polygerrit-ui/app/models/comments/comments-model.ts b/polygerrit-ui/app/models/comments/comments-model.ts
index eca8b7c..c9b0bd9 100644
--- a/polygerrit-ui/app/models/comments/comments-model.ts
+++ b/polygerrit-ui/app/models/comments/comments-model.ts
@@ -438,6 +438,7 @@
     private readonly navigation: NavigationService
   ) {
     super(initialState);
+    console.info('CommentsModel constrcutor');
     this.subscriptions.push(
       this.savingInProgress$.subscribe(savingInProgress => {
         if (savingInProgress) {
@@ -477,6 +478,7 @@
     );
     this.subscriptions.push(
       this.changeViewModel.changeNum$.subscribe(changeNum => {
+        console.info(`CommentsModel reload ${changeNum}`);
         this.changeNum = changeNum;
         this.setState({...initialState});
         this.reloadAllComments();
@@ -518,8 +520,18 @@
     this.setState(reducer({...this.getState()}));
   }
 
+  override setState(state: CommentState) {
+    const commentsUndefPrev = this.getState().comments === undefined;
+    const commentsUndefNext = state.comments === undefined;
+    console.info(
+      `CommentsModel setState ${commentsUndefPrev} ${commentsUndefNext} ${this.stateUpdateInProgress}`
+    );
+    super.setState(state);
+  }
+
   async reloadComments(changeNum: NumericChangeId): Promise<void> {
     const comments = await this.restApiService.getDiffComments(changeNum);
+    console.info(`CommentsModel setComments ${comments === undefined}`);
     this.modifyState(s => setComments(s, comments));
   }
 
diff --git a/polygerrit-ui/app/models/model.ts b/polygerrit-ui/app/models/model.ts
index 19b52fc..2d0ff42 100644
--- a/polygerrit-ui/app/models/model.ts
+++ b/polygerrit-ui/app/models/model.ts
@@ -27,7 +27,7 @@
    * another `next()` call. So make sure that state updates complete before
    * starting another one.
    */
-  private stateUpdateInProgress = false;
+  protected stateUpdateInProgress = false;
 
   private subject$: BehaviorSubject<T>;