diff options
| author | Henry Jameson <me@hjkos.com> | 2018-12-05 10:43:03 +0300 |
|---|---|---|
| committer | Henry Jameson <me@hjkos.com> | 2018-12-05 10:43:03 +0300 |
| commit | 51cf4dc298303127c9d59015f4eef52f6f6e1103 (patch) | |
| tree | d9e13fd7069f9af3985c39b2b938b64ea8ac0217 /src/modules/statuses.js | |
| parent | e95b6c7e538e5b65ee81fd5e5d3cb905609c6bab (diff) | |
| parent | 914386270796fa2ec460b828710ee31ef870ea69 (diff) | |
Merge remote-tracking branch 'upstream/develop' into feature/theming2
* upstream/develop:
Fix iOS Safari from making videos play fullscreen by default
added PR comments
resolved the lint
used the deleted data param as condition in status template
Switch to "timeline" when pressing user-settings
Added user setting tooltip
made links in user bio always open in new tabs
addressed PR comments
added tooltip
Add userId property to timelines so that we don't overwrite user timeline meant for another user
Added option to auto-hide subject field when it's empty.
removes hacks from notifications storage, adds api call to let server update is_seen attribute
fixes vimium not giving retweet button a hint
Do not use underscore at the beginning of the method
Logout user on password change
Route user to the correct profile URL
Typo
Fix filetype detection
Switch to settings when touching settings
Switch to timeline on nav panel actions
Diffstat (limited to 'src/modules/statuses.js')
| -rw-r--r-- | src/modules/statuses.js | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/src/modules/statuses.js b/src/modules/statuses.js index 2c3d2550..8cdd4e28 100644 --- a/src/modules/statuses.js +++ b/src/modules/statuses.js @@ -1,5 +1,4 @@ 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' @@ -16,6 +15,7 @@ const emptyTl = () => ({ followers: [], friends: [], viewing: 'statuses', + userId: 0, flushMarker: 0 }) @@ -26,7 +26,6 @@ export const defaultState = { notifications: { desktopNotificationSilence: true, maxId: 0, - maxSavedId: 0, minId: Number.POSITIVE_INFINITY, data: [], error: false, @@ -132,7 +131,7 @@ const sortTimeline = (timeline) => { return timeline } -const addNewStatuses = (state, { statuses, showImmediately = false, timeline, user = {}, noIdUpdate = false }) => { +const addNewStatuses = (state, { statuses, showImmediately = false, timeline, user = {}, noIdUpdate = false, userId }) => { // Sanity check if (!isArray(statuses)) { return false @@ -149,6 +148,13 @@ const addNewStatuses = (state, { statuses, showImmediately = false, timeline, us timelineObject.maxId = maxNew } + // This makes sure that user timeline won't get data meant for other + // user. I.e. opening different user profiles makes request which could + // return data late after user already viewing different user profile + if (timeline === 'user' && timelineObject.userId !== userId) { + return + } + const addStatus = (status, showImmediately, addToTimeline = true) => { const result = mergeOrAdd(allStatuses, allStatusesObject, status) status = result.item @@ -297,7 +303,7 @@ const addNewNotifications = (state, { dispatch, notifications, older, visibleNot state.notifications.maxId = Math.max(notification.id, state.notifications.maxId) state.notifications.minId = Math.min(notification.id, state.notifications.minId) - const fresh = !older && !notification.is_seen && notification.id > state.notifications.maxSavedId + const fresh = !notification.is_seen const status = notification.ntype === 'like' ? find(allStatuses, { id: action.in_reply_to_status_id }) : action @@ -306,7 +312,6 @@ const addNewNotifications = (state, { dispatch, notifications, older, visibleNot type: notification.ntype, status, action, - // Always assume older notifications as seen seen: !fresh } @@ -404,9 +409,8 @@ export const mutations = { addFollowers (state, { followers }) { state.timelines['user'].followers = followers }, - markNotificationsAsSeen (state, notifications) { - set(state.notifications, 'maxSavedId', state.notifications.maxId) - each(notifications, (notification) => { + markNotificationsAsSeen (state) { + each(state.notifications.data, (notification) => { notification.seen = true }) }, @@ -418,8 +422,8 @@ export const mutations = { const statuses = { state: defaultState, actions: { - addNewStatuses ({ rootState, commit }, { statuses, showImmediately = false, timeline = false, noIdUpdate = false }) { - commit('addNewStatuses', { statuses, showImmediately, timeline, noIdUpdate, user: rootState.users.currentUser }) + addNewStatuses ({ rootState, commit }, { statuses, showImmediately = false, timeline = false, noIdUpdate = false, userId }) { + commit('addNewStatuses', { statuses, showImmediately, timeline, noIdUpdate, user: rootState.users.currentUser, userId }) }, addNewNotifications ({ rootState, commit, dispatch }, { notifications, older }) { commit('addNewNotifications', { visibleNotificationTypes: visibleNotificationTypes(rootState), dispatch, notifications, older }) @@ -484,6 +488,13 @@ const statuses = { }, queueFlush ({ rootState, commit }, { timeline, id }) { commit('queueFlush', { timeline, id }) + }, + markNotificationsAsSeen ({ rootState, commit }) { + commit('markNotificationsAsSeen') + apiService.markNotificationsAsSeen({ + id: rootState.statuses.notifications.maxId, + credentials: rootState.users.currentUser.credentials + }) } }, mutations |
