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,
|
migrated_to?: InputChannel,
|
||||||
admin_rights?: ChatAdminRights,
|
admin_rights?: ChatAdminRights,
|
||||||
default_banned_rights?: ChatBannedRights,
|
default_banned_rights?: ChatBannedRights,
|
||||||
rTitle?: string
|
initials?: string
|
||||||
};
|
};
|
||||||
|
|
||||||
export type chatForbidden = {
|
export type chatForbidden = {
|
||||||
_: 'chatForbidden',
|
_: 'chatForbidden',
|
||||||
id: number,
|
id: number,
|
||||||
title: string
|
title: string,
|
||||||
|
initials?: string
|
||||||
};
|
};
|
||||||
|
|
||||||
export type channel = {
|
export type channel = {
|
||||||
@ -641,7 +642,8 @@ export namespace Chat {
|
|||||||
admin_rights?: ChatAdminRights,
|
admin_rights?: ChatAdminRights,
|
||||||
banned_rights?: ChatBannedRights,
|
banned_rights?: ChatBannedRights,
|
||||||
default_banned_rights?: ChatBannedRights,
|
default_banned_rights?: ChatBannedRights,
|
||||||
participants_count?: number
|
participants_count?: number,
|
||||||
|
initials?: string
|
||||||
};
|
};
|
||||||
|
|
||||||
export type channelForbidden = {
|
export type channelForbidden = {
|
||||||
@ -654,7 +656,8 @@ export namespace Chat {
|
|||||||
id: number,
|
id: number,
|
||||||
access_hash: string,
|
access_hash: string,
|
||||||
title: string,
|
title: string,
|
||||||
until_date?: number
|
until_date?: number,
|
||||||
|
initials?: string
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
import { MOUNT_CLASS_TO } from "../../config/debug";
|
import { MOUNT_CLASS_TO } from "../../config/debug";
|
||||||
import { numberThousandSplitter } from "../../helpers/number";
|
import { numberThousandSplitter } from "../../helpers/number";
|
||||||
import { isObject, safeReplaceObject, copy, deepEqual } from "../../helpers/object";
|
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 { i18n, LangPackKey } from "../langPack";
|
||||||
import apiManagerProxy from "../mtproto/mtprotoworker";
|
import apiManagerProxy from "../mtproto/mtprotoworker";
|
||||||
import apiManager from '../mtproto/mtprotoworker';
|
import apiManager from '../mtproto/mtprotoworker';
|
||||||
@ -178,7 +178,8 @@ export class AppChatsManager {
|
|||||||
apiChats.forEach(chat => this.saveApiChat(chat, override));
|
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') {
|
/* if(chat._ !== 'chat' && chat._ !== 'channel') {
|
||||||
return;
|
return;
|
||||||
} */
|
} */
|
||||||
@ -186,17 +187,17 @@ export class AppChatsManager {
|
|||||||
// * exclude from state
|
// * exclude from state
|
||||||
// defineNotNumerableProperties(chat, ['rTitle', 'initials']);
|
// defineNotNumerableProperties(chat, ['rTitle', 'initials']);
|
||||||
|
|
||||||
const oldChat = this.chats[chat.id];
|
const oldChat: Exclude<Chat, Chat.chatEmpty> = this.chats[chat.id];
|
||||||
|
|
||||||
/* if(oldChat && !override) {
|
/* if(oldChat && !override) {
|
||||||
return;
|
return;
|
||||||
} */
|
} */
|
||||||
|
|
||||||
if(chat.pFlags === undefined) {
|
if((chat as Chat.chat).pFlags === undefined) {
|
||||||
chat.pFlags = {};
|
(chat as Chat.chat).pFlags = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
if(chat.pFlags.min && oldChat !== undefined) {
|
if((chat as Chat.channel).pFlags.min && oldChat !== undefined) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -205,8 +206,8 @@ export class AppChatsManager {
|
|||||||
if(chat._ === 'channel' &&
|
if(chat._ === 'channel' &&
|
||||||
chat.participants_count === undefined &&
|
chat.participants_count === undefined &&
|
||||||
oldChat !== undefined &&
|
oldChat !== undefined &&
|
||||||
oldChat.participants_count) {
|
(oldChat as Chat.channel).participants_count) {
|
||||||
chat.participants_count = oldChat.participants_count;
|
chat.participants_count = (oldChat as Chat.channel).participants_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if(chat.username) {
|
/* if(chat.username) {
|
||||||
@ -218,9 +219,9 @@ export class AppChatsManager {
|
|||||||
if(oldChat === undefined) {
|
if(oldChat === undefined) {
|
||||||
this.chats[chat.id] = chat;
|
this.chats[chat.id] = chat;
|
||||||
} else {
|
} else {
|
||||||
const oldPhoto = oldChat.photo?.photo_small;
|
const oldPhotoId = ((oldChat as Chat.chat).photo as ChatPhoto.chatPhoto)?.photo_id;
|
||||||
const newPhoto = chat.photo?.photo_small;
|
const newPhotoId = ((chat as Chat.chat).photo as ChatPhoto.chatPhoto)?.photo_id;
|
||||||
if(JSON.stringify(oldPhoto) !== JSON.stringify(newPhoto)) {
|
if(oldPhotoId !== newPhotoId) {
|
||||||
changedPhoto = true;
|
changedPhoto = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,7 +114,22 @@
|
|||||||
}, {
|
}, {
|
||||||
"predicate": "chat",
|
"predicate": "chat",
|
||||||
"params": [
|
"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",
|
"predicate": "messageActionChatLeave",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user