Skip to content

Conversation

@nicodh
Copy link
Member

@nicodh nicodh commented Sep 18, 2025

  • Extract useDraft from composer
  • Include message store
  • MessageStore as Singleton

As discussed here #5337 (comment) "make the message list available to the shortcut handling code"
To avoid loading messages when navigation up or down when selecting messages for replyTo reuse the MessageStore which already holds the visible messages in messageCache

Special case: if there is already a quoted message in a draft, and the quoted message is not in messageCache (i.e. not visible) - we jump to that message on first shortcut event and only the next up or down will navigate to the next message.

Copy link
Member

@WofWca WofWca left a comment

Choose a reason for hiding this comment

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

I confirmed that the first commit only moves useDraft, without smuggling any other changes.
Otherwise see my comment.

Copy link
Member

@WofWca WofWca left a comment

Choose a reason for hiding this comment

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

Yes, this looks closer to what I meant. The message list buggines seems to be gone now since my last review. And yes, this seems to fix the bug this is intending to fix, despite some functionality being now lost due to the migration to the messageCache as the "source of truth" (e.g. there is now this "jump without quoting" behavior).

The commit history is messy, but I would still vote for a fast-forward merge, because otherwise it's gonna be impossible to decipher the changes to useDraft, since it has been moved.

@WofWca
Copy link
Member

WofWca commented Oct 18, 2025

About performance: for some reason it feels very sluggish, but only in dev mode. If you build frontend in prod mode, then it's very snappy!

Copy link
Member

@WofWca WofWca left a comment

Choose a reason for hiding this comment

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

Looking at the state of the code, I think we are finally (almost) ready, thanks!

As I mentioned, it would be very nice to have a separate commit for useDraft being moved to a separate file, otherwise the changes that this MR does to it are gonna be undecipherable.
However, there has been a lot of changing stuff back and forth, so it would also be nice to squash the last few commits.

If you agree with the suggestion, I could take care of that.

Comment on lines +106 to +111
const {
store: messageListStore,
state: messageListState,
fetchMoreBottom,
fetchMoreTop,
} = useMessageList(accountId, chat.id)
Copy link
Member

Choose a reason for hiding this comment

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

Maybe not destructuring these would be tidier, but alright.

@nicodh
Copy link
Member Author

nicodh commented Oct 21, 2025

As I mentioned, it would be very nice to have a separate commit for useDraft being moved to a separate file, otherwise the changes that this MR does to it are gonna be undecipherable.

But there is a separate commit for extract useDraft:
71a00f1

@WofWca
Copy link
Member

WofWca commented Oct 21, 2025

Yes, sorry, I meant that we should not squash that commit, but squash the other ones (or almost all the other ones)

@nicodh
Copy link
Member Author

nicodh commented Oct 21, 2025

Yes, sorry, I meant that we should not squash that commit, but squash the other ones (or almost all the other ones)

That means I have to merge locally or is that possible in the github UI?

@WofWca
Copy link
Member

WofWca commented Oct 21, 2025

No I don't think it's possible on GitHub, but one could squash locally and then force push to this MR.

@nicodh nicodh force-pushed the extract-usedraft-hook branch from 41917a8 to 047f845 Compare October 21, 2025 19:59
@nicodh nicodh merged commit b0693c6 into main Oct 21, 2025
10 checks passed
@nicodh nicodh deleted the extract-usedraft-hook branch October 21, 2025 20:33
@nicodh
Copy link
Member Author

nicodh commented Oct 21, 2025

No I don't think it's possible on GitHub, but one could squash locally and then force push to this MR.

Damn, I just wanted to expand the "Squash & Merge button" to select the other option and then it just squashed an merged it immediately. Bad UI!

@WofWca
Copy link
Member

WofWca commented Oct 22, 2025

FTR we force-pushed. This is merged as 6fc4777 (and the parent commit).

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