Skip to content

Commit

Permalink
Test
Browse files Browse the repository at this point in the history
  • Loading branch information
1aerostorm committed Sep 30, 2024
1 parent cd88c72 commit 3d2a3de
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
17 changes: 14 additions & 3 deletions src/utils/NotifyApiClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,19 @@ async function connectNotifyWs() {
notifyWs.addEventListener('open', () => {
notifyWs.isOpen = true
clearTimeout(timeout)
setInterval(() => {
console.log('NOTW', notifyWs.readyState)
//notifyWs.send('_heartbeat')
}, 1000)
resolve()
})

notifyWs.addEventListener('error', () => {
alert('NOTW close')
})

notifyWs.addEventListener('сlose', () => {
alert('NOTW close')
if (!notifyWs.isOpen) {
clearTimeout(timeout)
const err = new Error('notifyWs - cannot connect')
Expand Down Expand Up @@ -200,7 +209,7 @@ export async function notificationSubscribe(account, scopes = 'message,donate_ms
throw new Error('Cannot subscribe');
}

export async function notificationSubscribeWs(account, callback, scopes = 'message,donate_msgs') {
export async function notificationSubscribeWs(account, callback, scopes = 'message,donate_msgs', sidKey = '__subscriber_id') {
if (!notifyWsAvailable()) return null
const xSession = notifySession()
return await new Promise(async (resolve, reject) => {
Expand All @@ -213,6 +222,7 @@ export async function notificationSubscribeWs(account, callback, scopes = 'messa
reject(err)
return
}
window[sidKey] = res.subscriber_id
resolve(res)
}, { event: 'queue', callback})
})
Expand Down Expand Up @@ -341,12 +351,13 @@ export async function sendOffchainMessage(op) {
}
}

if (process.env.BROWSER) {
//if (process.env.BROWSER) {
window.getNotifications = getNotifications;
window.markNotificationRead = markNotificationRead;
window.notificationSubscribe = notificationSubscribe;
window.notificationSubscribeWs = notificationSubscribeWs
window.notificationUnsubscribe = notificationUnsubscribe;
window.notificationShallowUnsubscribe = notificationShallowUnsubscribe
window.notificationTake = notificationTake;
window.queueWatch = queueWatch
}
//}
2 changes: 1 addition & 1 deletion src/utils/ServerApiClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { fetchEx } from 'golos-lib-js/lib/utils'
export function getHost() {
const { location, } = window;
if (process.env.NODE_ENV === 'development') {
return location.protocol + '//'+ location.hostname + ':8089';
return location.protocol + '//'+ location.hostname + ':8088';
}
return location.origin;
}
Expand Down

0 comments on commit 3d2a3de

Please sign in to comment.