From f742dc6a6535d4661e3bcdde48a5a88ca7c92330 Mon Sep 17 00:00:00 2001 From: JatinBumbra Date: Fri, 1 Jul 2022 23:22:22 +0530 Subject: [PATCH 1/6] Timout if dashboard fails to start, show an alert. Implement a generic channel to listen request to open external links --- shared/react-components/ExternalLink.tsx | 31 ++++++++++ src/@types/generic.ts | 5 ++ src/@types/ipc_channels.ts | 3 +- src/dashboard/bridge.ts | 14 ++--- src/dashboard/index.ts | 31 ++++------ src/dashboard/ui/App.tsx | 28 +++++++++- .../ui/components/DashboardTitle.tsx | 8 ++- .../ui/components/DashboardUpdateAlert.tsx | 4 +- src/dashboard/ui/components/TimeoutAlert.tsx | 56 +++++++++++++++++++ 9 files changed, 144 insertions(+), 36 deletions(-) create mode 100644 shared/react-components/ExternalLink.tsx create mode 100644 src/dashboard/ui/components/TimeoutAlert.tsx diff --git a/shared/react-components/ExternalLink.tsx b/shared/react-components/ExternalLink.tsx new file mode 100644 index 0000000..36edb59 --- /dev/null +++ b/shared/react-components/ExternalLink.tsx @@ -0,0 +1,31 @@ +import { ReactEventHandler } from 'react' +// MUI +import { TypographyVariant } from '@mui/material' +import Typography from '@mui/material/Typography' + +const ExternalLink = ({ + children, + variant = 'body1', + onClick, +}: { + children: string + variant?: TypographyVariant + onClick: ReactEventHandler +}) => { + return ( + + {children} + + ) +} + +export default ExternalLink diff --git a/src/@types/generic.ts b/src/@types/generic.ts index 14a0b35..d516015 100644 --- a/src/@types/generic.ts +++ b/src/@types/generic.ts @@ -58,3 +58,8 @@ export type GithubRelease = { browser_download_url: string // eslint-disable-line camelcase }> } + +export interface StartTimeoutState { + isTimedOut: boolean + isSet: boolean +} diff --git a/src/@types/ipc_channels.ts b/src/@types/ipc_channels.ts index 033b5b3..298c44e 100644 --- a/src/@types/ipc_channels.ts +++ b/src/@types/ipc_channels.ts @@ -22,6 +22,7 @@ export enum GenericChannelsEnum { check_for_updates = 'generic:check_for_updates', get_identifier = 'generic:get_identifier', minimize_window = 'generic:minimize_window', + open_external_link = 'generic:open_external_link', } export enum DashboardChannelsEnum { @@ -30,8 +31,6 @@ export enum DashboardChannelsEnum { get_version = 'dashboard:get_version', check_for_updates = 'dashboard:check_for_updates', log_out = 'dashboard:log_out', - open_download_link = 'dashboard:open_download_link', - open_feedback_link = 'dashboard:open_feedback_link', } export enum FirefoxChannelsEnum { diff --git a/src/dashboard/bridge.ts b/src/dashboard/bridge.ts index 3dfce2d..71a554f 100644 --- a/src/dashboard/bridge.ts +++ b/src/dashboard/bridge.ts @@ -1,15 +1,13 @@ +import { contextBridge, ipcRenderer } from 'electron' +// Types import { BountyChannelsEnum, DashboardChannelsEnum, UninstallerChannelsEnum, -} from './../@types/ipc_channels' -import { contextBridge, ipcRenderer } from 'electron' -// Types -import { FirefoxChannelsEnum, GenericChannelsEnum, NodeChannelsEnum, -} from '../@types/ipc_channels' +} from './../@types/ipc_channels' declare global { // eslint-disable-next-line @@ -28,10 +26,6 @@ export const api = { getDashboardVersion: () => ipcRenderer.send(DashboardChannelsEnum.get_version), logOut: () => ipcRenderer.send(DashboardChannelsEnum.log_out), - openFeedbackLink: () => - ipcRenderer.send(DashboardChannelsEnum.open_feedback_link), - openDashboardDownloadLink: () => - ipcRenderer.send(DashboardChannelsEnum.open_download_link), // Node getIdentityInfo: () => ipcRenderer.send(NodeChannelsEnum.get_identity), pingNode: () => ipcRenderer.send(NodeChannelsEnum.running_status), @@ -43,6 +37,8 @@ export const api = { getFirefoxVersion: () => ipcRenderer.send(FirefoxChannelsEnum.get_version), launchBrowser: () => ipcRenderer.send(FirefoxChannelsEnum.launch), // Generic + openExternalLink: (link: string) => + ipcRenderer.send(GenericChannelsEnum.open_external_link, link), getIndentifier: () => ipcRenderer.send(GenericChannelsEnum.get_identifier), checkForUpdates: () => ipcRenderer.send(GenericChannelsEnum.check_for_updates), diff --git a/src/dashboard/index.ts b/src/dashboard/index.ts index c99b33c..c8580a1 100644 --- a/src/dashboard/index.ts +++ b/src/dashboard/index.ts @@ -95,26 +95,6 @@ export default function (isExplicitRun = false) { }, }, // Dashboard channels - { - channel: DashboardChannelsEnum.open_feedback_link, - listener() { - try { - shell.openExternal('https://pointnetwork.io/support') - } catch (error) { - logger.error(error) - } - }, - }, - { - channel: DashboardChannelsEnum.open_download_link, - listener() { - try { - shell.openExternal('https://pointnetwork.io/download') - } catch (error) { - logger.error(error) - } - }, - }, { channel: DashboardChannelsEnum.log_out, async listener() { @@ -296,6 +276,17 @@ export default function (isExplicitRun = false) { ) }, }, + { + channel: GenericChannelsEnum.open_external_link, + // @ts-ignore + listener(_, link: string) { + try { + shell.openExternal(link) + } catch (error) { + logger.error(ErrorsEnum.DASHBOARD_ERROR, error) + } + }, + }, { channel: GenericChannelsEnum.check_for_updates, async listener() { diff --git a/src/dashboard/ui/App.tsx b/src/dashboard/ui/App.tsx index 849ee47..50e8943 100644 --- a/src/dashboard/ui/App.tsx +++ b/src/dashboard/ui/App.tsx @@ -11,6 +11,7 @@ import ResourceItemCard from './components/ResourceItemCard' import TopBar from './components/TopBar' import UIThemeProvider from '../../../shared/react-components/UIThemeProvider' import WalletInfo from './components/WalletInfo' +import DashboardUpdateAlert from './components/DashboardUpdateAlert' // Types import { DashboardChannelsEnum, @@ -19,11 +20,15 @@ import { NodeChannelsEnum, UninstallerChannelsEnum, } from '../../@types/ipc_channels' -import { LaunchProcessLog, IsUpdatingState } from '../../@types/generic' +import { + LaunchProcessLog, + IsUpdatingState, + StartTimeoutState, +} from '../../@types/generic' // Icons import { ReactComponent as FirefoxLogo } from '../../../assets/firefox-logo.svg' import { ReactComponent as PointLogo } from '../../../assets/point-logo.svg' -import DashboardUpdateAlert from './components/DashboardUpdateAlert' +import TimeoutAlert from './components/TimeoutAlert' const App = () => { const [identifier, setIdentifier] = useState('') @@ -37,6 +42,10 @@ const App = () => { pointsdk: true, }) // Running state variables + const [startTimeout, setStartTimeout] = useState({ + isTimedOut: false, + isSet: false, + }) const [loader, setIsLaunching] = useState<{ isLoading: boolean message: string @@ -64,11 +73,12 @@ const App = () => { // 4. Once browser is running, we finish the launch procedure useEffect(() => { - if (isBrowserRunning) + if (isBrowserRunning) { setIsLaunching({ isLoading: false, message: 'Launched', }) + } }, [isBrowserRunning]) // Register these events once to prevent leaks @@ -83,6 +93,17 @@ const App = () => { if (!parsed.isRunning) { setTimeout(window.Dashboard.launchNodeAndPing, 2000) + if (!startTimeout.isSet) { + setStartTimeout(prev => ({ ...prev, isSet: true })) + setTimeout(() => { + if (isNodeRunning) + setStartTimeout({ isSet: false, isTimedOut: false }) + else { + setIsLaunching({ isLoading: false, message: '' }) + setStartTimeout({ isSet: false, isTimedOut: true }) + } + }, 30000) + } } }) @@ -130,6 +151,7 @@ const App = () => { + { open={isHelpMenuOpen} onClose={closeHelpMenu} > - + + window.Dashboard.openExternalLink( + 'https://pointnetwork.io/support' + ) + } + > Help & Feedback diff --git a/src/dashboard/ui/components/DashboardUpdateAlert.tsx b/src/dashboard/ui/components/DashboardUpdateAlert.tsx index e0b302c..f00788e 100644 --- a/src/dashboard/ui/components/DashboardUpdateAlert.tsx +++ b/src/dashboard/ui/components/DashboardUpdateAlert.tsx @@ -29,7 +29,9 @@ const DashboardUpdateAlert = () => { Click{' '} + window.Dashboard.openExternalLink('https://pointnetwork.io/download') + } > here {' '} diff --git a/src/dashboard/ui/components/TimeoutAlert.tsx b/src/dashboard/ui/components/TimeoutAlert.tsx new file mode 100644 index 0000000..5bc8689 --- /dev/null +++ b/src/dashboard/ui/components/TimeoutAlert.tsx @@ -0,0 +1,56 @@ +// MUI +import Box from '@mui/material/Box' +import Button from '@mui/material/Button' +import Dialog from '@mui/material/Dialog' +import Typography from '@mui/material/Typography' +// Components +import ExternalLink from '../../../../shared/react-components/ExternalLink' +// Types +import { StartTimeoutState } from '../../../@types/generic' + +const TimeoutAlert = ({ + startTimeout, +}: { + startTimeout: StartTimeoutState +}) => { + return ( + + + + Failed to start Point. Please, close and reopen the dashboard. If the + problem persists, contact the support team on{' '} + + window.Dashboard.openExternalLink( + 'https://discord.com/invite/DkH6zxCXWz' + ) + } + > + Discord + {' '} + or{' '} + + window.Dashboard.openExternalLink('https://t.me/pointnetworkchat') + } + > + Telegram + + + + + + + + ) +} + +export default TimeoutAlert From a1fc8f25392591e0d76ce0842d01c405019fbdfa Mon Sep 17 00:00:00 2001 From: JatinBumbra Date: Mon, 4 Jul 2022 10:28:03 +0530 Subject: [PATCH 2/6] Fix dashboard update alert bug --- src/dashboard/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dashboard/index.ts b/src/dashboard/index.ts index c8580a1..ad0c7df 100644 --- a/src/dashboard/index.ts +++ b/src/dashboard/index.ts @@ -302,7 +302,7 @@ export default function (isExplicitRun = false) { const installedDashboardV = await helpers.getInstalledDashboardVersion() - if (latestDashboardV !== installedDashboardV) + if (latestDashboardV !== `v${installedDashboardV}`) window?.webContents.send( DashboardChannelsEnum.check_for_updates, JSON.stringify({ From 3e1c5747c565b32a6208b649cfbf85f8cb0add27 Mon Sep 17 00:00:00 2001 From: JatinBumbra Date: Mon, 4 Jul 2022 10:57:21 +0530 Subject: [PATCH 3/6] Add try/catch to logger sendToChannel --- shared/logger.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/shared/logger.ts b/shared/logger.ts index 46fba5a..5146ead 100644 --- a/shared/logger.ts +++ b/shared/logger.ts @@ -47,17 +47,17 @@ export default class Logger { } info = (...log: string[]) => { - // TODO: Add back SYSTEM_INFO or find a better way to log it only once logger.info(`[${this.module}]`, ...log) } error = (...err: any[]) => { - // TODO: Add back SYSTEM_INFO or find a better way to log it only once logger.error(`[${this.module}]`, ...err) } sendToChannel = ({ channel, log }: { channel: string; log: string }) => { - this.window?.webContents.send(channel, log) + try { + this.window?.webContents.send(channel, log) + } catch (error) {} } sendMetric = (payload: Record) => { From 5cce8a09239f2937e9b4aed0e54998fd068d1193 Mon Sep 17 00:00:00 2001 From: JatinBumbra Date: Mon, 4 Jul 2022 11:02:01 +0530 Subject: [PATCH 4/6] Add check for the lastCheck key in updates --- src/firefox/index.ts | 1 + src/node/index.ts | 1 + src/pointsdk/index.ts | 5 +++-- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/firefox/index.ts b/src/firefox/index.ts index 4ee0ec1..13821c3 100644 --- a/src/firefox/index.ts +++ b/src/firefox/index.ts @@ -275,6 +275,7 @@ class Firefox { if ( isBinMissing || + !installInfo.lastCheck || (moment().diff(moment.unix(installInfo.lastCheck), 'hours') >= 1 && installInfo.installedReleaseVersion !== latestVersion) ) { diff --git a/src/node/index.ts b/src/node/index.ts index 68df568..53ebbf8 100644 --- a/src/node/index.ts +++ b/src/node/index.ts @@ -289,6 +289,7 @@ class Node { if ( isBinMissing || + !installInfo.lastCheck || (moment().diff(moment.unix(installInfo.lastCheck), 'hours') >= 1 && installInfo.installedReleaseVersion !== latestVersion) ) { diff --git a/src/pointsdk/index.ts b/src/pointsdk/index.ts index fcefb03..6f79426 100644 --- a/src/pointsdk/index.ts +++ b/src/pointsdk/index.ts @@ -131,8 +131,9 @@ class PointSDK { const latestVersion = await this.getLatestVersion() if ( - moment().diff(moment.unix(installInfo.lastCheck), 'hours') >= 1 && - installInfo.installedReleaseVersion !== latestVersion + !installInfo.lastCheck || + (moment().diff(moment.unix(installInfo.lastCheck), 'hours') >= 1 && + installInfo.installedReleaseVersion !== latestVersion) ) { this.logger.info('Update available') this.logger.sendToChannel({ From c8b0a3b0a3e3a625fbfb212af21ad917c7c7b06f Mon Sep 17 00:00:00 2001 From: JatinBumbra Date: Mon, 4 Jul 2022 15:45:53 +0530 Subject: [PATCH 5/6] Return identity info object from the getIdentity method --- src/node/index.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/node/index.ts b/src/node/index.ts index 53ebbf8..a3c363b 100644 --- a/src/node/index.ts +++ b/src/node/index.ts @@ -324,7 +324,7 @@ class Node { /** * Returns the identity currently active on Point Node */ - async getIdentityInfo() { + async getIdentityInfo(): Promise<{ address: string; identity: string }> { this.logger.info('Getting identity') this.logger.sendToChannel({ channel: NodeChannelsEnum.get_identity, @@ -342,16 +342,18 @@ class Node { res = await axios.get( `http://localhost:2468/v1/api/identity/ownerToIdentity/${address}` ) + const identity = res.data.data.identity this.logger.info('Fetched identity') this.logger.sendToChannel({ channel: NodeChannelsEnum.get_identity, log: JSON.stringify({ isFetching: false, address, - identity: res.data.data.identity, + identity, log: 'Identity fetched', } as IdentityLog), }) + return { address, identity } } catch (e) { this.logger.error(ErrorsEnum.NODE_ERROR, e) throw e From bcb1567a50f04b7810ffae2763907de04453748e Mon Sep 17 00:00:00 2001 From: JatinBumbra Date: Mon, 4 Jul 2022 15:48:50 +0530 Subject: [PATCH 6/6] Add WS connection to the notifications server --- package-lock.json | 105 ++++++++++++++++++++++++++--------------- package.json | 3 +- src/dashboard/index.ts | 19 +++++++- yarn.lock | 16 +++---- 4 files changed, 95 insertions(+), 48 deletions(-) diff --git a/package-lock.json b/package-lock.json index afeb882..d68ef74 100644 --- a/package-lock.json +++ b/package-lock.json @@ -44,7 +44,8 @@ "tar-fs": "^2.1.1", "unbzip2-stream": "^1.4.3", "web-ext": "^6.7.0", - "which": "^2.0.2" + "which": "^2.0.2", + "ws": "^8.8.0" }, "devDependencies": { "@babel/core": "7.17.2", @@ -12761,6 +12762,27 @@ "express": "^4.0.0 || ^5.0.0-alpha.1" } }, + "node_modules/express-ws/node_modules/ws": { + "version": "7.5.8", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.8.tgz", + "integrity": "sha512-ri1Id1WinAX5Jqn9HejiGb8crfRio0Qgu8+MtL36rlTA6RLsMdWt1Az/19A2Qij6uSHUMphEFaTKa4WG+UNHNw==", + "dev": true, + "engines": { + "node": ">=8.3.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": "^5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + }, "node_modules/express/node_modules/debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", @@ -18176,6 +18198,27 @@ "node": ">=0.4.0" } }, + "node_modules/jsdom/node_modules/ws": { + "version": "7.5.8", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.8.tgz", + "integrity": "sha512-ri1Id1WinAX5Jqn9HejiGb8crfRio0Qgu8+MtL36rlTA6RLsMdWt1Az/19A2Qij6uSHUMphEFaTKa4WG+UNHNw==", + "dev": true, + "engines": { + "node": ">=8.3.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": "^5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + }, "node_modules/jsesc": { "version": "2.5.2", "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", @@ -28272,27 +28315,6 @@ "url": "https://opencollective.com/webpack" } }, - "node_modules/webpack-dev-server/node_modules/ws": { - "version": "8.6.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.6.0.tgz", - "integrity": "sha512-AzmM3aH3gk0aX7/rZLYvjdvZooofDu3fFOzGqcSnQ1tOcTWwhM/o+q++E8mAyVVIyUdajrkzWUGftaVSDLn1bw==", - "dev": true, - "engines": { - "node": ">=10.0.0" - }, - "peerDependencies": { - "bufferutil": "^4.0.1", - "utf-8-validate": "^5.0.2" - }, - "peerDependenciesMeta": { - "bufferutil": { - "optional": true - }, - "utf-8-validate": { - "optional": true - } - } - }, "node_modules/webpack-merge": { "version": "5.8.0", "resolved": "https://registry.npmjs.org/webpack-merge/-/webpack-merge-5.8.0.tgz", @@ -28563,12 +28585,11 @@ } }, "node_modules/ws": { - "version": "7.5.7", - "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.7.tgz", - "integrity": "sha512-KMvVuFzpKBuiIXW3E4u3mySRO2/mCHSyZDJQM5NQ9Q9KHWHWh0NHgfbRMLLrceUK5qAL4ytALJbpRMjixFZh8A==", - "dev": true, + "version": "8.8.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.8.0.tgz", + "integrity": "sha512-JDAgSYQ1ksuwqfChJusw1LSJ8BizJ2e/vVu5Lxjq3YvNJNlROv1ui4i+c/kUUrPheBvQl4c5UbERhTwKa6QBJQ==", "engines": { - "node": ">=8.3.0" + "node": ">=10.0.0" }, "peerDependencies": { "bufferutil": "^4.0.1", @@ -38484,6 +38505,15 @@ "dev": true, "requires": { "ws": "^7.4.6" + }, + "dependencies": { + "ws": { + "version": "7.5.8", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.8.tgz", + "integrity": "sha512-ri1Id1WinAX5Jqn9HejiGb8crfRio0Qgu8+MtL36rlTA6RLsMdWt1Az/19A2Qij6uSHUMphEFaTKa4WG+UNHNw==", + "dev": true, + "requires": {} + } } }, "ext-list": { @@ -42592,6 +42622,13 @@ "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.7.0.tgz", "integrity": "sha512-V/LGr1APy+PXIwKebEWrkZPwoeoF+w1jiOBUmuxuiUIaOHtob8Qc9BTrYo7VuI5fR8tqsy+buA2WFooR5olqvQ==", "dev": true + }, + "ws": { + "version": "7.5.8", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.8.tgz", + "integrity": "sha512-ri1Id1WinAX5Jqn9HejiGb8crfRio0Qgu8+MtL36rlTA6RLsMdWt1Az/19A2Qij6uSHUMphEFaTKa4WG+UNHNw==", + "dev": true, + "requires": {} } } }, @@ -50324,13 +50361,6 @@ "ajv-formats": "^2.1.1", "ajv-keywords": "^5.0.0" } - }, - "ws": { - "version": "8.6.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.6.0.tgz", - "integrity": "sha512-AzmM3aH3gk0aX7/rZLYvjdvZooofDu3fFOzGqcSnQ1tOcTWwhM/o+q++E8mAyVVIyUdajrkzWUGftaVSDLn1bw==", - "dev": true, - "requires": {} } } }, @@ -50509,10 +50539,9 @@ } }, "ws": { - "version": "7.5.7", - "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.7.tgz", - "integrity": "sha512-KMvVuFzpKBuiIXW3E4u3mySRO2/mCHSyZDJQM5NQ9Q9KHWHWh0NHgfbRMLLrceUK5qAL4ytALJbpRMjixFZh8A==", - "dev": true, + "version": "8.8.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.8.0.tgz", + "integrity": "sha512-JDAgSYQ1ksuwqfChJusw1LSJ8BizJ2e/vVu5Lxjq3YvNJNlROv1ui4i+c/kUUrPheBvQl4c5UbERhTwKa6QBJQ==", "requires": {} }, "xdg-basedir": { diff --git a/package.json b/package.json index 58fb8fd..2147d48 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,8 @@ "tar-fs": "^2.1.1", "unbzip2-stream": "^1.4.3", "web-ext": "^6.7.0", - "which": "^2.0.2" + "which": "^2.0.2", + "ws": "^8.8.0" }, "devDependencies": { "@babel/core": "7.17.2", diff --git a/src/dashboard/index.ts b/src/dashboard/index.ts index ad0c7df..940b4e8 100644 --- a/src/dashboard/index.ts +++ b/src/dashboard/index.ts @@ -1,5 +1,5 @@ import { UpdateLog } from './../@types/generic' -import { app, BrowserWindow, ipcMain, shell } from 'electron' +import { app, BrowserWindow, ipcMain, shell, Notification } from 'electron' import axios from 'axios' import Bounty from '../bounty' import Firefox from '../firefox' @@ -11,6 +11,7 @@ import helpers from '../../shared/helpers' import welcome from '../welcome' import { getIdentifier } from '../../shared/getIdentifier' import baseWindowConfig from '../../shared/windowConfig' +import WebSocket from 'ws' // Types import { BountyChannelsEnum, @@ -28,6 +29,7 @@ let node: Node | null let firefox: Firefox | null let pointSDK: PointSDK | null let uninstaller: Uninstaller | null +let ws: WebSocket | null declare const DASHBOARD_WINDOW_PRELOAD_WEBPACK_ENTRY: string declare const DASHBOARD_WINDOW_WEBPACK_ENTRY: string @@ -252,6 +254,8 @@ export default function (isExplicitRun = false) { async listener() { try { await node?.ping() + // We connect to WS server once the node is finally running + if (!ws) connectToWsServer() } catch (error) { logger.error(ErrorsEnum.DASHBOARD_ERROR, error) } @@ -337,6 +341,19 @@ export default function (isExplicitRun = false) { }) } + async function connectToWsServer() { + const { address } = await node?.getIdentityInfo()! + ws = new WebSocket(`ws://localhost:8080/ws?address=${address}`) + logger.info('Connected to Point Notifications websocket server') + ws.on('message', (message: string) => { + const { title, body } = JSON.parse(message) + new Notification({ + title, + body, + }).show() + }) + } + if (isExplicitRun) { createWindow() registerListeners() diff --git a/yarn.lock b/yarn.lock index b5926f2..e0eff70 100644 --- a/yarn.lock +++ b/yarn.lock @@ -13853,14 +13853,14 @@ "signal-exit" "^3.0.7" "ws@^7.4.6": - "integrity" "sha512-KMvVuFzpKBuiIXW3E4u3mySRO2/mCHSyZDJQM5NQ9Q9KHWHWh0NHgfbRMLLrceUK5qAL4ytALJbpRMjixFZh8A==" - "resolved" "https://registry.npmjs.org/ws/-/ws-7.5.7.tgz" - "version" "7.5.7" - -"ws@^8.4.2": - "integrity" "sha512-AzmM3aH3gk0aX7/rZLYvjdvZooofDu3fFOzGqcSnQ1tOcTWwhM/o+q++E8mAyVVIyUdajrkzWUGftaVSDLn1bw==" - "resolved" "https://registry.npmjs.org/ws/-/ws-8.6.0.tgz" - "version" "8.6.0" + "integrity" "sha512-ri1Id1WinAX5Jqn9HejiGb8crfRio0Qgu8+MtL36rlTA6RLsMdWt1Az/19A2Qij6uSHUMphEFaTKa4WG+UNHNw==" + "resolved" "https://registry.npmjs.org/ws/-/ws-7.5.8.tgz" + "version" "7.5.8" + +"ws@^8.4.2", "ws@^8.8.0": + "integrity" "sha512-JDAgSYQ1ksuwqfChJusw1LSJ8BizJ2e/vVu5Lxjq3YvNJNlROv1ui4i+c/kUUrPheBvQl4c5UbERhTwKa6QBJQ==" + "resolved" "https://registry.npmjs.org/ws/-/ws-8.8.0.tgz" + "version" "8.8.0" "ws@7.4.6": "integrity" "sha512-YmhHDO4MzaDLB+M9ym/mDA5z0naX8j7SIlT8f8z+I0VtzsRbekxEutHSme7NPS2qE8StCYQNUnfWdXta/Yu85A=="