2020-01-29 12:37:25 -07:00
|
|
|
<template>
|
2021-04-09 21:40:50 -06:00
|
|
|
<div class="fcuexfpr _root">
|
2021-04-16 20:40:47 -06:00
|
|
|
<transition name="fade" mode="out-in">
|
|
|
|
<div v-if="note" class="note">
|
|
|
|
<div class="_gap" v-if="showNext">
|
|
|
|
<XNotes class="_content" :pagination="next" :no-gap="true"/>
|
2020-10-17 05:12:00 -06:00
|
|
|
</div>
|
2021-04-16 20:40:47 -06:00
|
|
|
|
|
|
|
<div class="main _gap">
|
2021-04-20 08:22:59 -06:00
|
|
|
<MkButton v-if="!showNext && hasNext" class="load next" @click="showNext = true"><i class="fas fa-chevron-up"></i></MkButton>
|
2021-08-16 00:21:58 -06:00
|
|
|
<div class="note _gap">
|
|
|
|
<MkRemoteCaution v-if="note.user.host != null" :href="note.url || note.uri" class="_isolated"/>
|
|
|
|
<XNoteDetailed v-model:note="note" :key="note.id" class="_isolated note"/>
|
2021-04-16 20:40:47 -06:00
|
|
|
</div>
|
|
|
|
<div class="_content clips _gap" v-if="clips && clips.length > 0">
|
|
|
|
<div class="title">{{ $ts.clip }}</div>
|
|
|
|
<MkA v-for="item in clips" :key="item.id" :to="`/clips/${item.id}`" class="item _panel _gap">
|
|
|
|
<b>{{ item.name }}</b>
|
|
|
|
<div v-if="item.description" class="description">{{ item.description }}</div>
|
|
|
|
<div class="user">
|
2021-04-17 08:52:54 -06:00
|
|
|
<MkAvatar :user="item.user" class="avatar" :show-indicator="true"/> <MkUserName :user="item.user" :nowrap="false"/>
|
2021-04-16 20:40:47 -06:00
|
|
|
</div>
|
|
|
|
</MkA>
|
|
|
|
</div>
|
2021-04-20 08:22:59 -06:00
|
|
|
<MkButton v-if="!showPrev && hasPrev" class="load prev" @click="showPrev = true"><i class="fas fa-chevron-down"></i></MkButton>
|
2020-11-16 22:59:15 -07:00
|
|
|
</div>
|
2020-02-16 06:15:49 -07:00
|
|
|
|
2021-04-16 20:40:47 -06:00
|
|
|
<div class="_gap" v-if="showPrev">
|
|
|
|
<XNotes class="_content" :pagination="prev" :no-gap="true"/>
|
|
|
|
</div>
|
2020-10-17 05:12:00 -06:00
|
|
|
</div>
|
2021-04-16 20:40:47 -06:00
|
|
|
<MkError v-else-if="error" @retry="fetch()"/>
|
|
|
|
<MkLoading v-else/>
|
|
|
|
</transition>
|
2020-01-29 12:37:25 -07:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-10-17 05:12:00 -06:00
|
|
|
import { computed, defineComponent } from 'vue';
|
2021-03-23 02:30:14 -06:00
|
|
|
import XNote from '@client/components/note.vue';
|
|
|
|
import XNoteDetailed from '@client/components/note-detailed.vue';
|
|
|
|
import XNotes from '@client/components/notes.vue';
|
|
|
|
import MkRemoteCaution from '@client/components/remote-caution.vue';
|
|
|
|
import MkButton from '@client/components/ui/button.vue';
|
|
|
|
import * as os from '@client/os';
|
2021-04-09 21:54:12 -06:00
|
|
|
import * as symbols from '@client/symbols';
|
2020-01-29 12:37:25 -07:00
|
|
|
|
2020-10-17 05:12:00 -06:00
|
|
|
export default defineComponent({
|
2020-01-29 12:37:25 -07:00
|
|
|
components: {
|
2020-02-16 06:15:49 -07:00
|
|
|
XNote,
|
2021-01-01 06:41:20 -07:00
|
|
|
XNoteDetailed,
|
2020-02-16 06:15:49 -07:00
|
|
|
XNotes,
|
2020-03-20 22:07:02 -06:00
|
|
|
MkRemoteCaution,
|
2020-10-17 05:12:00 -06:00
|
|
|
MkButton,
|
2020-01-29 12:37:25 -07:00
|
|
|
},
|
2020-10-24 10:21:41 -06:00
|
|
|
props: {
|
|
|
|
noteId: {
|
|
|
|
type: String,
|
|
|
|
required: true
|
|
|
|
}
|
|
|
|
},
|
2020-01-29 12:37:25 -07:00
|
|
|
data() {
|
|
|
|
return {
|
2021-04-09 21:54:12 -06:00
|
|
|
[symbols.PAGE_INFO]: computed(() => this.note ? {
|
2020-12-25 18:47:36 -07:00
|
|
|
title: this.$ts.note,
|
2020-11-03 04:36:12 -07:00
|
|
|
avatar: this.note.user,
|
2021-04-10 08:52:45 -06:00
|
|
|
path: `/notes/${this.note.id}`,
|
2021-04-09 22:38:24 -06:00
|
|
|
share: {
|
|
|
|
title: this.$t('noteOf', { user: this.note.user.name }),
|
|
|
|
text: this.note.text,
|
|
|
|
},
|
2020-10-17 05:12:00 -06:00
|
|
|
} : null),
|
2020-01-29 12:37:25 -07:00
|
|
|
note: null,
|
2020-11-16 22:59:15 -07:00
|
|
|
clips: null,
|
2020-02-16 06:15:49 -07:00
|
|
|
hasPrev: false,
|
|
|
|
hasNext: false,
|
|
|
|
showPrev: false,
|
|
|
|
showNext: false,
|
2020-01-29 12:37:25 -07:00
|
|
|
error: null,
|
2020-02-16 06:15:49 -07:00
|
|
|
prev: {
|
|
|
|
endpoint: 'users/notes',
|
|
|
|
limit: 10,
|
|
|
|
params: init => ({
|
|
|
|
userId: this.note.userId,
|
|
|
|
untilId: this.note.id,
|
|
|
|
})
|
|
|
|
},
|
|
|
|
next: {
|
|
|
|
reversed: true,
|
|
|
|
endpoint: 'users/notes',
|
|
|
|
limit: 10,
|
|
|
|
params: init => ({
|
|
|
|
userId: this.note.userId,
|
|
|
|
sinceId: this.note.id,
|
|
|
|
})
|
|
|
|
},
|
2020-01-29 12:37:25 -07:00
|
|
|
};
|
|
|
|
},
|
|
|
|
watch: {
|
2020-10-24 10:21:41 -06:00
|
|
|
noteId: 'fetch'
|
2020-01-29 12:37:25 -07:00
|
|
|
},
|
|
|
|
created() {
|
|
|
|
this.fetch();
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
fetch() {
|
2021-04-16 20:40:47 -06:00
|
|
|
this.note = null;
|
2020-10-17 05:12:00 -06:00
|
|
|
os.api('notes/show', {
|
2020-10-24 10:21:41 -06:00
|
|
|
noteId: this.noteId
|
2020-01-29 12:37:25 -07:00
|
|
|
}).then(note => {
|
2021-08-16 00:21:58 -06:00
|
|
|
this.note = note;
|
2020-02-16 06:15:49 -07:00
|
|
|
Promise.all([
|
2020-11-16 22:59:15 -07:00
|
|
|
os.api('notes/clips', {
|
|
|
|
noteId: note.id,
|
|
|
|
}),
|
2020-10-17 05:12:00 -06:00
|
|
|
os.api('users/notes', {
|
2020-02-16 06:15:49 -07:00
|
|
|
userId: note.userId,
|
|
|
|
untilId: note.id,
|
|
|
|
limit: 1,
|
|
|
|
}),
|
2020-10-17 05:12:00 -06:00
|
|
|
os.api('users/notes', {
|
2020-02-16 06:15:49 -07:00
|
|
|
userId: note.userId,
|
|
|
|
sinceId: note.id,
|
|
|
|
limit: 1,
|
|
|
|
}),
|
2020-11-16 22:59:15 -07:00
|
|
|
]).then(([clips, prev, next]) => {
|
|
|
|
this.clips = clips;
|
2020-02-16 06:15:49 -07:00
|
|
|
this.hasPrev = prev.length !== 0;
|
|
|
|
this.hasNext = next.length !== 0;
|
|
|
|
});
|
2020-01-29 12:37:25 -07:00
|
|
|
}).catch(e => {
|
|
|
|
this.error = e;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
2020-10-17 05:12:00 -06:00
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2021-04-16 20:40:47 -06:00
|
|
|
.fade-enter-active,
|
|
|
|
.fade-leave-active {
|
|
|
|
transition: opacity 0.125s ease;
|
|
|
|
}
|
|
|
|
.fade-enter-from,
|
|
|
|
.fade-leave-to {
|
|
|
|
opacity: 0;
|
|
|
|
}
|
|
|
|
|
2020-10-17 05:12:00 -06:00
|
|
|
.fcuexfpr {
|
2021-08-16 00:21:58 -06:00
|
|
|
background: var(--bg);
|
|
|
|
|
2020-10-17 05:12:00 -06:00
|
|
|
> .note {
|
2020-11-16 22:59:15 -07:00
|
|
|
> .main {
|
2020-10-17 05:12:00 -06:00
|
|
|
> .load {
|
|
|
|
min-width: 0;
|
2021-04-09 21:40:50 -06:00
|
|
|
margin: 0 auto;
|
2020-10-17 05:12:00 -06:00
|
|
|
border-radius: 999px;
|
2020-11-16 22:59:15 -07:00
|
|
|
|
|
|
|
&.next {
|
|
|
|
margin-bottom: var(--margin);
|
|
|
|
}
|
|
|
|
|
|
|
|
&.prev {
|
|
|
|
margin-top: var(--margin);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-16 00:21:58 -06:00
|
|
|
> .note {
|
|
|
|
> .note {
|
|
|
|
border-radius: var(--radius);
|
|
|
|
background: var(--panel);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-16 22:59:15 -07:00
|
|
|
> .clips {
|
|
|
|
> .title {
|
|
|
|
font-weight: bold;
|
|
|
|
padding: 12px;
|
|
|
|
}
|
|
|
|
|
|
|
|
> .item {
|
|
|
|
display: block;
|
|
|
|
padding: 16px;
|
|
|
|
|
|
|
|
> .description {
|
|
|
|
padding: 8px 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
> .user {
|
|
|
|
$height: 32px;
|
|
|
|
padding-top: 16px;
|
2021-04-09 21:40:50 -06:00
|
|
|
border-top: solid 0.5px var(--divider);
|
2020-11-16 22:59:15 -07:00
|
|
|
line-height: $height;
|
|
|
|
|
|
|
|
> .avatar {
|
|
|
|
width: $height;
|
|
|
|
height: $height;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-10-17 05:12:00 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|