mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-21 16:26:00 +00:00
29 lines
708 B
TypeScript
29 lines
708 B
TypeScript
import { writable } from "svelte/store";
|
|
|
|
export const statusBarTabInfo = writable({});
|
|
|
|
// export function updateStatuBarInfo(tabid, info) {
|
|
// statusBarTabInfo.update(x => ({
|
|
// ...x,
|
|
// [tabid]: info,
|
|
// }));
|
|
// }
|
|
|
|
export function updateStatuBarInfoItem(tabid, key, item) {
|
|
statusBarTabInfo.update(tabs => {
|
|
const items = tabs[tabid] || [];
|
|
let newItems;
|
|
if (item == null) {
|
|
newItems = items.filter(x => x.key != key);
|
|
} else if (items.find(x => x.key == key)) {
|
|
newItems = items.map(x => (x.key == key ? { ...item, key } : x));
|
|
} else {
|
|
newItems = [...items, { ...item, key }];
|
|
}
|
|
return {
|
|
...tabs,
|
|
[tabid]: newItems,
|
|
};
|
|
});
|
|
}
|