Merge pull request #381 from akito19/allow-reload-page

Allow reload pages with shortcut keys
This commit is contained in:
AkiraFukushima 2018-06-27 00:28:37 +09:00 committed by GitHub
commit a679074d28
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 271 additions and 0 deletions

View File

@ -1,5 +1,7 @@
<template>
<div id="favourites">
<div v-shortkey="{linux: ['ctrl', 'r'], mac: ['meta', 'r']}" @shortkey="reload()">
</div>
<div class="fav" v-for="message in favourites" v-bind:key="message.id">
<toot :message="message" v-on:update="updateToot" v-on:delete="deleteToot"></toot>
</div>
@ -69,6 +71,38 @@ export default {
})
})
}
},
async reload () {
const loading = this.$loading({
lock: true,
text: 'Loading',
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.7)'
})
const account = await this.$store.dispatch('TimelineSpace/localAccount', this.$route.params.id).catch(() => {
this.$message({
message: 'Could not find account',
type: 'error'
})
})
await this.$store.dispatch('TimelineSpace/stopUserStreaming')
await this.$store.dispatch('TimelineSpace/stopLocalStreaming')
await this.$store.dispatch('TimelineSpace/Contents/Home/fetchTimeline', account)
await this.$store.dispatch('TimelineSpace/Contents/Local/fetchLocalTimeline', account)
await this.$store.dispatch('TimelineSpace/Contents/Favourites/fetchFavourites', account)
.catch(() => {
loading.close()
this.$message({
message: 'Could not fetch favourites',
type: 'error'
})
})
this.$store.dispatch('TimelineSpace/startUserStreaming', account)
this.$store.dispatch('TimelineSpace/startLocalStreaming', account)
loading.close()
}
}
}

View File

@ -1,6 +1,8 @@
<template>
<div name="tag">
<div class="unread">{{ unread.length > 0 ? unread.length : '' }}</div>
<div v-shortkey="{linux: ['ctrl', 'r'], mac: ['meta', 'r']}" @shortkey="reload()">
</div>
<transition-group name="timeline" tag="div">
<div class="tag-timeline" v-for="message in timeline" v-bind:key="message.id">
<toot :message="message" v-on:update="updateToot" v-on:delete="deleteToot"></toot>
@ -115,6 +117,47 @@ export default {
this.$store.commit('TimelineSpace/Contents/Hashtag/Tag/changeHeading', true)
this.$store.commit('TimelineSpace/Contents/Hashtag/Tag/mergeTimeline')
}
},
async reload () {
const tag = this.$route.params.tag
const loading = this.$loading({
lock: true,
text: 'Loading',
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.7)'
})
const account = await this.$store.dispatch('TimelineSpace/localAccount', this.$route.params.id).catch(() => {
this.$message({
message: 'Could not find account',
type: 'error'
})
})
await this.$store.dispatch('TimelineSpace/stopUserStreaming')
await this.$store.dispatch('TimelineSpace/stopLocalStreaming')
await this.$store.dispatch('TimelineSpace/Contents/Hashtag/Tag/stopStreaming')
await this.$store.dispatch('TimelineSpace/Contents/Home/fetchTimeline', account)
await this.$store.dispatch('TimelineSpace/Contents/Local/fetchLocalTimeline', account)
await this.$store.dispatch('TimelineSpace/Contents/Hashtag/Tag/fetch', tag)
.catch(() => {
this.$message({
message: 'Could not fetch timeline with tag',
type: 'error'
})
})
this.$store.dispatch('TimelineSpace/startUserStreaming', account)
this.$store.dispatch('TimelineSpace/startLocalStreaming', account)
this.$store.dispatch('TimelineSpace/Contents/Hashtag/Tag/startStreaming', tag)
.catch(() => {
loading.close()
this.$message({
message: 'Failed to restart streaming',
type: 'error'
})
})
loading.close()
}
}
}

View File

