This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| async canGoOn(routeData, guard) { | |
| if (guard) { | |
| return await guard(routeData) | |
| } | |
| return true; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| path: 'image/:index', | |
| element: 'div', | |
| attributes: {is: 'detailed-image'}, | |
| guard: imageExistGuard | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const imageExistGuard = async path => { | |
| if (!path) { | |
| console.error('no path') | |
| return false | |
| } | |
| const imageId = path.split('/')[2] | |
| if (!imageId) { | |
| return false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const imageExistGuard = async path => { | |
| if (!path) { | |
| console.error('no path') | |
| return false | |
| } | |
| const imageId = path.split('/')[2] | |
| if (!imageId) { | |
| return false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| async function letMeNotifyYouAndPleaseDontRevoke() { | |
| // Get the permission status | |
| const status = await navigator.permissions.request({name: 'notifications'}); | |
| //Handle the change | |
| status.onchange = changeEvent => { | |
| // Although we have the status on the outer scope, we will use it as the target | |
| const newState = changeEvent.target.state; | |
| // Show alert if the permission is not granted |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| async function stopNotifying() { | |
| return await navigator.permissions.revoke({name: 'notifications'}) | |
| } | |
| // Will return a promise of an update PermissionStatus, | |
| // while its state will be 'prompt' if it has been previously granted. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| async function pleaseLetMeUseBothNotificationsAndCamera() { | |
| return await navigator.permissions.requestAll([{name: 'camera'}, | |
| {name: 'notifications'}]). | |
| } | |
| // This will return a promise of an array of two permission statuses |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| async function pleaseLetMeNotify() { | |
| return await navigator.permissions.request({name: 'notifications'}); | |
| } | |
| // Retuns a promise of a PermissionStatusObject |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| async function mayINotify() { | |
| return await navigator.permission.query({name: 'notifications'}); | |
| } | |
| // This will return a promise of PermssionStatus object |