➕ 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": [
|
||||
{
|
||||
"name": "cool1",
|
||||
"domain": "freechat.shockrah.io",
|
||||
"ip": "0.0.0.0",
|
||||
"description": "really good",
|
||||
"key": "this right here is the secret for that user",
|
||||
"username": "this is optional per server"
|
||||
},
|
||||
{
|
||||
"name": "another one"
|
||||
},
|
||||
{
|
||||
"name": "shockrah's lair"
|
||||
}
|
||||
],
|
||||
|
||||
"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"
|
||||
"servers": [
|
||||
{
|
||||
"server": {
|
||||
"description": "Server for sick development things",
|
||||
"hostname": "localhost",
|
||||
"name": "Freechat Sample Server",
|
||||
"port": 4536,
|
||||
"protocol": "http"
|
||||
},
|
||||
"user": {
|
||||
"id": 1,
|
||||
"joindate": 1615187538,
|
||||
"name": "shockrah",
|
||||
"permissions": 51,
|
||||
"secret": "ooky-spooky-base64-string===",
|
||||
"status": 0
|
||||
}
|
||||
}
|
||||
],
|
||||
"username": "shockrah"
|
||||
}
|
||||
|
||||
|
@ -1,12 +1,21 @@
|
||||
const { ipcMain } = require('electron')
|
||||
const { app, BrowserWindow } = require('electron')
|
||||
const { ArgumentParser } = require('argparse')
|
||||
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 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
|
||||
// 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) {
|
||||
return config;
|
||||
})
|
||||
|
||||
|
||||
ipcMain.handle('config-update', function(event, data) {
|
||||
config = data;
|
||||
cfg.update_file(data, data['path']);
|
||||
ipcMain.handle('config-update', async function(event, updated_config) {
|
||||
config = new Config(updated_config.path, updated_config.data)
|
||||
await config.write_disk()
|
||||
})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user