Browse Source

misc

master
morethanwords 3 years ago
parent
commit
f93ca1b71c
  1. 7
      src/lib/appManagers/appChatsManager.ts
  2. 27
      src/lib/appManagers/appMessagesManager.ts
  3. 1
      src/lib/rootScope.ts
  4. 12
      src/lib/storages/dialogs.ts
  5. 20
      src/lib/storages/filters.ts

7
src/lib/appManagers/appChatsManager.ts

@ -644,8 +644,11 @@ export class AppChatsManager {
peer: appPeersManager.getInputPeerById(peerId), peer: appPeersManager.getInputPeerById(peerId),
about about
}).then(bool => { }).then(bool => {
//apiUpdatesManager.processUpdateMessage(updates); if(bool) {
rootScope.dispatchEvent('peer_bio_edit', peerId); rootScope.dispatchEvent('peer_bio_edit', peerId);
}
return bool;
}); });
} }

27
src/lib/appManagers/appMessagesManager.ts

@ -2198,14 +2198,22 @@ export class AppMessagesManager {
} else { } else {
delete this.notificationsToHandle[peerId]; delete this.notificationsToHandle[peerId];
delete this.typings[peerId]; delete this.typings[peerId];
this.reloadConversationsPeers.delete(peerId);
const c = this.reloadConversationsPeers.get(peerId);
if(c) {
this.reloadConversationsPeers.delete(peerId);
c.promise.resolve(undefined);
}
this.dialogsStorage.dropDialog(peerId); this.dialogsStorage.dropDialogOnDeletion(peerId);
rootScope.dispatchEvent('dialog_drop', {peerId});
} }
}); });
} }
public onPeerDeleted(peerId: number) {
}
public hidePinnedMessages(peerId: PeerId) { public hidePinnedMessages(peerId: PeerId) {
return Promise.all([ return Promise.all([
appStateManager.getState(), appStateManager.getState(),
@ -3255,10 +3263,7 @@ export class AppMessagesManager {
//setTimeout(() => { //setTimeout(() => {
rootScope.dispatchEvent('dialog_migrate', {migrateFrom, migrateTo}); rootScope.dispatchEvent('dialog_migrate', {migrateFrom, migrateTo});
const dropped = this.dialogsStorage.dropDialog(migrateFrom); this.dialogsStorage.dropDialogWithEvent(migrateFrom);
if(dropped.length) {
rootScope.dispatchEvent('dialog_drop', {peerId: migrateFrom, dialog: dropped[0]});
}
//}, 100); //}, 100);
} }
} }
@ -4697,10 +4702,7 @@ export class AppMessagesManager {
if(needDialog) { if(needDialog) {
this.reloadConversation(peerId); this.reloadConversation(peerId);
} else { } else {
if(dialog) { this.dialogsStorage.dropDialogOnDeletion(peerId);
this.dialogsStorage.dropDialog(peerId);
rootScope.dispatchEvent('dialog_drop', {peerId, dialog});
}
} }
} }
}; };
@ -5350,7 +5352,8 @@ export class AppMessagesManager {
// * add bound manually. // * add bound manually.
// * offset_id will be inclusive only if there is 'add_offset' <= -1 (-1 - will only include the 'offset_id') // * offset_id will be inclusive only if there is 'add_offset' <= -1 (-1 - will only include the 'offset_id')
if(offset_id && !mids.includes(offset_id) && offsetIdOffset < count) { // * check that offset_id is not 0
if(offset_id && appMessagesIdsManager.getServerMessageId(offset_id) && !mids.includes(offset_id) && offsetIdOffset < count) {
let i = 0; let i = 0;
for(const length = mids.length; i < length; ++i) { for(const length = mids.length; i < length; ++i) {
if(offset_id > mids[i]) { if(offset_id > mids[i]) {

1
src/lib/rootScope.ts

@ -31,6 +31,7 @@ export type BroadcastEvents = {
'peer_block': {peerId: PeerId, blocked: boolean}, 'peer_block': {peerId: PeerId, blocked: boolean},
'peer_title_edit': PeerId, 'peer_title_edit': PeerId,
'peer_bio_edit': PeerId, 'peer_bio_edit': PeerId,
'peer_deleted': PeerId, // left chat, deleted user dialog, left channel
'filter_delete': MyDialogFilter, 'filter_delete': MyDialogFilter,
'filter_update': MyDialogFilter, 'filter_update': MyDialogFilter,

12
src/lib/storages/dialogs.ts

@ -140,7 +140,7 @@ export default class DialogsStorage {
const peerId = chatId.toPeerId(true); const peerId = chatId.toPeerId(true);
if(chat.pFlags.left && this.getDialogOnly(peerId)) { if(chat.pFlags.left && this.getDialogOnly(peerId)) {
this.dropDialogWithEvent(peerId); this.dropDialogOnDeletion(peerId);
} }
}); });
@ -654,6 +654,16 @@ export default class DialogsStorage {
if(dropped.length) { if(dropped.length) {
rootScope.dispatchEvent('dialog_drop', {peerId, dialog: dropped[0]}); rootScope.dispatchEvent('dialog_drop', {peerId, dialog: dropped[0]});
} }
return dropped;
}
/**
* leaving chat, leaving channel, deleting private dialog
*/
public dropDialogOnDeletion(peerId: PeerId) {
this.dropDialogWithEvent(peerId);
rootScope.dispatchEvent('peer_deleted', peerId);
} }
public applyDialogs(dialogsResult: MessagesPeerDialogs.messagesPeerDialogs) { public applyDialogs(dialogsResult: MessagesPeerDialogs.messagesPeerDialogs) {

20
src/lib/storages/filters.ts

@ -89,6 +89,26 @@ export default class FiltersStorage {
updateDialogFilterOrder: this.onUpdateDialogFilterOrder updateDialogFilterOrder: this.onUpdateDialogFilterOrder
}); });
// delete peers when dialog is being dropped
/* rootScope.addEventListener('peer_deleted', (peerId) => {
for(const filterId in this.filters) {
const filter = this.filters[filterId];
let modified = false;
[filter.pinned_peers, filter.include_peers, filter.exclude_peers].forEach(arr => {
forEachReverse(arr, (inputPeer, idx) => {
if(this.appPeersManager.getPeerId(inputPeer) === peerId) {
arr.splice(idx, 1);
modified = true;
}
});
});
if(modified) {
this.saveDialogFilter(filter, true);
}
}
}); */
} }
public clear(init = false) { public clear(init = false) {

Loading…
Cancel
Save