forked from AkkomaGang/akkoma-fe
add hacky reply filtering, turn off streaming by default
This commit is contained in:
parent
42e48348ae
commit
87683052e8
2 changed files with 14 additions and 3 deletions
|
@ -3,6 +3,16 @@ import { WSConnectionStatus } from '../services/api/api.service.js'
|
||||||
|
|
||||||
const retryTimeout = (multiplier) => 1000 * multiplier
|
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 = {
|
const api = {
|
||||||
state: {
|
state: {
|
||||||
retryMultiplier: 1,
|
retryMultiplier: 1,
|
||||||
|
@ -85,20 +95,21 @@ const api = {
|
||||||
state.mastoUserSocket.addEventListener(
|
state.mastoUserSocket.addEventListener(
|
||||||
'message',
|
'message',
|
||||||
({ detail: message }) => {
|
({ detail: message }) => {
|
||||||
|
const replyVisibility = rootState.config.replyVisibility
|
||||||
if (!message) return // pings
|
if (!message) return // pings
|
||||||
if (message.event === 'notification') {
|
if (message.event === 'notification') {
|
||||||
dispatch('addNewNotifications', {
|
dispatch('addNewNotifications', {
|
||||||
notifications: [message.notification],
|
notifications: [message.notification],
|
||||||
older: false
|
older: false
|
||||||
})
|
})
|
||||||
} else if (message.event === 'update') {
|
} else if (message.event === 'update' && isVisible(store, message.status, replyVisibility)) {
|
||||||
dispatch('addNewStatuses', {
|
dispatch('addNewStatuses', {
|
||||||
statuses: [message.status],
|
statuses: [message.status],
|
||||||
userId: false,
|
userId: false,
|
||||||
showImmediately: timelineData.visibleStatuses.length === 0,
|
showImmediately: timelineData.visibleStatuses.length === 0,
|
||||||
timeline: 'friends'
|
timeline: 'friends'
|
||||||
})
|
})
|
||||||
} else if (message.event === 'status.update') {
|
} else if (message.event === 'status.update' && isVisible(store, message.status, replyVisibility)) {
|
||||||
dispatch('addNewStatuses', {
|
dispatch('addNewStatuses', {
|
||||||
statuses: [message.status],
|
statuses: [message.status],
|
||||||
userId: false,
|
userId: false,
|
||||||
|
|
|
@ -72,7 +72,7 @@ export const defaultState = {
|
||||||
highlight: {},
|
highlight: {},
|
||||||
interfaceLanguage: browserLocale,
|
interfaceLanguage: browserLocale,
|
||||||
hideScopeNotice: false,
|
hideScopeNotice: false,
|
||||||
useStreamingApi: true,
|
useStreamingApi: false,
|
||||||
sidebarRight: undefined, // instance default
|
sidebarRight: undefined, // instance default
|
||||||
scopeCopy: undefined, // instance default
|
scopeCopy: undefined, // instance default
|
||||||
subjectLineBehavior: undefined, // instance default
|
subjectLineBehavior: undefined, // instance default
|
||||||
|
|
Loading…
Reference in a new issue