Skip to content

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

TypeScript fluxerfluxerapp

feat(app): route pass and Explore, drop card age check page

Hampusb2b3b27d1052
diff --git a/fluxer_app/src/app/HistoryBootstrap.ts b/fluxer_app/src/app/HistoryBootstrap.ts
index 41632b488..676ff5695 100644
--- a/fluxer_app/src/app/HistoryBootstrap.ts
+++ b/fluxer_app/src/app/HistoryBootstrap.ts
@@ -22,13 +22,14 @@ export function derivePathStack(path: string): Array<string> {
.filter((s) => s.length > 0);
if (segments[0] !== 'channels' || segments.length < 2) return [];
const root = segments[1];
- if (root === '@me' || root === '@favorites' || root === '@discover') {
+ if (root === '@me' || root === '@favorites' || root === '@explore' || root === '@discover') {
const stack: Array<string> = [];
if (root !== '@me') stack.push('/channels/@me');
stack.push(`/channels/${root}`);
if (segments.length >= 3) stack.push(`/channels/${root}/${segments[2]}`);
return stack.slice(0, -1);
}
+ if (root.startsWith('@')) return [];
const stack: Array<string> = [`/channels/${root}`];
if (segments.length >= 3) stack.push(`/channels/${root}/${segments[2]}`);
return stack.slice(0, -1);
diff --git a/fluxer_app/src/app/router/routes/AppRoutes.tsx b/fluxer_app/src/app/router/routes/AppRoutes.tsx
index e48340dda..479f4669d 100644
--- a/fluxer_app/src/app/router/routes/AppRoutes.tsx
+++ b/fluxer_app/src/app/router/routes/AppRoutes.tsx
@@ -10,7 +10,9 @@ import {DiscoveryLayout} from '@app/features/app/components/layout/DiscoveryLayo
import {FavoritesLayout} from '@app/features/app/components/layout/FavoritesLayout';
import {GuildsLayout} from '@app/features/app/components/layout/GuildsLayout';
import {NotFoundPage} from '@app/features/app/components/pages/NotFoundPage';
+import RuntimeConfig from '@app/features/app/state/RuntimeConfig';
import {isDiscoveryAvailable} from '@app/features/app/utils/DiscoveryFeatures';
+import {isAccountHandoffArrival} from '@app/features/auth/state/AccountHandoffCapture';
import {
AuthenticatedRuntimeInvariantError,
readAuthenticatedRuntimeContext,
@@ -22,7 +24,8 @@ import Channels from '@app/features/channel/state/Channels';
import GatewaySessions from '@app/features/gateway/transport/GatewaySessionPool';
import SelectedChannel from '@app/features/navigation/state/SelectedChannel';
import {navigateToLinkedUserProfile} from '@app/features/navigation/utils/DeepLinkUtils';
-import {getDirectMessagesFallbackPath} from '@app/features/navigation/utils/DefaultLandingUtils';
+import {getDefaultLandingPath} from '@app/features/navigation/utils/DefaultLandingUtils';
+import * as RouterUtils from '@app/features/navigation/utils/RouterUtils';
import {
createDefaultLoadableComponent,
createNamedLoadableComponent,
@@ -53,6 +56,23 @@ function authenticatedRuntimeDisablesDirectMessages(): boolean {
return requireAuthenticatedRuntime().community.direct_messages_disabled;
}
+function personalNotesHomePath(directMessagesDisabled: boolean, friendsDisabled: boolean): string | null {
+ const userId = SessionManager.userId;
+ return directMessagesDisabled && friendsDisabled && userId != null ? Routes.dmChannel(userId) : null;
+}
+
+function authenticatedRuntimePersonalNotesHomePath(): string | null {
+ const {community} = requireAuthenticatedRuntime();
+ return personalNotesHomePath(
+ community.direct_messages_disabled,
+ community.friends_disabled ?? community.direct_messages_disabled,
+ );
+}
+
+function redirectsDirectMessageRoute(guildId: string, channelId: string): boolean {
+ return guildId === ME && channelId !== SessionManager.userId && authenticatedRuntimeDisablesDirectMessages();
+}
+
function authenticatedRuntimeHasDiscovery(): boolean {
return isDiscoveryAvailable(requireAuthenticatedRuntime());
}
@@ -61,10 +81,6 @@ const YouPage = createNamedLoadableComponent<AppRouteComponentProps>({
displayName: 'YouPage',
load: async () => (await import('@app/features/app/components/pages/YouPage')).YouPage,
});
-const MatureContentCheckCallbackPage = createDefaultLoadableComponent<AppRouteComponentProps>({
- displayName: 'MatureContentCheckCallbackPage',
- load: () => import('@app/features/auth/components/pages/MatureContentCheckCallbackPage'),
-});
const GuildMembersPage = createNamedLoadableComponent<AppRouteComponentProps>({
displayName: 'GuildMembersPage',
load: async () => (await import('@app/features/channel/components/GuildMembersPage')).GuildMembersPage,
@@ -86,6 +102,11 @@ const PlutoniumPageLayout = createNamedLoadableComponent<AppRouteComponentProps>
load: async () =>
(await import('@app/features/premium/components/plutonium_page/PlutoniumPageLayout')).PlutoniumPageLayout,
});
+const OperatorPassRoutePage = createNamedLoadableComponent<AppRouteComponentProps>({
+ displayName: 'OperatorPassRoutePage',
+ load: async () =>
+ (await import('@app/features/premium/components/operator_pass/OperatorPassRoutePage')).OperatorPassRoutePage,
+});
const PremiumCallbackPage = createDefaultLoadableComponent<AppRouteComponentProps>({
displayName: 'PremiumCallbackPage',
load: () => import('@app/features/premium/components/pages/PremiumCallbackPage'),
@@ -185,15 +206,6 @@ export const premiumCallbackRoute = createRoute({
preload: PremiumCallbackPage.preload,
component: () => <PremiumCallbackPage data-flx="app.router.app-routes.premium-callback-page" />,
});
-export const matureContentCheckCallbackRoute = createRoute({
- getParentRoute: () => rootRoute,
- id: 'matureContentCheckCallback',
- path: Routes.AGE_VERIFICATION_CALLBACK,
- preload: MatureContentCheckCallbackPage.preload,
- component: () => (
- <MatureContentCheckCallbackPage data-flx="app.router.app-routes.mature-content-check-callback-page" />
- ),
-});
export const connectionCallbackRoute = createRoute({
getParentRoute: () => rootRoute,
id: 'connectionCallback',
@@ -217,35 +229,46 @@ const meRoute = createRoute({
getParentRoute: () => guildsLayoutRoute,
id: 'me',
path: '/channels/@me',
- onEnter: whenAuthenticated(() => {
- if (!authenticatedRuntimeDisablesDirectMessages()) {
+ onEnter: whenAuthenticated((context) => {
+ if (isAccountHandoffArrival(context.url.pathname)) {
return undefined;
}
- const fallback = getDirectMessagesFallbackPath();
- return fallback === Routes.ME ? undefined : new Redirect(fallback);
+ const notesPath = authenticatedRuntimePersonalNotesHomePath();
+ return notesPath ? new Redirect(notesPath) : undefined;
}),
component: observer(() => {
const isMobileLayout = MobileLayout.enabled;
+ const homeFallbackPath = isAccountHandoffArrival(Routes.ME)
+ ? null
+ : personalNotesHomePath(RuntimeConfig.directMessagesDisabled, RuntimeConfig.friendsDisabled);
useEffect(() => {
if (!isMobileLayout && SelectedChannel.selectedChannelIds.has(ME)) {
SelectedChannel.clearGuildSelection(ME);
}
}, [isMobileLayout]);
+ useEffect(() => {
+ if (homeFallbackPath) {
+ RouterUtils.replaceWith(homeFallbackPath);
+ }
+ }, [homeFallbackPath]);
return <DMLayout data-flx="app.router.app-routes.dm-layout--3" />;
}),
});
const discoverRoute = createRoute({
getParentRoute: () => guildsLayoutRoute,
id: 'discover',
- path: '/channels/@discover',
- onEnter: whenAuthenticated(() => {
- if (authenticatedRuntimeHasDiscovery()) {
- return undefined;
- }
- return new Redirect(Routes.ME);
- }),
+ path: Routes.DISCOVER,
+ onEnter: whenAuthenticated(() =>
+ authenticatedRuntimeHasDiscovery() ? undefined : new Redirect(getDefaultLandingPath()),
+ ),
component: () => <DiscoveryLayout data-flx="app.router.app-routes.discovery-layout" />,
});
+const legacyDiscoverRoute = createRoute({
+ getParentRoute: () => guildsLayoutRoute,
+ id: 'legacyDiscover',
+ path: Routes.LEGACY_DISCOVER,
+ onEnter: () => new Redirect(Routes.DISCOVER),
+});
const plutoniumRoute = createRoute({
getParentRoute: () => guildsLayoutRoute,
id: 'plutonium',
@@ -263,6 +286,17 @@ const legacyPlutoniumRoute = createRoute({
path: Routes.LEGACY_PLUTONIUM,
onEnter: () => new Redirect(Routes.PLUTONIUM),
});
+const operatorPassRoute = createRoute({
+ getParentRoute: () => guildsLayoutRoute,
+ id: 'operatorPass',
+ path: Routes.OPERATOR_PASS,
+ preload: OperatorPassRoutePage.preload,
+ component: () => (
+ <DMLayout data-flx="app.router.app-routes.dm-layout--operator-pass">
+ <OperatorPassRoutePage data-flx="app.router.app-routes.operator-pass-route-page" />
+ </DMLayout>
+ ),
+});
const userProfileRoute = createRoute({
getParentRoute: () => appLayoutRoute,
id: 'userProfile',
@@ -326,8 +360,8 @@ const channelRoute = createRoute({
path: '/channels/:guildId/:channelId',
onEnter: whenAuthenticated((ctx) => {
const {guildId, channelId} = ctx.params;
- if (guildId === ME && authenticatedRuntimeDisablesDirectMessages()) {
- return new Redirect(getDirectMessagesFallbackPath());
+ if (redirectsDirectMessageRoute(guildId, channelId)) {
+ return new Redirect(Routes.ME);
}
const channel = Channels.getChannel(channelId);
if (channel && channel.type === ChannelTypes.GUILD_CATEGORY) {
@@ -347,8 +381,8 @@ const messageRoute = createRoute({
path: '/channels/:guildId/:channelId/:messageId',
onEnter: whenAuthenticated((ctx) => {
const {guildId, channelId} = ctx.params;
- if (guildId === ME && authenticatedRuntimeDisablesDirectMessages()) {
- return new Redirect(getDirectMessagesFallbackPath());
+ if (redirectsDirectMessageRoute(guildId, channelId)) {
+ return new Redirect(Routes.ME);
}
const channel = Channels.getChannel(channelId);
if (channel && channel.type === ChannelTypes.GUILD_CATEGORY) {
@@ -399,8 +433,10 @@ export const appRouteTree = appLayoutRoute.addChildren([
mentionsRoute,
meRoute,
discoverRoute,
+ legacyDiscoverRoute,
plutoniumRoute,
legacyPlutoniumRoute,
+ operatorPassRoute,
favoritesRoute.addChildren([favoritesChannelRoute]),
channelsRoute.addChildren([membersRoute, channelRoute.addChildren([messageRoute, threadPanelRoute])]),
]),
diff --git a/fluxer_app/src/app/router/routes/RouterRoutes.ts b/fluxer_app/src/app/router/routes/RouterRoutes.ts
index cbf4ebc1e..666c4cf0d 100644
--- a/fluxer_app/src/app/router/routes/RouterRoutes.ts
+++ b/fluxer_app/src/app/router/routes/RouterRoutes.ts
@@ -1,11 +1,6 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
-import {
- appRouteTree,
- connectionCallbackRoute,
- matureContentCheckCallbackRoute,
- premiumCallbackRoute,
-} from '@app/app/router/routes/AppRoutes';
+import {appRouteTree, connectionCallbackRoute, premiumCallbackRoute} from '@app/app/router/routes/AppRoutes';
import {authRouteTree} from '@app/app/router/routes/AuthRoutes';
import {appRoute, homeRoute, notFoundRoute, rootRoute} from '@app/app/router/routes/RootRoutes';
import type {RouteConfig} from '@app/features/platform/components/router/RouterTypes';
@@ -15,7 +10,6 @@ const routeTree = rootRoute.addChildren([
appRoute,
notFoundRoute,
premiumCallbackRoute,
- matureContentCheckCallbackRoute,
connectionCallbackRoute,
authRouteTree,
appRouteTree,