Skip to content

Commit

Permalink
renderer: Index: re-fetch data when login/logout
Browse files Browse the repository at this point in the history
  • Loading branch information
rocka committed Mar 2, 2020
1 parent d554837 commit 9a7f5d4
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/renderer/page/Index/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,20 @@ export default {
},
},
created() {
this.fetchData();
this.unsub = this.$store.subscribe(({ type, payload }) => {
// clear recommend data when logout
if (type === SET_LOGIN_VALID && payload === false) {
if (
type === SET_LOGIN_VALID &&
(
payload === false || // clear personalized data on logout
(payload === true && this.playlist.length > 0) // get personalized data on login
)
) {
this.fetchData();
}
});
},
mounted() {
this.fetchData();
/** @type {HTMLDivElement[]} */
const scrollers = Array.from(document.getElementsByClassName('scroller'));
scrollers.forEach(s => {
Expand All @@ -153,7 +158,7 @@ export default {
});
});
},
beforeCreate() {
beforeDestroy() {
this.unsub();
},
components: {
Expand Down

0 comments on commit 9a7f5d4

Please sign in to comment.