mirror of
https://github.com/Shik3i/KoalaSync.git
synced 2026-08-29 03:57:09 +00:00
fix: add null guards to prevent runtime crashes
- popup.js: guard peers/state.acks in updateLastActionUI() - popup.js: guard state.duration in refreshDebugInfo() - popup.js: guard elements.lobbyPeerStatus in updateLobbyUI() - background.js: use Array.isArray() for currentRoom.peers.length checks
This commit is contained in:
@@ -577,7 +577,7 @@ function handleServerEvent(event, data) {
|
||||
}
|
||||
|
||||
// Check if all peers responded
|
||||
const peerCount = currentRoom ? currentRoom.peers.length : 1;
|
||||
const peerCount = currentRoom && Array.isArray(currentRoom.peers) ? currentRoom.peers.length : 1;
|
||||
if (forceSyncAcks.size >= peerCount) {
|
||||
executeForceSync();
|
||||
}
|
||||
@@ -649,7 +649,7 @@ function handleServerEvent(event, data) {
|
||||
}
|
||||
|
||||
if (isForceSyncInitiator) {
|
||||
const peerCount = currentRoom.peers ? currentRoom.peers.length : 1;
|
||||
const peerCount = Array.isArray(currentRoom.peers) ? currentRoom.peers.length : 1;
|
||||
if (forceSyncAcks.size >= peerCount) {
|
||||
executeForceSync();
|
||||
}
|
||||
@@ -1179,7 +1179,7 @@ async function handleAsyncMessage(message, sender, sendResponse) {
|
||||
});
|
||||
}
|
||||
|
||||
const peerCount = currentRoom ? currentRoom.peers.length : 1;
|
||||
const peerCount = currentRoom && Array.isArray(currentRoom.peers) ? currentRoom.peers.length : 1;
|
||||
if (forceSyncAcks.size >= peerCount) {
|
||||
executeForceSync();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user