Add muting to statuses.

This commit is contained in:
Roger Braun 2017-02-14 00:01:50 +01:00
parent 66ef9f1328
commit 4c12de262f
4 changed files with 81 additions and 56 deletions

View file

@ -11,7 +11,8 @@ const Status = {
], ],
data: () => ({ data: () => ({
replying: false, replying: false,
expanded: false expanded: false,
unmuted: false
}), }),
computed: { computed: {
retweet () { return !!this.statusoid.retweeted_status }, retweet () { return !!this.statusoid.retweeted_status },
@ -25,7 +26,8 @@ const Status = {
}, },
loggedIn () { loggedIn () {
return !!this.$store.state.users.currentUser return !!this.$store.state.users.currentUser
} },
muted () { return !this.unmuted && this.status.user.muted }
}, },
components: { components: {
Attachment, Attachment,
@ -40,6 +42,9 @@ const Status = {
}, },
toggleExpanded () { toggleExpanded () {
this.$emit('toggleExpanded') this.$emit('toggleExpanded')
},
toggleMute () {
this.unmuted = !this.unmuted
} }
} }
} }

View file

@ -1,70 +1,78 @@
<template> <template>
<div class="status-el base00-background" v-if="!status.deleted"> <div class="status-el base00-background" v-if="!status.deleted">
<div v-if="retweet" class="media container retweet-info"> <template v-if="muted">
<div class="media-left"> <div class="media status container muted">
<i class='fa icon-retweet retweeted'></i> <small><router-link :to="{ name: 'user-profile', params: { id: status.user.id } }">{{status.user.screen_name}}</router-link></small>
<button @click="toggleMute">show</button>
</div> </div>
<div class="media-body"> </template>
Retweeted by {{retweeter}} <template v-if="!muted">
<div v-if="retweet" class="media container retweet-info">
<div class="media-left">
<i class='fa icon-retweet retweeted'></i>
</div>
<div class="media-body">
Retweeted by {{retweeter}}
</div>
</div> </div>
</div> <div class="media status container">
<div class="media status container"> <div class="media-left">
<div class="media-left"> <a :href="status.user.statusnet_profile_url">
<a :href="status.user.statusnet_profile_url"> <img class='avatar' :src="status.user.profile_image_url_original">
<img class='avatar' :src="status.user.profile_image_url_original"> </a>
</a> </div>
</div> <div class="media-body">
<div class="media-body"> <div class="user-content">
<div class="user-content"> <h4 class="media-heading">
<h4 class="media-heading"> {{status.user.name}}
{{status.user.name}} <small><router-link :to="{ name: 'user-profile', params: { id: status.user.id } }">{{status.user.screen_name}}</router-link></small>
<small><router-link :to="{ name: 'user-profile', params: { id: status.user.id } }">{{status.user.screen_name}}</router-link></small> <small v-if="status.in_reply_to_screen_name"> &gt;
<small v-if="status.in_reply_to_screen_name"> &gt; <router-link :to="{ name: 'user-profile', params: { id: status.in_reply_to_user_id } }">
<router-link :to="{ name: 'user-profile', params: { id: status.in_reply_to_user_id } }"> {{status.in_reply_to_screen_name}}
{{status.in_reply_to_screen_name}} </router-link>
</router-link> </small>
</small>
-
<small>
<router-link :to="{ name: 'conversation', params: { id: status.id } }">
<timeago :since="status.created_at" :auto-update="60"></timeago>
</router-link>
</small>
<template v-if="expandable">
- -
<small> <small>
<a href="#" @click.prevent="toggleExpanded" >Expand</a> <router-link :to="{ name: 'conversation', params: { id: status.id } }">
<timeago :since="status.created_at" :auto-update="60"></timeago>
</router-link>
</small> </small>
</template> <template v-if="expandable">
<small v-if="!status.is_local" class="source_url"> -
<a :href="status.external_url" target="_blank" >Source</a> <small>
</small> <a href="#" @click.prevent="toggleExpanded" >Expand</a>
</h4> </small>
</template>
<small v-if="!status.is_local" class="source_url">
<a :href="status.external_url" target="_blank" >Source</a>
</small>
</h4>
<div class="status-content" v-html="status.statusnet_html"></div> <div class="status-content" v-html="status.statusnet_html"></div>
<div v-if='status.attachments' class='attachments'> <div v-if='status.attachments' class='attachments'>
<attachment :status-id="status.id" :nsfw="status.nsfw" :attachment="attachment" v-for="attachment in status.attachments"> <attachment :status-id="status.id" :nsfw="status.nsfw" :attachment="attachment" v-for="attachment in status.attachments">
</attachment> </attachment>
</div>
</div>
<div v-if="loggedIn">
<div class='status-actions'>
<div>
<a href="#" v-on:click.prevent="toggleReplying">
<i class='fa icon-reply'></i>
</a>
</div> </div>
<retweet-button :status=status></retweet-button>
<favorite-button :status=status></favorite-button>
<delete-button :status=status></delete-button>
</div> </div>
<post-status-form v-if="replying" :reply-to="status.id" :attentions="status.attentions" :repliedUser="status.user" v-on:posted="toggleReplying"></post-status-form> <div v-if="loggedIn">
<div class='status-actions'>
<div>
<a href="#" v-on:click.prevent="toggleReplying">
<i class='fa icon-reply'></i>
</a>
</div>
<retweet-button :status=status></retweet-button>
<favorite-button :status=status></favorite-button>
<delete-button :status=status></delete-button>
</div>
<post-status-form v-if="replying" :reply-to="status.id" :attentions="status.attentions" :repliedUser="status.user" v-on:posted="toggleReplying"></post-status-form>
</div>
</div> </div>
</div> </div>
</div> </template>
</div> </div>
</template> </template>
@ -128,4 +136,7 @@
padding-right: 1em; padding-right: 1em;
border-bottom: 1px solid; border-bottom: 1px solid;
} }
.muted button {
margin-left: auto;
}
</style> </style>

View file

@ -4,7 +4,7 @@
<div class='user-info'> <div class='user-info'>
<img :src="user.profile_image_url"> <img :src="user.profile_image_url">
<div v-if='user.muted' class='muteinfo'>Muted</div> <div v-if='user.muted' class='muteinfo'>Muted</div>
<div class='muteinfo'> <div class='muteinfo' v-if='isOtherUser'>
<button @click="toggleMute">Mute/Unmute</button> <button @click="toggleMute">Mute/Unmute</button>
</div> </div>
<span class="glyphicon glyphicon-user"></span> <span class="glyphicon glyphicon-user"></span>

View file

@ -52,6 +52,15 @@ const users = {
const retweetedUsers = compact(map(statuses, 'retweeted_status.user')) const retweetedUsers = compact(map(statuses, 'retweeted_status.user'))
store.commit('addNewUsers', users) store.commit('addNewUsers', users)
store.commit('addNewUsers', retweetedUsers) store.commit('addNewUsers', retweetedUsers)
// Reconnect users to statuses
each(statuses, (status) => {
status.user = find(store.state.users, status.user)
})
// Reconnect users to retweets
each(compact(map(statuses, 'retweeted_status')), (status) => {
status.user = find(store.state.users, status.user)
})
}, },
loginUser (store, userCredentials) { loginUser (store, userCredentials) {
const commit = store.commit const commit = store.commit