From 2f2f50488fbd91510f78a1a962da07fabc4f29fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Cutzach?= Date: Mon, 7 Oct 2024 18:29:58 +0200 Subject: [PATCH] fix: removing wheel reinvention of urlStates --- app/client/ui/DocumentSettings.ts | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/app/client/ui/DocumentSettings.ts b/app/client/ui/DocumentSettings.ts index dfa06def..c2d3b519 100644 --- a/app/client/ui/DocumentSettings.ts +++ b/app/client/ui/DocumentSettings.ts @@ -333,14 +333,12 @@ export class DocSettingsPage extends Disposable { docType = "tutorial"; } await persistType(docType, docId); - const currentUrl = window.location.href; - const urlId = currentUrl.split("/docs/")[1]; - const cleanUrlId = urlId.match(/^doc\/.*/) ? urlId.split("/")[1] : urlId.split("/")[0]; - const shortDocId = urlId?.split("~")[0]; - const reloadUrl = urlId.match(/^doc\/.*/) ? - currentUrl.replace(`doc/${cleanUrlId}`, shortDocId) : - currentUrl.replace(cleanUrlId, shortDocId); - window.location.replace(reloadUrl ?? ""); + const {trunkId} = docPageModel.currentDoc.get()!.idParts; + window.location.replace(urlState().makeUrl({ + docPage: "settings", + fork: undefined, // will be automatically set once the page is reloaded + doc: trunkId, + })); }; const documentTypeOptions = () => [