Skip to content

Commit 21402b3

Browse files
committed
update title with autorun
1 parent b7e5b13 commit 21402b3

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

resources/js/chat/chat-state-store.ts

+12-4
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,18 @@ export default class ChatStateStore implements DispatchListener {
125125
this.publicChannels.load();
126126
}
127127
});
128+
129+
autorun(() => {
130+
if (this.isChatMounted) {
131+
const selectedChannelOrType = this.selectedChannelOrType;
132+
const channelName = selectedChannelOrType instanceof Channel
133+
? selectedChannelOrType.name
134+
: trans(`chat.channels.${selectedChannelOrType ?? 'none'}`);
135+
136+
// FIXME: channelName on sendto=
137+
core.browserTitleWithNotificationCount.title = `${channelName} · ${trans('page_title.main.chat_controller._')}`;
138+
}
139+
});
128140
}
129141

130142
// Only up to one join/create channel operation should be allowed to be running at any time.
@@ -305,23 +317,19 @@ export default class ChatStateStore implements DispatchListener {
305317
private updateUrl(channel: Channel | AddChannelType, mode: 'advanceHistory' | 'replaceHistory' | null) {
306318
if (mode == null) return;
307319

308-
let channelName: string;
309320
let hash = '';
310321
let params: Record<'channel_id' | 'sendto', string | null | undefined>;
311322

312323
if (typeof channel === 'string') {
313-
channelName = trans(`chat.channels.${channel}`);
314324
hash = channel;
315325
params = { channel_id: null, sendto: null };
316326
} else {
317-
channelName = channel.name;
318327
params = channel.newPmChannel
319328
? { channel_id: null, sendto: channel.pmTarget?.toString() }
320329
: { channel_id: channel.channelId.toString(), sendto: null };
321330

322331
}
323332

324333
Turbolinks.controller[mode](updateQueryString(null, params, hash));
325-
core.browserTitleWithNotificationCount.title = `${channelName} · ${trans('page_title.main.chat_controller._')}`;
326334
}
327335
}

resources/lang/en/chat.php

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
'confirm_part' => 'Do you want to hide this channel? You will still receive messages from this channel.',
2020
'create' => 'create announcement',
2121
'join' => 'join channel',
22+
'none' => 'no channel',
2223

2324
'list' => [
2425
'title' => [

0 commit comments

Comments
 (0)