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() {
|
delete() {
|
||||||
const parent = this.parent;
|
const parent = this.parent;
|
||||||
|
|
||||||
|
if (parent == null)
|
||||||
|
return;
|
||||||
|
|
||||||
parent.remove?.(this);
|
parent.remove?.(this);
|
||||||
parent.getRoot().saveData();
|
parent.getRoot()?.saveData();
|
||||||
}
|
}
|
||||||
|
|
||||||
open() {}
|
open() {}
|
||||||
|
|
@ -72,7 +76,7 @@ export class VirtualBase extends EventEmitter {
|
||||||
* @returns {VirtualRoot}
|
* @returns {VirtualRoot}
|
||||||
*/
|
*/
|
||||||
getRoot() {
|
getRoot() {
|
||||||
const root = this.root ?? this.parent.getRoot();
|
const root = this.root ?? this.parent?.getRoot();
|
||||||
|
|
||||||
if (root === null) {
|
if (root === null) {
|
||||||
throw new Error("Root not found");
|
throw new Error("Root not found");
|
||||||
|
|
|
||||||
|
|
@ -219,7 +219,7 @@ export class VirtualFolder extends VirtualBase {
|
||||||
removeFromArray(child, this.subFolders);
|
removeFromArray(child, this.subFolders);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.getRoot().saveData();
|
this.getRoot()?.saveData();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -284,7 +284,7 @@ export class VirtualFolder extends VirtualBase {
|
||||||
item.delete();
|
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
|
* A virtual folder that serves as the root folder
|
||||||
*/
|
*/
|
||||||
export class VirtualRoot extends VirtualFolder {
|
export class VirtualRoot extends VirtualFolder {
|
||||||
|
/**
|
||||||
|
* @type {boolean}
|
||||||
|
*/
|
||||||
initiated = false;
|
initiated = false;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
|
|
@ -177,6 +180,13 @@ export class VirtualRoot extends VirtualFolder {
|
||||||
return this;
|
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) {
|
static isValidName(name) {
|
||||||
// TO DO
|
// TO DO
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue