Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing branch for #1340 #1

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open

Testing branch for #1340 #1

wants to merge 13 commits into from

Conversation

PIG208
Copy link
Owner

@PIG208 PIG208 commented Feb 8, 2025

No description provided.

PIG208 added 13 commits February 7, 2025 19:55
This allows us to call it from model code when GlobalStore is available.

Signed-off-by: Zixuan James Li <[email protected]>
PerAccountStore shouldn't be an owner of the MessageListView elements.

Its relationship to MessageListView is similar to that of
AutocompleteViewManager to MentionAutocompleteView (zulip#645).

With two owners, the MessageListView can be disposed twice:

1. before the frame is rendered, `removeAccount` disposes the
  `PerAccountStoreWidget`, which disposes the `MessageListView`;
   `_MessageListState` is not yet disposed;

2. during build, because `store` is set to `null`,
  `PerAccountStoreWidget` gets rebuilt. `_MessageListState`,
  a descendent of it, is no longer in the render tree;

3. during finalization, `_MessageListState` tries to dispose the
   `MessageListView`.

This removes regression tests added for zulip#810, because
`MessageStoreImpl.dispose` no longer exists.  `MessageListView` does not
get disposed unless there is a `_MessageListState` owner.

Signed-off-by: Zixuan James Li <[email protected]>
This highlights the API choice that the callback signature allows the
caller to clear/cancel the reported errors, drawing distinction from a
later added variant that does not allow this.

Signed-off-by: Zixuan James Li <[email protected]>
Signed-off-by: Zixuan James Li <[email protected]>
Coming up with a realistic test case doesn't actually require
invalidating API key. Because the goal is to use routes that exist in
the app (`InboxPageBody` has become a part of `HomePage` and
doesn't exist on its own), we can set up HomePage and MessageListPage
instead.

Signed-off-by: Zixuan James Li <[email protected]>
The method loadPerAccount has two call sites, i.e. places
where we send register-queue requests:

1. _reloadPerAccount through [UpdateMachine._handlePollError]
2. perAccount through [PerAccountStoreWidget] (the common case)

We utilize the existing [AccountNotFoundException] because
invalidating invalid auth keys effectively logs out the account, that it
can no longer be found in the store.  [PerAccountStoreWidget] already
expects this error by ignoring it and waiting for the route to be
removed:

```dart
  try {
    // If this succeeds, globalStore will notify listeners, and
    // [didChangeDependencies] will run again, this time in the
    // `store != null` case above.
    await globalStore.perAccount(widget.accountId);
  } on AccountNotFoundException {
    // The account was logged out while its store was loading.
    // This widget will be showing [placeholder] perpetually,
    // but that's OK as long as other code will be removing it from the UI
    // (usually by using [routeToRemoveOnLogout]).
  }
```
(included because unchanged code is not in the diff)

To handle 1, we apply the same expectation that the account gets logged
out when the exception happens.  For `_handlePollError`, while the store
was not replaced at all, the end result of having the old store disposed
is still expected.

This partly addresses zulip#890 by handling authentication errors for
register-queue.

Fixes: zulip#737

Signed-off-by: Zixuan James Li <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant