diff --git a/freechat-client/make b/freechat-client/make index c5aaeee..8cf263e 100755 --- a/freechat-client/make +++ b/freechat-client/make @@ -7,7 +7,7 @@ run() { # Required to tests against the self certs we use in testing envs - export NODE_TLS_REJECT_UNAUTHORIZED=0 + export NODE_TLS_REJECT_UNAUTHORIZED='0' export DEV_ENV=true ./node_modules/electron/dist/electron main.js $@ } diff --git a/freechat-client/src/channels.js b/freechat-client/src/channels.js index efab70c..0d6d6c6 100644 --- a/freechat-client/src/channels.js +++ b/freechat-client/src/channels.js @@ -3,6 +3,8 @@ const { ipcRenderer } = require('electron') const auth = require('./auth.js') const { Request } = require('./request.js') +const VOICE_KIND = 1 +const TEXT_KIND = 2 class Channel { constructor(name, id, type, description) { this.name = name @@ -20,12 +22,25 @@ class Channel { * @param {Number} port | Should always be the default value of 4536 but other owner * @param {Object} params | basic object with jwt + id fields */ -function channels_list(domain, port, params) { +function update_channels_list(domain, port, params) { Request('get', domain, port, '/channels/list', params).then( - channels => { - // fill the DOM with stuff here - console.log('sucess', channels) + response => { + if(response.status_code != 200) { + document.getElementById('channels-list').textContent = 'Could not fetch channels' + } + else { + const channels = response.body + const voice = channels.filter(chan => chan.kind == VOICE_KIND) + const text = channels.filter(chan => chan.kind == TEXT_KIND) + + const chans = voice.concat(text) + for(const channel of chans) { + const name = channel.name + let item = `