use editor data

This commit is contained in:
Jan Prochazka
2021-03-07 11:38:02 +01:00
parent 00d5b25baa
commit f4fe5b9b53
7 changed files with 204 additions and 8 deletions

View File

@@ -0,0 +1,28 @@
import { openedTabs } from '../stores';
export class LoadingToken {
isCanceled = false;
cancel() {
this.isCanceled = true;
}
}
export function sleep(milliseconds) {
return new Promise(resolve => window.setTimeout(() => resolve(null), milliseconds));
}
export function changeTab(tabid, changeFunc) {
openedTabs.update(files => files.map(tab => (tab.tabid == tabid ? changeFunc(tab) : tab)));
}
export function setSelectedTabFunc(files, tabid) {
return [
...(files || []).filter(x => x.tabid != tabid).map(x => ({ ...x, selected: false })),
...(files || []).filter(x => x.tabid == tabid).map(x => ({ ...x, selected: true })),
];
}
export function setSelectedTab(tabid) {
openedTabs.update(tabs => setSelectedTabFunc(tabs, tabid));
}