fix highlight of unread messages
This commit is contained in:
Vendored
+16
-19
@@ -1230,8 +1230,7 @@
|
|||||||
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.setReadStatus(true);
|
||||||
this.storeInfo();
|
|
||||||
};
|
};
|
||||||
this.handleMessageSent = (chatMessage) => {
|
this.handleMessageSent = (chatMessage) => {
|
||||||
chatMessage.status = "sent" /* Sent */;
|
chatMessage.status = "sent" /* Sent */;
|
||||||
@@ -1301,8 +1300,8 @@
|
|||||||
this.subscribe = () => {
|
this.subscribe = () => {
|
||||||
this.connectionModel.addChannel(this.info.primaryChannel);
|
this.connectionModel.addChannel(this.info.primaryChannel);
|
||||||
};
|
};
|
||||||
this.markRead = () => {
|
this.setReadStatus = (hasUnreadMessages) => {
|
||||||
this.info.hasUnreadMessages = false;
|
this.info.hasUnreadMessages = hasUnreadMessages;
|
||||||
this.storeInfo();
|
this.storeInfo();
|
||||||
};
|
};
|
||||||
// storage
|
// storage
|
||||||
@@ -3038,7 +3037,7 @@
|
|||||||
// view
|
// view
|
||||||
this.open = () => {
|
this.open = () => {
|
||||||
this.chatListViewModel.openChat(this);
|
this.chatListViewModel.openChat(this);
|
||||||
this.markRead();
|
this.setReadStatus(false);
|
||||||
};
|
};
|
||||||
this.close = () => {
|
this.close = () => {
|
||||||
this.chatListViewModel.closeChat();
|
this.chatListViewModel.closeChat();
|
||||||
@@ -3059,10 +3058,6 @@
|
|||||||
const index = this.chatListViewModel.chatIndexManager.getIndex(this);
|
const index = this.chatListViewModel.chatIndexManager.getIndex(this);
|
||||||
this.index.value = index;
|
this.index.value = index;
|
||||||
};
|
};
|
||||||
this.markRead = () => {
|
|
||||||
this.hasUnreadMessages.value = false;
|
|
||||||
this.chatModel.markRead();
|
|
||||||
};
|
|
||||||
// load
|
// load
|
||||||
this.loadPageSelection = () => {
|
this.loadPageSelection = () => {
|
||||||
const path = StorageModel.getPath(
|
const path = StorageModel.getPath(
|
||||||
@@ -3079,12 +3074,22 @@
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
this.loadInfo = () => {
|
this.loadInfo = () => {
|
||||||
this.hasUnreadMessages.value = this.chatModel.info.hasUnreadMessages;
|
this.updateReadStatus();
|
||||||
this.taskBoardSuggestions.set(CALENDAR_EVENT_BOARD_ID, [
|
this.taskBoardSuggestions.set(CALENDAR_EVENT_BOARD_ID, [
|
||||||
CALENDAR_EVENT_BOARD_ID,
|
CALENDAR_EVENT_BOARD_ID,
|
||||||
translations.chatPage.calendar.eventsBoard
|
translations.chatPage.calendar.eventsBoard
|
||||||
]);
|
]);
|
||||||
};
|
};
|
||||||
|
this.updateReadStatus = () => {
|
||||||
|
if (this.chatListViewModel.selectedChat.value == this) {
|
||||||
|
this.chatModel.setReadStatus(false);
|
||||||
|
}
|
||||||
|
this.hasUnreadMessages.value = this.chatModel.info.hasUnreadMessages;
|
||||||
|
};
|
||||||
|
this.setReadStatus = (hasUnreadMessages) => {
|
||||||
|
this.chatModel.setReadStatus(hasUnreadMessages);
|
||||||
|
this.hasUnreadMessages.value = hasUnreadMessages;
|
||||||
|
};
|
||||||
this.storageModel = storageModel2;
|
this.storageModel = storageModel2;
|
||||||
this.chatModel = chatModel;
|
this.chatModel = chatModel;
|
||||||
this.settingsViewModel = settingsViewModel2;
|
this.settingsViewModel = settingsViewModel2;
|
||||||
@@ -3114,7 +3119,7 @@
|
|||||||
chatModel.chatMessageHandlerManager.addHandler(
|
chatModel.chatMessageHandlerManager.addHandler(
|
||||||
(chatMessage) => {
|
(chatMessage) => {
|
||||||
this.messagePageViewModel.showChatMessage(chatMessage);
|
this.messagePageViewModel.showChatMessage(chatMessage);
|
||||||
this.markRead();
|
this.updateReadStatus();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
this.loadPageSelection();
|
this.loadPageSelection();
|
||||||
@@ -5534,14 +5539,6 @@
|
|||||||
path: [""],
|
path: [""],
|
||||||
body: ""
|
body: ""
|
||||||
};
|
};
|
||||||
var counter = {};
|
|
||||||
for (let i = 0; i < 1e3; i++) {
|
|
||||||
const token = generateRandomToken(10);
|
|
||||||
const length = token.length;
|
|
||||||
if (!counter[length]) counter[length] = 0;
|
|
||||||
counter[length]++;
|
|
||||||
}
|
|
||||||
console.log(counter);
|
|
||||||
|
|
||||||
// src/View/Components/chatEntry.tsx
|
// src/View/Components/chatEntry.tsx
|
||||||
function ChatEntry(chatViewModel) {
|
function ChatEntry(chatViewModel) {
|
||||||
|
|||||||
@@ -85,8 +85,7 @@ export default class ChatModel {
|
|||||||
chatMessage.status = ChatMessageStatus.Received;
|
chatMessage.status = ChatMessageStatus.Received;
|
||||||
this.addMessage(chatMessage);
|
this.addMessage(chatMessage);
|
||||||
|
|
||||||
this.info.hasUnreadMessages = true;
|
this.setReadStatus(true);
|
||||||
this.storeInfo();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
handleMessageSent = (chatMessage: ChatMessage): void => {
|
handleMessageSent = (chatMessage: ChatMessage): void => {
|
||||||
@@ -177,8 +176,8 @@ export default class ChatModel {
|
|||||||
this.connectionModel.addChannel(this.info.primaryChannel);
|
this.connectionModel.addChannel(this.info.primaryChannel);
|
||||||
};
|
};
|
||||||
|
|
||||||
markRead = (): void => {
|
setReadStatus = (hasUnreadMessages: boolean): void => {
|
||||||
this.info.hasUnreadMessages = false;
|
this.info.hasUnreadMessages = hasUnreadMessages;
|
||||||
this.storeInfo();
|
this.storeInfo();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -46,14 +46,14 @@ export default class ChatViewModel {
|
|||||||
// view
|
// view
|
||||||
open = (): void => {
|
open = (): void => {
|
||||||
this.chatListViewModel.openChat(this);
|
this.chatListViewModel.openChat(this);
|
||||||
this.markRead();
|
this.setReadStatus(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
close = (): void => {
|
close = (): void => {
|
||||||
this.chatListViewModel.closeChat();
|
this.chatListViewModel.closeChat();
|
||||||
};
|
};
|
||||||
|
|
||||||
closeSubPages = (): void => {};
|
closeSubPages = (): void => { };
|
||||||
|
|
||||||
setColor = (color: Color): void => {
|
setColor = (color: Color): void => {
|
||||||
this.setDisplayedColor(color);
|
this.setDisplayedColor(color);
|
||||||
@@ -74,11 +74,6 @@ export default class ChatViewModel {
|
|||||||
this.index.value = index;
|
this.index.value = index;
|
||||||
};
|
};
|
||||||
|
|
||||||
markRead = (): void => {
|
|
||||||
this.hasUnreadMessages.value = false;
|
|
||||||
this.chatModel.markRead();
|
|
||||||
};
|
|
||||||
|
|
||||||
// load
|
// load
|
||||||
loadPageSelection = (): void => {
|
loadPageSelection = (): void => {
|
||||||
const path: string[] = StorageModel.getPath(
|
const path: string[] = StorageModel.getPath(
|
||||||
@@ -97,14 +92,25 @@ export default class ChatViewModel {
|
|||||||
};
|
};
|
||||||
|
|
||||||
loadInfo = (): void => {
|
loadInfo = (): void => {
|
||||||
this.hasUnreadMessages.value = this.chatModel.info.hasUnreadMessages;
|
this.updateReadStatus();
|
||||||
|
|
||||||
this.taskBoardSuggestions.set(CALENDAR_EVENT_BOARD_ID, [
|
this.taskBoardSuggestions.set(CALENDAR_EVENT_BOARD_ID, [
|
||||||
CALENDAR_EVENT_BOARD_ID,
|
CALENDAR_EVENT_BOARD_ID,
|
||||||
translations.chatPage.calendar.eventsBoard,
|
translations.chatPage.calendar.eventsBoard,
|
||||||
]);
|
]);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
updateReadStatus = (): void => {
|
||||||
|
if (this.chatListViewModel.selectedChat.value == this) {
|
||||||
|
this.chatModel.setReadStatus(false);
|
||||||
|
}
|
||||||
|
this.hasUnreadMessages.value = this.chatModel.info.hasUnreadMessages;
|
||||||
|
}
|
||||||
|
|
||||||
|
setReadStatus = (hasUnreadMessages: boolean): void => {
|
||||||
|
this.chatModel.setReadStatus(hasUnreadMessages);
|
||||||
|
this.hasUnreadMessages.value = hasUnreadMessages;
|
||||||
|
}
|
||||||
|
|
||||||
// init
|
// init
|
||||||
constructor(
|
constructor(
|
||||||
public coreViewModel: CoreViewModel,
|
public coreViewModel: CoreViewModel,
|
||||||
@@ -148,7 +154,7 @@ export default class ChatViewModel {
|
|||||||
chatModel.chatMessageHandlerManager.addHandler(
|
chatModel.chatMessageHandlerManager.addHandler(
|
||||||
(chatMessage: ChatMessage) => {
|
(chatMessage: ChatMessage) => {
|
||||||
this.messagePageViewModel.showChatMessage(chatMessage);
|
this.messagePageViewModel.showChatMessage(chatMessage);
|
||||||
this.markRead();
|
this.updateReadStatus();
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user