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

27
src/lib/appManagers/appMessagesManager.ts

@ -2198,14 +2198,22 @@ export class AppMessagesManager { @@ -2198,14 +2198,22 @@ export class AppMessagesManager {
} else {
delete this.notificationsToHandle[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);
rootScope.dispatchEvent('dialog_drop', {peerId});
this.dialogsStorage.dropDialogOnDeletion(peerId);
}
});
}
public onPeerDeleted(peerId: number) {
}
public hidePinnedMessages(peerId: PeerId) {
return Promise.all([
appStateManager.getState(),
@ -3255,10 +3263,7 @@ export class AppMessagesManager { @@ -3255,10 +3263,7 @@ export class AppMessagesManager {
//setTimeout(() => {
rootScope.dispatchEvent('dialog_migrate', {migrateFrom, migrateTo});
const dropped = this.dialogsStorage.dropDialog(migrateFrom);
if(dropped.length) {
rootScope.dispatchEvent('dialog_drop', {peerId: migrateFrom, dialog: dropped[0]});
}
this.dialogsStorage.dropDialogWithEvent(migrateFrom);
//}, 100);
}
}
@ -4697,10 +4702,7 @@ export class AppMessagesManager { @@ -4697,10 +4702,7 @@ export class AppMessagesManager {
if(needDialog) {
this.reloadConversation(peerId);
} else {
if(dialog) {
this.dialogsStorage.dropDialog(peerId);
rootScope.dispatchEvent('dialog_drop', {peerId, dialog});
}
this.dialogsStorage.dropDialogOnDeletion(peerId);
}
}
};
@ -5350,7 +5352,8 @@ export class AppMessagesManager { @@ -5350,7 +5352,8 @@ export class AppMessagesManager {
// * add bound manually.
// * 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;
for(const length = mids.length; i < length; ++i) {
if(offset_id > mids[i]) {

1
src/lib/rootScope.ts

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

12
src/lib/storages/dialogs.ts

@ -140,7 +140,7 @@ export default class DialogsStorage { @@ -140,7 +140,7 @@ export default class DialogsStorage {
const peerId = chatId.toPeerId(true);
if(chat.pFlags.left && this.getDialogOnly(peerId)) {
this.dropDialogWithEvent(peerId);
this.dropDialogOnDeletion(peerId);
}
});
@ -654,6 +654,16 @@ export default class DialogsStorage { @@ -654,6 +654,16 @@ export default class DialogsStorage {
if(dropped.length) {
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) {

20
src/lib/storages/filters.ts

@ -89,6 +89,26 @@ export default class FiltersStorage { @@ -89,6 +89,26 @@ export default class FiltersStorage {
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) {

Loading…
Cancel
Save