diff --git a/freechat-client/src/config.js b/freechat-client/src/config.js index a5d0809..73ba88f 100644 --- a/freechat-client/src/config.js +++ b/freechat-client/src/config.js @@ -1,14 +1,12 @@ const { ArgumentParser } = require('argparse') const fs = require('fs').promises const syncFs = require('fs') - -// required because freechat by default uses i64/u64 in json payloads -// timestamps will get especially rekt'd if we don't parse things correctly -const JSONBig = require('json-bigint') +const JSONBig = require('json-bigint')({storeAsString: true}) class Config { /** * + * TODO: change .data out for something not stupid * @param {String} path path to config on startup * @param {Object} data Contains actual config data */ @@ -39,12 +37,13 @@ exports.from_cli_parser = function(parser) { let ret = new Config(path, {}) // Allow errors from here to bubble up instead of handling them - fs.readFile(path).then(file => { const json = JSONBig.parse(file) + ret.data['servers'] = [] - for(const key of Object.keys(json)) { - ret.data[key] = json[key] + // TODO: redo this so its let 'yolo' + for(const serv of json['servers']) { + ret.data['servers'].push(serv) } }) .catch(err => console.error(err)) @@ -52,26 +51,3 @@ exports.from_cli_parser = function(parser) { return ret } -/** - * Updates the config with the new object data - * Called from node's main process - * - * @param {Config} config new config data to write - * @param {String} path | set to 'default' if we're using $HOME/.config/freechat/config.json - * Set this to anything else to write changes to that specified path - */ -exports.update_file = function(config, path='default') { - if (path == 'default') { - path = `${process.env.HOME || process.env.USERPROFILE}/.config/freechat/config.json` - } else { - path = path - } - - const data = JSON.stringify(config, null, 2) - fs.writeFile(path, data, function(err) { - if(err) { console.error(err) } - else { console.log('fine') } - }) -} - - diff --git a/freechat-client/src/events.ts b/freechat-client/src/events.ts index a5278d1..631bed2 100644 --- a/freechat-client/src/events.ts +++ b/freechat-client/src/events.ts @@ -54,10 +54,4 @@ export class Event { return new Message(mid, time, content, content_type, uid, uname, cid) } - - // Sets up the inner channel data - private _channel(obj: Object) : Channel|null { - // todo: still require some testing to verify event data is appropriate - return null - } }