Skip to content

Commit

Permalink
Fix App Init System
Browse files Browse the repository at this point in the history
  • Loading branch information
kemzops committed Mar 15, 2023
1 parent 0c683d3 commit b9c4dac
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 26 deletions.
7 changes: 4 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@ const fs = require('fs-extra');
app.setAppUserModelId("org.altaqwaa.rn0x");
const appInitialization = require('./modules/appInitialization.js');
const App_Path = path.join(app?.getPath("appData"), './altaqwaa');
const settings = fs.readJsonSync(path.join(App_Path, './data/settings.json'));
appInitialization(path, fs, App_Path);

/* App Main Code Start Here */
app.on('ready', (e) => {
app.on('ready', async (e) => {
e.preventDefault();

await appInitialization(path, fs, App_Path);
const settings = fs.readJsonSync(path.join(App_Path, './data/settings.json'));

let loadingWindow

if (process.argv.includes('--hidden')) {
Expand Down
46 changes: 23 additions & 23 deletions src/modules/appInitialization.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,26 @@
module.exports = async (path, fs, App_Path) => {

fs.existsSync(App_Path) ? true : fs.mkdirsSync(App_Path, { recursive: true });
fs.existsSync(App_Path) ? true : await fs.mkdirsSync(App_Path, { recursive: true });

fs.existsSync(path.join(App_Path, "./data")) ? true :
fs.mkdirsSync(path.join(App_Path, "./data"), { recursive: true });
await fs.mkdirsSync(path.join(App_Path, "./data"), { recursive: true });

fs.existsSync(path.join(App_Path, "./data/settings.json")) ? true :
await fs.writeJsonSync(path.join(App_Path, './data/settings.json'), {
"Calculation": "UmmAlQura",
"notifications_adhan": true,
"notifications_adhkar": true,
"autostart": true,
"startHidden": false,
"minimizeToPanel": false,
"morning_adhkar_time": "",
"evening_adhkar_time": "",
"dark_mode": true,
"font_size_quran": 30,
"font_size_adhkar": 30,
"volume": 1,
"adhanVolume": 1,
});

if (!fs.existsSync(path.join(App_Path, './data/location.json'))) {

Expand All @@ -15,7 +32,7 @@ module.exports = async (path, fs, App_Path) => {
if (status !== 200) return
let body = await response?.json();

fs.writeJsonSync(path.join(App_Path, './data/location.json'), {
await fs.writeJsonSync(path.join(App_Path, './data/location.json'), {
country: body?.country,
countryCode: body?.countryCode,
regionName: body?.regionName,
Expand All @@ -33,29 +50,12 @@ module.exports = async (path, fs, App_Path) => {
}

fs.existsSync(path.join(App_Path, "./data/Now.json")) ? true :
fs.writeJsonSync(path.join(App_Path, './data/Now.json'), { "id": "surah_number_1" });
await fs.writeJsonSync(path.join(App_Path, './data/Now.json'), { "id": "surah_number_1" });

fs.existsSync(path.join(App_Path, "./data/audio_window.json")) ? fs.writeJsonSync(path.join(App_Path, './data/audio_window.json'), { "start": false }) :
fs.writeJsonSync(path.join(App_Path, './data/audio_window.json'), { "start": false });

fs.existsSync(path.join(App_Path, "./data/settings.json")) ? true :
fs.writeJsonSync(path.join(App_Path, './data/settings.json'), {
"Calculation": "UmmAlQura",
"notifications_adhan": true,
"notifications_adhkar": true,
"autostart": true,
"startHidden": false,
"minimizeToPanel": false,
"morning_adhkar_time": "",
"evening_adhkar_time": "",
"dark_mode": true,
"font_size_quran": 30,
"font_size_adhkar": 30,
"volume": 1,
"adhanVolume": 1,
});
await fs.writeJsonSync(path.join(App_Path, './data/audio_window.json'), { "start": false });

fs.existsSync(path.join(App_Path, "./data/sound.json")) ? fs.writeJsonSync(path.join(App_Path, './data/sound.json'), { "sound": true }) :
fs.writeJsonSync(path.join(App_Path, './data/sound.json'), { "sound": true });
await fs.writeJsonSync(path.join(App_Path, './data/sound.json'), { "sound": true });

}

0 comments on commit b9c4dac

Please sign in to comment.