This commit is contained in:
syuilo
2025-03-23 09:53:02 +09:00
parent 50435a3f68
commit f3bb4d6603
9 changed files with 23 additions and 5 deletions

View File

@@ -248,11 +248,11 @@ export class ChatService {
public async readUserChatMessage(
readerId: MiUser['id'],
senderId: MiUser['id'],
) {
): Promise<void> {
const redisPipeline = this.redisClient.pipeline();
redisPipeline.del(`newChatMessageExists:${readerId}:${senderId}`);
redisPipeline.srem(`newChatMessagesExists:${readerId}`, `user:${senderId}`);
redisPipeline.exec();
await redisPipeline.exec();
}
@bindThis
@@ -467,6 +467,7 @@ export class ChatService {
@bindThis
public async hasUnreadMessages(userId: MiUser['id']) {
// TODO
const card = await this.redisClient.scard(`newChatMessagesExists:${userId}`);
return card > 0;
}
}

View File

@@ -74,6 +74,7 @@ export interface MainEventTypes {
unreadNotification: Packed<'Notification'>;
readAllAntennas: undefined;
unreadAntenna: MiAntenna;
newChatMessage: Packed<'ChatMessage'>;
readAllAnnouncements: undefined;
myTokenRegenerated: undefined;
signin: {

View File

@@ -545,6 +545,10 @@ export const packedMeDetailedOnlySchema = {
type: 'boolean',
nullable: false, optional: false,
},
hasUnreadChatMessages: {
type: 'boolean',
nullable: false, optional: false,
},
hasUnreadNotification: {
type: 'boolean',
nullable: false, optional: false,

View File

@@ -133,6 +133,7 @@ describe('ユーザー', () => {
hasUnreadAnnouncement: user.hasUnreadAnnouncement,
hasUnreadAntenna: user.hasUnreadAntenna,
hasUnreadChannel: user.hasUnreadChannel,
hasUnreadChatMessages: user.hasUnreadChatMessages,
hasUnreadNotification: user.hasUnreadNotification,
unreadNotificationsCount: user.unreadNotificationsCount,
hasPendingReceivedFollowRequest: user.hasPendingReceivedFollowRequest,
@@ -371,6 +372,7 @@ describe('ユーザー', () => {
assert.strictEqual(response.hasUnreadAnnouncement, false);
assert.strictEqual(response.hasUnreadAntenna, false);
assert.strictEqual(response.hasUnreadChannel, false);
assert.strictEqual(response.hasUnreadChatMessages, false);
assert.strictEqual(response.hasUnreadNotification, false);
assert.strictEqual(response.unreadNotificationsCount, 0);
assert.strictEqual(response.hasPendingReceivedFollowRequest, false);

View File

@@ -511,6 +511,11 @@ export async function mainBoot() {
sound.playMisskeySfx('antenna');
});
main.on('newChatMessage', () => {
updateCurrentAccountPartial({ hasUnreadChatMessages: true });
sound.playMisskeySfx('chat');
});
main.on('readAllAnnouncements', () => {
updateCurrentAccountPartial({ hasUnreadAnnouncement: false });
});

View File

@@ -114,6 +114,7 @@ export const navbarItemDef = reactive({
title: i18n.ts.chat,
icon: 'ti ti-message',
to: '/chat',
indicated: computed(() => $i != null && $i.hasUnreadChatMessages),
},
achievements: {
title: i18n.ts.achievements,

View File

@@ -626,6 +626,7 @@ export type Channels = {
readAllUnreadSpecifiedNotes: () => void;
readAllAntennas: () => void;
unreadAntenna: (payload: Antenna) => void;
newChatMessage: (payload: ChatMessage) => void;
readAllAnnouncements: () => void;
myTokenRegenerated: () => void;
signin: (payload: Signin) => void;
@@ -3480,8 +3481,8 @@ type V2AdminEmojiListResponse = operations['v2___admin___emoji___list']['respons
//
// src/entities.ts:50:2 - (ae-forgotten-export) The symbol "ModerationLogPayloads" needs to be exported by the entry point index.d.ts
// src/streaming.ts:57:3 - (ae-forgotten-export) The symbol "ReconnectingWebSocket" needs to be exported by the entry point index.d.ts
// src/streaming.types.ts:220:4 - (ae-forgotten-export) The symbol "ReversiUpdateKey" needs to be exported by the entry point index.d.ts
// src/streaming.types.ts:230:4 - (ae-forgotten-export) The symbol "ReversiUpdateSettings" needs to be exported by the entry point index.d.ts
// src/streaming.types.ts:222:4 - (ae-forgotten-export) The symbol "ReversiUpdateKey" needs to be exported by the entry point index.d.ts
// src/streaming.types.ts:232:4 - (ae-forgotten-export) The symbol "ReversiUpdateSettings" needs to be exported by the entry point index.d.ts
// (No @packageDocumentation comment for this package)

View File

@@ -3914,6 +3914,7 @@ export type components = {
unreadAnnouncements: components['schemas']['Announcement'][];
hasUnreadAntenna: boolean;
hasUnreadChannel: boolean;
hasUnreadChatMessages: boolean;
hasUnreadNotification: boolean;
hasPendingReceivedFollowRequest: boolean;
unreadNotificationsCount: number;

View File

@@ -1,5 +1,6 @@
import {
Antenna,
ChatMessage,
DriveFile,
DriveFolder,
Note,
@@ -53,6 +54,7 @@ export type Channels = {
readAllUnreadSpecifiedNotes: () => void;
readAllAntennas: () => void;
unreadAntenna: (payload: Antenna) => void;
newChatMessage: (payload: ChatMessage) => void;
readAllAnnouncements: () => void;
myTokenRegenerated: () => void;
signin: (payload: Signin) => void;