fix(app/edge): race between redirects when selecting a template (#12230)

pull/12235/head
LP B 2024-09-20 16:00:40 +02:00 committed by GitHub
parent d647980c3a
commit 61353cbe8a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 5 deletions

View File

@ -92,7 +92,7 @@ function getTemplateValues(
type: 'custom' | 'app' | undefined, type: 'custom' | 'app' | undefined,
template: TemplateViewModel | CustomTemplate | undefined template: TemplateViewModel | CustomTemplate | undefined
): TemplateValues { ): TemplateValues {
if (!type) { if (!type || !template) {
return getInitialTemplateValues(); return getInitialTemplateValues();
} }

View File

@ -1,7 +1,10 @@
import { useRouter } from '@uirouter/react';
import { useParamState } from '@/react/hooks/useParamState'; import { useParamState } from '@/react/hooks/useParamState';
export function useTemplateParams() { export function useTemplateParams() {
const [id, setTemplateId] = useParamState('templateId', (param) => { const router = useRouter();
const [id] = useParamState('templateId', (param) => {
if (!param) { if (!param) {
return undefined; return undefined;
} }
@ -14,7 +17,7 @@ export function useTemplateParams() {
return templateId; return templateId;
}); });
const [type, setTemplateType] = useParamState('templateType', (param) => { const [type] = useParamState('templateType', (param) => {
if (param === 'app' || param === 'custom') { if (param === 'app' || param === 'custom') {
return param; return param;
} }
@ -31,7 +34,10 @@ export function useTemplateParams() {
id: number | undefined; id: number | undefined;
type: 'app' | 'custom' | undefined; type: 'app' | 'custom' | undefined;
}) { }) {
setTemplateId(id); router.stateService.go(
setTemplateType(type); '.',
{ templateId: id, templateType: type },
{ reload: false }
);
} }
} }