Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions app/src/composables/useCommunityService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@
// Community query is perspective-scoped (typically one per perspective — low cost).
// Use ChannelSummary — lightweight model without @HasMany relations.
// Property getters run by default (deepQuery=true) via batched VALUES queries.
const { data: communities, loading: communitiesLoading, error: communitiesError } = useLiveQuery(Community, perspective);

Check warning on line 144 in app/src/composables/useCommunityService.ts

View workflow job for this annotation

GitHub Actions / tests

'communitiesError' is assigned a value but never used

Check warning on line 144 in app/src/composables/useCommunityService.ts

View workflow job for this annotation

GitHub Actions / tests

'communitiesLoading' is assigned a value but never used

Check warning on line 144 in app/src/composables/useCommunityService.ts

View workflow job for this annotation

GitHub Actions / tests

'communitiesError' is assigned a value but never used

Check warning on line 144 in app/src/composables/useCommunityService.ts

View workflow job for this annotation

GitHub Actions / tests

'communitiesLoading' is assigned a value but never used

Check warning on line 144 in app/src/composables/useCommunityService.ts

View workflow job for this annotation

GitHub Actions / build

'communitiesError' is assigned a value but never used

Check warning on line 144 in app/src/composables/useCommunityService.ts

View workflow job for this annotation

GitHub Actions / build

'communitiesLoading' is assigned a value but never used
const { data: allChannels, loading: channelsLoading, error: channelsError } = useLiveQuery(ChannelSummary, perspective);

Check warning on line 145 in app/src/composables/useCommunityService.ts

View workflow job for this annotation

GitHub Actions / tests

'channelsError' is assigned a value but never used

Check warning on line 145 in app/src/composables/useCommunityService.ts

View workflow job for this annotation

GitHub Actions / tests

'channelsLoading' is assigned a value but never used

Check warning on line 145 in app/src/composables/useCommunityService.ts

View workflow job for this annotation

GitHub Actions / tests

'channelsError' is assigned a value but never used

Check warning on line 145 in app/src/composables/useCommunityService.ts

View workflow job for this annotation

GitHub Actions / tests

'channelsLoading' is assigned a value but never used

Check warning on line 145 in app/src/composables/useCommunityService.ts

View workflow job for this annotation

GitHub Actions / build

'channelsError' is assigned a value but never used

Check warning on line 145 in app/src/composables/useCommunityService.ts

View workflow job for this annotation

GitHub Actions / build

'channelsLoading' is assigned a value but never used

// Cache for conversation instances — populated during data fetching, looked up in computeds.
// Plain Map (not reactive) is sufficient: updates always precede the ref changes that trigger re-computation.
Expand All @@ -163,8 +163,8 @@

const isAuthor = computed(() => communities.value[0]?.author === me.value.did);
const community = computed<Community>(() => communities.value[0]);
const pinnedChannels = computed(() => allChannels.value.filter((channel) => channel.isPinned));

Check warning on line 166 in app/src/composables/useCommunityService.ts

View workflow job for this annotation

GitHub Actions / tests

'pinnedChannels' is assigned a value but never used

Check warning on line 166 in app/src/composables/useCommunityService.ts

View workflow job for this annotation

GitHub Actions / tests

'pinnedChannels' is assigned a value but never used

Check warning on line 166 in app/src/composables/useCommunityService.ts

View workflow job for this annotation

GitHub Actions / build

'pinnedChannels' is assigned a value but never used
const conversationChannels = computed(() => allChannels.value.filter((channel) => channel.isConversation));

Check warning on line 167 in app/src/composables/useCommunityService.ts

View workflow job for this annotation

GitHub Actions / tests

'conversationChannels' is assigned a value but never used

Check warning on line 167 in app/src/composables/useCommunityService.ts

View workflow job for this annotation

GitHub Actions / tests

'conversationChannels' is assigned a value but never used

Check warning on line 167 in app/src/composables/useCommunityService.ts

View workflow job for this annotation

GitHub Actions / build

'conversationChannels' is assigned a value but never used
const spaceChannels = computed(() => allChannels.value.filter((channel) => !channel.isConversation));
const pinnedConversationsWithAgents = computed((): ChannelDataWithAgents[] => {
return pinnedConversations.value.map((data) => ({
Expand Down Expand Up @@ -490,7 +490,7 @@
// Local dedup set avoids redundant addLinks RPCs — ChannelSummary doesn't
// carry participants, so the old channel.participants.includes() check was lost.
const knownParticipants = new Set<string>();
function handleParticipantTracking(link: any) {

Check warning on line 493 in app/src/composables/useCommunityService.ts

View workflow job for this annotation

GitHub Actions / tests

Unexpected any. Specify a different type

Check warning on line 493 in app/src/composables/useCommunityService.ts

View workflow job for this annotation

GitHub Actions / tests

Unexpected any. Specify a different type

Check warning on line 493 in app/src/composables/useCommunityService.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected any. Specify a different type
if (link.data.predicate !== CHANNEL) return null;
if (!link.author) return null;

Expand All @@ -517,9 +517,27 @@
}
perspective.addListener('link-added', handleParticipantTracking);

// Refetch the members list whenever the signalling service learns about a
// DID we don't already have in `members`. The signalling service tracks
// every agent that broadcasts a heartbeat (including their "first-broadcast"
// on join), so this catches new joiners automatically — without polling
// and without waiting for the modal to remount.
const membersDidSet = computed(() => new Set(members.value.map((m) => m.did)));
const stopMembersWatcher = signallingService
? watch(
() => Object.keys(signallingService.agents.value),
(signallingDids) => {
if (membersLoading.value) return;
const hasNew = signallingDids.some((did) => did && !membersDidSet.value.has(did));
if (hasNew) getMembers();
},
)
: null;

// Cleanup function to remove all listeners
function cleanup() {
perspective.removeListener('link-added', handleParticipantTracking);
if (stopMembersWatcher) stopMembersWatcher();
}

getMembers();
Expand Down
Loading