@ -1,6 +1,8 @@
<template>
<div id="home">
<div class="unread">{{ unread.length > 0 ? unread.length : '' }}</div>
<div v-shortkey="{linux: ['ctrl', 'r'], mac: ['meta', 'r']}" @shortkey="reload()">
</div>
<transition-group name="timeline" tag="div">
<div class="home-timeline" v-for="(message, index) in timeline" v-bind:key="index">
<toot :message="message" :key="message.id" v-on:update="updateToot" v-on:delete="deleteToot"></toot>
@ -70,6 +72,43 @@ export default {
},
deleteToot (message) {
this.$store.commit('TimelineSpace/Contents/Home/deleteToot', message)
},
async reload () {
const loading = this.$loading({
lock: true,
text: 'Loading',
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.7)'
})
const account = await this.$store.dispatch('TimelineSpace/localAccount', this.$route.params.id).catch(() => {
this.$message({
message: 'Could not find account',
type: 'error'
})
})
await this.$store.dispatch('TimelineSpace/stopUserStreaming')
await this.$store.dispatch('TimelineSpace/stopLocalStreaming')
await this.$store.dispatch('TimelineSpace/Contents/Home/fetchTimeline', account)
.catch(() => {
loading.close()
this.$message({
message: 'Could not fetch timeline',
type: 'error'
})
})
await this.$store.dispatch('TimelineSpace/Contents/Local/fetchLocalTimeline', account)
this.$store.dispatch('TimelineSpace/startUserStreaming', account)
.catch(() => {
loading.close()
this.$message({
message: 'Failed to restart streaming',
type: 'error'
})
})
this.$store.dispatch('TimelineSpace/startLocalStreaming', account)
loading.close()
}
}
}

View File

@ -1,6 +1,8 @@
<template>
<div name="list">
<div class="unread">{{ unread.length > 0 ? unread.length : '' }}</div>
<div v-shortkey="{linux: ['ctrl', 'r'], mac: ['meta', 'r']}" @shortkey="reload()">
</div>
<transition-group name="timeline" tag="div">
<div class="list-timeline" v-for="message in timeline" v-bind:key="message.id">
<toot :message="message" v-on:update="updateToot" v-on:delete="deleteToot"></toot>
@ -107,6 +109,45 @@ export default {
this.$store.commit('TimelineSpace/Contents/Lists/Show/changeHeading', true)
this.$store.commit('TimelineSpace/Contents/Lists/Show/mergeTimeline')
}
},
async reload () {
const loading = this.$loading({
lock: true,
text: 'Loading',
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.7)'
})
const account = await this.$store.dispatch('TimelineSpace/localAccount', this.$route.params.id).catch(() => {
this.$message({
message: 'Could not find account',
type: 'error'
})
})
await this.$store.dispatch('TimelineSpace/stopUserStreaming')
await this.$store.dispatch('TimelineSpace/stopLocalStreaming')
await this.$store.dispatch('TimelineSpace/Contents/Lists/Show/stopStreaming')
await this.$store.dispatch('TimelineSpace/Contents/Home/fetchTimeline', account)
await this.$store.dispatch('TimelineSpace/Contents/Local/fetchLocalTimeline', account)
await this.$store.dispatch('TimelineSpace/Contents/Lists/Show/fetchTimeline', this.list_id)
.catch(() => {
this.$message({
message: 'Could not fetch timeline',
type: 'error'
})
})
this.$store.dispatch('TimelineSpace/startUserStreaming', account)
this.$store.dispatch('TimelineSpace/startLocalStreaming', account)
this.$store.dispatch('TimelineSpace/Contents/Lists/Show/startStreaming', this.list_id)
.catch(() => {
this.$message({
message: 'Failed to restart streaming',
type: 'error'
})
})
loading.close()
}
}
}

View File

@ -1,6 +1,8 @@
<template>
<div id="local">
<div class="unread">{{ unread.length > 0 ? unread.length : '' }}</div>
<div v-shortkey="{linux: ['ctrl', 'r'], mac: ['meta', 'r']}" @shortkey="reload()">
</div>
<transition-group name="timeline" tag="div">
<div class="local-timeline" v-for="message in timeline" v-bind:key="message.id">
<toot :message="message" v-on:update="updateToot" v-on:delete="deleteToot"></toot>
@ -69,6 +71,43 @@ export default {
this.$store.commit('TimelineSpace/Contents/Local/changeHeading', true)
this.$store.commit('TimelineSpace/Contents/Local/mergeTimeline')
}
},
async reload () {
const loading = this.$loading({
lock: true,
text: 'Loading',
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.7)'
})
const account = await this.$store.dispatch('TimelineSpace/localAccount', this.$route.params.id).catch(() => {
this.$message({
message: 'Could not find account',
type: 'error'
})
})
await this.$store.dispatch('TimelineSpace/stopUserStreaming')
await this.$store.dispatch('TimelineSpace/stopLocalStreaming')
await this.$store.dispatch('TimelineSpace/Contents/Home/fetchTimeline', account)
await this.$store.dispatch('TimelineSpace/Contents/Local/fetchLocalTimeline', account)
.catch(() => {
loading.close()
this.$message({
message: 'Could not fetch local timeline',
type: 'error'
})
})
this.$store.dispatch('TimelineSpace/startUserStreaming', account)
this.$store.dispatch('TimelineSpace/startLocalStreaming', account)
.catch(() => {
loading.close()
this.$message({
message: 'Failed to restart streaming',
type: 'error'
})
})
loading.close()
}
}
}

