Added reset function for virtual drive
This commit is contained in:
parent
47525f1347
commit
57f85d7fa6
3 changed files with 18 additions and 4 deletions
|
|
@ -54,8 +54,12 @@ export class VirtualBase extends EventEmitter {
|
|||
|
||||
delete() {
|
||||
const parent = this.parent;
|
||||
|
||||
if (parent == null)
|
||||
return;
|
||||
|
||||
parent.remove?.(this);
|
||||
parent.getRoot().saveData();
|
||||
parent.getRoot()?.saveData();
|
||||
}
|
||||
|
||||
open() {}
|
||||
|
|
@ -72,7 +76,7 @@ export class VirtualBase extends EventEmitter {
|
|||
* @returns {VirtualRoot}
|
||||
*/
|
||||
getRoot() {
|
||||
const root = this.root ?? this.parent.getRoot();
|
||||
const root = this.root ?? this.parent?.getRoot();
|
||||
|
||||
if (root === null) {
|
||||
throw new Error("Root not found");
|
||||
|
|
|
|||
|
|
@ -219,7 +219,7 @@ export class VirtualFolder extends VirtualBase {
|
|||
removeFromArray(child, this.subFolders);
|
||||
}
|
||||
|
||||
this.getRoot().saveData();
|
||||
this.getRoot()?.saveData();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -284,7 +284,7 @@ export class VirtualFolder extends VirtualBase {
|
|||
item.delete();
|
||||
});
|
||||
|
||||
this.getRoot().saveData();
|
||||
this.getRoot()?.saveData();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -8,6 +8,9 @@ export const WALLPAPER_COUNT = 6;
|
|||
* A virtual folder that serves as the root folder
|
||||
*/
|
||||
export class VirtualRoot extends VirtualFolder {
|
||||
/**
|
||||
* @type {boolean}
|
||||
*/
|
||||
initiated = false;
|
||||
|
||||
constructor() {
|
||||
|
|
@ -177,6 +180,13 @@ export class VirtualRoot extends VirtualFolder {
|
|||
return this;
|
||||
}
|
||||
|
||||
reset() {
|
||||
if (window.confirm("Are you sure you want to reset all your data?")) {
|
||||
StorageManager.clear();
|
||||
window.location.reload(false);
|
||||
}
|
||||
}
|
||||
|
||||
static isValidName(name) {
|
||||
// TO DO
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue