Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,11 @@ async function startApp() {
app.quit();
}
});

app.on("will-quit", async () => {
console.log("will-quit");
await tools.destroy();
});
}

startApp();
6,667 changes: 1,387 additions & 5,280 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"fix-path": "4.0.0",
"jquery": "3.7.1",
"jquery-ui": "^1.14.0",
"node-fetch": "3.3.2",
"socks-proxy-agent": "8.0.4",
"web-auto-extractor": "1.0.17"
},
Expand Down
49 changes: 32 additions & 17 deletions tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ const { dialog } = require("electron");
const ApkReader = require("adbkit-apkreader");
const adbkit = require("@devicefarmer/adbkit").default;
const adb = adbkit.createClient();
const fetch = (...args) =>
import("node-fetch").then(({ default: fetch }) => fetch(...args));
const WAE = require("web-auto-extractor").default;
// const HttpProxyAgent = require('https-proxy-agent'); // TODO add https proxy support
const { SocksProxyAgent } = require("socks-proxy-agent");
Expand All @@ -30,7 +28,7 @@ const l = 32;
const configLocationOld = path.join(global.homedir, "sidenoder-config.json");
const configLocation = path.join(global.sidenoderHome, "config.json");

let agentOculus, agentSteam, agentSQ;
let agentOculus, agentSteam, agentSQ, tracker;

init();

