Participants rank in members tab

Fix infinite history request in empty chats
This commit is contained in:
Eduard Kuzmenko 2023-03-08 22:48:55 +04:00
parent 56cf2db459
commit 5226e4ca95
8 changed files with 48 additions and 13 deletions

View File

@ -78,6 +78,7 @@ import wrapMediaSpoiler, {onMediaSpoilerClick} from './wrappers/mediaSpoiler';
import filterAsync from '../helpers/array/filterAsync'; import filterAsync from '../helpers/array/filterAsync';
import ChatContextMenu from './chat/contextMenu'; import ChatContextMenu from './chat/contextMenu';
import PopupElement from './popups'; import PopupElement from './popups';
import getParticipantRank from '../lib/appManagers/utils/chats/getParticipantRank';
// const testScroll = false; // const testScroll = false;
@ -1240,10 +1241,13 @@ export default class AppSearchSuper {
return; return;
} }
return peerId; return {
peerId,
rank: getParticipantRank(participant as ChannelParticipant)
};
}).filter(Boolean); }).filter(Boolean);
const filtered = await filterAsync(peerIds, async(peerId) => { const filtered = await filterAsync(peerIds, async({peerId}) => {
const peer: User | Chat = await this.managers.appPeersManager.getPeer(peerId); const peer: User | Chat = await this.managers.appPeersManager.getPeer(peerId);
if(!middleware()) { if(!middleware()) {
return false; return false;
@ -1256,7 +1260,11 @@ export default class AppSearchSuper {
return true; return true;
}); });
for(const peerId of filtered) { for(const {peerId, rank} of filtered) {
if(rank) {
membersList.ranks.set(peerId, rank);
}
membersList.add(peerId); membersList.add(peerId);
} }
}; };

View File

@ -3633,11 +3633,11 @@ export default class ChatBubbles {
restoreScroll?.(); restoreScroll?.();
pause(!this.chat.setPeerPromise ? 0 : 1000) m(pause(!this.chat.setPeerPromise ? 0 : 1000))
.then(() => getHeavyAnimationPromise()) .then(() => m(getHeavyAnimationPromise()))
.then(() => { .then(() => {
this.lazyLoadQueue.setAllSeen(); this.lazyLoadQueue.setAllSeen();
}); }).catch(noop);
// this.setStickyDateManually(); // this.setStickyDateManually();
}; };

View File

