cloud file, folder operations

This commit is contained in:
SPRINX0\prochazka
2025-05-28 10:46:35 +02:00
parent 741b942dea
commit 7b50a19b2c
9 changed files with 150 additions and 41 deletions

View File

@@ -47,5 +47,11 @@ export function installCloudListeners() {
ensureCloudConnectionsLoaded(...conids);
});
apiOn('cloud-content-updated', () => cloudConnectionsStore.set({}));
apiOn('cloud-content-updated', () => {
const conids = Object.keys(getCloudConnectionsStore());
cloudConnectionsStore.set({});
for (const conn of conids) {
loadCloudConnection(conn);
}
});
}

View File

@@ -111,6 +111,8 @@ async function openSavedElectronFile(filePath, parsed, folder) {
props: {
savedFile: null,
savedFolder: null,
savedCloudFolderId: null,
savedCloudContentId: null,
savedFilePath: filePath,
savedFormat: handler.format,
...connProps,

View File

@@ -30,7 +30,8 @@ export default async function openNewTab(newTab, initialData: any = undefined, o
};
}
const { savedFile, savedFolder, savedFilePath, conid, database } = newTab.props || {};
const { savedFile, savedFolder, savedFilePath, savedCloudFolderId, savedCloudContentId, conid, database } =
newTab.props || {};
if (conid && database) {
const connection = await getConnectionInfo({ conid });
@@ -49,7 +50,9 @@ export default async function openNewTab(newTab, initialData: any = undefined, o
x.closedTime == null &&
x.props.savedFile == savedFile &&
x.props.savedFolder == savedFolder &&
x.props.savedFilePath == savedFilePath
x.props.savedFilePath == savedFilePath &&
x.props.savedCloudFolderId == savedCloudFolderId &&
x.props.savedCloudContentId == savedCloudContentId
);
}

View File

@@ -15,16 +15,31 @@ export default async function saveTabFile(editor, saveMode, folder, format, file
const tabs = get(openedTabs);
const tabid = editor.activator.tabid;
const data = editor.getData();
const { savedFile, savedFilePath, savedFolder } = tabs.find(x => x.tabid == tabid).props || {};
const { savedFile, savedFilePath, savedFolder, savedCloudFolderId, savedCloudContentId } =
tabs.find(x => x.tabid == tabid).props || {};
const handleSave = async () => {
if (savedFile) {
await apiCall('files/save', { folder: savedFolder || folder, file: savedFile, data, format });
if (savedCloudFolderId && savedCloudContentId) {
const resp = await apiCall('cloud/save-file', {
folid: savedCloudFolderId,
fileName: savedFile,
data,
contentFolder: folder,
format,
cntid: savedCloudContentId,
});
if (resp.cntid) {
markTabSaved(tabid);
}
} else {
if (savedFile) {
await apiCall('files/save', { folder: savedFolder || folder, file: savedFile, data, format });
}
if (savedFilePath) {
await apiCall('files/save-as', { filePath: savedFilePath, data, format });
}
markTabSaved(tabid);
}
if (savedFilePath) {
await apiCall('files/save-as', { filePath: savedFilePath, data, format });
}
markTabSaved(tabid);
};
const onSave = (title, newProps) => {
@@ -60,6 +75,8 @@ export default async function saveTabFile(editor, saveMode, folder, format, file
savedFile: null,
savedFolder: null,
savedFilePath: file,
savedCloudFolderId: null,
savedCloudContentId: null,
});
}
} else if ((savedFile || savedFilePath) && saveMode == 'save') {
@@ -73,6 +90,8 @@ export default async function saveTabFile(editor, saveMode, folder, format, file
name: savedFile || 'newFile',
filePath: savedFilePath,
onSave,
folid: savedCloudFolderId,
// cntid: savedCloudContentId,
});
}
}