Skip to content

Commit

Permalink
🎨
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanessa219 committed Jul 9, 2024
1 parent d0e64e4 commit a683464
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions app/src/editor/rename.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ import {getAssetName, getDisplayName, pathPosix, setNotebookName} from "../util/
import {fetchPost} from "../util/fetch";
import {Constants} from "../constants";
import {showTooltip} from "../dialog/tooltip";
/// #if !MOBILE
import {getAllEditor, getAllModels} from "../layout/getAll";
import {getCurrentEditor} from "../mobile/editor";
/// #endif

export const validateName = (name: string, targetElement?: HTMLElement) => {
if (/\r\n|\r|\n|\u2028|\u2029|\t|\//.test(name)) {
Expand Down Expand Up @@ -135,6 +138,9 @@ export const renameAsset = (assetPath: string) => {
}

fetchPost("/api/asset/renameAsset", {oldPath: assetPath, newName: inputElement.value}, (response) => {
/// #if MOBILE
getCurrentEditor()?.reload(false);
/// #else
getAllModels().asset.forEach(item => {
if (item.path === assetPath) {
item.path = response.data.newPath;
Expand All @@ -144,6 +150,7 @@ export const renameAsset = (assetPath: string) => {
getAllEditor().forEach(item => {
item.reload(false);
});
/// #endif
dialog.destroy();
});
});
Expand Down

0 comments on commit a683464

Please sign in to comment.