2020-01-29 19:37:25 +00:00
|
|
|
<template>
|
|
|
|
<div class="mk-note-page">
|
2020-02-09 18:55:33 +00:00
|
|
|
<portal to="avatar" v-if="note"><mk-avatar class="avatar" :user="note.user" :disable-preview="true"/></portal>
|
2020-03-20 04:57:55 +00:00
|
|
|
<portal to="title" v-if="note">
|
|
|
|
<mfm
|
|
|
|
:text="$t('noteOf', { user: note.user.name || note.user.username })"
|
|
|
|
:plain="true" :nowrap="true" :custom-emojis="note.user.emojis" :is-note="false"
|
|
|
|
/>
|
|
|
|
</portal>
|
2020-02-09 18:55:33 +00:00
|
|
|
|
2020-03-21 03:32:40 +00:00
|
|
|
<div v-if="note">
|
|
|
|
<button class="_panel _button" v-if="hasNext && !showNext" @click="showNext = true" style="margin: 0 auto var(--margin) auto;"><fa :icon="faChevronUp"/></button>
|
|
|
|
<x-notes v-if="showNext" ref="next" :pagination="next"/>
|
|
|
|
<hr v-if="showNext"/>
|
2020-02-16 13:15:49 +00:00
|
|
|
|
2020-04-02 12:59:14 +00:00
|
|
|
<mk-remote-caution v-if="note.user.host != null" :href="note.url || note.uri" style="margin-bottom: var(--margin)"/>
|
2020-07-27 14:25:37 +00:00
|
|
|
<x-note v-model="note" :key="note.id" :detail="true"/>
|
2020-03-21 03:32:40 +00:00
|
|
|
|
|
|
|
<button class="_panel _button" v-if="hasPrev && !showPrev" @click="showPrev = true" style="margin: var(--margin) auto 0 auto;"><fa :icon="faChevronDown"/></button>
|
|
|
|
<hr v-if="showPrev"/>
|
|
|
|
<x-notes v-if="showPrev" ref="prev" :pagination="prev" style="margin-top: var(--margin);"/>
|
|
|
|
</div>
|
2020-07-11 01:13:11 +00:00
|
|
|
|
|
|
|
<div v-if="error">
|
|
|
|
<mk-error @retry="fetch()"/>
|
|
|
|
</div>
|
2020-01-29 19:37:25 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import Vue from 'vue';
|
2020-02-16 13:15:49 +00:00
|
|
|
import { faChevronUp, faChevronDown } from '@fortawesome/free-solid-svg-icons';
|
2020-01-29 19:37:25 +00:00
|
|
|
import Progress from '../scripts/loading';
|
|
|
|
import XNote from '../components/note.vue';
|
2020-02-16 13:15:49 +00:00
|
|
|
import XNotes from '../components/notes.vue';
|
2020-03-21 04:07:02 +00:00
|
|
|
import MkRemoteCaution from '../components/remote-caution.vue';
|
2020-01-29 19:37:25 +00:00
|
|
|
|
|
|
|
export default Vue.extend({
|
|
|
|
metaInfo() {
|
|
|
|
return {
|
|
|
|
title: this.$t('note') as string
|
|
|
|
};
|
|
|
|
},
|
|
|
|
components: {
|
2020-02-16 13:15:49 +00:00
|
|
|
XNote,
|
|
|
|
XNotes,
|
2020-03-21 04:07:02 +00:00
|
|
|
MkRemoteCaution,
|
2020-01-29 19:37:25 +00:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
note: null,
|
2020-02-16 13:15:49 +00:00
|
|
|
hasPrev: false,
|
|
|
|
hasNext: false,
|
|
|
|
showPrev: false,
|
|
|
|
showNext: false,
|
2020-01-29 19:37:25 +00:00
|
|
|
error: null,
|
2020-02-16 13:15:49 +00: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,
|
|
|
|
})
|
|
|
|
},
|
|
|
|
faChevronUp, faChevronDown
|
2020-01-29 19:37:25 +00:00
|
|
|
};
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
$route: 'fetch'
|
|
|
|
},
|
|
|
|
created() {
|
|
|
|
this.fetch();
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
fetch() {
|
|
|
|
Progress.start();
|
|
|
|
this.$root.api('notes/show', {
|
|
|
|
noteId: this.$route.params.note
|
|
|
|
}).then(note => {
|
2020-02-16 13:15:49 +00:00
|
|
|
Promise.all([
|
|
|
|
this.$root.api('users/notes', {
|
|
|
|
userId: note.userId,
|
|
|
|
untilId: note.id,
|
|
|
|
limit: 1,
|
|
|
|
}),
|
|
|
|
this.$root.api('users/notes', {
|
|
|
|
userId: note.userId,
|
|
|
|
sinceId: note.id,
|
|
|
|
limit: 1,
|
|
|
|
}),
|
|
|
|
]).then(([prev, next]) => {
|
|
|
|
this.hasPrev = prev.length !== 0;
|
|
|
|
this.hasNext = next.length !== 0;
|
|
|
|
this.note = note;
|
|
|
|
});
|
2020-01-29 19:37:25 +00:00
|
|
|
}).catch(e => {
|
|
|
|
this.error = e;
|
|
|
|
}).finally(() => {
|
|
|
|
Progress.done();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|