Show visibility in note-detail (#3308)

* Show visibility in note-detail

* fix
This commit is contained in:
MeiMei 2018-11-18 22:47:21 +09:00 committed by syuilo
parent 046ccd49ca
commit 43c2b00cf8
2 changed files with 119 additions and 84 deletions

View file

@ -2,7 +2,7 @@
<div class="mk-note-detail" :title="title"> <div class="mk-note-detail" :title="title">
<button <button
class="read-more" class="read-more"
v-if="p.reply && p.reply.replyId && conversation.length == 0" v-if="appearNote.reply && appearNote.reply.replyId && conversation.length == 0"
:title="$t('title')" :title="$t('title')"
@click="fetchConversation" @click="fetchConversation"
:disabled="conversationFetching" :disabled="conversationFetching"
@ -13,8 +13,8 @@
<div class="conversation"> <div class="conversation">
<x-sub v-for="note in conversation" :key="note.id" :note="note"/> <x-sub v-for="note in conversation" :key="note.id" :note="note"/>
</div> </div>
<div class="reply-to" v-if="p.reply"> <div class="reply-to" v-if="appearNote.reply">
<x-sub :note="p.reply"/> <x-sub :note="appearNote.reply"/>
</div> </div>
<div class="renote" v-if="isRenote"> <div class="renote" v-if="isRenote">
<p> <p>
@ -28,50 +28,61 @@
</p> </p>
</div> </div>
<article> <article>
<mk-avatar class="avatar" :user="p.user"/> <mk-avatar class="avatar" :user="appearNote.user"/>
<header> <header>
<router-link class="name" :to="p.user | userPage" v-user-preview="p.user.id">{{ p.user | userName }}</router-link> <router-link class="name" :to="appearNote.user | userPage" v-user-preview="appearNote.user.id">{{ appearNote.user | userName }}</router-link>
<span class="username"><mk-acct :user="p.user"/></span> <span class="username"><mk-acct :user="appearNote.user"/></span>
<router-link class="time" :to="p | notePage"> <div class="info">
<mk-time :time="p.createdAt"/> <router-link class="time" :to="appearNote | notePage">
</router-link> <mk-time :time="appearNote.createdAt"/>
</router-link>
<div class="visibility-info">
<span class="visibility" v-if="appearNote.visibility != 'public'">
<fa v-if="appearNote.visibility == 'home'" icon="home"/>
<fa v-if="appearNote.visibility == 'followers'" icon="unlock"/>
<fa v-if="appearNote.visibility == 'specified'" icon="envelope"/>
<fa v-if="appearNote.visibility == 'private'" icon="lock"/>
</span>
<span class="localOnly" v-if="appearNote.localOnly == true"><fa icon="heart"/></span>
</div>
</div>
</header> </header>
<div class="body"> <div class="body">
<p v-if="p.cw != null" class="cw"> <p v-if="appearNote.cw != null" class="cw">
<span class="text" v-if="p.cw != ''">{{ p.cw }}</span> <span class="text" v-if="appearNote.cw != ''">{{ appearNote.cw }}</span>
<mk-cw-button v-model="showContent"/> <mk-cw-button v-model="showContent"/>
</p> </p>
<div class="content" v-show="p.cw == null || showContent"> <div class="content" v-show="appearNote.cw == null || showContent">
<div class="text"> <div class="text">
<span v-if="p.isHidden" style="opacity: 0.5">{{ $t('private') }}</span> <span v-if="appearNote.isHidden" style="opacity: 0.5">{{ $t('private') }}</span>
<span v-if="p.deletedAt" style="opacity: 0.5">{{ $t('deleted') }}</span> <span v-if="appearNote.deletedAt" style="opacity: 0.5">{{ $t('deleted') }}</span>
<misskey-flavored-markdown v-if="p.text" :text="p.text" :i="$store.state.i" :customEmojis="p.emojis" /> <misskey-flavored-markdown v-if="appearNote.text" :text="appearNote.text" :i="$store.state.i" :customEmojis="appearNote.emojis" />
</div> </div>
<div class="files" v-if="p.files.length > 0"> <div class="files" v-if="appearNote.files.length > 0">
<mk-media-list :media-list="p.files" :raw="true"/> <mk-media-list :media-list="appearNote.files" :raw="true"/>
</div> </div>
<mk-poll v-if="p.poll" :note="p"/> <mk-poll v-if="appearNote.poll" :note="appearNote"/>
<mk-url-preview v-for="url in urls" :url="url" :key="url" :detail="true"/> <mk-url-preview v-for="url in urls" :url="url" :key="url" :detail="true"/>
<a class="location" v-if="p.geo" :href="`https://maps.google.com/maps?q=${p.geo.coordinates[1]},${p.geo.coordinates[0]}`" target="_blank"><fa icon="map-marker-alt"/> {{ $t('location') }}</a> <a class="location" v-if="appearNote.geo" :href="`https://maps.google.com/maps?q=${appearNote.geo.coordinates[1]},${appearNote.geo.coordinates[0]}`" target="_blank"><fa icon="map-marker-alt"/> {{ $t('location') }}</a>
<div class="map" v-if="p.geo" ref="map"></div> <div class="map" v-if="appearNote.geo" ref="map"></div>
<div class="renote" v-if="p.renote"> <div class="renote" v-if="appearNote.renote">
<mk-note-preview :note="p.renote"/> <mk-note-preview :note="appearNote.renote"/>
</div> </div>
</div> </div>
</div> </div>
<footer> <footer>
<span class="app" v-if="note.app && $store.state.settings.showVia">via <b>{{ note.app.name }}</b></span> <span class="app" v-if="note.app && $store.state.settings.showVia">via <b>{{ note.app.name }}</b></span>
<mk-reactions-viewer :note="p"/> <mk-reactions-viewer :note="appearNote"/>
<button class="replyButton" @click="reply" :title="$t('reply')"> <button class="replyButton" @click="reply" :title="$t('reply')">
<template v-if="p.reply"><fa icon="reply-all"/></template> <template v-if="appearNote.reply"><fa icon="reply-all"/></template>
<template v-else><fa icon="reply"/></template> <template v-else><fa icon="reply"/></template>
<p class="count" v-if="p.repliesCount > 0">{{ p.repliesCount }}</p> <p class="count" v-if="appearNote.repliesCount > 0">{{ appearNote.repliesCount }}</p>
</button> </button>
<button class="renoteButton" @click="renote" :title="$t('renote')"> <button class="renoteButton" @click="renote" :title="$t('renote')">
<fa icon="retweet"/><p class="count" v-if="p.renoteCount > 0">{{ p.renoteCount }}</p> <fa icon="retweet"/><p class="count" v-if="appearNote.renoteCount > 0">{{ appearNote.renoteCount }}</p>
</button> </button>
<button class="reactionButton" :class="{ reacted: p.myReaction != null }" @click="react" ref="reactButton" :title="$t('add-reaction')"> <button class="reactionButton" :class="{ reacted: appearNote.myReaction != null }" @click="react" ref="reactButton" :title="$t('add-reaction')">
<fa icon="plus"/><p class="count" v-if="p.reactions_count > 0">{{ p.reactions_count }}</p> <fa icon="plus"/><p class="count" v-if="appearNote.reactions_count > 0">{{ appearNote.reactions_count }}</p>
</button> </button>
<button @click="menu" ref="menuButton"> <button @click="menu" ref="menuButton">
<fa icon="ellipsis-h"/> <fa icon="ellipsis-h"/>
@ -132,23 +143,23 @@ export default Vue.extend({
this.note.poll == null); this.note.poll == null);
}, },
p(): any { appearNote(): any {
return this.isRenote ? this.note.renote : this.note; return this.isRenote ? this.note.renote : this.note;
}, },
reactionsCount(): number { reactionsCount(): number {
return this.p.reactionCounts return this.appearNote.reactionCounts
? sum(Object.values(this.p.reactionCounts)) ? sum(Object.values(this.appearNote.reactionCounts))
: 0; : 0;
}, },
title(): string { title(): string {
return new Date(this.p.createdAt).toLocaleString(); return new Date(this.appearNote.createdAt).toLocaleString();
}, },
urls(): string[] { urls(): string[] {
if (this.p.text) { if (this.appearNote.text) {
const ast = parse(this.p.text); const ast = parse(this.appearNote.text);
return unique(ast return unique(ast
.filter(t => (t.type == 'url' || t.type == 'link') && !t.silent) .filter(t => (t.type == 'url' || t.type == 'link') && !t.silent)
.map(t => t.url)); .map(t => t.url));
@ -162,7 +173,7 @@ export default Vue.extend({
// Get replies // Get replies
if (!this.compact) { if (!this.compact) {
this.$root.api('notes/replies', { this.$root.api('notes/replies', {
noteId: this.p.id, noteId: this.appearNote.id,
limit: 8 limit: 8
}).then(replies => { }).then(replies => {
this.replies = replies; this.replies = replies;
@ -170,11 +181,11 @@ export default Vue.extend({
} }
// Draw map // Draw map
if (this.p.geo) { if (this.appearNote.geo) {
const shouldShowMap = this.$store.getters.isSignedIn ? this.$store.state.settings.showMaps : true; const shouldShowMap = this.$store.getters.isSignedIn ? this.$store.state.settings.showMaps : true;
if (shouldShowMap) { if (shouldShowMap) {
this.$root.os.getGoogleMaps().then(maps => { this.$root.os.getGoogleMaps().then(maps => {
const uluru = new maps.LatLng(this.p.geo.coordinates[1], this.p.geo.coordinates[0]); const uluru = new maps.LatLng(this.appearNote.geo.coordinates[1], this.appearNote.geo.coordinates[0]);
const map = new maps.Map(this.$refs.map, { const map = new maps.Map(this.$refs.map, {
center: uluru, center: uluru,
zoom: 15 zoom: 15
@ -194,7 +205,7 @@ export default Vue.extend({
// Fetch conversation // Fetch conversation
this.$root.api('notes/conversation', { this.$root.api('notes/conversation', {
noteId: this.p.replyId noteId: this.appearNote.replyId
}).then(conversation => { }).then(conversation => {
this.conversationFetching = false; this.conversationFetching = false;
this.conversation = conversation.reverse(); this.conversation = conversation.reverse();
@ -203,27 +214,27 @@ export default Vue.extend({
reply() { reply() {
this.$root.new(MkPostFormWindow, { this.$root.new(MkPostFormWindow, {
reply: this.p reply: this.appearNote
}); });
}, },
renote() { renote() {
this.$root.new(MkRenoteFormWindow, { this.$root.new(MkRenoteFormWindow, {
note: this.p note: this.appearNote
}); });
}, },
react() { react() {
this.$root.new(MkReactionPicker, { this.$root.new(MkReactionPicker, {
source: this.$refs.reactButton, source: this.$refs.reactButton,
note: this.p note: this.appearNote
}); });
}, },
menu() { menu() {
this.$root.new(MkNoteMenu, { this.$root.new(MkNoteMenu, {
source: this.$refs.menuButton, source: this.$refs.menuButton,
note: this.p note: this.appearNote
}); });
} }
} }
@ -335,12 +346,21 @@ export default Vue.extend({
margin 0 margin 0
color var(--noteHeaderAcct) color var(--noteHeaderAcct)
> .time > .info
position absolute position absolute
top 0 top 0
right 32px right 32px
font-size 1em font-size 1em
color var(--noteHeaderInfo)
> .time
color var(--noteHeaderInfo)
> .visibility-info
text-align: right
color var(--noteHeaderInfo)
> .localOnly
margin-left 4px
> .body > .body
padding 8px 0 padding 8px 0

View file

@ -2,7 +2,7 @@
<div class="mk-note-detail"> <div class="mk-note-detail">
<button <button
class="more" class="more"
v-if="p.reply && p.reply.replyId && conversation.length == 0" v-if="appearNote.reply && appearNote.reply.replyId && conversation.length == 0"
@click="fetchConversation" @click="fetchConversation"
:disabled="conversationFetching" :disabled="conversationFetching"
> >
@ -12,8 +12,8 @@
<div class="conversation"> <div class="conversation">
<x-sub v-for="note in conversation" :key="note.id" :note="note"/> <x-sub v-for="note in conversation" :key="note.id" :note="note"/>
</div> </div>
<div class="reply-to" v-if="p.reply"> <div class="reply-to" v-if="appearNote.reply">
<x-sub :note="p.reply"/> <x-sub :note="appearNote.reply"/>
</div> </div>
<div class="renote" v-if="isRenote"> <div class="renote" v-if="isRenote">
<p> <p>
@ -28,50 +28,59 @@
</div> </div>
<article> <article>
<header> <header>
<mk-avatar class="avatar" :user="p.user"/> <mk-avatar class="avatar" :user="appearNote.user"/>
<div> <div>
<router-link class="name" :to="p.user | userPage">{{ p.user | userName }}</router-link> <router-link class="name" :to="appearNote.user | userPage">{{ appearNote.user | userName }}</router-link>
<span class="username"><mk-acct :user="p.user"/></span> <span class="username"><mk-acct :user="appearNote.user"/></span>
</div> </div>
</header> </header>
<div class="body"> <div class="body">
<p v-if="p.cw != null" class="cw"> <p v-if="appearNote.cw != null" class="cw">
<span class="text" v-if="p.cw != ''">{{ p.cw }}</span> <span class="text" v-if="appearNote.cw != ''">{{ appearNote.cw }}</span>
<mk-cw-button v-model="showContent"/> <mk-cw-button v-model="showContent"/>
</p> </p>
<div class="content" v-show="p.cw == null || showContent"> <div class="content" v-show="appearNote.cw == null || showContent">
<div class="text"> <div class="text">
<span v-if="p.isHidden" style="opacity: 0.5">({{ $t('private') }})</span> <span v-if="appearNote.isHidden" style="opacity: 0.5">({{ $t('private') }})</span>
<span v-if="p.deletedAt" style="opacity: 0.5">({{ $t('deleted') }})</span> <span v-if="appearNote.deletedAt" style="opacity: 0.5">({{ $t('deleted') }})</span>
<misskey-flavored-markdown v-if="p.text" :text="p.text" :i="$store.state.i" :customEmojis="p.emojis"/> <misskey-flavored-markdown v-if="appearNote.text" :text="appearNote.text" :i="$store.state.i" :customEmojis="appearNote.emojis"/>
</div> </div>
<div class="files" v-if="p.files.length > 0"> <div class="files" v-if="appearNote.files.length > 0">
<mk-media-list :media-list="p.files" :raw="true"/> <mk-media-list :media-list="appearNote.files" :raw="true"/>
</div> </div>
<mk-poll v-if="p.poll" :note="p"/> <mk-poll v-if="appearNote.poll" :note="appearNote"/>
<mk-url-preview v-for="url in urls" :url="url" :key="url" :detail="true"/> <mk-url-preview v-for="url in urls" :url="url" :key="url" :detail="true"/>
<a class="location" v-if="p.geo" :href="`https://maps.google.com/maps?q=${p.geo.coordinates[1]},${p.geo.coordinates[0]}`" target="_blank"><fa icon="map-marker-alt"/> {{ $t('location') }}</a> <a class="location" v-if="appearNote.geo" :href="`https://maps.google.com/maps?q=${appearNote.geo.coordinates[1]},${appearNote.geo.coordinates[0]}`" target="_blank"><fa icon="map-marker-alt"/> {{ $t('location') }}</a>
<div class="map" v-if="p.geo" ref="map"></div> <div class="map" v-if="appearNote.geo" ref="map"></div>
<div class="renote" v-if="p.renote"> <div class="renote" v-if="appearNote.renote">
<mk-note-preview :note="p.renote"/> <mk-note-preview :note="appearNote.renote"/>
</div> </div>
</div> </div>
</div> </div>
<router-link class="time" :to="p | notePage"> <router-link class="time" :to="appearNote | notePage">
<mk-time :time="p.createdAt" mode="detail"/> <mk-time :time="appearNote.createdAt" mode="detail"/>
</router-link> </router-link>
<div class="visibility-info">
<span class="visibility" v-if="appearNote.visibility != 'public'">
<fa v-if="appearNote.visibility == 'home'" icon="home"/>
<fa v-if="appearNote.visibility == 'followers'" icon="unlock"/>
<fa v-if="appearNote.visibility == 'specified'" icon="envelope"/>
<fa v-if="appearNote.visibility == 'private'" icon="lock"/>
</span>
<span class="localOnly" v-if="appearNote.localOnly == true"><fa icon="heart"/></span>
</div>
<footer> <footer>
<mk-reactions-viewer :note="p"/> <mk-reactions-viewer :note="appearNote"/>
<button @click="reply" :title="$t('title')"> <button @click="reply" :title="$t('title')">
<template v-if="p.reply"><fa icon="reply-all"/></template> <template v-if="appearNote.reply"><fa icon="reply-all"/></template>
<template v-else><fa icon="reply"/></template> <template v-else><fa icon="reply"/></template>
<p class="count" v-if="p.repliesCount > 0">{{ p.repliesCount }}</p> <p class="count" v-if="appearNote.repliesCount > 0">{{ appearNote.repliesCount }}</p>
</button> </button>
<button @click="renote" title="Renote"> <button @click="renote" title="Renote">
<fa icon="retweet"/><p class="count" v-if="p.renoteCount > 0">{{ p.renoteCount }}</p> <fa icon="retweet"/><p class="count" v-if="appearNote.renoteCount > 0">{{ appearNote.renoteCount }}</p>
</button> </button>
<button :class="{ reacted: p.myReaction != null }" @click="react" ref="reactButton" :title="$t('title')"> <button :class="{ reacted: appearNote.myReaction != null }" @click="react" ref="reactButton" :title="$t('title')">
<fa icon="plus"/><p class="count" v-if="p.reactions_count > 0">{{ p.reactions_count }}</p> <fa icon="plus"/><p class="count" v-if="appearNote.reactions_count > 0">{{ appearNote.reactions_count }}</p>
</button> </button>
<button @click="menu" ref="menuButton"> <button @click="menu" ref="menuButton">
<fa icon="ellipsis-h"/> <fa icon="ellipsis-h"/>
@ -130,19 +139,19 @@ export default Vue.extend({
this.note.poll == null); this.note.poll == null);
}, },
p(): any { appearNote(): any {
return this.isRenote ? this.note.renote : this.note; return this.isRenote ? this.note.renote : this.note;
}, },
reactionsCount(): number { reactionsCount(): number {
return this.p.reactionCounts return this.appearNote.reactionCounts
? sum(Object.values(this.p.reactionCounts)) ? sum(Object.values(this.appearNote.reactionCounts))
: 0; : 0;
}, },
urls(): string[] { urls(): string[] {
if (this.p.text) { if (this.appearNote.text) {
const ast = parse(this.p.text); const ast = parse(this.appearNote.text);
return unique(ast return unique(ast
.filter(t => (t.type == 'url' || t.type == 'link') && !t.silent) .filter(t => (t.type == 'url' || t.type == 'link') && !t.silent)
.map(t => t.url)); .map(t => t.url));
@ -156,7 +165,7 @@ export default Vue.extend({
// Get replies // Get replies
if (!this.compact) { if (!this.compact) {
this.$root.api('notes/replies', { this.$root.api('notes/replies', {
noteId: this.p.id, noteId: this.appearNote.id,
limit: 8 limit: 8
}).then(replies => { }).then(replies => {
this.replies = replies; this.replies = replies;
@ -164,11 +173,11 @@ export default Vue.extend({
} }
// Draw map // Draw map
if (this.p.geo) { if (this.appearNote.geo) {
const shouldShowMap = this.$store.getters.isSignedIn ? this.$store.state.settings.showMaps : true; const shouldShowMap = this.$store.getters.isSignedIn ? this.$store.state.settings.showMaps : true;
if (shouldShowMap) { if (shouldShowMap) {
this.$root.os.getGoogleMaps().then(maps => { this.$root.os.getGoogleMaps().then(maps => {
const uluru = new maps.LatLng(this.p.geo.coordinates[1], this.p.geo.coordinates[0]); const uluru = new maps.LatLng(this.appearNote.geo.coordinates[1], this.appearNote.geo.coordinates[0]);
const map = new maps.Map(this.$refs.map, { const map = new maps.Map(this.$refs.map, {
center: uluru, center: uluru,
zoom: 15 zoom: 15
@ -188,7 +197,7 @@ export default Vue.extend({
// Fetch conversation // Fetch conversation
this.$root.api('notes/conversation', { this.$root.api('notes/conversation', {
noteId: this.p.replyId noteId: this.appearNote.replyId
}).then(conversation => { }).then(conversation => {
this.conversationFetching = false; this.conversationFetching = false;
this.conversation = conversation.reverse(); this.conversation = conversation.reverse();
@ -197,20 +206,20 @@ export default Vue.extend({
reply() { reply() {
this.$post({ this.$post({
reply: this.p reply: this.appearNote
}); });
}, },
renote() { renote() {
this.$post({ this.$post({
renote: this.p renote: this.appearNote
}); });
}, },
react() { react() {
this.$root.new(MkReactionPicker, { this.$root.new(MkReactionPicker, {
source: this.$refs.reactButton, source: this.$refs.reactButton,
note: this.p, note: this.appearNote,
compact: true, compact: true,
big: true big: true
}); });
@ -219,7 +228,7 @@ export default Vue.extend({
menu() { menu() {
this.$root.new(MkNoteMenu, { this.$root.new(MkNoteMenu, {
source: this.$refs.menuButton, source: this.$refs.menuButton,
note: this.p, note: this.appearNote,
compact: true compact: true
}); });
} }
@ -400,6 +409,12 @@ export default Vue.extend({
font-size 16px font-size 16px
color var(--noteHeaderInfo) color var(--noteHeaderInfo)
> .visibility-info
color var(--noteHeaderInfo)
> .localOnly
margin-left 4px
> footer > footer
font-size 1.2em font-size 1.2em