fix(desktop): notification token updating
This commit is contained in:
parent
43692c67ee
commit
51e1ece5ae
|
|
@ -117,6 +117,7 @@ function bootstrap() {
|
|||
updateProxy()
|
||||
registerUpdater()
|
||||
registerAppTray()
|
||||
updateNotificationsToken()
|
||||
|
||||
app.on("open-url", (_, url) => {
|
||||
if (mainWindow && !mainWindow.isDestroyed()) {
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ import { registerAppMenu } from "./menu"
|
|||
import type { RendererHandlers } from "./renderer-handlers"
|
||||
import { initializeSentry } from "./sentry"
|
||||
import { router } from "./tipc"
|
||||
import { createMainWindow, getMainWindow } from "./window"
|
||||
import { getMainWindowOrCreate } from "./window"
|
||||
|
||||
if (process.argv.length === 3 && process.argv[2]!.startsWith("follow-dev:")) {
|
||||
process.env.NODE_ENV = "development"
|
||||
|
|
@ -155,10 +155,6 @@ const registerPushNotifications = async () => {
|
|||
const credentials = store.get(credentialsKey)
|
||||
const persistentIds = store.get(persistentIdsKey)
|
||||
|
||||
if (credentials) {
|
||||
updateNotificationsToken(credentials)
|
||||
}
|
||||
|
||||
const instance = new PushReceiver({
|
||||
debug: true,
|
||||
firebase: JSON.parse(env.VITE_FIREBASE_CONFIG),
|
||||
|
|
@ -190,10 +186,7 @@ const registerPushNotifications = async () => {
|
|||
body: data.description,
|
||||
})
|
||||
notification.on("click", () => {
|
||||
let mainWindow = getMainWindow()
|
||||
if (!mainWindow) {
|
||||
mainWindow = createMainWindow()
|
||||
}
|
||||
const mainWindow = getMainWindowOrCreate()
|
||||
mainWindow.restore()
|
||||
mainWindow.focus()
|
||||
const handlers = getRendererHandlers<RendererHandlers>(mainWindow.webContents)
|
||||
|
|
|
|||
|
|
@ -27,10 +27,10 @@ export const updateNotificationsToken = async (newCredentials?: Credentials) =>
|
|||
channel: notificationChannel,
|
||||
},
|
||||
})
|
||||
logger.info("updateNotificationsToken success: ", credentials.fcm.token)
|
||||
} catch (error) {
|
||||
logger.error("updateNotificationsToken error: ", error)
|
||||
}
|
||||
logger.info("updateNotificationsToken success: ", credentials.fcm.token)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue