Post syncing logic is wokting. As expected datachannels fail to send posts above a certain size. Need to implement chunking next.

This commit is contained in:
2025-05-19 01:21:32 -07:00
parent cedc1d7b36
commit 338266a3c6
4 changed files with 115 additions and 15 deletions

View File

@@ -583,9 +583,13 @@ class App {
this.sync.addUserPeer(userID, sendingPeerID);
if (this.sync.shouldSyncUserID(userID)) {
let postIDs = await this.peerManager?.rpc.getPostIDsForUser(sendingPeerID, userID);
console.log.apply(null, log(`[app] announceUsers response, gotPostIDs`, postIDs));
let neededPosts = await this.sync.checkPostIds(userID, sendingPeerID, postIDs);
console.log.apply(null, log(`[app] announceUsers needed posts`, neededPosts));
// console.log.apply(null, log(`[app] announceUsers response, gotPostIDs`, postIDs));
let neededPostIDs = await this.sync.checkPostIds(userID, sendingPeerID, postIDs);
// console.log.apply(null, log(`[app] announceUsers needed posts`, neededPostIDs));
if (neededPostIDs.length > 0) {
let neededPosts = await this.peerManager?.rpc.getPostsForUser(sendingPeerID, this.peerID, userID, neededPostIDs);
console.log(neededPosts);
}
}
}
;
@@ -626,7 +630,20 @@ class App {
});
this.peerManager.registerRPC('getPostIDsForUser', async (userID) => {
let postIDs = await this.sync.getPostIdsForUser(userID);
return postIDs;
if (postIDs) {
return postIDs;
}
});
this.peerManager.registerRPC('getPostsForUser', async (requestingPeerID, userID, postIDs) => {
let posts = await this.sync.getPostsForUser(userID, postIDs);
for (let post of posts) {
this.peerManager?.rpc.sendPostForUser(requestingPeerID, userID, post);
}
// return posts;
// return postIDs;
});
this.peerManager.registerRPC('sendPostForUser', async (requestingPeerID, userID, post) => {
console.log.apply(null, log(`[app] sendPostForUser to [${logID(requestingPeerID)}] `, userID, post));
});
await this.peerManager.connect();
console.log.apply(null, log("*************** after peerManager.connect"));