#468 - pin/unpin status

This commit is contained in:
dave 2019-04-04 12:47:25 -04:00 committed by taehoon
parent b491e6acbe
commit 1aa0e8d7e0
4 changed files with 34 additions and 6 deletions

View file

@ -353,6 +353,16 @@ const Status = {
this.expandingSubject = true 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) { replyEnter (id, event) {
this.showPreview = true this.showPreview = true
const targetId = id const targetId = id

View file

@ -52,12 +52,18 @@
<a :href="status.external_url" target="_blank" v-if="!status.is_local && !isPreview" class="source_url" title="Source"> <a :href="status.external_url" target="_blank" v-if="!status.is_local && !isPreview" class="source_url" title="Source">
<i class="button-icon icon-link-ext-alt"></i> <i class="button-icon icon-link-ext-alt"></i>
</a> </a>
<template v-if="expandable && !isPreview"> <div class="button-icon button-action-icon" v-if="!status.pinned" @click.prevent="pinStatus" title="Pin">
<a href="#" @click.prevent="toggleExpanded" title="Expand"> <i class="fa icon-pin"></i>
</div>
<div class="button-icon button-action-icon" v-else @click.prevent="unpinStatus" title="Unpin">
<i class="fa icon-cancel"></i>
</div>
<div class="button-icon button-action-icon" v-if="expandable && !isPreview" @click.prevent="toggleExpanded" title="Expand">
<i class="button-icon icon-plus-squared"></i> <i class="button-icon icon-plus-squared"></i>
</a> </div>
</template> <div class="button-icon button-action-icon" v-if="unmuted" @click.prevent="toggleMute" title="Toggle Mute">
<a href="#" @click.prevent="toggleMute" v-if="unmuted"><i class="button-icon icon-eye-off"></i></a> <i class="button-icon icon-eye-off"></i>
</div>
</span> </span>
</div> </div>
@ -678,6 +684,10 @@ a.unmute {
} }
} }
.button-action-icon {
cursor: pointer;
}
@media all and (max-width: 800px) { @media all and (max-width: 800px) {
.status-el { .status-el {
.retweet-info { .retweet-info {

View file

@ -424,6 +424,10 @@ export const mutations = {
newStatus.favoritedBy.push(user) newStatus.favoritedBy.push(user)
} }
}, },
setPinned (state, { status }) {
const newStatus = state.allStatusesObject[status.id]
newStatus.pinned = status.pinned
},
setRetweeted (state, { status, value }) { setRetweeted (state, { status, value }) {
const newStatus = state.allStatusesObject[status.id] const newStatus = state.allStatusesObject[status.id]
@ -533,6 +537,9 @@ const statuses = {
rootState.api.backendInteractor.unfavorite(status.id) rootState.api.backendInteractor.unfavorite(status.id)
.then(status => commit('setFavoritedConfirm', { status, user: rootState.users.currentUser })) .then(status => commit('setFavoritedConfirm', { status, user: rootState.users.currentUser }))
}, },
updatePinned ({ rootState, commit }, status) {
commit('setPinned', { status })
},
retweet ({ rootState, commit }, status) { retweet ({ rootState, commit }, status) {
// Optimistic retweeting... // Optimistic retweeting...
commit('setRetweeted', { status, value: true }) commit('setRetweeted', { status, value: true })

View file

@ -211,6 +211,7 @@ export const parseStatus = (data) => {
output.summary_html = addEmojis(data.spoiler_text, data.emojis) output.summary_html = addEmojis(data.spoiler_text, data.emojis)
output.external_url = data.url output.external_url = data.url
output.pinned = data.pinned
} else { } else {
output.favorited = data.favorited output.favorited = data.favorited
output.fave_num = data.fave_num output.fave_num = data.fave_num