Browse Source

Fix deleted status & avatar in sidebar

Fix muted icon in chat list
master
morethanwords 4 years ago
parent
commit
c69c6a841b
  1. 31
      src/lib/appManagers/appDialogsManager.ts
  2. 35
      src/lib/appManagers/appImManager.ts
  3. 181
      src/lib/appManagers/appMessagesManager.ts
  4. 17
      src/lib/appManagers/appPeersManager.ts
  5. 32
      src/lib/appManagers/appUsersManager.ts
  6. 4
      src/lib/rootScope.ts
  7. 16
      src/scss/partials/_chatlist.scss
  8. 2
      src/scss/partials/_rightSidebar.scss

31
src/lib/appManagers/appDialogsManager.ts

@ -29,7 +29,8 @@ type DialogDom = { @@ -29,7 +29,8 @@ type DialogDom = {
unreadMessagesSpan: HTMLSpanElement,
lastMessageSpan: HTMLSpanElement,
containerEl: HTMLDivElement,
listEl: HTMLLIElement
listEl: HTMLLIElement,
muteAnimationTimeout?: number
};
const testScroll = false;
@ -143,16 +144,14 @@ export class AppDialogsManager { @@ -143,16 +144,14 @@ export class AppDialogsManager {
} */
$rootScope.$on('user_update', (e) => {
let userID = e.detail;
let user = appUsersManager.getUser(userID);
let dialog = appMessagesManager.getDialogByPeerID(user.id)[0];
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) {
let online = user.status && user.status._ == 'userStatusOnline';
let dom = this.getDialogDom(dialog.peerID);
const online = user.status?._ == 'userStatusOnline';
const dom = this.getDialogDom(dialog.peerID);
if(dom) {
dom.avatarEl.classList.toggle('is-online', online);
@ -737,8 +736,18 @@ export class AppDialogsManager { @@ -737,8 +736,18 @@ export class AppDialogsManager {
}
const isMuted = (dialog.notify_settings?.mute_until * 1000) > Date.now();
const wasMuted = dom.listEl.classList.contains('is-muted');
if(!isMuted && wasMuted) {
dom.listEl.classList.add('backwards');
if(dom.muteAnimationTimeout) clearTimeout(dom.muteAnimationTimeout);
dom.muteAnimationTimeout = window.setTimeout(() => {
delete dom.muteAnimationTimeout;
dom.listEl.classList.remove('backwards', 'is-muted');
}, 200);
} else {
dom.listEl.classList.toggle('is-muted', isMuted);
}
const lastMessage = appMessagesManager.getMessage(dialog.top_message);
if(lastMessage._ != 'messageEmpty' && !lastMessage.deleted &&
@ -772,9 +781,9 @@ export class AppDialogsManager { @@ -772,9 +781,9 @@ export class AppDialogsManager {
if(dialog.unread_count || dialog.pFlags.unread_mark) {
//dom.unreadMessagesSpan.innerText = '' + (dialog.unread_count ? formatNumber(dialog.unread_count, 1) : ' ');
dom.unreadMessagesSpan.innerText = '' + (dialog.unread_count || ' ');
dom.unreadMessagesSpan.classList.add(isMuted ? 'unread-muted' : 'unread');
dom.unreadMessagesSpan.classList.add('unread');
} else if(isPinned) {
dom.unreadMessagesSpan.classList.remove('unread', 'unread-muted');
dom.unreadMessagesSpan.classList.remove('unread');
dom.unreadMessagesSpan.classList.add('tgico-pinnedchat');
}
}

35
src/lib/appManagers/appImManager.ts

@ -23,7 +23,7 @@ import { wrapAlbum, wrapDocument, wrapPhoto, wrapPoll, wrapReply, wrapSticker, w @@ -23,7 +23,7 @@ import { wrapAlbum, wrapDocument, wrapPhoto, wrapPoll, wrapReply, wrapSticker, w
import mediaSizes from '../../helpers/mediaSizes';
import { isTouchSupported } from '../../helpers/touchSupport';
import { isAndroid, isApple, isSafari } from '../../helpers/userAgent';
import { InputNotifyPeer, InputPeerNotifySettings } from '../../layer';
import { InputNotifyPeer, InputPeerNotifySettings, NotifyPeer, Update } from '../../layer';
import { logger, LogLevels } from "../logger";
import apiManager from '../mtproto/mtprotoworker';
import { MOUNT_CLASS_TO } from '../mtproto/mtproto_config';
@ -910,7 +910,7 @@ export class AppImManager { @@ -910,7 +910,7 @@ export class AppImManager {
}
public setPeerStatus(needClear = false) {
if(!this.myID) return;
if(!this.myID || !this.peerID) return;
const profileElements = appSidebarRight.sharedMediaTab.profileElements;
@ -950,7 +950,7 @@ export class AppImManager { @@ -950,7 +950,7 @@ export class AppImManager {
if(this.myID == this.peerID) {
this.subtitleEl.innerText = profileElements.subtitle.innerText = '';
} else if(user && user.status) {
} else if(user) {
let subtitle = appUsersManager.getUserStatusString(user.id);
if(subtitle == 'online') {
@ -2629,7 +2629,19 @@ export class AppImManager { @@ -2629,7 +2629,19 @@ export class AppImManager {
peer: inputNotifyPeer,
settings: settings
}).then(bool => {
this.handleUpdate({_: 'updateNotifySettings', peer: inputNotifyPeer, notify_settings: settings});
if(bool) {
this.handleUpdate({
_: 'updateNotifySettings',
peer: {
_: 'notifyPeer',
peer: appPeersManager.getOutputPeer(peerID)
},
notify_settings: { // ! WOW, IT WORKS !
...settings,
_: 'peerNotifySettings',
}
});
}
});
/* return apiManager.invokeApi('account.getNotifySettings', {
@ -2649,7 +2661,7 @@ export class AppImManager { @@ -2649,7 +2661,7 @@ export class AppImManager {
}
public handleUpdate(update: any) {
public handleUpdate(update: Update) {
switch(update._) {
case 'updateUserTyping':
case 'updateChatUserTyping': {
@ -2661,9 +2673,11 @@ export class AppImManager { @@ -2661,9 +2673,11 @@ export class AppImManager {
this.typingUsers[update.user_id] = peerID;
if(!appUsersManager.hasUser(update.user_id)) {
if(update._ == 'updateChatUserTyping') {
if(update.chat_id && appChatsManager.hasChat(update.chat_id) && !appChatsManager.isChannel(update.chat_id)) {
appProfileManager.getChatFull(update.chat_id);
}
}
//return;
}
@ -2698,21 +2712,18 @@ export class AppImManager { @@ -2698,21 +2712,18 @@ export class AppImManager {
}
case 'updateNotifySettings': {
let {peer, notify_settings} = update;
// peer was NotifyPeer
peer = peer.peer;
const {peer, notify_settings} = update;
let peerID = appPeersManager.getPeerID(peer);
const peerID = appPeersManager.getPeerID((peer as NotifyPeer.notifyPeer).peer);
let dialog = appMessagesManager.getDialogByPeerID(peerID)[0];
const dialog = appMessagesManager.getDialogByPeerID(peerID)[0];
if(dialog) {
dialog.notify_settings = notify_settings;
$rootScope.$broadcast('dialog_notify_settings', peerID);
}
if(peerID == this.peerID) {
let muted = notify_settings.mute_until ? new Date(notify_settings.mute_until * 1000) > new Date() : false;
const muted = notify_settings.mute_until ? new Date(notify_settings.mute_until * 1000) > new Date() : false;
this.setMutedState(muted);
}

181
src/lib/appManagers/appMessagesManager.ts

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
import ProgressivePreloader from "../../components/preloader";
import { CancellablePromise, deferredPromise } from "../../helpers/cancellablePromise";
import { Dialog as MTDialog, DialogFilter, DocumentAttribute, InputMessage, Message, MessagesDialogs, MessagesFilter, MessagesMessages, MessagesPeerDialogs, MethodDeclMap, PhotoSize } from "../../layer";
import { Dialog as MTDialog, DialogFilter, DialogPeer, DocumentAttribute, InputMessage, Message, MessagesDialogs, MessagesFilter, MessagesMessages, MessagesPeerDialogs, MethodDeclMap, PhotoSize, Update } from "../../layer";
import { Modify } from "../../types";
import { bigint, nextRandomInt } from "../bin_utils";
import { logger } from "../logger";
@ -240,12 +240,12 @@ export class FiltersStorage { @@ -240,12 +240,12 @@ export class FiltersStorage {
});
}
public handleUpdate(update: any) {
public handleUpdate(update: Update) {
switch(update._) {
case 'updateDialogFilter': {
//console.log('updateDialogFilter', update);
if(update.filter) {
this.saveDialogFilter(update.filter);
this.saveDialogFilter(update.filter as any);
} else if(this.filters[update.id]) { // Папка удалена
//this.getDialogFilters(true);
$rootScope.$broadcast('filter_delete', this.filters[update.id]);
@ -361,7 +361,7 @@ export class FiltersStorage { @@ -361,7 +361,7 @@ export class FiltersStorage {
this.handleUpdate({
_: 'updateDialogFilter',
id: filter.id,
filter: remove ? undefined : filter
filter: remove ? undefined : filter as any
});
}
@ -2521,20 +2521,18 @@ export class AppMessagesManager { @@ -2521,20 +2521,18 @@ export class AppMessagesManager {
const dialog = this.getDialogByPeerID(peerID)[0];
if(!dialog) return Promise.reject();
const peer = appPeersManager.getInputDialogPeerByID(peerID);
const flags = dialog.pFlags?.pinned ? 0 : 1;
const pinned = dialog.pFlags?.pinned ? undefined : true;
return apiManager.invokeApi('messages.toggleDialogPin', {
flags,
peer
peer: appPeersManager.getInputDialogPeerByID(peerID),
pinned
}).then(bool => {
if(bool) {
const pFlags: Update.updateDialogPinned['pFlags'] = pinned ? {pinned} : {};
this.handleUpdate({
_: 'updateDialogPinned',
peer: peer,
pFlags: {
pinned: flags
}
peer: appPeersManager.getDialogPeer(peerID),
folder_id: filterID,
pFlags
});
}
});
@ -2544,20 +2542,17 @@ export class AppMessagesManager { @@ -2544,20 +2542,17 @@ export class AppMessagesManager {
const dialog = this.getDialogByPeerID(peerID)[0];
if(!dialog) return Promise.reject();
const peer = appPeersManager.getInputDialogPeerByID(peerID);
const flags = read || dialog.pFlags?.unread_mark ? 0 : 1;
const unread = read || dialog.pFlags?.unread_mark ? undefined : true;
return apiManager.invokeApi('messages.markDialogUnread', {
flags,
peer
peer: appPeersManager.getInputDialogPeerByID(peerID),
unread
}).then(bool => {
if(bool) {
const pFlags: Update.updateDialogUnreadMark['pFlags'] = unread ? {unread} : {};
this.handleUpdate({
_: 'updateDialogUnreadMark',
peer: peer,
pFlags: {
unread: flags
}
peer: appPeersManager.getDialogPeer(peerID),
pFlags
});
}
});
@ -3336,22 +3331,22 @@ export class AppMessagesManager { @@ -3336,22 +3331,22 @@ export class AppMessagesManager {
});
}
public handleUpdate(update: any) {
public handleUpdate(update: Update) {
this.log.debug('AMM: handleUpdate:', update._);
switch(update._) {
case 'updateMessageID': {
var randomID = update.random_id;
var pendingData = this.pendingByRandomID[randomID];
const randomID = update.random_id;
const pendingData = this.pendingByRandomID[randomID];
//this.log('AMM updateMessageID:', update, pendingData);
if(pendingData) {
var peerID: number = pendingData[0];
var tempID = pendingData[1];
var channelID = appPeersManager.isChannel(peerID) ? -peerID : 0;
var mid = appMessagesIDsManager.getFullMessageID(update.id, channelID);
var message = this.messagesStorage[mid];
const peerID: number = pendingData[0];
const tempID = pendingData[1];
const channelID = appPeersManager.isChannel(peerID) ? -peerID : 0;
const mid = appMessagesIDsManager.getFullMessageID(update.id, channelID);
const message = this.messagesStorage[mid];
if(message) {
var historyStorage = this.historiesStorage[peerID];
var pos = historyStorage.pending.indexOf(tempID);
const historyStorage = this.historiesStorage[peerID];
const pos = historyStorage.pending.indexOf(tempID);
if(pos != -1) {
historyStorage.pending.splice(pos, 1);
}
@ -3367,10 +3362,9 @@ export class AppMessagesManager { @@ -3367,10 +3362,9 @@ export class AppMessagesManager {
case 'updateNewMessage':
case 'updateNewChannelMessage': {
var message = update.message;
var peerID = this.getMessagePeer(message);
var historyStorage = this.historiesStorage[peerID];
let foundDialog = this.getDialogByPeerID(peerID);
const message = update.message as MyMessage;
const peerID = this.getMessagePeer(message);
const foundDialog = this.getDialogByPeerID(peerID);
if(!foundDialog.length) {
this.newDialogsToHandle[peerID] = {reload: true};
@ -3383,7 +3377,7 @@ export class AppMessagesManager { @@ -3383,7 +3377,7 @@ export class AppMessagesManager {
}
if(update._ == 'updateNewChannelMessage') {
var chat = appChatsManager.getChat(-peerID);
const chat = appChatsManager.getChat(-peerID);
if(chat.pFlags && (chat.pFlags.left || chat.pFlags.kicked)) {
break;
}
@ -3392,6 +3386,7 @@ export class AppMessagesManager { @@ -3392,6 +3386,7 @@ export class AppMessagesManager {
this.saveMessages([message]);
// this.log.warn(dT(), 'message unread', message.mid, message.pFlags.unread)
let historyStorage = this.historiesStorage[peerID];
if(historyStorage === undefined) {
historyStorage = this.historiesStorage[peerID] = {
count: null,
@ -3400,11 +3395,11 @@ export class AppMessagesManager { @@ -3400,11 +3395,11 @@ export class AppMessagesManager {
};
}
var history = message.mid > 0 ? historyStorage.history : historyStorage.pending;
const history = message.mid > 0 ? historyStorage.history : historyStorage.pending;
if(history.indexOf(message.mid) != -1) {
return false;
}
var topMsgID = history[0];
const topMsgID = history[0];
history.unshift(message.mid);
if(message.mid > 0 && message.mid < topMsgID) {
history.sort((a, b) => {
@ -3425,8 +3420,8 @@ export class AppMessagesManager { @@ -3425,8 +3420,8 @@ export class AppMessagesManager {
appUsersManager.forceUserOnline(appPeersManager.getPeerID(message.from_id));
}
var randomID = this.pendingByMessageID[message.mid],
pendingMessage;
const randomID = this.pendingByMessageID[message.mid];
let pendingMessage: any;
if(randomID) {
if(pendingMessage = this.finalizePendingMessage(randomID, message)) {
@ -3447,8 +3442,8 @@ export class AppMessagesManager { @@ -3447,8 +3442,8 @@ export class AppMessagesManager {
}
}
var inboxUnread = !message.pFlags.out && message.pFlags.unread;
var dialog = foundDialog[0];
const inboxUnread = !message.pFlags.out && message.pFlags.unread;
const dialog = foundDialog[0];
dialog.top_message = message.mid;
if(inboxUnread) {
dialog.unread_count++;
@ -3465,14 +3460,14 @@ export class AppMessagesManager { @@ -3465,14 +3460,14 @@ export class AppMessagesManager {
case 'updateDialogUnreadMark': {
this.log('updateDialogUnreadMark', update);
let peerID = appPeersManager.getPeerID(update.peer.peer);
let foundDialog = this.getDialogByPeerID(peerID);
const peerID = appPeersManager.getPeerID((update.peer as DialogPeer.dialogPeer).peer);
const foundDialog = this.getDialogByPeerID(peerID);
if(!foundDialog.length) {
this.newDialogsToHandle[peerID] = {reload: true};
this.scheduleHandleNewDialogs();
} else {
let dialog = foundDialog[0];
const dialog = foundDialog[0];
if(!update.pFlags.unread) {
delete dialog.pFlags.unread_mark;
@ -3519,7 +3514,7 @@ export class AppMessagesManager { @@ -3519,7 +3514,7 @@ export class AppMessagesManager {
case 'updateDialogPinned': {
const folderID = update.folder_id ?? 0;
this.log('updateDialogPinned', update);
const peerID = appPeersManager.getPeerID(update.peer.peer);
const peerID = appPeersManager.getPeerID((update.peer as DialogPeer.dialogPeer).peer);
const foundDialog = this.getDialogByPeerID(peerID);
// этот код внизу никогда не сработает, в папках за пиннед отвечает updateDialogFilter
@ -3621,10 +3616,10 @@ export class AppMessagesManager { @@ -3621,10 +3616,10 @@ export class AppMessagesManager {
case 'updateEditMessage':
case 'updateEditChannelMessage': {
var message = update.message;
var peerID = this.getMessagePeer(message);
var channelID = message.peer_id._ == 'peerChannel' ? -peerID : 0;
var mid = appMessagesIDsManager.getFullMessageID(message.id, channelID);
const message = update.message as MyMessage;
const peerID = this.getMessagePeer(message);
const channelID = message.peer_id._ == 'peerChannel' ? -peerID : 0;
const mid = appMessagesIDsManager.getFullMessageID(message.id, channelID);
if(this.messagesStorage[mid] === undefined) {
break;
}
@ -3633,8 +3628,9 @@ export class AppMessagesManager { @@ -3633,8 +3628,9 @@ export class AppMessagesManager {
this.saveMessages([message], {isEdited: true});
safeReplaceObject(this.messagesStorage[mid], message);
var dialog = this.getDialogByPeerID(peerID)[0];
var isTopMessage = dialog && dialog.top_message == mid;
const dialog = this.getDialogByPeerID(peerID)[0];
const isTopMessage = dialog && dialog.top_message == mid;
// @ts-ignore
if(message.clear_history) { // that's will never happen
if(isTopMessage) {
$rootScope.$broadcast('dialog_flush', {peerID: peerID});
@ -3648,7 +3644,7 @@ export class AppMessagesManager { @@ -3648,7 +3644,7 @@ export class AppMessagesManager {
});
if(isTopMessage) {
var updatedDialogs: {[peerID: number]: Dialog} = {};
const updatedDialogs: {[peerID: number]: Dialog} = {};
updatedDialogs[peerID] = dialog;
$rootScope.$broadcast('dialogs_multiupdate', updatedDialogs);
}
@ -3660,9 +3656,9 @@ export class AppMessagesManager { @@ -3660,9 +3656,9 @@ export class AppMessagesManager {
case 'updateReadHistoryOutbox':
case 'updateReadChannelInbox':
case 'updateReadChannelOutbox': {
const channelID: number = update.channel_id;
const channelID: number = (update as Update.updateReadChannelInbox).channel_id;
const maxID = appMessagesIDsManager.getFullMessageID(update.max_id, channelID);
const peerID = channelID ? -channelID : appPeersManager.getPeerID(update.peer);
const peerID = channelID ? -channelID : appPeersManager.getPeerID((update as Update.updateReadHistoryInbox).peer);
const isOut = update._ == 'updateReadHistoryOutbox' || update._ == 'updateReadChannelOutbox' ? true : undefined;
const foundDialog = this.getDialogByPeerID(peerID)[0];
const history = getObjectKeysAndSort(this.messagesStorageByPeerID[peerID] || {}, 'desc');
@ -3753,10 +3749,10 @@ export class AppMessagesManager { @@ -3753,10 +3749,10 @@ export class AppMessagesManager {
}
case 'updateChannelAvailableMessages': {
var channelID: number = update.channel_id;
var messages: any[] = [];
var peerID: number = -channelID;
var history = (this.historiesStorage[peerID] || {}).history || [];
const channelID: number = update.channel_id;
const messages: number[] = [];
const peerID: number = -channelID;
const history = (this.historiesStorage[peerID] || {}).history || [];
if(history.length) {
history.forEach((msgID: number) => {
if(!update.available_min_id ||
@ -3765,24 +3761,26 @@ export class AppMessagesManager { @@ -3765,24 +3761,26 @@ export class AppMessagesManager {
}
});
}
update.messages = messages;
(update as any as Update.updateDeleteChannelMessages).messages = messages;
}
case 'updateDeleteMessages':
case 'updateDeleteChannelMessages': {
let historiesUpdated: {[peerID: number]: {count: number, unread: number, msgs: {[mid: number]: true}}} = {};
let channelID: number = update.channel_id;
const historiesUpdated: {[peerID: number]: {count: number, unread: number, msgs: {[mid: number]: true}}} = {};
const channelID: number = (update as Update.updateDeleteChannelMessages).channel_id;
const messages = (update as any as Update.updateDeleteChannelMessages).messages;
for(let i = 0; i < update.messages.length; i++) {
let messageID = appMessagesIDsManager.getFullMessageID(update.messages[i], channelID);
let message: MyMessage = this.messagesStorage[messageID];
for(let i = 0; i < messages.length; i++) {
const messageID = appMessagesIDsManager.getFullMessageID(messages[i], channelID);
const message: MyMessage = this.messagesStorage[messageID];
if(message) {
let peerID = this.getMessagePeer(message);
let history = historiesUpdated[peerID] || (historiesUpdated[peerID] = {count: 0, unread: 0, msgs: {}});
const peerID = this.getMessagePeer(message);
const history = historiesUpdated[peerID] || (historiesUpdated[peerID] = {count: 0, unread: 0, msgs: {}});
if((message as Message.message).media) {
// @ts-ignore
let c = message.media.webpage || message.media;
const c = message.media.webpage || message.media;
const smth = c.photo || c.document;
if(smth?.file_reference) {
@ -3806,9 +3804,9 @@ export class AppMessagesManager { @@ -3806,9 +3804,9 @@ export class AppMessagesManager {
date: message.date
};
let peerMessagesToHandle = this.newMessagesToHandle[peerID];
const peerMessagesToHandle = this.newMessagesToHandle[peerID];
if(peerMessagesToHandle && peerMessagesToHandle.length) {
let peerMessagesHandlePos = peerMessagesToHandle.indexOf(messageID);
const peerMessagesHandlePos = peerMessagesToHandle.indexOf(messageID);
if(peerMessagesHandlePos != -1) {
peerMessagesToHandle.splice(peerMessagesHandlePos);
}
@ -3818,11 +3816,11 @@ export class AppMessagesManager { @@ -3818,11 +3816,11 @@ export class AppMessagesManager {
Object.keys(historiesUpdated).forEach(_peerID => {
const peerID = +_peerID;
let updatedData = historiesUpdated[peerID];
let historyStorage = this.historiesStorage[peerID];
const updatedData = historiesUpdated[peerID];
const historyStorage = this.historiesStorage[peerID];
if(historyStorage !== undefined) {
let newHistory: number[] = [];
let newPending: number[] = [];
const newHistory: number[] = [];
const newPending: number[] = [];
for(let i = 0; i < historyStorage.history.length; i++) {
if(!updatedData.msgs[historyStorage.history[i]]) {
newHistory.push(historyStorage.history[i]);
@ -3838,9 +3836,9 @@ export class AppMessagesManager { @@ -3838,9 +3836,9 @@ export class AppMessagesManager {
}
}
for(let i = 0; i < historyStorage.pending.length; i++) {
if(!updatedData.msgs[historyStorage.pending[i]]) {
newPending.push(historyStorage.pending[i]);
for(const mid of historyStorage.pending) {
if(!updatedData.msgs[mid]) {
newPending.push(mid);
}
}
historyStorage.pending = newPending;
@ -3848,7 +3846,7 @@ export class AppMessagesManager { @@ -3848,7 +3846,7 @@ export class AppMessagesManager {
$rootScope.$broadcast('history_delete', {peerID, msgs: updatedData.msgs});
}
let foundDialog = this.getDialogByPeerID(peerID)[0];
const foundDialog = this.getDialogByPeerID(peerID)[0];
if(foundDialog) {
if(updatedData.unread) {
foundDialog.unread_count -= updatedData.unread;
@ -3899,7 +3897,9 @@ export class AppMessagesManager { @@ -3899,7 +3897,9 @@ export class AppMessagesManager {
break;
}
// @ts-ignore
case 'updateChannelReload': {
// @ts-ignore
const channelID: number = update.channel_id;
const peerID = -channelID;
@ -3914,9 +3914,9 @@ export class AppMessagesManager { @@ -3914,9 +3914,9 @@ export class AppMessagesManager {
}
case 'updateChannelMessageViews': {
let views = update.views;
let mid = appMessagesIDsManager.getFullMessageID(update.id, update.channel_id);
let message = this.getMessage(mid);
const views = update.views;
const mid = appMessagesIDsManager.getFullMessageID(update.id, update.channel_id);
const message = this.getMessage(mid);
if(message && message.views && message.views < views) {
message.views = views;
$rootScope.$broadcast('message_views', {mid, views});
@ -3926,10 +3926,10 @@ export class AppMessagesManager { @@ -3926,10 +3926,10 @@ export class AppMessagesManager {
case 'updateServiceNotification': {
this.log('updateServiceNotification', update);
var fromID = 777000;
var peerID = fromID;
var messageID = this.tempID--;
var message: any = {
const fromID = 777000;
const peerID = fromID;
const messageID = this.tempID--;
const message: any = {
_: 'message',
id: messageID,
from_id: appPeersManager.getOutputPeer(fromID),
@ -3957,19 +3957,18 @@ export class AppMessagesManager { @@ -3957,19 +3957,18 @@ export class AppMessagesManager {
this.handleUpdate({
_: 'updateNewMessage',
message: message
});
} as any);
}
break;
}
case 'updateChannelPinnedMessage':
case 'updateChatPinnedMessage':
case 'updateUserPinnedMessage': {
let {id} = update;
// hz nado li tut appMessagesIDsManager.getFullMessageID(update.max_id, channelID);
let peerID = update.user_id || -update.chat_id || -update.channel_id;
this.savePinnedMessage(peerID, id);
const peerID = appPeersManager.getPeerID(update);
this.savePinnedMessage(peerID, update.id);
break;
}

17
src/lib/appManagers/appPeersManager.ts

@ -1,9 +1,9 @@ @@ -1,9 +1,9 @@
import appUsersManager from "./appUsersManager";
import appChatsManager from "./appChatsManager";
import { isObject } from "../utils";
import { DialogPeer, InputDialogPeer, InputPeer, Peer } from "../../layer";
import { RichTextProcessor } from "../richtextprocessor";
import { InputPeer, InputDialogPeer, Peer } from "../../layer";
import { isObject } from "../utils";
import appChatsManager from "./appChatsManager";
import appStateManager from "./appStateManager";
import appUsersManager from "./appUsersManager";
// https://github.com/eelcohn/Telegram-API/wiki/Calculating-color-for-a-Telegram-user-on-IRC
/*
@ -66,7 +66,7 @@ export class AppPeersManager { @@ -66,7 +66,7 @@ export class AppPeersManager {
if(peer.first_name) title += peer.first_name;
if(peer.last_name) title += ' ' + peer.last_name;
if(!title) title = peer.pFlags.deleted ? 'Deleted account' : peer.username;
if(!title) title = peer.pFlags.deleted ? 'Deleted Account' : peer.username;
else title = title.trim();
} else {
title = peer.title;
@ -123,6 +123,13 @@ export class AppPeersManager { @@ -123,6 +123,13 @@ export class AppPeersManager {
return isUser ? peerParams[0] : -peerParams[0] || 0;
}
public getDialogPeer(peerID: number): DialogPeer {
return {
_: 'dialogPeer',
peer: this.getOutputPeer(peerID)
};
}
public isChannel(peerID: number): boolean {
return (peerID < 0) && appChatsManager.isChannel(-peerID);
}

32
src/lib/appManagers/appUsersManager.ts

@ -1,15 +1,15 @@ @@ -1,15 +1,15 @@
import { safeReplaceObject, isObject, tsNow, getAbbreviation } from "../utils";
import { RichTextProcessor } from "../richtextprocessor";
import appChatsManager from "./appChatsManager";
import { formatPhoneNumber } from "../../components/misc";
import { InputUser, Update, User as MTUser } from "../../layer";
//import apiManager from '../mtproto/apiManager';
import apiManager from '../mtproto/mtprotoworker';
import serverTimeManager from "../mtproto/serverTimeManager";
import { formatPhoneNumber } from "../../components/misc";
import { RichTextProcessor } from "../richtextprocessor";
import $rootScope from "../rootScope";
import searchIndexManager from "../searchIndexManager";
import { getAbbreviation, isObject, safeReplaceObject, tsNow } from "../utils";
import appChatsManager from "./appChatsManager";
import appPeersManager from "./appPeersManager";
import appStateManager from "./appStateManager";
import { InputUser, User as MTUser } from "../../layer";
import $rootScope from "../rootScope";
/* export type User = {
_: 'user',
@ -65,12 +65,12 @@ export class AppUsersManager { @@ -65,12 +65,12 @@ export class AppUsersManager {
$rootScope.$on('stateSynchronized', this.updateUsersStatuses.bind(this));
$rootScope.$on('apiUpdate', (e) => {
let update = e.detail;
const update = e.detail as Update;
//console.log('on apiUpdate', update);
switch(update._) {
case 'updateUserStatus':
var userID = update.user_id;
var user = this.users[userID];
const userID = update.user_id;
const user = this.users[userID];
if(user) {
user.status = update.status;
if(user.status) {
@ -88,9 +88,9 @@ export class AppUsersManager { @@ -88,9 +88,9 @@ export class AppUsersManager {
} //////else console.warn('No user by id:', userID);
break;
case 'updateUserPhoto':
var userID = update.user_id;
var user = this.users[userID];
case 'updateUserPhoto': {
const userID = update.user_id;
const user = this.users[userID];
if(user) {
this.forceUserOnline(userID);
if(!user.photo) {
@ -107,7 +107,10 @@ export class AppUsersManager { @@ -107,7 +107,10 @@ export class AppUsersManager {
$rootScope.$broadcast('user_update', userID);
$rootScope.$broadcast('avatar_update', userID);
} else console.warn('No user by id:', userID);
break
break;
}
/* case 'updateContactLink':
this.onContactUpdated(update.user_id, update.my_link._ == 'contactLinkContact');
@ -470,7 +473,8 @@ export class AppUsersManager { @@ -470,7 +473,8 @@ export class AppUsersManager {
user.status &&
user.status._ != 'userStatusOnline' &&
user.status._ != 'userStatusEmpty' &&
!user.pFlags.support) {
!user.pFlags.support &&
!user.pFlags.deleted) {
user.status = {
_: 'userStatusOnline',

4
src/lib/rootScope.ts

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
import type { StickerSet } from "../layer";
import type { StickerSet, Update } from "../layer";
import type { MyDocument } from "./appManagers/appDocsManager";
import type { AppMessagesManager, Dialog, MyDialogFilter } from "./appManagers/appMessagesManager";
import type { Poll, PollResults } from "./appManagers/appPollsManager";
@ -55,7 +55,7 @@ type BroadcastEvents = { @@ -55,7 +55,7 @@ type BroadcastEvents = {
'channel_settings': {channelID: number},
'webpage_updated': {id: string, msgs: number[]},
'apiUpdate': any,
'apiUpdate': Update,
'download_progress': any,
//'draft_updated': any,
};

16
src/scss/partials/_chatlist.scss

@ -118,8 +118,13 @@ @@ -118,8 +118,13 @@
margin-left: .125rem;
display: inline-block;
height: 29px;
animation: fade-in-opacity .2s ease forwards;
}
}
&.backwards .user-title:after {
animation: fade-in-backwards-opacity .2s ease forwards;
}
}
}
@ -299,7 +304,7 @@ @@ -299,7 +304,7 @@
}
}
.unread, .unread-muted, .tgico-pinnedchat {
.unread, .tgico-pinnedchat {
height: 24px;
text-align: center;
line-height: 24px;
@ -310,10 +315,11 @@ @@ -310,10 +315,11 @@
flex: 0 0 auto;
}
.unread, .unread-muted {
.unread {
min-width: 24px;
padding: 0 8px;
font-weight: 500;
transition: .2s background-color;
}
.tgico-pinnedchat {
@ -321,15 +327,15 @@ @@ -321,15 +327,15 @@
font-size: 1.5rem;
}
.unread:empty, .unread-muted:empty {
.unread:empty {
visibility: hidden;
}
.unread {
.unread, li.is-muted.backwards .unread {
background: $color-green;
}
.unread-muted, .tgico-pinnedchat {
li.is-muted .unread, .tgico-pinnedchat {
background: #c5c9cc;
}

2
src/scss/partials/_rightSidebar.scss

@ -229,7 +229,7 @@ @@ -229,7 +229,7 @@
}
&.tgico-avatar_deletedaccount {
font-size: 6rem;
font-size: 6rem !important;
}
}

Loading…
Cancel
Save