2018-03-08 10:36:09 +01:00
|
|
|
<template>
|
2018-07-02 14:53:09 +02:00
|
|
|
<div
|
|
|
|
id="timeline_space"
|
|
|
|
v-loading="loading"
|
2018-08-15 09:08:44 +02:00
|
|
|
:element-loading-text="$t('message.loading')"
|
2018-07-02 14:53:09 +02:00
|
|
|
element-loading-spinner="el-icon-loading"
|
2018-07-05 15:15:31 +02:00
|
|
|
element-loading-background="rgba(0, 0, 0, 0.8)"
|
2018-11-27 01:03:07 +01:00
|
|
|
v-shortkey="shortcutEnabled ? {help: ['shift', '?']} : {}"
|
2018-08-22 16:30:49 +02:00
|
|
|
@shortkey="handleKey"
|
2018-07-05 15:15:31 +02:00
|
|
|
>
|
2018-03-09 07:21:25 +01:00
|
|
|
<side-menu></side-menu>
|
2018-07-02 18:01:46 +02:00
|
|
|
<div :class="collapse ? 'page-narrow':'page'">
|
2018-04-18 01:18:50 +02:00
|
|
|
<header class="header" style="-webkit-app-region: drag;">
|
2018-03-22 10:09:58 +01:00
|
|
|
<header-menu></header-menu>
|
2018-03-24 04:16:33 +01:00
|
|
|
</header>
|
2018-03-29 17:20:15 +02:00
|
|
|
<contents></contents>
|
2018-03-09 07:21:25 +01:00
|
|
|
</div>
|
2018-03-29 17:20:35 +02:00
|
|
|
<modals></modals>
|
2018-07-05 15:15:31 +02:00
|
|
|
<receive-drop v-show="droppableVisible"></receive-drop>
|
2018-03-08 10:36:09 +01:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2018-08-23 17:17:47 +02:00
|
|
|
import { mapState, mapGetters } from 'vuex'
|
2018-03-09 07:21:25 +01:00
|
|
|
import SideMenu from './TimelineSpace/SideMenu'
|
2018-03-22 10:09:58 +01:00
|
|
|
import HeaderMenu from './TimelineSpace/HeaderMenu'
|
2018-03-29 17:20:15 +02:00
|
|
|
import Contents from './TimelineSpace/Contents'
|
2018-03-29 17:20:35 +02:00
|
|
|
import Modals from './TimelineSpace/Modals'
|
2018-06-06 13:25:28 +02:00
|
|
|
import Mousetrap from 'mousetrap'
|
2018-07-05 15:15:31 +02:00
|
|
|
import ReceiveDrop from './TimelineSpace/ReceiveDrop'
|
2018-03-09 07:21:25 +01:00
|
|
|
|
2018-03-08 10:36:09 +01:00
|
|
|
export default {
|
2018-03-08 16:24:18 +01:00
|
|
|
name: 'timeline-space',
|
2018-07-05 15:15:31 +02:00
|
|
|
components: { SideMenu, HeaderMenu, Modals, Contents, ReceiveDrop },
|
|
|
|
data () {
|
|
|
|
return {
|
|
|
|
dropTarget: null,
|
|
|
|
droppableVisible: false
|
|
|
|
}
|
|
|
|
},
|
2018-07-02 14:53:09 +02:00
|
|
|
computed: {
|
|
|
|
...mapState({
|
2018-07-02 18:01:46 +02:00
|
|
|
loading: state => state.TimelineSpace.loading,
|
|
|
|
collapse: state => state.TimelineSpace.SideMenu.collapse
|
2018-08-23 17:17:47 +02:00
|
|
|
}),
|
|
|
|
...mapGetters('TimelineSpace/Modals', [
|
|
|
|
'modalOpened'
|
|
|
|
]),
|
|
|
|
shortcutEnabled: function () {
|
|
|
|
return !this.modalOpened
|
|
|
|
}
|
2018-07-02 14:53:09 +02:00
|
|
|
},
|
2018-11-17 09:49:52 +01:00
|
|
|
async created () {
|
2018-12-12 01:49:24 +01:00
|
|
|
this.$store.dispatch('TimelineSpace/Contents/SideBar/close')
|
2018-07-02 14:53:09 +02:00
|
|
|
this.$store.commit('TimelineSpace/changeLoading', true)
|
2018-11-17 09:49:52 +01:00
|
|
|
await this.initialize()
|
2018-07-02 14:53:09 +02:00
|
|
|
.finally(() => {
|
|
|
|
this.$store.commit('TimelineSpace/changeLoading', false)
|
2018-04-19 17:13:37 +02:00
|
|
|
this.$store.commit('GlobalHeader/updateChanging', false)
|
2018-03-21 02:41:53 +01:00
|
|
|
})
|
|
|
|
},
|
2018-06-06 13:25:28 +02:00
|
|
|
mounted () {
|
2018-07-05 15:15:31 +02:00
|
|
|
window.addEventListener('dragenter', this.onDragEnter)
|
|
|
|
window.addEventListener('dragleave', this.onDragLeave)
|
|
|
|
window.addEventListener('dragover', this.onDragOver)
|
|
|
|
window.addEventListener('drop', this.handleDrop)
|
2018-06-06 13:25:28 +02:00
|
|
|
Mousetrap.bind(['command+t', 'ctrl+t'], () => {
|
|
|
|
this.$store.commit('TimelineSpace/Modals/Jump/changeModal', true)
|
|
|
|
})
|
|
|
|
},
|
2018-03-21 02:41:53 +01:00
|
|
|
beforeDestroy () {
|
2018-07-05 15:15:31 +02:00
|
|
|
window.removeEventListener('dragenter', this.onDragEnter)
|
|
|
|
window.removeEventListener('dragleave', this.onDragLeave)
|
|
|
|
window.removeEventListener('dragover', this.onDragOver)
|
|
|
|
window.removeEventListener('drop', this.handleDrop)
|
2018-11-08 00:12:51 +01:00
|
|
|
this.$store.dispatch('TimelineSpace/stopStreamings')
|
2018-11-17 13:03:56 +01:00
|
|
|
this.$store.dispatch('TimelineSpace/unbindStreamings')
|
2018-03-21 02:41:53 +01:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
async clear () {
|
|
|
|
await this.$store.dispatch('TimelineSpace/clearAccount')
|
2018-11-08 00:12:51 +01:00
|
|
|
this.$store.dispatch('TimelineSpace/clearContentsTimelines')
|
2018-03-21 02:41:53 +01:00
|
|
|
await this.$store.dispatch('TimelineSpace/removeShortcutEvents')
|
2018-05-17 15:02:59 +02:00
|
|
|
await this.$store.dispatch('TimelineSpace/clearUnread')
|
2018-03-21 02:41:53 +01:00
|
|
|
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({
|
2018-08-13 08:27:53 +02:00
|
|
|
message: this.$t('message.account_load_error'),
|
2018-04-08 15:09:28 +02:00
|
|
|
type: 'error'
|
|
|
|
})
|
|
|
|
})
|
|
|
|
this.$store.dispatch('TimelineSpace/SideMenu/fetchLists', account)
|
2018-11-08 00:12:51 +01:00
|
|
|
await this.$store.dispatch('TimelineSpace/loadUnreadNotification', this.$route.params.id)
|
|
|
|
|
|
|
|
// Load timelines
|
|
|
|
await this.$store.dispatch('TimelineSpace/fetchContentsTimelines', account)
|
|
|
|
.catch(_ => {
|
2018-04-08 15:09:28 +02:00
|
|
|
this.$message({
|
2018-11-08 00:12:51 +01:00
|
|
|
message: this.$t('message.timeline_fetch_error'),
|
2018-04-08 15:09:28 +02:00
|
|
|
type: 'error'
|
|
|
|
})
|
|
|
|
})
|
2018-11-08 00:12:51 +01:00
|
|
|
|
|
|
|
// Bind streamings
|
|
|
|
await this.$store.dispatch('TimelineSpace/bindStreamings', account)
|
|
|
|
// Start streamings
|
|
|
|
this.$store.dispatch('TimelineSpace/startStreamings', account)
|
|
|
|
|
2018-08-19 07:42:20 +02:00
|
|
|
this.$store.dispatch('TimelineSpace/fetchEmojis', account)
|
2018-10-02 13:49:37 +02:00
|
|
|
this.$store.dispatch('TimelineSpace/fetchInstance', account)
|
2018-07-05 15:15:31 +02:00
|
|
|
},
|
|
|
|
handleDrop (e) {
|
|
|
|
e.preventDefault()
|
|
|
|
e.stopPropagation()
|
|
|
|
this.droppableVisible = false
|
|
|
|
if (e.dataTransfer.files.item(0) === null || e.dataTransfer.files.item(0) === undefined) {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
const file = e.dataTransfer.files.item(0)
|
|
|
|
if (!file.type.includes('image') && !file.type.includes('video')) {
|
|
|
|
this.$message({
|
2018-08-13 08:27:53 +02:00
|
|
|
message: this.$t('validation.new_toot.attach_image'),
|
2018-07-05 15:15:31 +02:00
|
|
|
type: 'error'
|
|
|
|
})
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
this.$store.dispatch('TimelineSpace/Modals/NewToot/openModal')
|
|
|
|
this.$store.dispatch('TimelineSpace/Modals/NewToot/incrementMediaId')
|
|
|
|
this.$store.dispatch('TimelineSpace/Modals/NewToot/uploadImage', file)
|
|
|
|
.catch(() => {
|
|
|
|
this.$message({
|
2018-08-13 08:27:53 +02:00
|
|
|
message: this.$t('message.attach_error'),
|
2018-07-05 15:15:31 +02:00
|
|
|
type: 'error'
|
|
|
|
})
|
|
|
|
})
|
|
|
|
return false
|
|
|
|
},
|
|
|
|
onDragEnter (e) {
|
|
|
|
this.dropTarget = e.target
|
|
|
|
this.droppableVisible = true
|
|
|
|
},
|
|
|
|
onDragLeave (e) {
|
|
|
|
if (e.target === this.dropTarget) {
|
|
|
|
this.droppableVisible = false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
onDragOver (e) {
|
|
|
|
e.preventDefault()
|
2018-08-22 16:30:49 +02:00
|
|
|
},
|
|
|
|
handleKey (event) {
|
|
|
|
switch (event.srcKey) {
|
|
|
|
case 'help':
|
|
|
|
this.$store.commit('TimelineSpace/Modals/Shortcut/changeModal', true)
|
|
|
|
break
|
|
|
|
}
|
2018-03-21 02:41:53 +01:00
|
|
|
}
|
2018-03-08 16:24:18 +01:00
|
|
|
}
|
2018-03-08 10:36:09 +01:00
|
|
|
}
|
|
|
|
</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 {
|
2018-11-21 16:40:05 +01:00
|
|
|
width: calc(100% - 180px);
|
2018-03-22 10:09:58 +01:00
|
|
|
position: fixed;
|
|
|
|
top: 0;
|
|
|
|
height: 48px;
|
2018-04-13 02:09:51 +02:00
|
|
|
border-bottom: solid 1px var(--theme-border-color);
|
2018-03-22 10:09:58 +01:00
|
|
|
}
|
2018-03-09 07:21:25 +01:00
|
|
|
}
|
2018-03-12 17:42:47 +01:00
|
|
|
|
2018-07-02 18:01:46 +02:00
|
|
|
.page-narrow {
|
2018-10-23 01:49:53 +02:00
|
|
|
margin-left: 64px;
|
2018-07-02 18:01:46 +02:00
|
|
|
height: 100%;
|
|
|
|
box-sizing: border-box;
|
|
|
|
|
|
|
|
.header {
|
2018-11-14 23:57:12 +01:00
|
|
|
width: calc(100% - 64px);
|
2018-07-02 18:01:46 +02:00
|
|
|
position: fixed;
|
|
|
|
top: 0;
|
|
|
|
height: 48px;
|
|
|
|
border-bottom: solid 1px var(--theme-border-color);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-14 23:57:12 +01:00
|
|
|
.with-global-header {
|
2018-11-23 11:12:26 +01:00
|
|
|
.page .header {
|
|
|
|
width: calc(100% - 245px);
|
|
|
|
}
|
|
|
|
|
2018-11-15 01:58:30 +01:00
|
|
|
.page-narrow .header {
|
2018-11-14 23:57:12 +01:00
|
|
|
width: calc(100% - 65px - 64px);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-08 10:36:09 +01:00
|
|
|
</style>
|