From 87683052e8e3af60a1ab004644ecfbb95bf1e3eb Mon Sep 17 00:00:00 2001 From: FloatingGhost Date: Tue, 20 Sep 2022 16:27:17 +0100 Subject: [PATCH] add hacky reply filtering, turn off streaming by default --- src/modules/api.js | 15 +++++++++++++-- src/modules/config.js | 2 +- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/modules/api.js b/src/modules/api.js index 6c896c79..1003a3f5 100644 --- a/src/modules/api.js +++ b/src/modules/api.js @@ -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, diff --git a/src/modules/config.js b/src/modules/config.js index e0530101..2934f2c5 100644 --- a/src/modules/config.js +++ b/src/modules/config.js @@ -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