Skip to content
This repository has been archived by the owner on Feb 22, 2024. It is now read-only.

Commit

Permalink
#83 popup-error when there is a problem syncing the favorites
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephanie Peters committed May 10, 2019
1 parent c96ef5c commit 1ec5889
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions src/Favourites.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function ensureUniqueId () {
return id
}

function syncWithServer () {
function syncWithServer (vueNode) {
const noAuthEnableIdParam = Conference.getConference().noAuthEnableIdParam && !Dukecloak.getKeycloak().isLoggedIn
if (Dukecloak.getKeycloak().isLoggedIn || noAuthEnableIdParam) {
if (syncIsRunning) {
Expand Down Expand Up @@ -115,6 +115,7 @@ function syncWithServer () {
})
.catch((e) => {
syncIsRunning = false
vueNode.eventbus.$emit('message.popup', { message: 'Unable to save favorites', error: true })
console.log('unable to save favorites', e)
})
} else {
Expand All @@ -127,6 +128,7 @@ function syncWithServer () {
Dukecloak.logout()
}
syncIsRunning = false
vueNode.eventbus.$emit('message.popup', { message: 'Unable to load favorites', error: true })
console.log('unable to load favorites', e)
})
}
Expand All @@ -137,6 +139,7 @@ function syncWithServer () {
.success(performSync)
.error(function () {
syncIsRunning = false
vueNode.eventbus.$emit('message.popup', { message: 'Error updating your token', error: true })
console.log('Error updating Keycloak token!')
})
} else {
Expand All @@ -159,7 +162,7 @@ function saveToSettings () {
}

export default class Favorites {
static toggleFavorite (eventId) {
static toggleFavorite (eventId, vueNode) {
let events = Conference.getAllEvents()
if (favorites[eventId] === true) {
if (Dukecloak.getKeycloak().isLoggedIn && events[eventId].numberOfFavorites !== undefined && events[eventId].numberOfFavorites > 0) {
Expand All @@ -186,7 +189,7 @@ export default class Favorites {
}
}
saveToSettings()
syncWithServer()
syncWithServer(vueNode)
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/components/event/Favourite.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default {
},
methods: {
toggleFavourite: function () {
Favourites.toggleFavorite(this.event.id)
Favourites.toggleFavorite(this.event.id, this)
}
},
computed: {
Expand Down

0 comments on commit 1ec5889

Please sign in to comment.