hide note preview if it's already quoted - fixes #888
I do not particularly _love_ this solution, but it is simple and effective I can't find another reliable way to determine if a link goes to a local note of the given id, apart from fetching the link
This commit is contained in:
parent
50a3e55be4
commit
c6eb1ffde3
5 changed files with 13 additions and 5 deletions
|
|
@ -44,7 +44,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
</div>
|
||||
</template>
|
||||
<div v-else-if="theNote" :class="[$style.link, { [$style.compact]: compact }]"><XNoteSimple :note="theNote" :class="$style.body"/></div>
|
||||
<div v-else>
|
||||
<div v-else-if="!hidePreview">
|
||||
<component :is="self ? 'MkA' : 'a'" :class="[$style.link, { [$style.compact]: compact }]" :[attr]="self ? url.substring(local.length) : url" rel="nofollow noopener" :target="target" :title="url">
|
||||
<div v-if="thumbnail && !sensitive" :class="$style.thumbnail" :style="defaultStore.state.dataSaver.urlPreview ? '' : `background-image: url('${thumbnail}')`">
|
||||
</div>
|
||||
|
|
@ -111,16 +111,19 @@ const props = withDefaults(defineProps<{
|
|||
compact?: boolean;
|
||||
showAsQuote?: boolean;
|
||||
showActions?: boolean;
|
||||
skipNoteIds?: string[];
|
||||
}>(), {
|
||||
detail: false,
|
||||
compact: false,
|
||||
showAsQuote: false,
|
||||
showActions: true,
|
||||
skipNoteIds: [],
|
||||
});
|
||||
|
||||
const MOBILE_THRESHOLD = 500;
|
||||
const isMobile = ref(deviceKind === 'smartphone' || window.innerWidth <= MOBILE_THRESHOLD);
|
||||
|
||||
const hidePreview = ref<boolean>(false);
|
||||
const self = props.url.startsWith(local);
|
||||
const attr = self ? 'to' : 'href';
|
||||
const target = self ? null : '_blank';
|
||||
|
|
@ -155,6 +158,11 @@ watch(activityPub, async (uri) => {
|
|||
try {
|
||||
const response = await misskeyApi('ap/show', { uri });
|
||||
if (response.type !== 'Note') return;
|
||||
const theNoteId = response['object'].id;
|
||||
if (theNoteId && props.skipNoteIds.includes(theNoteId)) {
|
||||
hidePreview.value = true;
|
||||
return;
|
||||
}
|
||||
theNote.value = response['object'];
|
||||
} catch (err) {
|
||||
if (_DEV_) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue