sound fixes
This commit is contained in:
@@ -112,8 +112,8 @@ export class ChatService {
|
||||
// 1. Play sound
|
||||
this.playMessageSound(channelId, senderIdentity);
|
||||
|
||||
// 2. System Notification (only if not from us and not muted)
|
||||
if (!senderIdentity.isEqual(this.identity || Identity.zero()) && !this.isChannelMuted(channelId)) {
|
||||
// 2. System Notification (only if not from us and notifications are enabled)
|
||||
if (!senderIdentity.isEqual(this.identity || Identity.zero()) && this.isChannelNotificationsEnabled(channelId)) {
|
||||
if ("Notification" in window && Notification.permission === "granted") {
|
||||
const isDm = this.#db.directMessages.some(d => d.channelId === channelId);
|
||||
const isMention = text.includes(`<@${this.identity?.toHexString()}>`);
|
||||
|
||||
@@ -99,19 +99,18 @@ export class MessagingService {
|
||||
|
||||
// Incremental update logic for visible messages
|
||||
const seenMessageIds = new Set<bigint>();
|
||||
let isFirstEmit = true;
|
||||
let initialSyncComplete = false;
|
||||
|
||||
visibleMessagesStore.subscribe((v) => {
|
||||
if (v.length > 0) {
|
||||
console.log(`[MessagingService] Received batch of ${v.length} messages. First emit: ${isFirstEmit}`);
|
||||
console.log(`[MessagingService] Received batch of ${v.length} messages. Initial sync complete: ${initialSyncComplete}`);
|
||||
}
|
||||
|
||||
// If this is a new batch, identify truly new messages
|
||||
for (const msg of v) {
|
||||
if (!seenMessageIds.has(msg.id)) {
|
||||
// Only trigger notifications if this isn't the very first time we see data
|
||||
// and the service is generally ready.
|
||||
if (!isFirstEmit && this.onMessageReceived) {
|
||||
// Only trigger notifications if the initial database sync is fully complete
|
||||
if (initialSyncComplete && this.onMessageReceived) {
|
||||
console.log(`[MessagingService] Dispatching notification for message ${msg.id}`);
|
||||
this.onMessageReceived({
|
||||
channelId: msg.channelId,
|
||||
@@ -125,11 +124,6 @@ export class MessagingService {
|
||||
}
|
||||
}
|
||||
|
||||
if (v.length > 0 && isFirstEmit) {
|
||||
console.log(`[MessagingService] Initial message load complete. Disabling first emit suppression.`);
|
||||
isFirstEmit = false;
|
||||
}
|
||||
|
||||
recentMessages = v;
|
||||
this.#updateBuckets([...recentMessages, ...scrollbackMessages]);
|
||||
|
||||
@@ -143,6 +137,7 @@ export class MessagingService {
|
||||
console.log(`[MessagingService] Global sync status: ${v}`);
|
||||
this.isGlobalSyncDone = v;
|
||||
if (v) {
|
||||
initialSyncComplete = true;
|
||||
const cid = untrack(() => this.#nav.activeChannelId);
|
||||
if (cid) {
|
||||
this.#readyChannels.add(cid);
|
||||
|
||||
Reference in New Issue
Block a user