Fix some identifies

This commit is contained in:
morethanwords 2021-10-21 19:51:25 +04:00
parent beebb77bce
commit 2fb747c584
11 changed files with 14 additions and 15 deletions

View File

@ -53,7 +53,7 @@ export default class AppNewGroupTab extends SliderSuperTab {
const title = this.groupNameInputField.value;
this.nextBtn.disabled = true;
appChatsManager.createChat(title, this.peerIds).then((chatId) => {
appChatsManager.createChat(title, this.peerIds.map(peerId => peerId.toUserId())).then((chatId) => {
if(this.uploadAvatar) {
this.uploadAvatar().then((inputFile) => {
appChatsManager.editPhoto(chatId, inputFile);
@ -81,10 +81,10 @@ export default class AppNewGroupTab extends SliderSuperTab {
this.nextBtn.disabled = false;
}
public open(userIds: PeerId[]) {
public open(peerIds: PeerId[]) {
const result = super.open();
result.then(() => {
this.peerIds = userIds;
this.peerIds = peerIds;
this.peerIds.forEach(userId => {
let {dom} = appDialogsManager.addDialogNew({

View File

@ -31,7 +31,7 @@ export default class AppEditContactTab extends SliderSuperTab {
protected init() {
this.container.classList.add('edit-peer-container', 'edit-contact-container');
const isNew = !appUsersManager.isContact(this.peerId);
const isNew = !appUsersManager.isContact(this.peerId.toUserId());
this.setTitle(isNew ? 'AddContactTitle' : 'Edit');
{

View File

@ -433,7 +433,7 @@ export default class AppSharedMediaTab extends SliderSuperTab {
private toggleEditBtn() {
let show: boolean;
if(this.peerId.isUser()) {
show = this.peerId !== rootScope.myId && appUsersManager.isContact(this.peerId);
show = this.peerId !== rootScope.myId && appUsersManager.isContact(this.peerId.toUserId());
} else {
show = appChatsManager.hasRights(this.peerId.toChatId(), 'change_info');
}

View File

@ -77,7 +77,7 @@ export default function getRichElementValue(node: HTMLElement, lines: string[],
_: tag.entityName,
offset: offset.offset,
length: nodeValue.length,
user_id: parentElement.dataset.follow
user_id: parentElement.dataset.follow.toUserId()
});
} else {
entities.push({

View File

@ -25,7 +25,7 @@ Number.prototype.toUserId = function() {
};
Number.prototype.toChatId = function() {
return -this;
return Math.abs(this as any);
};
Number.prototype.toPeerId = function(isChat?: boolean) {

View File

@ -535,8 +535,8 @@ export class AppImManager {
}
case INTERNAL_LINK_TYPE.PRIVATE_POST: {
const chatId: ChatId = link.channel;
const peerId = link.channel.toPeerId(true);
const chatId = link.channel.toChatId();
const peerId = chatId.toPeerId(true);
const chat = appChatsManager.getChat(chatId);
if(chat.deleted) {

View File

@ -107,7 +107,7 @@ export class AppInlineBotsManager {
public switchToPM(fromPeerId: PeerId, botId: BotId, startParam: string) {
this.setHash[botId] = {peerId: fromPeerId, time: Date.now()};
rootScope.dispatchEvent('history_focus', {peerId: botId.toPeerId()});
return appMessagesManager.startBot(botId, '0', startParam);
return appMessagesManager.startBot(botId, undefined, startParam);
}
/*

View File

@ -3069,7 +3069,7 @@ export class AppMessagesManager {
});
}
public startBot(botId: BotId, chatId: ChatId, startParam: string) {
public startBot(botId: BotId, chatId?: ChatId, startParam?: string) {
const peerId = chatId ? chatId.toPeerId(true) : botId.toPeerId();
if(startParam) {
const randomId = randomLong();

View File

@ -170,7 +170,7 @@ export class AppProfileManager {
appUsersManager.saveApiUser(user, true);
if(userFull.profile_photo) {
userFull.profile_photo = appPhotosManager.savePhoto(userFull.profile_photo, {type: 'profilePhoto', peerId: peerId});
userFull.profile_photo = appPhotosManager.savePhoto(userFull.profile_photo, {type: 'profilePhoto', peerId});
}
if(userFull.about !== undefined) {
@ -262,7 +262,7 @@ export class AppProfileManager {
appUsersManager.saveApiUsers(result.users);
const fullChat = result.full_chat as ChatFull.chatFull;
if(fullChat && fullChat.chat_photo && fullChat.chat_photo.id) {
fullChat.chat_photo = appPhotosManager.savePhoto(fullChat.chat_photo, {type: 'profilePhoto', peerId: peerId});
fullChat.chat_photo = appPhotosManager.savePhoto(fullChat.chat_photo, {type: 'profilePhoto', peerId});
}
//appMessagesManager.savePinnedMessage(peerId, fullChat.pinned_msg_id);

View File

@ -31,7 +31,6 @@ import telegramMeWebManager from './telegramMeWebManager';
import { CacheStorageDbName } from '../cacheStorage';
import { pause } from '../../helpers/schedulers/pause';
import IS_WEBP_SUPPORTED from '../../environment/webpSupport';
import appUsersManager from '../appManagers/appUsersManager';
type Task = {
taskId: number,

View File

@ -305,7 +305,7 @@ namespace RichTextProcessor {
} else if(match[11]) { // custom mention
entity = {
_: 'messageEntityMentionName',
user_id: match[10],
user_id: match[10].toUserId(),
offset: matchIndex,
length: text.length
};