nextcloud / spreed

🗨️ Nextcloud Talk – chat, video & audio calls for Nextcloud
https://nextcloud.com/talk
GNU Affero General Public License v3.0
1.59k stars 422 forks source link

Cache conversation messages to speed up conversation display #11605

Open vagner-dias opened 5 months ago

vagner-dias commented 5 months ago

Presently, the current version of the Nextcloud desktop client lacks conversation caching, resulting in a delay when users click on a conversation.

Enhancing the user experience would involve enabling users to click on a conversation without having to wait for it to load. Instead, the conversation should be promptly displayed upon the user's click.

ShGKme commented 4 months ago

A possible solution could be to cache conversations in IndexedDB and broadcast updates to other tabs, similar to the conversation list.

The complex part here would be as usual — cache invalidation:

When the client is loaded, it should somehow get updates about the messages from the cache that are to be updated or deleted. For example, always fetch conversation messages on open as currently, using cache only to optimize initial rendering and multi-tabs.

nickvergessen commented 4 months ago

When the client is loaded, it should somehow get updates about the messages from the cache that are to be updated or deleted.

There are hidden system messages being sent having the modified/deleted message as parent, because that is how the iOS app handles it.

ShGKme commented 4 months ago

There are hidden system messages being sent having the modified/deleted message as parent, because that is how the iOS app handles it.

So, fetching new messages will inform about deleting/modifying old messages, poll changes (and reactions?). Then there is not this complex part, doable.

SystemKeeper commented 4 months ago

[...] (and reactions?).

Yep. These are the messages we currently consider an "update message": https://github.com/nextcloud/talk-ios/blob/c53dd7b6cb05d793a542d2ca3ed69c5ac98e2933/NextcloudTalk/NCChatMessage.m#L254-L262

When we receive such a message, we update the corresponding message and the quotes of that message, see https://github.com/nextcloud/talk-ios/blob/c53dd7b6cb05d793a542d2ca3ed69c5ac98e2933/NextcloudTalk/BaseChatViewController.swift#L579-L614