2020-11-15 03:34:47 +00:00
|
|
|
<template>
|
2022-06-20 08:38:49 +00:00
|
|
|
<MkStickyContainer>
|
|
|
|
<template #header><MkPageHeader :actions="headerActions"/></template>
|
2022-12-27 09:01:06 +00:00
|
|
|
<MkSpacer :content-max="800">
|
2022-06-20 08:38:49 +00: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>
|
|
|
|
<div class="user">
|
|
|
|
<MkAvatar :user="clip.user" class="avatar" :show-indicator="true"/> <MkUserName :user="clip.user" :nowrap="false"/>
|
|
|
|
</div>
|
2021-12-10 07:15:36 +00:00
|
|
|
</div>
|
2020-11-15 03:34:47 +00:00
|
|
|
|
2022-06-20 08:38:49 +00:00
|
|
|
<XNotes :pagination="pagination" :detail="true"/>
|
|
|
|
</div>
|
|
|
|
</MkSpacer>
|
|
|
|
</MkStickyContainer>
|
2020-11-15 03:34:47 +00:00
|
|
|
</template>
|
|
|
|
|
2022-06-18 09:23:54 +00:00
|
|
|
<script lang="ts" setup>
|
2022-06-18 09:27:09 +00:00
|
|
|
import { computed, watch, provide } from 'vue';
|
2022-06-18 09:23:54 +00:00
|
|
|
import * as misskey from 'misskey-js';
|
2022-08-30 15:24:33 +00:00
|
|
|
import XNotes from '@/components/MkNotes.vue';
|
2022-06-18 09:23:54 +00:00
|
|
|
import { $i } from '@/account';
|
|
|
|
import { i18n } from '@/i18n';
|
2021-11-11 17:02:25 +00:00
|
|
|
import * as os from '@/os';
|
2022-06-20 08:38:49 +00:00
|
|
|
import { definePageMetadata } from '@/scripts/page-metadata';
|
2020-11-15 03:34:47 +00:00
|
|
|
|
2022-06-18 09:23:54 +00:00
|
|
|
const props = defineProps<{
|
|
|
|
clipId: string,
|
|
|
|
}>();
|
|
|
|
|
|
|
|
let clip: misskey.entities.Clip = $ref<misskey.entities.Clip>();
|
|
|
|
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,
|
|
|
|
});
|
|
|
|
}, {
|
|
|
|
immediate: true,
|
|
|
|
});
|
|
|
|
|
2022-06-18 09:27:47 +00:00
|
|
|
provide('currentClipPage', $$(clip));
|
2022-06-18 09:27:09 +00:00
|
|
|
|
2022-06-20 08:38:49 +00:00
|
|
|
const headerActions = $computed(() => clip && isOwned ? [{
|
2022-12-19 10:01:30 +00:00
|
|
|
icon: 'ti ti-pencil',
|
2022-06-20 08:38:49 +00: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 03:34:47 +00:00
|
|
|
},
|
2022-06-20 08:38:49 +00:00
|
|
|
description: {
|
|
|
|
type: 'string',
|
|
|
|
required: false,
|
|
|
|
multiline: true,
|
|
|
|
label: i18n.ts.description,
|
|
|
|
default: clip.description,
|
2020-11-15 03:34:47 +00:00
|
|
|
},
|
2022-06-20 08:38:49 +00:00
|
|
|
isPublic: {
|
|
|
|
type: 'boolean',
|
|
|
|
label: i18n.ts.public,
|
|
|
|
default: clip.isPublic,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
if (canceled) return;
|
|
|
|
|
|
|
|
os.apiWithDialog('clips/update', {
|
|
|
|
clipId: clip.id,
|
|
|
|
...result,
|
|
|
|
});
|
|
|
|
},
|
|
|
|
}, {
|
2022-12-19 10:01:30 +00:00
|
|
|
icon: 'ti ti-trash',
|
2022-06-20 08:38:49 +00: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,
|
|
|
|
});
|
|
|
|
},
|
|
|
|
}] : null);
|
|
|
|
|
|
|
|
definePageMetadata(computed(() => clip ? {
|
|
|
|
title: clip.name,
|
2022-12-19 10:01:30 +00:00
|
|
|
icon: 'ti ti-paperclip',
|
2022-06-20 08:38:49 +00:00
|
|
|
} : null));
|
2020-11-15 03:34:47 +00:00
|
|
|
</script>
|
|
|
|
|
2022-12-27 09:01:06 +00:00
|
|
|
<style lang="scss">
|
2020-11-15 03:34:47 +00:00
|
|
|
.okzinsic {
|
|
|
|
position: relative;
|
2021-12-10 07:15:36 +00:00
|
|
|
margin-bottom: var(--margin);
|
2020-11-15 03:34:47 +00:00
|
|
|
|
|
|
|
> .description {
|
|
|
|
padding: 16px;
|
|
|
|
}
|
2020-11-15 03:47:54 +00:00
|
|
|
|
|
|
|
> .user {
|
|
|
|
$height: 32px;
|
|
|
|
padding: 16px;
|
2021-04-10 03:40:50 +00:00
|
|
|
border-top: solid 0.5px var(--divider);
|
2020-11-15 03:47:54 +00:00
|
|
|
line-height: $height;
|
|
|
|
|
|
|
|
> .avatar {
|
|
|
|
width: $height;
|
|
|
|
height: $height;
|
|
|
|
}
|
|
|
|
}
|
2020-11-15 03:34:47 +00:00
|
|
|
}
|
|
|
|
</style>
|