Move muted threads to new persistence + context (#1838)
This commit is contained in:
parent
4afed4be28
commit
74f8390f1d
12 changed files with 95 additions and 94 deletions
|
|
@ -18,6 +18,7 @@ import {RootStoreModel} from '../root-store'
|
|||
import {PostThreadModel} from '../content/post-thread'
|
||||
import {cleanError} from 'lib/strings/errors'
|
||||
import {logger} from '#/logger'
|
||||
import {isThreadMuted} from '#/state/muted-threads'
|
||||
|
||||
const GROUPABLE_REASONS = ['like', 'repost', 'follow']
|
||||
const PAGE_SIZE = 30
|
||||
|
|
@ -550,8 +551,7 @@ export class NotificationsFeedModel {
|
|||
.filter(item => {
|
||||
const hideByLabel = item.shouldFilter
|
||||
let mutedThread = !!(
|
||||
item.reasonSubjectRootUri &&
|
||||
this.rootStore.mutedThreads.uris.has(item.reasonSubjectRootUri)
|
||||
item.reasonSubjectRootUri && isThreadMuted(item.reasonSubjectRootUri)
|
||||
)
|
||||
return !hideByLabel && !mutedThread
|
||||
})
|
||||
|
|
|
|||
|
|
@ -75,10 +75,6 @@ export class PostsFeedItemModel {
|
|||
return this.post.uri
|
||||
}
|
||||
|
||||
get isThreadMuted() {
|
||||
return this.rootStore.mutedThreads.uris.has(this.rootUri)
|
||||
}
|
||||
|
||||
get moderation(): PostModeration {
|
||||
return moderatePost(this.post, this.rootStore.preferences.moderationOpts)
|
||||
}
|
||||
|
|
@ -172,20 +168,6 @@ export class PostsFeedItemModel {
|
|||
}
|
||||
}
|
||||
|
||||
async toggleThreadMute() {
|
||||
try {
|
||||
if (this.isThreadMuted) {
|
||||
this.rootStore.mutedThreads.uris.delete(this.rootUri)
|
||||
track('Post:ThreadUnmute')
|
||||
} else {
|
||||
this.rootStore.mutedThreads.uris.add(this.rootUri)
|
||||
track('Post:ThreadMute')
|
||||
}
|
||||
} catch (error) {
|
||||
logger.error('Failed to toggle thread mute', {error})
|
||||
}
|
||||
}
|
||||
|
||||
async delete() {
|
||||
try {
|
||||
await this.rootStore.agent.deletePost(this.post.uri)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue