From 1aa0e8d7e026267aa2af82fbd18cf7521ad842e9 Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 4 Apr 2019 12:47:25 -0400 Subject: [PATCH] #468 - pin/unpin status --- src/components/status/status.js | 10 +++++++++ src/components/status/status.vue | 22 ++++++++++++++----- src/modules/statuses.js | 7 ++++++ .../entity_normalizer.service.js | 1 + 4 files changed, 34 insertions(+), 6 deletions(-) diff --git a/src/components/status/status.js b/src/components/status/status.js index c01cfe79..c52e026a 100644 --- a/src/components/status/status.js +++ b/src/components/status/status.js @@ -353,6 +353,16 @@ const Status = { this.expandingSubject = true } }, + pinStatus () { + this.$store.state.api.backendInteractor.pinOwnStatus(this.status.id).then((status) => { + this.$store.dispatch('updatePinned', status) + }) + }, + unpinStatus () { + this.$store.state.api.backendInteractor.unpinOwnStatus(this.status.id).then((status) => { + this.$store.dispatch('updatePinned', status) + }) + }, replyEnter (id, event) { this.showPreview = true const targetId = id diff --git a/src/components/status/status.vue b/src/components/status/status.vue index 21077972..0a2562c0 100644 --- a/src/components/status/status.vue +++ b/src/components/status/status.vue @@ -52,12 +52,18 @@ - - +
+ +
+
+ +
+
+ +
+
+ +
@@ -678,6 +684,10 @@ a.unmute { } } +.button-action-icon { + cursor: pointer; +} + @media all and (max-width: 800px) { .status-el { .retweet-info { diff --git a/src/modules/statuses.js b/src/modules/statuses.js index 4c92d4e1..176e5f42 100644 --- a/src/modules/statuses.js +++ b/src/modules/statuses.js @@ -424,6 +424,10 @@ export const mutations = { newStatus.favoritedBy.push(user) } }, + setPinned (state, { status }) { + const newStatus = state.allStatusesObject[status.id] + newStatus.pinned = status.pinned + }, setRetweeted (state, { status, value }) { const newStatus = state.allStatusesObject[status.id] @@ -533,6 +537,9 @@ const statuses = { rootState.api.backendInteractor.unfavorite(status.id) .then(status => commit('setFavoritedConfirm', { status, user: rootState.users.currentUser })) }, + updatePinned ({ rootState, commit }, status) { + commit('setPinned', { status }) + }, retweet ({ rootState, commit }, status) { // Optimistic retweeting... commit('setRetweeted', { status, value: true }) diff --git a/src/services/entity_normalizer/entity_normalizer.service.js b/src/services/entity_normalizer/entity_normalizer.service.js index 7a8708d5..97e20b99 100644 --- a/src/services/entity_normalizer/entity_normalizer.service.js +++ b/src/services/entity_normalizer/entity_normalizer.service.js @@ -211,6 +211,7 @@ export const parseStatus = (data) => { output.summary_html = addEmojis(data.spoiler_text, data.emojis) output.external_url = data.url + output.pinned = data.pinned } else { output.favorited = data.favorited output.fave_num = data.fave_num