-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Add some improvements to thread handling #8407
base: main
Are you sure you want to change the base?
Conversation
This is kind of bad. Is that happening today? Also, I believe there is some code doing something kind of the same in the notifications area. Have we looked at how these thread gaps are different than fetching posts on a channel? Will review soon. Just wanted to add this comment before I forget. |
I would swear it does. I have not changed any logic around that.
I looked how we were adding the threads, and I was not much worried about the last_reply_at since I expected the threads to be fetch again when the app ran.
With fetching posts we have a more reliable update at (the post update at). Here we don't have such a thing right now (AFAIK). Also, since we are receiving "0 replies threads" (and therefore we have a last reply at as 0) that was messing with the bottom end of the gaps, something that would not happen with posts (the update_at is always above 0). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple non-blocking questions otherwise LGTM.
const {earliestThread, latestThread} = getThreadsListEdges(latestThreads.threads); | ||
syncDataUpdate.latest = latestThread.last_reply_at; | ||
syncDataUpdate.earliest = earliestThread.last_reply_at; | ||
syncDataUpdate.latest = latestThread.last_reply_at || latestThread.post.create_at; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we not sync data on post edits? Or is that done per post?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The thread information in the database only includes the post id, so updates in the post should not affect this piece of data (it affects the post itself, which is done somewhere else).
@@ -291,7 +291,7 @@ export const syncThreadsIfNeeded = async (serverUrl: string, isCRTEnabled: boole | |||
|
|||
if (teams?.length) { | |||
for (const team of teams) { | |||
promises.push(syncTeamThreads(serverUrl, team.id, true, true)); | |||
promises.push(syncTeamThreads(serverUrl, team.id, {excludeDirect: true, fetchOnly: true})); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious - where do we sync the DM/GM threads?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In other calls to syncTeamThreads
, where we don't pass the excludeDirect
option. Mainly on startup / reconnect, if I am not mistaken.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exclude direct is false also for the initial team, this will fetch the threads on DM's and GM's that are returned for every team if you don't set the flag as true
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me, but I still think we should look into the notifications area
@enahum I added the changes to the native side. It seems we had a bigger problem on android, since react native maps work as streams, so the moment you read from them, you cannot put more information. Therefore, we were never adding the threads to the notification data object. Copying to read is one option, but I can look for smarter solutions. |
Can you expand on this? I don't quite understand what you mean |
@enahum In order to create a map of values, we use the following:
Then, we add more values to it by calling stuff like:
And we get information out of the map with:
So... this flow works fine:
But this other one won't:
With this flow, the From what I read, this is because of how these objects work on the inside, and the keyword I remember is that they "work like streams". So... one way to fix the flow I showed you before is copying the map before accessing its values:
|
@larkox got it, maybe then we should use hashmaps or bundles instead, thoughts? |
Btw @larkox this PR now has conflict that needs resolution, perhaps that can be done while fixing the issue on Android native as well ? |
Summary
The following improvements has been added:
This should solve several issues, but mainly tackling two:
This does NOT solve the following issues:
Some of the issues may need a database purge (logout and log back in) to get fixed.
Ticket Link
Fix https://mattermost.atlassian.net/browse/MM-61759
Fix https://mattermost.atlassian.net/browse/MM-60745
Release Note