-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removed functions that modified the App's bundle
- Loading branch information
1 parent
431751f
commit 43098e9
Showing
5 changed files
with
73 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,67 @@ | ||
import {debug, storage, filesystem, os} from '@neutralinojs/lib'; | ||
import {pathExists} from './utils'; | ||
import { debug, storage, filesystem, os } from "@neutralinojs/lib"; | ||
import { pathExists } from "./utils"; | ||
|
||
export async function dataPath(): Promise<string> { | ||
return `${await os.getPath('data')}/AppleBlox/.storage`; | ||
return `${await os.getPath("data")}/AppleBlox/config`; | ||
} | ||
|
||
/** Copies the settings folder to Application Support */ | ||
async function copyNeuStorage(panelId: string) { | ||
const path = await dataPath(); | ||
if (!(await pathExists(path))) { | ||
await filesystem.createDirectory(path); | ||
} | ||
try { | ||
const filepath = `${path}/${panelId}.neustorage`; | ||
if (await pathExists(filepath)) { | ||
await filesystem.remove(filepath); | ||
// async function copyNeuStorage(panelId: string) { | ||
// const path = await dataPath(); | ||
// if (!(await pathExists(path))) { | ||
// await filesystem.createDirectory(path); | ||
// } | ||
// try { | ||
// const filepath = `${path}/${panelId}.json`; | ||
// if (await pathExists(filepath)) { | ||
// await filesystem.remove(filepath); | ||
// } | ||
// await filesystem.copy(`${window.NL_PATH}/.storage/${panelId}.json`, filepath); | ||
// } catch (err) { | ||
// console.error(err); | ||
// } | ||
// } | ||
|
||
/** Saves the data provided to the Application Support folder */ | ||
let saveQueue: {path: string,data:string}[] = [] | ||
let hasInterval = false; | ||
if (!hasInterval) { | ||
setInterval(()=>{ | ||
for (const file of saveQueue) { | ||
filesystem.writeFile(file.path,file.data).catch(console.error) | ||
} | ||
await filesystem.copy(`${window.NL_PATH}/.storage/${panelId}.neustorage`, filepath); | ||
} catch (err) { | ||
console.error(err); | ||
} | ||
},1000) | ||
} | ||
|
||
/** Saves the data provided to the Application Support folder */ | ||
export async function saveSettings(panelId: string, data: Object): Promise<void> { | ||
try { | ||
await storage.setData(panelId, JSON.stringify(data)); | ||
copyNeuStorage(panelId); | ||
const path = await dataPath(); | ||
if (!(await pathExists(path))) { | ||
await filesystem.createDirectory(path); | ||
} | ||
try { | ||
const filepath = `${path}/${panelId}.json`; | ||
if (await pathExists(filepath)) { | ||
await filesystem.remove(filepath); | ||
} | ||
saveQueue.push({path: `${path}/${panelId}.json`, data: JSON.stringify(data)}); | ||
} catch (err) { | ||
console.error(err); | ||
} | ||
} catch (err) { | ||
throw err; | ||
} | ||
} | ||
|
||
/** Loads the data from the specified panelID */ | ||
export async function loadSettings(panelId: string): Promise<{[key: string]: Object} | undefined> { | ||
export async function loadSettings(panelId: string): Promise<{ [key: string]: Object } | undefined> { | ||
try { | ||
const filepath = `${await dataPath()}/${panelId}.neustorage`; | ||
const filepath = `${await dataPath()}/${panelId}.json`; | ||
if (!(await pathExists(filepath))) { | ||
return undefined | ||
return undefined; | ||
} | ||
return JSON.parse(await filesystem.readFile(filepath)); | ||
} catch (err) { | ||
console.error(err) | ||
console.error(err); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters