@ -1,4 +1,4 @@
const { AppSubUrl , csrf , N otificationSettings} = window . config ;
const { appSubUrl , csrfToken , n otificationSettings} = window . config ;
let notificationSequenceNumber = 0 ;
@ -47,7 +47,7 @@ export async function initNotificationCount() {
return ;
}
if ( N otificationSettings. EventSourceUpdateTime > 0 && ! ! window . EventSource && window . SharedWorker ) {
if ( n otificationSettings. EventSourceUpdateTime > 0 && ! ! window . EventSource && window . SharedWorker ) {
// Try to connect to the event source via the shared worker first
const worker = new SharedWorker ( ` ${ _ _webpack _public _path _ _ } js/eventsource.sharedworker.js ` , 'notification-worker' ) ;
worker . addEventListener ( 'error' , ( event ) => {
@ -58,7 +58,7 @@ export async function initNotificationCount() {
} ) ;
worker . port . postMessage ( {
type : 'start' ,
url : ` ${ window . location . origin } ${ A ppSubUrl} /user/events ` ,
url : ` ${ window . location . origin } ${ a ppSubUrl} /user/events ` ,
} ) ;
worker . port . addEventListener ( 'message' , ( event ) => {
if ( ! event . data || ! event . data . type ) {
@ -77,7 +77,7 @@ export async function initNotificationCount() {
type : 'close' ,
} ) ;
worker . port . close ( ) ;
window . location . href = A ppSubUrl;
window . location . href = a ppSubUrl;
} else if ( event . data . type === 'close' ) {
worker . port . postMessage ( {
type : 'close' ,
@ -99,7 +99,7 @@ export async function initNotificationCount() {
return ;
}
if ( N otificationSettings. MinTimeout <= 0 ) {
if ( n otificationSettings. MinTimeout <= 0 ) {
return ;
}
@ -109,13 +109,13 @@ export async function initNotificationCount() {
} , timeout ) ;
} ;
fn ( N otificationSettings. MinTimeout , notificationCount . text ( ) ) ;
fn ( n otificationSettings. MinTimeout , notificationCount . text ( ) ) ;
}
async function updateNotificationCountWithCallback ( callback , timeout , lastCount ) {
const currentCount = $ ( '.notification_count' ) . text ( ) ;
if ( lastCount !== currentCount ) {
callback ( N otificationSettings. MinTimeout , currentCount ) ;
callback ( n otificationSettings. MinTimeout , currentCount ) ;
return ;
}
@ -124,9 +124,9 @@ async function updateNotificationCountWithCallback(callback, timeout, lastCount)
if ( lastCount !== newCount ) {
needsUpdate = true ;
timeout = N otificationSettings. MinTimeout ;
} else if ( timeout < N otificationSettings. MaxTimeout ) {
timeout += N otificationSettings. TimeoutStep ;
timeout = n otificationSettings. MinTimeout ;
} else if ( timeout < n otificationSettings. MaxTimeout ) {
timeout += n otificationSettings. TimeoutStep ;
}
callback ( timeout , newCount ) ;
@ -140,7 +140,7 @@ async function updateNotificationTable() {
if ( notificationDiv . length > 0 ) {
const data = await $ . ajax ( {
type : 'GET' ,
url : ` ${ A ppSubUrl} /notifications? ${ notificationDiv . data ( 'params' ) } ` ,
url : ` ${ a ppSubUrl} /notifications? ${ notificationDiv . data ( 'params' ) } ` ,
data : {
'div-only' : true ,
'sequence-number' : ++ notificationSequenceNumber ,
@ -156,9 +156,9 @@ async function updateNotificationTable() {
async function updateNotificationCount ( ) {
const data = await $ . ajax ( {
type : 'GET' ,
url : ` ${ A ppSubUrl} /api/v1/notifications/new ` ,
url : ` ${ a ppSubUrl} /api/v1/notifications/new ` ,
headers : {
'X-Csrf-Token' : csrf ,
'X-Csrf-Token' : csrfToken ,
} ,
} ) ;
@ -183,7 +183,7 @@ async function updateNotification(url, status, page, q, notificationID) {
type : 'POST' ,
url ,
data : {
_csrf : csrf ,
_csrf : csrfToken ,
notification _id : notificationID ,
status ,
page ,