Skip to content

Commit

Permalink
Misc: small changes to satisfy eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
Leleat committed Apr 7, 2024
1 parent 5c6f756 commit 50a1757
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 11 deletions.
23 changes: 20 additions & 3 deletions tiling-assistant@leleat-on-github/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -301,10 +301,22 @@ export default class TilingAssistantExtension extends Extension {
const userPath = GLib.get_user_config_dir();
const parentPath = GLib.build_filenamev([userPath, '/tiling-assistant']);
const parent = Gio.File.new_for_path(parentPath);
try { parent.make_directory_with_parents(null); } catch (e) {}

try {
parent.make_directory_with_parents(null);
} catch (e) {
logError(e);
}

const path = GLib.build_filenamev([parentPath, '/tiledSessionRestore.json']);
const file = Gio.File.new_for_path(path);
try { file.create(Gio.FileCreateFlags.NONE, null); } catch (e) {}

try {
file.create(Gio.FileCreateFlags.NONE, null);
} catch (e) {
logError(e);
}

file.replace_contents(JSON.stringify(saveObj), null, false,
Gio.FileCreateFlags.REPLACE_DESTINATION, null);
}
Expand All @@ -325,7 +337,12 @@ export default class TilingAssistantExtension extends Extension {
if (!file.query_exists(null))
return;

try { file.create(Gio.FileCreateFlags.NONE, null); } catch (e) {}
try {
file.create(Gio.FileCreateFlags.NONE, null);
} catch (e) {
logError(e);
}

const [success, contents] = file.load_contents(null);
if (!success || !contents.length)
return;
Expand Down
12 changes: 6 additions & 6 deletions tiling-assistant@leleat-on-github/src/extension/resizeHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,20 @@ export default class TilingResizeHandler {
global.display.connectObject(
'grab-op-begin',
(d, window, grabOp) => {
grabOp &= ~1024; // META_GRAB_OP_WINDOW_FLAG_UNCONSTRAINED
grabOp &= ~1024; // META_GRAB_OP_WINDOW_FLAG_UNCONSTRAINED

if (window && isResizing(grabOp))
this._onResizeStarted(window, grabOp);
if (window && isResizing(grabOp))
this._onResizeStarted(window, grabOp);
},
this
);
global.display.connectObject(
'grab-op-end',
(d, window, grabOp) => {
grabOp &= ~1024; // META_GRAB_OP_WINDOW_FLAG_UNCONSTRAINED
grabOp &= ~1024; // META_GRAB_OP_WINDOW_FLAG_UNCONSTRAINED

if (window && isResizing(grabOp))
this._onResizeFinished(window, grabOp);
if (window && isResizing(grabOp))
this._onResizeFinished(window, grabOp);
},
this
);
Expand Down
14 changes: 12 additions & 2 deletions tiling-assistant@leleat-on-github/src/prefs/layoutsPrefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,23 @@ export default class {
const dirLocation = parentPath ||
GLib.build_filenamev([userConfigDir, '/tiling-assistant']);
const parentDir = Gio.File.new_for_path(dirLocation);
try { parentDir.make_directory_with_parents(null); } catch (e) {}

try {
parentDir.make_directory_with_parents(null);
} catch (e) {
logError(e);
}

// Create file, if it doesn't exist.
const fName = fileName || 'layouts.json';
const filePath = GLib.build_filenamev([dirLocation, '/', fName]);
const file = Gio.File.new_for_path(filePath);
try { file.create(Gio.FileCreateFlags.NONE, null); } catch (e) {}

try {
file.create(Gio.FileCreateFlags.NONE, null);
} catch (e) {
logError(e);
}

return file;
}
Expand Down

0 comments on commit 50a1757

Please sign in to comment.