Merge pull request 'add hacky reply filtering, turn off streaming by default' (#172) from streaming-filters into develop

Reviewed-on: AkkomaGang/pleroma-fe#172
This commit is contained in:
floatingghost 2022-09-20 15:28:53 +00:00
commit 2ab223e791
2 changed files with 14 additions and 3 deletions

View file

@ -3,6 +3,16 @@ import { WSConnectionStatus } from '../services/api/api.service.js'
const retryTimeout = (multiplier) => 1000 * multiplier
const isVisible = (store, message, visibility) => {
if (visibility === 'all') {
return true
} else if (visibility === 'following') {
return store.getters.relationship(message.in_reply_to_user_id).following
} else if (visibility === 'self') {
return message.in_reply_to_user_id === store.rootState.users.currentUser.id
}
return false
}
const api = {
state: {
retryMultiplier: 1,
@ -85,20 +95,21 @@ const api = {
state.mastoUserSocket.addEventListener(
'message',
({ detail: message }) => {
const replyVisibility = rootState.config.replyVisibility
if (!message) return // pings
if (message.event === 'notification') {
dispatch('addNewNotifications', {
notifications: [message.notification],
older: false
})
} else if (message.event === 'update') {
} else if (message.event === 'update' && isVisible(store, message.status, replyVisibility)) {
dispatch('addNewStatuses', {
statuses: [message.status],
userId: false,
showImmediately: timelineData.visibleStatuses.length === 0,
timeline: 'friends'
})
} else if (message.event === 'status.update') {
} else if (message.event === 'status.update' && isVisible(store, message.status, replyVisibility)) {
dispatch('addNewStatuses', {
statuses: [message.status],
userId: false,

View file

@ -72,7 +72,7 @@ export const defaultState = {
highlight: {},
interfaceLanguage: browserLocale,
hideScopeNotice: false,
useStreamingApi: true,
useStreamingApi: false,
sidebarRight: undefined, // instance default
scopeCopy: undefined, // instance default
subjectLineBehavior: undefined, // instance default