feat: implement initial Electron chat application with core UI components and Convex backend integration.
All checks were successful
Build and Release / build-and-release (push) Successful in 11m1s
All checks were successful
Build and Release / build-and-release (push) Successful in 11m1s
This commit is contained in:
@@ -70,6 +70,16 @@ export const updateState = mutation({
|
||||
Object.entries(updates).filter(([, val]) => val !== undefined)
|
||||
);
|
||||
await ctx.db.patch(existing._id, filtered);
|
||||
|
||||
// When a user stops screen sharing, clear all viewers watching their stream
|
||||
if (args.isScreenSharing === false) {
|
||||
const allStates = await ctx.db.query("voiceStates").collect();
|
||||
for (const s of allStates) {
|
||||
if (s.watchingStream === args.userId) {
|
||||
await ctx.db.patch(s._id, { watchingStream: undefined });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -105,6 +115,28 @@ export const serverMute = mutation({
|
||||
},
|
||||
});
|
||||
|
||||
export const setWatchingStream = mutation({
|
||||
args: {
|
||||
userId: v.id("userProfiles"),
|
||||
watchingStream: v.optional(v.id("userProfiles")),
|
||||
},
|
||||
returns: v.null(),
|
||||
handler: async (ctx, args) => {
|
||||
const existing = await ctx.db
|
||||
.query("voiceStates")
|
||||
.withIndex("by_user", (q) => q.eq("userId", args.userId))
|
||||
.first();
|
||||
|
||||
if (existing) {
|
||||
await ctx.db.patch(existing._id, {
|
||||
watchingStream: args.watchingStream ?? undefined,
|
||||
});
|
||||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
});
|
||||
|
||||
export const getAll = query({
|
||||
args: {},
|
||||
returns: v.any(),
|
||||
@@ -119,6 +151,7 @@ export const getAll = query({
|
||||
isScreenSharing: boolean;
|
||||
isServerMuted: boolean;
|
||||
avatarUrl: string | null;
|
||||
watchingStream: string | null;
|
||||
}>> = {};
|
||||
|
||||
for (const s of states) {
|
||||
@@ -136,6 +169,7 @@ export const getAll = query({
|
||||
isScreenSharing: s.isScreenSharing,
|
||||
isServerMuted: s.isServerMuted,
|
||||
avatarUrl,
|
||||
watchingStream: s.watchingStream ?? null,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -177,6 +211,14 @@ export const afkMove = mutation({
|
||||
isServerMuted: currentState.isServerMuted,
|
||||
});
|
||||
|
||||
// Clear viewers watching the moved user's stream (screen sharing stops on AFK move)
|
||||
const allStates = await ctx.db.query("voiceStates").collect();
|
||||
for (const s of allStates) {
|
||||
if (s.watchingStream === args.userId) {
|
||||
await ctx.db.patch(s._id, { watchingStream: undefined });
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user