relita

an encrypted, decentralized, peer-to-peer social network
Log | Files | Refs | README | LICENSE | git clone https://git.ne02ptzero.me/git/relita

commit c5987a6b3bee1ca0703a274708067aff4dbc7415
parent d817ae2e2c99455d60a3bb400226e9cfb93e3363
Author: Ne02ptzero <louis@ne02ptzero.me>
Date:   Sun,  9 Apr 2017 21:28:02 +0200

Add(Server): Now synchronizing on-the-fly with entries

Diffstat:
Mjs/renderer.js | 9+++++++--
Mmain.js | 13+++++++++++--
2 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/js/renderer.js b/js/renderer.js @@ -6,7 +6,6 @@ $(function() { $(".title i").fadeOut(600, function() { $(".title").fadeOut(500, function() { $(".add_post").fadeIn(100); - ipcRenderer.send('get_feed', null); }); }) }) @@ -19,10 +18,16 @@ $(function() { $(".posts_list").html("") for (i = 0; i < arg.length; i++) { - $(".posts_list").append("<strong>"+ arg[i].value.author + "</strong>: "+ arg[i].value.content.text + "<br />") + $(".posts_list").append("<strong>"+ arg[i].value.author + "</strong>: "+ arg[i].value.content.value + "<br />") } }) + ipcRenderer.on('new_entry', (event, arg) => { + if (arg.sync === true) + return ; + $(".posts_list").append("<strong>"+ arg.value.author + "</strong>: "+ arg.value.content.value + "<br />") + }) + ipcRenderer.send('connect_client', null); $(".add_post button").click(function() { diff --git a/main.js b/main.js @@ -60,6 +60,10 @@ function create_window() { }) } +function live_drain(msg) { + mainWindow.webContents.send('new_entry', msg) +} + app.on('ready', create_window) app.on('window-all-closed', function () { @@ -85,6 +89,10 @@ ipcMain.on('connect_client', (event, arg) => { sbot.whoami(function(err, info) { user_id = info.id; }) + pull( + sbot.createLogStream({ live: true }), + pull.drain(live_drain) + ) event.sender.send('connect_client', 'OK') } @@ -94,10 +102,11 @@ ipcMain.on('connect_client', (event, arg) => { ipcMain.on('get_feed', (event, arg) => { console.log("Getting feed...") pull( - sbot_client.createUserStream({id: user_id}), + sbot_client.createFeedStream(), pull.collect(function (err, msgs) { if (err) throw err; + console.log(msgs) event.sender.send('get_feed', msgs); }) ) @@ -107,7 +116,7 @@ ipcMain.on('add_post', (event, arg) => { console.log("Adding new post, content is: "+ arg) sbot_client.publish({ type: 'post', - text: arg, + value: arg, }, function (err, msg) { if (err)