Fix handling chat photo update
This commit is contained in:
parent
21f7a1201f
commit
5cae7dcad9
11
src/layer.d.ts
vendored
11
src/layer.d.ts
vendored
@ -600,13 +600,14 @@ export namespace Chat {
|
||||
migrated_to?: InputChannel,
|
||||
admin_rights?: ChatAdminRights,
|
||||
default_banned_rights?: ChatBannedRights,
|
||||
rTitle?: string
|
||||
initials?: string
|
||||
};
|
||||
|
||||
export type chatForbidden = {
|
||||
_: 'chatForbidden',
|
||||
id: number,
|
||||
title: string
|
||||
title: string,
|
||||
initials?: string
|
||||
};
|
||||
|
||||
export type channel = {
|
||||
@ -641,7 +642,8 @@ export namespace Chat {
|
||||
admin_rights?: ChatAdminRights,
|
||||
banned_rights?: ChatBannedRights,
|
||||
default_banned_rights?: ChatBannedRights,
|
||||
participants_count?: number
|
||||
participants_count?: number,
|
||||
initials?: string
|
||||
};
|
||||
|
||||
export type channelForbidden = {
|
||||
@ -654,7 +656,8 @@ export namespace Chat {
|
||||
id: number,
|
||||
access_hash: string,
|
||||
title: string,
|
||||
until_date?: number
|
||||
until_date?: number,
|
||||
initials?: string
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
import { MOUNT_CLASS_TO } from "../../config/debug";
|
||||
import { numberThousandSplitter } from "../../helpers/number";
|
||||
import { isObject, safeReplaceObject, copy, deepEqual } from "../../helpers/object";
|
||||
import { ChannelParticipant, Chat, ChatAdminRights, ChatBannedRights, ChatFull, ChatParticipant, ChatParticipants, InputChannel, InputChatPhoto, InputFile, InputPeer, SendMessageAction, Update, Updates } from "../../layer";
|
||||
import { ChannelParticipant, Chat, ChatAdminRights, ChatBannedRights, ChatFull, ChatParticipant, ChatParticipants, ChatPhoto, InputChannel, InputChatPhoto, InputFile, InputPeer, SendMessageAction, Update, Updates } from "../../layer";
|
||||
import { i18n, LangPackKey } from "../langPack";
|
||||
import apiManagerProxy from "../mtproto/mtprotoworker";
|
||||
import apiManager from '../mtproto/mtprotoworker';
|
||||
@ -178,7 +178,8 @@ export class AppChatsManager {
|
||||
apiChats.forEach(chat => this.saveApiChat(chat, override));
|
||||
}
|
||||
|
||||
public saveApiChat(chat: any, override?: boolean) {
|
||||
public saveApiChat(chat: Chat, override?: boolean) {
|
||||
if(chat._ === 'chatEmpty') return;
|
||||
/* if(chat._ !== 'chat' && chat._ !== 'channel') {
|
||||
return;
|
||||
} */
|
||||
@ -186,17 +187,17 @@ export class AppChatsManager {
|
||||
// * exclude from state
|
||||
// defineNotNumerableProperties(chat, ['rTitle', 'initials']);
|
||||
|
||||
const oldChat = this.chats[chat.id];
|
||||
const oldChat: Exclude<Chat, Chat.chatEmpty> = this.chats[chat.id];
|
||||
|
||||
/* if(oldChat && !override) {
|
||||
return;
|
||||
} */
|
||||
|
||||
if(chat.pFlags === undefined) {
|
||||
chat.pFlags = {};
|
||||
if((chat as Chat.chat).pFlags === undefined) {
|
||||
(chat as Chat.chat).pFlags = {};
|
||||
}
|
||||
|
||||
if(chat.pFlags.min && oldChat !== undefined) {
|
||||
if((chat as Chat.channel).pFlags.min && oldChat !== undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -205,8 +206,8 @@ export class AppChatsManager {
|
||||
if(chat._ === 'channel' &&
|
||||
chat.participants_count === undefined &&
|
||||
oldChat !== undefined &&
|
||||
oldChat.participants_count) {
|
||||
chat.participants_count = oldChat.participants_count;
|
||||
(oldChat as Chat.channel).participants_count) {
|
||||
chat.participants_count = (oldChat as Chat.channel).participants_count;
|
||||
}
|
||||
|
||||
/* if(chat.username) {
|
||||
@ -218,9 +219,9 @@ export class AppChatsManager {
|
||||
if(oldChat === undefined) {
|
||||
this.chats[chat.id] = chat;
|
||||
} else {
|
||||
const oldPhoto = oldChat.photo?.photo_small;
|
||||
const newPhoto = chat.photo?.photo_small;
|
||||
if(JSON.stringify(oldPhoto) !== JSON.stringify(newPhoto)) {
|
||||
const oldPhotoId = ((oldChat as Chat.chat).photo as ChatPhoto.chatPhoto)?.photo_id;
|
||||
const newPhotoId = ((chat as Chat.chat).photo as ChatPhoto.chatPhoto)?.photo_id;
|
||||
if(oldPhotoId !== newPhotoId) {
|
||||
changedPhoto = true;
|
||||
}
|
||||
|
||||
|
@ -114,7 +114,22 @@
|
||||
}, {
|
||||
"predicate": "chat",
|
||||
"params": [
|
||||
{"name": "rTitle", "type": "string"}
|
||||
{"name": "initials", "type": "string"}
|
||||
]
|
||||
}, {
|
||||
"predicate": "chatForbidden",
|
||||
"params": [
|
||||
{"name": "initials", "type": "string"}
|
||||
]
|
||||
}, {
|
||||
"predicate": "channel",
|
||||
"params": [
|
||||
{"name": "initials", "type": "string"}
|
||||
]
|
||||
}, {
|
||||
"predicate": "channelForbidden",
|
||||
"params": [
|
||||
{"name": "initials", "type": "string"}
|
||||
]
|
||||
}, {
|
||||
"predicate": "messageActionChatLeave",
|
||||
|
Loading…
x
Reference in New Issue
Block a user