Skip to content

Commit

Permalink
fix(snackbar): fix issue for __package_version__ (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
arashagp authored Jan 9, 2025
1 parent daea0ce commit 9dfd8bc
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const notifyLocalStorageKey = 'notify_new_version';
* changelogPage: 'https://example.com/changelog'
* });
*/
export function serviceWorkerNotifySnackbar(options: {lastNotifyVersion: string; changelogPage?: string}): void {
export function serviceWorkerNotifySnackbar(options: {lastNotifyVersion: string; changelogPage?: string, currentVersion: string}): void {
logger.logMethodArgs?.('serviceWorkerNotifyHandler', {options});

serviceWorkerSignal.subscribe(({event}) => {
Expand Down Expand Up @@ -51,7 +51,7 @@ export function serviceWorkerNotifySnackbar(options: {lastNotifyVersion: string;
const lastLocalVersion = localStorage.getItem(notifyLocalStorageKey);
if (lastLocalVersion !== null) {
localStorage.removeItem(notifyLocalStorageKey);
const message = `به نسخه ${l10n.replaceNumber(__package_version__.replace('-alpha', '-آلفا'))} خوش‌آمدید.`;
const message = `به نسخه ${l10n.replaceNumber(options.currentVersion.replace('-alpha', '-آلفا'))} خوش‌آمدید.`;

/**
* Handles the display of a snackbar notification based on the service worker event.
Expand All @@ -60,7 +60,7 @@ export function serviceWorkerNotifySnackbar(options: {lastNotifyVersion: string;
* Otherwise, it shows a snackbar with a close button.
*/
if (
(options.changelogPage != null && options.lastNotifyVersion === __package_version__) ||
(options.changelogPage != null && options.lastNotifyVersion === options.currentVersion) ||
lastLocalVersion === '' ||
isVersionLarger(options.lastNotifyVersion, lastLocalVersion)
) {
Expand Down

0 comments on commit 9dfd8bc

Please sign in to comment.