Skip to content

Commit

Permalink
Load translation messages from pretalx
Browse files Browse the repository at this point in the history
  • Loading branch information
rixx committed Aug 16, 2024
1 parent 0c9b4da commit d9661d0
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ export default {
allTracks: [],
onlyFavs: false,
scheduleError: false,
onHomeServer: false,
loggedIn: false,
apiUrl: null,
translationMessages: {},
}
},
computed: {
Expand Down Expand Up @@ -207,6 +211,9 @@ export default {
this.onWindowResize()
}
this.schedule.tracks.forEach(t => { t.value = t.id; t.label = getLocalizedString(t.name); this.allTracks.push(t) })
// set API URL before loading favs
this.apiUrl = this.eventUrl.split('/').slice(0, 3).join('/') + '/api/events/' + this.eventSlug + '/'
this.favs = this.pruneFavs(this.loadFavs(), this.schedule)
const fragment = window.location.hash.slice(1)
Expand Down Expand Up @@ -237,6 +244,15 @@ export default {
window.addEventListener('resize', this.onWindowResize)
this.onWindowResize()
}
/* global PRETALX_MESSAGES */
if (typeof PRETALX_MESSAGES !== 'undefined') {
this.translationMessages = PRETALX_MESSAGES
// this variable being present indicates that we're running on our home instance rather than as an embedded widget elsewhere
this.onHomeServer = true
if (document.querySelector("#pretalx-messages")?.dataset.loggedIn) {
this.loggedIn = true
}
}
},
destroyed () {
// TODO destroy observers
Expand Down Expand Up @@ -270,6 +286,8 @@ export default {
pruneFavs (favs, schedule) {
const talks = schedule.talks || []
const talkIds = talks.map(e => e.code)
// we're not pushing the changed list to the server, as if a talk vanished but will appear again,
// we want it to still be faved
return favs.filter(e => talkIds.includes(e))
},
saveFavs () {
Expand Down

0 comments on commit d9661d0

Please sign in to comment.