From d2385a0e52912632fc039598e09441b271bd1c53 Mon Sep 17 00:00:00 2001 From: MeiMei <30769358+mei23@users.noreply.github.com> Date: Fri, 16 Nov 2018 16:35:13 +0900 Subject: [PATCH] Do not show duplicate url-preview (#3259) --- src/client/app/common/scripts/note-mixin.ts | 6 +++--- .../app/common/views/components/messaging-room.message.vue | 5 +++-- src/client/app/desktop/views/components/note-detail.vue | 6 +++--- src/client/app/mobile/views/components/note-detail.vue | 6 +++--- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/client/app/common/scripts/note-mixin.ts b/src/client/app/common/scripts/note-mixin.ts index 91b0d1d9c0..e0df788b34 100644 --- a/src/client/app/common/scripts/note-mixin.ts +++ b/src/client/app/common/scripts/note-mixin.ts @@ -1,5 +1,5 @@ import parse from '../../../../mfm/parse'; -import { sum } from '../../../../prelude/array'; +import { sum, unique } from '../../../../prelude/array'; import shouldMuteNote from './should-mute-note'; import MkNoteMenu from '../views/components/note-menu.vue'; import MkReactionPicker from '../views/components/reaction-picker.vue'; @@ -78,9 +78,9 @@ export default (opts: Opts = {}) => ({ urls(): string[] { if (this.appearNote.text) { const ast = parse(this.appearNote.text); - return ast + return unique(ast .filter(t => (t.type == 'url' || t.type == 'link') && !t.silent) - .map(t => t.url); + .map(t => t.url)); } else { return null; } diff --git a/src/client/app/common/views/components/messaging-room.message.vue b/src/client/app/common/views/components/messaging-room.message.vue index 0dce57a06a..966bd54170 100644 --- a/src/client/app/common/views/components/messaging-room.message.vue +++ b/src/client/app/common/views/components/messaging-room.message.vue @@ -34,6 +34,7 @@ import Vue from 'vue'; import i18n from '../../../i18n'; import parse from '../../../../../mfm/parse'; +import { unique } from '../../../../../prelude/array'; export default Vue.extend({ i18n: i18n('common/views/components/messaging-room.message.vue'), @@ -49,9 +50,9 @@ export default Vue.extend({ urls(): string[] { if (this.message.text) { const ast = parse(this.message.text); - return ast + return unique(ast .filter(t => (t.type == 'url' || t.type == 'link') && !t.silent) - .map(t => t.url); + .map(t => t.url)); } else { return null; } diff --git a/src/client/app/desktop/views/components/note-detail.vue b/src/client/app/desktop/views/components/note-detail.vue index f86a48ec5d..eca9896877 100644 --- a/src/client/app/desktop/views/components/note-detail.vue +++ b/src/client/app/desktop/views/components/note-detail.vue @@ -94,7 +94,7 @@ import MkRenoteFormWindow from './renote-form-window.vue'; import MkNoteMenu from '../../../common/views/components/note-menu.vue'; import MkReactionPicker from '../../../common/views/components/reaction-picker.vue'; import XSub from './note.sub.vue'; -import { sum } from '../../../../../prelude/array'; +import { sum, unique } from '../../../../../prelude/array'; import noteSubscriber from '../../../common/scripts/note-subscriber'; export default Vue.extend({ @@ -149,9 +149,9 @@ export default Vue.extend({ urls(): string[] { if (this.p.text) { const ast = parse(this.p.text); - return ast + return unique(ast .filter(t => (t.type == 'url' || t.type == 'link') && !t.silent) - .map(t => t.url); + .map(t => t.url)); } else { return null; } diff --git a/src/client/app/mobile/views/components/note-detail.vue b/src/client/app/mobile/views/components/note-detail.vue index 6a147f5195..001ffc5da8 100644 --- a/src/client/app/mobile/views/components/note-detail.vue +++ b/src/client/app/mobile/views/components/note-detail.vue @@ -92,7 +92,7 @@ import parse from '../../../../../mfm/parse'; import MkNoteMenu from '../../../common/views/components/note-menu.vue'; import MkReactionPicker from '../../../common/views/components/reaction-picker.vue'; import XSub from './note.sub.vue'; -import { sum } from '../../../../../prelude/array'; +import { sum, unique } from '../../../../../prelude/array'; import noteSubscriber from '../../../common/scripts/note-subscriber'; export default Vue.extend({ @@ -143,9 +143,9 @@ export default Vue.extend({ urls(): string[] { if (this.p.text) { const ast = parse(this.p.text); - return ast + return unique(ast .filter(t => (t.type == 'url' || t.type == 'link') && !t.silent) - .map(t => t.url); + .map(t => t.url)); } else { return null; }