2018-02-16 17:17:05 +09:00
|
|
|
<template>
|
2018-06-21 01:46:35 +09:00
|
|
|
<div class="oh5y2r7l5lx8j6jj791ykeiwgihheguk">
|
2018-02-16 17:17:05 +09:00
|
|
|
<header>
|
2018-06-21 01:46:35 +09:00
|
|
|
<span :data-active="mode == 'default'" @click="mode = 'default'">%fa:comment-alt R% %i18n:@default%</span>
|
|
|
|
<span :data-active="mode == 'with-replies'" @click="mode = 'with-replies'">%fa:comments% %i18n:@with-replies%</span>
|
|
|
|
<span :data-active="mode == 'with-media'" @click="mode = 'with-media'">%fa:images% %i18n:@with-media%</span>
|
2018-02-16 17:17:05 +09:00
|
|
|
</header>
|
|
|
|
<div class="loading" v-if="fetching">
|
|
|
|
<mk-ellipsis-icon/>
|
|
|
|
</div>
|
2018-04-26 11:19:57 +09:00
|
|
|
<mk-notes ref="timeline" :more="existMore ? more : null">
|
2018-05-20 06:36:26 +09:00
|
|
|
<p class="empty" slot="empty">%fa:R comments%%i18n:@empty%</p>
|
2018-04-08 02:30:37 +09:00
|
|
|
</mk-notes>
|
2018-02-16 17:17:05 +09:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import Vue from 'vue';
|
2018-04-26 11:19:57 +09:00
|
|
|
|
|
|
|
const fetchLimit = 10;
|
|
|
|
|
2018-02-16 17:17:05 +09:00
|
|
|
export default Vue.extend({
|
|
|
|
props: ['user'],
|
2018-05-26 23:53:22 +09:00
|
|
|
|
2018-02-16 17:17:05 +09:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
fetching: true,
|
|
|
|
moreFetching: false,
|
2018-04-26 11:19:57 +09:00
|
|
|
existMore: false,
|
2018-02-16 17:17:05 +09:00
|
|
|
mode: 'default',
|
|
|
|
unreadCount: 0,
|
|
|
|
date: null
|
|
|
|
};
|
|
|
|
},
|
2018-05-26 23:53:22 +09:00
|
|
|
|
2018-04-16 15:13:31 +09:00
|
|
|
watch: {
|
|
|
|
mode() {
|
|
|
|
this.fetch();
|
|
|
|
}
|
|
|
|
},
|
2018-05-26 23:53:22 +09:00
|
|
|
|
2018-02-16 17:17:05 +09:00
|
|
|
mounted() {
|
|
|
|
document.addEventListener('keydown', this.onDocumentKeydown);
|
|
|
|
|
|
|
|
this.fetch(() => this.$emit('loaded'));
|
|
|
|
},
|
2018-05-26 23:53:22 +09:00
|
|
|
|
2018-02-16 17:17:05 +09:00
|
|
|
beforeDestroy() {
|
|
|
|
document.removeEventListener('keydown', this.onDocumentKeydown);
|
|
|
|
},
|
2018-05-26 23:53:22 +09:00
|
|
|
|
2018-02-16 17:17:05 +09:00
|
|
|
methods: {
|
|
|
|
onDocumentKeydown(e) {
|
|
|
|
if (e.target.tagName !== 'INPUT' && e.target.tagName !== 'TEXTAREA') {
|
|
|
|
if (e.which == 84) { // [t]
|
|
|
|
(this.$refs.timeline as any).focus();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2018-05-26 23:53:22 +09:00
|
|
|
|
2018-02-16 17:17:05 +09:00
|
|
|
fetch(cb?) {
|
2018-04-26 11:19:57 +09:00
|
|
|
this.fetching = true;
|
|
|
|
(this.$refs.timeline as any).init(() => new Promise((res, rej) => {
|
|
|
|
(this as any).api('users/notes', {
|
|
|
|
userId: this.user.id,
|
|
|
|
limit: fetchLimit + 1,
|
|
|
|
untilDate: this.date ? this.date.getTime() : undefined,
|
|
|
|
includeReplies: this.mode == 'with-replies',
|
|
|
|
withMedia: this.mode == 'with-media'
|
|
|
|
}).then(notes => {
|
|
|
|
if (notes.length == fetchLimit + 1) {
|
|
|
|
notes.pop();
|
|
|
|
this.existMore = true;
|
|
|
|
}
|
|
|
|
res(notes);
|
|
|
|
this.fetching = false;
|
|
|
|
if (cb) cb();
|
|
|
|
}, rej);
|
|
|
|
}));
|
2018-02-16 17:17:05 +09:00
|
|
|
},
|
2018-05-26 23:53:22 +09:00
|
|
|
|
2018-02-16 17:17:05 +09:00
|
|
|
more() {
|
|
|
|
this.moreFetching = true;
|
2018-05-26 23:53:22 +09:00
|
|
|
|
|
|
|
const promise = (this as any).api('users/notes', {
|
2018-03-29 14:48:47 +09:00
|
|
|
userId: this.user.id,
|
2018-04-26 11:19:57 +09:00
|
|
|
limit: fetchLimit + 1,
|
2018-04-16 15:13:31 +09:00
|
|
|
includeReplies: this.mode == 'with-replies',
|
|
|
|
withMedia: this.mode == 'with-media',
|
2018-04-26 11:19:57 +09:00
|
|
|
untilId: (this.$refs.timeline as any).tail().id
|
2018-05-26 23:53:22 +09:00
|
|
|
});
|
|
|
|
|
|
|
|
promise.then(notes => {
|
2018-04-26 11:19:57 +09:00
|
|
|
if (notes.length == fetchLimit + 1) {
|
|
|
|
notes.pop();
|
|
|
|
} else {
|
|
|
|
this.existMore = false;
|
|
|
|
}
|
|
|
|
notes.forEach(n => (this.$refs.timeline as any).append(n));
|
2018-02-16 17:17:05 +09:00
|
|
|
this.moreFetching = false;
|
|
|
|
});
|
2018-05-26 23:53:22 +09:00
|
|
|
|
|
|
|
return promise;
|
2018-02-16 17:17:05 +09:00
|
|
|
},
|
2018-05-26 23:53:22 +09:00
|
|
|
|
2018-02-22 21:39:36 +09:00
|
|
|
warp(date) {
|
|
|
|
this.date = date;
|
|
|
|
this.fetch();
|
2018-02-16 17:17:05 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="stylus" scoped>
|
2018-03-03 13:47:55 +09:00
|
|
|
@import '~const.styl'
|
|
|
|
|
2018-06-21 01:46:35 +09:00
|
|
|
root(isDark)
|
|
|
|
background isDark ? #282C37 : #fff
|
2018-02-16 17:17:05 +09:00
|
|
|
|
|
|
|
> header
|
2018-06-21 01:46:35 +09:00
|
|
|
padding 0 8px
|
|
|
|
z-index 10
|
|
|
|
background isDark ? #313543 : #fff
|
|
|
|
border-radius 6px 6px 0 0
|
|
|
|
box-shadow 0 1px isDark ? rgba(#000, 0.15) : rgba(#000, 0.08)
|
2018-02-16 17:17:05 +09:00
|
|
|
|
|
|
|
> span
|
2018-06-21 01:46:35 +09:00
|
|
|
display inline-block
|
|
|
|
padding 0 10px
|
|
|
|
line-height 42px
|
|
|
|
font-size 12px
|
|
|
|
user-select none
|
2018-02-16 17:17:05 +09:00
|
|
|
|
2018-06-21 01:46:35 +09:00
|
|
|
&[data-active]
|
2018-02-16 17:17:05 +09:00
|
|
|
color $theme-color
|
2018-06-21 01:46:35 +09:00
|
|
|
cursor default
|
|
|
|
font-weight bold
|
|
|
|
|
|
|
|
&:before
|
|
|
|
content ""
|
|
|
|
display block
|
|
|
|
position absolute
|
|
|
|
bottom 0
|
|
|
|
left -8px
|
|
|
|
width calc(100% + 16px)
|
|
|
|
height 2px
|
|
|
|
background $theme-color
|
|
|
|
|
|
|
|
&:not([data-active])
|
|
|
|
color isDark ? #9aa2a7 : #6f7477
|
2018-02-16 17:17:05 +09:00
|
|
|
cursor pointer
|
|
|
|
|
|
|
|
&:hover
|
2018-06-21 01:46:35 +09:00
|
|
|
color isDark ? #d9dcde : #525a5f
|
2018-02-16 17:17:05 +09:00
|
|
|
|
|
|
|
> .loading
|
|
|
|
padding 64px 0
|
|
|
|
|
|
|
|
> .empty
|
|
|
|
display block
|
|
|
|
margin 0 auto
|
|
|
|
padding 32px
|
|
|
|
max-width 400px
|
|
|
|
text-align center
|
|
|
|
color #999
|
|
|
|
|
|
|
|
> [data-fa]
|
|
|
|
display block
|
|
|
|
margin-bottom 16px
|
|
|
|
font-size 3em
|
|
|
|
color #ccc
|
|
|
|
|
2018-06-21 01:46:35 +09:00
|
|
|
.oh5y2r7l5lx8j6jj791ykeiwgihheguk[data-darkmode]
|
|
|
|
root(true)
|
|
|
|
|
|
|
|
.oh5y2r7l5lx8j6jj791ykeiwgihheguk:not([data-darkmode])
|
|
|
|
root(false)
|
|
|
|
|
2018-02-16 17:17:05 +09:00
|
|
|
</style>
|