Browse Source

Networker connection status

master
Eduard Kuzmenko 4 years ago
parent
commit
d9b1b31108
  1. 6
      src/components/animationIntersector.ts
  2. 6
      src/components/appMediaPlaybackController.ts
  3. 8
      src/components/appMediaViewer.ts
  4. 10
      src/components/appSearch.ts
  5. 14
      src/components/appSelectPeers.ts
  6. 6
      src/components/audio.ts
  7. 4
      src/components/avatar.ts
  8. 4
      src/components/bubbleGroups.ts
  9. 6
      src/components/chat/audio.ts
  10. 10
      src/components/chat/contextMenu.ts
  11. 18
      src/components/chat/input.ts
  12. 4
      src/components/chat/search.ts
  13. 6
      src/components/dialogsContextMenu.ts
  14. 6
      src/components/emoticonsDropdown/index.ts
  15. 6
      src/components/emoticonsDropdown/tabs/stickers.ts
  16. 6
      src/components/poll.ts
  17. 6
      src/components/popup.ts
  18. 6
      src/components/popupCreatePoll.ts
  19. 8
      src/components/popupDeleteMessages.ts
  20. 11
      src/components/sidebarLeft/index.ts
  21. 10
      src/components/sidebarLeft/tabs/chatFolders.ts
  22. 6
      src/components/sidebarLeft/tabs/contacts.ts
  23. 4
      src/components/sidebarLeft/tabs/editProfile.ts
  24. 4
      src/components/sidebarLeft/tabs/includedChats.ts
  25. 4
      src/components/sidebarLeft/tabs/settings.ts
  26. 16
      src/components/sidebarRight/tabs/sharedMedia.ts
  27. 6
      src/lib/appManagers/AppInlineBotsManager.ts
  28. 16
      src/lib/appManagers/apiUpdatesManager.ts
  29. 10
      src/lib/appManagers/appChatsManager.ts
  30. 96
      src/lib/appManagers/appDialogsManager.ts
  31. 4
      src/lib/appManagers/appDownloadManager.ts
  32. 46
      src/lib/appManagers/appImManager.ts
  33. 114
      src/lib/appManagers/appMessagesManager.ts
  34. 6
      src/lib/appManagers/appPeersManager.ts
  35. 6
      src/lib/appManagers/appPollsManager.ts
  36. 4
      src/lib/appManagers/appStateManager.ts
  37. 10
      src/lib/appManagers/appStickersManager.ts
  38. 26
      src/lib/appManagers/appUsersManager.ts
  39. 6
      src/lib/appManagers/appWebPagesManager.ts
  40. 8
      src/lib/mtproto/apiManager.ts
  41. 4
      src/lib/mtproto/mtproto.worker.ts
  42. 8
      src/lib/mtproto/mtprotoworker.ts
  43. 97
      src/lib/mtproto/networker.ts
  44. 3
      src/lib/mtproto/networkerFactory.ts
  45. 18
      src/lib/mtproto/transports/websocket.ts
  46. 56
      src/lib/rootScope.ts
  47. 14
      src/lib/storages/filters.ts
  48. 73
      src/scss/partials/_leftSidebar.scss
  49. 4
      src/scss/style.scss
  50. 10
      src/types.d.ts

