diff options
| author | dakkar <dakkar@thenautilus.net> | 2025-06-04 12:35:20 +0000 |
|---|---|---|
| committer | dakkar <dakkar@thenautilus.net> | 2025-06-04 12:35:20 +0000 |
| commit | e9a038b24464b234bc764d75eadf2eb2bb12c2a8 (patch) | |
| tree | 4c3c3f1c8204a05bff2e545fb21bdd5f30ece839 /packages/frontend/src/components | |
| parent | merge: Add delay and retry to Page's embedded note loading (!1072) (diff) | |
| parent | remove unused import. (diff) | |
| download | sharkey-e9a038b24464b234bc764d75eadf2eb2bb12c2a8.tar.gz sharkey-e9a038b24464b234bc764d75eadf2eb2bb12c2a8.tar.bz2 sharkey-e9a038b24464b234bc764d75eadf2eb2bb12c2a8.zip | |
merge: Link attributions (!1048)
View MR for information: https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/1048
Approved-by: dakkar <dakkar@thenautilus.net>
Approved-by: Hazelnoot <acomputerdog@gmail.com>
Diffstat (limited to 'packages/frontend/src/components')
| -rw-r--r-- | packages/frontend/src/components/MkUrlPreview.vue | 55 |
1 files changed, 54 insertions, 1 deletions
diff --git a/packages/frontend/src/components/MkUrlPreview.vue b/packages/frontend/src/components/MkUrlPreview.vue index a14c2ecef9..69a1540600 100644 --- a/packages/frontend/src/components/MkUrlPreview.vue +++ b/packages/frontend/src/components/MkUrlPreview.vue @@ -65,6 +65,17 @@ SPDX-License-Identifier: AGPL-3.0-only </footer> </article> </component> + + <I18n v-if="attributionUser" :src="i18n.ts.writtenBy" :class="$style.linkAttribution" tag="p"> + <template #user> + <MkA v-user-preview="attributionUser.id" :to="userPage(attributionUser)"> + <MkAvatar :class="$style.linkAttributionIcon" :user="attributionUser"/> + <MkUserName :user="attributionUser" style="color: var(--MI_THEME-accent)"/> + </MkA> + </template> + </I18n> + <p v-else-if="linkAttribution" :class="$style.linkAttribution"><MkEllipsis/></p> + <template v-if="showActions"> <div v-if="tweetId" :class="$style.action"> <MkButton :small="true" inline @click="tweetExpanded = true"> @@ -106,6 +117,7 @@ import { misskeyApi } from '@/utility/misskey-api.js'; import { warningExternalWebsite } from '@/utility/warning-external-website.js'; import DynamicNoteSimple from '@/components/DynamicNoteSimple.vue'; import { $i } from '@/i'; +import { userPage } from '@/filters/user.js'; type SummalyResult = Awaited<ReturnType<typeof summaly>>; @@ -146,6 +158,10 @@ const player = ref<SummalyResult['player']>({ height: null, allow: [], }); +const linkAttribution = ref<{ + userId: string, +} | null>(null); +const attributionUser = ref<Misskey.entities.User | null>(null); const playerEnabled = ref(false); const tweetId = ref<string | null>(null); const tweetExpanded = ref(props.detail); @@ -221,7 +237,12 @@ function refresh(withFetch = false) { return res.json(); }) - .then(async (info: SummalyResult & { haveNoteLocally?: boolean } | null) => { + .then(async (info: SummalyResult & { + haveNoteLocally?: boolean, + linkAttribution?: { + userId: string, + } + } | null) => { unknownUrl.value = info == null; title.value = info?.title ?? null; description.value = info?.description ?? null; @@ -236,6 +257,16 @@ function refresh(withFetch = false) { }; sensitive.value = info?.sensitive ?? false; activityPub.value = info?.activityPub ?? null; + linkAttribution.value = info?.linkAttribution ?? null; + if (linkAttribution.value) { + try { + const response = await misskeyApi('users/show', { userId: linkAttribution.value.userId }); + attributionUser.value = response; + } catch { + // makes the loading ellipsis vanish. + linkAttribution.value = null; + } + } theNote.value = null; if (info?.haveNoteLocally) { @@ -395,6 +426,28 @@ refresh(); vertical-align: top; } +.linkAttributionIcon { + display: inline-block; + width: 16px; + height: 16px; + margin-left: 0.25em; + margin-right: 0.25em; + vertical-align: middle; + border-radius: 50%; + * { + border-radius: 4px; + } +} + +.linkAttribution { + width: 100%; + font-size: 0.8em; + display: inline-block; + margin: auto; + padding-top: 0.5em; + text-align: right; +} + .action { display: flex; gap: 6px; |