summaryrefslogtreecommitdiffstats
path: root/src/views/ProfilePageIntegration.vue
blob: 8771a19e15bafd5e3a30d3486f0c984b5074b0b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<template>
	<div>
		<h2>Social</h2>
		<transition-group name="list" tag="ul">
			<TimelineEntry v-for="entry in timeline"
				:key="entry.id"
				:item="entry" />
		</transition-group>
	</div>
</template>

<script>
import TimelineEntry from './../components/TimelineEntry.vue'
import axios from '@nextcloud/axios'
import { generateUrl } from '@nextcloud/router'
import logger from './../services/logger.js'

export default {
	name: 'ProfilePageIntegration',
	components: {
		TimelineEntry,
	},
	props: {
		userId: {
			type: String,
			default: '',
		},
	},
	data() {
		return {
			accountInfo: null,
			timeline: [],
		}
	},
	computed: {
		getCount() {
			const account = this.accountInfo
			return (field) => account.details.count ? account.details.count[field] : ''
		},
	},
	// Start fetching account information before mounting the component
	beforeMount() {
		const uid = this.userId

		axios.get(generateUrl(`apps/social/api/v1/global/account/info?account=${uid}`)).then(({ data }) => {
			this.accountInfo = data
			logger.log(this.accountInfo)
		})

		axios.get(generateUrl(`apps/social/api/v1/accounts/${uid}/statuses`)).then(({ data }) => {
			this.timeline = data
			logger.log(this.timeline)
		})
	},
}
</script>