mirror of
https://github.com/cinnyapp/cinny.git
synced 2025-11-04 22:40:29 +03:00
fix dm invite appears in home
This commit is contained in:
parent
78a0d11f24
commit
782dabe21b
1 changed files with 12 additions and 6 deletions
|
|
@ -230,8 +230,11 @@ export const addRoomIdToMDirect = async (
|
||||||
roomId: string,
|
roomId: string,
|
||||||
userId: string
|
userId: string
|
||||||
): Promise<void> => {
|
): Promise<void> => {
|
||||||
const mDirectsEvent = mx.getAccountData(AccountDataEvent.Direct);
|
const mDirectsEvent = mx.getAccountData(AccountDataEvent.Direct as any);
|
||||||
const userIdToRoomIds: Record<string, string[]> = mDirectsEvent?.getContent() ?? {};
|
let userIdToRoomIds: Record<string, string[]> = {};
|
||||||
|
|
||||||
|
if (typeof mDirectsEvent !== 'undefined')
|
||||||
|
userIdToRoomIds = structuredClone(mDirectsEvent.getContent());
|
||||||
|
|
||||||
// remove it from the lists of any others users
|
// remove it from the lists of any others users
|
||||||
// (it can only be a DM room for one person)
|
// (it can only be a DM room for one person)
|
||||||
|
|
@ -252,12 +255,15 @@ export const addRoomIdToMDirect = async (
|
||||||
}
|
}
|
||||||
userIdToRoomIds[userId] = roomIds;
|
userIdToRoomIds[userId] = roomIds;
|
||||||
|
|
||||||
await mx.setAccountData(AccountDataEvent.Direct, userIdToRoomIds);
|
await mx.setAccountData(AccountDataEvent.Direct as any, userIdToRoomIds as any);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const removeRoomIdFromMDirect = async (mx: MatrixClient, roomId: string): Promise<void> => {
|
export const removeRoomIdFromMDirect = async (mx: MatrixClient, roomId: string): Promise<void> => {
|
||||||
const mDirectsEvent = mx.getAccountData(AccountDataEvent.Direct);
|
const mDirectsEvent = mx.getAccountData(AccountDataEvent.Direct as any);
|
||||||
const userIdToRoomIds: Record<string, string[]> = mDirectsEvent?.getContent() ?? {};
|
let userIdToRoomIds: Record<string, string[]> = {};
|
||||||
|
|
||||||
|
if (typeof mDirectsEvent !== 'undefined')
|
||||||
|
userIdToRoomIds = structuredClone(mDirectsEvent.getContent());
|
||||||
|
|
||||||
Object.keys(userIdToRoomIds).forEach((targetUserId) => {
|
Object.keys(userIdToRoomIds).forEach((targetUserId) => {
|
||||||
const roomIds = userIdToRoomIds[targetUserId];
|
const roomIds = userIdToRoomIds[targetUserId];
|
||||||
|
|
@ -267,7 +273,7 @@ export const removeRoomIdFromMDirect = async (mx: MatrixClient, roomId: string):
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
await mx.setAccountData(AccountDataEvent.Direct, userIdToRoomIds);
|
await mx.setAccountData(AccountDataEvent.Direct as any, userIdToRoomIds as any);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const mxcUrlToHttp = (
|
export const mxcUrlToHttp = (
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue