From 63650aec29effef1e5c78d953d078ae4a12cb09f Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Sun, 12 Aug 2018 14:14:34 +0300 Subject: [PATCH 01/19] Added support for qvitter api fetching of notifications --- src/components/notification/notification.vue | 2 +- src/components/notifications/notifications.js | 23 +++- .../notifications/notifications.vue | 6 + src/main.js | 3 +- src/modules/statuses.js | 112 ++++++++++-------- src/services/api/api.service.js | 2 + test/unit/specs/modules/statuses.spec.js | 36 +++--- 7 files changed, 110 insertions(+), 74 deletions(-) diff --git a/src/components/notification/notification.vue b/src/components/notification/notification.vue index eed598a8..1c07bae9 100644 --- a/src/components/notification/notification.vue +++ b/src/components/notification/notification.vue @@ -11,7 +11,7 @@
{{ notification.action.user.name }} - + {{$t('notifications.favorited_you')}} diff --git a/src/components/notifications/notifications.js b/src/components/notifications/notifications.js index f8314bfc..f07d550e 100644 --- a/src/components/notifications/notifications.js +++ b/src/components/notifications/notifications.js @@ -1,16 +1,18 @@ import Notification from '../notification/notification.vue' +import notificationsFetcher from '../../services/notifications_fetcher/notifications_fetcher.service.js' import { sortBy, take, filter } from 'lodash' const Notifications = { - data () { - return { - visibleNotificationCount: 20 - } + created () { + const store = this.$store + const credentials = store.state.users.currentUser.credentials + + notificationsFetcher.startFetching({ store, credentials }) }, computed: { notifications () { - return this.$store.state.statuses.notifications + return this.$store.state.statuses.notifications.data }, unseenNotifications () { return filter(this.notifications, ({seen}) => !seen) @@ -19,7 +21,7 @@ const Notifications = { // Don't know why, but sortBy([seen, -action.id]) doesn't work. let sortedNotifications = sortBy(this.notifications, ({action}) => -action.id) sortedNotifications = sortBy(sortedNotifications, 'seen') - return take(sortedNotifications, this.visibleNotificationCount) + return sortedNotifications }, unseenCount () { return this.unseenNotifications.length @@ -40,6 +42,15 @@ const Notifications = { methods: { markAsSeen () { this.$store.commit('markNotificationsAsSeen', this.visibleNotifications) + }, + fetchOlderNotifications () { + const store = this.$store + const credentials = store.state.users.currentUser.credentials + notificationsFetcher.fetchAndUpdate({ + store, + credentials, + older: true + }) } } } diff --git a/src/components/notifications/notifications.vue b/src/components/notifications/notifications.vue index 4fa6e925..859730ed 100644 --- a/src/components/notifications/notifications.vue +++ b/src/components/notifications/notifications.vue @@ -11,6 +11,12 @@
+ diff --git a/src/main.js b/src/main.js index bacd7f6d..41773080 100644 --- a/src/main.js +++ b/src/main.js @@ -53,7 +53,8 @@ const persistedStateOptions = { 'config.streaming', 'config.muteWords', 'config.customTheme', - 'users.lastLoginName' + 'users.lastLoginName', + 'statuses.notifications.maxSavedId' ] } diff --git a/src/modules/statuses.js b/src/modules/statuses.js index 291ab53c..a8a0d4fe 100644 --- a/src/modules/statuses.js +++ b/src/modules/statuses.js @@ -1,4 +1,5 @@ import { includes, remove, slice, sortBy, toInteger, each, find, flatten, maxBy, minBy, merge, last, isArray } from 'lodash' +import { set } from 'vue' import apiService from '../services/api/api.service.js' // import parse from '../services/status_parser/status_parser.js' @@ -22,7 +23,12 @@ export const defaultState = { allStatuses: [], allStatusesObject: {}, maxId: 0, - notifications: [], + notifications: { + maxId: 0, + maxSavedId: 0, + minId: Number.POSITIVE_INFINITY, + data: [] + }, favorites: new Set(), error: false, timelines: { @@ -135,10 +141,6 @@ const addNewStatuses = (state, { statuses, showImmediately = false, timeline, us status = result.item if (result.new) { - if (statusType(status) === 'retweet' && status.retweeted_status.user.id === user.id) { - addNotification({ type: 'repeat', status: status, action: status }) - } - // We are mentioned in a post if (statusType(status) === 'status' && find(status.attentions, { id: user.id })) { const mentions = state.timelines.mentions @@ -150,10 +152,6 @@ const addNewStatuses = (state, { statuses, showImmediately = false, timeline, us sortTimeline(mentions) } - // Don't add notification for self-mention - if (status.user.id !== user.id) { - addNotification({ type: 'mention', status, action: status }) - } } } @@ -176,32 +174,6 @@ const addNewStatuses = (state, { statuses, showImmediately = false, timeline, us return status } - const addNotification = ({type, status, action}) => { - // Only add a new notification if we don't have one for the same action - if (!find(state.notifications, (oldNotification) => oldNotification.action.id === action.id)) { - state.notifications.push({ type, status, action, seen: false }) - - if ('Notification' in window && window.Notification.permission === 'granted') { - const title = action.user.name - const result = {} - result.icon = action.user.profile_image_url - result.body = action.text // there's a problem that it doesn't put a space before links tho - - // Shows first attached non-nsfw image, if any. Should add configuration for this somehow... - if (action.attachments && action.attachments.length > 0 && !action.nsfw && - action.attachments[0].mimetype.startsWith('image/')) { - result.image = action.attachments[0].url - } - - let notification = new window.Notification(title, result) - - // Chrome is known for not closing notifications automatically - // according to MDN, anyway. - setTimeout(notification.close.bind(notification), 5000) - } - } - } - const favoriteStatus = (favorite) => { const status = find(allStatuses, { id: toInteger(favorite.in_reply_to_status_id) }) if (status) { @@ -211,11 +183,6 @@ const addNewStatuses = (state, { statuses, showImmediately = false, timeline, us if (favorite.user.id === user.id) { status.favorited = true } - - // Add a notification if the user's status is favorited - if (status.user.id === user.id) { - addNotification({type: 'favorite', status, action: favorite}) - } } return status } @@ -253,13 +220,6 @@ const addNewStatuses = (state, { statuses, showImmediately = false, timeline, us favoriteStatus(favorite) } }, - 'follow': (status) => { - let re = new RegExp(`started following ${user.name} \\(${user.statusnet_profile_url}\\)`) - let repleroma = new RegExp(`started following ${user.screen_name}$`) - if (status.text.match(re) || status.text.match(repleroma)) { - addNotification({ type: 'follow', status: status, action: status }) - } - }, 'deletion': (deletion) => { const uri = deletion.uri @@ -269,7 +229,7 @@ const addNewStatuses = (state, { statuses, showImmediately = false, timeline, us return } - remove(state.notifications, ({action: {id}}) => id === status.id) + remove(state.notifications.data, ({action: {id}}) => id === status.id) remove(allStatuses, { uri }) if (timeline) { @@ -298,8 +258,54 @@ const addNewStatuses = (state, { statuses, showImmediately = false, timeline, us } } +const addNewNotifications = (state, { notifications, older }) => { + const allStatuses = state.allStatuses + each(notifications, (notification) => { + const action = notification.notice + // Only add a new notification if we don't have one for the same action + if (!find(state.notifications.data, (oldNotification) => oldNotification.action.id === action.id)) { + state.notifications.maxId = Math.max(notification.id, state.notifications.maxId) + state.notifications.minId = Math.min(notification.id, state.notifications.minId) + + console.log(notification) + const fresh = !older && !notification.is_seen && notification.id >= state.notifications.maxSavedId + const status = notification.ntype === 'like' + ? find(allStatuses, { id: action.in_reply_to_status_id }) + : action + state.notifications.data.push({ + type: notification.ntype, + status, + action, + // Always assume older notifications as seen + seen: !fresh + }) + + if ('Notification' in window && window.Notification.permission === 'granted') { + const title = action.user.name + const result = {} + result.icon = action.user.profile_image_url + result.body = action.text // there's a problem that it doesn't put a space before links tho + + // Shows first attached non-nsfw image, if any. Should add configuration for this somehow... + if (action.attachments && action.attachments.length > 0 && !action.nsfw && + action.attachments[0].mimetype.startsWith('image/')) { + result.image = action.attachments[0].url + } + + if (fresh) { + let notification = new window.Notification(title, result) + // Chrome is known for not closing notifications automatically + // according to MDN, anyway. + setTimeout(notification.close.bind(notification), 5000) + } + } + } + }) +} + export const mutations = { addNewStatuses, + addNewNotifications, showNewStatuses (state, { timeline }) { const oldTimeline = (state.timelines[timeline]) @@ -334,6 +340,9 @@ export const mutations = { setError (state, { value }) { state.error = value }, + setNotificationsError (state, { value }) { + state.notificationsError = value + }, setProfileView (state, { v }) { // load followers / friends only when needed state.timelines['user'].viewing = v @@ -345,6 +354,7 @@ export const mutations = { state.timelines['user'].followers = followers }, markNotificationsAsSeen (state, notifications) { + set(state.notifications, 'maxSavedId', state.notifications.maxId) each(notifications, (notification) => { notification.seen = true }) @@ -360,9 +370,15 @@ const statuses = { addNewStatuses ({ rootState, commit }, { statuses, showImmediately = false, timeline = false, noIdUpdate = false }) { commit('addNewStatuses', { statuses, showImmediately, timeline, noIdUpdate, user: rootState.users.currentUser }) }, + addNewNotifications ({ rootState, commit }, { notifications, older }) { + commit('addNewNotifications', { notifications, older }) + }, setError ({ rootState, commit }, { value }) { commit('setError', { value }) }, + setNotificationsError ({ rootState, commit }, { value }) { + commit('setNotificationsError', { value }) + }, addFriends ({ rootState, commit }, { friends }) { commit('addFriends', { friends }) }, diff --git a/src/services/api/api.service.js b/src/services/api/api.service.js index adf598b7..9a09e503 100644 --- a/src/services/api/api.service.js +++ b/src/services/api/api.service.js @@ -27,6 +27,7 @@ const BANNER_UPDATE_URL = '/api/account/update_profile_banner.json' const PROFILE_UPDATE_URL = '/api/account/update_profile.json' const EXTERNAL_PROFILE_URL = '/api/externalprofile/show.json' const QVITTER_USER_TIMELINE_URL = '/api/qvitter/statuses/user_timeline.json' +const QVITTER_USER_NOTIFICATIONS_URL = '/api/qvitter/statuses/notifications.json' const BLOCKING_URL = '/api/blocks/create.json' const UNBLOCKING_URL = '/api/blocks/destroy.json' const USER_URL = '/api/users/show.json' @@ -301,6 +302,7 @@ const fetchTimeline = ({timeline, credentials, since = false, until = false, use public: PUBLIC_TIMELINE_URL, friends: FRIENDS_TIMELINE_URL, mentions: MENTIONS_URL, + notifications: QVITTER_USER_NOTIFICATIONS_URL, 'publicAndExternal': PUBLIC_AND_EXTERNAL_TIMELINE_URL, user: QVITTER_USER_TIMELINE_URL, tag: TAG_TIMELINE_URL diff --git a/test/unit/specs/modules/statuses.spec.js b/test/unit/specs/modules/statuses.spec.js index f929192b..49b420b8 100644 --- a/test/unit/specs/modules/statuses.spec.js +++ b/test/unit/specs/modules/statuses.spec.js @@ -296,10 +296,10 @@ describe('The Statuses module', () => { mutations.addNewStatuses(state, { statuses: [retweet], user }) - expect(state.notifications.length).to.eql(1) - expect(state.notifications[0].status).to.eql(retweet) - expect(state.notifications[0].action).to.eql(retweet) - expect(state.notifications[0].type).to.eql('repeat') + expect(state.notifications.data.length).to.eql(1) + expect(state.notifications.data[0].status).to.eql(retweet) + expect(state.notifications.data[0].action).to.eql(retweet) + expect(state.notifications.data[0].type).to.eql('repeat') }) it('adds a notification when you are mentioned', () => { @@ -311,13 +311,13 @@ describe('The Statuses module', () => { mutations.addNewStatuses(state, { statuses: [status], user }) - expect(state.notifications.length).to.eql(0) + expect(state.notifications.data.length).to.eql(0) mutations.addNewStatuses(state, { statuses: [mentionedStatus], user }) - expect(state.notifications.length).to.eql(1) - expect(state.notifications[0].status).to.eql(mentionedStatus) - expect(state.notifications[0].action).to.eql(mentionedStatus) - expect(state.notifications[0].type).to.eql('mention') + expect(state.notifications.data.length).to.eql(1) + expect(state.notifications.data[0].status).to.eql(mentionedStatus) + expect(state.notifications.data[0].action).to.eql(mentionedStatus) + expect(state.notifications.data[0].type).to.eql('mention') }) it('removes a notification when the notice gets removed', () => { @@ -336,18 +336,18 @@ describe('The Statuses module', () => { mutations.addNewStatuses(state, { statuses: [status, otherStatus], user }) - expect(state.notifications.length).to.eql(1) + expect(state.notifications.data.length).to.eql(1) mutations.addNewStatuses(state, { statuses: [mentionedStatus], user }) expect(state.allStatuses.length).to.eql(3) - expect(state.notifications.length).to.eql(2) - expect(state.notifications[1].status).to.eql(mentionedStatus) - expect(state.notifications[1].action).to.eql(mentionedStatus) - expect(state.notifications[1].type).to.eql('mention') + expect(state.notifications.data.length).to.eql(2) + expect(state.notifications.data[1].status).to.eql(mentionedStatus) + expect(state.notifications.data[1].action).to.eql(mentionedStatus) + expect(state.notifications.data[1].type).to.eql('mention') mutations.addNewStatuses(state, { statuses: [deletion], user }) expect(state.allStatuses.length).to.eql(2) - expect(state.notifications.length).to.eql(1) + expect(state.notifications.data.length).to.eql(1) }) it('adds the message to mentions when you are mentioned', () => { @@ -384,7 +384,7 @@ describe('The Statuses module', () => { mutations.addNewStatuses(state, { statuses: [status], showImmediately: true, timeline: 'public', user }) mutations.addNewStatuses(state, { statuses: [favorite], showImmediately: true, timeline: 'public', user }) - expect(state.notifications).to.have.length(1) + expect(state.notifications.data).to.have.length(1) }) it('adds a notification when the user is followed', () => { @@ -402,7 +402,7 @@ describe('The Statuses module', () => { mutations.addNewStatuses(state, { statuses: [follow], showImmediately: true, timeline: 'public', user }) - expect(state.notifications).to.have.length(1) + expect(state.notifications.data).to.have.length(1) }) it('does not add a notification when an other user is followed', () => { @@ -420,7 +420,7 @@ describe('The Statuses module', () => { mutations.addNewStatuses(state, { statuses: [follow], showImmediately: true, timeline: 'public', user }) - expect(state.notifications).to.have.length(0) + expect(state.notifications.data).to.have.length(0) }) }) }) From d085cc85845c84a544ed5fff8a41aafd47937b6e Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Sun, 12 Aug 2018 14:15:09 +0300 Subject: [PATCH 02/19] undo test condition --- src/modules/statuses.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/statuses.js b/src/modules/statuses.js index a8a0d4fe..bc3799dd 100644 --- a/src/modules/statuses.js +++ b/src/modules/statuses.js @@ -268,7 +268,7 @@ const addNewNotifications = (state, { notifications, older }) => { state.notifications.minId = Math.min(notification.id, state.notifications.minId) console.log(notification) - const fresh = !older && !notification.is_seen && notification.id >= state.notifications.maxSavedId + const fresh = !older && !notification.is_seen && notification.id > state.notifications.maxSavedId const status = notification.ntype === 'like' ? find(allStatuses, { id: action.in_reply_to_status_id }) : action From ef515056b5cee27c2b62f3287349c58b67c286e4 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Mon, 13 Aug 2018 13:17:10 +0300 Subject: [PATCH 03/19] missing files and a plug for bad favs --- src/components/notification/notification.vue | 7 +++- .../notifications_fetcher.service.js | 41 +++++++++++++++++++ 2 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 src/services/notifications_fetcher/notifications_fetcher.service.js diff --git a/src/components/notification/notification.vue b/src/components/notification/notification.vue index 1c07bae9..5d50e72a 100644 --- a/src/components/notification/notification.vue +++ b/src/components/notification/notification.vue @@ -24,12 +24,15 @@ {{$t('notifications.followed_you')}}
- +
@{{notification.action.user.screen_name}}
- + +
+ Favorite for missing post +
diff --git a/src/services/notifications_fetcher/notifications_fetcher.service.js b/src/services/notifications_fetcher/notifications_fetcher.service.js new file mode 100644 index 00000000..5aedc4fb --- /dev/null +++ b/src/services/notifications_fetcher/notifications_fetcher.service.js @@ -0,0 +1,41 @@ +import apiService from '../api/api.service.js' + +const update = ({store, notifications, older}) => { + store.dispatch('setNotificationsError', { value: false }) + + store.dispatch('addNewNotifications', { notifications, older }) +} + +const fetchAndUpdate = ({store, credentials, older = false}) => { + const args = { credentials } + const rootState = store.rootState || store.state + const timelineData = rootState.statuses.notifications + + if (older) { + if (timelineData.minId !== Number.POSITIVE_INFINITY) { + args['until'] = timelineData.minId + } + } else { + args['since'] = timelineData.maxId + } + + args['timeline'] = 'notifications' + + return apiService.fetchTimeline(args) + .then((notifications) => { + update({store, notifications, older}) + }, () => store.dispatch('setNotificationsError', { value: true })) +} + +const startFetching = ({credentials, store}) => { + fetchAndUpdate({ credentials, store }) + const boundFetchAndUpdate = () => fetchAndUpdate({ credentials, store }) + return setInterval(boundFetchAndUpdate, 10000) +} + +const notificationsFetcher = { + fetchAndUpdate, + startFetching +} + +export default notificationsFetcher From ef04a786344ff50cdfeefc79722dafd9c52dbf86 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Thu, 16 Aug 2018 13:12:31 +0300 Subject: [PATCH 04/19] added workaround for broken favorites --- src/modules/api.js | 4 ++ src/modules/statuses.js | 37 +++++++++++++++---- src/modules/users.js | 2 + src/services/api/api.service.js | 3 ++ .../backend_interactor_service.js | 11 ++++++ .../timeline_fetcher.service.js | 4 +- 6 files changed, 51 insertions(+), 10 deletions(-) diff --git a/src/modules/api.js b/src/modules/api.js index a61340c2..20586f5c 100644 --- a/src/modules/api.js +++ b/src/modules/api.js @@ -46,6 +46,10 @@ const api = { store.commit('addFetcher', {timeline, fetcher}) } }, + fetchOldPost (store, { postId }) { + console.log(store) + store.state.backendInteractor.fetchOldPost({ store, postId }) + }, stopFetching (store, timeline) { const fetcher = store.state.fetchers[timeline] window.clearInterval(fetcher) diff --git a/src/modules/statuses.js b/src/modules/statuses.js index bc3799dd..bd6b968f 100644 --- a/src/modules/statuses.js +++ b/src/modules/statuses.js @@ -27,7 +27,8 @@ export const defaultState = { maxId: 0, maxSavedId: 0, minId: Number.POSITIVE_INFINITY, - data: [] + data: [], + brokenFavorites: {} }, favorites: new Set(), error: false, @@ -35,6 +36,7 @@ export const defaultState = { mentions: emptyTl(), public: emptyTl(), user: emptyTl(), + own: emptyTl(), publicAndExternal: emptyTl(), friends: emptyTl(), tag: emptyTl() @@ -140,6 +142,12 @@ const addNewStatuses = (state, { statuses, showImmediately = false, timeline, us const result = mergeOrAdd(allStatuses, allStatusesObject, status) status = result.item + const brokenFavorites = state.notifications.brokenFavorites[status.id] || [] + brokenFavorites.forEach((fav) => { + fav.status = status + }) + delete state.notifications.brokenFavorites[status.id] + if (result.new) { // We are mentioned in a post if (statusType(status) === 'status' && find(status.attentions, { id: user.id })) { @@ -174,7 +182,7 @@ const addNewStatuses = (state, { statuses, showImmediately = false, timeline, us return status } - const favoriteStatus = (favorite) => { + const favoriteStatus = (favorite, counter) => { const status = find(allStatuses, { id: toInteger(favorite.in_reply_to_status_id) }) if (status) { status.fave_num += 1 @@ -258,7 +266,7 @@ const addNewStatuses = (state, { statuses, showImmediately = false, timeline, us } } -const addNewNotifications = (state, { notifications, older }) => { +const addNewNotifications = (state, { dispatch, notifications, older }) => { const allStatuses = state.allStatuses each(notifications, (notification) => { const action = notification.notice @@ -267,18 +275,31 @@ const addNewNotifications = (state, { notifications, older }) => { state.notifications.maxId = Math.max(notification.id, state.notifications.maxId) state.notifications.minId = Math.min(notification.id, state.notifications.minId) - console.log(notification) const fresh = !older && !notification.is_seen && notification.id > state.notifications.maxSavedId const status = notification.ntype === 'like' ? find(allStatuses, { id: action.in_reply_to_status_id }) : action - state.notifications.data.push({ + + const result = { type: notification.ntype, status, action, // Always assume older notifications as seen seen: !fresh - }) + } + + if (notification.ntype === 'like' && !status) { + let broken = state.notifications.brokenFavorites[action.in_reply_to_status_id] + if (broken) { + broken.push(result) + } else { + dispatch('fetchOldPost', { postId: action.in_reply_to_status_id }) + broken = [ result ] + state.notifications.brokenFavorites[action.in_reply_to_status_id] = broken + } + } + + state.notifications.data.push(result) if ('Notification' in window && window.Notification.permission === 'granted') { const title = action.user.name @@ -370,8 +391,8 @@ const statuses = { addNewStatuses ({ rootState, commit }, { statuses, showImmediately = false, timeline = false, noIdUpdate = false }) { commit('addNewStatuses', { statuses, showImmediately, timeline, noIdUpdate, user: rootState.users.currentUser }) }, - addNewNotifications ({ rootState, commit }, { notifications, older }) { - commit('addNewNotifications', { notifications, older }) + addNewNotifications ({ rootState, commit, dispatch }, { notifications, older }) { + commit('addNewNotifications', { dispatch, notifications, older }) }, setError ({ rootState, commit }, { value }) { commit('setError', { value }) diff --git a/src/modules/users.js b/src/modules/users.js index 8303ecc1..03686c60 100644 --- a/src/modules/users.js +++ b/src/modules/users.js @@ -103,6 +103,8 @@ 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 9a09e503..351f88ca 100644 --- a/src/services/api/api.service.js +++ b/src/services/api/api.service.js @@ -305,6 +305,9 @@ 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 dbfb54f9..f65ad43e 100644 --- a/src/services/backend_interactor_service/backend_interactor_service.js +++ b/src/services/backend_interactor_service/backend_interactor_service.js @@ -54,6 +54,16 @@ const backendInteractorService = (credentials) => { return timelineFetcherService.startFetching({timeline, store, credentials, userId}) } + const fetchOldPost = ({store, postId}) => { + return timelineFetcherService.fetchAndUpdate({ + store, + credentials, + timeline: 'own', + older: true, + until: postId + }) + } + const setUserMute = ({id, muted = true}) => { return apiService.setUserMute({id, muted, credentials}) } @@ -86,6 +96,7 @@ const backendInteractorService = (credentials) => { fetchAllFollowing, verifyCredentials: apiService.verifyCredentials, startFetching, + fetchOldPost, setUserMute, fetchMutes, register, diff --git a/src/services/timeline_fetcher/timeline_fetcher.service.js b/src/services/timeline_fetcher/timeline_fetcher.service.js index bb5fdc2e..0e3e32d2 100644 --- a/src/services/timeline_fetcher/timeline_fetcher.service.js +++ b/src/services/timeline_fetcher/timeline_fetcher.service.js @@ -14,13 +14,13 @@ const update = ({store, statuses, timeline, showImmediately}) => { }) } -const fetchAndUpdate = ({store, credentials, timeline = 'friends', older = false, showImmediately = false, userId = false, tag = false}) => { +const fetchAndUpdate = ({store, credentials, timeline = 'friends', older = false, showImmediately = false, userId = false, tag = false, until}) => { const args = { timeline, credentials } const rootState = store.rootState || store.state const timelineData = rootState.statuses.timelines[camelCase(timeline)] if (older) { - args['until'] = timelineData.minVisibleId + args['until'] = until || timelineData.minVisibleId } else { args['since'] = timelineData.maxId } From e8f7491003de352bb265b0046c6e1a06a4dff21e Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Thu, 16 Aug 2018 13:20:29 +0300 Subject: [PATCH 05/19] fixed favoriting from notification column --- src/modules/statuses.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/modules/statuses.js b/src/modules/statuses.js index bd6b968f..da7a72dc 100644 --- a/src/modules/statuses.js +++ b/src/modules/statuses.js @@ -268,8 +268,10 @@ const addNewStatuses = (state, { statuses, showImmediately = false, timeline, us const addNewNotifications = (state, { dispatch, notifications, older }) => { const allStatuses = state.allStatuses + const allStatusesObject = state.allStatusesObject each(notifications, (notification) => { const action = notification.notice + mergeOrAdd(allStatuses, allStatusesObject, action) // Only add a new notification if we don't have one for the same action if (!find(state.notifications.data, (oldNotification) => oldNotification.action.id === action.id)) { state.notifications.maxId = Math.max(notification.id, state.notifications.maxId) From 693eb4b717e8e1e0ecd4c7c5e4e0fa9cbdd8541a Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Thu, 16 Aug 2018 13:41:45 +0300 Subject: [PATCH 06/19] cleanup, updated broken favorites look + localization strings --- src/components/notification/notification.vue | 10 ++++++---- src/components/notifications/notifications.scss | 10 ++++++++++ src/i18n/messages.js | 6 ++++-- src/modules/api.js | 1 - 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/components/notification/notification.vue b/src/components/notification/notification.vue index 5d50e72a..2485b9ff 100644 --- a/src/components/notification/notification.vue +++ b/src/components/notification/notification.vue @@ -29,10 +29,12 @@ - -
- Favorite for missing post -
+ diff --git a/src/components/notifications/notifications.scss b/src/components/notifications/notifications.scss index 008530b4..09741060 100644 --- a/src/components/notifications/notifications.scss +++ b/src/components/notifications/notifications.scss @@ -58,6 +58,16 @@ border-bottom-color: inherit; padding-left: 4px; + .broken-favorite { + border-radius: $fallback--tooltipRadius; + border-radius: var(--tooltipRadius, $fallback--tooltipRadius); + color: $fallback--faint; + color: var(--faint, $fallback--faint); + background-color: $fallback--cAlertRed; + background-color: var(--cAlertRed, $fallback--cAlertRed); + padding: 2px .5em + } + .avatar-compact { width: 32px; height: 32px; diff --git a/src/i18n/messages.js b/src/i18n/messages.js index e9d6e176..cd605c05 100644 --- a/src/i18n/messages.js +++ b/src/i18n/messages.js @@ -339,7 +339,8 @@ const en = { read: 'Read!', followed_you: 'followed you', favorited_you: 'favorited your status', - repeated_you: 'repeated your status' + repeated_you: 'repeated your status', + broken_favorite: 'Unknown status, searching for it...' }, login: { login: 'Log in', @@ -1628,7 +1629,8 @@ const ru = { read: 'Прочесть', followed_you: 'начал(а) читать вас', favorited_you: 'нравится ваш статус', - repeated_you: 'повторил(а) ваш статус' + repeated_you: 'повторил(а) ваш статус', + broken_favorite: 'Неизвестный статус, ищем...' }, login: { login: 'Войти', diff --git a/src/modules/api.js b/src/modules/api.js index 20586f5c..2f07a91e 100644 --- a/src/modules/api.js +++ b/src/modules/api.js @@ -47,7 +47,6 @@ const api = { } }, fetchOldPost (store, { postId }) { - console.log(store) store.state.backendInteractor.fetchOldPost({ store, postId }) }, stopFetching (store, timeline) { From decc209fdcd7b62ec46b559b3d5bfc0f1c343b25 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Thu, 16 Aug 2018 13:57:16 +0300 Subject: [PATCH 07/19] fix lint --- src/components/notifications/notifications.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/notifications/notifications.js b/src/components/notifications/notifications.js index f07d550e..55a9b0ab 100644 --- a/src/components/notifications/notifications.js +++ b/src/components/notifications/notifications.js @@ -1,7 +1,7 @@ import Notification from '../notification/notification.vue' import notificationsFetcher from '../../services/notifications_fetcher/notifications_fetcher.service.js' -import { sortBy, take, filter } from 'lodash' +import { sortBy, filter } from 'lodash' const Notifications = { created () { From 3afe65352b4cd57153b12cb024076f2b76f465df Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Thu, 16 Aug 2018 14:07:06 +0300 Subject: [PATCH 08/19] removed notification-relevant test because the functionality they are testing do not exist anymore. Gotta write more tho... --- test/unit/specs/modules/statuses.spec.js | 107 ----------------------- 1 file changed, 107 deletions(-) diff --git a/test/unit/specs/modules/statuses.spec.js b/test/unit/specs/modules/statuses.spec.js index 49b420b8..ecc7dc50 100644 --- a/test/unit/specs/modules/statuses.spec.js +++ b/test/unit/specs/modules/statuses.spec.js @@ -286,40 +286,6 @@ describe('The Statuses module', () => { }) describe('notifications', () => { - it('adds a notfications for retweets if you are the retweetet', () => { - const user = { id: 1 } - const state = cloneDeep(defaultState) - const status = makeMockStatus({id: 1}) - status.user = user - const retweet = makeMockStatus({id: 2, is_post_verb: false}) - retweet.retweeted_status = status - - mutations.addNewStatuses(state, { statuses: [retweet], user }) - - expect(state.notifications.data.length).to.eql(1) - expect(state.notifications.data[0].status).to.eql(retweet) - expect(state.notifications.data[0].action).to.eql(retweet) - expect(state.notifications.data[0].type).to.eql('repeat') - }) - - it('adds a notification when you are mentioned', () => { - const user = { id: 1 } - const state = cloneDeep(defaultState) - const status = makeMockStatus({id: 1}) - const mentionedStatus = makeMockStatus({id: 2}) - mentionedStatus.attentions = [user] - - mutations.addNewStatuses(state, { statuses: [status], user }) - - expect(state.notifications.data.length).to.eql(0) - - mutations.addNewStatuses(state, { statuses: [mentionedStatus], user }) - expect(state.notifications.data.length).to.eql(1) - expect(state.notifications.data[0].status).to.eql(mentionedStatus) - expect(state.notifications.data[0].action).to.eql(mentionedStatus) - expect(state.notifications.data[0].type).to.eql('mention') - }) - it('removes a notification when the notice gets removed', () => { const user = { id: 1 } const state = cloneDeep(defaultState) @@ -349,78 +315,5 @@ describe('The Statuses module', () => { expect(state.allStatuses.length).to.eql(2) expect(state.notifications.data.length).to.eql(1) }) - - it('adds the message to mentions when you are mentioned', () => { - const user = { id: 1 } - const state = cloneDeep(defaultState) - const status = makeMockStatus({id: 1}) - const mentionedStatus = makeMockStatus({id: 2}) - mentionedStatus.attentions = [user] - - mutations.addNewStatuses(state, { statuses: [status], user }) - - expect(state.timelines.mentions.statuses).to.have.length(0) - - mutations.addNewStatuses(state, { statuses: [mentionedStatus], user }) - expect(state.timelines.mentions.statuses).to.have.length(1) - expect(state.timelines.mentions.statuses).to.eql([mentionedStatus]) - }) - - it('adds a notfication when one of the user\'s status is favorited', () => { - const state = cloneDeep(defaultState) - const status = makeMockStatus({id: 1}) - const user = {id: 1} - status.user = user - - const favorite = { - id: 2, - is_post_verb: false, - in_reply_to_status_id: '1', // The API uses strings here... - uri: 'tag:shitposter.club,2016-08-21:fave:3895:note:773501:2016-08-21T16:52:15+00:00', - text: 'a favorited something by b', - user: {} - } - - mutations.addNewStatuses(state, { statuses: [status], showImmediately: true, timeline: 'public', user }) - mutations.addNewStatuses(state, { statuses: [favorite], showImmediately: true, timeline: 'public', user }) - - expect(state.notifications.data).to.have.length(1) - }) - - it('adds a notification when the user is followed', () => { - const state = cloneDeep(defaultState) - const user = {id: 1, screen_name: 'b'} - const follower = {id: 2, screen_name: 'a'} - - const follow = { - id: 3, - is_post_verb: false, - activity_type: 'follow', - text: 'a started following b', - user: follower - } - - mutations.addNewStatuses(state, { statuses: [follow], showImmediately: true, timeline: 'public', user }) - - expect(state.notifications.data).to.have.length(1) - }) - - it('does not add a notification when an other user is followed', () => { - const state = cloneDeep(defaultState) - const user = {id: 1, screen_name: 'b'} - const follower = {id: 2, screen_name: 'a'} - - const follow = { - id: 3, - is_post_verb: false, - activity_type: 'follow', - text: 'a started following b@shitposter.club', - user: follower - } - - mutations.addNewStatuses(state, { statuses: [follow], showImmediately: true, timeline: 'public', user }) - - expect(state.notifications.data).to.have.length(0) - }) }) }) From cc473df314ed44f0a4f6085508af3e5291e7fc11 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Thu, 16 Aug 2018 14:46:05 +0300 Subject: [PATCH 09/19] changed the only surviving and important test to accommodate for new notifications flow. --- test/unit/specs/modules/statuses.spec.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/unit/specs/modules/statuses.spec.js b/test/unit/specs/modules/statuses.spec.js index ecc7dc50..ba459b38 100644 --- a/test/unit/specs/modules/statuses.spec.js +++ b/test/unit/specs/modules/statuses.spec.js @@ -301,8 +301,28 @@ describe('The Statuses module', () => { deletion.uri = 'xxx' mutations.addNewStatuses(state, { statuses: [status, otherStatus], user }) + mutations.addNewNotifications( + state, + { + notifications: [{ + ntype: 'mention', + status: otherStatus, + notice: otherStatus, + is_seen: false + }] + }) expect(state.notifications.data.length).to.eql(1) + mutations.addNewNotifications( + state, + { + notifications: [{ + ntype: 'mention', + status: mentionedStatus, + notice: mentionedStatus, + is_seen: false + }] + }) mutations.addNewStatuses(state, { statuses: [mentionedStatus], user }) expect(state.allStatuses.length).to.eql(3) From 23a10002981f4e8a2a07a7ed53ccbd043b187c72 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Thu, 16 Aug 2018 18:13:31 +0300 Subject: [PATCH 10/19] fix post search query to have id +1 because search is exclusive --- .../backend_interactor_service/backend_interactor_service.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/backend_interactor_service/backend_interactor_service.js b/src/services/backend_interactor_service/backend_interactor_service.js index f65ad43e..c84373ac 100644 --- a/src/services/backend_interactor_service/backend_interactor_service.js +++ b/src/services/backend_interactor_service/backend_interactor_service.js @@ -60,7 +60,7 @@ const backendInteractorService = (credentials) => { credentials, timeline: 'own', older: true, - until: postId + until: postId + 1 }) } From 0b6f9c62a179c3937ebbfdcb334ae0cf1e82f314 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Sat, 18 Aug 2018 13:41:23 +0300 Subject: [PATCH 11/19] fix --- src/modules/statuses.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/statuses.js b/src/modules/statuses.js index da7a72dc..45dd3afa 100644 --- a/src/modules/statuses.js +++ b/src/modules/statuses.js @@ -270,8 +270,8 @@ const addNewNotifications = (state, { dispatch, notifications, older }) => { const allStatuses = state.allStatuses const allStatusesObject = state.allStatusesObject each(notifications, (notification) => { - const action = notification.notice - mergeOrAdd(allStatuses, allStatusesObject, action) + const result = mergeOrAdd(allStatuses, allStatusesObject, notification.notice) + const action = result.item // Only add a new notification if we don't have one for the same action if (!find(state.notifications.data, (oldNotification) => oldNotification.action.id === action.id)) { state.notifications.maxId = Math.max(notification.id, state.notifications.maxId) From 612aa56c8b2d6bae75bd47ff1846dfcfb012d525 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Mon, 20 Aug 2018 19:01:54 +0300 Subject: [PATCH 12/19] 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 45dd3afa..1e1bf72f 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 c592fe4e..ba548765 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 1cb5e0b8..4f6af06d 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 c84373ac..5742441c 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 13/19] 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 845facc3..0bcfb25a 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 14/19] 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 1e1bf72f..063f5f9c 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 5aedc4fb..74a4bcda 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 15/19] 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 2bc71bfe..08557ea2 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 16/19] 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 08557ea2..5881fbaa 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 17/19] 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 55a9b0ab..b24250b0 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 5881fbaa..5b09685b 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 859730ed..a0b0e5f5 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 063f5f9c..8e1e7fe7 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 From a196c3551a1a44660c2f9c4ee940bb988782e929 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Tue, 21 Aug 2018 00:21:35 +0300 Subject: [PATCH 18/19] Revert "Drop the entire thing about hidden "own" timeline since it doesn't necessarily" This reverts commit 612aa56c8b2d6bae75bd47ff1846dfcfb012d525. --- 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, 8 insertions(+), 2 deletions(-) diff --git a/src/modules/statuses.js b/src/modules/statuses.js index 8e1e7fe7..ff2cb098 100644 --- a/src/modules/statuses.js +++ b/src/modules/statuses.js @@ -38,6 +38,7 @@ 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 ba548765..c592fe4e 100644 --- a/src/modules/users.js +++ b/src/modules/users.js @@ -107,6 +107,8 @@ 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 4f6af06d..1cb5e0b8 100644 --- a/src/services/api/api.service.js +++ b/src/services/api/api.service.js @@ -306,6 +306,9 @@ 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 5742441c..c84373ac 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, timeline = 'friends'}) => { + const fetchOldPost = ({store, postId}) => { return timelineFetcherService.fetchAndUpdate({ store, credentials, - timeline, + timeline: 'own', older: true, until: postId + 1 }) From 13acdc4a00f7c4e8487de0c95fe69ff110f13e6e Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Wed, 22 Aug 2018 15:51:03 +0300 Subject: [PATCH 19/19] fixed error not displaying for 500 error. --- .../notifications_fetcher/notifications_fetcher.service.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/services/notifications_fetcher/notifications_fetcher.service.js b/src/services/notifications_fetcher/notifications_fetcher.service.js index 74a4bcda..1480cded 100644 --- a/src/services/notifications_fetcher/notifications_fetcher.service.js +++ b/src/services/notifications_fetcher/notifications_fetcher.service.js @@ -25,6 +25,7 @@ const fetchAndUpdate = ({store, credentials, older = false}) => { .then((notifications) => { update({store, notifications, older}) }, () => store.dispatch('setNotificationsError', { value: true })) + .catch(() => store.dispatch('setNotificationsError', { value: true })) } const startFetching = ({credentials, store}) => {