➕ More comprehensive example user config
➕ Moving main.js to use more async code and make things a bit more homogeneous
This commit is contained in:
parent
7125fc954d
commit
c4e3fa72ce
@ -1,22 +1,23 @@
|
|||||||
{
|
{
|
||||||
"servers": [
|
"servers": [
|
||||||
{
|
{
|
||||||
"name": "cool1",
|
"server": {
|
||||||
"domain": "freechat.shockrah.io",
|
"description": "Server for sick development things",
|
||||||
"ip": "0.0.0.0",
|
"hostname": "localhost",
|
||||||
"description": "really good",
|
"name": "Freechat Sample Server",
|
||||||
"key": "this right here is the secret for that user",
|
"port": 4536,
|
||||||
"username": "this is optional per server"
|
"protocol": "http"
|
||||||
},
|
},
|
||||||
{
|
"user": {
|
||||||
"name": "another one"
|
"id": 1,
|
||||||
},
|
"joindate": 1615187538,
|
||||||
{
|
"name": "shockrah",
|
||||||
"name": "shockrah's lair"
|
"permissions": 51,
|
||||||
}
|
"secret": "ooky-spooky-base64-string===",
|
||||||
],
|
"status": 0
|
||||||
|
}
|
||||||
"ignore-me": "global's like this are mainly for default configuration things",
|
}
|
||||||
"global-username": "shockrah",
|
],
|
||||||
"global-proxy": "one day this will be a thing but not today"
|
"username": "shockrah"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,12 +1,21 @@
|
|||||||
const { ipcMain } = require('electron')
|
const { ipcMain } = require('electron')
|
||||||
const { app, BrowserWindow } = require('electron')
|
const { app, BrowserWindow } = require('electron')
|
||||||
|
const { ArgumentParser } = require('argparse')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
|
|
||||||
const cfg = require('./src/config.js')
|
const { Config, from_cli_parser } = require('./src/config.js')
|
||||||
|
|
||||||
|
const arguments = (() => {
|
||||||
|
const parser = new ArgumentParser({
|
||||||
|
description: 'Freechat client'
|
||||||
|
})
|
||||||
|
parser.add_argument('-c', '--config', {help: 'Specify config path'})
|
||||||
|
return parser
|
||||||
|
})()
|
||||||
|
|
||||||
|
|
||||||
let win
|
let win
|
||||||
let config = cfg.get_config(cfg.load_parser())
|
let config = from_cli_parser(arguments)
|
||||||
|
|
||||||
// NOTE: this line is only here for demonstration as the current make script exposes this var
|
// NOTE: this line is only here for demonstration as the current make script exposes this var
|
||||||
// so that we can test against self signed certificates but still use ssl
|
// so that we can test against self signed certificates but still use ssl
|
||||||
@ -50,14 +59,14 @@ app.on('activate', () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// returns the config
|
// returns the in-memory config reference
|
||||||
ipcMain.handle('config-request', async function(event, _arg) {
|
ipcMain.handle('config-request', async function(event, _arg) {
|
||||||
return config;
|
return config;
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
ipcMain.handle('config-update', function(event, data) {
|
ipcMain.handle('config-update', async function(event, updated_config) {
|
||||||
config = data;
|
config = new Config(updated_config.path, updated_config.data)
|
||||||
cfg.update_file(data, data['path']);
|
await config.write_disk()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user