2020-11-15 05:34:47 +02:00
|
|
|
<template>
|
2022-06-20 11:38:49 +03:00
|
|
|
<MkStickyContainer>
|
|
|
|
<template #header><MkPageHeader :actions="headerActions"/></template>
|
2023-01-16 07:18:11 +02:00
|
|
|
<MkSpacer :content-max="800">
|
2022-06-20 11:38:49 +03:00
|
|
|
<div v-if="clip">
|
|
|
|
<div class="okzinsic _panel">
|
|
|
|
<div v-if="clip.description" class="description">
|
|
|
|
<Mfm :text="clip.description" :is-note="false" :i="$i"/>
|
|
|
|
</div>
|
2023-03-16 10:24:49 +02:00
|
|
|
<MkButton v-if="favorited" v-tooltip="i18n.ts.unfavorite" as-like class="button" rounded primary @click="unfavorite()"><i class="ti ti-heart"></i><span v-if="clip.favoritedCount > 0" style="margin-left: 6px;">{{ clip.favoritedCount }}</span></MkButton>
|
|
|
|
<MkButton v-else v-tooltip="i18n.ts.favorite" as-like class="button" rounded @click="favorite()"><i class="ti ti-heart"></i><span v-if="clip.favoritedCount > 0" style="margin-left: 6px;">{{ clip.favoritedCount }}</span></MkButton>
|
2022-06-20 11:38:49 +03:00
|
|
|
<div class="user">
|
2023-02-08 13:07:19 +02:00
|
|
|
<MkAvatar :user="clip.user" class="avatar" indicator link preview/> <MkUserName :user="clip.user" :nowrap="false"/>
|
2022-06-20 11:38:49 +03:00
|
|
|
</div>
|
2021-12-10 09:15:36 +02:00
|
|
|
</div>
|
2020-11-15 05:34:47 +02:00
|
|
|
|
2023-02-22 04:00:34 +02:00
|
|
|
<MkNotes :pagination="pagination" :detail="true"/>
|
2022-06-20 11:38:49 +03:00
|
|
|
</div>
|
|
|
|
</MkSpacer>
|
|
|
|
</MkStickyContainer>
|
2020-11-15 05:34:47 +02:00
|
|
|
</template>
|
|
|
|
|
2022-06-18 12:23:54 +03:00
|
|
|
<script lang="ts" setup>
|
2022-06-18 12:27:09 +03:00
|
|
|
import { computed, watch, provide } from 'vue';
|
2022-06-18 12:23:54 +03:00
|
|
|
import * as misskey from 'misskey-js';
|
2023-02-22 04:00:34 +02:00
|
|
|
import MkNotes from '@/components/MkNotes.vue';
|
2022-06-18 12:23:54 +03:00
|
|
|
import { $i } from '@/account';
|
|
|
|
import { i18n } from '@/i18n';
|
2021-11-11 19:02:25 +02:00
|
|
|
import * as os from '@/os';
|
2022-06-20 11:38:49 +03:00
|
|
|
import { definePageMetadata } from '@/scripts/page-metadata';
|
2023-03-04 03:17:45 +02:00
|
|
|
import { url } from '@/config';
|
2023-03-16 10:24:49 +02:00
|
|
|
import MkButton from '@/components/MkButton.vue';
|
2023-03-24 09:54:37 +02:00
|
|
|
import { clipsCache } from '@/cache';
|
2020-11-15 05:34:47 +02:00
|
|
|
|
2022-06-18 12:23:54 +03:00
|
|
|
const props = defineProps<{
|
|
|
|
clipId: string,
|
|
|
|
}>();
|
|
|
|
|
|
|
|
let clip: misskey.entities.Clip = $ref<misskey.entities.Clip>();
|
2023-03-16 10:24:49 +02:00
|
|
|
let favorited = $ref(false);
|
2022-06-18 12:23:54 +03:00
|
|
|
const pagination = {
|
|
|
|
endpoint: 'clips/notes' as const,
|
|
|
|
limit: 10,
|
|
|
|
params: computed(() => ({
|
|
|
|
clipId: props.clipId,
|
|
|
|
})),
|
|
|
|
};
|
|
|
|
|
|
|
|
const isOwned: boolean | null = $computed<boolean | null>(() => $i && clip && ($i.id === clip.userId));
|
|
|
|
|
|
|
|
watch(() => props.clipId, async () => {
|
|
|
|
clip = await os.api('clips/show', {
|
|
|
|
clipId: props.clipId,
|
|
|
|
});
|
2023-03-16 10:24:49 +02:00
|
|
|
favorited = clip.isFavorited;
|
2022-06-18 12:23:54 +03:00
|
|
|
}, {
|
|
|
|
immediate: true,
|
|
|
|
});
|
|
|
|
|
2023-03-31 09:01:56 +03:00
|
|
|
provide('currentClip', $$(clip));
|
2022-06-18 12:27:09 +03:00
|
|
|
|
2023-03-16 10:24:49 +02:00
|
|
|
function favorite() {
|
|
|
|
os.apiWithDialog('clips/favorite', {
|
|
|
|
clipId: props.clipId,
|
|
|
|
}).then(() => {
|
|
|
|
favorited = true;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
async function unfavorite() {
|
|
|
|
const confirm = await os.confirm({
|
|
|
|
type: 'warning',
|
|
|
|
text: i18n.ts.unfavoriteConfirm,
|
|
|
|
});
|
|
|
|
if (confirm.canceled) return;
|
|
|
|
os.apiWithDialog('clips/unfavorite', {
|
|
|
|
clipId: props.clipId,
|
|
|
|
}).then(() => {
|
|
|
|
favorited = false;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-06-20 11:38:49 +03:00
|
|
|
const headerActions = $computed(() => clip && isOwned ? [{
|
2022-12-19 12:01:30 +02:00
|
|
|
icon: 'ti ti-pencil',
|
2022-06-20 11:38:49 +03:00
|
|
|
text: i18n.ts.edit,
|
|
|
|
handler: async (): Promise<void> => {
|
|
|
|
const { canceled, result } = await os.form(clip.name, {
|
|
|
|
name: {
|
|
|
|
type: 'string',
|
|
|
|
label: i18n.ts.name,
|
|
|
|
default: clip.name,
|
2020-11-15 05:34:47 +02:00
|
|
|
},
|
2022-06-20 11:38:49 +03:00
|
|
|
description: {
|
|
|
|
type: 'string',
|
|
|
|
required: false,
|
|
|
|
multiline: true,
|
|
|
|
label: i18n.ts.description,
|
|
|
|
default: clip.description,
|
2020-11-15 05:34:47 +02:00
|
|
|
},
|
2022-06-20 11:38:49 +03:00
|
|
|
isPublic: {
|
|
|
|
type: 'boolean',
|
|
|
|
label: i18n.ts.public,
|
|
|
|
default: clip.isPublic,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
if (canceled) return;
|
|
|
|
|
|
|
|
os.apiWithDialog('clips/update', {
|
|
|
|
clipId: clip.id,
|
|
|
|
...result,
|
|
|
|
});
|
2023-03-24 09:54:37 +02:00
|
|
|
|
|
|
|
clipsCache.delete();
|
2022-06-20 11:38:49 +03:00
|
|
|
},
|
2023-03-04 03:17:45 +02:00
|
|
|
}, ...(clip.isPublic ? [{
|
|
|
|
icon: 'ti ti-share',
|
|
|
|
text: i18n.ts.share,
|
|
|
|
handler: async (): Promise<void> => {
|
|
|
|
navigator.share({
|
|
|
|
title: clip.name,
|
|
|
|
text: clip.description,
|
|
|
|
url: `${url}/clips/${clip.id}`,
|
|
|
|
});
|
|
|
|
},
|
|
|
|
}] : []), {
|
2022-12-19 12:01:30 +02:00
|
|
|
icon: 'ti ti-trash',
|
2022-06-20 11:38:49 +03:00
|
|
|
text: i18n.ts.delete,
|
|
|
|
danger: true,
|
|
|
|
handler: async (): Promise<void> => {
|
|
|
|
const { canceled } = await os.confirm({
|
|
|
|
type: 'warning',
|
|
|
|
text: i18n.t('deleteAreYouSure', { x: clip.name }),
|
|
|
|
});
|
|
|
|
if (canceled) return;
|
|
|
|
|
|
|
|
await os.apiWithDialog('clips/delete', {
|
|
|
|
clipId: clip.id,
|
|
|
|
});
|
2023-03-24 09:54:37 +02:00
|
|
|
|
|
|
|
clipsCache.delete();
|
2022-06-20 11:38:49 +03:00
|
|
|
},
|
|
|
|
}] : null);
|
|
|
|
|
|
|
|
definePageMetadata(computed(() => clip ? {
|
|
|
|
title: clip.name,
|
2022-12-19 12:01:30 +02:00
|
|
|
icon: 'ti ti-paperclip',
|
2022-06-20 11:38:49 +03:00
|
|
|
} : null));
|
2020-11-15 05:34:47 +02:00
|
|
|
</script>
|
|
|
|
|
2022-12-27 11:29:39 +02:00
|
|
|
<style lang="scss" scoped>
|
2020-11-15 05:34:47 +02:00
|
|
|
.okzinsic {
|
|
|
|
position: relative;
|
2021-12-10 09:15:36 +02:00
|
|
|
margin-bottom: var(--margin);
|
2020-11-15 05:34:47 +02:00
|
|
|
|
|
|
|
> .description {
|
|
|
|
padding: 16px;
|
|
|
|
}
|
2020-11-15 05:47:54 +02:00
|
|
|
|
|
|
|
> .user {
|
|
|
|
$height: 32px;
|
|
|
|
padding: 16px;
|
2021-04-10 06:40:50 +03:00
|
|
|
border-top: solid 0.5px var(--divider);
|
2020-11-15 05:47:54 +02:00
|
|
|
line-height: $height;
|
|
|
|
|
|
|
|
> .avatar {
|
|
|
|
width: $height;
|
|
|
|
height: $height;
|
|
|
|
}
|
|
|
|
}
|
2020-11-15 05:34:47 +02:00
|
|
|
}
|
|
|
|
</style>
|