View File

@ -1,6 +1,8 @@
<template>
<div id="notifications">
<div class="unread">{{ unread.length > 0 ? unread.length : '' }}</div>
<div v-shortkey="{linux: ['ctrl', 'r'], mac: ['meta', 'r']}" @shortkey="reload()">
</div>
<transition-group name="timeline" tag="div">
<div class="notifications" v-for="message in notifications" v-bind:key="message.id">
<notification :message="message"></notification>
@ -64,6 +66,37 @@ export default {
this.$store.commit('TimelineSpace/Contents/Notifications/changeHeading', true)
this.$store.commit('TimelineSpace/Contents/Notifications/mergeNotifications')
}
},
async reload () {
const loading = this.$loading({
lock: true,
text: 'Loading',
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.7)'
})
const account = await this.$store.dispatch('TimelineSpace/localAccount', this.$route.params.id).catch(() => {
this.$message({
message: 'Could not find account',
type: 'error'
})
})
await this.$store.dispatch('TimelineSpace/stopUserStreaming')
await this.$store.dispatch('TimelineSpace/stopLocalStreaming')
await this.$store.dispatch('TimelineSpace/Contents/Home/fetchTimeline', account)
await this.$store.dispatch('TimelineSpace/Contents/Local/fetchLocalTimeline', account)
await this.$store.dispatch('TimelineSpace/Contents/Notifications/fetchNotifications', account)
.catch(() => {
loading.close()
this.$message({
message: 'Could not fetch notifications',
type: 'error'
})
})
this.$store.dispatch('TimelineSpace/startUserStreaming', account)
this.$store.dispatch('TimelineSpace/startLocalStreaming', account)
loading.close()
}
}
}

View File

@ -1,6 +1,8 @@
<template>
<div id="public">
<div class="unread">{{ unread.length > 0 ? unread.length : '' }}</div>
<div v-shortkey="{linux: ['ctrl', 'r'], mac: ['meta', 'r']}" @shortkey="reload()">
</div>
<transition-group name="timeline" tag="div">
<div class="public-timeline" v-for="message in timeline" v-bind:key="message.id">
<toot :message="message" v-on:update="updateToot" v-on:delete="deleteToot"></toot>
@ -97,6 +99,46 @@ export default {
this.$store.commit('TimelineSpace/Contents/Public/changeHeading', true)
this.$store.commit('TimelineSpace/Contents/Public/mergeTimeline')
}
},
async reload () {
const loading = this.$loading({
lock: true,
text: 'Loading',
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.7)'
})
const account = await this.$store.dispatch('TimelineSpace/localAccount', this.$route.params.id).catch(() => {
this.$message({
message: 'Could not find account',
type: 'error'
})
})
await this.$store.dispatch('TimelineSpace/stopUserStreaming')
await this.$store.dispatch('TimelineSpace/stopLocalStreaming')
await this.$store.dispatch('TimelineSpace/Contents/Public/stopPublicStreaming')
await this.$store.dispatch('TimelineSpace/Contents/Home/fetchTimeline', account)
await this.$store.dispatch('TimelineSpace/Contents/Local/fetchLocalTimeline', account)
await this.$store.dispatch('TimelineSpace/Contents/Public/fetchPublicTimeline')
.catch(() => {
loading.close()
this.$message({
message: 'Could not fetch public timeline',
type: 'error'
})
})
this.$store.dispatch('TimelineSpace/startUserStreaming', account)
this.$store.dispatch('TimelineSpace/startLocalStreaming', account)
this.$store.dispatch('TimelineSpace/Contents/Public/startPublicStreaming')
.catch(() => {
loading.close()
this.$message({
message: 'Failed to restart streaming',
type: 'error'
})
})
loading.close()
}
}
}