@things-factory/notification 7.0.12 → 7.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/client/bootstrap.ts
CHANGED
package/dist-client/bootstrap.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../client/bootstrap.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,aAAa,CAAA;AAE7B,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,+CAA+C,CAAA;AAEpE,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,iBAAiB,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAChE,OAAO,EAAE,SAAS,IAAI,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AAEhE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAA;AACxF,OAAO,YAAY,MAAM,yBAAyB,CAAA;AAElD,IAAI,mBAAwB,CAAA;AAE5B,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,SAAS;IACrC,yBAAyB;IACzB,KAAK,CAAC,WAAW,CAAC,EAAE,YAAY,EAAE,CAAC,CAAA;IAEnC,KAAK,UAAU,cAAc,CAAC,YAAkB;QAC9C,KAAK,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAC,QAAQ,EAAC,EAAE;YAC/B,IAAI,YAAY,EAAE,CAAC;gBACjB,MAAM,iBAAiB,CAAC,GAAG,CAAC,YAAY,CAAC,CAAA;gBACzC,MAAM,iBAAiB,CAAC,KAAK,EAAE,CAAA;YACjC,CAAC;YAED,MAAM,OAAO,GAAG,MAAM,iBAAiB,CAAC,MAAM,EAAE,CAAA;YAEhD,QAAQ,CAAC;gBACP,IAAI,EAAE,mBAAmB;gBACzB,OAAO,EA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AAC,CAAC,OAAO;aAChC,CAAC,CAAA;QACJ,CAAC;IACH,CAAC,CAAC,CAAA;IAEF,MAAM,cAAc,EAAE,CAAA;AACxB,CAAC","sourcesContent":["import gql from 'graphql-tag'\n\nimport { notify } from '@operato/layout'\nimport { auth } from '@things-factory/auth-base/dist-client/auth.js'\n\nimport { i18next } from '@operato/i18n'\nimport { notificationStore, route, store } from '@operato/shell'\nimport { subscribe as graphqlSubscribe } from '@operato/graphql'\n\nimport { subscribe, unsubscribe, UPDATE_NOTIFICATION } from './actions/notification-fcm'\nimport notification from './reducers/notification'\n\nvar graphqlSubscription: any\n\nexport default async function bootstrap() {\n /* initialize reducers */\n store.addReducers({ notification })\n\n async function onnotification(notification?: any) {\n store.dispatch((async dispatch => {\n if (notification) {\n await notificationStore.add(notification)\n await notificationStore.limit()\n }\n\n const history = await notificationStore.getAll()\n\n dispatch({\n type: UPDATE_NOTIFICATION,\n history: [...history]\n })\n }) as any)\n }\n\n auth.on('presignout', async () => {\n try {\n await unsubscribe()\n /* await */ notificationStore.clear()\n } catch (err) {\n console.warn(err)\n }\n })\n\n auth.on('profile', async ({ credential }) => {\n try {\n await subscribe()\n } catch (err) {\n console.warn(err)\n }\n\n /*\n * subscription graphql notifications\n */\n var query = gql`\n subscription notification($subjects: [String!]) {\n notification(subjects: $subjects) {\n subject\n type\n title\n body\n url\n image\n timestamp\n }\n }\n `\n\n graphqlSubscription = await graphqlSubscribe(\n {\n query,\n variables: {\n subjects: ['info', 'warn', 'error', 'reload']\n }\n },\n {\n next({ data }) {\n const { notification } = data || {}\n onnotification({\n timestamp: Date.now(),\n ...notification\n })\n }\n }\n )\n })\n\n /* subscription web-push notification */\n const channel = new BroadcastChannel('notification')\n channel.addEventListener('message', async ({ data }) => {\n const { type } = data || {}\n\n switch (type) {\n case 'notificationclick':\n const { action, notification } = data\n\n // TODO how to follow action with notification.data\n notification.url && route(notification.url)\n break\n\n case 'show-reload-snackbar':\n notify({\n level: 'info',\n message: i18next.t('text.the application has been updated'),\n option: {\n action: {\n label: i18next.t('button.reload'),\n callback: () => window.location.reload()\n },\n timer: -1\n }\n })\n break\n\n case 'notification':\n default:\n onnotification()\n }\n })\n\n document.addEventListener('notify', (event: Event) => {\n let { message, level, ex = '', option = {} } = (event as CustomEvent).detail\n const title = message.split(' .\\n')[0]\n\n if (level === 'error') {\n onnotification({\n timestamp: Date.now(),\n type: 'ERROR',\n title,\n body: ex ? ex.message : message\n })\n }\n })\n\n await onnotification()\n}\n"]}
|