Skip to content

A free and open source instant messaging and VoIP chat app built for friends, groups, and communities.

TypeScript fluxerfluxerapp

fix(ThreadHeaderButtons): show thread button in threads (#3553)

Jiralite3a7c73ceaf35
diff --git a/fluxer_app/src/features/threads/components/ThreadHeaderButtons.tsx b/fluxer_app/src/features/threads/components/ThreadHeaderButtons.tsx
index d5d78f2e1..0935eab3a 100644
--- a/fluxer_app/src/features/threads/components/ThreadHeaderButtons.tsx
+++ b/fluxer_app/src/features/threads/components/ThreadHeaderButtons.tsx
@@ -2,6 +2,7 @@
import {ChannelHeaderIcon} from '@app/features/channel/components/channel_header_components/ChannelHeaderIcon';
import type {Channel} from '@app/features/channel/models/Channel';
+import Channels from '@app/features/channel/state/Channels';
import {NOTIFICATION_SETTINGS_DESCRIPTOR} from '@app/features/i18n/utils/CommonMessageDescriptors';
import * as ThreadCommands from '@app/features/threads/commands/ThreadCommands';
import {ThreadBrowser, ThreadBrowserCreateButton} from '@app/features/threads/components/ThreadBrowser';
@@ -27,11 +28,17 @@ function isThreadBrowserParent(channel: Channel): boolean {
return TEXT_THREAD_PARENT_CHANNEL_TYPES.has(channel.type);
}
+function resolveThreadBrowserParent(channel: Channel): Channel | null {
+ const parent = channel.isThread() && channel.parentId != null ? Channels.getChannel(channel.parentId) : channel;
+ return parent != null && isThreadBrowserParent(parent) ? parent : null;
+}
+
export const ThreadsButton = observer(({channel}: {channel: Channel}) => {
const {i18n} = useLingui();
const {isOpen, openProps} = usePopout(`thread-browser-${channel.id}`);
const [sheetOpen, setSheetOpen] = useState(false);
- if (!ThreadGuilds.isActive(channel.guildId) || !isThreadBrowserParent(channel)) return null;
+ const parent = resolveThreadBrowserParent(channel);
+ if (!ThreadGuilds.isActive(channel.guildId) || parent == null) return null;
if (MobileLayout.enabled) {
return (
<>
@@ -53,7 +60,7 @@ export const ThreadsButton = observer(({channel}: {channel: Channel}) => {
disablePadding
leadingAction={
<ThreadBrowserCreateButton
- parent={channel}
+ parent={parent}
onClose={() => setSheetOpen(false)}
sheet
data-flx="threads.threads-button.thread-browser-create-button"
@@ -62,7 +69,7 @@ export const ThreadsButton = observer(({channel}: {channel: Channel}) => {
data-flx="threads.threads-button.bottom-sheet"
>
<ThreadBrowser
- parent={channel}
+ parent={parent}
onClose={() => setSheetOpen(false)}
sheet
data-flx="threads.threads-button.thread-browser--sheet"
@@ -76,7 +83,7 @@ export const ThreadsButton = observer(({channel}: {channel: Channel}) => {
{...openProps}
position="bottom-end"
render={({onClose}) => (
- <ThreadBrowser parent={channel} onClose={onClose} data-flx="threads.threads-button.thread-browser" />
+ <ThreadBrowser parent={parent} onClose={onClose} data-flx="threads.threads-button.thread-browser" />
)}
subscribeTo="THREAD_BROWSER_OPEN"
data-flx="threads.threads-button.popout"