- removing uninportant things

+ messages module was for some reason still using legacy url generation(fixed that)
+ switching types to use bigint since everything is u64/i64 on the backend
This commit is contained in:
shockrah 2021-04-14 22:58:03 -07:00
parent 40351f934e
commit 68e22e1b38
4 changed files with 29 additions and 25 deletions

View File

@ -1,4 +1,4 @@
// Requesting channel data here
const { ipcRenderer } = require('electron')
const { Channel } = require('./types')
const $ = require('jquery')
const got = require('got')
@ -98,15 +98,6 @@ async function list(server, user, kind) {
}
}
/**
* @param {List<Channel>}
*/
async function assemble_channels_dom(channels) {
for(const channel of channels) {
console.log(channel)
push(server, user, channel)
}
}
/**
* @param {String} remote.url
@ -118,7 +109,22 @@ exports.server_button_cb = async function(remote, user) {
let tc = await list(remote, user, TEXT_KIND)
vc.push(...tc)
// Assemble the DOM
for(const chan of vc) {
push(remote, user, chan)
}
// Finally update the cache
let parts = URL.parse(remote.url)
await ipcRenderer.invoke('cache-new-server', {
cfg: remote,
channels: vc, //weirdly named but it really _is_ the collection of channels
messages: [],
active_target: remote['wsurl']
})
let jwt_value = encodeURIComponent(user.jwt)
let url = `${remote.wsurl}/text?jwt=${jwt_value}`
await ipcRenderer.invoke('open-socket', {
url: url,
conf: remote
})
}

View File

@ -17,9 +17,8 @@ class Config {
this.data = data
}
// TODO: this function basically
async write_disk() {
const str = JSON.stringify(this.data, null, 4)
const str = JSONBig.stringify(this.data, null, 4)
await fs.writeFile(this.path, str)
}
}

View File

@ -1,13 +1,12 @@
const { ipcRenderer } = require('electron')
const { Message } = require('./types')
const URL = require('url')
const got = require('got')
const $ = require('jquery')
/**
* @param {String} server.hostname | Hostname of target server
* @param {u16} server.port | Port to use for server
* @param {String} server.protocol | http/https (no colon)
* @param {String} server.url | Hostname of target server
*
* @param {String} auth.jwt | jwt for quick auth
* @param {u64} auth.id user | id required by most/all endpoints
@ -141,7 +140,7 @@ exports.recent_messages = async function (auth, server, channel, start_time, end
* @param {Any} body
*/
async function send(server, auth, channel_id, body) {
const url = `${server.protocol}://${server.hostname}:${server.port}/message/send`
const url = `${server.url}/message/send`
// using callbacks for finer grain control of error messages
got.post(url, {
searchParams: {
@ -154,9 +153,8 @@ async function send(server, auth, channel_id, body) {
.then(
response => {
console.log(response);
//await ipcRenderer.invoke('cache-sent-message', {host: server.hostname, message: response.body }
},
failure => { console.log('Failed to send: ', server, auth, channel_id, failure.options) }
failure => { console.log('Failed to send: ', server, auth, channel_id, failure) }
)
}

View File

@ -7,15 +7,16 @@ const MESSAGE_TYPES: Array<String> = [
]
export class Message {
id: Number
time: Number
id: BigInt //u64
time: BigInt//i64
uid: BigInt //u64
cid: BigInt //u64
type: String
content: String|null
uid: Number
uname: String
cid: Number
constructor(id: Number, time: Number, content: String, type: String, uid: Number, uname: String, cid: Number) {
constructor(id: BigInt, time: BigInt, content: String, type: String, uid: BigInt, uname: String, cid: BigInt) {
this.id = id
this.time = time
this.uid = uid
@ -36,10 +37,10 @@ export class Message {
export class Channel {
name: String
type: Number
id: Number
id: BigInt
description: String|null
constructor(name: String, type: Number, id: Number, desc: String) {
constructor(name: String, type: Number, id: BigInt, desc: String) {
this.name = name
this.type = type
this.id = id