Final cleanup, ready for packing!
This commit is contained in:
parent
68bda87253
commit
2a97cb358f
6 changed files with 31 additions and 11 deletions
|
@ -11,7 +11,7 @@ module.exports = {
|
|||
},
|
||||
{
|
||||
name: '@electron-forge/maker-zip',
|
||||
platforms: ['darwin'],
|
||||
platforms: ['darwin', 'win32'],
|
||||
},
|
||||
{
|
||||
name: '@electron-forge/maker-deb',
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "ed-safari",
|
||||
"productName": "ed-safari",
|
||||
"version": "0.1.0",
|
||||
"version": "1.0.0",
|
||||
"description": "My Electron application description",
|
||||
"main": ".vite/build/main.js",
|
||||
"scripts": {
|
||||
|
|
|
@ -18,6 +18,7 @@ export class Journal extends EventEmitter {
|
|||
testing: string;
|
||||
location: System;
|
||||
navRoute: System[];
|
||||
#tail?: TailType;
|
||||
|
||||
constructor(journalPath: string) {
|
||||
super();
|
||||
|
@ -218,12 +219,12 @@ export class Journal extends EventEmitter {
|
|||
|
||||
// Watch the journal for changes.
|
||||
watch(): void {
|
||||
const tail: TailType = new Tail(this.#path, {useWatchFile: true});
|
||||
this.#tail = new Tail(this.#path, {useWatchFile: true});
|
||||
|
||||
Log.write(`Watching ${path.basename(this.#path)}...`);
|
||||
|
||||
tail.on('line', (data) => data ? this.#parseLine(data) : undefined);
|
||||
tail.on('error', (err) => Log.write(`Tail error in Journal.watch(): ${err}`));
|
||||
this.#tail?.on('line', (data) => data ? this.#parseLine(data) : undefined);
|
||||
this.#tail?.on('error', (err) => Log.write(`Tail error in Journal.watch(): ${err}`));
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------ #parseLine() ---- */
|
||||
|
@ -296,7 +297,7 @@ export class Journal extends EventEmitter {
|
|||
|
||||
/* --------------------------------------------------------------------- #handleScanLine ---- */
|
||||
|
||||
#handleScanLine(line: autoScan|detailedScan, DSS: boolean = false) {
|
||||
#handleScanLine(line: autoScan|detailedScan, DSS: boolean = false): void {
|
||||
const dupChecker = {'BodyName': line.BodyName, 'BodyID': line.BodyID};
|
||||
let body: Body|null = null;
|
||||
|
||||
|
@ -327,4 +328,10 @@ export class Journal extends EventEmitter {
|
|||
Log.write(`Scan detected. Body: ${line.BodyName}.`);
|
||||
this.emit('BODY_SCANNED', body, DSS);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------------- shutdown ---- */
|
||||
|
||||
shutdown(): void {
|
||||
this.#tail?.unwatch();
|
||||
}
|
||||
}
|
|
@ -14,6 +14,8 @@ export class Safari {
|
|||
#journalPattern?: string;
|
||||
journal?: Journal;
|
||||
|
||||
#watcher?: any;
|
||||
|
||||
private constructor(isPackaged: boolean) {
|
||||
if (!isPackaged && os.platform() === 'linux') { // Account for WSL during development
|
||||
this.#journalDir = "/mnt/c/Users/marle/Saved\ Games/Frontier\ Developments/Elite\ Dangerous/";
|
||||
|
@ -80,9 +82,16 @@ export class Safari {
|
|||
|
||||
watchJournalDir(): void {
|
||||
const options = {usePolling: true, persistent: true, ignoreInitial: true};
|
||||
const watcher = chokidar.watch(this.#journalPattern, options);
|
||||
this.#watcher = chokidar.watch(this.#journalPattern, options);
|
||||
|
||||
watcher.on('ready', () => Log.write('Watching journal folder for changes...'));
|
||||
watcher.on('add', () => this.journal = this.#getLatestJournal());
|
||||
this.#watcher.on('ready', () => Log.write('Watching journal folder for changes...'));
|
||||
this.#watcher.on('add', () => this.journal = this.#getLatestJournal());
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------------- shutdown ---- */
|
||||
|
||||
async shutdown(): Promise<void> {
|
||||
this.journal?.shutdown();
|
||||
await this.#watcher.close();
|
||||
}
|
||||
}
|
|
@ -44,6 +44,7 @@ settings.on('CUSTOM_COLORS_SET', () => {
|
|||
/* -------------------------------------------------------------------- close window handler ---- */
|
||||
|
||||
$('#closeBtn').on('click', () => {
|
||||
safari.shutdown();
|
||||
ipcRenderer.send('CLOSE_WINDOW');
|
||||
});
|
||||
|
||||
|
|
|
@ -7,9 +7,11 @@ const { ipcRenderer } = require('electron');
|
|||
const { setTimeout } = require('node:timers/promises');
|
||||
const { basename } = require('node:path');
|
||||
|
||||
import { Safari } from './models/Safari';
|
||||
import { Settings } from './models/Settings';
|
||||
import { UI } from './models/UI';
|
||||
|
||||
const safari = Safari.start();
|
||||
const settings = Settings.get();
|
||||
|
||||
if (settings.matrix) {
|
||||
|
@ -25,13 +27,14 @@ settings.on('CUSTOM_COLORS_SET', () => {
|
|||
/* -------------------------------------------------------------------- close window handler ---- */
|
||||
|
||||
$('#closeBtn').on('click', () => {
|
||||
ipcRenderer.send('CLOSE_WINDOW')
|
||||
safari.shutdown();
|
||||
ipcRenderer.send('CLOSE_WINDOW');
|
||||
})
|
||||
|
||||
/* ---------------------------------------------------------------- load main window handler ---- */
|
||||
|
||||
$('.backBtn').on('click', () => {
|
||||
ipcRenderer.send('LOAD_MAIN')
|
||||
ipcRenderer.send('LOAD_MAIN');
|
||||
})
|
||||
|
||||
/* ------------------------------------------------------------------- insert current values ---- */
|
||||
|
|
Loading…
Reference in a new issue