2020-01-30 04:37:25 +09:00
|
|
|
<template>
|
2020-05-10 17:12:19 +09:00
|
|
|
<div class="mfcuwfyp">
|
2020-02-19 06:16:49 +09:00
|
|
|
<x-list class="notifications" :items="items" v-slot="{ item: notification }">
|
2020-02-19 06:26:29 +09:00
|
|
|
<x-note v-if="['reply', 'quote', 'mention'].includes(notification.type)" :note="notification.note" :key="notification.id"/>
|
2020-03-20 18:11:39 +09:00
|
|
|
<x-notification v-else :notification="notification" :with-time="true" :full="true" class="_panel notification" :key="notification.id"/>
|
2020-02-19 06:16:49 +09:00
|
|
|
</x-list>
|
2020-01-30 04:37:25 +09:00
|
|
|
|
2020-05-31 12:53:06 +09:00
|
|
|
<button class="_panel _button" ref="loadMore" v-show="more" :disabled="moreFetching" :style="{ cursor: moreFetching ? 'wait' : 'pointer' }">
|
2020-07-25 01:56:52 +09:00
|
|
|
<template v-if="!moreFetching">{{ $t('loadMore') }}</template>
|
2020-03-21 12:32:40 +09:00
|
|
|
<template v-if="moreFetching"><mk-loading inline/></template>
|
2020-02-19 06:16:49 +09:00
|
|
|
</button>
|
2020-01-30 04:37:25 +09:00
|
|
|
|
2020-07-25 01:56:52 +09:00
|
|
|
<p class="empty" v-if="empty">{{ $t('noNotifications') }}</p>
|
2020-01-30 04:37:25 +09:00
|
|
|
|
2020-02-19 06:16:49 +09:00
|
|
|
<mk-error v-if="error" @retry="init()"/>
|
2020-01-30 04:37:25 +09:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import Vue from 'vue';
|
|
|
|
import paging from '../scripts/paging';
|
|
|
|
import XNotification from './notification.vue';
|
|
|
|
import XList from './date-separated-list.vue';
|
2020-02-19 06:26:29 +09:00
|
|
|
import XNote from './note.vue';
|
2020-01-30 04:37:25 +09:00
|
|
|
|
|
|
|
export default Vue.extend({
|
|
|
|
components: {
|
|
|
|
XNotification,
|
|
|
|
XList,
|
2020-02-19 06:26:29 +09:00
|
|
|
XNote,
|
2020-01-30 04:37:25 +09:00
|
|
|
},
|
|
|
|
|
|
|
|
mixins: [
|
|
|
|
paging({}),
|
|
|
|
],
|
|
|
|
|
|
|
|
props: {
|
|
|
|
type: {
|
|
|
|
type: String,
|
|
|
|
required: false
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
connection: null,
|
|
|
|
pagination: {
|
|
|
|
endpoint: 'i/notifications',
|
|
|
|
limit: 10,
|
|
|
|
params: () => ({
|
|
|
|
includeTypes: this.type ? [this.type] : undefined
|
|
|
|
})
|
|
|
|
},
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
watch: {
|
|
|
|
type() {
|
|
|
|
this.reload();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
mounted() {
|
|
|
|
this.connection = this.$root.stream.useSharedConnection('main');
|
|
|
|
this.connection.on('notification', this.onNotification);
|
|
|
|
},
|
|
|
|
|
|
|
|
beforeDestroy() {
|
|
|
|
this.connection.dispose();
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
onNotification(notification) {
|
2020-05-24 18:41:40 +09:00
|
|
|
if (document.visibilityState === 'visible') {
|
|
|
|
this.$root.stream.send('readNotification', {
|
|
|
|
id: notification.id
|
|
|
|
});
|
2020-05-26 14:34:49 +09:00
|
|
|
|
|
|
|
notification.isRead = true;
|
2020-05-24 18:41:40 +09:00
|
|
|
}
|
2020-01-30 04:37:25 +09:00
|
|
|
|
|
|
|
this.prepend(notification);
|
|
|
|
},
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2020-05-10 17:12:19 +09:00
|
|
|
.mfcuwfyp {
|
2020-02-19 06:16:49 +09:00
|
|
|
> .empty {
|
|
|
|
margin: 0;
|
|
|
|
padding: 16px;
|
|
|
|
text-align: center;
|
|
|
|
color: var(--fg);
|
|
|
|
}
|
2020-01-30 04:37:25 +09:00
|
|
|
|
2020-02-19 06:16:49 +09:00
|
|
|
> .placeholder {
|
|
|
|
padding: 32px;
|
|
|
|
opacity: 0.3;
|
2020-01-30 04:37:25 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|