feat: add notifications system with bell badge, polling, Directus flows, and webhook integration
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import { i18n } from '../i18n.js'
|
||||
|
||||
const POW_SERVER = 'https://pow.dgray.io'
|
||||
|
||||
let modalScriptLoaded = false
|
||||
@@ -80,7 +82,8 @@ export async function openCheckout(invoiceId) {
|
||||
resolve(lastStatus || 'unknown')
|
||||
})
|
||||
|
||||
window.btcpay.showInvoice(invoiceId)
|
||||
const lang = i18n.getLocale() || 'en'
|
||||
window.btcpay.showInvoice(invoiceId, { lang })
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -114,9 +114,10 @@ class DirectusService {
|
||||
document.addEventListener('visibilitychange', () => {
|
||||
if (document.visibilityState === 'visible' && this.refreshToken) {
|
||||
const timeLeft = this.tokenExpiry - Date.now()
|
||||
if (timeLeft < 60000) {
|
||||
if (timeLeft < 120000) {
|
||||
this.refreshSession()
|
||||
}
|
||||
this.scheduleTokenRefresh()
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -280,7 +281,7 @@ class DirectusService {
|
||||
this.clearTokens()
|
||||
}
|
||||
|
||||
async refreshSession() {
|
||||
async refreshSession(_retryCount = 0) {
|
||||
if (!this.refreshToken) return false
|
||||
|
||||
try {
|
||||
@@ -298,6 +299,10 @@ class DirectusService {
|
||||
return true
|
||||
}
|
||||
} catch (e) {
|
||||
if (_retryCount < 2) {
|
||||
await new Promise(r => setTimeout(r, 2000))
|
||||
return this.refreshSession(_retryCount + 1)
|
||||
}
|
||||
this.clearTokens()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user