mirror of
https://github.com/mattermost/mattermost-mobile.git
synced 2026-11-23 03:48:16 +00:00
Four route files were still consuming useLocalSearchParams directly, bypassing the safeParseJSON decode that every other route already uses via usePropsFromParams. Combined with propsToParams unconditionally JSON.stringify'ing every prop (#9931), that means their string params arrived with literal quote characters embedded (e.g. rootId "abc123" -> `"abc123"`). Impact: - thread.tsx: rootId doesn't match any post in the DB, rootPost stays undefined, ThreadContent never renders. The user sees a blank thread screen with subtitle `in "channel name"` (visible quote characters). - code.tsx: code param is rendered verbatim by the highlighter with outer quotes and escaped inner quotes/backslashes. The MM-69330 workaround (bypassing the hook to preserve string type) is obsolete now that propsToParams always JSON-encodes: safeParseJSON('"42"') returns the string '42', not the number 42. - about.tsx / settings_display_timezone_select.tsx: header text and timezone identifier arrive with extra quotes. Migrating all four to usePropsFromParams closes the symmetry: every param is JSON-encoded on send and JSON-decoded on receive. Also updates code.test.tsx to feed the route JSON-encoded params, so the MM-69330 regression coverage still exercises the exact scenario seen in production. Co-authored-by: Cursor <cursoragent@cursor.com>
28 lines
795 B
TypeScript
28 lines
795 B
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import {useTheme} from '@context/theme';
|
|
import {getHeaderOptions, useNavigationHeader} from '@hooks/navigation_header';
|
|
import {usePropsFromParams} from '@hooks/props_from_params';
|
|
import CodeScreen, {type CodeScreenProps} from '@screens/code';
|
|
|
|
export default function CodeRoute() {
|
|
const theme = useTheme();
|
|
const {code, title, ...props} = usePropsFromParams<CodeScreenProps & {title: string}>();
|
|
|
|
useNavigationHeader({
|
|
showWhenPushed: true,
|
|
headerOptions: {
|
|
headerTitle: title,
|
|
...getHeaderOptions(theme),
|
|
},
|
|
});
|
|
|
|
return (
|
|
<CodeScreen
|
|
{...props}
|
|
code={code}
|
|
/>
|
|
);
|
|
}
|