Premium gift service message
This commit is contained in:
parent
4b7bf6b97b
commit
df25877d0c
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -134,6 +134,9 @@ import toggleDisability from '../../helpers/dom/toggleDisability';
|
||||||
import {copyTextToClipboard} from '../../helpers/clipboard';
|
import {copyTextToClipboard} from '../../helpers/clipboard';
|
||||||
import liteMode from '../../helpers/liteMode';
|
import liteMode from '../../helpers/liteMode';
|
||||||
import getMediaDurationFromMessage from '../../lib/appManagers/utils/messages/getMediaDurationFromMessage';
|
import getMediaDurationFromMessage from '../../lib/appManagers/utils/messages/getMediaDurationFromMessage';
|
||||||
|
import wrapLocalSticker from '../wrappers/localSticker';
|
||||||
|
import {LottieAssetName} from '../../lib/rlottie/lottieLoader';
|
||||||
|
import clamp from '../../helpers/number/clamp';
|
||||||
|
|
||||||
export const USER_REACTIONS_INLINE = false;
|
export const USER_REACTIONS_INLINE = false;
|
||||||
const USE_MEDIA_TAILS = false;
|
const USE_MEDIA_TAILS = false;
|
||||||
|
@ -3926,11 +3929,63 @@ export default class ChatBubbles {
|
||||||
promise = peerTitle.update({peerId: action.channel_id.toPeerId(true), wrapOptions});
|
promise = peerTitle.update({peerId: action.channel_id.toPeerId(true), wrapOptions});
|
||||||
s.append(i18n('ChatMigration.To', [peerTitle.element]));
|
s.append(i18n('ChatMigration.To', [peerTitle.element]));
|
||||||
} else {
|
} else {
|
||||||
s.append(await wrapMessageActionTextNew({
|
promise = wrapMessageActionTextNew({
|
||||||
message,
|
message,
|
||||||
...wrapOptions
|
...wrapOptions
|
||||||
}));
|
}).then((el) => s.append(el));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(action._ === 'messageActionGiftPremium') {
|
||||||
|
const content = bubbleContainer.cloneNode(false) as HTMLElement;
|
||||||
|
content.classList.add('bubble-premium-gift-container');
|
||||||
|
content.style.height = '12.875rem';
|
||||||
|
content.style.width = '12.5rem';
|
||||||
|
|
||||||
|
const service = s.cloneNode(false) as HTMLElement;
|
||||||
|
service.classList.add('bubble-premium-gift-wrapper');
|
||||||
|
|
||||||
|
const size = 160;
|
||||||
|
|
||||||
|
const months = action.months;
|
||||||
|
|
||||||
|
const durationAssetMap: {[key: number]: LottieAssetName} = {
|
||||||
|
3: 'Gift3',
|
||||||
|
6: 'Gift6',
|
||||||
|
12: 'Gift12'
|
||||||
|
};
|
||||||
|
|
||||||
|
const assetName = durationAssetMap[clamp(months, 3, 12)];
|
||||||
|
|
||||||
|
const promise = wrapLocalSticker({
|
||||||
|
width: size,
|
||||||
|
height: size,
|
||||||
|
assetName,
|
||||||
|
middleware,
|
||||||
|
loop: false,
|
||||||
|
autoplay: liteMode.isAvailable('stickers_chat')
|
||||||
|
}).then(({container, promise}) => {
|
||||||
|
container.classList.add('bubble-premium-gift-sticker');
|
||||||
|
container.style.position = 'relative';
|
||||||
|
container.style.width = container.style.height = size + 'px';
|
||||||
|
service.prepend(container);
|
||||||
|
return promise;
|
||||||
|
});
|
||||||
|
|
||||||
|
const isYears = months >= 12 && !(months % 12);
|
||||||
|
const duration = i18n(isYears ? 'Years' : 'Months', [isYears ? months / 12 : months]);
|
||||||
|
|
||||||
|
const title = i18n('ActionGiftPremiumTitle');
|
||||||
|
const subtitle = i18n('ActionGiftPremiumSubtitle', [duration]);
|
||||||
|
title.classList.add('text-bold');
|
||||||
|
|
||||||
|
service.append(title, subtitle);
|
||||||
|
loadPromises.push(promise);
|
||||||
|
|
||||||
|
content.append(service);
|
||||||
|
bubbleContainer.after(content);
|
||||||
|
}
|
||||||
|
|
||||||
|
loadPromises.push(promise);
|
||||||
}
|
}
|
||||||
bubbleContainer.append(s);
|
bubbleContainer.append(s);
|
||||||
|
|
||||||
|
|
|
@ -4,38 +4,67 @@
|
||||||
* https://github.com/morethanwords/tweb/blob/master/LICENSE
|
* https://github.com/morethanwords/tweb/blob/master/LICENSE
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import {Middleware} from '../../helpers/middleware';
|
||||||
import {MyDocument} from '../../lib/appManagers/appDocsManager';
|
import {MyDocument} from '../../lib/appManagers/appDocsManager';
|
||||||
import {AppManagers} from '../../lib/appManagers/managers';
|
import {AppManagers} from '../../lib/appManagers/managers';
|
||||||
|
import lottieLoader, {LottieAssetName} from '../../lib/rlottie/lottieLoader';
|
||||||
|
import RLottiePlayer from '../../lib/rlottie/rlottiePlayer';
|
||||||
import rootScope from '../../lib/rootScope';
|
import rootScope from '../../lib/rootScope';
|
||||||
import wrapSticker from './sticker';
|
import wrapSticker from './sticker';
|
||||||
|
|
||||||
export default async function wrapLocalSticker({emoji, width, height, managers = rootScope.managers}: {
|
export default async function wrapLocalSticker({
|
||||||
|
emoji,
|
||||||
|
width,
|
||||||
|
height,
|
||||||
|
assetName,
|
||||||
|
middleware,
|
||||||
|
managers = rootScope.managers,
|
||||||
|
loop = false,
|
||||||
|
autoplay = true
|
||||||
|
}: {
|
||||||
doc?: MyDocument,
|
doc?: MyDocument,
|
||||||
url?: string,
|
// url?: string,
|
||||||
emoji?: string,
|
emoji?: string,
|
||||||
|
assetName?: LottieAssetName,
|
||||||
width: number,
|
width: number,
|
||||||
height: number,
|
height: number,
|
||||||
managers?: AppManagers
|
managers?: AppManagers,
|
||||||
|
middleware?: Middleware,
|
||||||
|
autoplay?: boolean,
|
||||||
|
loop?: false
|
||||||
}) {
|
}) {
|
||||||
const container = document.createElement('div');
|
const container = document.createElement('div');
|
||||||
|
container.classList.add('media-sticker-wrapper');
|
||||||
|
|
||||||
const doc = await managers.appStickersManager.getAnimatedEmojiSticker(emoji);
|
let playerPromise: Promise<RLottiePlayer>;
|
||||||
if(doc) {
|
if(assetName) {
|
||||||
wrapSticker({
|
playerPromise = lottieLoader.loadAnimationAsAsset({
|
||||||
|
container,
|
||||||
|
loop,
|
||||||
|
autoplay,
|
||||||
|
width,
|
||||||
|
height,
|
||||||
|
noCache: true,
|
||||||
|
middleware
|
||||||
|
}, assetName).then((animation) => {
|
||||||
|
return lottieLoader.waitForFirstFrame(animation);
|
||||||
|
});
|
||||||
|
} else if(emoji) {
|
||||||
|
const doc = await managers.appStickersManager.getAnimatedEmojiSticker(emoji);
|
||||||
|
if(doc) playerPromise = wrapSticker({
|
||||||
doc,
|
doc,
|
||||||
div: container,
|
div: container,
|
||||||
loop: false,
|
loop,
|
||||||
play: true,
|
play: autoplay,
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
emoji,
|
emoji,
|
||||||
managers
|
managers,
|
||||||
}).then(() => {
|
middleware
|
||||||
// this.animation = player;
|
}).then((result) => {
|
||||||
|
return result.render as Promise<RLottiePlayer>;
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
container.classList.add('media-sticker-wrapper');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return {container};
|
return {container, promise: playerPromise};
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,8 @@ import wrapMessageActionTextNewUnsafe from './messageActionTextNewUnsafe';
|
||||||
export type WrapMessageActionTextOptions = {
|
export type WrapMessageActionTextOptions = {
|
||||||
message: MyMessage,
|
message: MyMessage,
|
||||||
plain?: boolean,
|
plain?: boolean,
|
||||||
noLinks?: boolean
|
noLinks?: boolean,
|
||||||
|
noTextFormat?: boolean
|
||||||
} & WrapSomethingOptions;
|
} & WrapSomethingOptions;
|
||||||
|
|
||||||
export default async function wrapMessageActionTextNew<T extends WrapMessageActionTextOptions>(
|
export default async function wrapMessageActionTextNew<T extends WrapMessageActionTextOptions>(
|
||||||
|
|
|
@ -482,6 +482,22 @@ export default async function wrapMessageActionTextNewUnsafe(options: WrapMessag
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case 'messageActionGiftPremium': {
|
||||||
|
const isMe = !!message.pFlags.out;
|
||||||
|
let authorElement: ReturnType<typeof getNameDivHTML>;
|
||||||
|
if(!isMe) {
|
||||||
|
authorElement = getNameDivHTML(message.fromId, plain);
|
||||||
|
}
|
||||||
|
|
||||||
|
args = authorElement ? [authorElement] : [];
|
||||||
|
|
||||||
|
args.push(paymentsWrapCurrencyAmount(action.amount, action.currency, false, true));
|
||||||
|
|
||||||
|
langPackKey = isMe ? 'ActionGiftOutbound' : 'ActionGiftInbound';
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
langPackKey = (langPack[_] || `[${action._}]`) as any;
|
langPackKey = (langPack[_] || `[${action._}]`) as any;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -211,7 +211,8 @@ export default async function wrapMessageForReply<T extends WrapMessageForReplyO
|
||||||
const actionWrapped = await wrapMessageActionTextNew({
|
const actionWrapped = await wrapMessageActionTextNew({
|
||||||
message: (message as Message.messageService),
|
message: (message as Message.messageService),
|
||||||
plain,
|
plain,
|
||||||
noLinks: true
|
noLinks: true,
|
||||||
|
noTextFormat: true
|
||||||
});
|
});
|
||||||
|
|
||||||
if(actionWrapped) {
|
if(actionWrapped) {
|
||||||
|
|
|
@ -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.3',
|
langPackVersion: '1.0.4',
|
||||||
langPack: 'webk',
|
langPack: 'webk',
|
||||||
langPackCode: 'en',
|
langPackCode: 'en',
|
||||||
domains: MAIN_DOMAINS,
|
domains: MAIN_DOMAINS,
|
||||||
|
|
|
@ -945,6 +945,10 @@ const lang = {
|
||||||
'GiftTelegramPremiumDescription': 'Give **%1$s** access to exclusive features with **Telegram Premium**.',
|
'GiftTelegramPremiumDescription': 'Give **%1$s** access to exclusive features with **Telegram Premium**.',
|
||||||
'PricePerMonth': '%1$s / month',
|
'PricePerMonth': '%1$s / month',
|
||||||
'GiftSubscriptionFor': 'Gift Subscription for %1$s',
|
'GiftSubscriptionFor': 'Gift Subscription for %1$s',
|
||||||
|
'ActionGiftInbound': 'un1 sent you a gift for **un2**',
|
||||||
|
'ActionGiftOutbound': 'You have sent a gift for **un2**',
|
||||||
|
'ActionGiftPremiumTitle': 'Telegram Premium',
|
||||||
|
'ActionGiftPremiumSubtitle': 'for %1$s',
|
||||||
|
|
||||||
// * macos
|
// * macos
|
||||||
'AccountSettings.Filters': 'Chat Folders',
|
'AccountSettings.Filters': 'Chat Folders',
|
||||||
|
|
|
@ -672,7 +672,7 @@ export class AppProfileManager extends AppManager {
|
||||||
|
|
||||||
public canGiftPremium(userId: UserId) {
|
public canGiftPremium(userId: UserId) {
|
||||||
const user = this.appUsersManager.getUser(userId);
|
const user = this.appUsersManager.getUser(userId);
|
||||||
if(user?.pFlags?.premium || true) {
|
if(user?.pFlags?.premium) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,7 @@
|
||||||
* https://github.com/morethanwords/tweb/blob/master/LICENSE
|
* https://github.com/morethanwords/tweb/blob/master/LICENSE
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import type {LiteModeKey} from '../../helpers/liteMode';
|
import animationIntersector from '../../components/animationIntersector';
|
||||||
import animationIntersector, {AnimationItemGroup} from '../../components/animationIntersector';
|
|
||||||
import {MOUNT_CLASS_TO} from '../../config/debug';
|
import {MOUNT_CLASS_TO} from '../../config/debug';
|
||||||
import pause from '../../helpers/schedulers/pause';
|
import pause from '../../helpers/schedulers/pause';
|
||||||
import {logger, LogTypes} from '../logger';
|
import {logger, LogTypes} from '../logger';
|
||||||
|
@ -21,7 +20,8 @@ export type LottieAssetName = 'EmptyFolder' | 'Folders_1' | 'Folders_2' |
|
||||||
'TwoFactorSetupMonkeyClose' | 'TwoFactorSetupMonkeyCloseAndPeek' |
|
'TwoFactorSetupMonkeyClose' | 'TwoFactorSetupMonkeyCloseAndPeek' |
|
||||||
'TwoFactorSetupMonkeyCloseAndPeekToIdle' | 'TwoFactorSetupMonkeyIdle' |
|
'TwoFactorSetupMonkeyCloseAndPeekToIdle' | 'TwoFactorSetupMonkeyIdle' |
|
||||||
'TwoFactorSetupMonkeyPeek' | 'TwoFactorSetupMonkeyTracking' |
|
'TwoFactorSetupMonkeyPeek' | 'TwoFactorSetupMonkeyTracking' |
|
||||||
'voice_outlined2' | 'voip_filled' | 'voice_mini' | 'jolly_roger';
|
'voice_outlined2' | 'voip_filled' | 'voice_mini' | 'jolly_roger' |
|
||||||
|
'Gift3' | 'Gift6' | 'Gift12';
|
||||||
|
|
||||||
export class LottieLoader {
|
export class LottieLoader {
|
||||||
private loadPromise: Promise<void> = !IS_WEB_ASSEMBLY_SUPPORTED ? Promise.reject() : undefined;
|
private loadPromise: Promise<void> = !IS_WEB_ASSEMBLY_SUPPORTED ? Promise.reject() : undefined;
|
||||||
|
|
|
@ -2470,6 +2470,23 @@ $bubble-border-radius-big: 12px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&-premium-gift {
|
||||||
|
&-container {
|
||||||
|
margin-top: .5rem !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
&-wrapper {
|
||||||
|
flex-direction: column;
|
||||||
|
width: 12.5rem;
|
||||||
|
height: 12.875rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
&-sticker {
|
||||||
|
margin-bottom: 10px;
|
||||||
|
margin-top: -20px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// .document-message + .audio-transcribed-text {
|
// .document-message + .audio-transcribed-text {
|
||||||
// margin-bottom: .75rem;
|
// margin-bottom: .75rem;
|
||||||
// }
|
// }
|
||||||
|
|
Loading…
Reference in New Issue