Skip to content

Commit

Permalink
Merge pull request #1443 from meetfranz/feature/multilingual-announce…
Browse files Browse the repository at this point in the history
…ments

support multilingual announcements
  • Loading branch information
DominikGuzei authored May 23, 2019
2 parents 4ea7765 + 7e9a50a commit 1b167e0
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/features/announcements/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,15 @@ export class AnnouncementsStore extends FeatureStore {
}

@computed get announcement() {
return getAnnouncementRequest.result;
if (!this.stores || !getAnnouncementRequest.result) return null;
const { locale, defaultLocale } = this.stores.app;
const announcement = getAnnouncementRequest.result;
// User locale
if (announcement[locale]) return announcement[locale];
// Default locale
if (announcement[defaultLocale]) return announcement[defaultLocale];
// No locales specified
return announcement;
}

@computed get areNewsAvailable() {
Expand Down Expand Up @@ -121,8 +129,8 @@ export class AnnouncementsStore extends FeatureStore {
_fetchAnnouncements = () => {
const targetVersion = this.targetVersion || this.currentVersion;
if (!targetVersion) return;
getChangelogRequest.execute(targetVersion);
getAnnouncementRequest.execute(targetVersion);
getChangelogRequest.reset().execute(targetVersion);
getAnnouncementRequest.reset().execute(targetVersion);
};

_showAnnouncementOnRouteMatch = () => {
Expand Down

0 comments on commit 1b167e0

Please # to comment.