feat: Initialize the Electron frontend with core UI components and integrate Convex backend services.
This commit is contained in:
@@ -197,14 +197,62 @@ export const getPublicKeys = query({
|
||||
id: v.string(),
|
||||
username: v.string(),
|
||||
public_identity_key: v.string(),
|
||||
status: v.optional(v.string()),
|
||||
avatarUrl: v.optional(v.union(v.string(), v.null())),
|
||||
aboutMe: v.optional(v.string()),
|
||||
customStatus: v.optional(v.string()),
|
||||
})
|
||||
),
|
||||
handler: async (ctx) => {
|
||||
const users = await ctx.db.query("userProfiles").collect();
|
||||
return users.map((u) => ({
|
||||
id: u._id,
|
||||
username: u.username,
|
||||
public_identity_key: u.publicIdentityKey,
|
||||
}));
|
||||
const results = [];
|
||||
for (const u of users) {
|
||||
let avatarUrl: string | null = null;
|
||||
if (u.avatarStorageId) {
|
||||
avatarUrl = await ctx.storage.getUrl(u.avatarStorageId);
|
||||
}
|
||||
results.push({
|
||||
id: u._id,
|
||||
username: u.username,
|
||||
public_identity_key: u.publicIdentityKey,
|
||||
status: u.status || "online",
|
||||
avatarUrl,
|
||||
aboutMe: u.aboutMe,
|
||||
customStatus: u.customStatus,
|
||||
});
|
||||
}
|
||||
return results;
|
||||
},
|
||||
});
|
||||
|
||||
// Update user profile (aboutMe, avatar, customStatus)
|
||||
export const updateProfile = mutation({
|
||||
args: {
|
||||
userId: v.id("userProfiles"),
|
||||
aboutMe: v.optional(v.string()),
|
||||
avatarStorageId: v.optional(v.id("_storage")),
|
||||
customStatus: v.optional(v.string()),
|
||||
},
|
||||
returns: v.null(),
|
||||
handler: async (ctx, args) => {
|
||||
const patch: Record<string, unknown> = {};
|
||||
if (args.aboutMe !== undefined) patch.aboutMe = args.aboutMe;
|
||||
if (args.avatarStorageId !== undefined) patch.avatarStorageId = args.avatarStorageId;
|
||||
if (args.customStatus !== undefined) patch.customStatus = args.customStatus;
|
||||
await ctx.db.patch(args.userId, patch);
|
||||
return null;
|
||||
},
|
||||
});
|
||||
|
||||
// Update user status
|
||||
export const updateStatus = mutation({
|
||||
args: {
|
||||
userId: v.id("userProfiles"),
|
||||
status: v.string(),
|
||||
},
|
||||
returns: v.null(),
|
||||
handler: async (ctx, args) => {
|
||||
await ctx.db.patch(args.userId, { status: args.status });
|
||||
return null;
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user