Properly detect thread-muted posts and set with_muted when fetching notifications #2208

Closed
rinpatch wants to merge 0 commits from gitlab-mr-iid-941 into develop
Member
No description provided.
Member

this should always be true otherwise you'll have to reload UI to get all the notifications you've been missing if you toggle that option off

this should always be true otherwise you'll have to reload UI to get all the notifications you've been missing if you toggle that option off
Member

why not both?

why not both?
Member

again, this will make old user's posts unaffected by toggling the setting, only newly fetched ones

again, this will make old user's posts unaffected by toggling the setting, only newly fetched ones
Author
Member

Well, timelines have the same logic. I don't think it should always be true because it would lead to inconsistent behavior of "Load older notifications" (e.g be returns 20 notifications but fe can't show any of them because they are from a muted thread) and would cause additional be load for no good reason. Instead the notifications should be reloaded when the option is changed, though I have no idea how to do that.

Well, timelines have the same logic. I don't think it should always be true because it would lead to inconsistent behavior of "Load older notifications" (e.g be returns 20 notifications but fe can't show any of them because they are from a muted thread) and would cause additional be load for no good reason. Instead the notifications should be reloaded when the option is changed, though I have no idea how to do that.
Author
Member

right, I will change that. Also note that old thread muted posts are not affected as well, ideally we would update the state of all posts with the same context after muting/unmuting but I have no idea where to put it.

right, I will change that. Also note that old thread muted posts are not affected as well, ideally we would update the state of all posts with the same context after muting/unmuting but I have no idea where to put it.
Member

if we had something like actual thread_muted we could probably keep a Set of muted ConversationIDs.

another option would be re-fetching the context of a post after muting and doing addNewStatuses with them.

assuming that BE will update muted property on them in timely fashion.

if we had something like actual `thread_muted` we could probably keep a Set of muted ConversationIDs. another option would be re-fetching the `context` of a post after muting and doing `addNewStatuses` with them. assuming that BE will update `muted` property on them in timely fashion.
Member

weird, that also be always true if you ask me. Loading next 20 notifications should also be accounted for hidden notifications.

if anything, such things should probably be controlled by some (new) option like "Use less data at cost of timeline consistency"

weird, that also be always true if you ask me. Loading next 20 notifications should also be accounted for hidden notifications. if anything, such things should probably be controlled by some (new) option like "Use less data at cost of timeline consistency"
Author
Member

another option would be re-fetching the context of a post after muting and doing addNewStatuses with them.

Yeah, let's do this one.

assuming that BE will update muted property on them in timely fashion.

It will, the bug that caused it not to do so is fixed and merged in master.

> another option would be re-fetching the `context` of a post after muting and doing `addNewStatuses` with them. Yeah, let's do this one. > assuming that BE will update `muted` property on them in timely fashion. It will, the bug that caused it not to do so is fixed and merged in master.
Author
Member

Actually no, the first one would probably be better. People usually mute hellthreads that have 5mb responses, so the delay will be noticeable, especially on a bad connection

Actually no, the first one would probably be better. People usually mute hellthreads that have 5mb responses, so the delay will be noticeable, especially on a bad connection
Author
Member

so, for now, should I set it to true for timelines as well, set it to true only in notifs, or leave it as is?

so, for now, should I set it to true for timelines as well, set it to true only in notifs, or leave it as is?
Member

i'd say leave it as is for consistency sake

i'd say leave it as is for consistency sake
Member

indeed.

Keeping a mutedConversationIds set should be easy, IIRC there is thread_muted in API, so when adding a post to vuex store, if post has thread_muted: true - add its conversation id to the set, if it's false - remove from it (if there's any).

in this very same line, check if that set has this conversationid or not.

indeed. Keeping a `mutedConversationIds` set should be easy, IIRC there is `thread_muted` in API, so when adding a post to vuex store, if post has `thread_muted: true` - add its conversation id to the set, if it's `false` - remove from it (if there's any). in this very same line, check if that set has this conversationid or not.
Author
Member

IIRC there is thread_muted in API

there isn't, but I will add one.

> IIRC there is `thread_muted` in API there isn't, but I will add one.
Author
Member

@hj I did just that, but because the computed properties are cached, only posts of the user who made the post on which the mute button was clicked are updated. Should this be fixed by dispatching an action to update muted in setMuted?

@hj I did just that, but because the computed properties are cached, only posts of the user who made the post on which the mute button was clicked are updated. Should this be fixed by dispatching an action to update muted in `setMuted`?
Member

to answer the question in other thread, i originally suggested using a Set, not array, since using Set (or Map or plain object with keys) would be O(1) (Set.get(key) / Map.get(key) / object[key]) instead of O(n) (findIndex(key))

Instead, since there's a problem with computed property not updating, I would suggest using conversationsObject which i forgot already exists and iterate over it like so:

newStatus.thread_muted = status.thread_muted

conversationsObject[newStatus.statusnet_conversation_id].forEach(status => status.thread_muted = newStatus.thread_muted)

or something along those lines.

to answer the question in other thread, i originally suggested using a `Set`, not array, since using `Set` (or `Map` or plain object with keys) would be O(1) (`Set.get(key)` / `Map.get(key)` / `object[key]`) instead of O(n) (`findIndex(key)`) Instead, since there's a problem with computed property not updating, I would suggest using `conversationsObject` which i forgot already exists and iterate over it like so: ```js newStatus.thread_muted = status.thread_muted conversationsObject[newStatus.statusnet_conversation_id].forEach(status => status.thread_muted = newStatus.thread_muted) ``` or something along those lines.
Author
Member

Done

Done
Member

nitpick: i'd check newStatus.thread_muted === undefined to avoid iterating if BE doesn't support thread_muted yet

nitpick: i'd check `newStatus.thread_muted === undefined` to avoid iterating if BE doesn't support thread_muted yet
Member

codewise looks good, just needs some testing with BE that supports it...

codewise looks good, just needs some testing with BE that supports it...
Author
Member

patch.cx has the extension deployed

patch.cx has the extension deployed
Member

lgtm

lgtm
Member

@rinpatch you've had this running for a while, ready to merge?

@rinpatch you've had this running for a while, ready to merge?
Author
Member

yes

yes
Author
Member

@shpuld resolved the merge conflicts.

@shpuld resolved the merge conflicts.

Pull request closed

Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
pleroma/pleroma-fe!2208
No description provided.