From 89a58dc5964f4df8c54c9c216d8fff3a63d86462 Mon Sep 17 00:00:00 2001 From: syuilo <syuilotan@yahoo.co.jp> Date: Thu, 17 May 2018 23:38:35 +0900 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E4=BB=98=E3=81=95=E3=82=8C=E3=81=9F?= =?UTF-8?q?=E3=83=A1=E3=83=87=E3=82=A3=E3=82=A2=E3=81=AEURL=E3=81=AF?= =?UTF-8?q?=E7=9C=81=E7=95=A5=E3=81=97=E3=81=A6=E8=A1=A8=E7=A4=BA=E3=81=99?= =?UTF-8?q?=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/client/app/common/scripts/can-hide-text.ts | 16 ++++++++++++++++ .../desktop/views/components/notes.note.vue | 18 ++++++++++++++++-- .../app/mobile/views/components/note.vue | 15 ++++++++++++++- src/models/drive-file.ts | 1 + 4 files changed, 47 insertions(+), 3 deletions(-) create mode 100644 src/client/app/common/scripts/can-hide-text.ts diff --git a/src/client/app/common/scripts/can-hide-text.ts b/src/client/app/common/scripts/can-hide-text.ts new file mode 100644 index 0000000000..4a4be8d9d0 --- /dev/null +++ b/src/client/app/common/scripts/can-hide-text.ts @@ -0,0 +1,16 @@ +export default function(note) { + if (note.text == null) return true; + + let txt = note.text; + + if (note.media) { + note.media.forEach(file => { + txt = txt.replace(file.url, ''); + if (file.src) txt = txt.replace(file.src, ''); + }); + + if (txt == '') return true; + } + + return false; +} diff --git a/src/client/app/desktop/views/components/notes.note.vue b/src/client/app/desktop/views/components/notes.note.vue index 057c3c0956..3ecef33d9a 100644 --- a/src/client/app/desktop/views/components/notes.note.vue +++ b/src/client/app/desktop/views/components/notes.note.vue @@ -44,7 +44,7 @@ <div class="text"> <span v-if="p.isHidden" style="opacity: 0.5">(ã“ã®æŠ•ç¨¿ã¯éžå…¬é–‹ã§ã™)</span> <a class="reply" v-if="p.reply">%fa:reply%</a> - <mk-note-html v-if="p.text" :text="p.text" :i="os.i" :class="$style.text"/> + <mk-note-html v-if="p.text && !canHideText(p)" :text="p.text" :i="os.i" :class="$style.text"/> <a class="rp" v-if="p.renote">RP:</a> </div> <div class="media" v-if="p.media.length > 0"> @@ -94,6 +94,7 @@ <script lang="ts"> import Vue from 'vue'; import dateStringify from '../../../common/scripts/date-stringify'; +import canHideText from '../../../common/scripts/can-hide-text'; import parse from '../../../../../text/parse'; import MkPostFormWindow from './post-form-window.vue'; @@ -130,16 +131,17 @@ export default Vue.extend({ }, computed: { - isRenote(): boolean { return (this.note.renote && this.note.text == null && this.note.mediaIds.length == 0 && this.note.poll == null); }, + p(): any { return this.isRenote ? this.note.renote : this.note; }, + reactionsCount(): number { return this.p.reactionCounts ? Object.keys(this.p.reactionCounts) @@ -147,9 +149,11 @@ export default Vue.extend({ .reduce((a, b) => a + b) : 0; }, + title(): string { return dateStringify(this.p.createdAt); }, + urls(): string[] { if (this.p.text) { const ast = parse(this.p.text); @@ -205,6 +209,8 @@ export default Vue.extend({ }, methods: { + canHideText, + capture(withHandler = false) { if ((this as any).os.isSignedIn) { this.connection.send({ @@ -214,6 +220,7 @@ export default Vue.extend({ if (withHandler) this.connection.on('note-updated', this.onStreamNoteUpdated); } }, + decapture(withHandler = false) { if ((this as any).os.isSignedIn) { this.connection.send({ @@ -223,9 +230,11 @@ export default Vue.extend({ if (withHandler) this.connection.off('note-updated', this.onStreamNoteUpdated); } }, + onStreamConnected() { this.capture(); }, + onStreamNoteUpdated(data) { const note = data.note; if (note.id == this.note.id) { @@ -234,28 +243,33 @@ export default Vue.extend({ this.note.renote = note; } }, + reply() { (this as any).os.new(MkPostFormWindow, { reply: this.p }); }, + renote() { (this as any).os.new(MkRenoteFormWindow, { note: this.p }); }, + react() { (this as any).os.new(MkReactionPicker, { source: this.$refs.reactButton, note: this.p }); }, + menu() { (this as any).os.new(MkNoteMenu, { source: this.$refs.menuButton, note: this.p }); }, + onKeydown(e) { let shouldBeCancel = true; diff --git a/src/client/app/mobile/views/components/note.vue b/src/client/app/mobile/views/components/note.vue index d66f5a1016..f5428b80cd 100644 --- a/src/client/app/mobile/views/components/note.vue +++ b/src/client/app/mobile/views/components/note.vue @@ -41,7 +41,7 @@ <div class="text"> <span v-if="p.isHidden" style="opacity: 0.5">(ã“ã®æŠ•ç¨¿ã¯éžå…¬é–‹ã§ã™)</span> <a class="reply" v-if="p.reply">%fa:reply%</a> - <mk-note-html v-if="p.text" :text="p.text" :i="os.i" :class="$style.text"/> + <mk-note-html v-if="p.text && !canHideText(p)" :text="p.text" :i="os.i" :class="$style.text"/> <a class="rp" v-if="p.renote != null">RP:</a> </div> <div class="media" v-if="p.media.length > 0"> @@ -85,6 +85,7 @@ <script lang="ts"> import Vue from 'vue'; import parse from '../../../../../text/parse'; +import canHideText from '../../../common/scripts/can-hide-text'; import MkNoteMenu from '../../../common/views/components/note-menu.vue'; import MkReactionPicker from '../../../common/views/components/reaction-picker.vue'; @@ -112,9 +113,11 @@ export default Vue.extend({ this.note.mediaIds.length == 0 && this.note.poll == null); }, + p(): any { return this.isRenote ? this.note.renote : this.note; }, + reactionsCount(): number { return this.p.reactionCounts ? Object.keys(this.p.reactionCounts) @@ -122,6 +125,7 @@ export default Vue.extend({ .reduce((a, b) => a + b) : 0; }, + urls(): string[] { if (this.p.text) { const ast = parse(this.p.text); @@ -177,6 +181,8 @@ export default Vue.extend({ }, methods: { + canHideText, + capture(withHandler = false) { if ((this as any).os.isSignedIn) { this.connection.send({ @@ -186,6 +192,7 @@ export default Vue.extend({ if (withHandler) this.connection.on('note-updated', this.onStreamNoteUpdated); } }, + decapture(withHandler = false) { if ((this as any).os.isSignedIn) { this.connection.send({ @@ -195,9 +202,11 @@ export default Vue.extend({ if (withHandler) this.connection.off('note-updated', this.onStreamNoteUpdated); } }, + onStreamConnected() { this.capture(); }, + onStreamNoteUpdated(data) { const note = data.note; if (note.id == this.note.id) { @@ -206,16 +215,19 @@ export default Vue.extend({ this.note.renote = note; } }, + reply() { (this as any).apis.post({ reply: this.p }); }, + renote() { (this as any).apis.post({ renote: this.p }); }, + react() { (this as any).os.new(MkReactionPicker, { source: this.$refs.reactButton, @@ -223,6 +235,7 @@ export default Vue.extend({ compact: true }); }, + menu() { (this as any).os.new(MkNoteMenu, { source: this.$refs.menuButton, diff --git a/src/models/drive-file.ts b/src/models/drive-file.ts index f8cad36f9a..8a18567dc6 100644 --- a/src/models/drive-file.ts +++ b/src/models/drive-file.ts @@ -154,6 +154,7 @@ export const pack = ( _target = Object.assign(_target, _file.metadata); + _target.src = _file.metadata.url; _target.url = `${config.drive_url}/${_target.id}/${encodeURIComponent(_target.name)}`; if (_target.properties == null) _target.properties = {}; -- GitLab