A free and open source instant messaging and VoIP chat app built for friends, groups, and communities.
feat(QuickSwitcher): allow deep linking in quick switcher (#3555)
Jiralite1a3d22af0c84
diff --git a/fluxer_app/src/features/navigation/utils/DeepLinkUtils.ts b/fluxer_app/src/features/navigation/utils/DeepLinkUtils.tsindex b07b757fa..fff50e714 100644--- a/fluxer_app/src/features/navigation/utils/DeepLinkUtils.ts+++ b/fluxer_app/src/features/navigation/utils/DeepLinkUtils.ts@@ -194,6 +194,10 @@ const navigateForTarget = (target: DeepLinkTarget) => {RouterUtils.transitionTo(dest);};+export function isAppDeepLink(rawUrl: string): boolean {+ return isAppProtocolUrl(rawUrl) && parseDeepLink(rawUrl) !== null;+}+export function handleDeepLinkUrl(rawUrl: string): boolean {const target = parseDeepLink(rawUrl);if (!target) return false;diff --git a/fluxer_app/src/features/search/commands/QuickSwitcherCommands.tsx b/fluxer_app/src/features/search/commands/QuickSwitcherCommands.tsxindex a6920b957..158046a0f 100644--- a/fluxer_app/src/features/search/commands/QuickSwitcherCommands.tsx+++ b/fluxer_app/src/features/search/commands/QuickSwitcherCommands.tsx@@ -7,6 +7,7 @@ import {focusChannelTextareaAfterNavigation} from '@app/features/messaging/utilsimport {goToMessage, parseMessagePath} from '@app/features/messaging/utils/MessageNavigator';import * as NavigationCommands from '@app/features/navigation/commands/NavigationCommands';import SelectedChannel from '@app/features/navigation/state/SelectedChannel';+import {handleDeepLinkUrl, isAppDeepLink} from '@app/features/navigation/utils/DeepLinkUtils';import * as RouterUtils from '@app/features/navigation/utils/RouterUtils';import QuickSwitcher from '@app/features/search/state/QuickSwitcher';import type {QuickSwitcherExecutableResult} from '@app/features/search/state/QuickSwitcherTypes';@@ -101,6 +102,10 @@ export async function switchTo(result: QuickSwitcherExecutableResult): Promise<vbreak;}case QuickSwitcherResultTypes.LINK: {+ if (isAppDeepLink(result.path)) {+ handleDeepLinkUrl(result.path);+ break;+ }const parsed = parseMessagePath(result.path);if (parsed) {const viewContext = result.path.startsWith(Routes.favoritesChannel(parsed.channelId))diff --git a/fluxer_app/src/features/search/state/QuickSwitcher.tsx b/fluxer_app/src/features/search/state/QuickSwitcher.tsxindex 8757a7ecc..88b094a4f 100644--- a/fluxer_app/src/features/search/state/QuickSwitcher.tsx+++ b/fluxer_app/src/features/search/state/QuickSwitcher.tsx@@ -1,13 +1,14 @@// SPDX-License-Identifier: AGPL-3.0-or-laterimport Guilds from '@app/features/guild/state/Guilds';+import {OPEN_LINK_DESCRIPTOR} from '@app/features/i18n/utils/CommonMessageDescriptors';import {onLocaleChange} from '@app/features/i18n/utils/LocaleChangeListener';import type {GuildMember} from '@app/features/member/models/GuildMember';import GuildMembers from '@app/features/member/state/GuildMembers';import MemberSearch, {type SearchContext} from '@app/features/member/state/MemberSearch';import type {TransformedMember} from '@app/features/member/workers/MemberSearchProtocol';import SelectedGuild from '@app/features/navigation/state/SelectedGuild';-import {parseChannelUrl} from '@app/features/navigation/utils/DeepLinkUtils';+import {isAppDeepLink, parseChannelUrl} from '@app/features/navigation/utils/DeepLinkUtils';import {AccountScopedWork} from '@app/features/platform/state/AccountScopedWork';import {Logger} from '@app/features/platform/utils/AppLogger';import {loadLazyModule} from '@app/features/platform/utils/LazyModuleLoader';@@ -477,6 +478,15 @@ class QuickSwitcher {path: channelPath,};linkResults.push(linkResult);+ } else if (isAppDeepLink(query)) {+ const linkResult: LinkResult = {+ type: QuickSwitcherResultTypes.LINK,+ id: 'link-open',+ title: i18n._(OPEN_LINK_DESCRIPTOR),+ subtitle: query,+ path: query,+ };+ linkResults.push(linkResult);}const {mode, search, variant} = parsePrefix(query);let results: Array<QuickSwitcherResult>;