summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2018-11-22 15:42:10 +0100
committerJulius Härtl <jus@bitgrid.net>2018-11-22 16:14:36 +0100
commit9375d246b9b72942b22ae89fc0f09234e6a1e287 (patch)
treecae348c2871096bf7181581af5eb6d99237ef223
parentf3a36449e086c662c3c84169172e63d1fbb20ac7 (diff)
Load different timeline streams
Signed-off-by: Julius Härtl <jus@bitgrid.net>
-rw-r--r--src/App.vue40
-rw-r--r--src/router.js4
-rw-r--r--src/store/timeline.js19
-rw-r--r--src/views/Timeline.vue10
4 files changed, 58 insertions, 15 deletions
diff --git a/src/App.vue b/src/App.vue
index efe135dc..e28879c0 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -89,13 +89,23 @@ export default {
{
id: 'social-timeline',
classes: [],
- icon: 'icon-category-monitoring',
- text: t('social', 'Timeline'),
+ icon: 'icon-home',
+ text: t('social', 'Home'),
router: {
name: 'timeline'
}
},
{
+ id: 'social-direct-messages',
+ classes: [],
+ router: {
+ name: 'timeline',
+ params: { type: 'direct' }
+ },
+ icon: 'icon-comment',
+ text: t('social', 'Direct messages')
+ },
+ {
id: 'social-account',
classes: [],
icon: 'icon-user',
@@ -106,18 +116,28 @@ export default {
}
},
{
- id: 'social-favorites',
+ id: 'social-spacer',
+ classes: []
+ },
+ {
+ id: 'social-timeline',
classes: [],
- href: '#',
- icon: 'icon-favorite',
- text: t('social', 'Favorites')
+ icon: 'icon-category-monitoring',
+ text: t('social', 'Local timeline'),
+ router: {
+ name: 'timeline',
+ params: { type: 'local' }
+ }
},
{
- id: 'social-direct-messages',
+ id: 'social-timeline',
classes: [],
- href: '#',
- icon: 'icon-comment',
- text: t('social', 'Direct messages')
+ icon: 'icon-link',
+ text: t('social', 'Global timeline'),
+ router: {
+ name: 'timeline',
+ params: { type: 'global' }
+ }
}
]
return {
diff --git a/src/router.js b/src/router.js
index b6e4c1ba..69833e83 100644
--- a/src/router.js
+++ b/src/router.js
@@ -41,6 +41,10 @@ export default new Router({
routes: [
{
path: '/:index(index.php/)?apps/social/',
+ redirect: { name: 'timeline' }
+ },
+ {
+ path: '/:index(index.php/)?apps/social/timeline/:type?',
components: {
default: Timeline
},
diff --git a/src/store/timeline.js b/src/store/timeline.js
index b06dad71..e872f475 100644
--- a/src/store/timeline.js
+++ b/src/store/timeline.js
@@ -25,18 +25,25 @@ import Vue from 'vue'
const state = {
timeline: {},
- since: new Date()
+ since: Math.floor(Date.now() / 1000) + 1,
+ type: 'home'
}
const mutations = {
addToTimeline(state, data) {
for (let item in data) {
- state.since = data[item].published
+ state.since = data[item].publishedTime
Vue.set(state.timeline, data[item].id, data[item])
}
},
addPost(state, data) {
// FIXME: push data we receive to the timeline array
// state.timeline.push(data)
+ },
+ resetTimeline(state) {
+ state.timeline = {}
+ },
+ setTimelineType(state, type) {
+ state.type = type
}
}
const getters = {
@@ -47,6 +54,10 @@ const getters = {
}
}
const actions = {
+ changeTimelineType(context, type) {
+ context.commit('resetTimeline')
+ context.commit('setTimelineType', type)
+ },
post(context, post) {
return axios.post(OC.generateUrl('apps/social/api/v1/post'), { data: post }).then((response) => {
context.commit('addPost', { data: response.data })
@@ -60,9 +71,9 @@ const actions = {
},
fetchTimeline(context, { account, sinceTimestamp }) {
if (typeof sinceTimestamp === 'undefined') {
- sinceTimestamp = Date.parse(state.since) / 1000
+ sinceTimestamp = state.since - 1
}
- return axios.get(OC.generateUrl('apps/social/api/v1/stream/timeline?limit=5&since=' + sinceTimestamp)).then((response) => {
+ return axios.get(OC.generateUrl(`apps/social/api/v1/stream/${state.type}?limit=5&since=` + sinceTimestamp)).then((response) => {
if (response.status === -1) {
throw response.message
}
diff --git a/src/views/Timeline.vue b/src/views/Timeline.vue
index 7209d0b8..9de7ace6 100644
--- a/src/views/Timeline.vue
+++ b/src/views/Timeline.vue
@@ -1,5 +1,6 @@
<template>
<div class="social__wrapper">
+ {{ type }}
<div class="social__container">
<transition name="slide-fade">
<div v-if="showInfo" class="social__welcome">
@@ -124,6 +125,12 @@ export default {
}
},
computed: {
+ type: function() {
+ if (this.$route.params.type) {
+ return this.$route.params.type
+ }
+ return 'home'
+ },
url: function() {
return OC.linkTo('social', 'img/nextcloud.png')
},
@@ -181,7 +188,7 @@ export default {
}
},
beforeMount: function() {
-
+ this.$store.dispatch('changeTimelineType', this.type)
},
methods: {
hideInfo() {
@@ -201,6 +208,7 @@ export default {
}).catch((error) => {
OC.Notification.showTemporary('Failed to load more timeline entries')
console.error('Failed to load more timeline entries', error)
+ $state.complete()
})
}
}