Channels: Fix "No Forwards" toggle (#2720)
This commit is contained in:
parent
673ad88e4e
commit
8696eb41ce
@ -80,9 +80,6 @@ export function init(_onUpdate: OnApiUpdate) {
|
||||
}
|
||||
|
||||
const sentMessageIds = new Set();
|
||||
// Workaround for a situation when an incorrect update comes with an undefined property `adminRights`
|
||||
let shouldIgnoreNextChannelUpdate = false;
|
||||
const IGNORE_NEXT_CHANNEL_UPDATE_TIMEOUT = 2000;
|
||||
|
||||
function dispatchUserAndChatUpdates(entities: (GramJs.TypeUser | GramJs.TypeChat)[]) {
|
||||
entities
|
||||
@ -756,18 +753,6 @@ export function updater(update: Update, originRequest?: GramJs.AnyRequest) {
|
||||
));
|
||||
|
||||
if (channel instanceof GramJs.Channel) {
|
||||
if (shouldIgnoreNextChannelUpdate) {
|
||||
shouldIgnoreNextChannelUpdate = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (originRequest instanceof GramJs.messages.ToggleNoForwards) {
|
||||
shouldIgnoreNextChannelUpdate = true;
|
||||
setTimeout(() => {
|
||||
shouldIgnoreNextChannelUpdate = false;
|
||||
}, IGNORE_NEXT_CHANNEL_UPDATE_TIMEOUT);
|
||||
}
|
||||
|
||||
const chat = buildApiChatFromPreview(channel);
|
||||
if (chat) {
|
||||
onUpdate({
|
||||
|
||||
@ -130,9 +130,15 @@ function getUpdatedChat<T extends GlobalState>(
|
||||
const chat = byId[chatId];
|
||||
const omitProps: (keyof ApiChat)[] = [];
|
||||
|
||||
const shouldOmitMinInfo = chatUpdate.isMin && chat && !chat.isMin;
|
||||
if (shouldOmitMinInfo) {
|
||||
const shouldIgnoreUndefinedFields = chatUpdate.isMin && chat && !chat.isMin;
|
||||
if (shouldIgnoreUndefinedFields) {
|
||||
omitProps.push('isMin', 'accessHash');
|
||||
Object.keys(chatUpdate).forEach((key) => {
|
||||
const prop = key as keyof ApiChat;
|
||||
if (chatUpdate[prop] === undefined) {
|
||||
omitProps.push(prop);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (!noOmitUnreadReactionCount) {
|
||||
|
||||
@ -115,9 +115,15 @@ function getUpdatedUser(global: GlobalState, userId: string, userUpdate: Partial
|
||||
const user = byId[userId];
|
||||
const omitProps: (keyof ApiUser)[] = [];
|
||||
|
||||
const shouldOmitMinInfo = userUpdate.isMin && user && !user.isMin;
|
||||
if (shouldOmitMinInfo) {
|
||||
const shouldIgnoreUndefinedFields = userUpdate.isMin && user && !user.isMin;
|
||||
if (shouldIgnoreUndefinedFields) {
|
||||
omitProps.push('isMin', 'accessHash');
|
||||
Object.keys(userUpdate).forEach((key) => {
|
||||
const prop = key as keyof ApiUser;
|
||||
if (userUpdate[prop] === undefined) {
|
||||
omitProps.push(prop);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (areDeepEqual(user?.usernames, userUpdate.usernames)) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user