#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
}
},
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

View File

@ -52,12 +52,18 @@
<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>
</a>
<template v-if="expandable && !isPreview">
<a href="#" @click.prevent="toggleExpanded" title="Expand">
<div class="button-icon button-action-icon" v-if="!status.pinned" @click.prevent="pinStatus" title="Pin">
<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>
</a>
</template>
<a href="#" @click.prevent="toggleMute" v-if="unmuted"><i class="button-icon icon-eye-off"></i></a>
</div>
<div class="button-icon button-action-icon" v-if="unmuted" @click.prevent="toggleMute" title="Toggle Mute">
<i class="button-icon icon-eye-off"></i>
</div>
</span>
</div>
@ -678,6 +684,10 @@ a.unmute {
}
}
.button-action-icon {
cursor: pointer;
}
@media all and (max-width: 800px) {
.status-el {
.retweet-info {

View File

@ -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 })

View File

@ -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