Copy stickers link

This commit is contained in:
Eduard Kuzmenko 2023-03-10 13:08:06 +04:00
parent 64d2e5faf8
commit 523a0366b0
7 changed files with 37 additions and 13 deletions

View File

@ -1235,7 +1235,7 @@ export default class AppSearchSuper {
this.afterPerforming(1, mediaTab.contentTab);
}
const peerIds = participants.map((participant) => {
const peerIds: {peerId: PeerId, rank: ReturnType<typeof getParticipantRank>}[] = participants.map((participant) => {
const peerId = userId ? (participant as Chat.chat).id.toPeerId(true) : getParticipantPeerId(participant as ChannelParticipant);
if(chatId ? peerId.isAnyChat() : peerId.isUser()) {
return;
@ -1243,7 +1243,7 @@ export default class AppSearchSuper {
return {
peerId,
rank: getParticipantRank(participant as ChannelParticipant)
rank: getParticipantRank(participant as ChannelParticipant) as any
};
}).filter(Boolean);

View File

@ -135,6 +135,7 @@ import wrapLocalSticker from '../wrappers/localSticker';
import {LottieAssetName} from '../../lib/rlottie/lottieLoader';
import clamp from '../../helpers/number/clamp';
import getParticipantRank from '../../lib/appManagers/utils/chats/getParticipantRank';
import wrapParticipantRank from '../wrappers/participantRank';
export const USER_REACTIONS_INLINE = false;
const USE_MEDIA_TAILS = false;
@ -5415,9 +5416,7 @@ export default class ChatBubbles {
private createBubbleNameRank(rank: ReturnType<typeof getParticipantRank> | 0) {
const span = document.createElement('span');
span.classList.add('bubble-name-rank');
span.append(typeof(rank) === 'number' ?
i18n(!rank ? 'Chat.ChannelBadge' : (rank === 1 ? 'Chat.OwnerBadge' : 'ChatAdmin')) :
rank);
span.append(wrapParticipantRank(rank));
return span;
}

View File

@ -28,6 +28,8 @@ import replaceContent from '../../helpers/dom/replaceContent';
import rootScope from '../../lib/rootScope';
import wrapCustomEmoji from '../wrappers/customEmoji';
import emoticonsDropdown from '../emoticonsDropdown';
import ButtonMenuToggle from '../buttonMenuToggle';
import {copyTextToClipboard} from '../../helpers/clipboard';
const ANIMATION_GROUP: AnimationItemGroup = 'STICKERS-POPUP';
@ -251,6 +253,21 @@ export default class PopupStickers extends PopupElement {
setInnerHTML(this.title, i18n('Emoji'));
}
const btnMenu = ButtonMenuToggle({
listenerSetter: this.listenerSetter,
buttons: [{
icon: 'copy',
text: 'CopyLink',
onClick: () => {
const prefix = `https://t.me/${this.isEmojis ? 'addemoji' : 'addstickers'}/`;
const text = sets.map((set) => prefix + set.set.short_name).join('\n');
copyTextToClipboard(text);
}
}],
direction: 'bottom-left'
});
this.title.after(btnMenu);
this.stickersFooter.textContent = '';
this.stickersFooter.append(button);

View File

@ -4,6 +4,7 @@
* https://github.com/morethanwords/tweb/blob/master/LICENSE
*/
import type LazyLoadQueue from './lazyLoadQueue';
import appDialogsManager, {AppDialogsManager, DialogDom, DialogElementSize} from '../lib/appManagers/appDialogsManager';
import {getHeavyAnimationPromise} from '../hooks/useHeavyAnimationCheck';
import isInDOM from '../helpers/dom/isInDOM';
@ -14,9 +15,9 @@ import SortedList, {SortedElementBase} from '../helpers/sortedList';
import safeAssign from '../helpers/object/safeAssign';
import {AppManagers} from '../lib/appManagers/managers';
import getUserStatusString from './wrappers/getUserStatusString';
import type LazyLoadQueue from './lazyLoadQueue';
import getChatMembersString from './wrappers/getChatMembersString';
import {i18n} from '../lib/langPack';
import wrapParticipantRank from './wrappers/participantRank';
import getParticipantRank from '../lib/appManagers/utils/chats/getParticipantRank';
interface SortedUser extends SortedElementBase<PeerId> {
dom: DialogDom
@ -25,7 +26,7 @@ interface SortedUser extends SortedElementBase<PeerId> {
export default class SortedUserList extends SortedList<SortedUser> {
protected static SORT_INTERVAL = 30e3;
public list: HTMLUListElement;
public ranks: Map<PeerId, string | number> = new Map();
public ranks: Map<PeerId, ReturnType<typeof getParticipantRank>> = new Map();
protected lazyLoadQueue: LazyLoadQueue;
protected avatarSize: DialogElementSize = 'abitbigger';
@ -87,9 +88,7 @@ export default class SortedUserList extends SortedList<SortedUser> {
const rank = this.ranks.get(base.id);
if(rank) {
dialogElement.titleRight.replaceChildren(typeof(rank) === 'number' ?
i18n(rank === 1 ? 'Chat.OwnerBadge' : 'ChatAdmin') :
rank);
dialogElement.titleRight.replaceChildren(wrapParticipantRank(rank));
}
(base as SortedUser).dom = dialogElement.dom;

View File

@ -0,0 +1,9 @@
import getParticipantRank from '../../lib/appManagers/utils/chats/getParticipantRank';
import {i18n} from '../../lib/langPack';
import wrapEmojiText from '../../lib/richTextProcessor/wrapEmojiText';
export default function wrapParticipantRank(rank: ReturnType<typeof getParticipantRank> | 0) {
return typeof(rank) === 'number' ?
i18n(!rank ? 'Chat.ChannelBadge' : (rank === 1 ? 'Chat.OwnerBadge' : 'ChatAdmin')) :
wrapEmojiText(rank);
}

View File

@ -404,6 +404,7 @@
&-border {
border-color: var(--message-checkbox-border-color);
z-index: 1 !important;
}
&-background {

View File

@ -46,11 +46,10 @@
&-close {
font-size: 1.5rem;
margin-inline-start: 1rem;
}
&-header {
margin: .625rem 0;
margin: .625rem 1rem;
flex: 0 0 auto;
}
}