Fixed some chat notifications

canary
WolverinDEV 2020-07-23 21:53:11 +02:00
parent b3743c554a
commit b665927832
4 changed files with 5 additions and 13 deletions

View File

@ -25,5 +25,6 @@ export {};
if(__build.target === "client") { if(__build.target === "client") {
/* do this so we don't get a react dev tools warning within the client */ /* do this so we don't get a react dev tools warning within the client */
(window as any).__REACT_DEVTOOLS_GLOBAL_HOOK__ = (window as any).__REACT_DEVTOOLS_GLOBAL_HOOK__ || {};
(window as any).__REACT_DEVTOOLS_GLOBAL_HOOK__.inject = function () {}; (window as any).__REACT_DEVTOOLS_GLOBAL_HOOK__.inject = function () {};
} }

View File

@ -800,9 +800,6 @@ export class ConnectionCommandHandler extends AbstractCommandHandler {
this.connection_handler.sound.play(Sound.MESSAGE_RECEIVED, {default_volume: .5}); this.connection_handler.sound.play(Sound.MESSAGE_RECEIVED, {default_volume: .5});
} }
if(!(invoker instanceof LocalClientEntry))
this.connection_handler.channelTree.findChannel(channel_id)?.setUnread(true);
const conversations = this.connection_handler.side_bar.channel_conversations(); const conversations = this.connection_handler.side_bar.channel_conversations();
conversations.findOrCreateConversation(channel_id).handleIncomingMessage({ conversations.findOrCreateConversation(channel_id).handleIncomingMessage({
sender_database_id: invoker ? invoker.properties.client_database_id : 0, sender_database_id: invoker ? invoker.properties.client_database_id : 0,
@ -826,9 +823,6 @@ export class ConnectionCommandHandler extends AbstractCommandHandler {
} }
}); });
if(!(invoker instanceof LocalClientEntry))
this.connection_handler.channelTree.server.setUnread(true);
conversations.findOrCreateConversation(0).handleIncomingMessage({ conversations.findOrCreateConversation(0).handleIncomingMessage({
sender_database_id: invoker ? invoker.properties.client_database_id : 0, sender_database_id: invoker ? invoker.properties.client_database_id : 0,
sender_name: json["invokername"], sender_name: json["invokername"],

View File

@ -73,7 +73,7 @@ export abstract class AbstractChat<Events extends ConversationUIEvents> {
if(event.isOwnMessage) if(event.isOwnMessage)
this.setUnreadTimestamp(undefined); this.setUnreadTimestamp(undefined);
else if(!this.unreadTimestamp) else if(!this.unreadTimestamp)
this.unreadTimestamp = event.message.timestamp; this.setUnreadTimestamp(event.message.timestamp);
/* let all other events run before */ /* let all other events run before */
this.events.fire_async("notify_chat_event", { this.events.fire_async("notify_chat_event", {
@ -583,12 +583,8 @@ export class Conversation extends AbstractChat<ConversationUIEvents> {
if(isNaN(timestamp)) if(isNaN(timestamp))
return; return;
if(timestamp > this.lastReadMessage) { if(timestamp > this.lastReadMessage)
this.setUnreadTimestamp(this.lastReadMessage); this.setUnreadTimestamp(this.lastReadMessage);
/* TODO: Move the whole last read part to the channel entry itself? */
this.handle.connection.channelTree.findChannel(this.conversationId)?.setUnread(true);
}
} }
public handleIncomingMessage(message: ChatMessage, isOwnMessage: boolean) { public handleIncomingMessage(message: ChatMessage, isOwnMessage: boolean) {
@ -647,6 +643,7 @@ export class Conversation extends AbstractChat<ConversationUIEvents> {
/* we've to update the last read timestamp regardless of if we're having actual unread stuff */ /* we've to update the last read timestamp regardless of if we're having actual unread stuff */
this.handle.connection.settings.changeServer(Settings.FN_CHANNEL_CHAT_READ(this.conversationId), typeof timestamp === "number" ? timestamp : Date.now()); this.handle.connection.settings.changeServer(Settings.FN_CHANNEL_CHAT_READ(this.conversationId), typeof timestamp === "number" ? timestamp : Date.now());
this.handle.connection.channelTree.findChannel(this.conversationId)?.setUnread(timestamp !== undefined);
} }
public localClientSwitchedChannel(type: "join" | "leave") { public localClientSwitchedChannel(type: "join" | "leave") {

View File

@ -251,7 +251,7 @@ export class PrivateConversation extends AbstractChat<PrivateConversationUIEvent
/* TODO: Move this somehow to the client itself? */ /* TODO: Move this somehow to the client itself? */
if(this.activeClient instanceof ClientEntry) if(this.activeClient instanceof ClientEntry)
this.activeClient.setUnread(timestamp === undefined); this.activeClient.setUnread(timestamp !== undefined);
} }
protected canClientAccessChat(): boolean { protected canClientAccessChat(): boolean {