mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-19 11:56:00 +00:00
use editor data
This commit is contained in:
28
packages/web/src/utility/common.ts
Normal file
28
packages/web/src/utility/common.ts
Normal 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));
|
||||
}
|
||||
Reference in New Issue
Block a user