From 50bb8865c57d098a66aafedf9c64878d8e39dba0 Mon Sep 17 00:00:00 2001 From: Maksim Pechnikov Date: Wed, 18 Dec 2019 21:17:06 +0300 Subject: [PATCH 01/22] dd --- local.json | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 local.json diff --git a/local.json b/local.json new file mode 100644 index 00000000..e9f4df0b --- /dev/null +++ b/local.json @@ -0,0 +1,4 @@ +{ + "target": "https://aqueous-sea-10253.herokuapp.com/", + "staticConfigPreference": false +} From 2d914c331eea5f5b9036e10ef3d937628891b9e1 Mon Sep 17 00:00:00 2001 From: Shpuld Shpuldson Date: Wed, 2 Sep 2020 20:40:47 +0300 Subject: [PATCH 02/22] replace setInterval for timelne, notifications and follow requests --- src/modules/api.js | 2 +- src/services/fetcher/fetcher.js | 23 +++++++++++++++++++ .../follow_request_fetcher.service.js | 4 ++-- .../notifications_fetcher.service.js | 7 +++--- .../timeline_fetcher.service.js | 7 +++--- 5 files changed, 34 insertions(+), 9 deletions(-) create mode 100644 src/services/fetcher/fetcher.js diff --git a/src/modules/api.js b/src/modules/api.js index 5e213f0d..7ddd8dde 100644 --- a/src/modules/api.js +++ b/src/modules/api.js @@ -20,7 +20,7 @@ const api = { state.fetchers[fetcherName] = fetcher }, removeFetcher (state, { fetcherName, fetcher }) { - window.clearInterval(fetcher) + state.fetchers[fetcherName]() delete state.fetchers[fetcherName] }, setWsToken (state, token) { diff --git a/src/services/fetcher/fetcher.js b/src/services/fetcher/fetcher.js new file mode 100644 index 00000000..1d9239cc --- /dev/null +++ b/src/services/fetcher/fetcher.js @@ -0,0 +1,23 @@ + +export const makeFetcher = (call, interval) => { + let stopped = false + let timeout = null + let func = () => {} + + func = () => { + call().finally(() => { + console.log('callbacks') + if (stopped) return + timeout = window.setTimeout(func, interval) + }) + } + + const stopFetcher = () => { + stopped = true + window.cancelTimeout(timeout) + } + + func() + + return stopFetcher +} diff --git a/src/services/follow_request_fetcher/follow_request_fetcher.service.js b/src/services/follow_request_fetcher/follow_request_fetcher.service.js index 93fac9bc..8d1aba7b 100644 --- a/src/services/follow_request_fetcher/follow_request_fetcher.service.js +++ b/src/services/follow_request_fetcher/follow_request_fetcher.service.js @@ -1,4 +1,5 @@ import apiService from '../api/api.service.js' +import { makeFetcher } from '../fetcher/fetcher.js' const fetchAndUpdate = ({ store, credentials }) => { return apiService.fetchFollowRequests({ credentials }) @@ -10,9 +11,8 @@ const fetchAndUpdate = ({ store, credentials }) => { } const startFetching = ({ credentials, store }) => { - fetchAndUpdate({ credentials, store }) const boundFetchAndUpdate = () => fetchAndUpdate({ credentials, store }) - return setInterval(boundFetchAndUpdate, 10000) + return makeFetcher(boundFetchAndUpdate, 10000) } const followRequestFetcher = { diff --git a/src/services/notifications_fetcher/notifications_fetcher.service.js b/src/services/notifications_fetcher/notifications_fetcher.service.js index 80be02ca..2a3a17be 100644 --- a/src/services/notifications_fetcher/notifications_fetcher.service.js +++ b/src/services/notifications_fetcher/notifications_fetcher.service.js @@ -1,4 +1,5 @@ import apiService from '../api/api.service.js' +import makeFetcher from '../fetcher/fetcher.js' const update = ({ store, notifications, older }) => { store.dispatch('setNotificationsError', { value: false }) @@ -39,6 +40,7 @@ const fetchAndUpdate = ({ store, credentials, older = false }) => { args['since'] = Math.max(...readNotifsIds) fetchNotifications({ store, args, older }) } + return result } } @@ -53,13 +55,12 @@ const fetchNotifications = ({ store, args, older }) => { } const startFetching = ({ credentials, store }) => { - fetchAndUpdate({ credentials, store }) - const boundFetchAndUpdate = () => fetchAndUpdate({ credentials, store }) // Initially there's set flag to silence all desktop notifications so // that there won't spam of them when user just opened up the FE we // reset that flag after a while to show new notifications once again. setTimeout(() => store.dispatch('setNotificationsSilence', false), 10000) - return setInterval(boundFetchAndUpdate, 10000) + const boundFetchAndUpdate = () => fetchAndUpdate({ credentials, store, refetch: true }) + return makeFetcher(boundFetchAndUpdate, 10000) } const notificationsFetcher = { diff --git a/src/services/timeline_fetcher/timeline_fetcher.service.js b/src/services/timeline_fetcher/timeline_fetcher.service.js index d0cddf84..8bbec2c7 100644 --- a/src/services/timeline_fetcher/timeline_fetcher.service.js +++ b/src/services/timeline_fetcher/timeline_fetcher.service.js @@ -1,6 +1,7 @@ import { camelCase } from 'lodash' import apiService from '../api/api.service.js' +import { makeFetcher } from '../fetcher/fetcher.js' const update = ({ store, statuses, timeline, showImmediately, userId, pagination }) => { const ccTimeline = camelCase(timeline) @@ -70,9 +71,9 @@ const startFetching = ({ timeline = 'friends', credentials, store, userId = fals const timelineData = rootState.statuses.timelines[camelCase(timeline)] const showImmediately = timelineData.visibleStatuses.length === 0 timelineData.userId = userId - fetchAndUpdate({ timeline, credentials, store, showImmediately, userId, tag }) - const boundFetchAndUpdate = () => fetchAndUpdate({ timeline, credentials, store, userId, tag }) - return setInterval(boundFetchAndUpdate, 10000) + const boundFetchAndUpdate = () => + fetchAndUpdate({ timeline, credentials, store, showImmediately, userId, tag }) + return makeFetcher(boundFetchAndUpdate, 10000) } const timelineFetcher = { fetchAndUpdate, From 1b6eee049700f6fbb0c2e43877ead3ef4cf3041b Mon Sep 17 00:00:00 2001 From: Shpuld Shpuldson Date: Wed, 2 Sep 2020 21:01:31 +0300 Subject: [PATCH 03/22] change chats to use custom makeFetcher --- src/components/chat/chat.js | 5 +++-- src/modules/chats.js | 11 +++++------ src/services/fetcher/fetcher.js | 3 +-- .../notifications_fetcher.service.js | 2 +- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/components/chat/chat.js b/src/components/chat/chat.js index 9c4e5b05..2062643d 100644 --- a/src/components/chat/chat.js +++ b/src/components/chat/chat.js @@ -5,6 +5,7 @@ import ChatMessage from '../chat_message/chat_message.vue' import PostStatusForm from '../post_status_form/post_status_form.vue' import ChatTitle from '../chat_title/chat_title.vue' import chatService from '../../services/chat_service/chat_service.js' +import { makeFetcher } from '../../services/fetcher/fetcher.js' import { getScrollPosition, getNewTopPosition, isBottomedOut, scrollableContainerHeight } from './chat_layout_utils.js' const BOTTOMED_OUT_OFFSET = 10 @@ -246,7 +247,7 @@ const Chat = { const fetchOlderMessages = !!maxId const sinceId = fetchLatest && chatMessageService.lastMessage && chatMessageService.lastMessage.id - this.backendInteractor.chatMessages({ id: chatId, maxId, sinceId }) + return this.backendInteractor.chatMessages({ id: chatId, maxId, sinceId }) .then((messages) => { // Clear the current chat in case we're recovering from a ws connection loss. if (isFirstFetch) { @@ -287,7 +288,7 @@ const Chat = { }, doStartFetching () { this.$store.dispatch('startFetchingCurrentChat', { - fetcher: () => setInterval(() => this.fetchChat({ fetchLatest: true }), 5000) + fetcher: () => makeFetcher(() => this.fetchChat({ fetchLatest: true }), 5000) }) this.fetchChat({ isFirstFetch: true }) }, diff --git a/src/modules/chats.js b/src/modules/chats.js index c7609018..45e4bdcc 100644 --- a/src/modules/chats.js +++ b/src/modules/chats.js @@ -3,6 +3,7 @@ import { find, omitBy, orderBy, sumBy } from 'lodash' import chatService from '../services/chat_service/chat_service.js' import { parseChat, parseChatMessage } from '../services/entity_normalizer/entity_normalizer.service.js' import { maybeShowChatNotification } from '../services/chat_utils/chat_utils.js' +import { makeFetcher } from '../services/fetcher/fetcher.js' const emptyChatList = () => ({ data: [], @@ -42,12 +43,10 @@ const chats = { actions: { // Chat list startFetchingChats ({ dispatch, commit }) { - const fetcher = () => { - dispatch('fetchChats', { latest: true }) - } + const fetcher = () => dispatch('fetchChats', { latest: true }) fetcher() commit('setChatListFetcher', { - fetcher: () => setInterval(() => { fetcher() }, 5000) + fetcher: () => makeFetcher(fetcher, 5000) }) }, stopFetchingChats ({ commit }) { @@ -113,14 +112,14 @@ const chats = { setChatListFetcher (state, { commit, fetcher }) { const prevFetcher = state.chatListFetcher if (prevFetcher) { - clearInterval(prevFetcher) + prevFetcher() } state.chatListFetcher = fetcher && fetcher() }, setCurrentChatFetcher (state, { fetcher }) { const prevFetcher = state.fetcher if (prevFetcher) { - clearInterval(prevFetcher) + prevFetcher() } state.fetcher = fetcher && fetcher() }, diff --git a/src/services/fetcher/fetcher.js b/src/services/fetcher/fetcher.js index 1d9239cc..95b8c9d3 100644 --- a/src/services/fetcher/fetcher.js +++ b/src/services/fetcher/fetcher.js @@ -6,7 +6,6 @@ export const makeFetcher = (call, interval) => { func = () => { call().finally(() => { - console.log('callbacks') if (stopped) return timeout = window.setTimeout(func, interval) }) @@ -14,7 +13,7 @@ export const makeFetcher = (call, interval) => { const stopFetcher = () => { stopped = true - window.cancelTimeout(timeout) + window.clearTimeout(timeout) } func() diff --git a/src/services/notifications_fetcher/notifications_fetcher.service.js b/src/services/notifications_fetcher/notifications_fetcher.service.js index 2a3a17be..c69d5b17 100644 --- a/src/services/notifications_fetcher/notifications_fetcher.service.js +++ b/src/services/notifications_fetcher/notifications_fetcher.service.js @@ -1,5 +1,5 @@ import apiService from '../api/api.service.js' -import makeFetcher from '../fetcher/fetcher.js' +import { makeFetcher } from '../fetcher/fetcher.js' const update = ({ store, notifications, older }) => { store.dispatch('setNotificationsError', { value: false }) From d939f2ffbcb632361a0362f0f2049f99160dee64 Mon Sep 17 00:00:00 2001 From: Shpuld Shpuldson Date: Wed, 2 Sep 2020 21:08:06 +0300 Subject: [PATCH 04/22] document makeFetcher a bit --- src/services/fetcher/fetcher.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/services/fetcher/fetcher.js b/src/services/fetcher/fetcher.js index 95b8c9d3..5a6ed4b8 100644 --- a/src/services/fetcher/fetcher.js +++ b/src/services/fetcher/fetcher.js @@ -1,11 +1,17 @@ -export const makeFetcher = (call, interval) => { +// makeFetcher - replacement for setInterval for fetching, starts counting +// the interval only after a request is done instead of immediately. +// promiseCall is a function that returns a promise, it's called when created +// and after every interval. +// interval is the interval delay in ms. + +export const makeFetcher = (promiseCall, interval) => { let stopped = false let timeout = null let func = () => {} func = () => { - call().finally(() => { + promiseCall().finally(() => { if (stopped) return timeout = window.setTimeout(func, interval) }) From 4d080a1654ff56e9875c49486457a1ac8e19297e Mon Sep 17 00:00:00 2001 From: Shpuld Shpuldson Date: Wed, 2 Sep 2020 21:26:02 +0300 Subject: [PATCH 05/22] add mention to changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 675c4b5b..e5521b83 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Changed - Polls will be hidden with status content if "Collapse posts with subjects" is enabled and the post is collapsed. +### Fixed +- Network fetches don't pile up anymore but wait for previous ones to finish to reduce throttling. + ## [2.1.0] - 2020-08-28 ### Added - Autocomplete domains from list of known instances From 5b403ba7d13eaf851ae43e814c583ceb018e2d20 Mon Sep 17 00:00:00 2001 From: Shpuld Shpuldson Date: Wed, 2 Sep 2020 22:12:50 +0300 Subject: [PATCH 06/22] fix timeline showimmediately being set wrongly --- src/services/fetcher/fetcher.js | 8 ++++---- .../follow_request_fetcher.service.js | 1 + .../notifications_fetcher.service.js | 3 ++- src/services/timeline_fetcher/timeline_fetcher.service.js | 3 ++- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/services/fetcher/fetcher.js b/src/services/fetcher/fetcher.js index 5a6ed4b8..aae1c2cc 100644 --- a/src/services/fetcher/fetcher.js +++ b/src/services/fetcher/fetcher.js @@ -1,9 +1,9 @@ // makeFetcher - replacement for setInterval for fetching, starts counting // the interval only after a request is done instead of immediately. -// promiseCall is a function that returns a promise, it's called when created -// and after every interval. -// interval is the interval delay in ms. +// - promiseCall is a function that returns a promise, it's called the first +// time after the first interval. +// - interval is the interval delay in ms. export const makeFetcher = (promiseCall, interval) => { let stopped = false @@ -22,7 +22,7 @@ export const makeFetcher = (promiseCall, interval) => { window.clearTimeout(timeout) } - func() + timeout = window.setTimeout(func, interval) return stopFetcher } diff --git a/src/services/follow_request_fetcher/follow_request_fetcher.service.js b/src/services/follow_request_fetcher/follow_request_fetcher.service.js index 8d1aba7b..bec434aa 100644 --- a/src/services/follow_request_fetcher/follow_request_fetcher.service.js +++ b/src/services/follow_request_fetcher/follow_request_fetcher.service.js @@ -12,6 +12,7 @@ const fetchAndUpdate = ({ store, credentials }) => { const startFetching = ({ credentials, store }) => { const boundFetchAndUpdate = () => fetchAndUpdate({ credentials, store }) + boundFetchAndUpdate() return makeFetcher(boundFetchAndUpdate, 10000) } diff --git a/src/services/notifications_fetcher/notifications_fetcher.service.js b/src/services/notifications_fetcher/notifications_fetcher.service.js index c69d5b17..90988fc4 100644 --- a/src/services/notifications_fetcher/notifications_fetcher.service.js +++ b/src/services/notifications_fetcher/notifications_fetcher.service.js @@ -59,7 +59,8 @@ const startFetching = ({ credentials, store }) => { // that there won't spam of them when user just opened up the FE we // reset that flag after a while to show new notifications once again. setTimeout(() => store.dispatch('setNotificationsSilence', false), 10000) - const boundFetchAndUpdate = () => fetchAndUpdate({ credentials, store, refetch: true }) + const boundFetchAndUpdate = () => fetchAndUpdate({ credentials, store }) + boundFetchAndUpdate() return makeFetcher(boundFetchAndUpdate, 10000) } diff --git a/src/services/timeline_fetcher/timeline_fetcher.service.js b/src/services/timeline_fetcher/timeline_fetcher.service.js index 8bbec2c7..9f585f68 100644 --- a/src/services/timeline_fetcher/timeline_fetcher.service.js +++ b/src/services/timeline_fetcher/timeline_fetcher.service.js @@ -71,8 +71,9 @@ const startFetching = ({ timeline = 'friends', credentials, store, userId = fals const timelineData = rootState.statuses.timelines[camelCase(timeline)] const showImmediately = timelineData.visibleStatuses.length === 0 timelineData.userId = userId + fetchAndUpdate({ timeline, credentials, store, showImmediately, userId, tag }) const boundFetchAndUpdate = () => - fetchAndUpdate({ timeline, credentials, store, showImmediately, userId, tag }) + fetchAndUpdate({ timeline, credentials, store, userId, tag }) return makeFetcher(boundFetchAndUpdate, 10000) } const timelineFetcher = { From 3fb35e8123d3a8cd151571b315b7ec4d7e0875c7 Mon Sep 17 00:00:00 2001 From: Shpuld Shpuldson Date: Fri, 4 Sep 2020 11:19:53 +0300 Subject: [PATCH 07/22] rename to promiseInterval --- src/components/chat/chat.js | 4 ++-- src/modules/api.js | 2 +- src/modules/chats.js | 4 ++-- .../follow_request_fetcher.service.js | 4 ++-- .../notifications_fetcher.service.js | 4 ++-- .../fetcher.js => promise_interval/promise_interval.js} | 8 ++++---- src/services/timeline_fetcher/timeline_fetcher.service.js | 4 ++-- 7 files changed, 15 insertions(+), 15 deletions(-) rename src/services/{fetcher/fetcher.js => promise_interval/promise_interval.js} (68%) diff --git a/src/components/chat/chat.js b/src/components/chat/chat.js index 2062643d..15123885 100644 --- a/src/components/chat/chat.js +++ b/src/components/chat/chat.js @@ -5,7 +5,7 @@ import ChatMessage from '../chat_message/chat_message.vue' import PostStatusForm from '../post_status_form/post_status_form.vue' import ChatTitle from '../chat_title/chat_title.vue' import chatService from '../../services/chat_service/chat_service.js' -import { makeFetcher } from '../../services/fetcher/fetcher.js' +import { promiseInterval } from '../../services/promise_interval/promise_interval.js' import { getScrollPosition, getNewTopPosition, isBottomedOut, scrollableContainerHeight } from './chat_layout_utils.js' const BOTTOMED_OUT_OFFSET = 10 @@ -288,7 +288,7 @@ const Chat = { }, doStartFetching () { this.$store.dispatch('startFetchingCurrentChat', { - fetcher: () => makeFetcher(() => this.fetchChat({ fetchLatest: true }), 5000) + fetcher: () => promiseInterval(() => this.fetchChat({ fetchLatest: true }), 5000) }) this.fetchChat({ isFirstFetch: true }) }, diff --git a/src/modules/api.js b/src/modules/api.js index 7ddd8dde..73511442 100644 --- a/src/modules/api.js +++ b/src/modules/api.js @@ -20,7 +20,7 @@ const api = { state.fetchers[fetcherName] = fetcher }, removeFetcher (state, { fetcherName, fetcher }) { - state.fetchers[fetcherName]() + state.fetchers[fetcherName].stop() delete state.fetchers[fetcherName] }, setWsToken (state, token) { diff --git a/src/modules/chats.js b/src/modules/chats.js index 45e4bdcc..60273a44 100644 --- a/src/modules/chats.js +++ b/src/modules/chats.js @@ -3,7 +3,7 @@ import { find, omitBy, orderBy, sumBy } from 'lodash' import chatService from '../services/chat_service/chat_service.js' import { parseChat, parseChatMessage } from '../services/entity_normalizer/entity_normalizer.service.js' import { maybeShowChatNotification } from '../services/chat_utils/chat_utils.js' -import { makeFetcher } from '../services/fetcher/fetcher.js' +import { promiseInterval } from '../services/promise_interval/promise_interval.js' const emptyChatList = () => ({ data: [], @@ -46,7 +46,7 @@ const chats = { const fetcher = () => dispatch('fetchChats', { latest: true }) fetcher() commit('setChatListFetcher', { - fetcher: () => makeFetcher(fetcher, 5000) + fetcher: () => promiseInterval(fetcher, 5000) }) }, stopFetchingChats ({ commit }) { diff --git a/src/services/follow_request_fetcher/follow_request_fetcher.service.js b/src/services/follow_request_fetcher/follow_request_fetcher.service.js index bec434aa..74af4081 100644 --- a/src/services/follow_request_fetcher/follow_request_fetcher.service.js +++ b/src/services/follow_request_fetcher/follow_request_fetcher.service.js @@ -1,5 +1,5 @@ import apiService from '../api/api.service.js' -import { makeFetcher } from '../fetcher/fetcher.js' +import { promiseInterval } from '../promise_interval/promise_interval.js' const fetchAndUpdate = ({ store, credentials }) => { return apiService.fetchFollowRequests({ credentials }) @@ -13,7 +13,7 @@ const fetchAndUpdate = ({ store, credentials }) => { const startFetching = ({ credentials, store }) => { const boundFetchAndUpdate = () => fetchAndUpdate({ credentials, store }) boundFetchAndUpdate() - return makeFetcher(boundFetchAndUpdate, 10000) + return promiseInterval(boundFetchAndUpdate, 10000) } const followRequestFetcher = { diff --git a/src/services/notifications_fetcher/notifications_fetcher.service.js b/src/services/notifications_fetcher/notifications_fetcher.service.js index 90988fc4..c908b644 100644 --- a/src/services/notifications_fetcher/notifications_fetcher.service.js +++ b/src/services/notifications_fetcher/notifications_fetcher.service.js @@ -1,5 +1,5 @@ import apiService from '../api/api.service.js' -import { makeFetcher } from '../fetcher/fetcher.js' +import { promiseInterval } from '../promise_interval/promise_interval.js' const update = ({ store, notifications, older }) => { store.dispatch('setNotificationsError', { value: false }) @@ -61,7 +61,7 @@ const startFetching = ({ credentials, store }) => { setTimeout(() => store.dispatch('setNotificationsSilence', false), 10000) const boundFetchAndUpdate = () => fetchAndUpdate({ credentials, store }) boundFetchAndUpdate() - return makeFetcher(boundFetchAndUpdate, 10000) + return promiseInterval(boundFetchAndUpdate, 10000) } const notificationsFetcher = { diff --git a/src/services/fetcher/fetcher.js b/src/services/promise_interval/promise_interval.js similarity index 68% rename from src/services/fetcher/fetcher.js rename to src/services/promise_interval/promise_interval.js index aae1c2cc..ee46a236 100644 --- a/src/services/fetcher/fetcher.js +++ b/src/services/promise_interval/promise_interval.js @@ -1,11 +1,11 @@ -// makeFetcher - replacement for setInterval for fetching, starts counting -// the interval only after a request is done instead of immediately. +// promiseInterval - replacement for setInterval for promises, starts counting +// the interval only after a promise is done instead of immediately. // - promiseCall is a function that returns a promise, it's called the first // time after the first interval. // - interval is the interval delay in ms. -export const makeFetcher = (promiseCall, interval) => { +export const promiseInterval = (promiseCall, interval) => { let stopped = false let timeout = null let func = () => {} @@ -24,5 +24,5 @@ export const makeFetcher = (promiseCall, interval) => { timeout = window.setTimeout(func, interval) - return stopFetcher + return { stop: stopFetcher } } diff --git a/src/services/timeline_fetcher/timeline_fetcher.service.js b/src/services/timeline_fetcher/timeline_fetcher.service.js index 9f585f68..72ea4890 100644 --- a/src/services/timeline_fetcher/timeline_fetcher.service.js +++ b/src/services/timeline_fetcher/timeline_fetcher.service.js @@ -1,7 +1,7 @@ import { camelCase } from 'lodash' import apiService from '../api/api.service.js' -import { makeFetcher } from '../fetcher/fetcher.js' +import { promiseInterval } from '../promise_interval/promise_interval.js' const update = ({ store, statuses, timeline, showImmediately, userId, pagination }) => { const ccTimeline = camelCase(timeline) @@ -74,7 +74,7 @@ const startFetching = ({ timeline = 'friends', credentials, store, userId = fals fetchAndUpdate({ timeline, credentials, store, showImmediately, userId, tag }) const boundFetchAndUpdate = () => fetchAndUpdate({ timeline, credentials, store, userId, tag }) - return makeFetcher(boundFetchAndUpdate, 10000) + return promiseInterval(boundFetchAndUpdate, 10000) } const timelineFetcher = { fetchAndUpdate, From c89ac79140e059f89d4da88ce49c9bb24db4cc20 Mon Sep 17 00:00:00 2001 From: Shpuld Shpuldson Date: Fri, 4 Sep 2020 11:22:14 +0300 Subject: [PATCH 08/22] fix chat fetcher stops, change fetcher code --- src/modules/chats.js | 4 ++-- src/services/promise_interval/promise_interval.js | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/modules/chats.js b/src/modules/chats.js index 60273a44..8e2fabb6 100644 --- a/src/modules/chats.js +++ b/src/modules/chats.js @@ -112,14 +112,14 @@ const chats = { setChatListFetcher (state, { commit, fetcher }) { const prevFetcher = state.chatListFetcher if (prevFetcher) { - prevFetcher() + prevFetcher.stop() } state.chatListFetcher = fetcher && fetcher() }, setCurrentChatFetcher (state, { fetcher }) { const prevFetcher = state.fetcher if (prevFetcher) { - prevFetcher() + prevFetcher.stop() } state.fetcher = fetcher && fetcher() }, diff --git a/src/services/promise_interval/promise_interval.js b/src/services/promise_interval/promise_interval.js index ee46a236..cf17970d 100644 --- a/src/services/promise_interval/promise_interval.js +++ b/src/services/promise_interval/promise_interval.js @@ -8,9 +8,8 @@ export const promiseInterval = (promiseCall, interval) => { let stopped = false let timeout = null - let func = () => {} - func = () => { + const func = () => { promiseCall().finally(() => { if (stopped) return timeout = window.setTimeout(func, interval) From 947d7cd6f285c7c683b92f79d9d2c08dd2131f5d Mon Sep 17 00:00:00 2001 From: Maksim Pechnikov Date: Mon, 7 Sep 2020 14:27:37 +0300 Subject: [PATCH 09/22] added import/export mutes --- local.json | 4 --- .../tabs/data_import_export_tab.js | 28 ++++++++++++++----- .../tabs/data_import_export_tab.vue | 17 +++++++++++ src/i18n/en.json | 6 ++++ src/services/api/api.service.js | 13 +++++++++ 5 files changed, 57 insertions(+), 11 deletions(-) delete mode 100644 local.json diff --git a/local.json b/local.json deleted file mode 100644 index e9f4df0b..00000000 --- a/local.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "target": "https://aqueous-sea-10253.herokuapp.com/", - "staticConfigPreference": false -} diff --git a/src/components/settings_modal/tabs/data_import_export_tab.js b/src/components/settings_modal/tabs/data_import_export_tab.js index 168f89e1..f4b736d2 100644 --- a/src/components/settings_modal/tabs/data_import_export_tab.js +++ b/src/components/settings_modal/tabs/data_import_export_tab.js @@ -1,6 +1,7 @@ import Importer from 'src/components/importer/importer.vue' import Exporter from 'src/components/exporter/exporter.vue' import Checkbox from 'src/components/checkbox/checkbox.vue' +import { mapState } from 'vuex' const DataImportExportTab = { data () { @@ -18,21 +19,26 @@ const DataImportExportTab = { Checkbox }, computed: { - user () { - return this.$store.state.users.currentUser - } + ...mapState({ + backendInteractor: (state) => state.api.backendInteractor, + user: (state) => state.users.currentUser + }) }, methods: { getFollowsContent () { - return this.$store.state.api.backendInteractor.exportFriends({ id: this.$store.state.users.currentUser.id }) + return this.backendInteractor.exportFriends({ id: this.user.id }) .then(this.generateExportableUsersContent) }, getBlocksContent () { - return this.$store.state.api.backendInteractor.fetchBlocks() + return this.backendInteractor.fetchBlocks() + .then(this.generateExportableUsersContent) + }, + getMutesContent () { + return this.backendInteractor.fetchMutes() .then(this.generateExportableUsersContent) }, importFollows (file) { - return this.$store.state.api.backendInteractor.importFollows({ file }) + return this.backendInteractor.importFollows({ file }) .then((status) => { if (!status) { throw new Error('failed') @@ -40,7 +46,15 @@ const DataImportExportTab = { }) }, importBlocks (file) { - return this.$store.state.api.backendInteractor.importBlocks({ file }) + return this.backendInteractor.importBlocks({ file }) + .then((status) => { + if (!status) { + throw new Error('failed') + } + }) + }, + importMutes (file) { + return this.backendInteractor.importMutes({ file }) .then((status) => { if (!status) { throw new Error('failed') diff --git a/src/components/settings_modal/tabs/data_import_export_tab.vue b/src/components/settings_modal/tabs/data_import_export_tab.vue index b5d0f5ed..a406077d 100644 --- a/src/components/settings_modal/tabs/data_import_export_tab.vue +++ b/src/components/settings_modal/tabs/data_import_export_tab.vue @@ -36,6 +36,23 @@ :export-button-label="$t('settings.block_export_button')" /> +
+

{{ $t('settings.mute_import') }}

+

{{ $t('settings.import_mutes_from_a_csv_file') }}

+ +
+
+

{{ $t('settings.mute_export') }}

+ +
diff --git a/src/i18n/en.json b/src/i18n/en.json index 8540f551..cf0a7e7c 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -276,6 +276,12 @@ "block_import": "Block import", "block_import_error": "Error importing blocks", "blocks_imported": "Blocks imported! Processing them will take a while.", + "mute_export": "Mute export", + "mute_export_button": "Export your mutes to a csv file", + "mute_import": "Mute import", + "mute_import_error": "Error importing mutes", + "mutes_imported": "Mutes imported! Processing them will take a while.", + "import_mutes_from_a_csv_file": "Import mutes from a csv file", "blocks_tab": "Blocks", "bot": "This is a bot account", "btnRadius": "Buttons", diff --git a/src/services/api/api.service.js b/src/services/api/api.service.js index da519001..34f86f93 100644 --- a/src/services/api/api.service.js +++ b/src/services/api/api.service.js @@ -3,6 +3,7 @@ import { parseStatus, parseUser, parseNotification, parseAttachment, parseChat, import { RegistrationError, StatusCodeError } from '../errors/errors' /* eslint-env browser */ +const MUTES_IMPORT_URL = '/api/pleroma/mutes_import' const BLOCKS_IMPORT_URL = '/api/pleroma/blocks_import' const FOLLOW_IMPORT_URL = '/api/pleroma/follow_import' const DELETE_ACCOUNT_URL = '/api/pleroma/delete_account' @@ -710,6 +711,17 @@ const setMediaDescription = ({ id, description, credentials }) => { }).then((data) => parseAttachment(data)) } +const importMutes = ({ file, credentials }) => { + const formData = new FormData() + formData.append('list', file) + return fetch(MUTES_IMPORT_URL, { + body: formData, + method: 'POST', + headers: authHeaders(credentials) + }) + .then((response) => response.ok) +} + const importBlocks = ({ file, credentials }) => { const formData = new FormData() formData.append('list', file) @@ -1280,6 +1292,7 @@ const apiService = { getCaptcha, updateProfileImages, updateProfile, + importMutes, importBlocks, importFollows, deleteAccount, From 92caaa2d7f8cbc74fe14430f9659b3b9d9113b55 Mon Sep 17 00:00:00 2001 From: eugenijm Date: Wed, 16 Sep 2020 05:08:12 +0300 Subject: [PATCH 10/22] Fix the chat list order and last message timestamp updates --- src/modules/chats.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/modules/chats.js b/src/modules/chats.js index c7609018..aef16322 100644 --- a/src/modules/chats.js +++ b/src/modules/chats.js @@ -143,6 +143,7 @@ const chats = { const isNewMessage = (chat.lastMessage && chat.lastMessage.id) !== (updatedChat.lastMessage && updatedChat.lastMessage.id) chat.lastMessage = updatedChat.lastMessage chat.unread = updatedChat.unread + chat.updated_at = updatedChat.updated_at if (isNewMessage && chat.unread) { newChatMessageSideEffects(updatedChat) } From 8c4514013d5a53218830a82a6ac46f5969edd69b Mon Sep 17 00:00:00 2001 From: eugenijm Date: Wed, 16 Sep 2020 02:34:19 +0300 Subject: [PATCH 11/22] Fix chat messages being missed when the streaming is disabled and the messages are sent by both participants simultaneously --- src/components/chat/chat.js | 12 +++++++---- src/modules/chats.js | 20 +++---------------- src/services/chat_service/chat_service.js | 17 +++++++++------- .../chat_service/chat_service.spec.js | 10 +++++----- 4 files changed, 26 insertions(+), 33 deletions(-) diff --git a/src/components/chat/chat.js b/src/components/chat/chat.js index 9c4e5b05..803abf69 100644 --- a/src/components/chat/chat.js +++ b/src/components/chat/chat.js @@ -204,9 +204,9 @@ const Chat = { } }, readChat () { - if (!(this.currentChatMessageService && this.currentChatMessageService.lastMessage)) { return } + if (!(this.currentChatMessageService && this.currentChatMessageService.maxId)) { return } if (document.hidden) { return } - const lastReadId = this.currentChatMessageService.lastMessage.id + const lastReadId = this.currentChatMessageService.maxId this.$store.dispatch('readChat', { id: this.currentChat.id, lastReadId }) }, bottomedOut (offset) { @@ -244,7 +244,7 @@ const Chat = { const chatId = chatMessageService.chatId const fetchOlderMessages = !!maxId - const sinceId = fetchLatest && chatMessageService.lastMessage && chatMessageService.lastMessage.id + const sinceId = fetchLatest && chatMessageService.maxId this.backendInteractor.chatMessages({ id: chatId, maxId, sinceId }) .then((messages) => { @@ -303,7 +303,11 @@ const Chat = { return this.backendInteractor.sendChatMessage(params) .then(data => { - this.$store.dispatch('addChatMessages', { chatId: this.currentChat.id, messages: [data] }).then(() => { + this.$store.dispatch('addChatMessages', { + chatId: this.currentChat.id, + messages: [data], + updateMaxId: false + }).then(() => { this.$nextTick(() => { this.handleResize() // When the posting form size changes because of a media attachment, we need an extra resize diff --git a/src/modules/chats.js b/src/modules/chats.js index c7609018..e752c6df 100644 --- a/src/modules/chats.js +++ b/src/modules/chats.js @@ -181,30 +181,16 @@ const chats = { setChatsLoading (state, { value }) { state.chats.loading = value }, - addChatMessages (state, { commit, chatId, messages }) { + addChatMessages (state, { chatId, messages, updateMaxId }) { const chatMessageService = state.openedChatMessageServices[chatId] if (chatMessageService) { - chatService.add(chatMessageService, { messages: messages.map(parseChatMessage) }) - commit('refreshLastMessage', { chatId }) + chatService.add(chatMessageService, { messages: messages.map(parseChatMessage), updateMaxId }) } }, - refreshLastMessage (state, { chatId }) { - const chatMessageService = state.openedChatMessageServices[chatId] - if (chatMessageService) { - const chat = getChatById(state, chatId) - if (chat) { - chat.lastMessage = chatMessageService.lastMessage - if (chatMessageService.lastMessage) { - chat.updated_at = chatMessageService.lastMessage.created_at - } - } - } - }, - deleteChatMessage (state, { commit, chatId, messageId }) { + deleteChatMessage (state, { chatId, messageId }) { const chatMessageService = state.openedChatMessageServices[chatId] if (chatMessageService) { chatService.deleteMessage(chatMessageService, messageId) - commit('refreshLastMessage', { chatId }) } }, resetChatNewMessageCount (state, _value) { diff --git a/src/services/chat_service/chat_service.js b/src/services/chat_service/chat_service.js index b60a889b..95c69482 100644 --- a/src/services/chat_service/chat_service.js +++ b/src/services/chat_service/chat_service.js @@ -8,7 +8,7 @@ const empty = (chatId) => { lastSeenTimestamp: 0, chatId: chatId, minId: undefined, - lastMessage: undefined + maxId: undefined } } @@ -18,7 +18,7 @@ const clear = (storage) => { storage.newMessageCount = 0 storage.lastSeenTimestamp = 0 storage.minId = undefined - storage.lastMessage = undefined + storage.maxId = undefined } const deleteMessage = (storage, messageId) => { @@ -26,8 +26,9 @@ const deleteMessage = (storage, messageId) => { storage.messages = storage.messages.filter(m => m.id !== messageId) delete storage.idIndex[messageId] - if (storage.lastMessage && (storage.lastMessage.id === messageId)) { - storage.lastMessage = _.maxBy(storage.messages, 'id') + if (storage.maxId === messageId) { + const lastMessage = _.maxBy(storage.messages, 'id') + storage.maxId = lastMessage.id } if (storage.minId === messageId) { @@ -36,7 +37,7 @@ const deleteMessage = (storage, messageId) => { } } -const add = (storage, { messages: newMessages }) => { +const add = (storage, { messages: newMessages, updateMaxId = true }) => { if (!storage) { return } for (let i = 0; i < newMessages.length; i++) { const message = newMessages[i] @@ -48,8 +49,10 @@ const add = (storage, { messages: newMessages }) => { storage.minId = message.id } - if (!storage.lastMessage || message.id > storage.lastMessage.id) { - storage.lastMessage = message + if (!storage.maxId || message.id > storage.maxId) { + if (updateMaxId) { + storage.maxId = message.id + } } if (!storage.idIndex[message.id]) { diff --git a/test/unit/specs/services/chat_service/chat_service.spec.js b/test/unit/specs/services/chat_service/chat_service.spec.js index 3ee9839d..2eb89a2d 100644 --- a/test/unit/specs/services/chat_service/chat_service.spec.js +++ b/test/unit/specs/services/chat_service/chat_service.spec.js @@ -33,12 +33,12 @@ describe('chatService', () => { const chat = chatService.empty() chatService.add(chat, { messages: [ message1 ] }) - expect(chat.lastMessage.id).to.eql(message1.id) + expect(chat.maxId).to.eql(message1.id) expect(chat.minId).to.eql(message1.id) expect(chat.newMessageCount).to.eql(1) chatService.add(chat, { messages: [ message2 ] }) - expect(chat.lastMessage.id).to.eql(message2.id) + expect(chat.maxId).to.eql(message2.id) expect(chat.minId).to.eql(message1.id) expect(chat.newMessageCount).to.eql(2) @@ -60,15 +60,15 @@ describe('chatService', () => { chatService.add(chat, { messages: [ message2 ] }) chatService.add(chat, { messages: [ message3 ] }) - expect(chat.lastMessage.id).to.eql(message3.id) + expect(chat.maxId).to.eql(message3.id) expect(chat.minId).to.eql(message1.id) chatService.deleteMessage(chat, message3.id) - expect(chat.lastMessage.id).to.eql(message2.id) + expect(chat.maxId).to.eql(message2.id) expect(chat.minId).to.eql(message1.id) chatService.deleteMessage(chat, message1.id) - expect(chat.lastMessage.id).to.eql(message2.id) + expect(chat.maxId).to.eql(message2.id) expect(chat.minId).to.eql(message2.id) }) }) From d6fe4f6a4fa4c8fb928bcd187e605c76f985d06d Mon Sep 17 00:00:00 2001 From: Shpuld Shpuldson Date: Wed, 16 Sep 2020 10:27:31 +0300 Subject: [PATCH 12/22] update changelog --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 18dafa8e..c56ac821 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [Unreleased] ## [Unreleased patch] +### Fixed +- Fixed chats list not updating its order when new messages come in +- Fixed chat messages sometimes getting lost when you receive a message at the same time + + +## [2.1.1] - 2020-09-08 ### Changed - Polls will be hidden with status content if "Collapse posts with subjects" is enabled and the post is collapsed. @@ -13,6 +19,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Autocomplete won't stop at the second @, so it'll still work with "@lain@l" and not start over. - Fixed weird autocomplete behavior when you write ":custom_emoji: ?" + ## [2.1.0] - 2020-08-28 ### Added - Autocomplete domains from list of known instances From 1b811d8b931706927d8fa096435b2c272eb0d7ef Mon Sep 17 00:00:00 2001 From: Shpuld Shpuldson Date: Wed, 16 Sep 2020 11:29:10 +0300 Subject: [PATCH 13/22] change side drawer to use shoutbox name --- src/components/side_drawer/side_drawer.vue | 2 +- src/i18n/en.json | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/components/side_drawer/side_drawer.vue b/src/components/side_drawer/side_drawer.vue index 0587ee02..b17813c3 100644 --- a/src/components/side_drawer/side_drawer.vue +++ b/src/components/side_drawer/side_drawer.vue @@ -90,7 +90,7 @@ @click="toggleDrawer" > - {{ $t("nav.chat") }} + {{ $t("shoutbox.title") }} diff --git a/src/i18n/en.json b/src/i18n/en.json index 8540f551..027e99be 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -113,7 +113,6 @@ "about": "About", "administration": "Administration", "back": "Back", - "chat": "Local Chat", "friend_requests": "Follow Requests", "mentions": "Mentions", "interactions": "Interactions", From 20d33c2fbc1e3cf9cdbab94c26b138acd505d001 Mon Sep 17 00:00:00 2001 From: Shpuld Shpuldson Date: Wed, 16 Sep 2020 11:53:54 +0300 Subject: [PATCH 14/22] change icon to a megaphone --- src/components/chat_panel/chat_panel.vue | 2 +- src/components/side_drawer/side_drawer.vue | 2 +- static/fontello.json | 6 ++++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/components/chat_panel/chat_panel.vue b/src/components/chat_panel/chat_panel.vue index ca529b5a..570435e7 100644 --- a/src/components/chat_panel/chat_panel.vue +++ b/src/components/chat_panel/chat_panel.vue @@ -63,7 +63,7 @@ @click.stop.prevent="togglePanel" >
- + {{ $t('shoutbox.title') }}
diff --git a/src/components/side_drawer/side_drawer.vue b/src/components/side_drawer/side_drawer.vue index b17813c3..eda5a68c 100644 --- a/src/components/side_drawer/side_drawer.vue +++ b/src/components/side_drawer/side_drawer.vue @@ -90,7 +90,7 @@ @click="toggleDrawer" > - {{ $t("shoutbox.title") }} + {{ $t("shoutbox.title") }} diff --git a/static/fontello.json b/static/fontello.json index 706800cd..b0136fd9 100644 --- a/static/fontello.json +++ b/static/fontello.json @@ -405,6 +405,12 @@ "css": "block", "code": 59434, "src": "fontawesome" + }, + { + "uid": "3e674995cacc2b09692c096ea7eb6165", + "css": "megaphone", + "code": 59435, + "src": "fontawesome" } ] } \ No newline at end of file From 70a5619496db1620fcc6d0127449ffb498a3dae4 Mon Sep 17 00:00:00 2001 From: Dym Sohin Date: Fri, 18 Sep 2020 11:07:38 +0200 Subject: [PATCH 15/22] [fix] case in/sensitive emoji search --- src/components/emoji_picker/emoji_picker.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/emoji_picker/emoji_picker.js b/src/components/emoji_picker/emoji_picker.js index 0f397b59..5c09f6ca 100644 --- a/src/components/emoji_picker/emoji_picker.js +++ b/src/components/emoji_picker/emoji_picker.js @@ -8,7 +8,10 @@ const LOAD_EMOJI_BY = 60 const LOAD_EMOJI_MARGIN = 64 const filterByKeyword = (list, keyword = '') => { - return list.filter(x => x.displayText.includes(keyword)) + const keywordLowercase = keyword.toLowerCase() + return list.filter(emoji => + emoji.displayText.toLowerCase().includes(keywordLowercase) + ) } const EmojiPicker = { From 5942001626d01f6438e53943f1b8a8a2448d1378 Mon Sep 17 00:00:00 2001 From: Maksim Pechnikov Date: Fri, 18 Sep 2020 22:09:05 +0300 Subject: [PATCH 16/22] updated changelog --- CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c56ac821..15aeb7cc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,8 +8,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Fixed - Fixed chats list not updating its order when new messages come in -- Fixed chat messages sometimes getting lost when you receive a message at the same time +- Fixed chat messages sometimes getting lost when you receive a message at the same time +### Added +- Import/export a muted users ## [2.1.1] - 2020-09-08 ### Changed From f9977dbb3c9b316521b6be40ddd1a34411f2d835 Mon Sep 17 00:00:00 2001 From: Dym Sohin Date: Sat, 19 Sep 2020 21:28:03 +0200 Subject: [PATCH 17/22] fix excessive underline in sidebar --- src/App.scss | 1 + src/components/nav_panel/nav_panel.vue | 10 +++++----- src/components/timeline_menu/timeline_menu.vue | 6 +----- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/App.scss b/src/App.scss index e2e2d079..8b1bbd2d 100644 --- a/src/App.scss +++ b/src/App.scss @@ -809,6 +809,7 @@ nav { .button-icon { font-size: 1.2em; + margin-right: 0.5em; } @keyframes shakeError { diff --git a/src/components/nav_panel/nav_panel.vue b/src/components/nav_panel/nav_panel.vue index f8459fd1..080e547f 100644 --- a/src/components/nav_panel/nav_panel.vue +++ b/src/components/nav_panel/nav_panel.vue @@ -7,12 +7,12 @@ :to="{ name: timelinesRoute }" :class="onTimelineRoute && 'router-link-active'" > - {{ $t("nav.timelines") }} + {{ $t("nav.timelines") }}
  • - {{ $t("nav.interactions") }} + {{ $t("nav.interactions") }}
  • @@ -23,12 +23,12 @@ > {{ unreadChatCount }} - {{ $t("nav.chats") }} + {{ $t("nav.chats") }}
  • - {{ $t("nav.friend_requests") }} + {{ $t("nav.friend_requests") }}
  • - {{ $t("nav.about") }} + {{ $t("nav.about") }}
  • diff --git a/src/components/timeline_menu/timeline_menu.vue b/src/components/timeline_menu/timeline_menu.vue index be512d60..3c029093 100644 --- a/src/components/timeline_menu/timeline_menu.vue +++ b/src/components/timeline_menu/timeline_menu.vue @@ -64,7 +64,7 @@ .timeline-menu-popover-wrap { overflow: hidden; // Match panel heading padding to line up menu with bottom of heading - margin-top: 0.6rem; + margin-top: 0.6rem 0.65em; padding: 0 15px 15px 15px; } .timeline-menu-popover { @@ -138,10 +138,6 @@ &:last-child { border: none; } - - i { - margin: 0 0.5em; - } } a { From 20362546d10287cbba8150424e5e073c39219757 Mon Sep 17 00:00:00 2001 From: Dym Sohin Date: Sat, 19 Sep 2020 21:50:56 +0200 Subject: [PATCH 18/22] fix/overflow-for-chat-unread --- src/App.scss | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/App.scss b/src/App.scss index e2e2d079..88e5df86 100644 --- a/src/App.scss +++ b/src/App.scss @@ -941,6 +941,9 @@ nav { min-height: 1.3rem; max-height: 1.3rem; line-height: 1.3rem; + max-width: 10em; + overflow: hidden; + text-overflow: ellipsis; } .chat-layout { From 3dacef944cf6980dc3a3c1843d5b3f94b851240a Mon Sep 17 00:00:00 2001 From: Dym Sohin Date: Thu, 24 Sep 2020 12:05:51 +0200 Subject: [PATCH 19/22] remove bio-table's max-width --- src/components/user_profile/user_profile.vue | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/components/user_profile/user_profile.vue b/src/components/user_profile/user_profile.vue index c7c67c0a..b26499b4 100644 --- a/src/components/user_profile/user_profile.vue +++ b/src/components/user_profile/user_profile.vue @@ -156,8 +156,7 @@ .user-profile-field { display: flex; - margin: 0.25em auto; - max-width: 32em; + margin: 0.25em; border: 1px solid var(--border, $fallback--border); border-radius: $fallback--inputRadius; border-radius: var(--inputRadius, $fallback--inputRadius); From f174f289a93e6bef1182a2face00bb809da49d18 Mon Sep 17 00:00:00 2001 From: Shpuld Shpludson Date: Tue, 29 Sep 2020 10:18:37 +0000 Subject: [PATCH 20/22] Timeline virtual scrolling --- CHANGELOG.md | 3 + src/components/attachment/attachment.vue | 4 ++ src/components/conversation/conversation.js | 20 +++++- src/components/conversation/conversation.vue | 11 +++- src/components/react_button/react_button.js | 5 +- .../retweet_button/retweet_button.js | 5 +- .../settings_modal/tabs/general_tab.vue | 5 ++ src/components/status/status.js | 31 +++++++-- src/components/status/status.scss | 5 ++ src/components/status/status.vue | 7 +- .../status_content/status_content.vue | 2 + src/components/still-image/still-image.js | 10 +-- src/components/timeline/timeline.js | 64 ++++++++++++++++++- src/components/timeline/timeline.vue | 6 +- .../video_attachment/video_attachment.js | 49 ++++++++++---- .../video_attachment/video_attachment.vue | 3 +- src/i18n/en.json | 1 + src/modules/config.js | 3 +- src/modules/instance.js | 1 + src/modules/statuses.js | 6 ++ src/services/api/api.service.js | 2 + 21 files changed, 204 insertions(+), 39 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 18dafa8e..eebc7115 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [Unreleased] +### Added +- New option to optimize timeline rendering to make the site more responsive (enabled by default) + ## [Unreleased patch] ### Changed diff --git a/src/components/attachment/attachment.vue b/src/components/attachment/attachment.vue index 63e0ceba..7fabc963 100644 --- a/src/components/attachment/attachment.vue +++ b/src/components/attachment/attachment.vue @@ -80,6 +80,8 @@ class="video" :attachment="attachment" :controls="allowPlay" + @play="$emit('play')" + @pause="$emit('pause')" />
    @@ -18,6 +20,7 @@
    +
    @@ -53,8 +60,8 @@ .conversation-status { border-color: $fallback--border; border-color: var(--border, $fallback--border); - border-left: 4px solid $fallback--cRed; - border-left: 4px solid var(--cRed, $fallback--cRed); + border-left-color: $fallback--cRed; + border-left-color: var(--cRed, $fallback--cRed); } .conversation-status:last-child { diff --git a/src/components/react_button/react_button.js b/src/components/react_button/react_button.js index abcf0455..11627e9c 100644 --- a/src/components/react_button/react_button.js +++ b/src/components/react_button/react_button.js @@ -1,5 +1,4 @@ import Popover from '../popover/popover.vue' -import { mapGetters } from 'vuex' const ReactButton = { props: ['status'], @@ -35,7 +34,9 @@ const ReactButton = { } return this.$store.state.instance.emoji || [] }, - ...mapGetters(['mergedConfig']) + mergedConfig () { + return this.$store.getters.mergedConfig + } } } diff --git a/src/components/retweet_button/retweet_button.js b/src/components/retweet_button/retweet_button.js index d9a0f92e..5a41f22d 100644 --- a/src/components/retweet_button/retweet_button.js +++ b/src/components/retweet_button/retweet_button.js @@ -1,4 +1,3 @@ -import { mapGetters } from 'vuex' const RetweetButton = { props: ['status', 'loggedIn', 'visibility'], @@ -28,7 +27,9 @@ const RetweetButton = { 'animate-spin': this.animated } }, - ...mapGetters(['mergedConfig']) + mergedConfig () { + return this.$store.getters.mergedConfig + } } } diff --git a/src/components/settings_modal/tabs/general_tab.vue b/src/components/settings_modal/tabs/general_tab.vue index 7f06d0bd..13482de7 100644 --- a/src/components/settings_modal/tabs/general_tab.vue +++ b/src/components/settings_modal/tabs/general_tab.vue @@ -58,6 +58,11 @@ {{ $t('settings.emoji_reactions_on_timeline') }} +
  • + + {{ $t('settings.virtual_scrolling') }} + +
  • diff --git a/src/components/status/status.js b/src/components/status/status.js index d263da68..cd6e2f72 100644 --- a/src/components/status/status.js +++ b/src/components/status/status.js @@ -15,7 +15,6 @@ import generateProfileLink from 'src/services/user_profile_link_generator/user_p import { highlightClass, highlightStyle } from '../../services/user_highlighter/user_highlighter.js' import { muteWordHits } from '../../services/status_parser/status_parser.js' import { unescape, uniqBy } from 'lodash' -import { mapGetters, mapState } from 'vuex' const Status = { name: 'Status', @@ -54,6 +53,8 @@ const Status = { replying: false, unmuted: false, userExpanded: false, + mediaPlaying: [], + suspendable: true, error: null } }, @@ -157,7 +158,7 @@ const Status = { return this.mergedConfig.hideFilteredStatuses }, hideStatus () { - return this.deleted || (this.muted && this.hideFilteredStatuses) + return this.deleted || (this.muted && this.hideFilteredStatuses) || this.virtualHidden }, isFocused () { // retweet or root of an expanded conversation @@ -207,11 +208,18 @@ const Status = { hidePostStats () { return this.mergedConfig.hidePostStats }, - ...mapGetters(['mergedConfig']), - ...mapState({ - betterShadow: state => state.interface.browserSupport.cssFilter, - currentUser: state => state.users.currentUser - }) + currentUser () { + return this.$store.state.users.currentUser + }, + betterShadow () { + return this.$store.state.interface.browserSupport.cssFilter + }, + mergedConfig () { + return this.$store.getters.mergedConfig + }, + isSuspendable () { + return !this.replying && this.mediaPlaying.length === 0 + } }, methods: { visibilityIcon (visibility) { @@ -251,6 +259,12 @@ const Status = { }, generateUserProfileLink (id, name) { return generateProfileLink(id, name, this.$store.state.instance.restrictedNicknames) + }, + addMediaPlaying (id) { + this.mediaPlaying.push(id) + }, + removeMediaPlaying (id) { + this.mediaPlaying = this.mediaPlaying.filter(mediaId => mediaId !== id) } }, watch: { @@ -280,6 +294,9 @@ const Status = { if (this.isFocused && this.statusFromGlobalRepository.favoritedBy && this.statusFromGlobalRepository.favoritedBy.length !== num) { this.$store.dispatch('fetchFavs', this.status.id) } + }, + 'isSuspendable': function (val) { + this.suspendable = val } }, filters: { diff --git a/src/components/status/status.scss b/src/components/status/status.scss index 8d292d3f..c92d870b 100644 --- a/src/components/status/status.scss +++ b/src/components/status/status.scss @@ -25,6 +25,11 @@ $status-margin: 0.75em; --icon: var(--selectedPostIcon, $fallback--icon); } + &.-conversation { + border-left-width: 4px; + border-left-style: solid; + } + .status-container { display: flex; padding: $status-margin; diff --git a/src/components/status/status.vue b/src/components/status/status.vue index 282ad37d..aa67e433 100644 --- a/src/components/status/status.vue +++ b/src/components/status/status.vue @@ -16,7 +16,7 @@ />
    diff --git a/src/i18n/en.json b/src/i18n/en.json index 8540f551..8d831e3d 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -430,6 +430,7 @@ "false": "no", "true": "yes" }, + "virtual_scrolling": "Optimize timeline rendering", "fun": "Fun", "greentext": "Meme arrows", "notifications": "Notifications", diff --git a/src/modules/config.js b/src/modules/config.js index 409d77a4..444b8ec7 100644 --- a/src/modules/config.js +++ b/src/modules/config.js @@ -65,7 +65,8 @@ export const defaultState = { useContainFit: false, greentext: undefined, // instance default hidePostStats: undefined, // instance default - hideUserStats: undefined // instance default + hideUserStats: undefined, // instance default + virtualScrolling: undefined // instance default } // caching the instance default properties diff --git a/src/modules/instance.js b/src/modules/instance.js index 3fe3bbf3..b3cbffc6 100644 --- a/src/modules/instance.js +++ b/src/modules/instance.js @@ -41,6 +41,7 @@ const defaultState = { sidebarRight: false, subjectLineBehavior: 'email', theme: 'pleroma-dark', + virtualScrolling: true, // Nasty stuff customEmoji: [], diff --git a/src/modules/statuses.js b/src/modules/statuses.js index e108b2a7..155cc4b9 100644 --- a/src/modules/statuses.js +++ b/src/modules/statuses.js @@ -568,6 +568,9 @@ export const mutations = { updateStatusWithPoll (state, { id, poll }) { const status = state.allStatusesObject[id] status.poll = poll + }, + setVirtualHeight (state, { statusId, height }) { + state.allStatusesObject[statusId].virtualHeight = height } } @@ -753,6 +756,9 @@ const statuses = { store.commit('addNewStatuses', { statuses: data.statuses }) return data }) + }, + setVirtualHeight ({ commit }, { statusId, height }) { + commit('setVirtualHeight', { statusId, height }) } }, mutations diff --git a/src/services/api/api.service.js b/src/services/api/api.service.js index da519001..d1842e17 100644 --- a/src/services/api/api.service.js +++ b/src/services/api/api.service.js @@ -539,8 +539,10 @@ const fetchTimeline = ({ const queryString = map(params, (param) => `${param[0]}=${param[1]}`).join('&') url += `?${queryString}` + let status = '' let statusText = '' + let pagination = {} return fetch(url, { headers: authHeaders(credentials) }) .then((data) => { From 1675f1a133934956a39ca4ade99b809789bb84a2 Mon Sep 17 00:00:00 2001 From: Dym Sohin Date: Tue, 29 Sep 2020 13:13:42 +0200 Subject: [PATCH 21/22] scoped back margin-right on icons --- src/App.scss | 1 - src/components/nav_panel/nav_panel.vue | 4 ++++ src/components/timeline_menu/timeline_menu.vue | 4 ++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/App.scss b/src/App.scss index 8b1bbd2d..e2e2d079 100644 --- a/src/App.scss +++ b/src/App.scss @@ -809,7 +809,6 @@ nav { .button-icon { font-size: 1.2em; - margin-right: 0.5em; } @keyframes shakeError { diff --git a/src/components/nav_panel/nav_panel.vue b/src/components/nav_panel/nav_panel.vue index 080e547f..4f944c95 100644 --- a/src/components/nav_panel/nav_panel.vue +++ b/src/components/nav_panel/nav_panel.vue @@ -125,6 +125,10 @@ } } +.nav-panel .button-icon { + margin-right: 0.5em; +} + .nav-panel .button-icon:before { width: 1.1em; } diff --git a/src/components/timeline_menu/timeline_menu.vue b/src/components/timeline_menu/timeline_menu.vue index 3c029093..481b1d09 100644 --- a/src/components/timeline_menu/timeline_menu.vue +++ b/src/components/timeline_menu/timeline_menu.vue @@ -170,6 +170,10 @@ text-decoration: underline; } } + + i { + margin: 0 0.5em; + } } } From c17012cfe19ecab7efc27a54c90c4369c36de343 Mon Sep 17 00:00:00 2001 From: Dym Sohin Date: Tue, 29 Sep 2020 13:20:16 +0200 Subject: [PATCH 22/22] fix appended 0.65em on wrong line --- src/components/timeline_menu/timeline_menu.vue | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/timeline_menu/timeline_menu.vue b/src/components/timeline_menu/timeline_menu.vue index 481b1d09..b7e5f2da 100644 --- a/src/components/timeline_menu/timeline_menu.vue +++ b/src/components/timeline_menu/timeline_menu.vue @@ -64,7 +64,7 @@ .timeline-menu-popover-wrap { overflow: hidden; // Match panel heading padding to line up menu with bottom of heading - margin-top: 0.6rem 0.65em; + margin-top: 0.6rem; padding: 0 15px 15px 15px; } .timeline-menu-popover { @@ -142,7 +142,7 @@ a { display: block; - padding: 0.6em 0; + padding: 0.6em 0.65em; &:hover { background-color: $fallback--lightBg; @@ -172,7 +172,7 @@ } i { - margin: 0 0.5em; + margin-right: 0.5em; } } }