@ -16,6 +16,7 @@ import {AppManagers} from '../lib/appManagers/managers';
import getUserStatusString from './wrappers/getUserStatusString'; import getUserStatusString from './wrappers/getUserStatusString';
import type LazyLoadQueue from './lazyLoadQueue'; import type LazyLoadQueue from './lazyLoadQueue';
import getChatMembersString from './wrappers/getChatMembersString'; import getChatMembersString from './wrappers/getChatMembersString';
import {i18n} from '../lib/langPack';
interface SortedUser extends SortedElementBase<PeerId> { interface SortedUser extends SortedElementBase<PeerId> {
dom: DialogDom dom: DialogDom
@ -24,6 +25,7 @@ interface SortedUser extends SortedElementBase<PeerId> {
export default class SortedUserList extends SortedList<SortedUser> { export default class SortedUserList extends SortedList<SortedUser> {
protected static SORT_INTERVAL = 30e3; protected static SORT_INTERVAL = 30e3;
public list: HTMLUListElement; public list: HTMLUListElement;
public ranks: Map<PeerId, string | number> = new Map();
protected lazyLoadQueue: LazyLoadQueue; protected lazyLoadQueue: LazyLoadQueue;
protected avatarSize: DialogElementSize = 'abitbigger'; protected avatarSize: DialogElementSize = 'abitbigger';
@ -71,7 +73,7 @@ export default class SortedUserList extends SortedList<SortedUser> {
} }
}, },
onElementCreate: (base) => { onElementCreate: (base) => {
const {dom} = appDialogsManager.addDialogNew({ const dialogElement = appDialogsManager.addDialogNew({
peerId: base.id, peerId: base.id,
container: false, container: false,
avatarSize: this.avatarSize, avatarSize: this.avatarSize,
@ -83,7 +85,14 @@ export default class SortedUserList extends SortedList<SortedUser> {
} }
}); });
(base as SortedUser).dom = dom; const rank = this.ranks.get(base.id);
if(rank) {
dialogElement.titleRight.replaceChildren(typeof(rank) === 'number' ?
i18n(rank === 1 ? 'Chat.OwnerBadge' : 'ChatAdmin') :
rank);
}
(base as SortedUser).dom = dialogElement.dom;
return base as SortedUser; return base as SortedUser;
}, },
updateElementWith: fastRaf, updateElementWith: fastRaf,

View File

@ -21,7 +21,7 @@ const App = {
version: process.env.VERSION, version: process.env.VERSION,
versionFull: process.env.VERSION_FULL, versionFull: process.env.VERSION_FULL,
build: +process.env.BUILD, build: +process.env.BUILD,
langPackVersion: '1.0.4', langPackVersion: '1.0.5',
langPack: 'webk', langPack: 'webk',
langPackCode: 'en', langPackCode: 'en',
domains: MAIN_DOMAINS, domains: MAIN_DOMAINS,

View File

@ -949,6 +949,7 @@ const lang = {
'ActionGiftOutbound': 'You have sent a gift for **un2**', 'ActionGiftOutbound': 'You have sent a gift for **un2**',
'ActionGiftPremiumTitle': 'Telegram Premium', 'ActionGiftPremiumTitle': 'Telegram Premium',
'ActionGiftPremiumSubtitle': 'for %1$s', 'ActionGiftPremiumSubtitle': 'for %1$s',
'ChatAdmin': 'admin',
// * macos // * macos
'AccountSettings.Filters': 'Chat Folders', 'AccountSettings.Filters': 'Chat Folders',
@ -1019,6 +1020,7 @@ const lang = {
'Chat.Context.ReactedFast': { 'Chat.Context.ReactedFast': {
'other_value': '%d Reacted' 'other_value': '%d Reacted'
}, },
'Chat.ChannelBadge': 'channel',
'Chat.Date.ScheduledFor': 'Scheduled for %@', 'Chat.Date.ScheduledFor': 'Scheduled for %@',
'Chat.Date.ScheduledForToday': 'Scheduled for today', 'Chat.Date.ScheduledForToday': 'Scheduled for today',
'Chat.DropTitle': 'Drop files here to send them', 'Chat.DropTitle': 'Drop files here to send them',
@ -1026,6 +1028,7 @@ const lang = {
'Chat.DropAsFilesDesc': 'without compression', 'Chat.DropAsFilesDesc': 'without compression',
'Chat.Edit.Cancel.Text': 'Are you sure you want to discard all changes?', 'Chat.Edit.Cancel.Text': 'Are you sure you want to discard all changes?',
'Chat.Input.ReplyToAnswer': 'Reply to message in topics', 'Chat.Input.ReplyToAnswer': 'Reply to message in topics',
'Chat.OwnerBadge': 'owner',
'Chat.SendVoice.PrivacyError': '%@ doesn\'t accept voice and video messages', 'Chat.SendVoice.PrivacyError': '%@ doesn\'t accept voice and video messages',
'Chat.Service.Call.Cancelled': 'Cancelled', 'Chat.Service.Call.Cancelled': 'Cancelled',
'Chat.Service.Call.Missed': 'Missed', 'Chat.Service.Call.Missed': 'Missed',
@ -1101,6 +1104,7 @@ const lang = {
'one_value': '%d Comment', 'one_value': '%d Comment',
'other_value': '%d Comments' 'other_value': '%d Comments'
}, },
'Chat.TopicBadge': 'topic creator',
'ChatTitle.ReportMessages': 'Report Messages', 'ChatTitle.ReportMessages': 'Report Messages',
'Chat.Send.WithoutSound': 'Send Without Sound', 'Chat.Send.WithoutSound': 'Send Without Sound',
'Chat.Send.SetReminder': 'Set a Reminder', 'Chat.Send.SetReminder': 'Set a Reminder',

View File

@ -5950,6 +5950,9 @@ export class AppMessagesManager extends AppManager {
if(isTopEnd || isBottomEnd) { if(isTopEnd || isBottomEnd) {
offsetIdOffset = isTopEnd ? count - topLoaded : bottomLoaded; offsetIdOffset = isTopEnd ? count - topLoaded : bottomLoaded;
} }
} else if(messages.length >= count) {
isTopEnd = true;
isBottomEnd = true;
} }
offsetIdOffset ??= 0; offsetIdOffset ??= 0;

View File

@ -0,0 +1,7 @@
import {ChannelParticipant, ChatParticipant} from '../../../../layer';
export default function getParticipantRank(participant: ChannelParticipant | ChatParticipant) {
return (participant as ChannelParticipant.channelParticipantAdmin).rank ||
(participant._ === 'channelParticipantAdmin' || participant._ === 'chatParticipantAdmin' ? 2 :
(participant._ === 'chatParticipantCreator' || participant._ === 'channelParticipantCreator' ? 1 : undefined));
}

View File

@ -2492,10 +2492,14 @@ $bubble-border-radius-big: 12px;
// } // }
} }
.timestamp.is-disabled { .timestamp {
color: inherit; text-decoration: underline;
text-decoration: none !important;
cursor: inherit; &.is-disabled {
color: inherit;
text-decoration: none !important;
cursor: inherit;
}
} }
@keyframes audio-dots { @keyframes audio-dots {