global fix and add tauri app
This commit is contained in:
@@ -985,8 +985,8 @@ export class AuthGrpcController {
|
||||
}
|
||||
|
||||
@GrpcMethod('ChatService', 'UpdateRoomSettings')
|
||||
updateChatRoomSettings(command: { userId: string; roomId: string; name?: string; notificationsMuted?: boolean }) {
|
||||
return this.chat.updateRoomSettings(command.userId, command.roomId, command.name, command.notificationsMuted);
|
||||
updateChatRoomSettings(command: { userId: string; roomId: string; name?: string; notificationsMuted?: boolean; pinned?: boolean }) {
|
||||
return this.chat.updateRoomSettings(command.userId, command.roomId, command.name, command.notificationsMuted, command.pinned);
|
||||
}
|
||||
|
||||
@GrpcMethod('ChatService', 'AddRoomMember')
|
||||
|
||||
@@ -104,6 +104,11 @@ export class ChatService {
|
||||
);
|
||||
|
||||
formatted.sort((a, b) => {
|
||||
const pinDiff = Number(Boolean(b.isPinned)) - Number(Boolean(a.isPinned));
|
||||
if (pinDiff !== 0) return pinDiff;
|
||||
if (a.isPinned && b.isPinned) {
|
||||
return (b.pinnedAt ?? '').localeCompare(a.pinnedAt ?? '');
|
||||
}
|
||||
const rank = (type: string) => (type === 'GENERAL' ? 0 : 1);
|
||||
const rankDiff = rank(a.type) - rank(b.type);
|
||||
if (rankDiff !== 0) return rankDiff;
|
||||
@@ -360,7 +365,7 @@ export class ChatService {
|
||||
return this.getRoomResponse(roomId, userId);
|
||||
}
|
||||
|
||||
async updateRoomSettings(userId: string, roomId: string, name?: string, notificationsMuted?: boolean) {
|
||||
async updateRoomSettings(userId: string, roomId: string, name?: string, notificationsMuted?: boolean, pinned?: boolean) {
|
||||
const room = await this.getRoomForMember(roomId, userId);
|
||||
if (name !== undefined) {
|
||||
const trimmedName = name.trim();
|
||||
@@ -381,6 +386,12 @@ export class ChatService {
|
||||
data: { notificationsMuted }
|
||||
});
|
||||
}
|
||||
if (pinned !== undefined) {
|
||||
await this.prisma.chatRoomMember.update({
|
||||
where: { roomId_userId: { roomId, userId } },
|
||||
data: { pinnedAt: pinned ? new Date() : null }
|
||||
});
|
||||
}
|
||||
return this.getRoomResponse(roomId, userId);
|
||||
}
|
||||
|
||||
@@ -903,6 +914,7 @@ export class ChatService {
|
||||
id: string;
|
||||
userId: string;
|
||||
notificationsMuted: boolean;
|
||||
pinnedAt?: Date | null;
|
||||
user: { displayName: string; avatarStorageKey: string | null; isVerified: boolean; verificationIcon: string | null };
|
||||
}>;
|
||||
},
|
||||
@@ -910,6 +922,7 @@ export class ChatService {
|
||||
lastMessage?: Awaited<ReturnType<ChatService['toMessage']>>,
|
||||
viewerId?: string
|
||||
) {
|
||||
const viewerMembership = viewerId ? room.members.find((member) => member.userId === viewerId) : undefined;
|
||||
const peerMember =
|
||||
viewerId && (room.type === 'DIRECT' || room.type === 'BOT' || room.type === 'E2E')
|
||||
? room.members.find((member) => member.userId !== viewerId)
|
||||
@@ -926,6 +939,8 @@ export class ChatService {
|
||||
hasAvatar: room.hasAvatar,
|
||||
createdById: room.createdById ?? undefined,
|
||||
updatedAt: room.updatedAt.toISOString(),
|
||||
isPinned: Boolean(viewerMembership?.pinnedAt),
|
||||
pinnedAt: viewerMembership?.pinnedAt?.toISOString(),
|
||||
members: room.members.map((member) => ({
|
||||
id: member.id,
|
||||
userId: member.userId,
|
||||
@@ -934,6 +949,8 @@ export class ChatService {
|
||||
isVerified: member.user.isVerified,
|
||||
verificationIcon: member.user.isVerified ? resolveVerificationIcon(member.user.verificationIcon) : undefined,
|
||||
notificationsMuted: member.notificationsMuted,
|
||||
isPinned: Boolean(member.pinnedAt),
|
||||
pinnedAt: member.pinnedAt?.toISOString(),
|
||||
familyRole: familyRoleByUserId.get(member.userId) ?? 'member',
|
||||
isChatCreator: room.createdById === member.userId
|
||||
})),
|
||||
|
||||
Reference in New Issue
Block a user