TeaWeb/client/js/teaforo.ts

25 lines
726 B
TypeScript
Raw Normal View History

2019-01-02 10:38:48 +00:00
import TeaForumIdentity = profiles.identities.TeaForumIdentity;
2018-10-07 16:21:28 +00:00
const ipc = require("electron").ipcRenderer;
let callback_listener: (() => any)[] = [];
ipc.on('teaforo-update', (event, data: forum.UserData) => {
2018-10-07 16:21:28 +00:00
console.log("Got data update: %o", data);
2019-01-02 10:38:48 +00:00
profiles.identities.set_static_identity(data ? new TeaForumIdentity(data.application_data, data.application_data_sign) : undefined);
2018-10-07 16:21:28 +00:00
try {
for(let listener of callback_listener)
setImmediate(listener);
} catch(e) {
console.log(e);
}
callback_listener = [];
});
export function register_callback(callback: () => any) {
callback_listener.push(callback);
}
export function open() {
ipc.send("teaforo-login");
}