fix: removing wheel reinvention of urlStates

This commit is contained in:
Grégoire Cutzach 2024-10-07 18:29:58 +02:00
parent fbc911721e
commit 2f2f50488f
No known key found for this signature in database
GPG Key ID: AA4155BE23C375E6

View File

@ -333,14 +333,12 @@ export class DocSettingsPage extends Disposable {
docType = "tutorial"; docType = "tutorial";
} }
await persistType(docType, docId); await persistType(docType, docId);
const currentUrl = window.location.href; const {trunkId} = docPageModel.currentDoc.get()!.idParts;
const urlId = currentUrl.split("/docs/")[1]; window.location.replace(urlState().makeUrl({
const cleanUrlId = urlId.match(/^doc\/.*/) ? urlId.split("/")[1] : urlId.split("/")[0]; docPage: "settings",
const shortDocId = urlId?.split("~")[0]; fork: undefined, // will be automatically set once the page is reloaded
const reloadUrl = urlId.match(/^doc\/.*/) ? doc: trunkId,
currentUrl.replace(`doc/${cleanUrlId}`, shortDocId) : }));
currentUrl.replace(cleanUrlId, shortDocId);
window.location.replace(reloadUrl ?? "");
}; };
const documentTypeOptions = () => [ const documentTypeOptions = () => [