Skip to content

Commit

Permalink
update existing nodes when new user info is received
Browse files Browse the repository at this point in the history
  • Loading branch information
liamcottle committed Nov 16, 2024
1 parent cfc0696 commit 5450ad6
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/js/Connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,25 @@ class Connection {

// listen for user info
connection.events.onUserPacket.subscribe((data) => {

console.log("onUserPacket", data);
// todo add new nodes

// get packet data
const fromNodeId = data.from;
const user = data.data;

// find node by id or do nothing
const node = GlobalState.nodesById[fromNodeId];
if(!node){
return;
}

// update node user
console.log(`updating node user ${fromNodeId}`);
node.user = user;

// todo add new nodes if they don't already exist

});

// listen for channels
Expand Down

0 comments on commit 5450ad6

Please sign in to comment.