Browse Source

Fix some identifies

master
morethanwords 3 years ago
parent
commit
2fb747c584
  1. 6
      src/components/sidebarLeft/tabs/newGroup.ts
  2. 2
      src/components/sidebarRight/tabs/editContact.ts
  3. 2
      src/components/sidebarRight/tabs/sharedMedia.ts
  4. 2
      src/helpers/dom/getRichElementValue.ts
  5. 2
      src/helpers/peerIdPolyfill.ts
  6. 4
      src/lib/appManagers/appImManager.ts
  7. 2
      src/lib/appManagers/appInlineBotsManager.ts
  8. 2
      src/lib/appManagers/appMessagesManager.ts
  9. 4
      src/lib/appManagers/appProfileManager.ts
  10. 1
      src/lib/mtproto/mtprotoworker.ts
  11. 2
      src/lib/richtextprocessor.ts

6
src/components/sidebarLeft/tabs/newGroup.ts

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

2
src/components/sidebarRight/tabs/editContact.ts

@ -31,7 +31,7 @@ export default class AppEditContactTab extends SliderSuperTab {
protected init() { protected init() {
this.container.classList.add('edit-peer-container', 'edit-contact-container'); 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'); this.setTitle(isNew ? 'AddContactTitle' : 'Edit');
{ {

2
src/components/sidebarRight/tabs/sharedMedia.ts

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

2
src/helpers/dom/getRichElementValue.ts

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

2
src/helpers/peerIdPolyfill.ts

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

4
src/lib/appManagers/appImManager.ts

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

2
src/lib/appManagers/appInlineBotsManager.ts

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

2
src/lib/appManagers/appMessagesManager.ts

@ -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(); const peerId = chatId ? chatId.toPeerId(true) : botId.toPeerId();
if(startParam) { if(startParam) {
const randomId = randomLong(); const randomId = randomLong();

4
src/lib/appManagers/appProfileManager.ts

@ -170,7 +170,7 @@ export class AppProfileManager {
appUsersManager.saveApiUser(user, true); appUsersManager.saveApiUser(user, true);
if(userFull.profile_photo) { 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) { if(userFull.about !== undefined) {
@ -262,7 +262,7 @@ export class AppProfileManager {
appUsersManager.saveApiUsers(result.users); appUsersManager.saveApiUsers(result.users);
const fullChat = result.full_chat as ChatFull.chatFull; const fullChat = result.full_chat as ChatFull.chatFull;
if(fullChat && fullChat.chat_photo && fullChat.chat_photo.id) { 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); //appMessagesManager.savePinnedMessage(peerId, fullChat.pinned_msg_id);

1
src/lib/mtproto/mtprotoworker.ts

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

2
src/lib/richtextprocessor.ts

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

Loading…
Cancel
Save