diff --git a/packages/apps/esm-offline-tools-app/src/components/offline-ready-modal.component.tsx b/packages/apps/esm-offline-tools-app/src/components/offline-ready-modal.component.tsx index 46d323c23..46f3f75dd 100644 --- a/packages/apps/esm-offline-tools-app/src/components/offline-ready-modal.component.tsx +++ b/packages/apps/esm-offline-tools-app/src/components/offline-ready-modal.component.tsx @@ -14,10 +14,8 @@ const OfflineReadyModal: React.FC = ({ closeMo const [abortController, setAbortController] = useState(() => new AbortController()); async function dispatchOfflineEvent() { - //TODO CHANGE MODE - let mode = getCurrentOfflineMode().active; window.dispatchEvent( - new CustomEvent(`openmrs:offline-${mode ? 'enabled' : 'disabled'}`, { + new CustomEvent(`openmrs:offline-enabled`, { detail: getCurrentOfflineMode(), }), ); diff --git a/packages/apps/esm-offline-tools-app/src/index.ts b/packages/apps/esm-offline-tools-app/src/index.ts index eb361ef61..1b2f04736 100644 --- a/packages/apps/esm-offline-tools-app/src/index.ts +++ b/packages/apps/esm-offline-tools-app/src/index.ts @@ -1,4 +1,4 @@ -import { defineConfigSchema, getSyncLifecycle, registerBreadcrumbs } from '@openmrs/esm-framework'; +import { defineConfigSchema, getSyncLifecycle, registerBreadcrumbs, registerOfflineHandler } from '@openmrs/esm-framework'; import { routes } from './constants'; import { createDashboardLink } from './createDashboardLink'; import { dashboardMeta } from './dashboard.meta'; @@ -88,11 +88,9 @@ export const offlineToolsOptInButton = getSyncLifecycle(offlineToolsOptInButtonC export function startupApp() { defineConfigSchema(moduleName, {}); - setupOffline(); + registerOfflineHandler(setupOffline); setupSynchronizingOfflineActionsNotifications(); - // registerOfflineHandler(setupOffline); - registerBreadcrumbs([ { path: `${window.spaBase}/${routes.offlineTools}`, diff --git a/packages/apps/esm-offline-tools-app/src/offline-actions/synchronizing-notification.tsx b/packages/apps/esm-offline-tools-app/src/offline-actions/synchronizing-notification.tsx index 2d1df0774..32b295198 100644 --- a/packages/apps/esm-offline-tools-app/src/offline-actions/synchronizing-notification.tsx +++ b/packages/apps/esm-offline-tools-app/src/offline-actions/synchronizing-notification.tsx @@ -51,7 +51,7 @@ function SynchronizingNotification({ mySynchronizationIndex }) {
{isCanceled ? t('offlineActionsSynchronizationNotificationCanceling', 'Canceling...') - : t('offlineActionsSynchronizationNotificationStatus', '{current} / {total} actions', { + : t('offlineActionsSynchronizationNotificationStatus', '{{current}} / {{total}} actions', { current: synchronization.totalCount - synchronization.pendingCount, total: synchronization.totalCount, })} diff --git a/packages/framework/esm-offline/src/mode.ts b/packages/framework/esm-offline/src/mode.ts index bccb1adb1..0412605d3 100644 --- a/packages/framework/esm-offline/src/mode.ts +++ b/packages/framework/esm-offline/src/mode.ts @@ -59,14 +59,11 @@ export function setCurrentOfflineMode(mode: OfflineMode) { localStorage.setItem(offlineModeStorageKey, mode === 'on' ? 'active' : 'disabled'); offlineMode = mode; } + lastRun = new Date().toLocaleString(); } export function registerOfflineHandler(setupOffline: OfflineHandler) { window.addEventListener('openmrs:offline-enabled', setupOffline); - const offlineMode = getCurrentOfflineMode(); - if (offlineMode.active) { - setupOffline(); - } } export async function activateOfflineCapability() {