define paths
This commit is contained in:
Vendored
+9
-15
@@ -496,8 +496,7 @@
|
|||||||
board,
|
board,
|
||||||
name
|
name
|
||||||
);
|
);
|
||||||
file.contentVersions.add(taskFileContent);
|
this.saveTask(file, taskFileContent);
|
||||||
this.fileModel.addOrUpdateFile(file);
|
|
||||||
};
|
};
|
||||||
saveTask = (file, newTaskFileContent) => {
|
saveTask = (file, newTaskFileContent) => {
|
||||||
file.contentVersions.add(newTaskFileContent);
|
file.contentVersions.add(newTaskFileContent);
|
||||||
@@ -550,18 +549,19 @@
|
|||||||
handleStringifiedFile = (stringifiedFile) => {
|
handleStringifiedFile = (stringifiedFile) => {
|
||||||
const file = parseValidObject(stringifiedFile, FileReference);
|
const file = parseValidObject(stringifiedFile, FileReference);
|
||||||
if (file == null) return;
|
if (file == null) return;
|
||||||
this.handleFile(file);
|
this.handleFileAndClearContents(file);
|
||||||
};
|
};
|
||||||
handleFile = (file) => {
|
handleFileAndClearContents = (file) => {
|
||||||
for (const fileContent of file.contentVersions) {
|
for (const fileContent of file.contentVersions) {
|
||||||
this.storeFileContent(file, fileContent);
|
this.storeFileContent(file, fileContent);
|
||||||
this.taskModel.handleTaskFileContent(file, fileContent);
|
this.taskModel.handleTaskFileContent(file, fileContent);
|
||||||
|
file.contentVersions.delete(fileContent);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
// methods
|
// methods
|
||||||
addOrUpdateFile = (file) => {
|
addOrUpdateFile = (file) => {
|
||||||
this.handleFile(file);
|
|
||||||
this.chatModel.sendMessage("", file);
|
this.chatModel.sendMessage("", file);
|
||||||
|
this.handleFileAndClearContents(file);
|
||||||
};
|
};
|
||||||
// storage
|
// storage
|
||||||
storeFileContent = (file, fileContent) => {
|
storeFileContent = (file, fileContent) => {
|
||||||
@@ -578,10 +578,6 @@
|
|||||||
listFileIds = () => {
|
listFileIds = () => {
|
||||||
return this.storageModel.list(this.getBasePath());
|
return this.storageModel.list(this.getBasePath());
|
||||||
};
|
};
|
||||||
listFileContents = (file) => {
|
|
||||||
const filePath = this.getFilePath(file.id);
|
|
||||||
return this.storageModel.list(filePath);
|
|
||||||
};
|
|
||||||
getFile = (fileId) => {
|
getFile = (fileId) => {
|
||||||
const filePath = this.getFilePath(fileId);
|
const filePath = this.getFilePath(fileId);
|
||||||
const fileOrNull = this.storageModel.readStringifiable(
|
const fileOrNull = this.storageModel.readStringifiable(
|
||||||
@@ -590,6 +586,10 @@
|
|||||||
);
|
);
|
||||||
return fileOrNull;
|
return fileOrNull;
|
||||||
};
|
};
|
||||||
|
listFileContents = (file) => {
|
||||||
|
const filePath = this.getFilePath(file.id);
|
||||||
|
return this.storageModel.list(filePath);
|
||||||
|
};
|
||||||
getLatestFileContentName = (fileContentNames) => {
|
getLatestFileContentName = (fileContentNames) => {
|
||||||
return fileContentNames[fileContentNames.length - 1];
|
return fileContentNames[fileContentNames.length - 1];
|
||||||
};
|
};
|
||||||
@@ -2567,10 +2567,4 @@
|
|||||||
ConnectionModal(connectionViewModel),
|
ConnectionModal(connectionViewModel),
|
||||||
StorageModal(storageViewModel)
|
StorageModal(storageViewModel)
|
||||||
);
|
);
|
||||||
console.log(
|
|
||||||
checkMatchesObjectStructure(
|
|
||||||
{ a: 1, c: /* @__PURE__ */ new Set() },
|
|
||||||
{ a: 2, c: /* @__PURE__ */ new Set(["bla"]) }
|
|
||||||
)
|
|
||||||
);
|
|
||||||
})();
|
})();
|
||||||
|
|||||||
@@ -26,6 +26,12 @@ export default class FileModel {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
getModelDirectoryPath = (
|
||||||
|
modelName: keyof typeof modelDirectories
|
||||||
|
): string[] => {
|
||||||
|
return [...this.getBasePath(), modelName];
|
||||||
|
};
|
||||||
|
|
||||||
getFilePath = (fileId: string): string[] => {
|
getFilePath = (fileId: string): string[] => {
|
||||||
return [...this.getBasePath(), fileId];
|
return [...this.getBasePath(), fileId];
|
||||||
};
|
};
|
||||||
@@ -140,6 +146,11 @@ export default class FileModel {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// paths
|
||||||
|
export const modelDirectories = {
|
||||||
|
taskModel: "tasks",
|
||||||
|
};
|
||||||
|
|
||||||
// types
|
// types
|
||||||
export interface File extends ValidObject {
|
export interface File extends ValidObject {
|
||||||
id: string;
|
id: string;
|
||||||
|
|||||||
@@ -13,6 +13,31 @@ export default class TaskModel {
|
|||||||
chatModel: ChatModel;
|
chatModel: ChatModel;
|
||||||
fileModel: FileModel;
|
fileModel: FileModel;
|
||||||
|
|
||||||
|
// paths
|
||||||
|
getBasePath = (): string[] => {
|
||||||
|
return this.fileModel.getModelDirectoryPath("taskModel");
|
||||||
|
};
|
||||||
|
|
||||||
|
getLocationDirPath = (): string[] => {
|
||||||
|
return [...this.getBasePath(), subDirectories.locations];
|
||||||
|
};
|
||||||
|
|
||||||
|
getTaskLocationPath = (fileId: string): string[] => {
|
||||||
|
return [...this.getLocationDirPath(), fileId];
|
||||||
|
};
|
||||||
|
|
||||||
|
getBoardDirPath = (): string[] => {
|
||||||
|
return [...this.getBasePath(), subDirectories.boards];
|
||||||
|
};
|
||||||
|
|
||||||
|
getBoardPath = (boardName: string): string[] => {
|
||||||
|
return [...this.getBoardDirPath(), boardName];
|
||||||
|
};
|
||||||
|
|
||||||
|
getTaskPath = (boardName: string, fileId: string): string[] => {
|
||||||
|
return [...this.getBoardPath(boardName), fileId];
|
||||||
|
};
|
||||||
|
|
||||||
// handler
|
// handler
|
||||||
handleTaskFileContent = (
|
handleTaskFileContent = (
|
||||||
file: File,
|
file: File,
|
||||||
@@ -42,6 +67,12 @@ export default class TaskModel {
|
|||||||
this.fileModel.addOrUpdateFile(file);
|
this.fileModel.addOrUpdateFile(file);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// locations
|
||||||
|
updateTaskLocation = (
|
||||||
|
file: File,
|
||||||
|
taskFileContent: TaskFileContent
|
||||||
|
): void => {};
|
||||||
|
|
||||||
// init
|
// init
|
||||||
constructor(chatModel: ChatModel, fileModel: FileModel) {
|
constructor(chatModel: ChatModel, fileModel: FileModel) {
|
||||||
this.chatModel = chatModel;
|
this.chatModel = chatModel;
|
||||||
@@ -64,6 +95,11 @@ export default class TaskModel {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const subDirectories = {
|
||||||
|
locations: "locations",
|
||||||
|
boards: "boards",
|
||||||
|
};
|
||||||
|
|
||||||
// types
|
// types
|
||||||
export interface TaskFileContent extends FileContent<"task"> {
|
export interface TaskFileContent extends FileContent<"task"> {
|
||||||
name: string;
|
name: string;
|
||||||
|
|||||||
@@ -184,11 +184,11 @@ export const filePaths = {
|
|||||||
info: (id: string) => [...filePaths.chat.chatBase(id), "info"],
|
info: (id: string) => [...filePaths.chat.chatBase(id), "info"],
|
||||||
color: (id: string) => [...filePaths.chat.chatBase(id), "color"],
|
color: (id: string) => [...filePaths.chat.chatBase(id), "color"],
|
||||||
messages: (id: string) => [...filePaths.chat.chatBase(id), "messages"],
|
messages: (id: string) => [...filePaths.chat.chatBase(id), "messages"],
|
||||||
files: (id: string) => [...filePaths.chat.chatBase(id), "files"],
|
|
||||||
lastUsedPage: (id: string) => [
|
lastUsedPage: (id: string) => [
|
||||||
...filePaths.chat.chatBase(id),
|
...filePaths.chat.chatBase(id),
|
||||||
"last-used-page",
|
"last-used-page",
|
||||||
],
|
],
|
||||||
|
files: (id: string) => [...filePaths.chat.chatBase(id), "files"],
|
||||||
},
|
},
|
||||||
|
|
||||||
settingsModel: {
|
settingsModel: {
|
||||||
|
|||||||
Reference in New Issue
Block a user