mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-23 06:56:01 +00:00
29 lines
765 B
TypeScript
29 lines
765 B
TypeScript
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));
|
|
}
|