Whalebird-desktop-client-ma.../src/renderer/components/TimelineSpace.vue

128 lines
3.6 KiB
Vue
Raw Normal View History

<template>
<div id="timeline_space">
<side-menu></side-menu>
2018-03-22 10:09:58 +01:00
<div class="page">
<header class="header" style="-webkit-app-region: drag;">
2018-03-22 10:09:58 +01:00
<header-menu></header-menu>
</header>
<contents></contents>
</div>
<modals></modals>
</div>
</template>
<script>
import SideMenu from './TimelineSpace/SideMenu'
2018-03-22 10:09:58 +01:00
import HeaderMenu from './TimelineSpace/HeaderMenu'
import Contents from './TimelineSpace/Contents'
import Modals from './TimelineSpace/Modals'
import Mousetrap from 'mousetrap'
export default {
name: 'timeline-space',
components: { SideMenu, HeaderMenu, Modals, Contents },
created () {
const loading = this.$loading({
lock: true,
text: 'Loading',
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.7)'
})
this.initialize()
.then(() => {
loading.close()
this.$store.commit('GlobalHeader/updateChanging', false)
})
.catch(() => {
loading.close()
this.$store.commit('GlobalHeader/updateChanging', false)
})
},
mounted () {
Mousetrap.bind(['command+t', 'ctrl+t'], () => {
this.$store.commit('TimelineSpace/Modals/Jump/changeModal', true)
})
},
beforeDestroy () {
this.$store.dispatch('TimelineSpace/stopUserStreaming')
this.$store.dispatch('TimelineSpace/stopLocalStreaming')
},
methods: {
async clear () {
await this.$store.dispatch('TimelineSpace/clearAccount')
await this.$store.commit('TimelineSpace/Contents/Home/clearTimeline')
await this.$store.commit('TimelineSpace/Contents/Local/clearTimeline')
await this.$store.commit('TimelineSpace/Contents/Notifications/clearNotifications')
await this.$store.dispatch('TimelineSpace/removeShortcutEvents')
await this.$store.dispatch('TimelineSpace/clearUnread')
return 'clear'
},
async initialize () {
await this.clear()
this.$store.dispatch('TimelineSpace/watchShortcutEvents')
2018-04-08 15:09:28 +02:00
const account = await this.$store.dispatch('TimelineSpace/localAccount', this.$route.params.id).catch(() => {
this.$message({
message: 'Could not find account',
type: 'error'
})
})
try {
await this.$store.dispatch('TimelineSpace/Contents/Home/fetchTimeline', account)
} catch (err) {
this.$message({
2018-04-08 15:09:28 +02:00
message: 'Could not fetch timeline',
type: 'error'
})
}
2018-04-08 15:09:28 +02:00
try {
await this.$store.dispatch('TimelineSpace/Contents/Notifications/fetchNotifications', account)
2018-04-08 15:09:28 +02:00
} catch (err) {
this.$message({
message: 'Could not fetch notification',
type: 'error'
})
}
try {
await this.$store.dispatch('TimelineSpace/Contents/Local/fetchLocalTimeline', account)
} catch (err) {
this.$message({
message: 'Could not fetch local timeline',
type: 'error'
})
}
2018-04-08 15:09:28 +02:00
this.$store.dispatch('TimelineSpace/SideMenu/fetchLists', account)
this.$store.dispatch('TimelineSpace/startUserStreaming', account)
.catch(() => {
this.$message({
message: 'Failed to start streaming',
type: 'error'
})
})
this.$store.dispatch('TimelineSpace/startLocalStreaming', account)
}
}
}
</script>
<style lang="scss" scoped>
2018-03-29 15:41:28 +02:00
#timeline_space {
height: 100%;
}
2018-03-22 10:09:58 +01:00
.page {
2018-03-09 09:36:57 +01:00
margin-left: 180px;
2018-03-29 15:41:28 +02:00
height: 100%;
box-sizing: border-box;
2018-03-22 10:09:58 +01:00
.header {
width: calc(100% - 245px);
2018-03-22 10:09:58 +01:00
position: fixed;
top: 0;
left: 245px;
height: 48px;
border-bottom: solid 1px var(--theme-border-color);
2018-03-22 10:09:58 +01:00
}
}
2018-03-12 17:42:47 +01:00
</style>