mirror of
https://github.com/Shik3i/KoalaSync.git
synced 2026-09-04 23:06:48 +00:00
fix(extension): exclude own tab from smart match and send immediate heartbeat after injection
This commit is contained in:
@@ -577,6 +577,9 @@
|
|||||||
setupListeners();
|
setupListeners();
|
||||||
schedulePeriodicHeartbeat();
|
schedulePeriodicHeartbeat();
|
||||||
|
|
||||||
|
// Immediate heartbeat on injection — populate peer data without waiting 15s
|
||||||
|
setTimeout(() => sendHeartbeat(), 300);
|
||||||
|
|
||||||
// Episode Auto-Sync: Boot recovery — check if background has an active lobby
|
// Episode Auto-Sync: Boot recovery — check if background has an active lobby
|
||||||
chrome.runtime.sendMessage({ type: 'CONTENT_BOOT' }, (res) => {
|
chrome.runtime.sendMessage({ type: 'CONTENT_BOOT' }, (res) => {
|
||||||
if (res && res.lobbyActive && res.expectedTitle) {
|
if (res && res.lobbyActive && res.expectedTitle) {
|
||||||
|
|||||||
+5
-2
@@ -431,8 +431,11 @@ async function populateTabs(providedPeers = null, providedTargetTabId = null) {
|
|||||||
option.value = tab.id;
|
option.value = tab.id;
|
||||||
const title = (tab.title || 'Loading...');
|
const title = (tab.title || 'Loading...');
|
||||||
|
|
||||||
// Smart Matching Logic
|
// Smart Matching Logic — exclude own tabTitle to prevent self-match
|
||||||
const peerTitles = peerIds.map(p => p.tabTitle).filter(t => t && t.length > 3);
|
const peerTitles = peerIds
|
||||||
|
.filter(p => (typeof p === 'object' ? p.peerId : p) !== localPeerId)
|
||||||
|
.map(p => (typeof p === 'object' ? p.tabTitle : null))
|
||||||
|
.filter(t => t && t.length > 3);
|
||||||
const isMatch = peerTitles.some(pt => {
|
const isMatch = peerTitles.some(pt => {
|
||||||
const t1 = title.toLowerCase();
|
const t1 = title.toLowerCase();
|
||||||
const t2 = pt.toLowerCase();
|
const t2 = pt.toLowerCase();
|
||||||
|
|||||||
Reference in New Issue
Block a user