make notification clickable to open chat

This commit is contained in:
marlon-erler
2026-04-01 19:14:42 +00:00
parent 3bd0287517
commit b7373e909f
4 changed files with 38 additions and 4 deletions
+16 -1
View File
@@ -3155,6 +3155,16 @@
this.messagesInMarquee.push(notification); this.messagesInMarquee.push(notification);
this.startLoop(); this.startLoop();
}; };
this.openNotification = () => {
const notification = this.marquee.value;
if (notification == void 0) return;
const chat = [
...this.chatListViewModel.chatViewModels.value.values()
].find(
(chat2) => chat2.chatModel.info.primaryChannel == notification.chat
);
chat.open();
};
// loop // loop
this.loop = () => { this.loop = () => {
if (this.messagesInMarquee.length == 0) { if (this.messagesInMarquee.length == 0) {
@@ -3176,6 +3186,10 @@
clearInterval(this.interval); clearInterval(this.interval);
this.interval = void 0; this.interval = void 0;
}; };
this.skipLoop = () => {
this.stopLoop();
this.startLoop();
};
this.chatListViewModel = chatListViewModel2; this.chatListViewModel = chatListViewModel2;
} }
// util // util
@@ -3246,6 +3260,7 @@
// view // view
this.openChat = (chatViewModel) => { this.openChat = (chatViewModel) => {
this.selectedChat.value = chatViewModel; this.selectedChat.value = chatViewModel;
this.notificationViewModel.skipLoop();
}; };
this.closeChat = () => { this.closeChat = () => {
this.selectedChat.value = void 0; this.selectedChat.value = void 0;
@@ -4623,7 +4638,7 @@
() => { () => {
const value = chatViewModel.notificationViewModel.marquee.value; const value = chatViewModel.notificationViewModel.marquee.value;
if (value == void 0) return /* @__PURE__ */ createElement("span", null); if (value == void 0) return /* @__PURE__ */ createElement("span", null);
return /* @__PURE__ */ createElement("span", null, /* @__PURE__ */ createElement("b", null, value.sender), /* @__PURE__ */ createElement("span", { class: "secondary" }, value.chat, ": "), /* @__PURE__ */ createElement("span", null, value.body)); return /* @__PURE__ */ createElement("span", { "on:click": chatViewModel.notificationViewModel.openNotification }, /* @__PURE__ */ createElement("b", null, value.sender), /* @__PURE__ */ createElement("span", { class: "secondary" }, value.chat, ": "), /* @__PURE__ */ createElement("span", null, value.body));
} }
); );
return /* @__PURE__ */ createElement( return /* @__PURE__ */ createElement(
+1 -1
View File
@@ -40,7 +40,7 @@ export function ChatPage(chatViewModel: ChatViewModel) {
const value = chatViewModel.notificationViewModel.marquee.value; const value = chatViewModel.notificationViewModel.marquee.value;
if (value == undefined) return <span></span>; if (value == undefined) return <span></span>;
return ( return (
<span> <span on:click={chatViewModel.notificationViewModel.openNotification}>
<b>{value.sender}</b> <b>{value.sender}</b>
<span class="secondary">{value.chat}: </span> <span class="secondary">{value.chat}: </span>
<span>{value.body}</span> <span>{value.body}</span>
+1 -1
View File
@@ -9,7 +9,6 @@ import SettingsViewModel from "../Global/settingsViewModel";
import StorageModel from "../../Model/Global/storageModel"; import StorageModel from "../../Model/Global/storageModel";
import ConnectionViewModel from "../Global/connectionViewModel"; import ConnectionViewModel from "../Global/connectionViewModel";
import NotificationViewModel from "../Global/notificationViewModel"; import NotificationViewModel from "../Global/notificationViewModel";
import NotificationModel from "../../Model/Global/notificationModel";
export default class ChatListViewModel { export default class ChatListViewModel {
storageModel: StorageModel; storageModel: StorageModel;
@@ -82,6 +81,7 @@ export default class ChatListViewModel {
// view // view
openChat = (chatViewModel: ChatViewModel): void => { openChat = (chatViewModel: ChatViewModel): void => {
this.selectedChat.value = chatViewModel; this.selectedChat.value = chatViewModel;
this.notificationViewModel.skipLoop();
}; };
closeChat = (): void => { closeChat = (): void => {
+20 -1
View File
@@ -17,13 +17,27 @@ export default class NotificationViewModel {
const notification = NotificationViewModel.createNotification(message); const notification = NotificationViewModel.createNotification(message);
if (this.seenMessageIds.has(message.id)) return; if (this.seenMessageIds.has(message.id)) return;
const currentChat = this.chatListViewModel.selectedChat.value.chatModel.info.primaryChannel; const currentChat =
this.chatListViewModel.selectedChat.value.chatModel.info
.primaryChannel;
if (notification.chat == currentChat) return; if (notification.chat == currentChat) return;
this.messagesInMarquee.push(notification); this.messagesInMarquee.push(notification);
this.startLoop(); this.startLoop();
}; };
openNotification = () => {
const notification = this.marquee.value;
if (notification == undefined) return;
const chat = [
...this.chatListViewModel.chatViewModels.value.values(),
].find(
(chat) => chat.chatModel.info.primaryChannel == notification.chat,
);
chat.open();
};
// loop // loop
loop = () => { loop = () => {
if (this.messagesInMarquee.length == 0) { if (this.messagesInMarquee.length == 0) {
@@ -50,6 +64,11 @@ export default class NotificationViewModel {
this.interval = undefined; this.interval = undefined;
}; };
skipLoop = () => {
this.stopLoop();
this.startLoop();
}
// init // init
constructor(chatListViewModel: ChatListViewModel) { constructor(chatListViewModel: ChatListViewModel) {
this.chatListViewModel = chatListViewModel; this.chatListViewModel = chatListViewModel;