+34
-2
static/app.js
+34
-2
static/app.js
···
1087
1087
// Particle reached destination - pulse the identity/PDS
1088
1088
pulseIdentity();
1089
1089
1090
-
// If this was a delete event, remove the app circle
1090
+
// If this was a delete event, lazily check if app should be removed
1091
1091
if (particle.metadata && particle.metadata.action === 'delete') {
1092
-
removeAppCircle(particle.metadata.namespace);
1092
+
maybeRemoveAppCircle(particle.metadata.namespace);
1093
1093
}
1094
1094
}
1095
1095
return alive;
···
1676
1676
1677
1677
// Reposition remaining circles
1678
1678
repositionAppCircles();
1679
+
}
1680
+
1681
+
// Check if a namespace still has records (any collection with count > 0)
1682
+
async function namespaceHasRecords(namespace) {
1683
+
if (!globalApps || !globalApps[namespace] || !globalPds) {
1684
+
return false;
1685
+
}
1686
+
1687
+
// Check each collection in this namespace
1688
+
for (const collection of globalApps[namespace]) {
1689
+
try {
1690
+
const url = `${globalPds}/xrpc/com.atproto.repo.listRecords?repo=${encodeURIComponent(did)}&collection=${encodeURIComponent(collection)}&limit=1`;
1691
+
const response = await fetch(url);
1692
+
if (response.ok) {
1693
+
const data = await response.json();
1694
+
if (data.records && data.records.length > 0) {
1695
+
return true; // Found at least one record
1696
+
}
1697
+
}
1698
+
} catch (e) {
1699
+
console.error(`Error checking records for ${collection}:`, e);
1700
+
}
1701
+
}
1702
+
return false;
1703
+
}
1704
+
1705
+
// Lazily check and remove app circle if namespace has no more records
1706
+
async function maybeRemoveAppCircle(namespace) {
1707
+
const hasRecords = await namespaceHasRecords(namespace);
1708
+
if (!hasRecords) {
1709
+
removeAppCircle(namespace);
1710
+
}
1679
1711
}
1680
1712
1681
1713
// Check auth status on page load