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

refactor: fix message list potentially being empty #4556

Merged
merged 2 commits into from
Jan 29, 2025

Conversation

WofWca
Copy link
Collaborator

@WofWca WofWca commented Jan 25, 2025

...sometimes.
And maybe sometimes showing messages from previous chat.

I have not been able to confirm whether this fixes
an actual bug.
But at least in my understanding this fixes a semantic error.

The presence of the error is obvious if you make
store.effect.loadChat() synchronous.
So, what could be happening is that loadChat finishes before
we subscribe to the new store instance,
and thus the state never gets updated,
at least not until the next store update, which could be e.g.
fetchMoreMessagesTop.

The second commit also appears to be just a refactor.

@WofWca WofWca force-pushed the wofwca/fix-message-list-empty branch from 1f23de5 to 3e412ad Compare January 25, 2025 10:34
@WofWca WofWca force-pushed the wofwca/fix-message-list-empty branch from 3e412ad to cbc5444 Compare January 25, 2025 10:57
@WofWca WofWca force-pushed the wofwca/fix-message-list-empty branch from cbc5444 to ec81292 Compare January 25, 2025 12:29
@WofWca WofWca changed the title fix: message list being empty (store.subscribe) refactor: fix message list potentially being empty Jan 25, 2025
@WofWca WofWca marked this pull request as ready for review January 25, 2025 12:37
@WofWca WofWca force-pushed the wofwca/fix-message-list-empty branch from ec81292 to 4da4970 Compare January 25, 2025 14:12
Copy link
Member

@nicodh nicodh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me and seems to make sense, although I would prefery to get this approved by @Simon-Laux since I'm not too familiar with the message store behaviour in detail

@WofWca WofWca requested a review from Simon-Laux January 29, 2025 10:10
Copy link
Member

@Simon-Laux Simon-Laux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code looks like it makes sense

...sometimes.
And maybe sometimes showing messages from previous chat.

I have not been able to confirm whether this fixes
an actual bug.
But at least in my understanding this fixes a semantic error.

The presence of the error is obvious if you make
`store.effect.loadChat()` synchronous.
So, what could be happening is that `loadChat` finishes _before_
we subscribe to the new store instance,
and thus the state never gets updated,
at least not until the next store update, which could be e.g.
`fetchMoreMessagesTop`.
Currently it appears that `useStore` is not really used with
an argument that can change, so this is just a refactor
and not a fix.

See previous commit (the messagelist.ts change,
`setState(store.getState())`).
@WofWca WofWca force-pushed the wofwca/fix-message-list-empty branch from 4da4970 to bde1567 Compare January 29, 2025 14:18
@WofWca WofWca merged commit 46a7331 into main Jan 29, 2025
8 of 9 checks passed
@WofWca WofWca deleted the wofwca/fix-message-list-empty branch January 29, 2025 14:18
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.

3 participants