add marker for unread messages
This commit is contained in:
Vendored
+7
@@ -426,6 +426,13 @@ body[showing-chat] #chat-page-wrapper {
|
|||||||
gap: var(--gap-between-tiles);
|
gap: var(--gap-between-tiles);
|
||||||
grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
|
grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
|
||||||
}
|
}
|
||||||
|
.chat-entry[unread] {
|
||||||
|
border: var(--outline-width) solid black;
|
||||||
|
}
|
||||||
|
.chat-entry[unread]:not(:hover):not(:active) {
|
||||||
|
background: rgb(255, 217, 0) !important;
|
||||||
|
color: black;
|
||||||
|
}
|
||||||
@media (min-width: 640px) {
|
@media (min-width: 640px) {
|
||||||
#home-page #overview-section {
|
#home-page #overview-section {
|
||||||
width: 20rem;
|
width: 20rem;
|
||||||
|
|||||||
Vendored
+22
-2
@@ -1191,6 +1191,8 @@
|
|||||||
if (chatMessage == null) return;
|
if (chatMessage == null) return;
|
||||||
chatMessage.status = "received" /* Received */;
|
chatMessage.status = "received" /* Received */;
|
||||||
this.addMessage(chatMessage);
|
this.addMessage(chatMessage);
|
||||||
|
this.info.hasUnreadMessages = true;
|
||||||
|
this.storeInfo();
|
||||||
};
|
};
|
||||||
handleMessageSent = (chatMessage) => {
|
handleMessageSent = (chatMessage) => {
|
||||||
chatMessage.status = "sent" /* Sent */;
|
chatMessage.status = "sent" /* Sent */;
|
||||||
@@ -1258,6 +1260,10 @@
|
|||||||
subscribe = () => {
|
subscribe = () => {
|
||||||
this.connectionModel.addChannel(this.info.primaryChannel);
|
this.connectionModel.addChannel(this.info.primaryChannel);
|
||||||
};
|
};
|
||||||
|
markUnread = () => {
|
||||||
|
this.info.hasUnreadMessages = false;
|
||||||
|
this.storeInfo();
|
||||||
|
};
|
||||||
// storage
|
// storage
|
||||||
storeInfo = () => {
|
storeInfo = () => {
|
||||||
this.storageModel.writeStringifiable(this.getInfoPath(), this.info);
|
this.storageModel.writeStringifiable(this.getInfoPath(), this.info);
|
||||||
@@ -2424,10 +2430,14 @@
|
|||||||
chatModel.chatMessageHandlerManager.addHandler(
|
chatModel.chatMessageHandlerManager.addHandler(
|
||||||
(chatMessage) => {
|
(chatMessage) => {
|
||||||
this.messagePageViewModel.showChatMessage(chatMessage);
|
this.messagePageViewModel.showChatMessage(chatMessage);
|
||||||
|
if (this.chatListViewModel.selectedChat.value != this) {
|
||||||
|
this.hasUnreadMessages.value = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
this.loadPageSelection();
|
this.loadPageSelection();
|
||||||
this.resetColor();
|
this.resetColor();
|
||||||
|
this.loadInfo();
|
||||||
}
|
}
|
||||||
chatModel;
|
chatModel;
|
||||||
storageModel;
|
storageModel;
|
||||||
@@ -2443,9 +2453,11 @@
|
|||||||
"messages" /* Messages */
|
"messages" /* Messages */
|
||||||
);
|
);
|
||||||
index = new State(0);
|
index = new State(0);
|
||||||
|
hasUnreadMessages = new State(false);
|
||||||
// view
|
// view
|
||||||
open = () => {
|
open = () => {
|
||||||
this.chatListViewModel.openChat(this);
|
this.chatListViewModel.openChat(this);
|
||||||
|
this.markUnread();
|
||||||
};
|
};
|
||||||
close = () => {
|
close = () => {
|
||||||
this.chatListViewModel.closeChat();
|
this.chatListViewModel.closeChat();
|
||||||
@@ -2466,6 +2478,10 @@
|
|||||||
const index = this.chatListViewModel.chatIndexManager.getIndex(this);
|
const index = this.chatListViewModel.chatIndexManager.getIndex(this);
|
||||||
this.index.value = index;
|
this.index.value = index;
|
||||||
};
|
};
|
||||||
|
markUnread = () => {
|
||||||
|
this.hasUnreadMessages.value = false;
|
||||||
|
this.chatModel.markUnread();
|
||||||
|
};
|
||||||
// load
|
// load
|
||||||
loadPageSelection = () => {
|
loadPageSelection = () => {
|
||||||
const path = StorageModel.getPath(
|
const path = StorageModel.getPath(
|
||||||
@@ -2481,6 +2497,9 @@
|
|||||||
this.resetColor();
|
this.resetColor();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
loadInfo = () => {
|
||||||
|
this.hasUnreadMessages.value = this.chatModel.info.hasUnreadMessages;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
// src/ViewModel/Chat/chatListViewModel.ts
|
// src/ViewModel/Chat/chatListViewModel.ts
|
||||||
@@ -4352,10 +4371,11 @@
|
|||||||
const view = /* @__PURE__ */ createElement(
|
const view = /* @__PURE__ */ createElement(
|
||||||
"button",
|
"button",
|
||||||
{
|
{
|
||||||
class: "tile colored-tile",
|
class: "tile colored-tile chat-entry",
|
||||||
"set:color": chatViewModel.settingsPageViewModel.color,
|
"set:color": chatViewModel.settingsPageViewModel.color,
|
||||||
style: "height: 8rem",
|
style: "height: 8rem",
|
||||||
"on:click": chatViewModel.open
|
"on:click": chatViewModel.open,
|
||||||
|
"toggle:unread": chatViewModel.hasUnreadMessages
|
||||||
},
|
},
|
||||||
/* @__PURE__ */ createElement(
|
/* @__PURE__ */ createElement(
|
||||||
"span",
|
"span",
|
||||||
|
|||||||
@@ -83,6 +83,9 @@ export default class ChatModel {
|
|||||||
|
|
||||||
chatMessage.status = ChatMessageStatus.Received;
|
chatMessage.status = ChatMessageStatus.Received;
|
||||||
this.addMessage(chatMessage);
|
this.addMessage(chatMessage);
|
||||||
|
|
||||||
|
this.info.hasUnreadMessages = true;
|
||||||
|
this.storeInfo();
|
||||||
};
|
};
|
||||||
|
|
||||||
handleMessageSent = (chatMessage: ChatMessage): void => {
|
handleMessageSent = (chatMessage: ChatMessage): void => {
|
||||||
@@ -171,6 +174,11 @@ export default class ChatModel {
|
|||||||
this.connectionModel.addChannel(this.info.primaryChannel);
|
this.connectionModel.addChannel(this.info.primaryChannel);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
markUnread = (): void => {
|
||||||
|
this.info.hasUnreadMessages = false;
|
||||||
|
this.storeInfo();
|
||||||
|
}
|
||||||
|
|
||||||
// storage
|
// storage
|
||||||
storeInfo = (): void => {
|
storeInfo = (): void => {
|
||||||
this.storageModel.writeStringifiable(this.getInfoPath(), this.info);
|
this.storageModel.writeStringifiable(this.getInfoPath(), this.info);
|
||||||
|
|||||||
@@ -5,10 +5,11 @@ import ChatViewModel from "../../ViewModel/Chat/chatViewModel";
|
|||||||
export function ChatEntry(chatViewModel: ChatViewModel) {
|
export function ChatEntry(chatViewModel: ChatViewModel) {
|
||||||
const view = (
|
const view = (
|
||||||
<button
|
<button
|
||||||
class="tile colored-tile"
|
class="tile colored-tile chat-entry"
|
||||||
set:color={chatViewModel.settingsPageViewModel.color}
|
set:color={chatViewModel.settingsPageViewModel.color}
|
||||||
style="height: 8rem"
|
style="height: 8rem"
|
||||||
on:click={chatViewModel.open}
|
on:click={chatViewModel.open}
|
||||||
|
toggle:unread={chatViewModel.hasUnreadMessages}
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
class="shadow"
|
class="shadow"
|
||||||
|
|||||||
+12
-1
@@ -31,7 +31,9 @@
|
|||||||
|
|
||||||
#home-page #overview-section,
|
#home-page #overview-section,
|
||||||
#home-page #chat-section {
|
#home-page #chat-section {
|
||||||
padding-bottom: calc(var(--content-padding) + var(--header-height) + var(--safe-area-bottom));
|
padding-bottom: calc(
|
||||||
|
var(--content-padding) + var(--header-height) + var(--safe-area-bottom)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#home-page #chat-grid {
|
#home-page #chat-grid {
|
||||||
@@ -43,6 +45,15 @@
|
|||||||
grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
|
grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.chat-entry[unread] {
|
||||||
|
border: var(--outline-width) solid black;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-entry[unread]:not(:hover):not(:active) {
|
||||||
|
background: rgb(255, 217, 0) !important;
|
||||||
|
color: black;
|
||||||
|
}
|
||||||
|
|
||||||
@media (min-width: 640px) {
|
@media (min-width: 640px) {
|
||||||
#home-page #overview-section {
|
#home-page #overview-section {
|
||||||
width: 20rem;
|
width: 20rem;
|
||||||
|
|||||||
@@ -33,10 +33,12 @@ export default class ChatViewModel {
|
|||||||
);
|
);
|
||||||
|
|
||||||
index: React.State<number> = new React.State(0);
|
index: React.State<number> = new React.State(0);
|
||||||
|
hasUnreadMessages: React.State<boolean> = new React.State(false);
|
||||||
|
|
||||||
// view
|
// view
|
||||||
open = (): void => {
|
open = (): void => {
|
||||||
this.chatListViewModel.openChat(this);
|
this.chatListViewModel.openChat(this);
|
||||||
|
this.markUnread();
|
||||||
};
|
};
|
||||||
|
|
||||||
close = (): void => {
|
close = (): void => {
|
||||||
@@ -64,6 +66,11 @@ export default class ChatViewModel {
|
|||||||
this.index.value = index;
|
this.index.value = index;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
markUnread = (): void => {
|
||||||
|
this.hasUnreadMessages.value = false;
|
||||||
|
this.chatModel.markUnread();
|
||||||
|
};
|
||||||
|
|
||||||
// load
|
// load
|
||||||
loadPageSelection = (): void => {
|
loadPageSelection = (): void => {
|
||||||
const path: string[] = StorageModel.getPath(
|
const path: string[] = StorageModel.getPath(
|
||||||
@@ -81,6 +88,10 @@ export default class ChatViewModel {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
loadInfo = (): void => {
|
||||||
|
this.hasUnreadMessages.value = this.chatModel.info.hasUnreadMessages;
|
||||||
|
};
|
||||||
|
|
||||||
// init
|
// init
|
||||||
constructor(
|
constructor(
|
||||||
public coreViewModel: CoreViewModel,
|
public coreViewModel: CoreViewModel,
|
||||||
@@ -101,7 +112,7 @@ export default class ChatViewModel {
|
|||||||
this.storageModel,
|
this.storageModel,
|
||||||
this.chatModel.fileModel.boardsAndTasksModel.calendarModel,
|
this.chatModel.fileModel.boardsAndTasksModel.calendarModel,
|
||||||
this.chatModel.fileModel.boardsAndTasksModel,
|
this.chatModel.fileModel.boardsAndTasksModel,
|
||||||
this,
|
this
|
||||||
);
|
);
|
||||||
this.taskPageViewModel = new TaskPageViewModel(
|
this.taskPageViewModel = new TaskPageViewModel(
|
||||||
this.coreViewModel,
|
this.coreViewModel,
|
||||||
@@ -122,12 +133,17 @@ export default class ChatViewModel {
|
|||||||
chatModel.chatMessageHandlerManager.addHandler(
|
chatModel.chatMessageHandlerManager.addHandler(
|
||||||
(chatMessage: ChatMessage) => {
|
(chatMessage: ChatMessage) => {
|
||||||
this.messagePageViewModel.showChatMessage(chatMessage);
|
this.messagePageViewModel.showChatMessage(chatMessage);
|
||||||
|
|
||||||
|
if (this.chatListViewModel.selectedChat.value != this) {
|
||||||
|
this.hasUnreadMessages.value = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
// load
|
// load
|
||||||
this.loadPageSelection();
|
this.loadPageSelection();
|
||||||
this.resetColor();
|
this.resetColor();
|
||||||
|
this.loadInfo();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user