diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/components/notifications/notifications.js | 2 | ||||
| -rw-r--r-- | src/components/post_status_form/post_status_form.js | 9 | ||||
| -rw-r--r-- | src/components/post_status_form/post_status_form.vue | 2 | ||||
| -rw-r--r-- | src/components/settings/settings.js | 7 | ||||
| -rw-r--r-- | src/components/settings/settings.vue | 6 | ||||
| -rw-r--r-- | src/components/user_profile/user_profile.js | 1 | ||||
| -rw-r--r-- | src/i18n/en.json | 1 | ||||
| -rw-r--r-- | src/i18n/ru.json | 1 | ||||
| -rw-r--r-- | src/main.js | 1 | ||||
| -rw-r--r-- | src/modules/config.js | 3 | ||||
| -rw-r--r-- | src/modules/instance.js | 1 | ||||
| -rw-r--r-- | src/modules/statuses.js | 31 | ||||
| -rw-r--r-- | src/services/api/api.service.js | 16 | ||||
| -rw-r--r-- | src/services/timeline_fetcher/timeline_fetcher.service.js | 6 |
14 files changed, 70 insertions, 17 deletions
diff --git a/src/components/notifications/notifications.js b/src/components/notifications/notifications.js index 58956f98..945ffd1f 100644 --- a/src/components/notifications/notifications.js +++ b/src/components/notifications/notifications.js @@ -52,7 +52,7 @@ const Notifications = { }, methods: { markAsSeen () { - this.$store.commit('markNotificationsAsSeen', this.visibleNotifications) + this.$store.dispatch('markNotificationsAsSeen', this.visibleNotifications) }, fetchOlderNotifications () { const store = this.$store diff --git a/src/components/post_status_form/post_status_form.js b/src/components/post_status_form/post_status_form.js index fa86ee59..789243cf 100644 --- a/src/components/post_status_form/post_status_form.js +++ b/src/components/post_status_form/post_status_form.js @@ -150,6 +150,15 @@ const PostStatusForm = { scopeOptionsEnabled () { return this.$store.state.instance.scopeOptionsEnabled }, + alwaysShowSubject () { + if (typeof this.$store.state.config.alwaysShowSubjectInput !== 'undefined') { + return this.$store.state.config.alwaysShowSubjectInput + } else if (typeof this.$store.state.instance.alwaysShowSubjectInput !== 'undefined') { + return this.$store.state.instance.alwaysShowSubjectInput + } else { + return this.$store.state.instance.scopeOptionsEnabled + } + }, formattingOptionsEnabled () { return this.$store.state.instance.formattingOptionsEnabled } diff --git a/src/components/post_status_form/post_status_form.vue b/src/components/post_status_form/post_status_form.vue index 42e9c65c..e4c46b9a 100644 --- a/src/components/post_status_form/post_status_form.vue +++ b/src/components/post_status_form/post_status_form.vue @@ -11,7 +11,7 @@ </i18n> <p v-if="this.newStatus.visibility == 'direct'" class="visibility-notice">{{ $t('post_status.direct_warning') }}</p> <input - v-if="scopeOptionsEnabled" + v-if="newStatus.spoilerText || alwaysShowSubject" type="text" :placeholder="$t('post_status.content_warning')" v-model="newStatus.spoilerText" diff --git a/src/components/settings/settings.js b/src/components/settings/settings.js index 910eea63..91a2014a 100644 --- a/src/components/settings/settings.js +++ b/src/components/settings/settings.js @@ -38,6 +38,10 @@ const settings = { ? instance.subjectLineBehavior : user.subjectLineBehavior, subjectLineBehaviorDefault: instance.subjectLineBehavior, + alwaysShowSubjectInputLocal: typeof user.alwaysShowSubjectInput === 'undefined' + ? instance.alwaysShowSubjectInput + : user.alwaysShowSubjectInput, + alwaysShowSubjectInputDefault: instance.alwaysShowSubjectInput, scopeCopyLocal: user.scopeCopy, scopeCopyDefault: this.$t('settings.values.' + instance.scopeCopy), stopGifs: user.stopGifs, @@ -122,6 +126,9 @@ const settings = { scopeCopyLocal (value) { this.$store.dispatch('setOption', { name: 'scopeCopy', value }) }, + alwaysShowSubjectInputLocal (value) { + this.$store.dispatch('setOption', { name: 'alwaysShowSubjectInput', value }) + }, subjectLineBehaviorLocal (value) { this.$store.dispatch('setOption', { name: 'subjectLineBehavior', value }) }, diff --git a/src/components/settings/settings.vue b/src/components/settings/settings.vue index 4a236d23..de506e4d 100644 --- a/src/components/settings/settings.vue +++ b/src/components/settings/settings.vue @@ -64,6 +64,12 @@ </label> </li> <li> + <input type="checkbox" id="subjectHide" v-model="alwaysShowSubjectInputLocal"> + <label for="subjectHide"> + {{$t('settings.subject_input_always_show')}} {{$t('settings.instance_default', { value: alwaysShowSubjectInputDefault })}} + </label> + </li> + <li> <div> {{$t('settings.subject_line_behavior')}} <label for="subjectLineBehavior" class="select"> diff --git a/src/components/user_profile/user_profile.js b/src/components/user_profile/user_profile.js index 26be1801..1d79713d 100644 --- a/src/components/user_profile/user_profile.js +++ b/src/components/user_profile/user_profile.js @@ -27,6 +27,7 @@ const UserProfile = { }, watch: { userId () { + this.$store.dispatch('stopFetching', 'user') this.$store.commit('clearTimeline', { timeline: 'user' }) this.$store.dispatch('startFetching', ['user', this.userId]) } diff --git a/src/i18n/en.json b/src/i18n/en.json index 314fa083..ae4f93d9 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -159,6 +159,7 @@ "set_new_profile_background": "Set new profile background", "set_new_profile_banner": "Set new profile banner", "settings": "Settings", + "subject_input_always_show": "Always show subject field", "subject_line_behavior": "Copy subject when replying", "subject_line_email": "Like email: \"re: subject\"", "subject_line_mastodon": "Like mastodon: copy as is", diff --git a/src/i18n/ru.json b/src/i18n/ru.json index 921bf67e..9c28ccf4 100644 --- a/src/i18n/ru.json +++ b/src/i18n/ru.json @@ -133,6 +133,7 @@ "set_new_profile_background": "Загрузить новый фон профиля", "set_new_profile_banner": "Загрузить новый баннер профиля", "settings": "Настройки", + "subject_input_always_show": "Всегда показывать поле ввода темы", "stop_gifs": "Проигрывать GIF анимации только при наведении", "streaming": "Включить автоматическую загрузку новых сообщений при прокрутке вверх", "text": "Текст", diff --git a/src/main.js b/src/main.js index 9f094ada..378fe95c 100644 --- a/src/main.js +++ b/src/main.js @@ -47,7 +47,6 @@ const persistedStateOptions = { paths: [ 'config', 'users.lastLoginName', - 'statuses.notifications.maxSavedId', 'oauth' ] } diff --git a/src/modules/config.js b/src/modules/config.js index 0d36e9bf..f23cacb7 100644 --- a/src/modules/config.js +++ b/src/modules/config.js @@ -27,7 +27,8 @@ const defaultState = { highlight: {}, interfaceLanguage: browserLocale, scopeCopy: undefined, // instance default - subjectLineBehavior: undefined // instance default + subjectLineBehavior: undefined, // instance default + alwaysShowSubjectInput: undefined // instance default } const config = { diff --git a/src/modules/instance.js b/src/modules/instance.js index 9a39cccf..641424b6 100644 --- a/src/modules/instance.js +++ b/src/modules/instance.js @@ -17,6 +17,7 @@ const defaultState = { showInstanceSpecificPanel: false, scopeOptionsEnabled: true, formattingOptionsEnabled: false, + alwaysShowSubjectInput: true, collapseMessageWithSubject: false, hidePostStats: false, hideUserStats: false, 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 diff --git a/src/services/api/api.service.js b/src/services/api/api.service.js index 714c0fc7..ae876b7f 100644 --- a/src/services/api/api.service.js +++ b/src/services/api/api.service.js @@ -29,6 +29,7 @@ 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 QVITTER_USER_NOTIFICATIONS_READ_URL = '/api/qvitter/statuses/notifications/read.json' const BLOCKING_URL = '/api/blocks/create.json' const UNBLOCKING_URL = '/api/blocks/destroy.json' const USER_URL = '/api/users/show.json' @@ -460,6 +461,18 @@ const suggestions = ({credentials}) => { }).then((data) => data.json()) } +const markNotificationsAsSeen = ({id, credentials}) => { + const body = new FormData() + + body.append('latest_id', id) + + return fetch(QVITTER_USER_NOTIFICATIONS_READ_URL, { + body, + headers: authHeaders(credentials), + method: 'POST' + }).then((data) => data.json()) +} + const apiService = { verifyCredentials, fetchTimeline, @@ -494,7 +507,8 @@ const apiService = { fetchFollowRequests, approveUser, denyUser, - suggestions + suggestions, + markNotificationsAsSeen } export default apiService diff --git a/src/services/timeline_fetcher/timeline_fetcher.service.js b/src/services/timeline_fetcher/timeline_fetcher.service.js index 0e3e32d2..c2a7de56 100644 --- a/src/services/timeline_fetcher/timeline_fetcher.service.js +++ b/src/services/timeline_fetcher/timeline_fetcher.service.js @@ -2,13 +2,14 @@ import { camelCase } from 'lodash' import apiService from '../api/api.service.js' -const update = ({store, statuses, timeline, showImmediately}) => { +const update = ({store, statuses, timeline, showImmediately, userId}) => { const ccTimeline = camelCase(timeline) store.dispatch('setError', { value: false }) store.dispatch('addNewStatuses', { timeline: ccTimeline, + userId, statuses, showImmediately }) @@ -33,7 +34,7 @@ const fetchAndUpdate = ({store, credentials, timeline = 'friends', older = false if (!older && statuses.length >= 20 && !timelineData.loading) { store.dispatch('queueFlush', { timeline: timeline, id: timelineData.maxId }) } - update({store, statuses, timeline, showImmediately}) + update({store, statuses, timeline, showImmediately, userId}) }, () => store.dispatch('setError', { value: true })) } @@ -41,6 +42,7 @@ const startFetching = ({timeline = 'friends', credentials, store, userId = false const rootState = store.rootState || store.state 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) |
