Toasts and name conflict handler
This commit is contained in:
parent
97519b2307
commit
9773f78506
|
@ -25,7 +25,8 @@
|
||||||
:readSnippet="readSnippet"
|
:readSnippet="readSnippet"
|
||||||
:injectStyle="injectStyle"
|
:injectStyle="injectStyle"
|
||||||
:toggleLiveUpdate="toggleLiveUpdate"
|
:toggleLiveUpdate="toggleLiveUpdate"
|
||||||
:ctxAction="ctxAction"/>
|
:ctxAction="ctxAction"
|
||||||
|
:toast="toast"/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -60,7 +61,8 @@
|
||||||
loading: true,
|
loading: true,
|
||||||
alwaysOnTop: false,
|
alwaysOnTop: false,
|
||||||
error: undefined,
|
error: undefined,
|
||||||
lastSaved: undefined
|
lastSaved: undefined,
|
||||||
|
toast: { active: false, msg: '' }
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
components: { BDEdit },
|
components: { BDEdit },
|
||||||
|
@ -218,15 +220,23 @@
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
const { oldName, newName } = item;
|
const { oldName, newName } = item;
|
||||||
|
|
||||||
|
if (this.files.find(f => f.name === newName)) {
|
||||||
|
this.loading = false;
|
||||||
|
this.showToast('err', `File ${newName} already exists`);
|
||||||
|
return {
|
||||||
|
err: `File ${newName} already exists`
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await ClientIPC.send('rnFile', { oldName: ['userfiles', oldName], newName: ['userfiles', newName] });
|
await ClientIPC.send('rnFile', { oldName: ['userfiles', oldName], newName: ['userfiles', newName] });
|
||||||
|
return item;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
|
return { err };
|
||||||
} finally {
|
} finally {
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (action === 'delete') {
|
if (action === 'delete') {
|
||||||
|
@ -242,6 +252,11 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
showToast(type, msg, timeout = 3000) {
|
||||||
|
this.toast = { active: true, type, msg };
|
||||||
|
setTimeout(() => { this.toast.active = false }, timeout);
|
||||||
|
},
|
||||||
|
|
||||||
toggleLiveUpdate(item) {
|
toggleLiveUpdate(item) {
|
||||||
item.liveUpdateEnabled = !item.liveUpdateEnabled;
|
item.liveUpdateEnabled = !item.liveUpdateEnabled;
|
||||||
return item;
|
return item;
|
||||||
|
|
Loading…
Reference in New Issue