Skip to content

Commit 177401b

Browse files
authored
Merge pull request #8120 from Couchers-org/na/mobile-1.1.14
Mobile app fixes v.1.1.14
2 parents c3f3539 + 8387e23 commit 177401b

11 files changed

Lines changed: 2360 additions & 2437 deletions

File tree

app/mobile/RELEASE_NOTES.txt

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
- Fix unexpected logouts
2-
- Fix "Message" button opening wrong conversation when clicked via profile
3-
- Fix tab highlighting after clicking couchers logo in navigation
4-
- Fix image uploads being forced to square
5-
- Hide "open in new tab" icon on search results
6-
- Remove beta flag
7-
- Fix issues with stale content on page change
8-
- Fix save button spacing in profile editor
1+
- Fix incompatible dependencies
2+
- Improve navigation behavior
3+
- Fix menu staying open after switching tabs

app/mobile/app.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const getIosIcon = () => {
4848
export default {
4949
name: getAppName(),
5050
slug: "mobile",
51-
version: "1.1.13",
51+
version: "1.1.14",
5252
orientation: "portrait",
5353
icon: getIcon(),
5454
scheme: getAppScheme(),

app/mobile/app/(tabs)/[...slug].tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ import WebEmbed from "@/components/WebEmbed";
55
export default function CatchAllScreen() {
66
const { slug } = useLocalSearchParams<{ slug?: string[] }>();
77
const path = `/${(slug ?? []).join("/")}`;
8+
89
return <WebEmbed path={path} />;
910
}

app/mobile/app/(tabs)/md/[...slug].tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ import WebEmbed from "@/components/WebEmbed";
55
export default function MarkdownScreen() {
66
const { slug } = useLocalSearchParams<{ slug?: string[] }>();
77
const path = `/md/${(slug ?? []).join("/")}`;
8+
89
return <WebEmbed path={path} />;
910
}

app/mobile/components/WebEmbed.tsx

Lines changed: 14 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import { useAuthContext } from "@/features/auth/AuthContext";
2121
import { useImagePicker } from "@/hooks/useImagePicker";
2222
import { useWebNavigation } from "@/hooks/useWebNavigation";
2323
import errorGraphic from "@/resources/404graphic.png";
24-
import { lastMobileNavigationRef } from "@/state/webViewState";
2524
import { theme } from "@/theme";
2625
import { shouldLoadInWebView } from "@/utils/webViewUrlUtils";
2726

@@ -48,15 +47,14 @@ export default function WebEmbed({ path }: WebEmbedProps) {
4847

4948
// Custom hooks for image picking and navigation
5049
const { pickImage } = useImagePicker();
51-
const { handleNavigationStateChange, canGoBackRef, currentWebPathRef } =
52-
useWebNavigation({
53-
webBaseUrl: WEB_BASE_URL,
54-
currentPath: path,
55-
syncTargetPathRef,
56-
onRetryCountReset: () => {
57-
retryCountRef.current = 0;
58-
},
59-
});
50+
const { handleNavigationStateChange, canGoBackRef } = useWebNavigation({
51+
webBaseUrl: WEB_BASE_URL,
52+
currentPath: path,
53+
syncTargetPathRef,
54+
onRetryCountReset: () => {
55+
retryCountRef.current = 0;
56+
},
57+
});
6058

6159
// Handle Android hardware back button - go back in WebView if possible
6260
useFocusEffect(
@@ -105,26 +103,10 @@ export default function WebEmbed({ path }: WebEmbedProps) {
105103
return;
106104
}
107105

108-
// Read the current WebView path from the ref (always up-to-date)
109-
const currentWebPath = currentWebPathRef.current;
110-
111-
// Strip locales from both paths for comparison
112-
const currentRoute = stripLocale(currentWebPath);
106+
// Strip locale for comparison
113107
const targetRoute = stripLocale(path);
114108

115-
if (currentRoute === targetRoute) {
116-
// Same route, just different locale or already synced
117-
return;
118-
}
119-
120-
// Check if we just navigated here from mobile router
121-
// If so, skip sync to avoid reload loop (WebView is already navigating there)
122-
if (lastMobileNavigationRef.current === targetRoute) {
123-
lastMobileNavigationRef.current = null; // Clear so next change is synced
124-
return;
125-
}
126-
127-
// Routes differ - sync WebView, using mobile i18n language as source of truth
109+
// Sync WebView, using mobile i18n language as source of truth
128110
// This ensures language selection persists across tab switches
129111
const currentLocale = i18n.language !== "en" ? i18n.language : null;
130112
const targetPath = currentLocale
@@ -138,7 +120,7 @@ export default function WebEmbed({ path }: WebEmbedProps) {
138120
window.postMessage(${JSON.stringify({ type: "MOBILE_NAVIGATE", path: targetPath })}, "*");
139121
true;
140122
`);
141-
}, [path, WEB_BASE_URL, stripLocale, i18n.language, currentWebPathRef]);
123+
}, [path, stripLocale, i18n.language]);
142124

143125
// Sync WebView when screen comes back into focus (tab switch)
144126
useFocusEffect(
@@ -148,19 +130,10 @@ export default function WebEmbed({ path }: WebEmbedProps) {
148130
return;
149131
}
150132

151-
// Read the current WebView path from the ref (always up-to-date)
152-
const currentWebPath = currentWebPathRef.current;
153-
154-
// Strip locales from both paths for comparison
155-
const currentRoute = stripLocale(currentWebPath);
133+
// Strip locale for comparison
156134
const targetRoute = stripLocale(path);
157135

158-
if (currentRoute === targetRoute) {
159-
// Same route, just different locale or already synced
160-
return;
161-
}
162-
163-
// Routes differ - sync WebView, using mobile i18n language as source of truth
136+
// Sync WebView, using mobile i18n language as source of truth
164137
// This ensures language selection persists across tab switches
165138
const currentLocale = i18n.language !== "en" ? i18n.language : null;
166139
const targetPath = currentLocale
@@ -174,7 +147,7 @@ export default function WebEmbed({ path }: WebEmbedProps) {
174147
window.postMessage(${JSON.stringify({ type: "MOBILE_NAVIGATE", path: targetPath })}, "*");
175148
true;
176149
`);
177-
}, [path, stripLocale, i18n.language, currentWebPathRef]),
150+
}, [path, stripLocale, i18n.language]),
178151
);
179152

180153
// Send result back to web app

app/mobile/hooks/useWebNavigation.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,23 @@ export function useWebNavigation({
154154
return;
155155
}
156156

157+
// Check if we're navigating from a tab to a catch-all route
158+
const isCurrentRouteTab =
159+
currentRoute &&
160+
["dashboard", "messages", "events", "communities", "search"].includes(
161+
currentRoute,
162+
);
163+
const isTargetRouteCatchAll =
164+
targetRoute === "[...slug]" || targetRoute === "md/[...slug]";
165+
157166
// Update native router to keep tab highlights in sync
158167
if (targetRoute !== currentRoute && targetRoute) {
168+
// Don't switch screens when navigating from a tab to a catch-all route
169+
// This keeps the user on the tab, allowing back button to work and preventing flash
170+
if (isCurrentRouteTab && isTargetRouteCatchAll) {
171+
return;
172+
}
173+
159174
if (targetRoute === "[...slug]" || targetRoute === "md/[...slug]") {
160175
// For catch-all routes, navigate to the appropriate screen
161176
// Strip locale prefix for mobile router (mobile routes don't use locale prefixes)

0 commit comments

Comments
 (0)