mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 11:35:04 +01:00
fix reloading or opening wrong page when clicking notif
This commit is contained in:
parent
f4bb95f459
commit
3767060632
@ -196,12 +196,13 @@ async function openClientFromNotif(event) {
|
|||||||
const {sessionId, roomId} = event.notification.data;
|
const {sessionId, roomId} = event.notification.data;
|
||||||
const sessionHash = `#/session/${sessionId}`;
|
const sessionHash = `#/session/${sessionId}`;
|
||||||
const roomHash = `${sessionHash}/room/${roomId}`;
|
const roomHash = `${sessionHash}/room/${roomId}`;
|
||||||
const roomURL = `/${roomHash}`;
|
|
||||||
const clientWithSession = await findClient(async client => {
|
const clientWithSession = await findClient(async client => {
|
||||||
return await sendAndWaitForReply(client, "hasSessionOpen", {sessionId});
|
return await sendAndWaitForReply(client, "hasSessionOpen", {sessionId});
|
||||||
});
|
});
|
||||||
if (clientWithSession) {
|
if (clientWithSession) {
|
||||||
console.log("notificationclick: client has session open, showing room there");
|
console.log("notificationclick: client has session open, showing room there");
|
||||||
|
// just change the hash, so the page doesn't refresh on / vs /index.html
|
||||||
|
const roomURL = new URL(roomHash, clientWithSession.url).href;
|
||||||
clientWithSession.navigate(roomURL);
|
clientWithSession.navigate(roomURL);
|
||||||
if ('focus' in clientWithSession) {
|
if ('focus' in clientWithSession) {
|
||||||
try {
|
try {
|
||||||
@ -210,6 +211,7 @@ async function openClientFromNotif(event) {
|
|||||||
}
|
}
|
||||||
} else if (self.clients.openWindow) {
|
} else if (self.clients.openWindow) {
|
||||||
console.log("notificationclick: no client found with session open, opening new window");
|
console.log("notificationclick: no client found with session open, opening new window");
|
||||||
|
const roomURL = new URL(`./${roomHash}`, baseURL).href;
|
||||||
await self.clients.openWindow(roomURL);
|
await self.clients.openWindow(roomURL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user