This commit is contained in:
2025-05-30 18:09:41 -07:00
parent 1c5ce87922
commit f670147b48
4 changed files with 65 additions and 5 deletions

View File

@@ -74,16 +74,39 @@ export class App {
firstRun = false;
peerManager: PeerManager | null = null;
sync: Sync = new Sync();
renderTimer: number = 0;
renderTimer: ReturnType<typeof setTimeout>|null = null;
syncQueues: Map<string, SyncItem[]> = new Map();
syncing: Set<string> = new Set();
updateStatusBar() {
return;
// let statusBarElement = document.getElementById('status_bar');
// if (!statusBarElement) {
// return;
// }
// let newStatusBar = "";
// for (let [userID, syncItems] of this.syncQueues.entries()) {
// let statusBarItem = `<span>${userID} - ${syncItems.length}</span>`;
// newStatusBar+= statusBarItem;
// }
// statusBarElement.innerHTML = newStatusBar;
}
async processSyncQueue(userID: string) {
if (this.syncing.has(userID)) {
return;
}
this.updateStatusBar();
let syncQueue = this.syncQueues.get(userID) as SyncItem[];
while (syncQueue.length !== 0) {
@@ -110,6 +133,8 @@ export class App {
}
this.syncing.delete(userID);
this.updateStatusBar();
}
addPostIDsToSyncQueue(userID: string, peerID: string, postIDs: string[]) {

View File

@@ -42,7 +42,7 @@ export class PeerManager {
eventListeners: Map<PeerEventTypes, Function[]> = new Map();
reconnectPeriod: number = 10;
messageSuperlog = false;
watchdogInterval: number = 0;
watchdogInterval: ReturnType<typeof setTimeout> |null = null;
reconnectTimer: number | null = null;
peerStateSuperlog: boolean = false;
@@ -586,7 +586,7 @@ class PeerConnection {
this.peerManager.disconnectFromPeer(this.remotePeerID);
}
this.dataChannel.onerror = (e: RTCErrorEvent) => {
this.dataChannel.onerror = (e: RTCErrorEvent) => {
this.dataChannelSuperlog && console.log.apply(null, log(`datachannel from peer ${this.remotePeerID} error:`, e.error));
}
}