From b68c38bbc80c88cbc9cd052c47d2034ebf53bbeb Mon Sep 17 00:00:00 2001 From: Denis Gao Date: Thu, 28 Oct 2021 21:07:48 -0400 Subject: [PATCH] First Commit --- web-basic-sample/.eslintrc.js | 2 +- web-basic-sample/src/js/const.js | 2 +- web-basic-sample/src/js/main.js | 4 ++++ web-basic-sample/src/js/utils.js | 26 ++++++++++++++++++++++++++ 4 files changed, 32 insertions(+), 2 deletions(-) diff --git a/web-basic-sample/.eslintrc.js b/web-basic-sample/.eslintrc.js index 0211a4b2..600ee67a 100644 --- a/web-basic-sample/.eslintrc.js +++ b/web-basic-sample/.eslintrc.js @@ -10,7 +10,7 @@ module.exports = { sourceType: 'module' }, rules: { - 'linebreak-style': ['error', 'unix'], + 'linebreak-style': ['error', 'windows'], quotes: ['warn', 'single'], semi: ['warn', 'always'], 'no-console': 1, diff --git a/web-basic-sample/src/js/const.js b/web-basic-sample/src/js/const.js index 6954d419..43bd40a5 100644 --- a/web-basic-sample/src/js/const.js +++ b/web-basic-sample/src/js/const.js @@ -1,4 +1,4 @@ -export const APP_ID = '9DA1B1F4-0BE6-4DA8-82C5-2E81DAB56F23'; +export const APP_ID = 'C9C493CF-0BD3-472F-9E24-F1D0B31FAC78'; export const USER_ID = 'user_id'; export const DISPLAY_NONE = 'none'; export const DISPLAY_BLOCK = 'block'; diff --git a/web-basic-sample/src/js/main.js b/web-basic-sample/src/js/main.js index 679d42a8..62138d93 100644 --- a/web-basic-sample/src/js/main.js +++ b/web-basic-sample/src/js/main.js @@ -7,6 +7,7 @@ import { body, UPDATE_INTERVAL_TIME } from './const'; import { SendBirdConnection } from './SendBirdConnection'; import { SendBirdEvent } from './SendBirdEvent'; import { LeftListItem } from './components/LeftListItem'; +import { notify } from './utils'; const sb = new SendBirdAction(); @@ -98,6 +99,9 @@ document.addEventListener('DOMContentLoaded', () => { updateGroupChannelTime(); chatLeft.getGroupChannelList(true); }) + .then(()=>{ + notify('Welcome to the Team!'); + }) .catch(() => { redirectToIndex('SendBird connection failed.'); }); diff --git a/web-basic-sample/src/js/utils.js b/web-basic-sample/src/js/utils.js index 3ce548de..f5dc6cca 100644 --- a/web-basic-sample/src/js/utils.js +++ b/web-basic-sample/src/js/utils.js @@ -177,3 +177,29 @@ export const protectFromXSS = text => { .replace(/\'/g, ''') : text; }; + +export const notify = (message) => { + // Let's check if the browser supports notifications + if (!('Notification' in window)) { + alert('This browser does not support desktop notification'); + } + + // Let's check whether notification permissions have already been granted + else if (Notification.permission === 'granted') { + // If it's okay let's create a notification + var notification = new Notification(message); + } + + // Otherwise, we need to ask the user for permission + else if (Notification.permission !== 'denied') { + Notification.requestPermission().then(function (permission) { + // If the user accepts, let's create a notification + if (permission === 'granted') { + var notification = new Notification(message); + } + }); + } + + // At last, if the user has denied notifications, and you + // want to be respectful there is no need to bother them any more. +} \ No newline at end of file