refactor(ags closer): make array of windows not to close to clarify code
This commit is contained in:
parent
0b4c525cf3
commit
f6588caae3
1 changed files with 12 additions and 4 deletions
|
@ -1,13 +1,19 @@
|
||||||
const { Window, EventBox } = ags.Widget;
|
const { Window, EventBox } = ags.Widget;
|
||||||
const { closeWindow } = ags.App;
|
const { closeWindow } = ags.App;
|
||||||
|
|
||||||
|
const ALWAYS_OPEN = [
|
||||||
|
'closer',
|
||||||
|
'bar',
|
||||||
|
'notifications',
|
||||||
|
];
|
||||||
|
|
||||||
// TODO: close on scroll event too?
|
// TODO: close on scroll event too?
|
||||||
export const closeAll = () => {
|
export const closeAll = () => {
|
||||||
ags.App.windows.forEach(w => {
|
ags.App.windows.forEach(w => {
|
||||||
if (w.name != 'bar' &&
|
if (!ALWAYS_OPEN.some(window => window === w.name))
|
||||||
w.name != 'notifications')
|
|
||||||
ags.App.closeWindow(w.name)
|
ags.App.closeWindow(w.name)
|
||||||
});
|
});
|
||||||
|
closeWindow('closer');
|
||||||
};
|
};
|
||||||
|
|
||||||
export const Closer = Window({
|
export const Closer = Window({
|
||||||
|
@ -18,9 +24,11 @@ export const Closer = Window({
|
||||||
|
|
||||||
child: EventBox({
|
child: EventBox({
|
||||||
onPrimaryClickRelease: () => closeAll(),
|
onPrimaryClickRelease: () => closeAll(),
|
||||||
connections: [[ags.App, (box, windowName, visible) => {
|
connections: [[ags.App, (_b, _w, _v) => {
|
||||||
if (!Array.from(ags.App.windows).some(w => w[1].visible && w[0] != 'bar' && w[0] != 'notifications' && w[0] != 'closer')) {
|
if (!Array.from(ags.App.windows).some(w => w[1].visible &&
|
||||||
|
!ALWAYS_OPEN.some(window => window === w[0]))) {
|
||||||
closeWindow('closer');
|
closeWindow('closer');
|
||||||
|
print('hi')
|
||||||
}
|
}
|
||||||
}]],
|
}]],
|
||||||
}),
|
}),
|
||||||
|
|
Loading…
Reference in a new issue