From c3bd113694ef1e50f811684f8a71e9132ed10733 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Julius=20H=C3=A4rtl?=
Date: Wed, 5 Dec 2018 10:50:37 +0100
Subject: [PATCH] Add public stream to profile page
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Julius Härtl
---
src/components/Composer.vue | 4 +-
src/components/TimelineEntry.vue | 7 +-
src/components/TimelineList.vue | 122 +++++++++++++++++++++++++++++++
src/store/timeline.js | 26 +++++--
src/views/ProfileTimeline.vue | 20 ++---
src/views/Timeline.vue | 117 ++---------------------------
6 files changed, 164 insertions(+), 132 deletions(-)
create mode 100644 src/components/TimelineList.vue
diff --git a/src/components/Composer.vue b/src/components/Composer.vue
index 1bdb78b6..de440406 100644
--- a/src/components/Composer.vue
+++ b/src/components/Composer.vue
@@ -499,9 +499,7 @@ export default {
this.$store.dispatch('post', this.getPostData()).then((response) => {
this.post = ''
this.$refs.composerInput.innerText = this.post
- this.$store.dispatch('refreshTimeline', {
- account: this.currentUser.uid
- })
+ this.$store.dispatch('refreshTimeline')
})
},
remoteSearch(text) {
diff --git a/src/components/TimelineEntry.vue b/src/components/TimelineEntry.vue
index 7fa30b32..ba90f88d 100644
--- a/src/components/TimelineEntry.vue
+++ b/src/components/TimelineEntry.vue
@@ -7,15 +7,20 @@
+ {{ item.account_info }}
+
diff --git a/src/components/TimelineList.vue b/src/components/TimelineList.vue
new file mode 100644
index 00000000..458ec3af
--- /dev/null
+++ b/src/components/TimelineList.vue
@@ -0,0 +1,122 @@
+
+
+
+
+
+
+
diff --git a/src/store/timeline.js b/src/store/timeline.js
index cadbd990..c31fb245 100644
--- a/src/store/timeline.js
+++ b/src/store/timeline.js
@@ -26,7 +26,8 @@ import Vue from 'vue'
const state = {
timeline: {},
since: Math.floor(Date.now() / 1000) + 1,
- type: 'home'
+ type: 'home',
+ account: ''
}
const mutations = {
addToTimeline(state, data) {
@@ -41,6 +42,9 @@ const mutations = {
},
setTimelineType(state, type) {
state.type = type
+ },
+ setAccount(state, account) {
+ state.account = account
}
}
const getters = {
@@ -54,6 +58,12 @@ const actions = {
changeTimelineType(context, type) {
context.commit('resetTimeline')
context.commit('setTimelineType', type)
+ context.commit('setAccount', '')
+ },
+ changeTimelineTypeAccount(context, account) {
+ context.commit('resetTimeline')
+ context.commit('setTimelineType', 'account')
+ context.commit('setAccount', account)
},
post(context, post) {
return axios.post(OC.generateUrl('apps/social/api/v1/post'), { data: post }).then((response) => {
@@ -64,14 +74,20 @@ const actions = {
console.error('Failed to create a post', error)
})
},
- refreshTimeline(context, account) {
- return this.dispatch('fetchTimeline', { account: account, sinceTimestamp: Math.floor(Date.now() / 1000) + 1 })
+ refreshTimeline(context) {
+ return this.dispatch('fetchTimeline', { sinceTimestamp: Math.floor(Date.now() / 1000) + 1 })
},
- fetchTimeline(context, { account, sinceTimestamp }) {
+ fetchTimeline(context, { sinceTimestamp }) {
if (typeof sinceTimestamp === 'undefined') {
sinceTimestamp = state.since - 1
}
- return axios.get(OC.generateUrl(`apps/social/api/v1/stream/${state.type}?limit=5&since=` + sinceTimestamp)).then((response) => {
+ let url
+ if (state.type === 'account') {
+ url = OC.generateUrl(`apps/social/api/v1/account/${state.account}/stream?limit=25&since=` + sinceTimestamp)
+ } else {
+ url = OC.generateUrl(`apps/social/api/v1/stream/${state.type}?limit=25&since=` + sinceTimestamp)
+ }
+ return axios.get(url).then((response) => {
if (response.status === -1) {
throw response.message
}
diff --git a/src/views/ProfileTimeline.vue b/src/views/ProfileTimeline.vue
index eb50a136..043dda4a 100644
--- a/src/views/ProfileTimeline.vue
+++ b/src/views/ProfileTimeline.vue
@@ -21,30 +21,26 @@
-->
-
-
-
+
diff --git a/src/views/Timeline.vue b/src/views/Timeline.vue
index 81b9fdea..4a6e986f 100644
--- a/src/views/Timeline.vue
+++ b/src/views/Timeline.vue
@@ -10,17 +10,8 @@
-
+
+
@@ -88,6 +79,7 @@ import TimelineEntry from './../components/TimelineEntry'
import Composer from './../components/Composer'
import CurrentUserMixin from './../mixins/currentUserMixin'
import EmptyContent from './../components/EmptyContent'
+import TimelineList from './../components/TimelineList'
export default {
name: 'Timeline',
@@ -98,104 +90,24 @@ export default {
Multiselect,
Composer,
InfiniteLoading,
- EmptyContent
+ EmptyContent,
+ TimelineList
},
mixins: [CurrentUserMixin],
data: function() {
return {
- infoHidden: false,
- state: [],
- emptyContent: {
- default: {
- image: 'img/undraw/posts.svg',
- title: t('social', 'No posts found'),
- description: t('social', 'Posts from people you follow will show up here')
- },
- direct: {
- image: 'img/undraw/direct.svg',
- title: t('social', 'No direct messages found'),
- description: t('social', 'Posts directed to you will show up here')
- },
- timeline: {
- image: 'img/undraw/local.svg',
- title: t('social', 'No local posts found'),
- description: t('social', 'Posts from other people on this instance will show up here')
- },
- federated: {
- image: 'img/undraw/global.svg',
- title: t('social', 'No global posts found'),
- description: t('social', 'Posts from federated instances will show up here')
- }
- }
+ infoHidden: false
}
},
computed: {
- emptyContentData() {
- if (typeof this.emptyContent[this.$route.params.type] !== 'undefined') {
- return this.emptyContent[this.$route.params.type]
- }
- return this.emptyContent.default
- },
type: function() {
if (this.$route.params.type) {
return this.$route.params.type
}
return 'home'
},
- url: function() {
- return OC.linkTo('social', 'img/nextcloud.png')
- },
- timeline: function() {
- return this.$store.getters.getTimeline
- },
showInfo() {
return this.$store.getters.getServerData.firstrun && !this.infoHidden
- },
- menu: function() {
- let defaultCategories = [
- {
- id: 'social-timeline',
- classes: [],
- href: '#',
- icon: 'icon-category-monitoring',
- text: t('social', 'Timeline')
- },
- {
- id: 'social-account',
- classes: [],
- href: '#',
- icon: 'icon-category-user',
- text: t('social', 'Profile')
- },
- {
- id: 'social-friends',
- classes: [],
- href: '#',
- icon: 'icon-category-social',
- text: t('social', 'Friends')
- },
- {
- id: 'social-favorites',
- classes: [],
- href: '#',
- icon: 'icon-favorite',
- text: t('social', 'Favorites')
- },
- {
- id: 'social-direct-messages',
- classes: [],
- href: '#',
- icon: 'icon-comment',
- utils: {
- counter: 3
- },
- text: t('social', 'Direct messages')
- }
- ]
- return {
- items: defaultCategories,
- loading: false
- }
}
},
beforeMount: function() {
@@ -204,23 +116,6 @@ export default {
methods: {
hideInfo() {
this.infoHidden = true
- },
- infiniteHandler($state) {
- this.$store.dispatch('fetchTimeline', {
- account: this.currentUser.uid
- }).then((response) => {
- if (response.status === -1) {
- OC.Notification.showTemporary('Failed to load more timeline entries')
- console.error('Failed to load more timeline entries', response)
- $state.complete()
- return
- }
- response.result.length > 0 ? $state.loaded() : $state.complete()
- }).catch((error) => {
- OC.Notification.showTemporary('Failed to load more timeline entries')
- console.error('Failed to load more timeline entries', error)
- $state.complete()
- })
}
}
}