Channels: Fix error after posting (#2224)
This commit is contained in:
parent
f1a82ff079
commit
7a908c702a
@ -16,7 +16,7 @@ import type {
|
||||
} from '../../types';
|
||||
|
||||
import {
|
||||
DEBUG, ARCHIVED_FOLDER_ID, MEMBERS_LOAD_SLICE, SERVICE_NOTIFICATIONS_USER_ID, ALL_FOLDER_ID,
|
||||
DEBUG, ARCHIVED_FOLDER_ID, MEMBERS_LOAD_SLICE, SERVICE_NOTIFICATIONS_USER_ID, ALL_FOLDER_ID, MAX_INT_32,
|
||||
} from '../../../config';
|
||||
import { invokeRequest, uploadFile } from './client';
|
||||
import {
|
||||
@ -57,7 +57,6 @@ type FullChatData = {
|
||||
membersCount?: number;
|
||||
};
|
||||
|
||||
const MAX_INT_32 = 2 ** 31 - 1;
|
||||
let onUpdate: OnApiUpdate;
|
||||
|
||||
export function init(_onUpdate: OnApiUpdate) {
|
||||
|
||||
@ -24,7 +24,7 @@ import {
|
||||
|
||||
import {
|
||||
ALL_FOLDER_ID,
|
||||
DEBUG, MENTION_UNREAD_SLICE,
|
||||
DEBUG, MAX_INT_32, MENTION_UNREAD_SLICE,
|
||||
PINNED_MESSAGES_LIMIT, REACTION_UNREAD_SLICE,
|
||||
SUPPORTED_IMAGE_CONTENT_TYPES,
|
||||
SUPPORTED_VIDEO_CONTENT_TYPES,
|
||||
@ -97,7 +97,7 @@ export async function fetchMessages({
|
||||
}),
|
||||
...(offsetId && {
|
||||
// Workaround for local message IDs overflowing some internal `Buffer` range check
|
||||
offsetId: Math.min(offsetId, 2 ** (32 - 1) - 1),
|
||||
offsetId: Math.min(offsetId, MAX_INT_32),
|
||||
}),
|
||||
...pagination,
|
||||
}), undefined, true);
|
||||
@ -763,27 +763,29 @@ export async function sendMessageAction({
|
||||
}
|
||||
|
||||
export async function markMessageListRead({
|
||||
chat, threadId, maxId, serverTimeOffset,
|
||||
chat, threadId, maxId = -1, serverTimeOffset,
|
||||
}: {
|
||||
chat: ApiChat; threadId: number; maxId?: number; serverTimeOffset: number;
|
||||
}) {
|
||||
const isChannel = getEntityTypeById(chat.id) === 'channel';
|
||||
|
||||
// Workaround for local message IDs overflowing some internal `Buffer` range check
|
||||
const fixedMaxId = Math.min(maxId, MAX_INT_32);
|
||||
if (isChannel && threadId === MAIN_THREAD_ID) {
|
||||
await invokeRequest(new GramJs.channels.ReadHistory({
|
||||
channel: buildInputEntity(chat.id, chat.accessHash) as GramJs.InputChannel,
|
||||
maxId,
|
||||
maxId: fixedMaxId,
|
||||
}));
|
||||
} else if (isChannel) {
|
||||
await invokeRequest(new GramJs.messages.ReadDiscussion({
|
||||
peer: buildInputPeer(chat.id, chat.accessHash),
|
||||
msgId: threadId,
|
||||
readMaxId: maxId,
|
||||
readMaxId: fixedMaxId,
|
||||
}));
|
||||
} else {
|
||||
await invokeRequest(new GramJs.messages.ReadHistory({
|
||||
peer: buildInputPeer(chat.id, chat.accessHash),
|
||||
maxId,
|
||||
maxId: fixedMaxId,
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
@ -10,9 +10,9 @@ import type {
|
||||
ApiNotifyException, ApiPhoto,
|
||||
} from '../../types';
|
||||
import type { ApiPrivacyKey, InputPrivacyRules, LangCode } from '../../../types';
|
||||
|
||||
import type { LANG_PACKS } from '../../../config';
|
||||
import { BLOCKED_LIST_LIMIT, DEFAULT_LANG_PACK } from '../../../config';
|
||||
|
||||
import { BLOCKED_LIST_LIMIT, DEFAULT_LANG_PACK, MAX_INT_32 } from '../../../config';
|
||||
import { ACCEPTABLE_USERNAME_ERRORS } from './management';
|
||||
import {
|
||||
buildApiConfig,
|
||||
@ -39,7 +39,6 @@ import { getServerTime } from '../../../util/serverTime';
|
||||
import { addEntitiesWithPhotosToLocalDb, addPhotoToLocalDb } from '../helpers';
|
||||
import localDb from '../localDb';
|
||||
|
||||
const MAX_INT_32 = 2 ** 31 - 1;
|
||||
const BETA_LANG_CODES = ['ar', 'fa', 'id', 'ko', 'uz', 'en'];
|
||||
|
||||
export function updateProfile({
|
||||
|
||||
@ -3,6 +3,7 @@ import React, {
|
||||
memo, useState, useEffect, useMemo, useCallback,
|
||||
} from '../../lib/teact/teact';
|
||||
|
||||
import { MAX_INT_32 } from '../../config';
|
||||
import buildClassName from '../../util/buildClassName';
|
||||
import { formatTime, formatDateToString, getDayStart } from '../../util/dateFormat';
|
||||
import type { LangFn } from '../../hooks/useLang';
|
||||
@ -15,7 +16,7 @@ import Button from '../ui/Button';
|
||||
|
||||
import './CalendarModal.scss';
|
||||
|
||||
const MAX_SAFE_DATE = 2147483647 * 1000; // API has int for dates
|
||||
const MAX_SAFE_DATE = MAX_INT_32 * 1000;
|
||||
const MIN_SAFE_DATE = 0;
|
||||
|
||||
export type OwnProps = {
|
||||
|
||||
@ -120,6 +120,7 @@ export const MOBILE_SCREEN_LANDSCAPE_MAX_WIDTH = 950; // px
|
||||
export const MOBILE_SCREEN_LANDSCAPE_MAX_HEIGHT = 450; // px
|
||||
|
||||
export const LOCAL_MESSAGE_MIN_ID = 1e11; // `Date.now()` is always used as base
|
||||
export const MAX_INT_32 = 2 ** 31 - 1;
|
||||
export const TMP_CHAT_ID = '0';
|
||||
|
||||
export const ANIMATION_END_DELAY = 100;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user