Files
artcraft/app/modules/TopBar/utilities.tsx
T
wilandwil ad2677a575 Scene - Save Load - v2.1 (#305)
Saving and Loading of Scenes
- Save New scene to server implemented
- Retrieving sceneToken from new scene and refreshes URL, which brings
the editor to state of editing an existing Scene
- Optimized scene reloading when URL changes
- Save Existing scene to server implemented
- Rename scene to server implemented
- Optimized Scene Renaming Component and Endpoint Operation

Editor Changes and Fixes:
- changed the way the api_manager retrieve session tokens
- changed the way api_manager uses a fetcher for the operations in
saving scenes

Co-authored-by: wil <wil@storyteller.ai>
2024-05-03 13:03:06 -04:00

33 lines
774 B
TypeScript

import { renameScene as renameSceneEndpoint } from "~/api";
export const renameScene = async (
sceneTitle: string,
sceneToken: string,
sessionToken: string,
) => {
const endpoint = renameSceneEndpoint(sceneToken);
// console.log(`rename ${sceneToken}: ${sceneTitle}`);
return await fetch(endpoint, {
method: 'POST',
headers: {
Accept: 'application/json',
session: sessionToken,
"Content-Type": "application/json",
},
body: JSON.stringify({
name: sceneTitle,
}),
})
.then(res => res.json())
.then(res => {
if (res && res.success) {
// console.log(res);
return res;
} else {
return { success : false };
}
})
.catch(e => {
return { success : false };
});
}