Change loading in order to change channel when loading
This commit is contained in:
parent
582e751fba
commit
351be72586
|
@ -1,8 +1,7 @@
|
||||||
<template>
|
<template>
|
||||||
<div id="directmessages" v-shortkey="shortcutEnabled ? { next: ['j'] } : {}" @shortkey="handleKey">
|
<div id="directmessages" v-shortkey="shortcutEnabled ? { next: ['j'] } : {}" @shortkey="handleKey">
|
||||||
<div class="unread">{{ unread.length > 0 ? unread.length : '' }}</div>
|
<div class="unread">{{ unread.length > 0 ? unread.length : '' }}</div>
|
||||||
<div v-shortkey="{linux: ['ctrl', 'r'], mac: ['meta', 'r']}" @shortkey="reload()">
|
<div v-shortkey="{ linux: ['ctrl', 'r'], mac: ['meta', 'r'] }" @shortkey="reload()"></div>
|
||||||
</div>
|
|
||||||
<transition-group name="timeline" tag="div">
|
<transition-group name="timeline" tag="div">
|
||||||
<toot
|
<toot
|
||||||
:message="message"
|
:message="message"
|
||||||
|
@ -20,11 +19,9 @@
|
||||||
>
|
>
|
||||||
</toot>
|
</toot>
|
||||||
</transition-group>
|
</transition-group>
|
||||||
<div class="loading-card" v-loading="lazyLoading" :element-loading-background="backgroundColor">
|
<div class="loading-card" v-loading="lazyLoading" :element-loading-background="backgroundColor"></div>
|
||||||
</div>
|
|
||||||
<div :class="openSideBar ? 'upper-with-side-bar' : 'upper'" v-show="!heading">
|
<div :class="openSideBar ? 'upper-with-side-bar' : 'upper'" v-show="!heading">
|
||||||
<el-button type="primary" icon="el-icon-arrow-up" @click="upper" circle>
|
<el-button type="primary" icon="el-icon-arrow-up" @click="upper" circle> </el-button>
|
||||||
</el-button>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -59,9 +56,7 @@ export default {
|
||||||
startReload: state => state.TimelineSpace.HeaderMenu.reload,
|
startReload: state => state.TimelineSpace.HeaderMenu.reload,
|
||||||
unreadNotification: state => state.TimelineSpace.unreadNotification
|
unreadNotification: state => state.TimelineSpace.unreadNotification
|
||||||
}),
|
}),
|
||||||
...mapGetters('TimelineSpace/Modals', [
|
...mapGetters('TimelineSpace/Modals', ['modalOpened']),
|
||||||
'modalOpened'
|
|
||||||
]),
|
|
||||||
shortcutEnabled: function() {
|
shortcutEnabled: function() {
|
||||||
if (this.modalOpened) {
|
if (this.modalOpened) {
|
||||||
return false
|
return false
|
||||||
|
@ -75,16 +70,14 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async mounted() {
|
async mounted() {
|
||||||
this.$store.commit('TimelineSpace/changeLoading', true)
|
|
||||||
this.$store.commit('TimelineSpace/SideMenu/changeUnreadDirectMessagesTimeline', false)
|
this.$store.commit('TimelineSpace/SideMenu/changeUnreadDirectMessagesTimeline', false)
|
||||||
document.getElementById('scrollable').addEventListener('scroll', this.onScroll)
|
document.getElementById('scrollable').addEventListener('scroll', this.onScroll)
|
||||||
if (!this.unreadNotification.direct) {
|
if (!this.unreadNotification.direct) {
|
||||||
await this.initialize()
|
this.$store.commit('TimelineSpace/Contents/changeLoading', true)
|
||||||
.catch(_ => {
|
await this.initialize().catch(_ => {
|
||||||
this.$store.commit('TimelineSpace/changeLoading', false)
|
this.$store.commit('TimelineSpace/Contents/changeLoading', false)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
this.$store.commit('TimelineSpace/changeLoading', false)
|
|
||||||
|
|
||||||
Event.$on('focus-timeline', () => {
|
Event.$on('focus-timeline', () => {
|
||||||
// If focusedId does not change, we have to refresh focusedId because Toot component watch change events.
|
// If focusedId does not change, we have to refresh focusedId because Toot component watch change events.
|
||||||
|
@ -122,8 +115,7 @@ export default {
|
||||||
watch: {
|
watch: {
|
||||||
startReload: function(newState, oldState) {
|
startReload: function(newState, oldState) {
|
||||||
if (!oldState && newState) {
|
if (!oldState && newState) {
|
||||||
this.reload()
|
this.reload().finally(() => {
|
||||||
.finally(() => {
|
|
||||||
this.$store.commit('TimelineSpace/HeaderMenu/changeReload', false)
|
this.$store.commit('TimelineSpace/HeaderMenu/changeReload', false)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -139,8 +131,7 @@ export default {
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async initialize() {
|
async initialize() {
|
||||||
await this.$store.dispatch('TimelineSpace/Contents/DirectMessages/fetchTimeline')
|
await this.$store.dispatch('TimelineSpace/Contents/DirectMessages/fetchTimeline').catch(_ => {
|
||||||
.catch(_ => {
|
|
||||||
this.$message({
|
this.$message({
|
||||||
message: this.$t('message.timeline_fetch_error'),
|
message: this.$t('message.timeline_fetch_error'),
|
||||||
type: 'error'
|
type: 'error'
|
||||||
|
@ -151,8 +142,12 @@ export default {
|
||||||
},
|
},
|
||||||
onScroll(event) {
|
onScroll(event) {
|
||||||
// for lazyLoading
|
// for lazyLoading
|
||||||
if (((event.target.clientHeight + event.target.scrollTop) >= document.getElementById('directmessages').clientHeight - 10) && !this.lazyloading) {
|
if (
|
||||||
this.$store.dispatch('TimelineSpace/Contents/DirectMessages/lazyFetchTimeline', this.timeline[this.timeline.length - 1])
|
event.target.clientHeight + event.target.scrollTop >= document.getElementById('directmessages').clientHeight - 10 &&
|
||||||
|
!this.lazyloading
|
||||||
|
) {
|
||||||
|
this.$store
|
||||||
|
.dispatch('TimelineSpace/Contents/DirectMessages/lazyFetchTimeline', this.timeline[this.timeline.length - 1])
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
this.$message({
|
this.$message({
|
||||||
message: this.$t('message.timeline_fetch_error'),
|
message: this.$t('message.timeline_fetch_error'),
|
||||||
|
@ -161,9 +156,9 @@ export default {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
// for unread control
|
// for unread control
|
||||||
if ((event.target.scrollTop > 10) && this.heading) {
|
if (event.target.scrollTop > 10 && this.heading) {
|
||||||
this.$store.commit('TimelineSpace/Contents/DirectMessages/changeHeading', false)
|
this.$store.commit('TimelineSpace/Contents/DirectMessages/changeHeading', false)
|
||||||
} else if ((event.target.scrollTop <= 10) && !this.heading) {
|
} else if (event.target.scrollTop <= 10 && !this.heading) {
|
||||||
this.$store.commit('TimelineSpace/Contents/DirectMessages/changeHeading', true)
|
this.$store.commit('TimelineSpace/Contents/DirectMessages/changeHeading', true)
|
||||||
this.$store.commit('TimelineSpace/Contents/DirectMessages/mergeTimeline')
|
this.$store.commit('TimelineSpace/Contents/DirectMessages/mergeTimeline')
|
||||||
}
|
}
|
||||||
|
@ -183,10 +178,7 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
upper() {
|
upper() {
|
||||||
scrollTop(
|
scrollTop(document.getElementById('scrollable'), 0)
|
||||||
document.getElementById('scrollable'),
|
|
||||||
0
|
|
||||||
)
|
|
||||||
this.focusedId = null
|
this.focusedId = null
|
||||||
},
|
},
|
||||||
focusNext() {
|
focusNext() {
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<div id="favourites" v-shortkey="shortcutEnabled ? { next: ['j'] } : {}" @shortkey="handleKey">
|
<div id="favourites" v-shortkey="shortcutEnabled ? { next: ['j'] } : {}" @shortkey="handleKey">
|
||||||
<div v-shortkey="{linux: ['ctrl', 'r'], mac: ['meta', 'r']}" @shortkey="reload()">
|
<div v-shortkey="{ linux: ['ctrl', 'r'], mac: ['meta', 'r'] }" @shortkey="reload()"></div>
|
||||||
</div>
|
|
||||||
<div class="fav" v-for="message in favourites" v-bind:key="message.id">
|
<div class="fav" v-for="message in favourites" v-bind:key="message.id">
|
||||||
<toot
|
<toot
|
||||||
:message="message"
|
:message="message"
|
||||||
|
@ -17,11 +16,9 @@
|
||||||
>
|
>
|
||||||
</toot>
|
</toot>
|
||||||
</div>
|
</div>
|
||||||
<div class="loading-card" v-loading="lazyLoading" :element-loading-background="backgroundColor">
|
<div class="loading-card" v-loading="lazyLoading" :element-loading-background="backgroundColor"></div>
|
||||||
</div>
|
|
||||||
<div :class="openSideBar ? 'upper-with-side-bar' : 'upper'" v-show="!heading">
|
<div :class="openSideBar ? 'upper-with-side-bar' : 'upper'" v-show="!heading">
|
||||||
<el-button type="primary" icon="el-icon-arrow-up" @click="upper" circle>
|
<el-button type="primary" icon="el-icon-arrow-up" @click="upper" circle> </el-button>
|
||||||
</el-button>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -53,16 +50,15 @@ export default {
|
||||||
lazyLoading: state => state.TimelineSpace.Contents.Favourites.lazyLoading,
|
lazyLoading: state => state.TimelineSpace.Contents.Favourites.lazyLoading,
|
||||||
filter: state => state.TimelineSpace.Contents.Favourites.filter
|
filter: state => state.TimelineSpace.Contents.Favourites.filter
|
||||||
}),
|
}),
|
||||||
...mapGetters('TimelineSpace/Modals', [
|
...mapGetters('TimelineSpace/Modals', ['modalOpened']),
|
||||||
'modalOpened'
|
|
||||||
]),
|
|
||||||
shortcutEnabled: function() {
|
shortcutEnabled: function() {
|
||||||
return !this.focusedId && !this.modalOpened
|
return !this.focusedId && !this.modalOpened
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.$store.commit('TimelineSpace/changeLoading', true)
|
this.$store.commit('TimelineSpace/Contents/changeLoading', true)
|
||||||
this.$store.dispatch('TimelineSpace/Contents/Favourites/fetchFavourites', this.account)
|
this.$store
|
||||||
|
.dispatch('TimelineSpace/Contents/Favourites/fetchFavourites', this.account)
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
this.$message({
|
this.$message({
|
||||||
message: this.$t('message.favourite_fetch_error'),
|
message: this.$t('message.favourite_fetch_error'),
|
||||||
|
@ -70,7 +66,7 @@ export default {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
this.$store.commit('TimelineSpace/changeLoading', false)
|
this.$store.commit('TimelineSpace/Contents/changeLoading', false)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
@ -97,8 +93,7 @@ export default {
|
||||||
watch: {
|
watch: {
|
||||||
startReload: function(newState, oldState) {
|
startReload: function(newState, oldState) {
|
||||||
if (!oldState && newState) {
|
if (!oldState && newState) {
|
||||||
this.reload()
|
this.reload().finally(() => {
|
||||||
.finally(() => {
|
|
||||||
this.$store.commit('TimelineSpace/HeaderMenu/changeReload', false)
|
this.$store.commit('TimelineSpace/HeaderMenu/changeReload', false)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -119,8 +114,12 @@ export default {
|
||||||
this.$store.commit('TimelineSpace/Contents/Favourites/deleteToot', message)
|
this.$store.commit('TimelineSpace/Contents/Favourites/deleteToot', message)
|
||||||
},
|
},
|
||||||
onScroll(event) {
|
onScroll(event) {
|
||||||
if (((event.target.clientHeight + event.target.scrollTop) >= document.getElementById('favourites').clientHeight - 10) && !this.lazyloading) {
|
if (
|
||||||
this.$store.dispatch('TimelineSpace/Contents/Favourites/lazyFetchFavourites', this.favourites[this.favourites.length - 1])
|
event.target.clientHeight + event.target.scrollTop >= document.getElementById('favourites').clientHeight - 10 &&
|
||||||
|
!this.lazyloading
|
||||||
|
) {
|
||||||
|
this.$store
|
||||||
|
.dispatch('TimelineSpace/Contents/Favourites/lazyFetchFavourites', this.favourites[this.favourites.length - 1])
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
this.$message({
|
this.$message({
|
||||||
message: this.$t('message.favourite_fetch_error'),
|
message: this.$t('message.favourite_fetch_error'),
|
||||||
|
@ -129,9 +128,9 @@ export default {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
// for upper
|
// for upper
|
||||||
if ((event.target.scrollTop > 10) && this.heading) {
|
if (event.target.scrollTop > 10 && this.heading) {
|
||||||
this.heading = false
|
this.heading = false
|
||||||
} else if ((event.target.scrollTop <= 10) && !this.heading) {
|
} else if (event.target.scrollTop <= 10 && !this.heading) {
|
||||||
this.heading = true
|
this.heading = true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -139,8 +138,7 @@ export default {
|
||||||
this.$store.commit('TimelineSpace/changeLoading', true)
|
this.$store.commit('TimelineSpace/changeLoading', true)
|
||||||
try {
|
try {
|
||||||
const account = await this.reloadable()
|
const account = await this.reloadable()
|
||||||
await this.$store.dispatch('TimelineSpace/Contents/Favourites/fetchFavourites', account)
|
await this.$store.dispatch('TimelineSpace/Contents/Favourites/fetchFavourites', account).catch(() => {
|
||||||
.catch(() => {
|
|
||||||
this.$message({
|
this.$message({
|
||||||
message: this.$t('message.favourite_fetch_error'),
|
message: this.$t('message.favourite_fetch_error'),
|
||||||
type: 'error'
|
type: 'error'
|
||||||
|
@ -151,10 +149,7 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
upper() {
|
upper() {
|
||||||
scrollTop(
|
scrollTop(document.getElementById('scrollable'), 0)
|
||||||
document.getElementById('scrollable'),
|
|
||||||
0
|
|
||||||
)
|
|
||||||
this.focusedId = null
|
this.focusedId = null
|
||||||
},
|
},
|
||||||
focusNext() {
|
focusNext() {
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
<template>
|
<template>
|
||||||
<div name="tag" v-shortkey="shortcutEnabled ? { next: ['j'] } : {}" @shortkey="handleKey">
|
<div name="tag" v-shortkey="shortcutEnabled ? { next: ['j'] } : {}" @shortkey="handleKey">
|
||||||
<div class="unread">{{ unread.length > 0 ? unread.length : '' }}</div>
|
<div class="unread">{{ unread.length > 0 ? unread.length : '' }}</div>
|
||||||
<div v-shortkey="{linux: ['ctrl', 'r'], mac: ['meta', 'r']}" @shortkey="reload()">
|
<div v-shortkey="{ linux: ['ctrl', 'r'], mac: ['meta', 'r'] }" @shortkey="reload()"></div>
|
||||||
</div>
|
|
||||||
<transition-group name="timeline" tag="div">
|
<transition-group name="timeline" tag="div">
|
||||||
<div class="tag-timeline" v-for="message in timeline" v-bind:key="message.uri + message.id">
|
<div class="tag-timeline" v-for="message in timeline" v-bind:key="message.uri + message.id">
|
||||||
<toot
|
<toot
|
||||||
|
@ -22,8 +21,7 @@
|
||||||
</transition-group>
|
</transition-group>
|
||||||
<div class="loading-card" v-loading="lazyLoading" :element-loading-background="backgroundColor"></div>
|
<div class="loading-card" v-loading="lazyLoading" :element-loading-background="backgroundColor"></div>
|
||||||
<div :class="openSideBar ? 'upper-with-side-bar' : 'upper'" v-show="!heading">
|
<div :class="openSideBar ? 'upper-with-side-bar' : 'upper'" v-show="!heading">
|
||||||
<el-button type="primary" icon="el-icon-arrow-up" @click="upper" circle>
|
<el-button type="primary" icon="el-icon-arrow-up" @click="upper" circle> </el-button>
|
||||||
</el-button>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -56,9 +54,7 @@ export default {
|
||||||
unread: state => state.TimelineSpace.Contents.Hashtag.Tag.unreadTimeline,
|
unread: state => state.TimelineSpace.Contents.Hashtag.Tag.unreadTimeline,
|
||||||
filter: state => state.TimelineSpace.Contents.Hashtag.Tag.filter
|
filter: state => state.TimelineSpace.Contents.Hashtag.Tag.filter
|
||||||
}),
|
}),
|
||||||
...mapGetters('TimelineSpace/Modals', [
|
...mapGetters('TimelineSpace/Modals', ['modalOpened']),
|
||||||
'modalOpened'
|
|
||||||
]),
|
|
||||||
shortcutEnabled: function() {
|
shortcutEnabled: function() {
|
||||||
if (this.modalOpened) {
|
if (this.modalOpened) {
|
||||||
return false
|
return false
|
||||||
|
@ -72,10 +68,9 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.$store.commit('TimelineSpace/changeLoading', true)
|
this.$store.commit('TimelineSpace/Contents/changeLoading', true)
|
||||||
this.load(this.tag)
|
this.load(this.tag).finally(() => {
|
||||||
.finally(() => {
|
this.$store.commit('TimelineSpace/Contents/changeLoading', false)
|
||||||
this.$store.commit('TimelineSpace/changeLoading', false)
|
|
||||||
})
|
})
|
||||||
document.getElementById('scrollable').addEventListener('scroll', this.onScroll)
|
document.getElementById('scrollable').addEventListener('scroll', this.onScroll)
|
||||||
|
|
||||||
|
@ -90,17 +85,15 @@ export default {
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
tag: function(newTag, _oldTag) {
|
tag: function(newTag, _oldTag) {
|
||||||
this.$store.commit('TimelineSpace/changeLoading', true)
|
this.$store.commit('TimelineSpace/Contents/changeLoading', true)
|
||||||
this.reset()
|
this.reset()
|
||||||
this.load(newTag)
|
this.load(newTag).finally(() => {
|
||||||
.finally(() => {
|
this.$store.commit('TimelineSpace/Contents/changeLoading', false)
|
||||||
this.$store.commit('TimelineSpace/changeLoading', false)
|
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
startReload: function(newState, oldState) {
|
startReload: function(newState, oldState) {
|
||||||
if (!oldState && newState) {
|
if (!oldState && newState) {
|
||||||
this.reload()
|
this.reload().finally(() => {
|
||||||
.finally(() => {
|
|
||||||
this.$store.commit('TimelineSpace/HeaderMenu/changeReload', false)
|
this.$store.commit('TimelineSpace/HeaderMenu/changeReload', false)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -121,15 +114,13 @@ export default {
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async load(tag) {
|
async load(tag) {
|
||||||
await this.$store.dispatch('TimelineSpace/Contents/Hashtag/Tag/fetch', tag)
|
await this.$store.dispatch('TimelineSpace/Contents/Hashtag/Tag/fetch', tag).catch(() => {
|
||||||
.catch(() => {
|
|
||||||
this.$message({
|
this.$message({
|
||||||
message: this.$t('message.timeline_fetch_error'),
|
message: this.$t('message.timeline_fetch_error'),
|
||||||
type: 'error'
|
type: 'error'
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
this.$store.dispatch('TimelineSpace/Contents/Hashtag/Tag/startStreaming', tag)
|
this.$store.dispatch('TimelineSpace/Contents/Hashtag/Tag/startStreaming', tag).catch(() => {
|
||||||
.catch(() => {
|
|
||||||
this.$message({
|
this.$message({
|
||||||
message: this.$t('message.start_streaming_error'),
|
message: this.$t('message.start_streaming_error'),
|
||||||
type: 'error'
|
type: 'error'
|
||||||
|
@ -154,16 +145,19 @@ export default {
|
||||||
this.$store.commit('TimelineSpace/Contents/Hashtag/Tag/deleteToot', toot)
|
this.$store.commit('TimelineSpace/Contents/Hashtag/Tag/deleteToot', toot)
|
||||||
},
|
},
|
||||||
onScroll(event) {
|
onScroll(event) {
|
||||||
if (((event.target.clientHeight + event.target.scrollTop) >= document.getElementsByName('tag')[0].clientHeight - 10) && !this.lazyloading) {
|
if (
|
||||||
|
event.target.clientHeight + event.target.scrollTop >= document.getElementsByName('tag')[0].clientHeight - 10 &&
|
||||||
|
!this.lazyloading
|
||||||
|
) {
|
||||||
this.$store.dispatch('TimelineSpace/Contents/Hashtag/Tag/lazyFetchTimeline', {
|
this.$store.dispatch('TimelineSpace/Contents/Hashtag/Tag/lazyFetchTimeline', {
|
||||||
tag: this.tag,
|
tag: this.tag,
|
||||||
status: this.timeline[this.timeline.length - 1]
|
status: this.timeline[this.timeline.length - 1]
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
// for unread control
|
// for unread control
|
||||||
if ((event.target.scrollTop > 10) && this.heading) {
|
if (event.target.scrollTop > 10 && this.heading) {
|
||||||
this.$store.commit('TimelineSpace/Contents/Hashtag/Tag/changeHeading', false)
|
this.$store.commit('TimelineSpace/Contents/Hashtag/Tag/changeHeading', false)
|
||||||
} else if ((event.target.scrollTop <= 10) && !this.heading) {
|
} else if (event.target.scrollTop <= 10 && !this.heading) {
|
||||||
this.$store.commit('TimelineSpace/Contents/Hashtag/Tag/changeHeading', true)
|
this.$store.commit('TimelineSpace/Contents/Hashtag/Tag/changeHeading', true)
|
||||||
this.$store.commit('TimelineSpace/Contents/Hashtag/Tag/mergeTimeline')
|
this.$store.commit('TimelineSpace/Contents/Hashtag/Tag/mergeTimeline')
|
||||||
}
|
}
|
||||||
|
@ -174,15 +168,13 @@ export default {
|
||||||
try {
|
try {
|
||||||
await this.reloadable()
|
await this.reloadable()
|
||||||
await this.$store.dispatch('TimelineSpace/Contents/Hashtag/Tag/stopStreaming')
|
await this.$store.dispatch('TimelineSpace/Contents/Hashtag/Tag/stopStreaming')
|
||||||
await this.$store.dispatch('TimelineSpace/Contents/Hashtag/Tag/fetch', tag)
|
await this.$store.dispatch('TimelineSpace/Contents/Hashtag/Tag/fetch', tag).catch(() => {
|
||||||
.catch(() => {
|
|
||||||
this.$message({
|
this.$message({
|
||||||
message: this.$t('message.timeline_fetch_error'),
|
message: this.$t('message.timeline_fetch_error'),
|
||||||
type: 'error'
|
type: 'error'
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
this.$store.dispatch('TimelineSpace/Contents/Hashtag/Tag/startStreaming', tag)
|
this.$store.dispatch('TimelineSpace/Contents/Hashtag/Tag/startStreaming', tag).catch(() => {
|
||||||
.catch(() => {
|
|
||||||
this.$message({
|
this.$message({
|
||||||
message: this.$t('message.start_streaming_error'),
|
message: this.$t('message.start_streaming_error'),
|
||||||
type: 'error'
|
type: 'error'
|
||||||
|
@ -193,10 +185,7 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
upper() {
|
upper() {
|
||||||
scrollTop(
|
scrollTop(document.getElementById('scrollable'), 0)
|
||||||
document.getElementById('scrollable'),
|
|
||||||
0
|
|
||||||
)
|
|
||||||
this.focusedId = null
|
this.focusedId = null
|
||||||
},
|
},
|
||||||
focusNext() {
|
focusNext() {
|
||||||
|
|
|
@ -29,7 +29,7 @@ export default {
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async init() {
|
async init() {
|
||||||
this.$store.commit('TimelineSpace/changeLoading', true)
|
this.$store.commit('TimelineSpace/Contents/changeLoading', true)
|
||||||
try {
|
try {
|
||||||
await this.$store.dispatch('TimelineSpace/Contents/Lists/Edit/fetchMembers', this.list_id)
|
await this.$store.dispatch('TimelineSpace/Contents/Lists/Edit/fetchMembers', this.list_id)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
@ -38,11 +38,11 @@ export default {
|
||||||
type: 'error'
|
type: 'error'
|
||||||
})
|
})
|
||||||
} finally {
|
} finally {
|
||||||
this.$store.commit('TimelineSpace/changeLoading', false)
|
this.$store.commit('TimelineSpace/Contents/changeLoading', false)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async removeAccount(account) {
|
async removeAccount(account) {
|
||||||
this.$store.commit('TimelineSpace/changeLoading', true)
|
this.$store.commit('TimelineSpace/Contents/changeLoading', true)
|
||||||
try {
|
try {
|
||||||
await this.$store.dispatch('TimelineSpace/Contents/Lists/Edit/removeAccount', {
|
await this.$store.dispatch('TimelineSpace/Contents/Lists/Edit/removeAccount', {
|
||||||
account: account,
|
account: account,
|
||||||
|
@ -55,7 +55,7 @@ export default {
|
||||||
type: 'error'
|
type: 'error'
|
||||||
})
|
})
|
||||||
} finally {
|
} finally {
|
||||||
this.$store.commit('TimelineSpace/changeLoading', false)
|
this.$store.commit('TimelineSpace/Contents/changeLoading', false)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
addAccount() {
|
addAccount() {
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
<template>
|
<template>
|
||||||
<div name="list" v-shortkey="shortcutEnabled ? { next: ['j'] } : {}" @shortkey="handleKey">
|
<div name="list" v-shortkey="shortcutEnabled ? { next: ['j'] } : {}" @shortkey="handleKey">
|
||||||
<div class="unread">{{ unread.length > 0 ? unread.length : '' }}</div>
|
<div class="unread">{{ unread.length > 0 ? unread.length : '' }}</div>
|
||||||
<div v-shortkey="{linux: ['ctrl', 'r'], mac: ['meta', 'r']}" @shortkey="reload()">
|
<div v-shortkey="{ linux: ['ctrl', 'r'], mac: ['meta', 'r'] }" @shortkey="reload()"></div>
|
||||||
</div>
|
|
||||||
<transition-group name="timeline" tag="div">
|
<transition-group name="timeline" tag="div">
|
||||||
<div class="list-timeline" v-for="message in timeline" v-bind:key="message.uri + message.id">
|
<div class="list-timeline" v-for="message in timeline" v-bind:key="message.uri + message.id">
|
||||||
<toot
|
<toot
|
||||||
|
@ -22,8 +21,7 @@
|
||||||
</transition-group>
|
</transition-group>
|
||||||
<div class="loading-card" v-loading="lazyLoading" :element-loading-background="backgroundColor"></div>
|
<div class="loading-card" v-loading="lazyLoading" :element-loading-background="backgroundColor"></div>
|
||||||
<div :class="openSideBar ? 'upper-with-side-bar' : 'upper'" v-show="!heading">
|
<div :class="openSideBar ? 'upper-with-side-bar' : 'upper'" v-show="!heading">
|
||||||
<el-button type="primary" icon="el-icon-arrow-up" @click="upper" circle>
|
<el-button type="primary" icon="el-icon-arrow-up" @click="upper" circle> </el-button>
|
||||||
</el-button>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -56,9 +54,7 @@ export default {
|
||||||
unread: state => state.TimelineSpace.Contents.Lists.Show.unreadTimeline,
|
unread: state => state.TimelineSpace.Contents.Lists.Show.unreadTimeline,
|
||||||
filter: state => state.TimelineSpace.Contents.Lists.Show.filter
|
filter: state => state.TimelineSpace.Contents.Lists.Show.filter
|
||||||
}),
|
}),
|
||||||
...mapGetters('TimelineSpace/Modals', [
|
...mapGetters('TimelineSpace/Modals', ['modalOpened']),
|
||||||
'modalOpened'
|
|
||||||
]),
|
|
||||||
shortcutEnabled: function() {
|
shortcutEnabled: function() {
|
||||||
if (this.modalOpened) {
|
if (this.modalOpened) {
|
||||||
return false
|
return false
|
||||||
|
@ -72,10 +68,9 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.$store.commit('TimelineSpace/changeLoading', true)
|
this.$store.commit('TimelineSpace/Contents/changeLoading', true)
|
||||||
this.load()
|
this.load().finally(() => {
|
||||||
.finally(() => {
|
this.$store.commit('TimelineSpace/Contents/changeLoading', false)
|
||||||
this.$store.commit('TimelineSpace/changeLoading', false)
|
|
||||||
})
|
})
|
||||||
document.getElementById('scrollable').addEventListener('scroll', this.onScroll)
|
document.getElementById('scrollable').addEventListener('scroll', this.onScroll)
|
||||||
},
|
},
|
||||||
|
@ -91,16 +86,14 @@ export default {
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
list_id: function() {
|
list_id: function() {
|
||||||
this.$store.commit('TimelineSpace/changeLoading', true)
|
this.$store.commit('TimelineSpace/Contents/changeLoading', true)
|
||||||
this.load()
|
this.load().finally(() => {
|
||||||
.finally(() => {
|
this.$store.commit('TimelineSpace/Contents/changeLoading', false)
|
||||||
this.$store.commit('TimelineSpace/changeLoading', false)
|
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
startReload: function(newState, oldState) {
|
startReload: function(newState, oldState) {
|
||||||
if (!oldState && newState) {
|
if (!oldState && newState) {
|
||||||
this.reload()
|
this.reload().finally(() => {
|
||||||
.finally(() => {
|
|
||||||
this.$store.commit('TimelineSpace/HeaderMenu/changeReload', false)
|
this.$store.commit('TimelineSpace/HeaderMenu/changeReload', false)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -138,8 +131,7 @@ export default {
|
||||||
type: 'error'
|
type: 'error'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
this.$store.dispatch('TimelineSpace/Contents/Lists/Show/startStreaming', this.list_id)
|
this.$store.dispatch('TimelineSpace/Contents/Lists/Show/startStreaming', this.list_id).catch(() => {
|
||||||
.catch(() => {
|
|
||||||
this.$message({
|
this.$message({
|
||||||
message: this.$t('message.start_streaming_error'),
|
message: this.$t('message.start_streaming_error'),
|
||||||
type: 'error'
|
type: 'error'
|
||||||
|
@ -154,16 +146,19 @@ export default {
|
||||||
this.$store.commit('TimelineSpace/Contents/Lists/Show/deleteToot', message)
|
this.$store.commit('TimelineSpace/Contents/Lists/Show/deleteToot', message)
|
||||||
},
|
},
|
||||||
onScroll(event) {
|
onScroll(event) {
|
||||||
if (((event.target.clientHeight + event.target.scrollTop) >= document.getElementsByName('list')[0].clientHeight - 10) && !this.lazyloading) {
|
if (
|
||||||
|
event.target.clientHeight + event.target.scrollTop >= document.getElementsByName('list')[0].clientHeight - 10 &&
|
||||||
|
!this.lazyloading
|
||||||
|
) {
|
||||||
this.$store.dispatch('TimelineSpace/Contents/Lists/Show/lazyFetchTimeline', {
|
this.$store.dispatch('TimelineSpace/Contents/Lists/Show/lazyFetchTimeline', {
|
||||||
list_id: this.list_id,
|
list_id: this.list_id,
|
||||||
status: this.timeline[this.timeline.length - 1]
|
status: this.timeline[this.timeline.length - 1]
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
// for unread control
|
// for unread control
|
||||||
if ((event.target.scrollTop > 10) && this.heading) {
|
if (event.target.scrollTop > 10 && this.heading) {
|
||||||
this.$store.commit('TimelineSpace/Contents/Lists/Show/changeHeading', false)
|
this.$store.commit('TimelineSpace/Contents/Lists/Show/changeHeading', false)
|
||||||
} else if ((event.target.scrollTop <= 10) && !this.heading) {
|
} else if (event.target.scrollTop <= 10 && !this.heading) {
|
||||||
this.$store.commit('TimelineSpace/Contents/Lists/Show/changeHeading', true)
|
this.$store.commit('TimelineSpace/Contents/Lists/Show/changeHeading', true)
|
||||||
this.$store.commit('TimelineSpace/Contents/Lists/Show/mergeTimeline')
|
this.$store.commit('TimelineSpace/Contents/Lists/Show/mergeTimeline')
|
||||||
}
|
}
|
||||||
|
@ -173,15 +168,13 @@ export default {
|
||||||
try {
|
try {
|
||||||
await this.reloadable()
|
await this.reloadable()
|
||||||
await this.$store.dispatch('TimelineSpace/Contents/Lists/Show/stopStreaming')
|
await this.$store.dispatch('TimelineSpace/Contents/Lists/Show/stopStreaming')
|
||||||
await this.$store.dispatch('TimelineSpace/Contents/Lists/Show/fetchTimeline', this.list_id)
|
await this.$store.dispatch('TimelineSpace/Contents/Lists/Show/fetchTimeline', this.list_id).catch(() => {
|
||||||
.catch(() => {
|
|
||||||
this.$message({
|
this.$message({
|
||||||
message: this.$t('message.timeline_fetch_error'),
|
message: this.$t('message.timeline_fetch_error'),
|
||||||
type: 'error'
|
type: 'error'
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
this.$store.dispatch('TimelineSpace/Contents/Lists/Show/startStreaming', this.list_id)
|
this.$store.dispatch('TimelineSpace/Contents/Lists/Show/startStreaming', this.list_id).catch(() => {
|
||||||
.catch(() => {
|
|
||||||
this.$message({
|
this.$message({
|
||||||
message: this.$t('message.start_streaming_error'),
|
message: this.$t('message.start_streaming_error'),
|
||||||
type: 'error'
|
type: 'error'
|
||||||
|
@ -192,10 +185,7 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
upper() {
|
upper() {
|
||||||
scrollTop(
|
scrollTop(document.getElementById('scrollable'), 0)
|
||||||
document.getElementById('scrollable'),
|
|
||||||
0
|
|
||||||
)
|
|
||||||
this.focusedId = null
|
this.focusedId = null
|
||||||
},
|
},
|
||||||
focusNext() {
|
focusNext() {
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
<template>
|
<template>
|
||||||
<div id="local" v-shortkey="shortcutEnabled ? { next: ['j'] } : {}" @shortkey="handleKey">
|
<div id="local" v-shortkey="shortcutEnabled ? { next: ['j'] } : {}" @shortkey="handleKey">
|
||||||
<div class="unread">{{ unread.length > 0 ? unread.length : '' }}</div>
|
<div class="unread">{{ unread.length > 0 ? unread.length : '' }}</div>
|
||||||
<div v-shortkey="{linux: ['ctrl', 'r'], mac: ['meta', 'r']}" @shortkey="reload()">
|
<div v-shortkey="{ linux: ['ctrl', 'r'], mac: ['meta', 'r'] }" @shortkey="reload()"></div>
|
||||||
</div>
|
|
||||||
<transition-group name="timeline" tag="div">
|
<transition-group name="timeline" tag="div">
|
||||||
<div class="local-timeline" v-for="message in timeline" :key="message.uri + message.id">
|
<div class="local-timeline" v-for="message in timeline" :key="message.uri + message.id">
|
||||||
<toot
|
<toot
|
||||||
|
@ -20,11 +19,9 @@
|
||||||
</toot>
|
</toot>
|
||||||
</div>
|
</div>
|
||||||
</transition-group>
|
</transition-group>
|
||||||
<div class="loading-card" v-loading="lazyLoading" :element-loading-background="backgroundColor">
|
<div class="loading-card" v-loading="lazyLoading" :element-loading-background="backgroundColor"></div>
|
||||||
</div>
|
|
||||||
<div :class="openSideBar ? 'upper-with-side-bar' : 'upper'" v-show="!heading">
|
<div :class="openSideBar ? 'upper-with-side-bar' : 'upper'" v-show="!heading">
|
||||||
<el-button type="primary" icon="el-icon-arrow-up" @click="upper" circle>
|
<el-button type="primary" icon="el-icon-arrow-up" @click="upper" circle> </el-button>
|
||||||
</el-button>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -59,9 +56,7 @@ export default {
|
||||||
startReload: state => state.TimelineSpace.HeaderMenu.reload,
|
startReload: state => state.TimelineSpace.HeaderMenu.reload,
|
||||||
unreadNotification: state => state.TimelineSpace.unreadNotification
|
unreadNotification: state => state.TimelineSpace.unreadNotification
|
||||||
}),
|
}),
|
||||||
...mapGetters('TimelineSpace/Modals', [
|
...mapGetters('TimelineSpace/Modals', ['modalOpened']),
|
||||||
'modalOpened'
|
|
||||||
]),
|
|
||||||
shortcutEnabled: function() {
|
shortcutEnabled: function() {
|
||||||
if (this.modalOpened) {
|
if (this.modalOpened) {
|
||||||
return false
|
return false
|
||||||
|
@ -75,16 +70,14 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async mounted() {
|
async mounted() {
|
||||||
this.$store.commit('TimelineSpace/changeLoading', true)
|
|
||||||
this.$store.commit('TimelineSpace/SideMenu/changeUnreadLocalTimeline', false)
|
this.$store.commit('TimelineSpace/SideMenu/changeUnreadLocalTimeline', false)
|
||||||
document.getElementById('scrollable').addEventListener('scroll', this.onScroll)
|
document.getElementById('scrollable').addEventListener('scroll', this.onScroll)
|
||||||
if (!this.unreadNotification.local) {
|
if (!this.unreadNotification.local) {
|
||||||
await this.initialize()
|
this.$store.commit('TimelineSpace/Contents/changeLoading', true)
|
||||||
.finally(_ => {
|
await this.initialize().finally(_ => {
|
||||||
this.$store.commit('TimelineSpace/changeLoading', false)
|
this.$store.commit('TimelineSpace/Contents/changeLoading', false)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
this.$store.commit('TimelineSpace/changeLoading', false)
|
|
||||||
|
|
||||||
Event.$on('focus-timeline', () => {
|
Event.$on('focus-timeline', () => {
|
||||||
// If focusedId does not change, we have to refresh focusedId because Toot component watch change events.
|
// If focusedId does not change, we have to refresh focusedId because Toot component watch change events.
|
||||||
|
@ -122,8 +115,7 @@ export default {
|
||||||
watch: {
|
watch: {
|
||||||
startReload: function(newState, oldState) {
|
startReload: function(newState, oldState) {
|
||||||
if (!oldState && newState) {
|
if (!oldState && newState) {
|
||||||
this.reload()
|
this.reload().finally(() => {
|
||||||
.finally(() => {
|
|
||||||
this.$store.commit('TimelineSpace/HeaderMenu/changeReload', false)
|
this.$store.commit('TimelineSpace/HeaderMenu/changeReload', false)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -139,8 +131,7 @@ export default {
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async initialize() {
|
async initialize() {
|
||||||
await this.$store.dispatch('TimelineSpace/Contents/Local/fetchLocalTimeline')
|
await this.$store.dispatch('TimelineSpace/Contents/Local/fetchLocalTimeline').catch(_ => {
|
||||||
.catch(_ => {
|
|
||||||
this.$message({
|
this.$message({
|
||||||
message: this.$t('message.timeline_fetch_error'),
|
message: this.$t('message.timeline_fetch_error'),
|
||||||
type: 'error'
|
type: 'error'
|
||||||
|
@ -156,9 +147,8 @@ export default {
|
||||||
this.$store.commit('TimelineSpace/Contents/Local/deleteToot', message)
|
this.$store.commit('TimelineSpace/Contents/Local/deleteToot', message)
|
||||||
},
|
},
|
||||||
onScroll(event) {
|
onScroll(event) {
|
||||||
if (((event.target.clientHeight + event.target.scrollTop) >= document.getElementById('local').clientHeight - 10) && !this.lazyloading) {
|
if (event.target.clientHeight + event.target.scrollTop >= document.getElementById('local').clientHeight - 10 && !this.lazyloading) {
|
||||||
this.$store.dispatch('TimelineSpace/Contents/Local/lazyFetchTimeline', this.timeline[this.timeline.length - 1])
|
this.$store.dispatch('TimelineSpace/Contents/Local/lazyFetchTimeline', this.timeline[this.timeline.length - 1]).catch(() => {
|
||||||
.catch(() => {
|
|
||||||
this.$message({
|
this.$message({
|
||||||
message: this.$t('message.timeline_fetch_error'),
|
message: this.$t('message.timeline_fetch_error'),
|
||||||
type: 'error'
|
type: 'error'
|
||||||
|
@ -166,9 +156,9 @@ export default {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
// for unread control
|
// for unread control
|
||||||
if ((event.target.scrollTop > 10) && this.heading) {
|
if (event.target.scrollTop > 10 && this.heading) {
|
||||||
this.$store.commit('TimelineSpace/Contents/Local/changeHeading', false)
|
this.$store.commit('TimelineSpace/Contents/Local/changeHeading', false)
|
||||||
} else if ((event.target.scrollTop <= 10) && !this.heading) {
|
} else if (event.target.scrollTop <= 10 && !this.heading) {
|
||||||
this.$store.commit('TimelineSpace/Contents/Local/changeHeading', true)
|
this.$store.commit('TimelineSpace/Contents/Local/changeHeading', true)
|
||||||
this.$store.commit('TimelineSpace/Contents/Local/mergeTimeline')
|
this.$store.commit('TimelineSpace/Contents/Local/mergeTimeline')
|
||||||
}
|
}
|
||||||
|
@ -182,10 +172,7 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
upper() {
|
upper() {
|
||||||
scrollTop(
|
scrollTop(document.getElementById('scrollable'), 0)
|
||||||
document.getElementById('scrollable'),
|
|
||||||
0
|
|
||||||
)
|
|
||||||
this.focusedId = null
|
this.focusedId = null
|
||||||
},
|
},
|
||||||
focusNext() {
|
focusNext() {
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
<template>
|
<template>
|
||||||
<div id="public" v-shortkey="shortcutEnabled ? { next: ['j'] } : {}" @shortkey="handleKey">
|
<div id="public" v-shortkey="shortcutEnabled ? { next: ['j'] } : {}" @shortkey="handleKey">
|
||||||
<div class="unread">{{ unread.length > 0 ? unread.length : '' }}</div>
|
<div class="unread">{{ unread.length > 0 ? unread.length : '' }}</div>
|
||||||
<div v-shortkey="{linux: ['ctrl', 'r'], mac: ['meta', 'r']}" @shortkey="reload()">
|
<div v-shortkey="{ linux: ['ctrl', 'r'], mac: ['meta', 'r'] }" @shortkey="reload()"></div>
|
||||||
</div>
|
|
||||||
<transition-group name="timeline" tag="div">
|
<transition-group name="timeline" tag="div">
|
||||||
<div class="public-timeline" v-for="message in timeline" :key="message.uri + message.id">
|
<div class="public-timeline" v-for="message in timeline" :key="message.uri + message.id">
|
||||||
<toot
|
<toot
|
||||||
|
@ -20,11 +19,9 @@
|
||||||
</toot>
|
</toot>
|
||||||
</div>
|
</div>
|
||||||
</transition-group>
|
</transition-group>
|
||||||
<div class="loading-card" v-loading="lazyLoading" :element-loading-background="backgroundColor">
|
<div class="loading-card" v-loading="lazyLoading" :element-loading-background="backgroundColor"></div>
|
||||||
</div>
|
|
||||||
<div :class="openSideBar ? 'upper-with-side-bar' : 'upper'" v-show="!heading">
|
<div :class="openSideBar ? 'upper-with-side-bar' : 'upper'" v-show="!heading">
|
||||||
<el-button type="primary" icon="el-icon-arrow-up" @click="upper" circle>
|
<el-button type="primary" icon="el-icon-arrow-up" @click="upper" circle> </el-button>
|
||||||
</el-button>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -59,9 +56,7 @@ export default {
|
||||||
startReload: state => state.TimelineSpace.HeaderMenu.reload,
|
startReload: state => state.TimelineSpace.HeaderMenu.reload,
|
||||||
unreadNotification: state => state.TimelineSpace.unreadNotification
|
unreadNotification: state => state.TimelineSpace.unreadNotification
|
||||||
}),
|
}),
|
||||||
...mapGetters('TimelineSpace/Modals', [
|
...mapGetters('TimelineSpace/Modals', ['modalOpened']),
|
||||||
'modalOpened'
|
|
||||||
]),
|
|
||||||
shortcutEnabled: function() {
|
shortcutEnabled: function() {
|
||||||
if (this.modalOpened) {
|
if (this.modalOpened) {
|
||||||
return false
|
return false
|
||||||
|
@ -75,16 +70,14 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async mounted() {
|
async mounted() {
|
||||||
this.$store.commit('TimelineSpace/changeLoading', true)
|
|
||||||
this.$store.commit('TimelineSpace/SideMenu/changeUnreadPublicTimeline', false)
|
this.$store.commit('TimelineSpace/SideMenu/changeUnreadPublicTimeline', false)
|
||||||
document.getElementById('scrollable').addEventListener('scroll', this.onScroll)
|
document.getElementById('scrollable').addEventListener('scroll', this.onScroll)
|
||||||
if (!this.unreadNotification.public) {
|
if (!this.unreadNotification.public) {
|
||||||
await this.initialize()
|
this.$store.commit('TimelineSpace/Contents/changeLoading', true)
|
||||||
.finally(_ => {
|
await this.initialize().finally(_ => {
|
||||||
this.$store.commit('TimelineSpace/changeLoading', false)
|
this.$store.commit('TimelineSpace/Contents/changeLoading', false)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
this.$store.commit('TimelineSpace/changeLoading', false)
|
|
||||||
|
|
||||||
Event.$on('focus-timeline', () => {
|
Event.$on('focus-timeline', () => {
|
||||||
// If focusedId does not change, we have to refresh focusedId because Toot component watch change events.
|
// If focusedId does not change, we have to refresh focusedId because Toot component watch change events.
|
||||||
|
@ -122,8 +115,7 @@ export default {
|
||||||
watch: {
|
watch: {
|
||||||
startReload: function(newState, oldState) {
|
startReload: function(newState, oldState) {
|
||||||
if (!oldState && newState) {
|
if (!oldState && newState) {
|
||||||
this.reload()
|
this.reload().finally(() => {
|
||||||
.finally(() => {
|
|
||||||
this.$store.commit('TimelineSpace/HeaderMenu/changeReload', false)
|
this.$store.commit('TimelineSpace/HeaderMenu/changeReload', false)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -139,8 +131,7 @@ export default {
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async initialize() {
|
async initialize() {
|
||||||
await this.$store.dispatch('TimelineSpace/Contents/Public/fetchPublicTimeline')
|
await this.$store.dispatch('TimelineSpace/Contents/Public/fetchPublicTimeline').catch(_ => {
|
||||||
.catch(_ => {
|
|
||||||
this.$message({
|
this.$message({
|
||||||
message: this.$t('message.timeline_fetch_error'),
|
message: this.$t('message.timeline_fetch_error'),
|
||||||
type: 'error'
|
type: 'error'
|
||||||
|
@ -156,9 +147,8 @@ export default {
|
||||||
this.$store.commit('TimelineSpace/Contents/Public/deleteToot', message)
|
this.$store.commit('TimelineSpace/Contents/Public/deleteToot', message)
|
||||||
},
|
},
|
||||||
onScroll(event) {
|
onScroll(event) {
|
||||||
if (((event.target.clientHeight + event.target.scrollTop) >= document.getElementById('public').clientHeight - 10) && !this.lazyloading) {
|
if (event.target.clientHeight + event.target.scrollTop >= document.getElementById('public').clientHeight - 10 && !this.lazyloading) {
|
||||||
this.$store.dispatch('TimelineSpace/Contents/Public/lazyFetchTimeline', this.timeline[this.timeline.length - 1])
|
this.$store.dispatch('TimelineSpace/Contents/Public/lazyFetchTimeline', this.timeline[this.timeline.length - 1]).catch(() => {
|
||||||
.catch(() => {
|
|
||||||
this.$message({
|
this.$message({
|
||||||
message: this.$t('message.timeline_fetch_error'),
|
message: this.$t('message.timeline_fetch_error'),
|
||||||
type: 'error'
|
type: 'error'
|
||||||
|
@ -166,9 +156,9 @@ export default {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
// for unread control
|
// for unread control
|
||||||
if ((event.target.scrollTop > 10) && this.heading) {
|
if (event.target.scrollTop > 10 && this.heading) {
|
||||||
this.$store.commit('TimelineSpace/Contents/Public/changeHeading', false)
|
this.$store.commit('TimelineSpace/Contents/Public/changeHeading', false)
|
||||||
} else if ((event.target.scrollTop <= 10) && !this.heading) {
|
} else if (event.target.scrollTop <= 10 && !this.heading) {
|
||||||
this.$store.commit('TimelineSpace/Contents/Public/changeHeading', true)
|
this.$store.commit('TimelineSpace/Contents/Public/changeHeading', true)
|
||||||
this.$store.commit('TimelineSpace/Contents/Public/mergeTimeline')
|
this.$store.commit('TimelineSpace/Contents/Public/mergeTimeline')
|
||||||
}
|
}
|
||||||
|
@ -182,10 +172,7 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
upper() {
|
upper() {
|
||||||
scrollTop(
|
scrollTop(document.getElementById('scrollable'), 0)
|
||||||
document.getElementById('scrollable'),
|
|
||||||
0
|
|
||||||
)
|
|
||||||
this.focusedId = null
|
this.focusedId = null
|
||||||
},
|
},
|
||||||
focusNext() {
|
focusNext() {
|
||||||
|
|
|
@ -1,16 +1,18 @@
|
||||||
<template>
|
<template>
|
||||||
<div id="search">
|
<div id="search">
|
||||||
<div class="search-header" v-loading="loading" :element-loading-background="loadingBackground">
|
<div class="search-header">
|
||||||
<el-form :inline="true">
|
<el-form :inline="true">
|
||||||
<el-select v-model="target" :placeholder="$t('search.search')" class="search-target">
|
<el-select v-model="target" :placeholder="$t('search.search')" class="search-target">
|
||||||
<el-option
|
<el-option v-for="item in searchTargets" :key="item.target" :label="item.label" :value="item.target"> </el-option>
|
||||||
v-for="item in searchTargets"
|
|
||||||
:key="item.target"
|
|
||||||
:label="item.label"
|
|
||||||
:value="item.target">
|
|
||||||
</el-option>
|
|
||||||
</el-select>
|
</el-select>
|
||||||
<input v-model="query" :placeholder="$t('search.keyword')" class="search-keyword" v-shortkey.avoid v-on:keyup.enter="search" autofocus></input>
|
<input
|
||||||
|
v-model="query"
|
||||||
|
:placeholder="$t('search.keyword')"
|
||||||
|
class="search-keyword"
|
||||||
|
v-shortkey.avoid
|
||||||
|
v-on:keyup.enter="search"
|
||||||
|
autofocus
|
||||||
|
/>
|
||||||
<div class="clearfix"></div>
|
<div class="clearfix"></div>
|
||||||
</el-form>
|
</el-form>
|
||||||
</div>
|
</div>
|
||||||
|
@ -23,7 +25,6 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { mapState } from 'vuex'
|
|
||||||
import SearchAccount from './Search/Account'
|
import SearchAccount from './Search/Account'
|
||||||
import SearchTag from './Search/Tag'
|
import SearchTag from './Search/Tag'
|
||||||
import SearchToots from './Search/Toots'
|
import SearchToots from './Search/Toots'
|
||||||
|
@ -38,10 +39,6 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState({
|
|
||||||
loading: state => state.TimelineSpace.Contents.Search.loading,
|
|
||||||
loadingBackground: state => state.App.theme.wrapper_mask_color
|
|
||||||
}),
|
|
||||||
searchTargets: {
|
searchTargets: {
|
||||||
get() {
|
get() {
|
||||||
return [
|
return [
|
||||||
|
@ -65,8 +62,7 @@ export default {
|
||||||
search() {
|
search() {
|
||||||
switch (this.target) {
|
switch (this.target) {
|
||||||
case 'account':
|
case 'account':
|
||||||
this.$store.dispatch('TimelineSpace/Contents/Search/Account/search', this.query)
|
this.$store.dispatch('TimelineSpace/Contents/Search/Account/search', this.query).catch(() => {
|
||||||
.catch(() => {
|
|
||||||
this.$message({
|
this.$message({
|
||||||
message: this.$t('message.search_error'),
|
message: this.$t('message.search_error'),
|
||||||
type: 'error'
|
type: 'error'
|
||||||
|
@ -74,8 +70,7 @@ export default {
|
||||||
})
|
})
|
||||||
break
|
break
|
||||||
case 'tag':
|
case 'tag':
|
||||||
this.$store.dispatch('TimelineSpace/Contents/Search/Tag/search', `#${this.query}`)
|
this.$store.dispatch('TimelineSpace/Contents/Search/Tag/search', `#${this.query}`).catch(() => {
|
||||||
.catch(() => {
|
|
||||||
this.$message({
|
this.$message({
|
||||||
message: this.$t('message.search_error'),
|
message: this.$t('message.search_error'),
|
||||||
type: 'error'
|
type: 'error'
|
||||||
|
@ -83,8 +78,7 @@ export default {
|
||||||
})
|
})
|
||||||
break
|
break
|
||||||
case 'toot':
|
case 'toot':
|
||||||
this.$store.dispatch('TimelineSpace/Contents/Search/Toots/search', this.query)
|
this.$store.dispatch('TimelineSpace/Contents/Search/Toots/search', this.query).catch(() => {
|
||||||
.catch(() => {
|
|
||||||
this.$message({
|
this.$message({
|
||||||
message: this.$t('message.search_error'),
|
message: this.$t('message.search_error'),
|
||||||
type: 'error'
|
type: 'error'
|
||||||
|
|
|
@ -112,6 +112,7 @@ const actions: ActionTree<TimelineSpaceState, RootState> = {
|
||||||
throw new AccountLoadError()
|
throw new AccountLoadError()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
await dispatch('detectPleroma')
|
||||||
dispatch('TimelineSpace/SideMenu/fetchLists', account, { root: true })
|
dispatch('TimelineSpace/SideMenu/fetchLists', account, { root: true })
|
||||||
dispatch('TimelineSpace/SideMenu/fetchFollowRequests', account, { root: true })
|
dispatch('TimelineSpace/SideMenu/fetchFollowRequests', account, { root: true })
|
||||||
await dispatch('loadUnreadNotification', accountId)
|
await dispatch('loadUnreadNotification', accountId)
|
||||||
|
@ -119,7 +120,6 @@ const actions: ActionTree<TimelineSpaceState, RootState> = {
|
||||||
await dispatch('fetchContentsTimelines', account).catch(_ => {
|
await dispatch('fetchContentsTimelines', account).catch(_ => {
|
||||||
throw new TimelineFetchError()
|
throw new TimelineFetchError()
|
||||||
})
|
})
|
||||||
await dispatch('detectPleroma')
|
|
||||||
await dispatch('bindStreamings', account)
|
await dispatch('bindStreamings', account)
|
||||||
dispatch('startStreamings', account)
|
dispatch('startStreamings', account)
|
||||||
dispatch('fetchEmojis', account)
|
dispatch('fetchEmojis', account)
|
||||||
|
|
|
@ -1,38 +1,23 @@
|
||||||
import Account, { AccountState } from './Search/Account'
|
import Account, { AccountState } from './Search/Account'
|
||||||
import Tag, { TagState } from './Search/Tag'
|
import Tag, { TagState } from './Search/Tag'
|
||||||
import Toots, { TootsState } from './Search/Toots'
|
import Toots, { TootsState } from './Search/Toots'
|
||||||
import { Module, MutationTree } from 'vuex'
|
import { Module } from 'vuex'
|
||||||
import { RootState } from '@/store'
|
import { RootState } from '@/store'
|
||||||
|
|
||||||
export interface SearchState {
|
export interface SearchState {}
|
||||||
loading: boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface SearchModuleState extends SearchState {
|
export interface SearchModuleState extends SearchState {
|
||||||
Account: AccountState,
|
Account: AccountState
|
||||||
Tag: TagState,
|
Tag: TagState
|
||||||
Toots: TootsState
|
Toots: TootsState
|
||||||
}
|
}
|
||||||
|
|
||||||
const state = (): SearchState => ({
|
const state = (): SearchState => ({})
|
||||||
loading: false
|
|
||||||
})
|
|
||||||
|
|
||||||
export const MUTATION_TYPES = {
|
|
||||||
CHANGE_LOADING: 'changeLoading'
|
|
||||||
}
|
|
||||||
|
|
||||||
const mutations: MutationTree<SearchState> = {
|
|
||||||
[MUTATION_TYPES.CHANGE_LOADING]: (state, loading: boolean) => {
|
|
||||||
state.loading = loading
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const Search: Module<SearchState, RootState> = {
|
const Search: Module<SearchState, RootState> = {
|
||||||
namespaced: true,
|
namespaced: true,
|
||||||
modules: { Account, Tag, Toots },
|
modules: { Account, Tag, Toots },
|
||||||
state: state,
|
state: state
|
||||||
mutations: mutations
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Search
|
export default Search
|
||||||
|
|
|
@ -22,7 +22,7 @@ const mutations: MutationTree<AccountState> = {
|
||||||
|
|
||||||
const actions: ActionTree<AccountState, RootState> = {
|
const actions: ActionTree<AccountState, RootState> = {
|
||||||
search: async ({ commit, rootState }, query: string): Promise<Array<Account>> => {
|
search: async ({ commit, rootState }, query: string): Promise<Array<Account>> => {
|
||||||
commit('TimelineSpace/Contents/Search/changeLoading', true, { root: true })
|
commit('TimelineSpace/Contents/changeLoading', true, { root: true })
|
||||||
const client = new Mastodon(rootState.TimelineSpace.account.accessToken!, rootState.TimelineSpace.account.baseURL + '/api/v1')
|
const client = new Mastodon(rootState.TimelineSpace.account.accessToken!, rootState.TimelineSpace.account.baseURL + '/api/v1')
|
||||||
return client
|
return client
|
||||||
.get<Array<Account>>('/accounts/search', { q: query, resolve: true })
|
.get<Array<Account>>('/accounts/search', { q: query, resolve: true })
|
||||||
|
@ -31,7 +31,7 @@ const actions: ActionTree<AccountState, RootState> = {
|
||||||
return res.data
|
return res.data
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
commit('TimelineSpace/Contents/Search/changeLoading', false, { root: true })
|
commit('TimelineSpace/Contents/changeLoading', false, { root: true })
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,18 +22,16 @@ const mutations: MutationTree<TagState> = {
|
||||||
|
|
||||||
const actions: ActionTree<TagState, RootState> = {
|
const actions: ActionTree<TagState, RootState> = {
|
||||||
search: ({ commit, rootState }, query: string): Promise<Array<Tag>> => {
|
search: ({ commit, rootState }, query: string): Promise<Array<Tag>> => {
|
||||||
commit('TimelineSpace/Contents/Search/changeLoading', true, { root: true })
|
commit('TimelineSpace/Contents/changeLoading', true, { root: true })
|
||||||
const client = new Mastodon(
|
const client = new Mastodon(rootState.TimelineSpace.account.accessToken!, rootState.TimelineSpace.account.baseURL + '/api/v2')
|
||||||
rootState.TimelineSpace.account.accessToken!,
|
return client
|
||||||
rootState.TimelineSpace.account.baseURL + '/api/v2'
|
.get<Results>('/search', { q: query, resolve: true })
|
||||||
)
|
|
||||||
return client.get<Results>('/search', { q: query, resolve: true })
|
|
||||||
.then(res => {
|
.then(res => {
|
||||||
commit(MUTATION_TYPES.UPDATE_RESULTS, res.data.hashtags)
|
commit(MUTATION_TYPES.UPDATE_RESULTS, res.data.hashtags)
|
||||||
return res.data.hashtags
|
return res.data.hashtags
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
commit('TimelineSpace/Contents/Search/changeLoading', false, { root: true })
|
commit('TimelineSpace/Contents/changeLoading', false, { root: true })
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,18 +22,16 @@ const mutations: MutationTree<TootsState> = {
|
||||||
|
|
||||||
const actions: ActionTree<TootsState, RootState> = {
|
const actions: ActionTree<TootsState, RootState> = {
|
||||||
search: ({ commit, rootState }, query: string): Promise<Array<Status>> => {
|
search: ({ commit, rootState }, query: string): Promise<Array<Status>> => {
|
||||||
commit('TimelineSpace/Contents/Search/changeLoading', true, { root: true })
|
commit('TimelineSpace/Contents/changeLoading', true, { root: true })
|
||||||
const client = new Mastodon(
|
const client = new Mastodon(rootState.TimelineSpace.account.accessToken!, rootState.TimelineSpace.account.baseURL + '/api/v1')
|
||||||
rootState.TimelineSpace.account.accessToken!,
|
return client
|
||||||
rootState.TimelineSpace.account.baseURL + '/api/v1'
|
.get<Results>('/search', { q: query, resolve: true })
|
||||||
)
|
|
||||||
return client.get<Results>('/search', { q: query, resolve: true })
|
|
||||||
.then(res => {
|
.then(res => {
|
||||||
commit(MUTATION_TYPES.UPDATE_RESULTS, res.data.statuses)
|
commit(MUTATION_TYPES.UPDATE_RESULTS, res.data.statuses)
|
||||||
return res.data.statuses
|
return res.data.statuses
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
commit('TimelineSpace/Contents/Search/changeLoading', false, { root: true })
|
commit('TimelineSpace/Contents/changeLoading', false, { root: true })
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue