Layer 128
This commit is contained in:
parent
57f4be00f0
commit
21f7a1201f
@ -908,12 +908,17 @@ export default class AppSearchSuper {
|
||||
}
|
||||
|
||||
participants.forEach(participant => {
|
||||
const user = appUsersManager.getUser(participant.user_id);
|
||||
const peerId = appChatsManager.getParticipantPeerId(participant);
|
||||
if(peerId < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const user = appUsersManager.getUser(peerId);
|
||||
if(user.pFlags.deleted) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.membersList.add(participant.user_id);
|
||||
this.membersList.add(peerId);
|
||||
});
|
||||
};
|
||||
|
||||
@ -1165,6 +1170,10 @@ export default class AppSearchSuper {
|
||||
return !this.loaded[inputFilter] || (this.historyStorage[inputFilter] && this.usedFromHistory[inputFilter] < this.historyStorage[inputFilter].length);
|
||||
});
|
||||
|
||||
if(peerId > 0) {
|
||||
toLoad.findAndSplice(mediaTab => mediaTab.type === 'members');
|
||||
}
|
||||
|
||||
if(!toLoad.length) {
|
||||
return;
|
||||
}
|
||||
|
@ -353,9 +353,11 @@ export default class AppSelectPeers {
|
||||
return;
|
||||
}
|
||||
|
||||
const userIds = participants.participants.map(participant => participant.user_id);
|
||||
userIds.findAndSplice(u => u === rootScope.myId);
|
||||
this.renderResultsFunc(userIds);
|
||||
const peerIds = participants.participants.map(participant => {
|
||||
return appChatsManager.getParticipantPeerId(participant);
|
||||
});
|
||||
peerIds.findAndSplice(u => u === rootScope.myId);
|
||||
this.renderResultsFunc(peerIds);
|
||||
|
||||
if(this.list.childElementCount >= participants.count || participants.participants.length < pageCount) {
|
||||
this.loadedWhat.channelParticipants = true;
|
||||
|
@ -11,6 +11,7 @@ import ScrollableLoader from "../../../helpers/listLoader";
|
||||
import { ChannelParticipant, Chat, ChatBannedRights, Update } from "../../../layer";
|
||||
import appChatsManager, { ChatRights } from "../../../lib/appManagers/appChatsManager";
|
||||
import appDialogsManager from "../../../lib/appManagers/appDialogsManager";
|
||||
import appPeersManager from "../../../lib/appManagers/appPeersManager";
|
||||
import appProfileManager from "../../../lib/appManagers/appProfileManager";
|
||||
import I18n, { i18n, join, LangPackKey } from "../../../lib/langPack";
|
||||
import rootScope from "../../../lib/rootScope";
|
||||
@ -241,7 +242,7 @@ export default class AppGroupPermissionsTab extends SliderSuperTabEventable {
|
||||
|
||||
const add = (participant: ChannelParticipant.channelParticipantBanned, append: boolean) => {
|
||||
const {dom} = appDialogsManager.addDialogNew({
|
||||
dialog: participant.user_id,
|
||||
dialog: appPeersManager.getPeerId(participant.peer),
|
||||
container: list,
|
||||
drawStatus: false,
|
||||
rippleEnabled: true,
|
||||
|
@ -4,10 +4,10 @@
|
||||
* https://github.com/morethanwords/tweb/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
import type { InputFileLocation, FileLocation } from "../layer";
|
||||
import type { InputFileLocation, InputStickerSet } from "../layer";
|
||||
import type { DownloadOptions } from "../lib/mtproto/apiFileManager";
|
||||
|
||||
export function getFileNameByLocation(location: InputFileLocation | FileLocation, options?: Partial<{
|
||||
export function getFileNameByLocation(location: InputFileLocation, options?: Partial<{
|
||||
fileName: string
|
||||
}>) {
|
||||
const fileName = '';//(options?.fileName || '').split('.');
|
||||
@ -20,9 +20,17 @@ export function getFileNameByLocation(location: InputFileLocation | FileLocation
|
||||
return (fileName[0] ? fileName[0] + '_' : '') + location.id + thumbPart + (ext ? '.' + ext : ext);
|
||||
}
|
||||
|
||||
case 'fileLocationToBeDeprecated':
|
||||
case 'inputPeerPhotoFileLocation':
|
||||
case 'inputStickerSetThumb':
|
||||
return ['peerPhoto', location.photo_id, location.pFlags.big ? 'big' : 'small'].join('_');
|
||||
|
||||
case 'inputStickerSetThumb': {
|
||||
const id = (location.stickerset as InputStickerSet.inputStickerSetID).id ||
|
||||
(location.stickerset as InputStickerSet.inputStickerSetShortName).short_name ||
|
||||
(location.stickerset as InputStickerSet.inputStickerSetDice).emoticon ||
|
||||
location.stickerset._;
|
||||
return ['stickerSetThumb', id, location.thumb_version].join('_');
|
||||
}
|
||||
|
||||
case 'inputFileLocation': {
|
||||
return location.volume_id + '_' + location.local_id + (ext ? '.' + ext : ext);
|
||||
}
|
||||
@ -42,4 +50,4 @@ export function getFileURL(type: FileURLType, options: DownloadOptions) {
|
||||
//console.log('getFileURL encode:', performance.now() - perf, encoded);
|
||||
|
||||
return '/' + type + '/' + encoded;
|
||||
}
|
||||
}
|
||||
|
3394
src/layer.d.ts
vendored
3394
src/layer.d.ts
vendored
File diff suppressed because it is too large
Load Diff
@ -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, ChatParticipants, InputChannel, InputChatPhoto, InputFile, InputPeer, SendMessageAction, Update, Updates } from "../../layer";
|
||||
import { ChannelParticipant, Chat, ChatAdminRights, ChatBannedRights, ChatFull, ChatParticipant, ChatParticipants, InputChannel, InputChatPhoto, InputFile, InputPeer, SendMessageAction, Update, Updates } from "../../layer";
|
||||
import { i18n, LangPackKey } from "../langPack";
|
||||
import apiManagerProxy from "../mtproto/mtprotoworker";
|
||||
import apiManager from '../mtproto/mtprotoworker';
|
||||
@ -742,11 +742,18 @@ export class AppChatsManager {
|
||||
});
|
||||
}
|
||||
|
||||
public getParticipantPeerId(participant: ChannelParticipant | ChatParticipant) {
|
||||
const peerId = (participant as ChannelParticipant.channelParticipantBanned).peer ?
|
||||
appPeersManager.getPeerId((participant as ChannelParticipant.channelParticipantBanned).peer) :
|
||||
(participant as ChatParticipant.chatParticipant).user_id;
|
||||
return peerId;
|
||||
}
|
||||
|
||||
public editBanned(id: number, participant: number | ChannelParticipant, banned_rights: ChatBannedRights) {
|
||||
const userId = typeof(participant) === 'number' ? participant : participant.user_id;
|
||||
const peerId = typeof(participant) === 'number' ? participant : this.getParticipantPeerId(participant);
|
||||
return apiManager.invokeApi('channels.editBanned', {
|
||||
channel: this.getChannelInput(id),
|
||||
user_id: appUsersManager.getUserInput(userId),
|
||||
participant: appPeersManager.getInputPeerById(peerId),
|
||||
banned_rights
|
||||
}).then((updates) => {
|
||||
this.onChatUpdated(id, updates);
|
||||
@ -759,15 +766,16 @@ export class AppChatsManager {
|
||||
_: 'updateChannelParticipant',
|
||||
channel_id: id,
|
||||
date: timestamp,
|
||||
//qts: 0,
|
||||
user_id: userId,
|
||||
actor_id: undefined,
|
||||
qts: undefined,
|
||||
user_id: peerId,
|
||||
prev_participant: participant,
|
||||
new_participant: Object.keys(banned_rights.pFlags).length ? {
|
||||
_: 'channelParticipantBanned',
|
||||
date: timestamp,
|
||||
banned_rights,
|
||||
kicked_by: appUsersManager.getSelf().id,
|
||||
user_id: userId,
|
||||
peer: appPeersManager.getOutputPeer(peerId),
|
||||
pFlags: {}
|
||||
} : undefined
|
||||
} as Update.updateChannelParticipant
|
||||
|
@ -705,7 +705,6 @@ export class AppMessagesManager {
|
||||
w: options.width,
|
||||
h: options.height,
|
||||
type: 'full',
|
||||
location: null,
|
||||
size: file.size
|
||||
};
|
||||
} else if(attachType === 'video') {
|
||||
@ -715,7 +714,6 @@ export class AppMessagesManager {
|
||||
w: options.width,
|
||||
h: options.height,
|
||||
type: 'full',
|
||||
location: null,
|
||||
size: options.thumbBlob.size
|
||||
};
|
||||
|
||||
|
@ -15,7 +15,7 @@ import { CancellablePromise } from "../../helpers/cancellablePromise";
|
||||
import { getFileNameByLocation } from "../../helpers/fileName";
|
||||
import { safeReplaceArrayInObject, defineNotNumerableProperties, isObject } from "../../helpers/object";
|
||||
import { isSafari } from "../../helpers/userAgent";
|
||||
import { FileLocation, InputFileLocation, InputMedia, Photo, PhotoSize, PhotosPhotos } from "../../layer";
|
||||
import { InputFileLocation, InputMedia, Photo, PhotoSize, PhotosPhotos } from "../../layer";
|
||||
import apiManager from "../mtproto/mtprotoworker";
|
||||
import referenceDatabase, { ReferenceContext } from "../mtproto/referenceDatabase";
|
||||
import { calcImageInBox } from "../../helpers/dom";
|
||||
@ -274,13 +274,13 @@ export class AppPhotosManager {
|
||||
|
||||
// maybe it's a thumb
|
||||
const isPhoto = (photoSize._ === 'photoSize' || photoSize._ === 'photoSizeProgressive') && photo.access_hash && photo.file_reference;
|
||||
const location: InputFileLocation.inputPhotoFileLocation | InputFileLocation.inputDocumentFileLocation | FileLocation = isPhoto ? {
|
||||
const location: InputFileLocation.inputPhotoFileLocation | InputFileLocation.inputDocumentFileLocation = {
|
||||
_: isDocument ? 'inputDocumentFileLocation' : 'inputPhotoFileLocation',
|
||||
id: photo.id,
|
||||
access_hash: photo.access_hash,
|
||||
file_reference: photo.file_reference,
|
||||
thumb_size: photoSize.type
|
||||
} : (photoSize as PhotoSize.photoSize).location;
|
||||
};
|
||||
|
||||
return {
|
||||
dcId: photo.dc_id,
|
||||
|
@ -14,7 +14,7 @@ import { tsNow } from "../../helpers/date";
|
||||
import { replaceContent } from "../../helpers/dom";
|
||||
import renderImageFromUrl from "../../helpers/dom/renderImageFromUrl";
|
||||
import sequentialDom from "../../helpers/sequentialDom";
|
||||
import { ChannelParticipantsFilter, ChannelsChannelParticipants, ChatFull, ChatParticipants, ChatPhoto, ExportedChatInvite, InputChannel, InputFile, InputFileLocation, PhotoSize, UserFull, UserProfilePhoto } from "../../layer";
|
||||
import { ChannelParticipantsFilter, ChannelsChannelParticipants, Chat, ChatFull, ChatParticipants, ChatPhoto, ExportedChatInvite, InputChannel, InputFile, InputFileLocation, PhotoSize, UserFull, UserProfilePhoto } from "../../layer";
|
||||
//import apiManager from '../mtproto/apiManager';
|
||||
import apiManager from '../mtproto/mtprotoworker';
|
||||
import { RichTextProcessor } from "../richtextprocessor";
|
||||
@ -97,10 +97,11 @@ export class AppProfileManager {
|
||||
|
||||
rootScope.on('chat_update', (chatId) => {
|
||||
const fullChat = this.chatsFull[chatId];
|
||||
const chat = appChatsManager.getChat(chatId);
|
||||
const chat: Chat.chat = appChatsManager.getChat(chatId);
|
||||
if(!chat.photo || !fullChat) {
|
||||
return;
|
||||
}
|
||||
|
||||
const emptyPhoto = chat.photo._ === 'chatPhotoEmpty';
|
||||
//////console.log('chat_update:', fullChat);
|
||||
if(fullChat.chat_photo && emptyPhoto !== (fullChat.chat_photo._ === 'photoEmpty')) {
|
||||
@ -112,9 +113,9 @@ export class AppProfileManager {
|
||||
return;
|
||||
}
|
||||
|
||||
const smallUserpic = chat.photo.photo_small;
|
||||
const smallPhotoSize = fullChat.chat_photo ? appPhotosManager.choosePhotoSize(fullChat.chat_photo as MyPhoto, 0, 0) : undefined;
|
||||
if(!smallPhotoSize || JSON.stringify(smallUserpic) !== JSON.stringify((smallPhotoSize as PhotoSize.photoSize).location)) {
|
||||
const photoId = (chat.photo as ChatPhoto.chatPhoto).photo_id;
|
||||
const chatFullPhotoId = fullChat.chat_photo?.id;
|
||||
if(chatFullPhotoId !== photoId) {
|
||||
delete this.chatsFull[chatId];
|
||||
rootScope.broadcast('chat_full_update', chatId);
|
||||
}
|
||||
@ -328,10 +329,10 @@ export class AppProfileManager {
|
||||
} */
|
||||
}
|
||||
|
||||
public getChannelParticipant(id: number, userId: number) {
|
||||
public getChannelParticipant(id: number, peerId: number) {
|
||||
return apiManager.invokeApiSingle('channels.getParticipant', {
|
||||
channel: appChatsManager.getChannelInput(id),
|
||||
user_id: appUsersManager.getUserInput(userId)
|
||||
participant: appPeersManager.getInputPeerById(peerId),
|
||||
}).then(channelParticipant => {
|
||||
appUsersManager.saveApiUsers(channelParticipant.users);
|
||||
return channelParticipant.participant;
|
||||
@ -452,8 +453,7 @@ export class AppProfileManager {
|
||||
_: 'inputPeerPhotoFileLocation',
|
||||
pFlags: {},
|
||||
peer: inputPeer,
|
||||
volume_id: photo[size].volume_id,
|
||||
local_id: photo[size].local_id
|
||||
photo_id: photo.photo_id
|
||||
};
|
||||
|
||||
if(size === 'photo_big') {
|
||||
@ -536,7 +536,7 @@ export class AppProfileManager {
|
||||
const photo = appPeersManager.getPeerPhoto(peerId);
|
||||
|
||||
const size: PeerPhotoSize = 'photo_small';
|
||||
const avatarAvailable = photo && photo[size];
|
||||
const avatarAvailable = !!photo;
|
||||
const avatarRendered = !!div.firstElementChild;
|
||||
|
||||
const myId = rootScope.myId;
|
||||
|
@ -132,11 +132,10 @@ export class AppStickersManager {
|
||||
const input: InputFileLocation.inputStickerSetThumb = {
|
||||
_: 'inputStickerSetThumb',
|
||||
stickerset: this.getStickerSetInput(stickerSet),
|
||||
volume_id: thumb.location.volume_id,
|
||||
local_id: thumb.location.local_id
|
||||
thumb_version: stickerSet.thumb_version
|
||||
};
|
||||
|
||||
return {dcId, location: input, size: thumb.size, mimeType: isAnimated ? "application/x-tgsticker" : 'image/webp'};
|
||||
return {dcId, location: input, size: thumb.size, mimeType: isAnimated ? 'application/x-tgsticker' : 'image/webp'};
|
||||
}
|
||||
|
||||
/* public getStickerSetThumbURL(stickerSet: MTStickerSet) {
|
||||
|
@ -15,7 +15,7 @@ import { CancellablePromise, deferredPromise } from "../../helpers/cancellablePr
|
||||
import { notifyAll, notifySomeone } from "../../helpers/context";
|
||||
import { getFileNameByLocation } from "../../helpers/fileName";
|
||||
import { nextRandomInt } from "../../helpers/random";
|
||||
import { FileLocation, InputFile, InputFileLocation, UploadFile } from "../../layer";
|
||||
import { InputFile, InputFileLocation, UploadFile } from "../../layer";
|
||||
import CacheStorageController from "../cacheStorage";
|
||||
import cryptoWorker from "../crypto/cryptoworker";
|
||||
import FileManager from "../filemanager";
|
||||
@ -31,7 +31,7 @@ type Delayed = {
|
||||
|
||||
export type DownloadOptions = {
|
||||
dcId: number,
|
||||
location: InputFileLocation | FileLocation,
|
||||
location: InputFileLocation,
|
||||
size?: number,
|
||||
fileName?: string,
|
||||
mimeType?: string,
|
||||
@ -150,7 +150,7 @@ export class ApiFileManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
public requestFilePart(dcId: number, location: InputFileLocation | FileLocation, offset: number, limit: number, id = 0, queueId = 0, checkCancel?: () => void) {
|
||||
public requestFilePart(dcId: number, location: InputFileLocation, offset: number, limit: number, id = 0, queueId = 0, checkCancel?: () => void) {
|
||||
return this.downloadRequest(dcId, id, async() => {
|
||||
checkCancel && checkCancel();
|
||||
|
||||
|
@ -12,7 +12,7 @@ import { logger, LogTypes } from '../logger';
|
||||
import type { DownloadOptions } from './apiFileManager';
|
||||
import type { WorkerTaskTemplate } from '../../types';
|
||||
import { notifySomeone } from '../../helpers/context';
|
||||
import type { InputFileLocation, FileLocation, UploadFile } from '../../layer';
|
||||
import type { InputFileLocation, UploadFile } from '../../layer';
|
||||
import { CancellablePromise, deferredPromise } from '../../helpers/cancellablePromise';
|
||||
|
||||
const log = logger('SW', LogTypes.Error | LogTypes.Debug | LogTypes.Log | LogTypes.Warn);
|
||||
@ -39,7 +39,7 @@ let taskId = 0;
|
||||
|
||||
export interface ServiceWorkerTask extends WorkerTaskTemplate {
|
||||
type: 'requestFilePart',
|
||||
payload: [number, InputFileLocation | FileLocation, number, number]
|
||||
payload: [number, InputFileLocation, number, number]
|
||||
};
|
||||
|
||||
export interface ServiceWorkerTaskResponse extends WorkerTaskTemplate {
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -9,7 +9,7 @@ const fs = require('fs');
|
||||
const allowedIPs = ['127.0.0.1'];
|
||||
const devMode = process.env.NODE_ENV !== 'production';
|
||||
const useLocal = true;
|
||||
const useLocalNotLocal = false;
|
||||
const useLocalNotLocal = true;
|
||||
|
||||
if(devMode) {
|
||||
console.log('DEVMODE IS ON!');
|
||||
|
Loading…
x
Reference in New Issue
Block a user