Skip to content

Commit

Permalink
feat(pwa-helper): handle nack to home event
Browse files Browse the repository at this point in the history
  • Loading branch information
alimd committed Mar 2, 2023
1 parent 286708e commit 4e30cdc
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 11 deletions.
3 changes: 2 additions & 1 deletion ui/pwa-helper/src/pwa-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ import '@alwatr/ui-kit/style/token.css';
import '@alwatr/ui-kit/top-app-bar/top-app-bar.js';
import {untilNextFrame} from '@alwatr/util';

import './signal/back-click-event.js';
import './signal/back-to-home-click.js';
import './signal/browser-back-click.js';
import './signal/register-service-worker-command.js';
import './signal/sw-user-notify.js';

Expand Down
10 changes: 0 additions & 10 deletions ui/pwa-helper/src/signal/back-click-event.ts

This file was deleted.

11 changes: 11 additions & 0 deletions ui/pwa-helper/src/signal/back-to-home-click.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import {redirect} from '@alwatr/router';
import {eventListener} from '@alwatr/signal';

import {logger} from '../logger.js';

import type {ClickSignalType} from '@alwatr/type';

eventListener.subscribe<ClickSignalType>('back_to_home_click_event', () => {
logger.logMethod('back_to_home_click_event');
redirect({sectionList: []});
});
16 changes: 16 additions & 0 deletions ui/pwa-helper/src/signal/browser-back-click.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import {eventListener} from '@alwatr/signal';

import {logger} from '../logger.js';

import type {ClickSignalType} from '@alwatr/type';

eventListener.subscribe<ClickSignalType>('browser_back_click_event', () => {
logger.logMethod('browser_back_click_event');
history.back();
});

// TODO: replace all and remove this
eventListener.subscribe<ClickSignalType>('back-click-event', () => {
logger.logMethod('browser_back_click_event');
history.back();
});

0 comments on commit 4e30cdc

Please sign in to comment.