Watch for route changes

This commit is contained in:
Peter Stuifzand 2018-09-08 15:14:27 +02:00
parent fc30b58069
commit 429170737f
2 changed files with 10 additions and 2 deletions

View File

@ -1,5 +1,5 @@
<template>
<div class="channel--name" @click="select(channel)">
<div class="channel--name">
<router-link :to='"/channel/" + channel.uid'>
{{ channel.name }}
<span :class="{ tag: true, 'is-success': channel.unread > 0}">{{ channel.unread }}</span>

View File

@ -10,7 +10,8 @@
<button class="button" @click="openFeedFollower">Add feed</button>
<new-post class="mt-20"></new-post>
<h1>{{ channel.name }}</h1>
<Timeline style="margin-top:20px" :timeline="this.$store.state.timeline" :channel="channel" @getPage="getPage"></Timeline>
<Timeline style="margin-top:20px" :timeline="this.$store.state.timeline" :channel="channel"
@getPage="getPage"></Timeline>
</div>
<div class="column"></div>
@ -75,6 +76,13 @@
}
},
watch: {
'$route'(to, from) {
this.$store.dispatch('fetchChannels')
this.$store.dispatch('fetchTimeline', {uid: to.params.uid})
}
},
mounted() {
if (this.$store.state.logged_in) {
this.$store.dispatch('fetchChannels')