feature (errorhandling): improve ux while renaming outside happy path

This commit is contained in:
MickaelK 2025-08-19 13:55:03 +10:00
parent a18d17490c
commit f359ed8edc

View file

@ -252,7 +252,11 @@ export function rm(...paths) {
name: arr[i+1], name: arr[i+1],
fn: (file) => { fn: (file) => {
if (file.name === arr[i+1]) { if (file.name === arr[i+1]) {
file = { ...file, loading: false, last: false }; file = {
...file,
loading: false,
last: false
};
} }
return file; return file;
}, },
@ -274,7 +278,7 @@ export function mv(fromPath, toPath) {
*/ */
before() { before() {
if (fromBasepath === toBasepath) this._beforeSamePath(); if (fromBasepath === toBasepath) this._beforeSamePath();
else this._beforeSamePath(); else this._beforeDifferentPath();
} }
_beforeSamePath() { _beforeSamePath() {
@ -282,9 +286,12 @@ export function mv(fromPath, toPath) {
name: fromName, name: fromName,
fn: (file) => { fn: (file) => {
if (file.name === fromName) { if (file.name === fromName) {
file.loading = true;
file.name = toName;
type = file.type; type = file.type;
return {
...file,
name: toName,
loading: true,
};
} }
return file; return file;
}, },
@ -296,9 +303,12 @@ export function mv(fromPath, toPath) {
name: fromName, name: fromName,
fn: (file) => { fn: (file) => {
if (file.name === fromName) { if (file.name === fromName) {
file.loading = true;
file.last = true;
type = file.type; type = file.type;
return {
...file,
loading: true,
last: true,
};
} }
return file; return file;
}, },
@ -374,10 +384,31 @@ export function mv(fromPath, toPath) {
* @override * @override
*/ */
async afterError() { async afterError() {
statePop(mutationFiles$, fromBasepath, fromName); if (fromBasepath === toBasepath) stateAdd(mutationFiles$, fromBasepath, {
if (fromBasepath !== toBasepath) { name: fromName,
fn: (file) => {
if (file.name === toName) return {
...file,
name: fromName,
loading: false,
};
return file;
},
}); else {
stateAdd(mutationFiles$, fromBasepath, {
name: fromName,
fn: (file) => {
if (file.name === fromName) return {
...file,
loading: false,
last: false,
}
return file;
},
});
statePop(virtualFiles$, toBasepath, toName); statePop(virtualFiles$, toBasepath, toName);
} }
statePop(mutationFiles$, fromBasepath, fromName);
return rxjs.EMPTY; return rxjs.EMPTY;
} }
}(); }();