unsaved file marker

This commit is contained in:
Jan Prochazka
2022-09-29 13:58:09 +02:00
parent 1382461bdc
commit 7604889b72
7 changed files with 59 additions and 14 deletions

View File

@@ -1,4 +1,4 @@
import { openedTabs } from '../stores';
import { getOpenedTabs, openedTabs } from '../stores';
import _ from 'lodash';
import getElectron from './getElectron';
@@ -18,6 +18,16 @@ export function changeTab(tabid, changeFunc) {
openedTabs.update(files => files.map(tab => (tab.tabid == tabid ? changeFunc(tab) : tab)));
}
export function markTabUnsaved(tabid) {
const tab = getOpenedTabs().find(x => x.tabid == tabid);
if (tab.unsaved) return;
openedTabs.update(files => files.map(tab => (tab.tabid == tabid ? { ...tab, unsaved: true } : tab)));
}
export function markTabSaved(tabid) {
openedTabs.update(files => files.map(tab => (tab.tabid == tabid ? { ...tab, unsaved: false } : tab)));
}
export function setSelectedTabFunc(files, tabid) {
return [
...(files || []).filter(x => x.tabid != tabid).map(x => ({ ...x, selected: false })),