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,
template: TemplateViewModel | CustomTemplate | undefined
): TemplateValues {
if (!type) {
if (!type || !template) {
return getInitialTemplateValues();
}

View File

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