From 612aa56c8b2d6bae75bd47ff1846dfcfb012d525 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Mon, 20 Aug 2018 19:01:54 +0300 Subject: [PATCH 1/6] Drop the entire thing about hidden "own" timeline since it doesn't necessarily contain all of the users posts (it doesn't contain DMs) even though it's "us". Since this is a workaround anyway just fetch home timeline instead. It could end up making more queries if user doesn't post that often. --- src/modules/statuses.js | 1 - src/modules/users.js | 2 -- src/services/api/api.service.js | 3 --- .../backend_interactor_service/backend_interactor_service.js | 4 ++-- 4 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/modules/statuses.js b/src/modules/statuses.js index 45dd3afac..1e1bf72f8 100644 --- a/src/modules/statuses.js +++ b/src/modules/statuses.js @@ -36,7 +36,6 @@ export const defaultState = { mentions: emptyTl(), public: emptyTl(), user: emptyTl(), - own: emptyTl(), publicAndExternal: emptyTl(), friends: emptyTl(), tag: emptyTl() diff --git a/src/modules/users.js b/src/modules/users.js index c592fe4e9..ba5487655 100644 --- a/src/modules/users.js +++ b/src/modules/users.js @@ -107,8 +107,6 @@ const users = { // Start getting fresh tweets. store.dispatch('startFetching', 'friends') - // Start getting our own posts, only really needed for mitigating broken favorites - store.dispatch('startFetching', ['own', user.id]) // Get user mutes and follower info store.rootState.api.backendInteractor.fetchMutes().then((mutedUsers) => { diff --git a/src/services/api/api.service.js b/src/services/api/api.service.js index 1cb5e0b8f..4f6af06dd 100644 --- a/src/services/api/api.service.js +++ b/src/services/api/api.service.js @@ -306,9 +306,6 @@ const fetchTimeline = ({timeline, credentials, since = false, until = false, use notifications: QVITTER_USER_NOTIFICATIONS_URL, 'publicAndExternal': PUBLIC_AND_EXTERNAL_TIMELINE_URL, user: QVITTER_USER_TIMELINE_URL, - // separate timeline for own posts, so it won't break due to user timeline bugs - // really needed only for broken favorites - own: QVITTER_USER_TIMELINE_URL, tag: TAG_TIMELINE_URL } diff --git a/src/services/backend_interactor_service/backend_interactor_service.js b/src/services/backend_interactor_service/backend_interactor_service.js index c84373acf..5742441cf 100644 --- a/src/services/backend_interactor_service/backend_interactor_service.js +++ b/src/services/backend_interactor_service/backend_interactor_service.js @@ -54,11 +54,11 @@ const backendInteractorService = (credentials) => { return timelineFetcherService.startFetching({timeline, store, credentials, userId}) } - const fetchOldPost = ({store, postId}) => { + const fetchOldPost = ({store, postId, timeline = 'friends'}) => { return timelineFetcherService.fetchAndUpdate({ store, credentials, - timeline: 'own', + timeline, older: true, until: postId + 1 }) From fa66385c5beb157fe885401f70029ce03f182ba5 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Mon, 20 Aug 2018 19:06:04 +0300 Subject: [PATCH 2/6] Updated localization files --- src/i18n/messages.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/i18n/messages.js b/src/i18n/messages.js index 845facc36..0bcfb25a3 100644 --- a/src/i18n/messages.js +++ b/src/i18n/messages.js @@ -340,7 +340,8 @@ const en = { followed_you: 'followed you', favorited_you: 'favorited your status', repeated_you: 'repeated your status', - broken_favorite: 'Unknown status, searching for it...' + broken_favorite: 'Unknown status, searching for it...', + load_older: 'Load older notifications' }, login: { login: 'Log in', @@ -1631,7 +1632,8 @@ const ru = { followed_you: 'начал(а) читать вас', favorited_you: 'нравится ваш статус', repeated_you: 'повторил(а) ваш статус', - broken_favorite: 'Неизвестный статус, ищем...' + broken_favorite: 'Неизвестный статус, ищем...', + load_older: 'Загрузить старые уведомления' }, login: { login: 'Войти', From 9e78c64d5eecb5f73e4da401dd3baec94e77efd7 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Mon, 20 Aug 2018 19:58:49 +0300 Subject: [PATCH 3/6] Hide initial desktop notifications spam when FE is opened and there's a lot of unseen notifications. --- src/modules/statuses.js | 9 ++++++++- .../notifications_fetcher.service.js | 4 ++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/modules/statuses.js b/src/modules/statuses.js index 1e1bf72f8..063f5f9cf 100644 --- a/src/modules/statuses.js +++ b/src/modules/statuses.js @@ -24,6 +24,7 @@ export const defaultState = { allStatusesObject: {}, maxId: 0, notifications: { + desktopNotificationSilence: true, maxId: 0, maxSavedId: 0, minId: Number.POSITIVE_INFINITY, @@ -314,7 +315,7 @@ const addNewNotifications = (state, { dispatch, notifications, older }) => { result.image = action.attachments[0].url } - if (fresh) { + if (fresh && !state.notifications.desktopNotificationSilence) { let notification = new window.Notification(title, result) // Chrome is known for not closing notifications automatically // according to MDN, anyway. @@ -365,6 +366,9 @@ export const mutations = { setNotificationsError (state, { value }) { state.notificationsError = value }, + setNotificationsSilence (state, { value }) { + state.notifications.desktopNotificationSilence = value + }, setProfileView (state, { v }) { // load followers / friends only when needed state.timelines['user'].viewing = v @@ -401,6 +405,9 @@ const statuses = { setNotificationsError ({ rootState, commit }, { value }) { commit('setNotificationsError', { value }) }, + setNotificationsSilence ({ rootState, commit }, { value }) { + commit('setNotificationsSilence', { value }) + }, addFriends ({ rootState, commit }, { friends }) { commit('addFriends', { friends }) }, diff --git a/src/services/notifications_fetcher/notifications_fetcher.service.js b/src/services/notifications_fetcher/notifications_fetcher.service.js index 5aedc4fbc..74a4bcda1 100644 --- a/src/services/notifications_fetcher/notifications_fetcher.service.js +++ b/src/services/notifications_fetcher/notifications_fetcher.service.js @@ -30,6 +30,10 @@ const fetchAndUpdate = ({store, credentials, older = false}) => { 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) } From 3ccea3442ec71bee8136886474b877526100ed70 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Mon, 20 Aug 2018 20:05:12 +0300 Subject: [PATCH 4/6] fix custom emoji in username, fix gif avatar not being animated when hovering on the notification --- src/components/notifications/notifications.scss | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/components/notifications/notifications.scss b/src/components/notifications/notifications.scss index 2bc71bfe4..08557ea24 100644 --- a/src/components/notifications/notifications.scss +++ b/src/components/notifications/notifications.scss @@ -79,7 +79,7 @@ } } - &:hover .animated.avatar { + &:hover .animated.avatar-compact { canvas { display: none; } @@ -155,6 +155,13 @@ max-width: 100%; text-overflow: ellipsis; white-space: nowrap; + + img { + width: 14px; + height: 14px; + vertical-align: middle; + object-fit: contain + } } .timeago { float: right; From f9b0a959695359f6159c5e1507609aba56a34d8d Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Mon, 20 Aug 2018 20:08:21 +0300 Subject: [PATCH 5/6] removed style for rounding bottom part of notifications because there's now always "load more" footer --- src/components/notifications/notifications.scss | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/components/notifications/notifications.scss b/src/components/notifications/notifications.scss index 08557ea24..5881fbaa5 100644 --- a/src/components/notifications/notifications.scss +++ b/src/components/notifications/notifications.scss @@ -211,15 +211,4 @@ margin-bottom: 0.3em; } } - - // ugly as heck - &:last-child { - border-bottom: none; - border-radius: 0 0 $fallback--panelRadius $fallback--panelRadius; - border-radius: 0 0 var(--panelRadius, $fallback--panelRadius) var(--panelRadius, $fallback--panelRadius); - .status-el { - border-radius: 0 0 $fallback--panelRadius $fallback--panelRadius; - border-radius: 0 0 var(--panelRadius, $fallback--panelRadius) var(--panelRadius, $fallback--panelRadius); - } - } } From b97db4912dacca3cfcf91fc0843e631666a47d1c Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Mon, 20 Aug 2018 20:45:54 +0300 Subject: [PATCH 6/6] error display --- src/components/notifications/notifications.js | 3 +++ .../notifications/notifications.scss | 19 +++++++++++++++++++ .../notifications/notifications.vue | 5 ++++- src/modules/statuses.js | 3 ++- 4 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/components/notifications/notifications.js b/src/components/notifications/notifications.js index 55a9b0ab9..b24250b07 100644 --- a/src/components/notifications/notifications.js +++ b/src/components/notifications/notifications.js @@ -14,6 +14,9 @@ const Notifications = { notifications () { return this.$store.state.statuses.notifications.data }, + error () { + return this.$store.state.statuses.notifications.error + }, unseenNotifications () { return filter(this.notifications, ({seen}) => !seen) }, diff --git a/src/components/notifications/notifications.scss b/src/components/notifications/notifications.scss index 5881fbaa5..5b09685b6 100644 --- a/src/components/notifications/notifications.scss +++ b/src/components/notifications/notifications.scss @@ -4,6 +4,10 @@ // a bit of a hack to allow scrolling below notifications padding-bottom: 15em; + .title { + display: inline-block; + } + .panel { background: $fallback--bg; background: var(--bg, $fallback--bg) @@ -22,6 +26,8 @@ background: var(--btn, $fallback--btn); color: $fallback--fg; color: var(--fg, $fallback--fg); + display: flex; + align-items: baseline; .read-button { position: absolute; right: 0.7em; @@ -44,6 +50,19 @@ line-height: 1.3em; } + .loadmore-error { + position: absolute; + right: 0.6em; + font-size: 14px; + min-width: 6em; + font-family: sans-serif; + text-align: center; + padding: 0 0.25em 0 0.25em; + margin: 0; + color: $fallback--fg; + color: var(--fg, $fallback--fg); + } + .unseen { box-shadow: inset 4px 0 0 var(--cRed, $fallback--cRed); padding-left: 0; diff --git a/src/components/notifications/notifications.vue b/src/components/notifications/notifications.vue index 859730ed8..a0b0e5f58 100644 --- a/src/components/notifications/notifications.vue +++ b/src/components/notifications/notifications.vue @@ -3,7 +3,10 @@
{{unseenCount}} - {{$t('notifications.notifications')}} +
{{$t('notifications.notifications')}}
+
+ {{$t('timeline.error_fetching')}} +
diff --git a/src/modules/statuses.js b/src/modules/statuses.js index 063f5f9cf..8e1e7fe7d 100644 --- a/src/modules/statuses.js +++ b/src/modules/statuses.js @@ -29,6 +29,7 @@ export const defaultState = { maxSavedId: 0, minId: Number.POSITIVE_INFINITY, data: [], + error: false, brokenFavorites: {} }, favorites: new Set(), @@ -364,7 +365,7 @@ export const mutations = { state.error = value }, setNotificationsError (state, { value }) { - state.notificationsError = value + state.notifications.error = value }, setNotificationsSilence (state, { value }) { state.notifications.desktopNotificationSilence = value