6
src/components/animationIntersector.ts

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
import { isInDOM } from "../helpers/dom";
import { RLottiePlayer } from "../lib/lottieLoader";
import { MOUNT_CLASS_TO } from "../lib/mtproto/mtproto_config";
import $rootScope from "../lib/rootScope";
import rootScope from "../lib/rootScope";
import { isSafari } from "../helpers/userAgent";
export interface AnimationItem {
@ -22,7 +22,7 @@ export class AnimationIntersector { @@ -22,7 +22,7 @@ export class AnimationIntersector {
constructor() {
this.observer = new IntersectionObserver((entries) => {
if($rootScope.idle.isIDLE) return;
if(rootScope.idle.isIDLE) return;
for(const entry of entries) {
const target = entry.target;
@ -99,7 +99,7 @@ export class AnimationIntersector { @@ -99,7 +99,7 @@ export class AnimationIntersector {
}
public checkAnimations(blurred?: boolean, group?: string, destroy = false) {
if($rootScope.idle.isIDLE) return;
if(rootScope.idle.isIDLE) return;
const groups = group /* && false */ ? [group] : Object.keys(this.byGroups);

6
src/components/appMediaPlaybackController.ts

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
import $rootScope from "../lib/rootScope";
import rootScope from "../lib/rootScope";
import appMessagesManager from "../lib/appManagers/appMessagesManager";
import appDocsManager, {MyDocument} from "../lib/appManagers/appDocsManager";
import { CancellablePromise, deferredPromise } from "../helpers/cancellablePromise";
@ -66,7 +66,7 @@ class AppMediaPlaybackController { @@ -66,7 +66,7 @@ class AppMediaPlaybackController {
// audio_pause не успеет сработать без таймаута
setTimeout(() => {
$rootScope.$broadcast('audio_play', {doc, mid});
rootScope.broadcast('audio_play', {doc, mid});
}, 0);
});
@ -158,7 +158,7 @@ class AppMediaPlaybackController { @@ -158,7 +158,7 @@ class AppMediaPlaybackController {
}
onPause = (e: Event) => {
$rootScope.$broadcast('audio_pause');
rootScope.broadcast('audio_pause');
};
onEnded = (e: Event) => {

8
src/components/appMediaViewer.ts

@ -10,7 +10,7 @@ import appPhotosManager from "../lib/appManagers/appPhotosManager"; @@ -10,7 +10,7 @@ import appPhotosManager from "../lib/appManagers/appPhotosManager";
import { logger } from "../lib/logger";
import VideoPlayer from "../lib/mediaPlayer";
import { RichTextProcessor } from "../lib/richtextprocessor";
import $rootScope from "../lib/rootScope";
import rootScope from "../lib/rootScope";
import { cancelEvent, fillPropertyValue, findUpClassName, generatePathData } from "../helpers/dom";
import animationIntersector from "./animationIntersector";
import appMediaPlaybackController from "./appMediaPlaybackController";
@ -253,7 +253,7 @@ class AppMediaViewerBase<ContentAdditionType extends string, ButtonsAdditionType @@ -253,7 +253,7 @@ class AppMediaViewerBase<ContentAdditionType extends string, ButtonsAdditionType
promise.finally(() => {
this.wholeDiv.remove();
$rootScope.overlayIsActive = false;
rootScope.overlayIsActive = false;
animationIntersector.checkAnimations(false);
});
@ -868,7 +868,7 @@ class AppMediaViewerBase<ContentAdditionType extends string, ButtonsAdditionType @@ -868,7 +868,7 @@ class AppMediaViewerBase<ContentAdditionType extends string, ButtonsAdditionType
this.pageEl.insertBefore(this.wholeDiv, mainColumns);
void this.wholeDiv.offsetLeft; // reflow
this.wholeDiv.classList.add('active');
$rootScope.overlayIsActive = true;
rootScope.overlayIsActive = true;
animationIntersector.checkAnimations(true);
}
@ -1324,7 +1324,7 @@ export default class AppMediaViewer extends AppMediaViewerBase<'caption', 'delet @@ -1324,7 +1324,7 @@ export default class AppMediaViewer extends AppMediaViewerBase<'caption', 'delet
else fromRight = this.currentMessageID > mid ? 1 : -1;
} else {
this.reverse = reverse;
this.peerID = $rootScope.selectedPeerID;
this.peerID = rootScope.selectedPeerID;
}
this.currentMessageID = mid;

10
src/components/appSearch.ts

@ -8,7 +8,7 @@ import { formatPhoneNumber } from "./misc"; @@ -8,7 +8,7 @@ import { formatPhoneNumber } from "./misc";
import appChatsManager from "../lib/appManagers/appChatsManager";
import SearchInput from "./searchInput";
import { Peer } from "../layer";
import $rootScope from "../lib/rootScope";
import rootScope from "../lib/rootScope";
import { escapeRegExp } from "../helpers/string";
export class SearchGroup {
@ -137,7 +137,7 @@ export default class AppSearch { @@ -137,7 +137,7 @@ export default class AppSearch {
private renderSaved() {
const group = this.searchGroups.contacts;
let {dialog, dom} = appDialogsManager.addDialog($rootScope.myID, group.list, false);
let {dialog, dom} = appDialogsManager.addDialog(rootScope.myID, group.list, false);
dom.lastMessageSpan.innerHTML = 'chat with yourself';
group.setActive();
}
@ -161,7 +161,7 @@ export default class AppSearch { @@ -161,7 +161,7 @@ export default class AppSearch {
if(!this.peerID && !maxID && !this.loadedContacts) {
let renderedSaved = false;
if('saved messages'.includes(query.toLowerCase())
|| appUsersManager.getUser($rootScope.myID).sortName.includes(query.toLowerCase())/* && this.searchGroups.hasOwnProperty('saved') */) {
|| appUsersManager.getUser(rootScope.myID).sortName.includes(query.toLowerCase())/* && this.searchGroups.hasOwnProperty('saved') */) {
this.renderSaved();
renderedSaved = true;
}
@ -174,7 +174,7 @@ export default class AppSearch { @@ -174,7 +174,7 @@ export default class AppSearch {
this.loadedContacts = true;
// set saved message as first peer to render
const peer = contacts.my_results.findAndSplice(p => (p as Peer.peerUser).user_id == $rootScope.myID);
const peer = contacts.my_results.findAndSplice(p => (p as Peer.peerUser).user_id == rootScope.myID);
if(peer) {
contacts.my_results.unshift(peer);
}
@ -184,7 +184,7 @@ export default class AppSearch { @@ -184,7 +184,7 @@ export default class AppSearch {
let setResults = (results: Peer[], group: SearchGroup, showMembersCount = false) => {
// ! because contacts.search returns duplicates in my_results
new Set(results.map(peer => appPeersManager.getPeerID(peer))).forEach((peerID) => {
if(peerID == $rootScope.myID) {
if(peerID == rootScope.myID) {
if(!renderedSaved) {
this.renderSaved();
}

14
src/components/appSelectPeers.ts

@ -4,7 +4,7 @@ import appMessagesManager, { Dialog } from "../lib/appManagers/appMessagesManage @@ -4,7 +4,7 @@ import appMessagesManager, { Dialog } from "../lib/appManagers/appMessagesManage
import appPeersManager from "../lib/appManagers/appPeersManager";
import appPhotosManager from "../lib/appManagers/appPhotosManager";
import appUsersManager from "../lib/appManagers/appUsersManager";
import $rootScope from "../lib/rootScope";
import rootScope from "../lib/rootScope";
import { cancelEvent, findUpAttribute, findUpClassName } from "../helpers/dom";
import Scrollable from "./scrollable";
@ -168,9 +168,9 @@ export default class AppSelectPeers { @@ -168,9 +168,9 @@ export default class AppSelectPeers {
if(!this.offsetIndex && this.folderID == 0 &&
(!this.query
|| 'saved messages'.includes(this.query.toLowerCase())
|| appUsersManager.getUser($rootScope.myID).sortName.includes(this.query.toLowerCase())) &&
|| appUsersManager.getUser(rootScope.myID).sortName.includes(this.query.toLowerCase())) &&
this.peerType.includes('dialogs')) {
this.renderResultsFunc([$rootScope.myID]);
this.renderResultsFunc([rootScope.myID]);
}
}
@ -193,7 +193,7 @@ export default class AppSelectPeers { @@ -193,7 +193,7 @@ export default class AppSelectPeers {
const newOffsetIndex = dialogs[dialogs.length - 1].index || 0;
dialogs = dialogs.slice();
dialogs.findAndSplice(d => d.peerID == $rootScope.myID); // no my account
dialogs.findAndSplice(d => d.peerID == rootScope.myID); // no my account
if(this.chatRightsAction) {
dialogs = dialogs.filter(d => {
@ -242,7 +242,7 @@ export default class AppSelectPeers { @@ -242,7 +242,7 @@ export default class AppSelectPeers {
this.cachedContacts = (await this.promise)[0].slice(); */
this.promise = appUsersManager.getContacts(this.query);
this.cachedContacts = (await this.promise).slice();
this.cachedContacts.findAndSplice(userID => userID == $rootScope.myID); // no my account
this.cachedContacts.findAndSplice(userID => userID == rootScope.myID); // no my account
this.promise = null;
}
@ -327,7 +327,7 @@ export default class AppSelectPeers { @@ -327,7 +327,7 @@ export default class AppSelectPeers {
let subtitle = '';
if(peerID < 0) {
subtitle = appChatsManager.getChatMembersString(-peerID);
} else if(peerID == $rootScope.myID) {
} else if(peerID == rootScope.myID) {
subtitle = 'chat with yourself';
} else {
subtitle = appUsersManager.getUserStatusString(peerID);
@ -359,7 +359,7 @@ export default class AppSelectPeers { @@ -359,7 +359,7 @@ export default class AppSelectPeers {
div.dataset.key = '' + peerID;
if(typeof(peerID) === 'number') {
if(title === undefined) {
title = peerID == $rootScope.myID ? 'Saved' : appPeersManager.getPeerTitle(peerID, false, true);
title = peerID == rootScope.myID ? 'Saved' : appPeersManager.getPeerTitle(peerID, false, true);
}
avatarEl.setAttribute('peer', '' + peerID);

6
src/components/audio.ts

@ -9,10 +9,10 @@ import { Download } from "../lib/appManagers/appDownloadManager"; @@ -9,10 +9,10 @@ import { Download } from "../lib/appManagers/appDownloadManager";
import mediaSizes from "../helpers/mediaSizes";
import { isSafari } from "../helpers/userAgent";
import appMessagesManager from "../lib/appManagers/appMessagesManager";
import $rootScope from "../lib/rootScope";
import rootScope from "../lib/rootScope";
import './middleEllipsis';
$rootScope.$on('messages_media_read', e => {
rootScope.on('messages_media_read', e => {
const mids = e.detail;
mids.forEach(mid => {
@ -64,7 +64,7 @@ function wrapVoiceMessage(doc: MyDocument, audioEl: AudioElement, mid: number) { @@ -64,7 +64,7 @@ function wrapVoiceMessage(doc: MyDocument, audioEl: AudioElement, mid: number) {
audioEl.classList.add('is-voice');
const message = appMessagesManager.getMessage(mid);
const isOut = message.fromID == $rootScope.myID && message.peerID != $rootScope.myID;
const isOut = message.fromID == rootScope.myID && message.peerID != rootScope.myID;
let isUnread = message && message.pFlags.media_unread;
if(isUnread) {
audioEl.classList.add('is-unread');

4
src/components/avatar.ts

@ -1,10 +1,10 @@ @@ -1,10 +1,10 @@
import appMessagesManager from "../lib/appManagers/appMessagesManager";
import appProfileManager from "../lib/appManagers/appProfileManager";
import $rootScope from "../lib/rootScope";
import rootScope from "../lib/rootScope";
import { cancelEvent } from "../helpers/dom";
import AppMediaViewer, { AppMediaViewerAvatar } from "./appMediaViewer";
$rootScope.$on('avatar_update', (e) => {
rootScope.on('avatar_update', (e) => {
let peerID = e.detail;
appProfileManager.removeFromAvatarsCache(peerID);

4
src/components/bubbleGroups.ts

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
import $rootScope from "../lib/rootScope";
import rootScope from "../lib/rootScope";
import { generatePathData } from "../helpers/dom";
export default class BubbleGroups {
@ -25,7 +25,7 @@ export default class BubbleGroups { @@ -25,7 +25,7 @@ export default class BubbleGroups {
let group: HTMLDivElement[];
// fix for saved messages forward to self
if(fromID == $rootScope.myID && $rootScope.selectedPeerID == $rootScope.myID && message.fwdFromID == fromID) {
if(fromID == rootScope.myID && rootScope.selectedPeerID == rootScope.myID && message.fwdFromID == fromID) {
fromID = -fromID;
}

6
src/components/chat/audio.ts

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
import appMessagesManager from "../../lib/appManagers/appMessagesManager";
import appPeersManager from "../../lib/appManagers/appPeersManager";
import { RichTextProcessor } from "../../lib/richtextprocessor";
import $rootScope from "../../lib/rootScope";
import rootScope from "../../lib/rootScope";
import { cancelEvent } from "../../helpers/dom";
import appMediaPlaybackController from "../appMediaPlaybackController";
import DivAndCaption from "../divAndCaption";
@ -32,7 +32,7 @@ export class ChatAudio extends PinnedContainer { @@ -32,7 +32,7 @@ export class ChatAudio extends PinnedContainer {
this.wrapper.prepend(this.toggleEl);
$rootScope.$on('audio_play', (e) => {
rootScope.on('audio_play', (e) => {
const {doc, mid} = e.detail;
let title: string, subtitle: string;
@ -51,7 +51,7 @@ export class ChatAudio extends PinnedContainer { @@ -51,7 +51,7 @@ export class ChatAudio extends PinnedContainer {
this.toggle(false);
});
$rootScope.$on('audio_pause', () => {
rootScope.on('audio_pause', () => {
this.toggleEl.classList.remove('flip-icon');
});
}

10
src/components/chat/contextMenu.ts

@ -4,7 +4,7 @@ import appImManager from "../../lib/appManagers/appImManager"; @@ -4,7 +4,7 @@ import appImManager from "../../lib/appManagers/appImManager";
import appMessagesManager from "../../lib/appManagers/appMessagesManager";
import appPeersManager from "../../lib/appManagers/appPeersManager";
import appPollsManager, { Poll } from "../../lib/appManagers/appPollsManager";
import $rootScope from "../../lib/rootScope";
import rootScope from "../../lib/rootScope";
import { cancelEvent, cancelSelection, findUpClassName } from "../../helpers/dom";
import ButtonMenu, { ButtonMenuItemOptions } from "../buttonMenu";
import { attachContextMenuListener, openBtnMenu, positionMenu } from "../misc";
@ -58,7 +58,7 @@ export default class ChatContextMenu { @@ -58,7 +58,7 @@ export default class ChatContextMenu {
}
}
this.peerID = $rootScope.selectedPeerID;
this.peerID = rootScope.selectedPeerID;
//this.msgID = msgID;
this.target = e.target as HTMLElement;
@ -152,7 +152,7 @@ export default class ChatContextMenu { @@ -152,7 +152,7 @@ export default class ChatContextMenu {
const message = appMessagesManager.getMessage(this.msgID);
// for new layer
// return this.msgID > 0 && message._ != 'messageService' && appImManager.pinnedMsgID != this.msgID && (this.peerID > 0 || appChatsManager.hasRights(-this.peerID, 'pin'));
return this.msgID > 0 && message._ != 'messageService' && appImManager.pinnedMsgID != this.msgID && (this.peerID == $rootScope.myID || (this.peerID < 0 && appChatsManager.hasRights(-this.peerID, 'pin')));
return this.msgID > 0 && message._ != 'messageService' && appImManager.pinnedMsgID != this.msgID && (this.peerID == rootScope.myID || (this.peerID < 0 && appChatsManager.hasRights(-this.peerID, 'pin')));
}
}, {
icon: 'unpin',
@ -263,11 +263,11 @@ export default class ChatContextMenu { @@ -263,11 +263,11 @@ export default class ChatContextMenu {
};
private onPinClick = () => {
new PopupPinMessage($rootScope.selectedPeerID, this.msgID);
new PopupPinMessage(rootScope.selectedPeerID, this.msgID);
};
private onUnpinClick = () => {
new PopupPinMessage($rootScope.selectedPeerID, 0);
new PopupPinMessage(rootScope.selectedPeerID, 0);
};
private onRetractVote = () => {

18
src/components/chat/input.ts

@ -10,7 +10,7 @@ import apiManager from "../../lib/mtproto/mtprotoworker"; @@ -10,7 +10,7 @@ import apiManager from "../../lib/mtproto/mtprotoworker";
//import Recorder from '../opus-recorder/dist/recorder.min';
import opusDecodeController from "../../lib/opusDecodeController";
import { RichTextProcessor } from "../../lib/richtextprocessor";
import $rootScope from '../../lib/rootScope';
import rootScope from '../../lib/rootScope';
import { cancelEvent, findUpClassName, getRichValue, isInputEmpty, serializeNodes } from "../../helpers/dom";
import ButtonMenu, { ButtonMenuItemOptions } from '../buttonMenu';
import emoticonsDropdown from "../emoticonsDropdown";
@ -151,7 +151,7 @@ export class ChatInput { @@ -151,7 +151,7 @@ export class ChatInput {
this.updateSendBtn();
$rootScope.$on('peer_changed', (e) => {
rootScope.on('peer_changed', (e) => {
const peerID = e.detail;
const visible = this.attachMenuButtons.filter(button => {
@ -249,12 +249,12 @@ export class ChatInput { @@ -249,12 +249,12 @@ export class ChatInput {
if(!value.trim() && !serializeNodes(Array.from(this.messageInput.childNodes)).trim()) {
this.messageInput.innerHTML = '';
appMessagesManager.setTyping($rootScope.selectedPeerID, 'sendMessageCancelAction');
appMessagesManager.setTyping(rootScope.selectedPeerID, 'sendMessageCancelAction');
} else {
const time = Date.now();
if(time - this.lastTimeType >= 6000) {
this.lastTimeType = time;
appMessagesManager.setTyping($rootScope.selectedPeerID, 'sendMessageTypingAction');
appMessagesManager.setTyping(rootScope.selectedPeerID, 'sendMessageTypingAction');
}
}
@ -299,8 +299,8 @@ export class ChatInput { @@ -299,8 +299,8 @@ export class ChatInput {
}, false);
document.addEventListener('paste', (e) => {
const peerID = $rootScope.selectedPeerID;
if(!peerID || $rootScope.overlayIsActive || (peerID < 0 && !appChatsManager.hasRights(peerID, 'send', 'send_media'))) {
const peerID = rootScope.selectedPeerID;
if(!peerID || rootScope.overlayIsActive || (peerID < 0 && !appChatsManager.hasRights(peerID, 'send', 'send_media'))) {
return;
}
@ -341,7 +341,7 @@ export class ChatInput { @@ -341,7 +341,7 @@ export class ChatInput {
this.sendMessage();
}
} else {
if($rootScope.selectedPeerID < 0 && !appChatsManager.hasRights($rootScope.selectedPeerID, 'send', 'send_media')) {
if(rootScope.selectedPeerID < 0 && !appChatsManager.hasRights(rootScope.selectedPeerID, 'send', 'send_media')) {
toast(POSTING_MEDIA_NOT_ALLOWED);
return;
}
@ -544,9 +544,9 @@ export class ChatInput { @@ -544,9 +544,9 @@ export class ChatInput {
}
});
} else if(this.helperType == 'reply') {
appImManager.setPeer($rootScope.selectedPeerID, this.replyToMsgID);
appImManager.setPeer(rootScope.selectedPeerID, this.replyToMsgID);
} else if(this.helperType == 'edit') {
appImManager.setPeer($rootScope.selectedPeerID, this.editMsgID);
appImManager.setPeer(rootScope.selectedPeerID, this.editMsgID);
}
});
}

4
src/components/chat/search.ts

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
import appImManager from "../../lib/appManagers/appImManager";
import $rootScope from "../../lib/rootScope";
import rootScope from "../../lib/rootScope";
import { cancelEvent, whichChild, findUpTag } from "../../helpers/dom";
import AppSearch, { SearchGroup } from "../appSearch";
import PopupDatePicker from "../popupDatepicker";
@ -73,7 +73,7 @@ export class ChatSearch { @@ -73,7 +73,7 @@ export class ChatSearch {
this.selectResult(this.searchGroup.list.children[0] as HTMLElement);
}
});
this.appSearch.beginSearch($rootScope.selectedPeerID);
this.appSearch.beginSearch(rootScope.selectedPeerID);
//appImManager.topbar.parentElement.insertBefore(this.results, appImManager.bubblesContainer);
appImManager.bubblesContainer.append(this.results);

6
src/components/dialogsContextMenu.ts

@ -3,7 +3,7 @@ import appDialogsManager from "../lib/appManagers/appDialogsManager"; @@ -3,7 +3,7 @@ import appDialogsManager from "../lib/appManagers/appDialogsManager";
import appImManager from "../lib/appManagers/appImManager";
import appMessagesManager from "../lib/appManagers/appMessagesManager";
import appPeersManager from "../lib/appManagers/appPeersManager";
import $rootScope from "../lib/rootScope";
import rootScope from "../lib/rootScope";
import { findUpTag } from "../helpers/dom";
import { parseMenuButtonsTo, positionMenu, openBtnMenu } from "./misc";
import { PopupButton } from "./popup";
@ -166,7 +166,7 @@ export default class DialogsContextMenu { @@ -166,7 +166,7 @@ export default class DialogsContextMenu {
this.selectedID = +li.getAttribute('data-peerID');
const dialog = appMessagesManager.getDialogByPeerID(this.selectedID)[0];
const notOurDialog = dialog.peerID != $rootScope.myID;
const notOurDialog = dialog.peerID != rootScope.myID;
// archive button
if(notOurDialog) {
@ -231,7 +231,7 @@ export default class DialogsContextMenu { @@ -231,7 +231,7 @@ export default class DialogsContextMenu {
} else {
deleteButtonText = 'Delete';
//deleteButtonText = 'Delete chat';
this.peerType = this.selectedID == $rootScope.myID ? 'saved' : 'chat';
this.peerType = this.selectedID == rootScope.myID ? 'saved' : 'chat';
}
(this.buttons.delete.firstElementChild as HTMLElement).innerText = deleteButtonText;

6
src/components/emoticonsDropdown/index.ts

@ -2,7 +2,7 @@ import { isTouchSupported } from "../../helpers/touchSupport"; @@ -2,7 +2,7 @@ import { isTouchSupported } from "../../helpers/touchSupport";
import appChatsManager from "../../lib/appManagers/appChatsManager";
import appImManager from "../../lib/appManagers/appImManager";
import { MOUNT_CLASS_TO } from "../../lib/mtproto/mtproto_config";
import $rootScope from "../../lib/rootScope";
import rootScope from "../../lib/rootScope";
import { findUpClassName, findUpTag, whichChild } from "../../helpers/dom";
import animationIntersector from "../animationIntersector";
import { horizontalMenu } from "../horizontalMenu";
@ -157,7 +157,7 @@ export class EmoticonsDropdown { @@ -157,7 +157,7 @@ export class EmoticonsDropdown {
(this.tabsEl.children[1] as HTMLLIElement).click(); // set emoji tab
this.tabs[0].init(); // onTransitionEnd не вызовется, т.к. это первая открытая вкладка
$rootScope.$on('peer_changed', this.checkRights);
rootScope.on('peer_changed', this.checkRights);
this.checkRights();
}
@ -174,7 +174,7 @@ export class EmoticonsDropdown { @@ -174,7 +174,7 @@ export class EmoticonsDropdown {
};
public checkRights = () => {
const peerID = $rootScope.selectedPeerID;
const peerID = rootScope.selectedPeerID;
const children = this.tabsEl.children;
const tabsElements = Array.from(children) as HTMLElement[];

6
src/components/emoticonsDropdown/tabs/stickers.ts

@ -8,7 +8,7 @@ import appStickersManager from "../../../lib/appManagers/appStickersManager"; @@ -8,7 +8,7 @@ import appStickersManager from "../../../lib/appManagers/appStickersManager";
import lottieLoader from "../../../lib/lottieLoader";
import apiManager from "../../../lib/mtproto/mtprotoworker";
import { RichTextProcessor } from "../../../lib/richtextprocessor";
import $rootScope from "../../../lib/rootScope";
import rootScope from "../../../lib/rootScope";
import animationIntersector from "../../animationIntersector";
import { LazyLoadQueueRepeat } from "../../lazyLoadQueue";
import { putPreloader, renderImageFromUrl } from "../../misc";
@ -256,7 +256,7 @@ export default class StickersTab implements EmoticonsTab { @@ -256,7 +256,7 @@ export default class StickersTab implements EmoticonsTab {
}
}); */
$rootScope.$on('stickers_installed', (e) => {
rootScope.on('stickers_installed', (e) => {
const set: StickerSet.stickerSet = e.detail;
if(!this.stickerSets[set.id] && this.mounted) {
@ -264,7 +264,7 @@ export default class StickersTab implements EmoticonsTab { @@ -264,7 +264,7 @@ export default class StickersTab implements EmoticonsTab {
}
});
$rootScope.$on('stickers_deleted', (e) => {
rootScope.on('stickers_deleted', (e) => {
const set: StickerSet.stickerSet = e.detail;
if(this.stickerSets[set.id] && this.mounted) {

6
src/components/poll.ts

@ -4,7 +4,7 @@ import appImManager from "../lib/appManagers/appImManager"; @@ -4,7 +4,7 @@ import appImManager from "../lib/appManagers/appImManager";
import appPollsManager, { Poll, PollResults } from "../lib/appManagers/appPollsManager";
import serverTimeManager from "../lib/mtproto/serverTimeManager";
import { RichTextProcessor } from "../lib/richtextprocessor";
import $rootScope from "../lib/rootScope";
import rootScope from "../lib/rootScope";
import { cancelEvent, findUpClassName } from "../helpers/dom";
import { ripple } from "./ripple";
import appSidebarRight from "./sidebarRight";
@ -65,7 +65,7 @@ export const roundPercents = (percents: number[]) => { @@ -65,7 +65,7 @@ export const roundPercents = (percents: number[]) => {
};
const connectedPolls: {id: string, element: PollElement}[] = [];
$rootScope.$on('poll_update', (e) => {
rootScope.on('poll_update', (e) => {
const {poll, results} = e.detail as {poll: Poll, results: PollResults};
//console.log('poll_update', poll, results);
@ -78,7 +78,7 @@ $rootScope.$on('poll_update', (e) => { @@ -78,7 +78,7 @@ $rootScope.$on('poll_update', (e) => {
}
});
$rootScope.$on('peer_changed', () => {
rootScope.on('peer_changed', () => {
if(prevQuizHint) {
hideQuizHint(prevQuizHint, prevQuizHintOnHide, prevQuizHintTimeout);
}

6
src/components/popup.ts

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
import $rootScope from "../lib/rootScope";
import rootScope from "../lib/rootScope";
import { cancelEvent, findUpClassName } from "../helpers/dom";
import { ripple } from "./ripple";
@ -103,7 +103,7 @@ export class PopupElement { @@ -103,7 +103,7 @@ export class PopupElement {
document.body.append(this.element);
void this.element.offsetWidth; // reflow
this.element.classList.add('active');
$rootScope.overlayIsActive = true;
rootScope.overlayIsActive = true;
}
public destroy = () => {
@ -112,7 +112,7 @@ export class PopupElement { @@ -112,7 +112,7 @@ export class PopupElement {
window.removeEventListener('keydown', this._onKeyDown, {capture: true});
if(this.closeBtn) this.closeBtn.removeEventListener('click', this.destroy);
$rootScope.overlayIsActive = false;
rootScope.overlayIsActive = false;
setTimeout(() => {
this.element.remove();

6
src/components/popupCreatePoll.ts

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
import appMessagesManager from "../lib/appManagers/appMessagesManager";
import appPeersManager from "../lib/appManagers/appPeersManager";
import appPollsManager, { Poll } from "../lib/appManagers/appPollsManager";
import $rootScope from "../lib/rootScope";
import rootScope from "../lib/rootScope";
import { cancelEvent, findUpTag, getRichValue, isInputEmpty, whichChild } from "../helpers/dom";
import CheckboxField from "./checkbox";
import InputField from "./inputField";
@ -57,7 +57,7 @@ export default class PopupCreatePoll extends PopupElement { @@ -57,7 +57,7 @@ export default class PopupCreatePoll extends PopupElement {
settingsCaption.classList.add('caption');
settingsCaption.innerText = 'Settings';
const peerID = $rootScope.selectedPeerID;
const peerID = rootScope.selectedPeerID;
if(!appPeersManager.isBroadcast(peerID)) {
this.anonymousCheckboxField = CheckboxField('Anonymous Voting', 'anonymous');
@ -213,7 +213,7 @@ export default class PopupCreatePoll extends PopupElement { @@ -213,7 +213,7 @@ export default class PopupCreatePoll extends PopupElement {
//console.log('Will try to create poll:', inputMediaPoll);
appMessagesManager.sendOther($rootScope.selectedPeerID, inputMediaPoll);
appMessagesManager.sendOther(rootScope.selectedPeerID, inputMediaPoll);
};
onInput = (e: Event) => {

8
src/components/popupDeleteMessages.ts

@ -1,13 +1,13 @@ @@ -1,13 +1,13 @@
import appChatsManager from "../lib/appManagers/appChatsManager";
import appMessagesManager from "../lib/appManagers/appMessagesManager";
import appPeersManager from "../lib/appManagers/appPeersManager";
import $rootScope from "../lib/rootScope";
import rootScope from "../lib/rootScope";
import { PopupButton } from "./popup";
import PopupPeer from "./popupPeer";
export default class PopupDeleteMessages {
constructor(mids: number[], onConfirm?: () => void) {
const peerID = $rootScope.selectedPeerID;
const peerID = rootScope.selectedPeerID;
const firstName = appPeersManager.getPeerTitle(peerID, false, true);
mids = mids.slice();
@ -20,7 +20,7 @@ export default class PopupDeleteMessages { @@ -20,7 +20,7 @@ export default class PopupDeleteMessages {
title = `Delete ${mids.length == 1 ? '' : mids.length + ' '}Message${mids.length == 1 ? '' : 's'}?`;
description = `Are you sure you want to delete ${mids.length == 1 ? 'this message' : 'these messages'}?`;
if(peerID == $rootScope.myID) {
if(peerID == rootScope.myID) {
buttons = [{
text: 'DELETE',
isDanger: true,
@ -46,7 +46,7 @@ export default class PopupDeleteMessages { @@ -46,7 +46,7 @@ export default class PopupDeleteMessages {
if(chat._ == 'chat') {
const canRevoke = hasRights ? mids.slice() : mids.filter(mid => {
const message = appMessagesManager.getMessage(mid);
return message.fromID == $rootScope.myID;
return message.fromID == rootScope.myID;
});
if(canRevoke.length) {

11
src/components/sidebarLeft/index.ts

@ -7,11 +7,11 @@ import appPeersManager from "../../lib/appManagers/appPeersManager"; @@ -7,11 +7,11 @@ import appPeersManager from "../../lib/appManagers/appPeersManager";
import appStateManager from "../../lib/appManagers/appStateManager";
import appUsersManager from "../../lib/appManagers/appUsersManager";
import { MOUNT_CLASS_TO } from "../../lib/mtproto/mtproto_config";
import $rootScope from "../../lib/rootScope";
import rootScope from "../../lib/rootScope";
import { findUpClassName, findUpTag } from "../../helpers/dom";
import AppSearch, { SearchGroup } from "../appSearch";
import "../avatar";
import { parseMenuButtonsTo } from "../misc";
import { parseMenuButtonsTo, putPreloader } from "../misc";
import { ScrollableX } from "../scrollable";
import SearchInput from "../searchInput";
import SidebarSlider from "../slider";
@ -133,7 +133,7 @@ export class AppSidebarLeft extends SidebarSlider { @@ -133,7 +133,7 @@ export class AppSidebarLeft extends SidebarSlider {
[AppSidebarLeft.SLIDERITEMSIDS.newGroup]: newGroupTab,
[AppSidebarLeft.SLIDERITEMSIDS.settings]: settingsTab,
[AppSidebarLeft.SLIDERITEMSIDS.editProfile]: editProfileTab,
[AppSidebarLeft.SLIDERITEMSIDS.chatFolders]: this.chatFoldersTab = new AppChatFoldersTab(appMessagesManager, appPeersManager, this, apiManagerProxy, $rootScope),
[AppSidebarLeft.SLIDERITEMSIDS.chatFolders]: this.chatFoldersTab = new AppChatFoldersTab(appMessagesManager, appPeersManager, this, apiManagerProxy, rootScope),
[AppSidebarLeft.SLIDERITEMSIDS.editFolder]: editFolderTab,
[AppSidebarLeft.SLIDERITEMSIDS.includedChats]: includedChatsTab,
});
@ -141,7 +141,8 @@ export class AppSidebarLeft extends SidebarSlider { @@ -141,7 +141,8 @@ export class AppSidebarLeft extends SidebarSlider {
//this._selectTab(0); // make first tab as default
this.searchInput = new SearchInput('Telegram Search');
this.sidebarEl.querySelector('.item-main .sidebar-header').append(this.searchInput.container);
const sidebarHeader = this.sidebarEl.querySelector('.item-main .sidebar-header');
sidebarHeader.append(this.searchInput.container);
this.toolsBtn = this.sidebarEl.querySelector('.sidebar-tools-button') as HTMLButtonElement;
this.backBtn = this.sidebarEl.querySelector('.sidebar-back-button') as HTMLButtonElement;
@ -321,7 +322,7 @@ export class AppSidebarLeft extends SidebarSlider { @@ -321,7 +322,7 @@ export class AppSidebarLeft extends SidebarSlider {
});
});
$rootScope.$on('dialogs_archived_unread', (e) => {
rootScope.on('dialogs_archived_unread', (e) => {
this.archivedCount.innerText = '' + formatNumber(e.detail.count, 1);
this.archivedCount.classList.toggle('hide', !e.detail.count);
});

10
src/components/sidebarLeft/tabs/chatFolders.ts

@ -10,7 +10,7 @@ import type { MyDialogFilter } from "../../../lib/storages/filters"; @@ -10,7 +10,7 @@ import type { MyDialogFilter } from "../../../lib/storages/filters";
import type { AppPeersManager } from "../../../lib/appManagers/appPeersManager";
import type { AppSidebarLeft } from "..";
import type { DialogFilterSuggested, DialogFilter } from "../../../layer";
import type _$rootScope from "../../../lib/rootScope";
import type _rootScope from "../../../lib/rootScope";
export default class AppChatFoldersTab implements SliderTab {
public container: HTMLElement;
@ -22,7 +22,7 @@ export default class AppChatFoldersTab implements SliderTab { @@ -22,7 +22,7 @@ export default class AppChatFoldersTab implements SliderTab {
private filtersRendered: {[filterID: number]: HTMLElement} = {};
constructor(private appMessagesManager: AppMessagesManager, private appPeersManager: AppPeersManager, private appSidebarLeft: AppSidebarLeft, private apiManager: ApiManagerProxy, private $rootScope: typeof _$rootScope) {
constructor(private appMessagesManager: AppMessagesManager, private appPeersManager: AppPeersManager, private appSidebarLeft: AppSidebarLeft, private apiManager: ApiManagerProxy, private rootScope: typeof _rootScope) {
}
@ -127,7 +127,7 @@ export default class AppChatFoldersTab implements SliderTab { @@ -127,7 +127,7 @@ export default class AppChatFoldersTab implements SliderTab {
}
});
this.$rootScope.$on('filter_update', (e) => {
this.rootScope.on('filter_update', (e) => {
const filter = e.detail;
if(this.filtersRendered.hasOwnProperty(filter.id)) {
this.renderFolder(filter, null, this.filtersRendered[filter.id]);
@ -138,7 +138,7 @@ export default class AppChatFoldersTab implements SliderTab { @@ -138,7 +138,7 @@ export default class AppChatFoldersTab implements SliderTab {
this.getSuggestedFilters();
});
this.$rootScope.$on('filter_delete', (e) => {
this.rootScope.on('filter_delete', (e) => {
const filter = e.detail;
if(this.filtersRendered.hasOwnProperty(filter.id)) {
/* for(const suggested of this.suggestedFilters) {
@ -153,7 +153,7 @@ export default class AppChatFoldersTab implements SliderTab { @@ -153,7 +153,7 @@ export default class AppChatFoldersTab implements SliderTab {
}
});
this.$rootScope.$on('filter_order', (e) => {
this.rootScope.on('filter_order', (e) => {
const order = e.detail;
order.forEach((filterID, idx) => {
const div = this.filtersRendered[filterID];

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

@ -4,7 +4,7 @@ import appDialogsManager from "../../../lib/appManagers/appDialogsManager"; @@ -4,7 +4,7 @@ import appDialogsManager from "../../../lib/appManagers/appDialogsManager";
import appUsersManager from "../../../lib/appManagers/appUsersManager";
import appPhotosManager from "../../../lib/appManagers/appPhotosManager";
import appSidebarLeft, { AppSidebarLeft } from "..";
import $rootScope from "../../../lib/rootScope";
import rootScope from "../../../lib/rootScope";
import SearchInput from "../../searchInput";
// TODO: поиск по людям глобальный, если не нашло в контактах никого
@ -70,10 +70,10 @@ export default class AppContactsTab implements SliderTab { @@ -70,10 +70,10 @@ export default class AppContactsTab implements SliderTab {
const contacts = [..._contacts];
if(!query) {
contacts.findAndSplice(u => u == $rootScope.myID);
contacts.findAndSplice(u => u == rootScope.myID);
}
/* if(query && 'saved messages'.includes(query.toLowerCase())) {
contacts.unshift($rootScope.myID);
contacts.unshift(rootScope.myID);
} */
let sorted = contacts

4
src/components/sidebarLeft/tabs/editProfile.ts

@ -5,7 +5,7 @@ import appProfileManager from "../../../lib/appManagers/appProfileManager"; @@ -5,7 +5,7 @@ import appProfileManager from "../../../lib/appManagers/appProfileManager";
import appUsersManager from "../../../lib/appManagers/appUsersManager";
import apiManager from "../../../lib/mtproto/mtprotoworker";
import RichTextProcessor from "../../../lib/richtextprocessor";
import $rootScope from "../../../lib/rootScope";
import rootScope from "../../../lib/rootScope";
import AvatarElement from "../../avatar";
import InputField from "../../inputField";
import PopupAvatar from "../../popupAvatar";
@ -225,7 +225,7 @@ export default class AppEditProfileTab implements SliderTab { @@ -225,7 +225,7 @@ export default class AppEditProfileTab implements SliderTab {
}
});
this.avatarElem.setAttribute('peer', '' + $rootScope.myID);
this.avatarElem.setAttribute('peer', '' + rootScope.myID);
if(!this.avatarElem.parentElement) {
this.canvas.parentElement.append(this.avatarElem);
}

4
src/components/sidebarLeft/tabs/includedChats.ts

@ -5,7 +5,7 @@ import appDialogsManager from "../../../lib/appManagers/appDialogsManager"; @@ -5,7 +5,7 @@ import appDialogsManager from "../../../lib/appManagers/appDialogsManager";
import appPeersManager from "../../../lib/appManagers/appPeersManager";
import appUsersManager from "../../../lib/appManagers/appUsersManager";
import { MyDialogFilter as DialogFilter } from "../../../lib/storages/filters";
import $rootScope from "../../../lib/rootScope";
import rootScope from "../../../lib/rootScope";
import { copy } from "../../../helpers/object";
export default class AppIncludedChatsTab implements SliderTab {
@ -109,7 +109,7 @@ export default class AppIncludedChatsTab implements SliderTab { @@ -109,7 +109,7 @@ export default class AppIncludedChatsTab implements SliderTab {
let subtitle = '';
if(peerID > 0) {
if(peerID == $rootScope.myID) {
if(peerID == rootScope.myID) {
subtitle = 'Chat with yourself';
} else if(appUsersManager.isBot(peerID)) {
subtitle = 'Bot';

4
src/components/sidebarLeft/tabs/settings.ts

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
import { SliderTab } from "../../slider";
import AvatarElement from "../../avatar";
import { parseMenuButtonsTo } from "../../misc";
//import $rootScope from "../../lib/rootScope";
//import rootScope from "../../lib/rootScope";
import apiManager from "../../../lib/mtproto/mtprotoworker";
import appSidebarLeft, { AppSidebarLeft } from "..";
import appUsersManager from "../../../lib/appManagers/appUsersManager";
@ -26,7 +26,7 @@ export default class AppSettingsTab implements SliderTab { @@ -26,7 +26,7 @@ export default class AppSettingsTab implements SliderTab {
constructor() {
parseMenuButtonsTo(this.buttons, this.container.querySelector('.profile-buttons').children);
/* $rootScope.$on('user_auth', (e) => {
/* rootScope.$on('user_auth', (e) => {
this.fillElements();
}); */

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

@ -7,7 +7,7 @@ import appProfileManager from "../../../lib/appManagers/appProfileManager"; @@ -7,7 +7,7 @@ import appProfileManager from "../../../lib/appManagers/appProfileManager";
import appUsersManager from "../../../lib/appManagers/appUsersManager";
import { logger } from "../../../lib/logger";
import { RichTextProcessor } from "../../../lib/richtextprocessor";
import $rootScope from "../../../lib/rootScope";
import rootScope from "../../../lib/rootScope";
import AppMediaViewer from "../../appMediaViewer";
import AvatarElement from "../../avatar";
import { horizontalMenu } from "../../horizontalMenu";
@ -408,7 +408,7 @@ export default class AppSharedMediaTab implements SliderTab { @@ -408,7 +408,7 @@ export default class AppSharedMediaTab implements SliderTab {
const load = () => appPhotosManager.preloadPhoto(isPhoto ? media.id : media, appPhotosManager.choosePhotoSize(media, 200, 200))
.then(() => {
if($rootScope.selectedPeerID != peerID) {
if(rootScope.selectedPeerID != peerID) {
this.log.warn('peer changed');
return;
}
@ -551,7 +551,7 @@ export default class AppSharedMediaTab implements SliderTab { @@ -551,7 +551,7 @@ export default class AppSharedMediaTab implements SliderTab {
if(webpage.photo) {
let load = () => appPhotosManager.preloadPhoto(webpage.photo.id, appPhotosManager.choosePhotoSize(webpage.photo, 60, 60))
.then(() => {
if($rootScope.selectedPeerID != peerID) {
if(rootScope.selectedPeerID != peerID) {
this.log.warn('peer changed');
return;
}
@ -701,7 +701,7 @@ export default class AppSharedMediaTab implements SliderTab { @@ -701,7 +701,7 @@ export default class AppSharedMediaTab implements SliderTab {
this.log(logStr + 'search house of glass', type, value);
if($rootScope.selectedPeerID != peerID) {
if(rootScope.selectedPeerID != peerID) {
this.log.warn('peer changed');
return;
}
@ -826,14 +826,14 @@ export default class AppSharedMediaTab implements SliderTab { @@ -826,14 +826,14 @@ export default class AppSharedMediaTab implements SliderTab {
}
public fillProfileElements() {
let peerID = this.peerID = $rootScope.selectedPeerID;
let peerID = this.peerID = rootScope.selectedPeerID;
this.cleanupHTML();
this.profileElements.avatar.setAttribute('peer', '' + peerID);
// username
if(peerID != $rootScope.myID) {
if(peerID != rootScope.myID) {
let username = appPeersManager.getPeerUsername(peerID);
if(username) {
setText(appPeersManager.getPeerUsername(peerID), this.profileElements.username);
@ -859,7 +859,7 @@ export default class AppSharedMediaTab implements SliderTab { @@ -859,7 +859,7 @@ export default class AppSharedMediaTab implements SliderTab {
//membersLi.style.display = 'none';
let user = appUsersManager.getUser(peerID);
if(user.phone && peerID != $rootScope.myID) {
if(user.phone && peerID != rootScope.myID) {
setText(user.rPhone, this.profileElements.phone);
}
@ -869,7 +869,7 @@ export default class AppSharedMediaTab implements SliderTab { @@ -869,7 +869,7 @@ export default class AppSharedMediaTab implements SliderTab {
return;
}
if(userFull.rAbout && peerID != $rootScope.myID) {
if(userFull.rAbout && peerID != rootScope.myID) {
setText(userFull.rAbout, this.profileElements.bio);
}

6
src/lib/appManagers/AppInlineBotsManager.ts

@ -102,7 +102,7 @@ export class AppInlineBotsManager { @@ -102,7 +102,7 @@ export class AppInlineBotsManager {
}
ConfigStorage.set({inline_bots_popular: result})
$rootScope.$broadcast('inline_bots_popular')
rootScope.$broadcast('inline_bots_popular')
})
}
@ -217,7 +217,7 @@ export class AppInlineBotsManager { @@ -217,7 +217,7 @@ export class AppInlineBotsManager {
var setHash = {}
setHash['inline_switch_pm' + botID] = {peer: peerString, time: tsNow()}
Storage.set(setHash)
$rootScope.$broadcast('history_focus', {peerString: AppPeersManager.getPeerString(botID)})
rootScope.$broadcast('history_focus', {peerString: AppPeersManager.getPeerString(botID)})
AppMessagesManager.startBot(botID, 0, startParam)
}
@ -239,7 +239,7 @@ export class AppInlineBotsManager { @@ -239,7 +239,7 @@ export class AppInlineBotsManager {
}
function switchInlineQuery (botID, toPeerString, query) {
$rootScope.$broadcast('history_focus', {
rootScope.$broadcast('history_focus', {
peerString: toPeerString,
attachment: {
_: 'inline_query',

16
src/lib/appManagers/apiUpdatesManager.ts

@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
import { logger, LogLevels } from '../logger';
import apiManager from '../mtproto/mtprotoworker';
import { MOUNT_CLASS_TO } from '../mtproto/mtproto_config';
import $rootScope from '../rootScope';
import rootScope from '../rootScope';
//import networkerFactory from '../mtproto/networkerFactory';
import appChatsManager from "./appChatsManager";
import appPeersManager from "./appPeersManager";
@ -151,10 +151,10 @@ export class ApiUpdatesManager { @@ -151,10 +151,10 @@ export class ApiUpdatesManager {
case 'updateShortChatMessage': {
this.log('updateShortMessage | updateShortChatMessage', {...updateMessage});
const isOut = updateMessage.pFlags.out;
const fromID = updateMessage.from_id || (isOut ? $rootScope.myID : updateMessage.user_id);
const fromID = updateMessage.from_id || (isOut ? rootScope.myID : updateMessage.user_id);
const toID = updateMessage.chat_id
? -updateMessage.chat_id
: (updateMessage.user_id || $rootScope.myID);
: (updateMessage.user_id || rootScope.myID);
this.processUpdate({
_: 'updateNewMessage',
@ -217,7 +217,7 @@ export class ApiUpdatesManager { @@ -217,7 +217,7 @@ export class ApiUpdatesManager {
updatesState.date = differenceResult.date;
updatesState.seq = differenceResult.seq;
updatesState.syncLoading = false;
$rootScope.$broadcast('stateSynchronized');
rootScope.broadcast('stateSynchronized');
return false;
}
@ -266,7 +266,7 @@ export class ApiUpdatesManager { @@ -266,7 +266,7 @@ export class ApiUpdatesManager {
this.getDifference();
} else {
// this.log('finished get diff')
$rootScope.$broadcast('stateSynchronized');
rootScope.broadcast('stateSynchronized');
updatesState.syncLoading = false;
}
}, () => {
@ -299,7 +299,7 @@ export class ApiUpdatesManager { @@ -299,7 +299,7 @@ export class ApiUpdatesManager {
if(differenceResult._ == 'updates.channelDifferenceEmpty') {
this.log('apply channel empty diff', differenceResult);
channelState.syncLoading = false;
$rootScope.$broadcast('stateSynchronized');
rootScope.broadcast('stateSynchronized');
return false;
}
@ -337,7 +337,7 @@ export class ApiUpdatesManager { @@ -337,7 +337,7 @@ export class ApiUpdatesManager {
this.getChannelDifference(channelID);
} else {
this.log('finished channel get diff');
$rootScope.$broadcast('stateSynchronized');
rootScope.broadcast('stateSynchronized');
channelState.syncLoading = false;
}
}, () => {
@ -519,7 +519,7 @@ export class ApiUpdatesManager { @@ -519,7 +519,7 @@ export class ApiUpdatesManager {
}
public saveUpdate(update: any) {
$rootScope.$broadcast('apiUpdate', update);
rootScope.broadcast('apiUpdate', update);
}
public attach() {

10
src/lib/appManagers/appChatsManager.ts

@ -4,7 +4,7 @@ import { ChatAdminRights, ChatBannedRights, ChatFull, ChatParticipants, InputCha @@ -4,7 +4,7 @@ import { ChatAdminRights, ChatBannedRights, ChatFull, ChatParticipants, InputCha
import apiManager from '../mtproto/mtprotoworker';
import { MOUNT_CLASS_TO } from "../mtproto/mtproto_config";
import { RichTextProcessor } from "../richtextprocessor";
import $rootScope from "../rootScope";
import rootScope from "../rootScope";
import apiUpdatesManager from "./apiUpdatesManager";
import appMessagesManager from "./appMessagesManager";
import appProfileManager from "./appProfileManager";
@ -74,14 +74,14 @@ export class AppChatsManager { @@ -74,14 +74,14 @@ export class AppChatsManager {
public megagroupOnlines: {[id: number]: {timestamp: number, onlines: number}} = {};
constructor() {
$rootScope.$on('apiUpdate', (e) => {
rootScope.on('apiUpdate', (e) => {
// console.log('on apiUpdate', update)
const update = e.detail;
switch(update._) {
case 'updateChannel':
const channelID = update.channel_id;
//console.log('updateChannel:', update);
$rootScope.$broadcast('channel_settings', {channelID: channelID});
rootScope.broadcast('channel_settings', {channelID: channelID});
break;
}
});
@ -143,7 +143,7 @@ export class AppChatsManager { @@ -143,7 +143,7 @@ export class AppChatsManager {
}
safeReplaceObject(oldChat, chat);
$rootScope.$broadcast('chat_update', chat.id);
rootScope.broadcast('chat_update', chat.id);
}
if(this.cachedPhotoLocations[chat.id] !== undefined) {
@ -152,7 +152,7 @@ export class AppChatsManager { @@ -152,7 +152,7 @@ export class AppChatsManager {
}
if(changedPhoto) {
$rootScope.$broadcast('avatar_update', -chat.id);
rootScope.broadcast('avatar_update', -chat.id);
}
}

96
src/lib/appManagers/appDialogsManager.ts

@ -12,7 +12,7 @@ import { isTouchSupported } from "../../helpers/touchSupport"; @@ -12,7 +12,7 @@ import { isTouchSupported } from "../../helpers/touchSupport";
import { isSafari } from "../../helpers/userAgent";
import { logger, LogLevels } from "../logger";
import { RichTextProcessor } from "../richtextprocessor";
import $rootScope from "../rootScope";
import rootScope from "../rootScope";
import { findUpClassName, positionElementByIndex } from "../../helpers/dom";
import appImManager, { AppImManager } from "./appImManager";
import appMessagesManager, { Dialog } from "./appMessagesManager";
@ -21,6 +21,9 @@ import appPeersManager from './appPeersManager'; @@ -21,6 +21,9 @@ import appPeersManager from './appPeersManager';
import appStateManager from "./appStateManager";
import appUsersManager, { User } from "./appUsersManager";
import { MOUNT_CLASS_TO } from "../mtproto/mtproto_config";
import Button from "../../components/button";
import SetTransition from "../../components/singleTransition";
import AppStorage from '../storage';
type DialogDom = {
avatarEl: AvatarElement,
@ -94,7 +97,11 @@ export class AppDialogsManager { @@ -94,7 +97,11 @@ export class AppDialogsManager {
this.folders.menuScrollContainer = this.folders.menu.parentElement;
this.scroll = this._scroll = new Scrollable(this.chatsContainer, 'CL', 500);
const bottomPart = document.createElement('div');
bottomPart.classList.add('connection-status-bottom');
bottomPart.append(this.folders.container);
this.scroll = this._scroll = new Scrollable(bottomPart, 'CL', 500);
this.scroll.onScrolledTop = this.onChatsScrollTop;
this.scroll.onScrolledBottom = this.onChatsScroll;
this.scroll.setVirtualContainer(this.chatList);
@ -140,13 +147,13 @@ export class AppDialogsManager { @@ -140,13 +147,13 @@ export class AppDialogsManager {
(window as any).addElement = add;
}
$rootScope.$on('user_update', (e) => {
rootScope.on('user_update', (e) => {
const userID = e.detail;
const user = appUsersManager.getUser(userID);
const dialog = appMessagesManager.getDialogByPeerID(user.id)[0];
//console.log('updating user:', user, dialog);
if(dialog && !appUsersManager.isBot(dialog.peerID) && dialog.peerID != $rootScope.myID) {
if(dialog && !appUsersManager.isBot(dialog.peerID) && dialog.peerID != rootScope.myID) {
const online = user.status?._ == 'userStatusOnline';
const dom = this.getDialogDom(dialog.peerID);
@ -155,12 +162,12 @@ export class AppDialogsManager { @@ -155,12 +162,12 @@ export class AppDialogsManager {
}
}
if($rootScope.selectedPeerID == user.id) {
if(rootScope.selectedPeerID == user.id) {
appImManager.setPeerStatus();
}
});
/* $rootScope.$on('dialog_top', (e) => {
/* rootScope.$on('dialog_top', (e) => {
const dialog = e.detail;
this.setLastMessage(dialog);
@ -169,7 +176,7 @@ export class AppDialogsManager { @@ -169,7 +176,7 @@ export class AppDialogsManager {
this.setFiltersUnreadCount();
}); */
$rootScope.$on('dialog_flush', (e) => {
rootScope.on('dialog_flush', (e) => {
const peerID: number = e.detail.peerID;
const dialog = appMessagesManager.getDialogByPeerID(peerID)[0];
if(dialog) {
@ -179,7 +186,7 @@ export class AppDialogsManager { @@ -179,7 +186,7 @@ export class AppDialogsManager {
}
});
$rootScope.$on('dialogs_multiupdate', (e) => {
rootScope.on('dialogs_multiupdate', (e) => {
const dialogs = e.detail;
for(const id in dialogs) {
@ -191,7 +198,7 @@ export class AppDialogsManager { @@ -191,7 +198,7 @@ export class AppDialogsManager {
this.setFiltersUnreadCount();
});
$rootScope.$on('dialog_drop', (e) => {
rootScope.on('dialog_drop', (e) => {
const {peerID, dialog} = e.detail;
const dom = this.getDialogDom(peerID);
@ -203,14 +210,14 @@ export class AppDialogsManager { @@ -203,14 +210,14 @@ export class AppDialogsManager {
this.setFiltersUnreadCount();
});
$rootScope.$on('dialog_unread', (e) => {
rootScope.on('dialog_unread', (e) => {
const info = e.detail;
const dialog = appMessagesManager.getDialogByPeerID(info.peerID)[0];
if(dialog) {
this.setUnreadMessages(dialog);
if(dialog.peerID == $rootScope.selectedPeerID) {
if(dialog.peerID == rootScope.selectedPeerID) {
appImManager.updateUnreadByDialog(dialog);
}
@ -219,14 +226,14 @@ export class AppDialogsManager { @@ -219,14 +226,14 @@ export class AppDialogsManager {
}
});
$rootScope.$on('dialog_notify_settings', e => {
rootScope.on('dialog_notify_settings', e => {
const dialog = appMessagesManager.getDialogByPeerID(e.detail)[0];
if(dialog) {
this.setUnreadMessages(dialog); // возможно это не нужно, но нужно менять is-muted
}
});
$rootScope.$on('peer_changed', (e) => {
rootScope.on('peer_changed', (e) => {
let peerID = e.detail;
let lastPeerID = this.lastActiveListElement && +this.lastActiveListElement.getAttribute('data-peerID');
@ -244,7 +251,7 @@ export class AppDialogsManager { @@ -244,7 +251,7 @@ export class AppDialogsManager {
}
});
$rootScope.$on('filter_update', (e) => {
rootScope.on('filter_update', (e) => {
const filter: DialogFilter = e.detail;
if(!this.filtersRendered[filter.id]) {
this.addFilter(filter);
@ -264,7 +271,7 @@ export class AppDialogsManager { @@ -264,7 +271,7 @@ export class AppDialogsManager {
elements.title.innerHTML = RichTextProcessor.wrapEmojiText(filter.title);
});
$rootScope.$on('filter_delete', (e) => {
rootScope.on('filter_delete', (e) => {
const filter: DialogFilter = e.detail;
const elements = this.filtersRendered[filter.id];
if(!elements) return;
@ -284,7 +291,7 @@ export class AppDialogsManager { @@ -284,7 +291,7 @@ export class AppDialogsManager {
}
});
$rootScope.$on('filter_order', (e) => {
rootScope.on('filter_order', (e) => {
const order = e.detail;
const containerToAppend = this.folders.menu.firstElementChild as HTMLUListElement;
@ -303,7 +310,7 @@ export class AppDialogsManager { @@ -303,7 +310,7 @@ export class AppDialogsManager {
});
const foldersScrollable = new ScrollableX(this.folders.menuScrollContainer);
this.chatsContainer.prepend(this.folders.menuScrollContainer);
bottomPart.prepend(this.folders.menuScrollContainer);
const selectTab = horizontalMenu(this.folders.menu, this.folders.container, (id, tabContent) => {
/* if(id != 0) {
id += 1;
@ -346,6 +353,49 @@ export class AppDialogsManager { @@ -346,6 +353,49 @@ export class AppDialogsManager {
});
});
const statusDiv = document.createElement('div');
statusDiv.classList.add('connection-status');
const networkButton = Button('btn-primary bg-warning connection-status-button');
networkButton.innerText = 'Waiting for network...';
putPreloader(networkButton);
statusDiv.append(networkButton);
this.chatsContainer.append(statusDiv, bottomPart);
rootScope.on('connection_status_change', e => {
const status = e.detail;
console.log(status);
setConnectionStatus();
});
const setConnectionStatus = () => {
AppStorage.get<number>('dc').then(baseDcID => {
if(setFirstConnectionTimeout) {
clearTimeout(setFirstConnectionTimeout);
setFirstConnectionTimeout = 0;
}
const status = rootScope.connectionStatus['NET-' + baseDcID];
SetTransition(statusDiv, 'is-not-connected', !status?.online, 200);
});
};
let setFirstConnectionTimeout = window.setTimeout(setConnectionStatus, 2e3);
/* let bool = true;
document.addEventListener('dblclick', () => {
rootScope.broadcast('connection_status_change', {
dcID: 5,
isFileDownload: false,
isFileNetworker: false,
isFileUpload: false,
name: "NET-5",
online: bool = !bool,
_: "networkerStatus"
});
}); */
/* const mutationObserver = new MutationObserver((mutationList, observer) => {
});
@ -754,7 +804,7 @@ export class AppDialogsManager { @@ -754,7 +804,7 @@ export class AppDialogsManager {
const senderBold = document.createElement('b');
let str = '';
if(sender.id == $rootScope.myID) {
if(sender.id == rootScope.myID) {
str = 'You';
} else {
//str = sender.first_name || sender.last_name || sender.username;
@ -808,7 +858,7 @@ export class AppDialogsManager { @@ -808,7 +858,7 @@ export class AppDialogsManager {
const lastMessage = appMessagesManager.getMessage(dialog.top_message);
if(lastMessage._ != 'messageEmpty' && !lastMessage.deleted &&
lastMessage.fromID == $rootScope.myID && lastMessage.peerID != $rootScope.myID/* &&
lastMessage.fromID == rootScope.myID && lastMessage.peerID != rootScope.myID/* &&
dialog.read_outbox_max_id */) { // maybe comment, 06.20.2020
const outgoing = (lastMessage.pFlags && lastMessage.pFlags.unread)
/* && dialog.read_outbox_max_id != 0 */; // maybe uncomment, 31.01.2020
@ -851,7 +901,7 @@ export class AppDialogsManager { @@ -851,7 +901,7 @@ export class AppDialogsManager {
this.accumulateArchivedTimeout = 0;
const dialogs = appMessagesManager.dialogsStorage.getFolder(1);
const sum = dialogs.reduce((acc, dialog) => acc + dialog.unread_count, 0);
$rootScope.$broadcast('dialogs_archived_unread', {count: sum});
rootScope.broadcast('dialogs_archived_unread', {count: sum});
}, 0);
}
@ -906,7 +956,7 @@ export class AppDialogsManager { @@ -906,7 +956,7 @@ export class AppDialogsManager {
avatarEl.setAttribute('peer', '' + peerID);
avatarEl.classList.add('dialog-avatar');
if(drawStatus && peerID != $rootScope.myID && dialog.peer) {
if(drawStatus && peerID != rootScope.myID && dialog.peer) {
const peer = dialog.peer;
switch(peer._) {
@ -932,7 +982,7 @@ export class AppDialogsManager { @@ -932,7 +982,7 @@ export class AppDialogsManager {
const titleSpan = document.createElement('span');
if(peerID == $rootScope.myID && meAsSaved) {
if(peerID == rootScope.myID && meAsSaved) {
title = onlyFirstName ? 'Saved' : 'Saved Messages';
}
@ -1037,7 +1087,7 @@ export class AppDialogsManager { @@ -1037,7 +1087,7 @@ export class AppDialogsManager {
this.doms[dialog.peerID] = dom;
if($rootScope.selectedPeerID == peerID) {
if(rootScope.selectedPeerID == peerID) {
li.classList.add('active');
this.lastActiveListElement = li;
}

4
src/lib/appManagers/appDownloadManager.ts

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
import $rootScope from "../rootScope";
import rootScope from "../rootScope";
import apiManager from "../mtproto/mtprotoworker";
import { deferredPromise, CancellablePromise } from "../../helpers/cancellablePromise";
import type { DownloadOptions } from "../mtproto/apiFileManager";
@ -30,7 +30,7 @@ export class AppDownloadManager { @@ -30,7 +30,7 @@ export class AppDownloadManager {
private uploadID = 0;
constructor() {
$rootScope.$on('download_progress', (e) => {
rootScope.on('download_progress', (e) => {
const details = e.detail as {done: number, fileName: string, total: number, offset: number};
this.progress[details.fileName] = details;

46
src/lib/appManagers/appImManager.ts

@ -39,7 +39,7 @@ import { logger, LogLevels } from "../logger"; @@ -39,7 +39,7 @@ import { logger, LogLevels } from "../logger";
import apiManager from '../mtproto/mtprotoworker';
import { MOUNT_CLASS_TO } from '../mtproto/mtproto_config';
import { RichTextProcessor } from "../richtextprocessor";
import $rootScope from '../rootScope';
import rootScope from '../rootScope';
import { cancelEvent, findUpClassName, findUpTag, placeCaretAtEnd, whichChild } from "../../helpers/dom";
import apiUpdatesManager from './apiUpdatesManager';
import appChatsManager, { Channel, Chat } from "./appChatsManager";
@ -163,7 +163,7 @@ export class AppImManager { @@ -163,7 +163,7 @@ export class AppImManager {
public hideRightSidebar = false;
get myID() {
return $rootScope.myID;
return rootScope.myID;
}
constructor() {
@ -230,7 +230,7 @@ export class AppImManager { @@ -230,7 +230,7 @@ export class AppImManager {
this.btnJoin.parentElement.insertBefore(this.pinnedMessageContainer.divAndCaption.container, this.btnJoin);
// will call when message is sent (only 1)
$rootScope.$on('history_append', (e) => {
rootScope.on('history_append', (e) => {
let details = e.detail;
if(!this.scrolledAllDown) {
@ -241,7 +241,7 @@ export class AppImManager { @@ -241,7 +241,7 @@ export class AppImManager {
});
// will call when sent for update pos
$rootScope.$on('history_update', (e) => {
rootScope.on('history_update', (e) => {
let details = e.detail;
if(details.mid && details.peerID == this.peerID) {
@ -262,7 +262,7 @@ export class AppImManager { @@ -262,7 +262,7 @@ export class AppImManager {
}
});
$rootScope.$on('history_multiappend', (e) => {
rootScope.on('history_multiappend', (e) => {
const msgIDsByPeer = e.detail;
for(const peerID in msgIDsByPeer) {
@ -274,7 +274,7 @@ export class AppImManager { @@ -274,7 +274,7 @@ export class AppImManager {
this.renderNewMessagesByIDs(msgIDs);
});
$rootScope.$on('history_delete', (e) => {
rootScope.on('history_delete', (e) => {
const {peerID, msgs} = e.detail;
const mids = Object.keys(msgs).map(s => +s);
@ -285,14 +285,14 @@ export class AppImManager { @@ -285,14 +285,14 @@ export class AppImManager {
}
});
$rootScope.$on('dialog_flush', (e) => {
rootScope.on('dialog_flush', (e) => {
let peerID: number = e.detail.peerID;
if(this.peerID == peerID) {
this.deleteMessagesByIDs(Object.keys(this.bubbles).map(m => +m));
}
});
$rootScope.$on('chat_update', (e) => {
rootScope.on('chat_update', (e) => {
const peerID: number = e.detail;
if(this.peerID == -peerID) {
const chat = appChatsManager.getChat(peerID) as Channel | Chat;
@ -302,7 +302,7 @@ export class AppImManager { @@ -302,7 +302,7 @@ export class AppImManager {
});
// Calls when message successfully sent and we have an ID
$rootScope.$on('message_sent', (e) => {
rootScope.on('message_sent', (e) => {
const {tempID, mid} = e.detail;
this.log('message_sent', e.detail);
@ -386,7 +386,7 @@ export class AppImManager { @@ -386,7 +386,7 @@ export class AppImManager {
}
});
$rootScope.$on('message_edit', (e) => {
rootScope.on('message_edit', (e) => {
const {peerID, mid} = e.detail;
if(peerID != this.peerID) return;
@ -395,7 +395,7 @@ export class AppImManager { @@ -395,7 +395,7 @@ export class AppImManager {
this.renderMessage(mounted.message, true, false, mounted.bubble, false);
});
$rootScope.$on('album_edit', (e) => {
rootScope.on('album_edit', (e) => {
const {peerID, groupID, deletedMids} = e.detail;
if(peerID != this.peerID) return;
@ -407,7 +407,7 @@ export class AppImManager { @@ -407,7 +407,7 @@ export class AppImManager {
this.renderMessage(appMessagesManager.getMessage(renderMaxID), true, false, this.bubbles[maxID], false);
});
$rootScope.$on('peer_pinned_message', (e) => {
rootScope.on('peer_pinned_message', (e) => {
const peerID = e.detail;
if(peerID == this.peerID) {
@ -418,7 +418,7 @@ export class AppImManager { @@ -418,7 +418,7 @@ export class AppImManager {
}
});
$rootScope.$on('messages_downloaded', (e) => {
rootScope.on('messages_downloaded', (e) => {
const mids: number[] = e.detail;
mids.forEach(mid => {
@ -448,13 +448,13 @@ export class AppImManager { @@ -448,13 +448,13 @@ export class AppImManager {
});
});
$rootScope.$on('dialog_drop', (e) => {
rootScope.on('dialog_drop', (e) => {
if(e.detail.peerID == this.peerID) {
this.setPeer(0);
}
});
$rootScope.$on('apiUpdate', (e) => {
rootScope.on('apiUpdate', (e) => {
const update = e.detail;
this.handleUpdate(update);
@ -463,12 +463,12 @@ export class AppImManager { @@ -463,12 +463,12 @@ export class AppImManager {
window.addEventListener('blur', () => {
animationIntersector.checkAnimations(true);
this.offline = $rootScope.idle.isIDLE = true;
this.offline = rootScope.idle.isIDLE = true;
this.updateStatus();
clearInterval(this.updateStatusInterval);
window.addEventListener('focus', () => {
this.offline = $rootScope.idle.isIDLE = false;
this.offline = rootScope.idle.isIDLE = false;
this.updateStatus();
this.updateStatusInterval = window.setInterval(() => this.updateStatus(), 50e3);
@ -725,7 +725,7 @@ export class AppImManager { @@ -725,7 +725,7 @@ export class AppImManager {
});
const onKeyDown = (e: KeyboardEvent) => {
if($rootScope.overlayIsActive) return;
if(rootScope.overlayIsActive) return;
const target = e.target as HTMLElement;
@ -1159,8 +1159,8 @@ export class AppImManager { @@ -1159,8 +1159,8 @@ export class AppImManager {
this.topbar.style.display = this.chatInput.style.display = 'none';
this.goDownBtn.classList.add('hide');
this.cleanup(true);
this.peerID = $rootScope.selectedPeerID = 0;
$rootScope.$broadcast('peer_changed', this.peerID);
this.peerID = rootScope.selectedPeerID = 0;
rootScope.broadcast('peer_changed', this.peerID);
this.selectTab(0);
@ -1218,7 +1218,7 @@ export class AppImManager { @@ -1218,7 +1218,7 @@ export class AppImManager {
}
// set new
this.peerID = $rootScope.selectedPeerID = peerID;
this.peerID = rootScope.selectedPeerID = peerID;
this.log('setPeer peerID:', this.peerID, dialog, lastMsgID, topMessage);
@ -1436,7 +1436,7 @@ export class AppImManager { @@ -1436,7 +1436,7 @@ export class AppImManager {
appSidebarRight.sharedMediaTab.fillProfileElements();
$rootScope.$broadcast('peer_changed', this.peerID);
rootScope.broadcast('peer_changed', this.peerID);
}
public updateUnreadByDialog(dialog: Dialog) {
@ -2894,7 +2894,7 @@ export class AppImManager { @@ -2894,7 +2894,7 @@ export class AppImManager {
const dialog = appMessagesManager.getDialogByPeerID(peerID)[0];
if(dialog) {
dialog.notify_settings = notify_settings;
$rootScope.$broadcast('dialog_notify_settings', peerID);
rootScope.broadcast('dialog_notify_settings', peerID);
}
if(peerID == this.peerID) {

114
src/lib/appManagers/appMessagesManager.ts

@ -16,7 +16,7 @@ import { MOUNT_CLASS_TO } from "../mtproto/mtproto_config"; @@ -16,7 +16,7 @@ import { MOUNT_CLASS_TO } from "../mtproto/mtproto_config";
import referenceDatabase, { ReferenceContext } from "../mtproto/referenceDatabase";
import serverTimeManager from "../mtproto/serverTimeManager";
import { RichTextProcessor } from "../richtextprocessor";
import $rootScope from "../rootScope";
import rootScope from "../rootScope";
import searchIndexManager from '../searchIndexManager';
import AppStorage from '../storage';
import DialogsStorage from "../storages/dialogs";
@ -137,13 +137,13 @@ export class AppMessagesManager { @@ -137,13 +137,13 @@ export class AppMessagesManager {
constructor() {
this.dialogsStorage = new DialogsStorage(this, appMessagesIDsManager, appChatsManager, appPeersManager, serverTimeManager);
this.filtersStorage = new FiltersStorage(appPeersManager, appUsersManager, /* apiManager, */ $rootScope);
this.filtersStorage = new FiltersStorage(appPeersManager, appUsersManager, /* apiManager, */ rootScope);
$rootScope.$on('apiUpdate', (e) => {
rootScope.on('apiUpdate', (e) => {
this.handleUpdate(e.detail);
});
$rootScope.$on('webpage_updated', (e) => {
rootScope.on('webpage_updated', (e) => {
const eventData = e.detail;
eventData.msgs.forEach((msgID) => {
const message = this.getMessage(msgID) as Message.message;
@ -153,7 +153,7 @@ export class AppMessagesManager { @@ -153,7 +153,7 @@ export class AppMessagesManager {
webpage: appWebPagesManager.getWebPage(eventData.id)
};
$rootScope.$broadcast('message_edit', {
rootScope.broadcast('message_edit', {
peerID: this.getMessagePeer(message),
mid: msgID,
justMedia: true
@ -161,7 +161,7 @@ export class AppMessagesManager { @@ -161,7 +161,7 @@ export class AppMessagesManager {
});
});
/* $rootScope.$on('draft_updated', (e) => {
/* rootScope.$on('draft_updated', (e) => {
let eventData = e.detail;;
var peerID = eventData.peerID;
var draft = eventData.draft;
@ -189,7 +189,7 @@ export class AppMessagesManager { @@ -189,7 +189,7 @@ export class AppMessagesManager {
this.dialogsStorage.pushDialog(dialog);
$rootScope.$broadcast('dialog_draft', {
rootScope.$broadcast('dialog_draft', {
peerID,
draft,
index: dialog.index
@ -459,7 +459,7 @@ export class AppMessagesManager { @@ -459,7 +459,7 @@ export class AppMessagesManager {
} else {
delete message.error;
}
$rootScope.$broadcast('messages_pending');
rootScope.broadcast('messages_pending');
}
message.send = () => {
@ -545,7 +545,7 @@ export class AppMessagesManager { @@ -545,7 +545,7 @@ export class AppMessagesManager {
this.saveMessages([message]);
historyStorage.pending.unshift(messageID);
$rootScope.$broadcast('history_append', {peerID, messageID, my: true});
rootScope.broadcast('history_append', {peerID, messageID, my: true});
setTimeout(() => message.send(), 0);
// setTimeout(function () {
@ -790,7 +790,7 @@ export class AppMessagesManager { @@ -790,7 +790,7 @@ export class AppMessagesManager {
delete message.error;
}
$rootScope.$broadcast('messages_pending');
rootScope.broadcast('messages_pending');
};
let uploaded = false,
@ -912,7 +912,7 @@ export class AppMessagesManager { @@ -912,7 +912,7 @@ export class AppMessagesManager {
this.saveMessages([message]);
historyStorage.pending.unshift(messageID);
$rootScope.$broadcast('history_append', {peerID, messageID, my: true});
rootScope.broadcast('history_append', {peerID, messageID, my: true});
setTimeout(message.send.bind(this), 0);
@ -1060,14 +1060,14 @@ export class AppMessagesManager { @@ -1060,14 +1060,14 @@ export class AppMessagesManager {
this.saveMessages([message]);
historyStorage.pending.unshift(messageID);
//$rootScope.$broadcast('history_append', {peerID: peerID, messageID: messageID, my: true});
//rootScope.$broadcast('history_append', {peerID: peerID, messageID: messageID, my: true});
this.pendingByRandomID[randomIDS] = [peerID, messageID];
return message;
});
$rootScope.$broadcast('history_append', {peerID, messageID: messages[messages.length - 1].id, my: true});
rootScope.broadcast('history_append', {peerID, messageID: messages[messages.length - 1].id, my: true});
let toggleError = (message: any, on: boolean) => {
if(on) {
@ -1076,7 +1076,7 @@ export class AppMessagesManager { @@ -1076,7 +1076,7 @@ export class AppMessagesManager {
delete message.error;
}
$rootScope.$broadcast('messages_pending');
rootScope.broadcast('messages_pending');
};
let uploaded = false,
@ -1352,7 +1352,7 @@ export class AppMessagesManager { @@ -1352,7 +1352,7 @@ export class AppMessagesManager {
delete historyMessage.error
}
} */
$rootScope.$broadcast('messages_pending');
rootScope.broadcast('messages_pending');
};
message.send = () => {
@ -1404,7 +1404,7 @@ export class AppMessagesManager { @@ -1404,7 +1404,7 @@ export class AppMessagesManager {
this.saveMessages([message]);
historyStorage.pending.unshift(messageID);
$rootScope.$broadcast('history_append', {peerID, messageID, my: true});
rootScope.broadcast('history_append', {peerID, messageID, my: true});
setTimeout(message.send, 0);
@ -1621,10 +1621,10 @@ export class AppMessagesManager { @@ -1621,10 +1621,10 @@ export class AppMessagesManager {
if(Object.keys(noIDsDialogs).length) {
//setTimeout(() => { // test bad situation
this.reloadConversation(Object.keys(noIDsDialogs).map(id => +id)).then(() => {
$rootScope.$broadcast('dialogs_multiupdate', noIDsDialogs);
rootScope.broadcast('dialogs_multiupdate', noIDsDialogs);
for(let peerID in noIDsDialogs) {
$rootScope.$broadcast('dialog_unread', {peerID: +peerID});
rootScope.broadcast('dialog_unread', {peerID: +peerID});
}
});
//}, 10e3);
@ -1641,7 +1641,7 @@ export class AppMessagesManager { @@ -1641,7 +1641,7 @@ export class AppMessagesManager {
if(hasPrepend) {
this.scheduleHandleNewDialogs();
} else {
$rootScope.$broadcast('dialogs_multiupdate', {});
rootScope.broadcast('dialogs_multiupdate', {});
}
return count;
@ -1788,11 +1788,11 @@ export class AppMessagesManager { @@ -1788,11 +1788,11 @@ export class AppMessagesManager {
}
if(justClear) {
$rootScope.$broadcast('dialog_flush', {peerID});
rootScope.broadcast('dialog_flush', {peerID});
} else {
this.dialogsStorage.dropDialog(peerID);
$rootScope.$broadcast('dialog_drop', {peerID});
rootScope.broadcast('dialog_drop', {peerID});
}
});
}
@ -1805,14 +1805,14 @@ export class AppMessagesManager { @@ -1805,14 +1805,14 @@ export class AppMessagesManager {
if(!this.messagesStorage.hasOwnProperty(mid)) {
this.wrapSingleMessage(mid).then(() => {
$rootScope.$broadcast('peer_pinned_message', peerID);
rootScope.broadcast('peer_pinned_message', peerID);
});
return;
}
}
$rootScope.$broadcast('peer_pinned_message', peerID);
rootScope.broadcast('peer_pinned_message', peerID);
}
public getPinnedMessage(peerID: number) {
@ -2330,10 +2330,10 @@ export class AppMessagesManager { @@ -2330,10 +2330,10 @@ export class AppMessagesManager {
setTimeout(() => {
const dropped = this.dialogsStorage.dropDialog(migrateFrom);
if(dropped.length) {
$rootScope.$broadcast('dialog_drop', {peerID: migrateFrom, dialog: dropped[0]});
rootScope.broadcast('dialog_drop', {peerID: migrateFrom, dialog: dropped[0]});
}
$rootScope.$broadcast('dialog_migrate', {migrateFrom, migrateTo});
rootScope.broadcast('dialog_migrate', {migrateFrom, migrateTo});
}, 100);
}
}
@ -2394,7 +2394,7 @@ export class AppMessagesManager { @@ -2394,7 +2394,7 @@ export class AppMessagesManager {
const message = this.messagesStorage[messageID];
return message && (
message.peerID > 0
|| message.fromID == $rootScope.myID
|| message.fromID == rootScope.myID
|| appChatsManager.getChat(message.peerID)._ == 'chat'
|| appChatsManager.hasRights(message.peerID, 'deleteRevoke')
);
@ -2440,7 +2440,7 @@ export class AppMessagesManager { @@ -2440,7 +2440,7 @@ export class AppMessagesManager {
this.saveConversation(dialog);
/* if(wasDialogBefore) {
$rootScope.$broadcast('dialog_top', dialog);
rootScope.$broadcast('dialog_top', dialog);
} else { */
updatedDialogs[peerID] = dialog;
hasUpdated = true;
@ -2448,7 +2448,7 @@ export class AppMessagesManager { @@ -2448,7 +2448,7 @@ export class AppMessagesManager {
} else {
const dropped = this.dialogsStorage.dropDialog(peerID);
if(dropped.length) {
$rootScope.$broadcast('dialog_drop', {peerID: peerID, dialog: dropped[0]});
rootScope.broadcast('dialog_drop', {peerID: peerID, dialog: dropped[0]});
}
}
@ -2463,7 +2463,7 @@ export class AppMessagesManager { @@ -2463,7 +2463,7 @@ export class AppMessagesManager {
});
if(hasUpdated) {
$rootScope.$broadcast('dialogs_multiupdate', updatedDialogs);
rootScope.broadcast('dialogs_multiupdate', updatedDialogs);
}
}
@ -2548,7 +2548,7 @@ export class AppMessagesManager { @@ -2548,7 +2548,7 @@ export class AppMessagesManager {
dialog.unread_count++;
} */
if(this.mergeReplyKeyboard(historyStorage, message)) {
$rootScope.$broadcast('history_reply_markup', {peerID});
rootScope.broadcast('history_reply_markup', {peerID});
}
} else if(!historyStorage.history.length && !historyStorage.pending.length) {
historyStorage[mid > 0 ? 'history' : 'pending'].push(mid);
@ -2875,7 +2875,7 @@ export class AppMessagesManager { @@ -2875,7 +2875,7 @@ export class AppMessagesManager {
clearTimeout(this.newMessagesHandlePromise);
this.newMessagesHandlePromise = 0;
$rootScope.$broadcast('history_multiappend', this.newMessagesToHandle);
rootScope.broadcast('history_multiappend', this.newMessagesToHandle);
this.newMessagesToHandle = {};
};
@ -2903,7 +2903,7 @@ export class AppMessagesManager { @@ -2903,7 +2903,7 @@ export class AppMessagesManager {
this.incrementMaxSeenID(newMaxSeenID);
}
$rootScope.$broadcast('dialogs_multiupdate', this.newDialogsToHandle as any);
rootScope.broadcast('dialogs_multiupdate', this.newDialogsToHandle as any);
this.newDialogsToHandle = {};
};
@ -3189,7 +3189,7 @@ export class AppMessagesManager { @@ -3189,7 +3189,7 @@ export class AppMessagesManager {
}
if(this.mergeReplyKeyboard(historyStorage, message)) {
$rootScope.$broadcast('history_reply_markup', {peerID});
rootScope.broadcast('history_reply_markup', {peerID});
}
if(!message.pFlags.out && message.from_id) {
@ -3201,7 +3201,7 @@ export class AppMessagesManager { @@ -3201,7 +3201,7 @@ export class AppMessagesManager {
if(randomID) {
if(pendingMessage = this.finalizePendingMessage(randomID, message)) {
$rootScope.$broadcast('history_update', {peerID, mid: message.mid});
rootScope.broadcast('history_update', {peerID, mid: message.mid});
}
delete this.pendingByMessageID[message.mid];
@ -3251,7 +3251,7 @@ export class AppMessagesManager { @@ -3251,7 +3251,7 @@ export class AppMessagesManager {
dialog.pFlags.unread_mark = true;
}
$rootScope.$broadcast('dialogs_multiupdate', {peerID: dialog});
rootScope.broadcast('dialogs_multiupdate', {peerID: dialog});
}
break;
@ -3409,10 +3409,10 @@ export class AppMessagesManager { @@ -3409,10 +3409,10 @@ export class AppMessagesManager {
// @ts-ignore
if(message.clear_history) { // that's will never happen
if(isTopMessage) {
$rootScope.$broadcast('dialog_flush', {peerID: peerID});
rootScope.broadcast('dialog_flush', {peerID: peerID});
}
} else {
$rootScope.$broadcast('message_edit', {
rootScope.broadcast('message_edit', {
peerID,
mid,
justMedia: false
@ -3429,14 +3429,14 @@ export class AppMessagesManager { @@ -3429,14 +3429,14 @@ export class AppMessagesManager {
}
if(pinnedMid) {
$rootScope.$broadcast('peer_pinned_message', peerID);
rootScope.broadcast('peer_pinned_message', peerID);
}
}
if(isTopMessage || groupID) {
const updatedDialogs: {[peerID: number]: Dialog} = {};
updatedDialogs[peerID] = dialog;
$rootScope.$broadcast('dialogs_multiupdate', updatedDialogs);
rootScope.broadcast('dialogs_multiupdate', updatedDialogs);
}
}
break;
@ -3507,11 +3507,11 @@ export class AppMessagesManager { @@ -3507,11 +3507,11 @@ export class AppMessagesManager {
// need be commented for read out messages
//if(newUnreadCount != 0 || !isOut) { // fix 16.11.2019 (maybe not)
//////////this.log.warn(dT(), 'cnt', peerID, newUnreadCount, isOut, foundDialog, update, foundAffected);
$rootScope.$broadcast('dialog_unread', {peerID, count: newUnreadCount});
rootScope.broadcast('dialog_unread', {peerID, count: newUnreadCount});
//}
if(foundAffected) {
$rootScope.$broadcast('messages_read');
rootScope.broadcast('messages_read');
}
break;
}
@ -3534,7 +3534,7 @@ export class AppMessagesManager { @@ -3534,7 +3534,7 @@ export class AppMessagesManager {
}
}
$rootScope.$broadcast('messages_media_read', messages);
rootScope.broadcast('messages_media_read', messages);
break;
}
@ -3631,11 +3631,11 @@ export class AppMessagesManager { @@ -3631,11 +3631,11 @@ export class AppMessagesManager {
if(updatedData.albums) {
for(const groupID in updatedData.albums) {
$rootScope.$broadcast('album_edit', {peerID, groupID, deletedMids: [...updatedData.albums[groupID]]});
rootScope.broadcast('album_edit', {peerID, groupID, deletedMids: [...updatedData.albums[groupID]]});
/* const mids = this.getMidsByAlbum(groupID);
if(mids.length) {
const mid = Math.max(...mids);
$rootScope.$broadcast('message_edit', {peerID, mid, justMedia: false});
rootScope.$broadcast('message_edit', {peerID, mid, justMedia: false});
} */
}
}
@ -3656,7 +3656,7 @@ export class AppMessagesManager { @@ -3656,7 +3656,7 @@ export class AppMessagesManager {
historyStorage.pending = newPending;
$rootScope.$broadcast('history_delete', {peerID, msgs: updatedData.msgs});
rootScope.broadcast('history_delete', {peerID, msgs: updatedData.msgs});
}
const foundDialog = this.getDialogByPeerID(peerID)[0];
@ -3664,7 +3664,7 @@ export class AppMessagesManager { @@ -3664,7 +3664,7 @@ export class AppMessagesManager {
if(updatedData.unread) {
foundDialog.unread_count -= updatedData.unread;
$rootScope.$broadcast('dialog_unread', {
rootScope.broadcast('dialog_unread', {
peerID,
count: foundDialog.unread_count
});
@ -3692,7 +3692,7 @@ export class AppMessagesManager { @@ -3692,7 +3692,7 @@ export class AppMessagesManager {
if(canViewHistory != hasHistory) {
delete this.historiesStorage[peerID];
$rootScope.$broadcast('history_forbidden', peerID);
rootScope.broadcast('history_forbidden', peerID);
}
if(hasDialog != needDialog) {
@ -3701,7 +3701,7 @@ export class AppMessagesManager { @@ -3701,7 +3701,7 @@ export class AppMessagesManager {
} else {
if(foundDialog[0]) {
this.dialogsStorage.dropDialog(peerID);
$rootScope.$broadcast('dialog_drop', {peerID: peerID, dialog: foundDialog[0]});
rootScope.broadcast('dialog_drop', {peerID: peerID, dialog: foundDialog[0]});
}
}
}
@ -3719,7 +3719,7 @@ export class AppMessagesManager { @@ -3719,7 +3719,7 @@ export class AppMessagesManager {
delete this.historiesStorage[peerID];
this.reloadConversation(-channelID).then(() => {
$rootScope.$broadcast('history_reload', peerID);
rootScope.broadcast('history_reload', peerID);
});
break;
@ -3731,7 +3731,7 @@ export class AppMessagesManager { @@ -3731,7 +3731,7 @@ export class AppMessagesManager {
const message = this.getMessage(mid);
if(message && message.views && message.views < views) {
message.views = views;
$rootScope.$broadcast('message_views', {mid, views});
rootScope.broadcast('message_views', {mid, views});
}
break;
}
@ -3809,7 +3809,7 @@ export class AppMessagesManager { @@ -3809,7 +3809,7 @@ export class AppMessagesManager {
delete message.random_id;
delete message.send;
$rootScope.$broadcast('messages_pending');
rootScope.broadcast('messages_pending');
}
delete this.messagesStorage[tempID];
@ -3835,7 +3835,7 @@ export class AppMessagesManager { @@ -3835,7 +3835,7 @@ export class AppMessagesManager {
delete this.tempFinalizeCallbacks[tempID];
}
$rootScope.$broadcast('message_sent', {tempID, mid});
rootScope.broadcast('message_sent', {tempID, mid});
}
public incrementMaxSeenID(maxID: number) {
@ -3989,7 +3989,7 @@ export class AppMessagesManager { @@ -3989,7 +3989,7 @@ export class AppMessagesManager {
historyStorage.history.splice(offset, historyStorage.history.length - offset);
historyResult.messages.forEach((message: any) => {
if(this.mergeReplyKeyboard(historyStorage, message)) {
$rootScope.$broadcast('history_reply_markup', {peerID});
rootScope.broadcast('history_reply_markup', {peerID});
}
historyStorage.history.push(message.mid);
@ -4047,7 +4047,7 @@ export class AppMessagesManager { @@ -4047,7 +4047,7 @@ export class AppMessagesManager {
//console.trace('requestHistory', peerID, maxID, limit, offset);
$rootScope.$broadcast('history_request');
rootScope.broadcast('history_request');
return apiManager.invokeApi('messages.getHistory', {
peer: appPeersManager.getInputPeerByID(peerID),
@ -4187,7 +4187,7 @@ export class AppMessagesManager { @@ -4187,7 +4187,7 @@ export class AppMessagesManager {
this.saveMessages(getMessagesResult.messages);
}
$rootScope.$broadcast('messages_downloaded', splitted.mids[+channelID]);
rootScope.broadcast('messages_downloaded', splitted.mids[+channelID]);
}));
});
@ -4202,7 +4202,7 @@ export class AppMessagesManager { @@ -4202,7 +4202,7 @@ export class AppMessagesManager {
public wrapSingleMessage(msgID: number, overwrite = false): Promise<void> {
if(this.messagesStorage[msgID] && !overwrite) {
$rootScope.$broadcast('messages_downloaded', [msgID]);
rootScope.broadcast('messages_downloaded', [msgID]);
return Promise.resolve();
} else if(this.needSingleMessages.indexOf(msgID) == -1) {
this.needSingleMessages.push(msgID);
@ -4213,7 +4213,7 @@ export class AppMessagesManager { @@ -4213,7 +4213,7 @@ export class AppMessagesManager {
}
public setTyping(peerID: number, _action: any): Promise<boolean> {
if(!$rootScope.myID) return Promise.resolve(false);
if(!rootScope.myID) return Promise.resolve(false);
const action: SendMessageAction = typeof(_action) == 'string' ? {_: _action} : _action;
return apiManager.invokeApi('messages.setTyping', {

6
src/lib/appManagers/appPeersManager.ts

@ -2,7 +2,7 @@ import { isObject } from "../../helpers/object"; @@ -2,7 +2,7 @@ import { isObject } from "../../helpers/object";
import { DialogPeer, InputDialogPeer, InputPeer, Peer } from "../../layer";
import { MOUNT_CLASS_TO } from "../mtproto/mtproto_config";
import { RichTextProcessor } from "../richtextprocessor";
import $rootScope from "../rootScope";
import rootScope from "../rootScope";
import appChatsManager from "./appChatsManager";
import appUsersManager from "./appUsersManager";
@ -29,7 +29,7 @@ export class AppPeersManager { @@ -29,7 +29,7 @@ export class AppPeersManager {
} */
public canPinMessage(peerID: number) {
return peerID == $rootScope.myID || (peerID < 0 && appChatsManager.hasRights(-peerID, 'pin'));
return peerID == rootScope.myID || (peerID < 0 && appChatsManager.hasRights(-peerID, 'pin'));
}
public getPeerPhoto(peerID: number) {
@ -53,7 +53,7 @@ export class AppPeersManager { @@ -53,7 +53,7 @@ export class AppPeersManager {
public getPeerTitle(peerID: number | any, plainText = false, onlyFirstName = false) {
if(!peerID) {
peerID = $rootScope.myID;
peerID = rootScope.myID;
}
let peer: any = {};

6
src/lib/appManagers/appPollsManager.ts

@ -4,7 +4,7 @@ import { logger, LogLevels } from "../logger"; @@ -4,7 +4,7 @@ import { logger, LogLevels } from "../logger";
import apiManager from "../mtproto/mtprotoworker";
import { MOUNT_CLASS_TO } from "../mtproto/mtproto_config";
import { RichTextProcessor } from "../richtextprocessor";
import $rootScope from "../rootScope";
import rootScope from "../rootScope";
import apiUpdatesManager from "./apiUpdatesManager";
import appMessagesManager from './appMessagesManager';
import appPeersManager from './appPeersManager';
@ -77,7 +77,7 @@ class AppPollsManager { @@ -77,7 +77,7 @@ class AppPollsManager {
private log = logger('POLLS', LogLevels.error);
constructor() {
$rootScope.$on('apiUpdate', (e) => {
rootScope.on('apiUpdate', (e) => {
let update = e.detail;
this.handleUpdate(update);
@ -95,7 +95,7 @@ class AppPollsManager { @@ -95,7 +95,7 @@ class AppPollsManager {
}
poll = this.savePoll(poll, update.results);
$rootScope.$broadcast('poll_update', {poll, results: update.results});
rootScope.broadcast('poll_update', {poll, results: update.results});
break;
}

4
src/lib/appManagers/appStateManager.ts

@ -2,7 +2,7 @@ import type { Dialog } from './appMessagesManager'; @@ -2,7 +2,7 @@ import type { Dialog } from './appMessagesManager';
import type { AppStickersManager } from './appStickersManager';
import { App, MOUNT_CLASS_TO, UserAuth } from '../mtproto/mtproto_config';
import EventListenerBase from '../../helpers/eventListenerBase';
import $rootScope from '../rootScope';
import rootScope from '../rootScope';
import AppStorage from '../storage';
import { logger } from '../logger';
import type { AppUsersManager } from './appUsersManager';
@ -91,7 +91,7 @@ export class AppStateManager extends EventListenerBase<{ @@ -91,7 +91,7 @@ export class AppStateManager extends EventListenerBase<{
if(auth?.id) {
// ! Warning ! DON'T delete this
this.state.authState = {_: 'authStateSignedIn'};
$rootScope.$broadcast('user_auth', {id: auth.id});
rootScope.broadcast('user_auth', {id: auth.id});
} else if(!this.state.authState) {
this.state.authState = {_: 'authStateSignIn'};
}

10
src/lib/appManagers/appStickersManager.ts

@ -2,7 +2,7 @@ import { Document, InputFileLocation, InputStickerSet, MessagesRecentStickers, M @@ -2,7 +2,7 @@ import { Document, InputFileLocation, InputStickerSet, MessagesRecentStickers, M
import { Modify } from '../../types';
import apiManager from '../mtproto/mtprotoworker';
import { MOUNT_CLASS_TO } from '../mtproto/mtproto_config';
import $rootScope from '../rootScope';
import rootScope from '../rootScope';
import appDocsManager from './appDocsManager';
import appStateManager from './appStateManager';
@ -44,13 +44,13 @@ export class AppStickersManager { @@ -44,13 +44,13 @@ export class AppStickersManager {
//}
});
$rootScope.$on('apiUpdate', (e) => {
rootScope.on('apiUpdate', (e) => {
const update = e.detail;
switch(update._) {
case 'updateNewStickerSet': {
this.saveStickerSet(update.stickerset, update.stickerset.set.id);
$rootScope.$broadcast('stickers_installed', update.stickerset.set);
rootScope.broadcast('stickers_installed', update.stickerset.set);
break;
}
}
@ -210,7 +210,7 @@ export class AppStickersManager { @@ -210,7 +210,7 @@ export class AppStickersManager {
if(res) {
delete set.installed_date;
$rootScope.$broadcast('stickers_deleted', set);
rootScope.broadcast('stickers_deleted', set);
return true;
}
} else {
@ -221,7 +221,7 @@ export class AppStickersManager { @@ -221,7 +221,7 @@ export class AppStickersManager {
if(res) {
set.installed_date = Date.now() / 1000 | 0;
$rootScope.$broadcast('stickers_installed', set);
rootScope.broadcast('stickers_installed', set);
return true;
}
}

26
src/lib/appManagers/appUsersManager.ts

@ -7,7 +7,7 @@ import apiManager from '../mtproto/mtprotoworker'; @@ -7,7 +7,7 @@ import apiManager from '../mtproto/mtprotoworker';
import { MOUNT_CLASS_TO } from "../mtproto/mtproto_config";
import serverTimeManager from "../mtproto/serverTimeManager";
import { RichTextProcessor } from "../richtextprocessor";
import $rootScope from "../rootScope";
import rootScope from "../rootScope";
import searchIndexManager from "../searchIndexManager";
import appChatsManager from "./appChatsManager";
import appPeersManager from "./appPeersManager";
@ -32,9 +32,9 @@ export class AppUsersManager { @@ -32,9 +32,9 @@ export class AppUsersManager {
constructor() {
setInterval(this.updateUsersStatuses, 60000);
$rootScope.$on('stateSynchronized', this.updateUsersStatuses);
rootScope.on('stateSynchronized', this.updateUsersStatuses);
$rootScope.$on('apiUpdate', (e) => {
rootScope.on('apiUpdate', (e) => {
const update = e.detail as Update;
//console.log('on apiUpdate', update);
switch(update._) {
@ -54,7 +54,7 @@ export class AppUsersManager { @@ -54,7 +54,7 @@ export class AppUsersManager {
}
user.sortStatus = this.getUserStatusForSort(user.status);
$rootScope.$broadcast('user_update', userID);
rootScope.broadcast('user_update', userID);
} //////else console.warn('No user by id:', userID);
break;
@ -74,8 +74,8 @@ export class AppUsersManager { @@ -74,8 +74,8 @@ export class AppUsersManager {
update.photo : {empty: true});
}
$rootScope.$broadcast('user_update', userID);
$rootScope.$broadcast('avatar_update', userID);
rootScope.broadcast('user_update', userID);
rootScope.broadcast('avatar_update', userID);
} else console.warn('No user by id:', userID);
break;
@ -281,7 +281,7 @@ export class AppUsersManager { @@ -281,7 +281,7 @@ export class AppUsersManager {
safeReplaceObject(result, user);
}
$rootScope.$broadcast('user_update', userID);
rootScope.broadcast('user_update', userID);
if(this.cachedPhotoLocations[userID] !== undefined) {
safeReplaceObject(this.cachedPhotoLocations[userID], user &&
@ -323,7 +323,7 @@ export class AppUsersManager { @@ -323,7 +323,7 @@ export class AppUsersManager {
}
public getSelf() {
return this.getUser($rootScope.myID);
return this.getUser(rootScope.myID);
}
public getUserStatusString(userID: number) {
@ -404,7 +404,7 @@ export class AppUsersManager { @@ -404,7 +404,7 @@ export class AppUsersManager {
}
public isNonContactUser(id: number) {
return this.isRegularUser(id) && !this.isContact(id) && id != $rootScope.myID;
return this.isRegularUser(id) && !this.isContact(id) && id != rootScope.myID;
}
public hasUser(id: number, allowMin?: boolean) {
@ -455,7 +455,7 @@ export class AppUsersManager { @@ -455,7 +455,7 @@ export class AppUsersManager {
user.status.expires < timestampNow) {
user.status = {_: 'userStatusOffline', was_online: user.status.expires};
$rootScope.$broadcast('user_update', user.id);
rootScope.broadcast('user_update', user.id);
}
}
};
@ -479,7 +479,7 @@ export class AppUsersManager { @@ -479,7 +479,7 @@ export class AppUsersManager {
};
user.sortStatus = this.getUserStatusForSort(user.status);
$rootScope.$broadcast('user_update', id);
rootScope.broadcast('user_update', id);
}
}
@ -615,7 +615,7 @@ export class AppUsersManager { @@ -615,7 +615,7 @@ export class AppUsersManager {
this.contactsList.splice(curPos, 1);
}
$rootScope.$broadcast('contacts_update', userID);
rootScope.$broadcast('contacts_update', userID);
}
}
} */
@ -637,7 +637,7 @@ export class AppUsersManager { @@ -637,7 +637,7 @@ export class AppUsersManager {
user.status = status;
user.sortStatus = this.getUserStatusForSort(user.status);
$rootScope.$broadcast('user_update', userID);
rootScope.broadcast('user_update', userID);
}
}
}

6
src/lib/appManagers/appWebPagesManager.ts

@ -2,7 +2,7 @@ import appPhotosManager from "./appPhotosManager"; @@ -2,7 +2,7 @@ import appPhotosManager from "./appPhotosManager";
import appDocsManager from "./appDocsManager";
import { RichTextProcessor } from "../richtextprocessor";
import { ReferenceContext } from "../mtproto/referenceDatabase";
import $rootScope from "../rootScope";
import rootScope from "../rootScope";
import { safeReplaceObject } from "../../helpers/object";
import { limitSymbols } from "../../helpers/string";
@ -11,7 +11,7 @@ class AppWebPagesManager { @@ -11,7 +11,7 @@ class AppWebPagesManager {
pendingWebPages: any = {};
constructor() {
$rootScope.$on('apiUpdate', (e) => {
rootScope.on('apiUpdate', (e) => {
const update = e.detail;
switch(update._) {
@ -93,7 +93,7 @@ class AppWebPagesManager { @@ -93,7 +93,7 @@ class AppWebPagesManager {
msgs.push(+msgID);
}
$rootScope.$broadcast('webpage_updated', {
rootScope.broadcast('webpage_updated', {
id: apiWebPage.id,
msgs: msgs
});

8
src/lib/mtproto/apiManager.ts

@ -14,7 +14,7 @@ import { CancellablePromise, deferredPromise } from '../../helpers/cancellablePr @@ -14,7 +14,7 @@ import { CancellablePromise, deferredPromise } from '../../helpers/cancellablePr
import { bytesFromHex, bytesToHex } from '../../helpers/bytes';
/// #if !MTPROTO_WORKER
import $rootScope from '../rootScope';
import rootScope from '../rootScope';
/// #endif
/* var networker = apiManager.cachedNetworkers.websocket.upload[2];
@ -90,7 +90,7 @@ export class ApiManager { @@ -90,7 +90,7 @@ export class ApiManager {
this.telegramMeNotify(true);
/// #if !MTPROTO_WORKER
$rootScope.$broadcast('user_auth', fullUserAuth);
rootScope.broadcast('user_auth', fullUserAuth);
/// #endif
}
@ -207,6 +207,10 @@ export class ApiManager { @@ -207,6 +207,10 @@ export class ApiManager {
}
}
/* networker.onConnectionStatusChange = (online) => {
console.log('status:', online);
}; */
delete this.gettingNetworkers[getKey];
return cache[dcID] = networker;
});

4
src/lib/mtproto/mtproto.worker.ts

@ -56,6 +56,10 @@ networkerFactory.setUpdatesProcessor((obj, bool) => { @@ -56,6 +56,10 @@ networkerFactory.setUpdatesProcessor((obj, bool) => {
respond({update: {obj, bool}});
});
networkerFactory.onConnectionStatusChange = (status) => {
respond({type: 'connectionStatusChange', payload: status});
};
ctx.addEventListener('message', async(e) => {
try {
const task = e.data;

8
src/lib/mtproto/mtprotoworker.ts

@ -4,7 +4,7 @@ import type { MethodDeclMap } from '../../layer'; @@ -4,7 +4,7 @@ import type { MethodDeclMap } from '../../layer';
import type { InvokeApiOptions } from '../../types';
import CryptoWorkerMethods from '../crypto/crypto_methods';
import { logger } from '../logger';
import $rootScope from '../rootScope';
import rootScope from '../rootScope';
import AppStorage from '../storage';
import webpWorkerController from '../webp/webpWorkerController';
import type { DownloadOptions } from './apiFileManager';
@ -127,7 +127,9 @@ export class ApiManagerProxy extends CryptoWorkerMethods { @@ -127,7 +127,9 @@ export class ApiManagerProxy extends CryptoWorkerMethods {
this.updatesProcessor(task.update.obj, task.update.bool);
}
} else if(task.progress) {
$rootScope.$broadcast('download_progress', task.progress);
rootScope.broadcast('download_progress', task.progress);
} else if(task.type == 'connectionStatusChange') {
rootScope.broadcast('connection_status_change', task.payload);
} else if(task.type == 'convertWebp') {
webpWorkerController.postMessage(task);
} else if((task as ServiceWorkerTaskResponse).type == 'requestFilePart') {
@ -229,7 +231,7 @@ export class ApiManagerProxy extends CryptoWorkerMethods { @@ -229,7 +231,7 @@ export class ApiManagerProxy extends CryptoWorkerMethods {
}
public setUserAuth(userAuth: {id: number}) {
$rootScope.$broadcast('user_auth', userAuth);
rootScope.broadcast('user_auth', userAuth);
return this.performTaskWorker('setUserAuth', userAuth);
}

97
src/lib/mtproto/networker.ts

@ -70,7 +70,9 @@ export type MTMessage = InvokeApiOptions & MTMessageOptions & { @@ -70,7 +70,9 @@ export type MTMessage = InvokeApiOptions & MTMessageOptions & {
export default class MTPNetworker {
private authKeyUint8: Uint8Array;
private upload: boolean;
private isFileNetworker: boolean;
private isFileUpload: boolean;
private isFileDownload: boolean;
private lastServerMessages: Array<string> = [];
@ -105,19 +107,27 @@ export default class MTPNetworker { @@ -105,19 +107,27 @@ export default class MTPNetworker {
//private transport: MTTransport;
private name: string;
private log: ReturnType<typeof logger>;
constructor(private dcID: number, private authKey: number[], private authKeyID: Uint8Array,
private serverSalt: number[], private transport: MTTransport, private options: InvokeApiOptions = {}) {
private isOnline = false;
//public onConnectionStatusChange: (online: boolean) => void;
constructor(public dcID: number, private authKey: number[], private authKeyID: Uint8Array,
private serverSalt: number[], private transport: MTTransport, options: InvokeApiOptions = {}) {
this.authKeyUint8 = convertToUint8Array(this.authKey);
//this.authKeyID = sha1BytesSync(this.authKey).slice(-8);
//console.trace('Create', dcID, options);
const suffix = this.options.fileUpload ? '-U' : this.options.fileDownload ? '-D' : '';
this.upload = this.options.fileUpload || this.options.fileDownload;
//this.log = logger('NET-' + dcID + suffix, this.upload && this.dcID == 2 ? LogLevels.debug | LogLevels.warn | LogLevels.log | LogLevels.error : LogLevels.error);
this.log = logger('NET-' + dcID + suffix, LogLevels.log | LogLevels.error);
this.isFileUpload = !!options.fileUpload;
this.isFileDownload = !!options.fileDownload;
this.isFileNetworker = this.isFileUpload || this.isFileDownload;
const suffix = this.isFileUpload ? '-U' : this.isFileDownload ? '-D' : '';
this.name = 'NET-' + dcID + suffix;
//this.log = logger(this.name, this.upload && this.dcID == 2 ? LogLevels.debug | LogLevels.warn | LogLevels.log | LogLevels.error : LogLevels.error);
this.log = logger(this.name, LogLevels.log | LogLevels.error);
this.log('constructor'/* , this.authKey, this.authKeyID, this.serverSalt */);
// Test resend after bad_server_salt
@ -130,8 +140,8 @@ export default class MTPNetworker { @@ -130,8 +140,8 @@ export default class MTPNetworker {
// if(!NetworkerFactory.offlineInited) {
// NetworkerFactory.offlineInited = true;
// /* $rootScope.offline = true
// $rootScope.offlineConnecting = true */
// /* rootScope.offline = true
// rootScope.offlineConnecting = true */
// }
/// #if MTPROTO_HTTP_UPLOAD
@ -198,7 +208,7 @@ export default class MTPNetworker { @@ -198,7 +208,7 @@ export default class MTPNetworker {
return seqNo;
}
public wrapMtpCall(method: string, params: any = {}, options: MTMessageOptions = {}) {
public wrapMtpCall(method: string, params: any, options: MTMessageOptions) {
const serializer = new TLSerialization({mtproto: true});
serializer.storeMethod(method, params);
@ -218,7 +228,7 @@ export default class MTPNetworker { @@ -218,7 +228,7 @@ export default class MTPNetworker {
return this.pushMessage(message, options);
}
public wrapMtpMessage(object: any = {}, options: MTMessageOptions = {}) {
public wrapMtpMessage(object: any, options: MTMessageOptions) {
const serializer = new TLSerialization({mtproto: true});
serializer.storeObject(object, 'Object');
@ -321,7 +331,7 @@ export default class MTPNetworker { @@ -321,7 +331,7 @@ export default class MTPNetworker {
AppStorage.get<number>('dc').then((baseDcID: number) => {
if(isClean && (
baseDcID != this.dcID ||
this.upload ||
this.isFileNetworker ||
(this.sleepAfter && Date.now() > this.sleepAfter)
)) {
//console.warn(dT(), 'Send long-poll for DC is delayed', this.dcID, this.sleepAfter);
@ -354,7 +364,7 @@ export default class MTPNetworker { @@ -354,7 +364,7 @@ export default class MTPNetworker {
}
public checkConnection = (event: Event | string) => {
/* $rootScope.offlineConnecting = true */
/* rootScope.offlineConnecting = true */
this.log('Check connection', event);
clearTimeout(this.checkConnectionTimeout);
@ -374,14 +384,14 @@ export default class MTPNetworker { @@ -374,14 +384,14 @@ export default class MTPNetworker {
};
this.sendEncryptedRequest(pingMessage).then((result) => {
/* delete $rootScope.offlineConnecting */
/* delete rootScope.offlineConnecting */
this.toggleOffline(false);
}, () => {
this.log('Delay ', this.checkConnectionPeriod * 1000);
this.checkConnectionTimeout = setTimeout(this.checkConnection, this.checkConnectionPeriod * 1000 | 0);
this.checkConnectionPeriod = Math.min(60, this.checkConnectionPeriod * 1.5);
/* setTimeout(function() {
delete $rootScope.offlineConnecting
delete rootScope.offlineConnecting
}, 1000); */
});
};
@ -393,8 +403,8 @@ export default class MTPNetworker { @@ -393,8 +403,8 @@ export default class MTPNetworker {
}
this.offline = enabled;
/* $rootScope.offline = enabled;
$rootScope.offlineConnecting = false; */
/* rootScope.offline = enabled;
rootScope.offlineConnecting = false; */
if(this.offline) {
clearTimeout(this.nextReqTimeout);
@ -481,17 +491,20 @@ export default class MTPNetworker { @@ -481,17 +491,20 @@ export default class MTPNetworker {
seq_no: number,
body: Uint8Array | number[],
isAPI?: boolean
}, options: MTMessageOptions = {}) {
return new Promise((resolve, reject) => {
this.sentMessages[message.msg_id] = Object.assign(message, options, {
deferred: {resolve, reject}
});
}, options: MTMessageOptions) {
const promise = new Promise((resolve, reject) => {
this.sentMessages[message.msg_id] = Object.assign(message, options, options.notContentRelated
? undefined
: {
deferred: {resolve, reject}
}
);
// this.log('Networker pushMessage:', this.sentMessages[message.msg_id]);
//this.log.error('Networker pushMessage:', this.sentMessages[message.msg_id]);
this.pendingMessages[message.msg_id] = 0;
if(!options || !options.noSchedule) {
if(!options.noSchedule) {
this.scheduleRequest();
}
@ -499,6 +512,40 @@ export default class MTPNetworker { @@ -499,6 +512,40 @@ export default class MTPNetworker {
options.messageID = message.msg_id;
}
});
if(!options.notContentRelated && !options.noResponse) {
const timeout = setTimeout(() => {
this.log.error('timeout', message);
this.setConnectionStatus(false);
}, 5e3);
promise.finally(() => {
clearTimeout(timeout);
this.setConnectionStatus(true);
});
}
return promise;
}
public setConnectionStatus(online: boolean) {
const willChange = this.isOnline != online;
this.isOnline = online;
if(willChange && NetworkerFactory.onConnectionStatusChange) {
NetworkerFactory.onConnectionStatusChange({
_: 'networkerStatus',
online: this.isOnline,
dcID: this.dcID,
name: this.name,
isFileNetworker: this.isFileNetworker,
isFileDownload: this.isFileDownload,
isFileUpload: this.isFileUpload
});
}
/* if(this.onConnectionStatusChange) {
this.onConnectionStatusChange(this.isOnline);
} */
}
public pushResend(messageID: string, delay = 0) {
@ -1198,7 +1245,7 @@ export default class MTPNetworker { @@ -1198,7 +1245,7 @@ export default class MTPNetworker {
this.applyServerSalt(message.server_salt);
AppStorage.get<number>('dc').then((baseDcID: number) => {
if(baseDcID == this.dcID && !this.upload && NetworkerFactory.updatesProcessor) {
if(baseDcID == this.dcID && !this.isFileNetworker && NetworkerFactory.updatesProcessor) {
NetworkerFactory.updatesProcessor(message, true);
}
});

3
src/lib/mtproto/networkerFactory.ts

@ -1,9 +1,10 @@ @@ -1,9 +1,10 @@
import MTPNetworker from "./networker";
import { InvokeApiOptions } from "../../types";
import { ConnectionStatusChange, InvokeApiOptions } from "../../types";
import MTTransport from "./transports/transport";
export class NetworkerFactory {
public updatesProcessor: (obj: any, bool: boolean) => void = null;
public onConnectionStatusChange: (info: ConnectionStatusChange) => void = null;
public setUpdatesProcessor(callback: (obj: any, bool: boolean) => void) {
this.updatesProcessor = callback;

18
src/lib/mtproto/transports/websocket.ts

@ -68,9 +68,13 @@ export default class Socket extends MTTransport { @@ -68,9 +68,13 @@ export default class Socket extends MTTransport {
this.releasePending();
if(this.networker && this.lastCloseTime) {
this.networker.cleanupSent();
this.networker.resend();
if(this.networker) {
this.networker.setConnectionStatus(true);
if(this.lastCloseTime) {
this.networker.cleanupSent();
this.networker.resend();
}
}
//}, 3e3);
};
@ -87,6 +91,10 @@ export default class Socket extends MTTransport { @@ -87,6 +91,10 @@ export default class Socket extends MTTransport {
const diff = time - this.lastCloseTime;
const needTimeout = !isNaN(diff) && diff < CONNECTION_RETRY_TIMEOUT ? CONNECTION_RETRY_TIMEOUT - diff : 0;
if(this.networker) {
this.networker.setConnectionStatus(false);
}
this.log('will try to reconnect after timeout:', needTimeout / 1000);
setTimeout(() => {
this.log('trying to reconnect...');
@ -98,10 +106,6 @@ export default class Socket extends MTTransport { @@ -98,10 +106,6 @@ export default class Socket extends MTTransport {
}
}
if(this.networker) {
this.pending
}
this.connect();
}, needTimeout);
};

56
src/lib/rootScope.ts

@ -3,6 +3,7 @@ import type { MyDocument } from "./appManagers/appDocsManager"; @@ -3,6 +3,7 @@ import type { MyDocument } from "./appManagers/appDocsManager";
import type { AppMessagesManager, Dialog } from "./appManagers/appMessagesManager";
import type { Poll, PollResults } from "./appManagers/appPollsManager";
import type { MyDialogFilter } from "./storages/filters";
import type { ConnectionStatusChange } from "../types";
import { MOUNT_CLASS_TO } from "./mtproto/mtproto_config";
type BroadcastEvents = {
@ -61,38 +62,51 @@ type BroadcastEvents = { @@ -61,38 +62,51 @@ type BroadcastEvents = {
'apiUpdate': Update,
'download_progress': any,
'connection_status_change': ConnectionStatusChange
//'draft_updated': any,
};
const $rootScope = {
$broadcast: <T extends keyof BroadcastEvents>(name: T, detail?: BroadcastEvents[T]) => {
class RootScope {
public overlayIsActive: boolean = false;
public selectedPeerID = 0;
public myID = 0;
public idle = {
isIDLE: false
};
public connectionStatus: {[name: string]: ConnectionStatusChange} = {};
constructor() {
this.on('user_auth', (e) => {
this.myID = e.detail.id;
});
this.on('connection_status_change', (e) => {
const status = e.detail;
this.connectionStatus[e.detail.name] = status;
});
}
public broadcast = <T extends keyof BroadcastEvents>(name: T, detail?: BroadcastEvents[T]) => {
/* if(name != 'user_update') {
console.debug(dT(), 'Broadcasting ' + name + ' event, with args:', detail);
} */
let myCustomEvent = new CustomEvent(name, {detail});
const myCustomEvent = new CustomEvent(name, {detail});
document.dispatchEvent(myCustomEvent);
},
$on: <T extends keyof BroadcastEvents>(name: T, callback: (e: Omit<CustomEvent, 'detail'> & {detail: BroadcastEvents[T]}) => any) => {
};
public on = <T extends keyof BroadcastEvents>(name: T, callback: (e: Omit<CustomEvent, 'detail'> & {detail: BroadcastEvents[T]}) => any) => {
// @ts-ignore
document.addEventListener(name, callback);
},
$off: <T extends keyof BroadcastEvents>(name: T, callback: (e: Omit<CustomEvent, 'detail'> & {detail: BroadcastEvents[T]}) => any) => {
};
public off = <T extends keyof BroadcastEvents>(name: T, callback: (e: Omit<CustomEvent, 'detail'> & {detail: BroadcastEvents[T]}) => any) => {
// @ts-ignore
document.removeEventListener(name, callback);
},
overlayIsActive: false,
selectedPeerID: 0,
myID: 0,
idle: {
isIDLE: false
}
};
};
}
$rootScope.$on('user_auth', (e) => {
$rootScope.myID = e.detail.id;
});
const rootScope = new RootScope();
MOUNT_CLASS_TO && (MOUNT_CLASS_TO.$rootScope = $rootScope);
export default $rootScope;
MOUNT_CLASS_TO && (MOUNT_CLASS_TO.rootScope = rootScope);
export default rootScope;

14
src/lib/storages/filters.ts

@ -4,7 +4,7 @@ import type { Modify } from "../../types"; @@ -4,7 +4,7 @@ import type { Modify } from "../../types";
import type { AppPeersManager } from "../appManagers/appPeersManager";
import type { AppUsersManager } from "../appManagers/appUsersManager";
//import type { ApiManagerProxy } from "../mtproto/mtprotoworker";
import type _$rootScope from "../rootScope";
import type _rootScope from "../rootScope";
import type {Dialog} from '../appManagers/appMessagesManager';
import apiManager from "../mtproto/mtprotoworker";
@ -22,8 +22,8 @@ export default class FiltersStorage { @@ -22,8 +22,8 @@ export default class FiltersStorage {
public filters: {[filterID: string]: MyDialogFilter} = {};
public orderIndex = START_ORDER_INDEX;
constructor(private appPeersManager: AppPeersManager, private appUsersManager: AppUsersManager, /* private apiManager: ApiManagerProxy, */ private $rootScope: typeof _$rootScope) {
$rootScope.$on('apiUpdate', (e) => {
constructor(private appPeersManager: AppPeersManager, private appUsersManager: AppUsersManager, /* private apiManager: ApiManagerProxy, */ private rootScope: typeof _rootScope) {
rootScope.on('apiUpdate', (e) => {
this.handleUpdate(e.detail);
});
}
@ -37,7 +37,7 @@ export default class FiltersStorage { @@ -37,7 +37,7 @@ export default class FiltersStorage {
this.saveDialogFilter(update.filter as any);
} else if(this.filters[update.id]) { // Папка удалена
//this.getDialogFilters(true);
this.$rootScope.$broadcast('filter_delete', this.filters[update.id]);
this.rootScope.broadcast('filter_delete', this.filters[update.id]);
delete this.filters[update.id];
}
@ -73,7 +73,7 @@ export default class FiltersStorage { @@ -73,7 +73,7 @@ export default class FiltersStorage {
this.setOrderIndex(filter);
});
this.$rootScope.$broadcast('filter_order', update.order);
this.rootScope.broadcast('filter_order', update.order);
break;
}
@ -179,7 +179,7 @@ export default class FiltersStorage { @@ -179,7 +179,7 @@ export default class FiltersStorage {
this.saveDialogFilter(filter);
}
$rootScope.$broadcast('filter_update', filter); */
rootScope.$broadcast('filter_update', filter); */
this.handleUpdate({
_: 'updateDialogFilter',
@ -246,7 +246,7 @@ export default class FiltersStorage { @@ -246,7 +246,7 @@ export default class FiltersStorage {
this.setOrderIndex(filter);
if(update) {
this.$rootScope.$broadcast('filter_update', filter);
this.rootScope.broadcast('filter_update', filter);
}
}

73
src/scss/partials/_leftSidebar.scss

@ -292,6 +292,79 @@ @@ -292,6 +292,79 @@
}
}
}
.connection-status {
width: 100%;
padding: 0 .5rem .5rem;
overflow: hidden;
flex: 0 0 auto;
&:not(.is-not-connected) {
.connection-status-button {
display: none;
}
}
&.is-not-connected {
&.animating {
.connection-status-button, & + .connection-status-bottom {
transition: transform var(--layer-transition);
}
}
&:not(.backwards) {
.connection-status-button {
transform: translateY(0);
}
& + .connection-status-bottom {
transform: translateY(64px);
}
}
&:not(.animating):not(.backwards) {
& + .connection-status-bottom {
height: calc(100% - 64px);
}
}
}
&-button {
color: #2e3939;
align-self: center;
pointer-events: none;
padding-left: 4.5rem;
text-align: left;
height: 3.5rem;
transform: translateY(-100%);
svg {
right: auto;
left: 15px;
height: calc(100% - 30px);
.preloader-path {
stroke: #2e3939;
}
}
}
&-bottom {
position: absolute;
left: 0;
top: 0;
bottom: 0;
right: 0;
overflow: hidden;
transform: translateY(0);
height: 100%;
/* transform: translateY(64px);
height: calc(100% - 64px); */
}
}
}
#search-container {

4
src/scss/style.scss

@ -313,6 +313,10 @@ input, textarea { @@ -313,6 +313,10 @@ input, textarea {
color: $color-error!important;
}
.bg-warning {
background: #fed85a;
}
#bubble-contextmenu, #dialogs-contextmenu {
position: fixed;
right: auto;

10
src/types.d.ts vendored

@ -62,3 +62,13 @@ export namespace AuthState { @@ -62,3 +62,13 @@ export namespace AuthState {
_: 'authStateSignedIn'
};
}
export type ConnectionStatusChange = {
_: 'networkerStatus',
online: boolean,
dcID: number,
name: string,
isFileNetworker: boolean,
isFileDownload: boolean,
isFileUpload: boolean
};
Loading…
Cancel
Save