Expand Down Expand Up @@ -63,6 +61,7 @@ module.exports = {
trackDevices,
checkDeps,
checkMount,
destroy,
mount,
killRClone,
getDir,
Expand Down Expand Up @@ -908,7 +907,7 @@ async function trackDevices() {
await getDeviceSync();

try {
const tracker = await adb.trackDevices();
tracker = await adb.trackDevices();
tracker.on("add", async (device) => {
console.log("Device was plugged in", device.id);
// await getDeviceSync();
Expand All @@ -926,15 +925,25 @@ async function trackDevices() {
});

tracker.on("end", () => {
console.error("Tracking stopped");
trackDevices();
console.log("Tracking stopped");
});
} catch (err) {
console.error("Something went wrong:", err.stack);
returnError(err);
}
}

async function destroy() {
try {
await killRClone();
} catch (_err) {
console.log("rclone not started");
}

tracker.end();
tracker = null;
}

async function appInfo(args) {
const { res, pkg } = args;
const app = KMETAS[pkg];
Expand Down Expand Up @@ -1495,7 +1504,7 @@ async function killRClone() {
platform == "win"
? `taskkill.exe /F /T /IM rclone.exe`
: `killall -9 rclone`;
console.log("try kill rclone");
console.log("killing rclone");
return new Promise((res, rej) => {
exec(killCmd, (error, stdout, stderr) => {
if (error) {
Expand Down Expand Up @@ -1624,17 +1633,23 @@ async function mount() {
exec(
`"${rcloneCmd}" ${mountCmd} --read-only --rc --rc-no-auth --config="${global.currentConfiguration.rcloneConf}" ${global.currentConfiguration.cfgSection}: "${global.mountFolder}"`,
(error, stdout, stderr) => {
if (error) {
console.error("rclone error:", error);
if (RCLONE_ID != myId) error = false;
console.log({ RCLONE_ID, myId });
win.webContents.send("check_mount", { success: false, error });
// checkMount();
/*if (error.message.search('transport endpoint is not connected')) {
console.log('GEVONDE');
}*/
try {
// We need to use a try/catch here because the callback may have been
// called after rclone has been closed.
if (error) {
if (!tracker) {
// Window is closing
return;
}
console.error("rclone error:", error);
if (RCLONE_ID != myId) error = false;
console.log({ RCLONE_ID, myId });
win.webContents.send("check_mount", { success: false, error });

return;
return;
}
} catch (e) {
// Do nothing
}

if (stderr) {
Expand Down
2 changes: 0 additions & 2 deletions versioncheck.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
const pkg = require("./package.json");
const fetch = (...args) =>
import("node-fetch").then(({ default: fetch }) => fetch(...args));
const compareVersions = require("compare-versions");
global.version = pkg.version;

Expand Down
2 changes: 1 addition & 1 deletion views/browse_include.twig
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
>
<a
class="btn btn-md btn-primary"
onclick="openSearch()"
onclick="toggleSearch()"
title="(hotkey: ctrl+f)"
>
<i class="fa fa-search"></i> Search</a
Expand Down
78 changes: 46 additions & 32 deletions views/js/search.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*eslint no-unused-vars: ["error", {
"varsIgnorePattern": "openSearch|sortItems"
"varsIgnorePattern": "toggleSearch|sortItems"
}]*/

/**
Expand Down Expand Up @@ -34,13 +34,19 @@ class FindDialog {
/**
* Toggle the visibility of the search box.
*
* @param {boolean} [display] Use true to show the element or false to hide it.
*
* @return {this} The instance of FindDialog.
*/
toggle() {
$(".find-box").toggle();
toggle(display) {
if (typeof display !== "undefined") {
$(".find-box").toggle(display);
} else {
$(".find-box").toggle();
}
this.clear();

if (this.isVisible) {
if (FindDialog.isVisible) {
this.dom.style.top = this.calcSearchTop;
this.focus();
}
Expand Down Expand Up @@ -71,10 +77,11 @@ class FindDialog {
/**
* Get search box visibility
*
* @static
* @readonly
* @type {boolean} Is visible
*/
get isVisible() {
static get isVisible() {
const $findBox = $(".find-box");
return $findBox.length > 0 && $findBox.css("display") !== "none";
}
Expand Down Expand Up @@ -119,7 +126,6 @@ class FindDialog {
destroy() {
document.removeEventListener("keydown", this._onKeydown);
document.removeEventListener("keydown", this._onResize);
this._onKeydown = null;
this._onResize = null;
this._handler = null;
FindDialog.instance = null;
Expand All @@ -137,17 +143,7 @@ class FindDialog {
* changed.
*/
#addListeners() {
if (!this._onKeydown) {
this._onKeydown = (event) => {
const { code, ctrlKey, metaKey } = event;
if (
(code === "KeyF" && (ctrlKey || metaKey)) ||
(code === "Escape" && this.isVisible)
) {
this.toggle();
}
};

if (!this._onResize) {
this._onResize = () => {
const navPanel = document.querySelector("#nav-panel");

Expand All @@ -174,7 +170,6 @@ class FindDialog {
this.toggle(false);
};

document.addEventListener("keydown", this._onKeydown);
window.addEventListener("resize", this._onResize);
$(document).on("newTemplate", this._onNewTemplate);
}
Expand Down Expand Up @@ -273,7 +268,7 @@ class FindDialog {
* The text is treated as a case-insensitive string, and the search is done
* using the includes() method.
*/
function openSearch() {
function toggleSearch() {
if (FindDialog.exists) {
FindDialog.instance.toggle();
} else {
Expand Down Expand Up @@ -312,6 +307,27 @@ function openSearch() {
}
}

document.addEventListener("keydown", (event) => {
const { code, ctrlKey, metaKey } = event;
const platform = remote.getGlobal("platform");

// Ignore [Ctrl]+[f] on Mac
if (ctrlKey && platform === "mac") {
return;
}

// Toggle the search dialog on:
// 1. [Meta]+[f] on a Mac
// 2. [Ctrl]+[f] on Windows
// 3. [Esc] on any platform if the search dialog is visible
if (
((ctrlKey || metaKey) && code === "KeyF") ||
(code === "Escape" && FindDialog.isVisible)
) {
toggleSearch();
}
});

/**
* Sorts two elements by their data-key attribute in ascending or descending order
* @param {String} key - the data-key attribute to sort by
Expand All @@ -320,19 +336,17 @@ function openSearch() {
*/
function sortBy(key, asc) {
return (a, b) => {
return (a, b) => {
var valA = $(a).data(key);
var valB = $(b).data(key);
if (valA < valB) {
return asc ? -1 : 1;
}

if (valA > valB) {
return asc ? 1 : -1;
}

return 0;
};
var valA = $(a).data(key);
var valB = $(b).data(key);
if (valA < valB) {
return asc ? -1 : 1;
}

if (valA > valB) {
return asc ? 1 : -1;
}

return 0;
};
}

Expand Down
6 changes: 3 additions & 3 deletions views/modals/app_tools.twig
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
console.log('app_tools msg came: ', arg);
$id('processingModal').modal('hide');

const { package, backupPath, availableRestore, availableConfig } = arg;
const { pkg, backupPath, availableRestore, availableConfig } = arg;

$id('packageName').text(pkg);

Expand Down Expand Up @@ -170,7 +170,7 @@
});
$id('backupAppPath').click((e) => {
shell.openPath(
path.join(remote.getGlobal('sidenoderHome'), 'backup_data', package),
path.join(remote.getGlobal('sidenoderHome'), 'backup_data', pkg),
);
return true;
});
Expand All @@ -189,7 +189,7 @@
.change(({ target }) => {
$(target).removeClass('is-valid');
ipcRenderer.send('app_config_set', {
package,
pkg,
key: 'username',
val: target.value,
});
Expand Down
2 changes: 1 addition & 1 deletion views/modals/installed.twig
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<i class="fa fa-list"></i> Installed APP's
</div>
<div class="float-right ml-4">
<a class="btn btn-md btn-primary" onclick="openSearch()">
<a class="btn btn-md btn-primary" onclick="toggleSearch()">
<i class="fa fa-search"></i> Search</a
>
<a
Expand Down