Moving as much auth/initialization logic out of index.html

 New local push function in auth for push server buttons onto the dom
This commit is contained in:
shockrah
2021-03-09 15:36:55 -08:00
parent 911edd8114
commit b5822cd3f1
2 changed files with 25 additions and 40 deletions

View File

@@ -114,50 +114,15 @@
(async () => {
const { ipcRenderer } = require('electron')
const auth = require('../src/auth.js')
const channels = require('../src/channels.js')
const { add_server_to_config } = require ('../src/settings.js')
// used for basic styling on server buttons
const classes = 'btn btn-outline-secondary btn-nav-settings'
// NOTE: this will probably take minute if your in a lot of servers
// even worse if server owners are running debug builds like tards
// get a new jwt from each server on startup
$('#add-admin-json').click(async () => await add_server_to_config() )
try {
let config = await auth.init()
for(const server_cfg of config.data['servers']) {
const remote = server_cfg['server']
const user = server_cfg['user']
// html generation
const id = remote['hostname']
const txt = remote['name']
$('#server-list').append(
$('<input>').attr({
type: 'button',
'class' : classes,
id: id,
value: txt
})
)
$(`#${id}`).on('click', async () => await channels.list(remote, user))
}
await auth.init()
} catch(err) {
console.log('Failure in IPC call')
console.log(err)
$('#server-list').append(
$('<input>').attr({
type: 'button',
'class': classes + ' disabled',
value: 'Problems setting up from config'
})
)
}
})()
</script>