From c7514be46fd9dbffdeb92cd01799a8dc6497011b Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Tue, 18 Dec 2018 23:31:10 +0300 Subject: [PATCH 1/6] Fixed some settings not using defaults from instance config. Made some parts of code more readable --- src/components/post_status_form/post_status_form.js | 6 +++++- src/components/settings/settings.js | 12 +++++++++++- src/components/status/status.js | 4 +++- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/components/post_status_form/post_status_form.js b/src/components/post_status_form/post_status_form.js index 0ce2aff0..89091f8e 100644 --- a/src/components/post_status_form/post_status_form.js +++ b/src/components/post_status_form/post_status_form.js @@ -41,12 +41,16 @@ const PostStatusForm = { const preset = this.$route.query.message let statusText = preset || '' + const scopeCopy = typeof this.$store.state.config.scopeCopy === 'undefined' + ? this.$store.state.instance.scopeCopy + : this.$store.state.config.scopeCopy + if (this.replyTo) { const currentUser = this.$store.state.users.currentUser statusText = buildMentionsString({ user: this.repliedUser, attentions: this.attentions }, currentUser) } - const scope = (this.copyMessageScope && this.$store.state.config.scopeCopy || this.copyMessageScope === 'direct') + const scope = (this.copyMessageScope && scopeCopy || this.copyMessageScope === 'direct') ? this.copyMessageScope : this.$store.state.users.currentUser.default_scope diff --git a/src/components/settings/settings.js b/src/components/settings/settings.js index 681ccda8..d45ec72d 100644 --- a/src/components/settings/settings.js +++ b/src/components/settings/settings.js @@ -15,14 +15,17 @@ const settings = { hideNsfwLocal: user.hideNsfw, hideISPLocal: user.hideISP, preloadImage: user.preloadImage, + hidePostStatsLocal: typeof user.hidePostStats === 'undefined' ? instance.hidePostStats : user.hidePostStats, hidePostStatsDefault: this.$t('settings.values.' + instance.hidePostStats), + hideUserStatsLocal: typeof user.hideUserStats === 'undefined' ? instance.hideUserStats : user.hideUserStats, hideUserStatsDefault: this.$t('settings.values.' + instance.hideUserStats), + notificationVisibilityLocal: user.notificationVisibility, replyVisibilityLocal: user.replyVisibility, loopVideoLocal: user.loopVideo, @@ -32,20 +35,27 @@ const settings = { streamingLocal: user.streaming, pauseOnUnfocusedLocal: user.pauseOnUnfocused, hoverPreviewLocal: user.hoverPreview, + collapseMessageWithSubjectLocal: typeof user.collapseMessageWithSubject === 'undefined' ? instance.collapseMessageWithSubject : user.collapseMessageWithSubject, collapseMessageWithSubjectDefault: this.$t('settings.values.' + instance.collapseMessageWithSubject), + subjectLineBehaviorLocal: typeof user.subjectLineBehavior === 'undefined' ? instance.subjectLineBehavior : user.subjectLineBehavior, subjectLineBehaviorDefault: instance.subjectLineBehavior, + alwaysShowSubjectInputLocal: typeof user.alwaysShowSubjectInput === 'undefined' ? instance.alwaysShowSubjectInput : user.alwaysShowSubjectInput, alwaysShowSubjectInputDefault: instance.alwaysShowSubjectInput, - scopeCopyLocal: user.scopeCopy, + + scopeCopyLocal: typeof user.scopeCopy === 'undefined' + ? instance.scopeCopy + : user.scopeCopy, scopeCopyDefault: this.$t('settings.values.' + instance.scopeCopy), + stopGifs: user.stopGifs, webPushNotificationsLocal: user.webPushNotifications, loopSilentAvailable: diff --git a/src/components/status/status.js b/src/components/status/status.js index 47a62fdf..e683056f 100644 --- a/src/components/status/status.js +++ b/src/components/status/status.js @@ -188,7 +188,9 @@ const Status = { }, replySubject () { if (!this.status.summary) return '' - const behavior = this.$store.state.config.subjectLineBehavior + const behavior = typeof this.$store.state.config.subjectLineBehavior === 'undefined' + ? this.$store.state.instance.subjectLineBehavior + : this.$store.state.config.subjectLineBehavior const startsWithRe = this.status.summary.match(/^re[: ]/i) if (behavior !== 'noop' && startsWithRe || behavior === 'masto') { return this.status.summary From 5c2030e467277de9bc75debe489a34e8a1c9b2fe Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Wed, 19 Dec 2018 01:55:53 +0300 Subject: [PATCH 2/6] no more "broken favorite" --- src/components/notification/notification.vue | 5 +--- .../notifications/notifications.scss | 10 -------- src/modules/api.js | 3 --- src/modules/statuses.js | 23 ++----------------- src/modules/users.js | 2 -- src/services/api/api.service.js | 3 --- .../backend_interactor_service.js | 11 --------- 7 files changed, 3 insertions(+), 54 deletions(-) diff --git a/src/components/notification/notification.vue b/src/components/notification/notification.vue index 1c89cbb7..56791d45 100644 --- a/src/components/notification/notification.vue +++ b/src/components/notification/notification.vue @@ -33,10 +33,7 @@ diff --git a/src/components/notifications/notifications.scss b/src/components/notifications/notifications.scss index a6468e01..5c4ca1b9 100644 --- a/src/components/notifications/notifications.scss +++ b/src/components/notifications/notifications.scss @@ -36,16 +36,6 @@ border-color: $fallback--border; border-color: var(--border, $fallback--border); - .broken-favorite { - border-radius: $fallback--tooltipRadius; - border-radius: var(--tooltipRadius, $fallback--tooltipRadius); - color: $fallback--text; - color: var(--alertErrorText, $fallback--text); - background-color: $fallback--alertError; - background-color: var(--alertError, $fallback--alertError); - padding: 2px .5em - } - .avatar-compact { width: 32px; height: 32px; diff --git a/src/modules/api.js b/src/modules/api.js index 2f07a91e..a61340c2 100644 --- a/src/modules/api.js +++ b/src/modules/api.js @@ -46,9 +46,6 @@ const api = { store.commit('addFetcher', {timeline, fetcher}) } }, - fetchOldPost (store, { postId }) { - 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 5bbf5f46..8c2d36bc 100644 --- a/src/modules/statuses.js +++ b/src/modules/statuses.js @@ -27,8 +27,7 @@ export const defaultState = { maxId: 0, minId: Number.POSITIVE_INFINITY, data: [], - error: false, - brokenFavorites: {} + error: false }, favorites: new Set(), error: false, @@ -36,7 +35,6 @@ export const defaultState = { mentions: emptyTl(), public: emptyTl(), user: emptyTl(), - own: emptyTl(), publicAndExternal: emptyTl(), friends: emptyTl(), tag: emptyTl(), @@ -158,12 +156,6 @@ 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 })) { @@ -304,7 +296,7 @@ const addNewNotifications = (state, { dispatch, notifications, older, visibleNot const fresh = !notification.is_seen const status = notification.ntype === 'like' - ? find(allStatuses, { id: action.in_reply_to_status_id }) + ? action.favorited_status : action const result = { @@ -314,17 +306,6 @@ const addNewNotifications = (state, { dispatch, notifications, older, visibleNot 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') { diff --git a/src/modules/users.js b/src/modules/users.js index 31fe94fc..13d3f26e 100644 --- a/src/modules/users.js +++ b/src/modules/users.js @@ -195,8 +195,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 b509c905..182f9126 100644 --- a/src/services/api/api.service.js +++ b/src/services/api/api.service.js @@ -300,9 +300,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 cc72f607..f44f52b6 100644 --- a/src/services/backend_interactor_service/backend_interactor_service.js +++ b/src/services/backend_interactor_service/backend_interactor_service.js @@ -54,16 +54,6 @@ 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 + 1 - }) - } - const setUserMute = ({id, muted = true}) => { return apiService.setUserMute({id, muted, credentials}) } @@ -97,7 +87,6 @@ const backendInteractorService = (credentials) => { fetchAllFollowing, verifyCredentials: apiService.verifyCredentials, startFetching, - fetchOldPost, setUserMute, fetchMutes, register, From b7962a224c55a20aaa411f01452879aec824cf93 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Thu, 20 Dec 2018 07:54:55 +0300 Subject: [PATCH 3/6] fixes many problems related to user profile --- src/components/user_profile/user_profile.js | 13 +++++++++---- src/components/user_profile/user_profile.vue | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/components/user_profile/user_profile.js b/src/components/user_profile/user_profile.js index deee77dd..77bb1835 100644 --- a/src/components/user_profile/user_profile.js +++ b/src/components/user_profile/user_profile.js @@ -4,7 +4,6 @@ import Timeline from '../timeline/timeline.vue' const UserProfile = { created () { - debugger this.$store.commit('clearTimeline', { timeline: 'user' }) this.$store.dispatch('startFetching', ['user', this.fetchBy]) if (!this.user) { @@ -19,18 +18,24 @@ const UserProfile = { return this.$store.state.statuses.timelines.user }, userId () { - return this.$route.params.id + return this.$route.params.id || this.user.id }, userName () { return this.$route.params.name }, + friends () { + return this.user.friends + }, + followers () { + return this.user.followers + }, user () { if (this.timeline.statuses[0]) { return this.timeline.statuses[0].user } else { return Object.values(this.$store.state.users.usersObject).filter(user => { return (this.isExternal ? user.id === this.userId : user.screen_name === this.userName) - })[0] || false + })[0] || {} } }, fetchBy () { @@ -68,7 +73,7 @@ const UserProfile = { this.$store.dispatch('startFetching', ['user', this.userId]) }, user () { - if (!this.user.followers) { + if (this.user.id && !this.user.followers) { this.fetchFollowers() this.fetchFriends() } diff --git a/src/components/user_profile/user_profile.vue b/src/components/user_profile/user_profile.vue index 5c823b3d..84fdba45 100644 --- a/src/components/user_profile/user_profile.vue +++ b/src/components/user_profile/user_profile.vue @@ -1,6 +1,6 @@