Skip to content

Commit aab311d

Browse files
committed
add halloween23 promo. AG-26741
Squashed commit of the following: commit ec86e04 Merge: 7fe9bfc 96e7cd5 Author: Slava Leleka <[email protected]> Date: Wed Oct 18 16:19:18 2023 +0300 Merge branch 'master' into feature/AG-26741 commit 7fe9bfc Author: Slava Leleka <[email protected]> Date: Wed Oct 18 14:35:27 2023 +0300 fix setNotificationViewed if withDelay is set commit f243127 Author: Slava Leleka <[email protected]> Date: Tue Oct 17 19:52:15 2023 +0300 fix constants commit c653378 Author: Slava Leleka <[email protected]> Date: Tue Oct 17 19:46:31 2023 +0300 add halloween promo
1 parent 96e7cd5 commit aab311d

14 files changed

+287
-165
lines changed

src/assets/images/back-to-school-2023.svg

-48
This file was deleted.

src/assets/images/halloween23.svg

+149
Loading
-606 Bytes
Binary file not shown.
-1.11 KB
Binary file not shown.
-673 Bytes
Binary file not shown.
-1.2 KB
Binary file not shown.
653 Bytes
Loading
1.12 KB
Loading
657 Bytes
Loading
1.15 KB
Loading

src/background/promoNotifications.ts

+118-97
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,18 @@ export interface PromoNotificationData {
3838
}
3939
}
4040

41+
const CHECK_TIMEOUT_MS = 10 * 60 * 1000; // 10 minutes
42+
43+
const MIN_PERIOD_MS = 30 * 60 * 1000; // 30 minutes
44+
45+
const NOTIFICATION_DELAY_MS = 30 * 1000; // clear notification in 30 seconds
46+
4147
const VIEWED_NOTIFICATIONS = 'viewed-notifications';
4248
const LAST_NOTIFICATION_TIME = 'viewed-notification-time';
4349

44-
const PROMO_LINK = `https://${FORWARDER_DOMAIN}/forward.html?action=back_to_school_23_vpn&from=popup&app=vpn_extension`;
50+
const TDS_PROMO_ACTION = 'halloween_23_vpn';
51+
52+
const PROMO_LINK = `https://${FORWARDER_DOMAIN}/forward.html?action=${TDS_PROMO_ACTION}&from=popup&app=vpn_extension`;
4553

4654
const normalizeLanguage = (locale: string): string | null => {
4755
if (!locale) {
@@ -51,185 +59,199 @@ const normalizeLanguage = (locale: string): string | null => {
5159
return locale.toLowerCase().replace('-', '_');
5260
};
5361

54-
const backToSchoolPromo23Notification = {
55-
id: 'backToSchool23',
62+
const HALLOWEEN_23_ID = 'halloween23';
63+
64+
const halloween23PromoNotification = {
65+
id: HALLOWEEN_23_ID,
5666
locales: {
5767
en: {
58-
title: 'Back to school: Quiz and prize',
59-
btn: 'Test yourself',
68+
title: 'Fact or fiction?',
69+
btn: 'Investigate',
6070
},
6171
ru: {
62-
title: 'Снова в школу: квиз и приз',
63-
btn: 'Пройти',
72+
title: 'Верю не верю',
73+
btn: 'Давайте проверим',
6474
},
6575
es: {
66-
title: 'Vuelta al cole: quiz y recompensa',
67-
btn: 'Hacer el quiz',
76+
title: '¿Realidad o ficción?',
77+
btn: '¡Adivinar!',
6878
},
6979
de: {
70-
title: 'Back to School: Quiz und Preis',
71-
btn: 'Quiz los',
80+
title: 'Falsch oder wahr?',
81+
btn: 'Kommen Sie klar',
7282
},
7383
fr: {
74-
title: 'La rentrée avec AdGuard : Quiz et cadeaux',
75-
btn: 'Passez le Quiz',
84+
title: 'Fait ou fiction ?',
85+
btn: 'Examinons',
7686
},
7787
it: {
78-
title: 'A Scuola con AdGuard: un quiz e un regalo',
79-
btn: 'Supera il Quiz',
88+
title: 'Fatto o finzione?',
89+
btn: 'Esaminiamo',
8090
},
8191
ko: {
82-
title: '백 투 스쿨: 퀴즈 및 할인',
83-
btn: '퀴즈게임 시작',
92+
title: '사실일까, 괴담일까?',
93+
btn: '퀴즈 시작',
8494
},
8595
ja: {
86-
title: 'Back to School セールとクイズ',
87-
btn: 'クイズに挑戦!',
96+
title: '事実か怪談か?',
97+
btn: 'クイズに挑戦する',
8898
},
8999
zh_cn: {
90-
title: '开学特惠:小测验大惊喜',
91-
btn: '测试自己',
100+
title: '万圣节答题小游戏',
101+
btn: '开始玩儿',
92102
},
93103
zh_tw: {
94-
title: '開學特惠:小測驗大驚喜',
95-
btn: '測試自己',
104+
title: '萬聖節答題小遊戲',
105+
btn: '開始玩',
96106
},
97107
uk: {
98-
title: 'Знову до школи: іспит і приз',
99-
btn: 'Скласти',
108+
title: 'Факт чи вигадка?',
109+
btn: 'Вгадай!',
100110
},
101111
pt_br: {
102-
title: 'Volta às aulas: quiz e prêmio',
103-
btn: 'Fazer o quiz',
112+
title: 'Realidade ou ficção?',
113+
btn: 'Adivinhar',
104114
},
105115
pt_pt: {
106-
title: 'Volta às aulas: quiz e prémio',
107-
btn: 'Fazer o quiz',
116+
title: 'Realidade ou ficção?',
117+
btn: 'Adivinhar',
108118
},
109119
ar: {
110-
title: 'العودة إلى المدرسة: مسابقة وجائزة',
111-
btn: 'حل الاختبار',
120+
title: 'حقيقة أم خيال؟',
121+
btn: '!يخمن',
112122
},
113123
be: {
114-
title: 'Зноў у школу: віктарына і прызы',
115-
btn: 'Прайсці',
124+
title: 'Факт ці выдумка?',
125+
btn: 'Адгадайце!',
116126
},
117127
bg: {
118-
title: 'Отново в училище: тест и награда',
119-
btn: 'Преминете',
128+
title: 'Факт или измислица?',
129+
btn: 'Познайте!',
120130
},
121131
ca: {
122-
title: "Tornada a l'escola: qüestionari i premi",
123-
btn: 'Passar',
132+
title: 'Realitat o ficció?',
133+
btn: 'Endevina!',
124134
},
125135
cs: {
126-
title: 'Zpátky do školy: kvíz a cena',
127-
btn: 'Projít',
136+
title: 'Pravda nebo fikce?',
137+
btn: 'Tipni si!',
128138
},
129139
da: {
130-
title: 'Tilbage til skolen: quiz og præmie',
131-
btn: 'Test deg selv',
140+
title: 'Fakta eller fiktion?',
141+
btn: 'Gætte!',
132142
},
133143
el: {
134-
title: 'Επιστροφή στο σχολείο',
135-
btn: 'Περάστε',
144+
title: 'Σωστό ή λάθος?',
145+
btn: 'Εικασία!',
136146
},
137147
es_419: {
138-
title: 'Vuelta al cole: quiz y recompensa',
139-
btn: 'Hacer el quiz',
148+
title: '¿Realidad o ficción?',
149+
btn: '¡Adivinar!',
140150
},
141151
fa: {
142-
title: 'بازگشت به مدرسه: مسابقه و جایزه',
143-
btn: 'امتحان را پاس کنید',
152+
title: 'واقعیت یا تخیل؟',
153+
btn: '!حدس بزن',
144154
},
145155
fi: {
146-
title: 'Takaisin kouluun: tietokilpailu ja palkinto',
147-
btn: 'Läpäise',
156+
title: 'Totta vai tarua?',
157+
btn: 'Arvaus!',
148158
},
149159
he: {
150-
title: 'חזרה לבית הספר: חידון ופרס',
151-
btn: 'לעבור',
160+
title: '?עובדה או בדיה',
161+
btn: '!לְנַחֵשׁ',
152162
},
153163
hr: {
154-
title: 'Povratak u školu: kviz i nagrada',
155-
btn: 'Provjerite se',
164+
title: 'Činjenica ili fikcija?',
165+
btn: 'Pogodite!',
156166
},
157167
hu: {
158-
title: 'Vissza az iskolába: egy kvíz és egy díj',
159-
btn: 'Teszteld magad',
168+
title: 'Tény vagy fikció?',
169+
btn: 'Találd ki!',
160170
},
161171
hy: {
162-
title: 'Վերադառնալ դպրոց',
163-
btn: 'Ստուգեք ինքներդ',
172+
title: 'Փաստ, թե հորինված.',
173+
btn: 'Գուշակիր',
164174
},
165175
id: {
166-
title: 'Kembali ke Sekolah: kuis dan Hadiah',
167-
btn: 'Uji dirimu',
176+
title: 'Fakta atau Fiksi?',
177+
btn: 'Tebakan!',
168178
},
169179
lt: {
170-
title: 'Atgal į mokyklą: viktorina ir prizas',
171-
btn: 'Išbandyk save',
180+
title: 'Faktas ar fikcija?',
181+
btn: 'Atspėk!',
172182
},
173183
ms: {
174-
title: 'Kembali ke Sekolah: kuiz dan Hadiah',
175-
btn: 'Uji diri sendiri',
184+
title: 'Fakta atau fiksyen?',
185+
btn: 'Teka!',
176186
},
177187
nb: {
178-
title: 'Tilbake til skolen: quiz og premie',
179-
btn: 'Test deg selv',
188+
title: 'Fakta eller fiksjon?',
189+
btn: 'Gjett!',
180190
},
181191
nl: {
182-
title: 'Terug naar school: quiz en prijs',
183-
btn: 'Test jezelf',
192+
title: 'Feit of Fictie?',
193+
btn: 'Gok!',
184194
},
185195
pl: {
186-
title: 'Powrót do szkoły: quiz i nagroda',
187-
btn: 'Sprawdź się',
196+
title: 'Fakt czy fikcja?',
197+
btn: 'Zgadywać!',
188198
},
189199
ro: {
190-
title: 'Înapoi la școală: test și premiu',
191-
btn: 'Testați-vă',
200+
title: 'Realitate sau fictiune?',
201+
btn: 'Ghici!',
192202
},
193203
sk: {
194-
title: 'Späť do školy: kvíz a cena',
195-
btn: 'Otestujte sa',
204+
title: 'Skutočnosť alebo fikcia?',
205+
btn: 'Hádaj!',
196206
},
197207
sl: {
198-
title: 'Nazaj v šolo: kviz in nagrada',
199-
btn: 'Preizkusite se',
208+
title: 'Dejstvo ali fikcija?',
209+
btn: 'Ugani!',
200210
},
201211
'sr-Latn': {
202-
title: 'Povratak u školu: kviz i nagrada',
203-
btn: 'Proverite sami',
212+
title: 'Tačno ili netačno?',
213+
btn: 'Izgleda!',
204214
},
205215
sv: {
206-
title: 'Tillbaka till skolan: quiz och pris',
207-
btn: 'Testa dig själv',
216+
title: 'Fakta eller påhitt?',
217+
btn: 'Gissa!',
208218
},
209219
tr: {
210-
title: 'Okula Dönüş: Sınav ve Ödül',
211-
btn: 'Kendinizi test edin',
220+
title: 'Gerçek mi kurgu mu?',
221+
btn: 'Tahmin etmek!',
212222
},
213223
vi: {
214-
title: 'Back to School: câu đố và giải thưởng',
215-
btn: 'Tự kiểm tra',
224+
title: 'Sự thật hay hư cấu?',
225+
btn: 'Đoán!',
226+
},
227+
hi: {
228+
title: 'तथ्य या कल्पना?',
229+
btn: 'अनुमान लगाना!',
230+
},
231+
et: {
232+
title: 'Fakt või väljamõeldis?',
233+
btn: 'Arva ära!',
234+
},
235+
th: {
236+
title: 'เรื่องจริงหรือนิยาย?',
237+
btn: 'เดา!',
216238
},
217239
},
218240
// will be selected for locale, see usage of getNotificationText
219241
text: null,
220242
url: PROMO_LINK,
221-
from: '28 August 2023 12:00:00',
222-
to: '3 September 2023 23:59:00',
243+
from: '25 October 2023 12:00:00',
244+
to: '1 November 2023 23:59:00',
223245
type: 'animated',
224246
get icons() {
225-
return lazyGet(backToSchoolPromo23Notification, 'icons', () => ({
247+
return lazyGet(halloween23PromoNotification, 'icons', () => ({
226248
ENABLED: {
227-
19: getUrl('assets/images/icons/bts2023-on-19.png'),
228-
38: getUrl('assets/images/icons/bts2023-on-38.png'),
249+
19: getUrl('assets/images/icons/halloween23-on-19.png'),
250+
38: getUrl('assets/images/icons/halloween23-on-38.png'),
229251
},
230252
DISABLED: {
231-
19: getUrl('assets/images/icons/bts2023-off-19.png'),
232-
38: getUrl('assets/images/icons/bts2023-off-38.png'),
253+
19: getUrl('assets/images/icons/halloween23-off-19.png'),
254+
38: getUrl('assets/images/icons/halloween23-off-38.png'),
233255
},
234256
}));
235257
},
@@ -252,7 +274,7 @@ const backToSchoolPromo23Notification = {
252274
*/
253275

254276
const notifications: { [key: string]: PromoNotificationData } = {
255-
backToSchoolPromo23: backToSchoolPromo23Notification,
277+
[HALLOWEEN_23_ID]: halloween23PromoNotification,
256278
};
257279

258280
/**
@@ -315,9 +337,6 @@ initNotifications();
315337

316338
let currentNotification: PromoNotificationData | null;
317339
let notificationCheckTime: number;
318-
const checkTimeoutMs = 10 * 60 * 1000; // 10 minutes
319-
const minPeriod = 30 * 60 * 1000; // 30 minutes
320-
const NOTIFICATION_DELAY = 30 * 1000; // clear notification in 30 seconds
321340
let timeoutId: number;
322341

323342
/**
@@ -329,7 +348,9 @@ const setNotificationViewed = async (withDelay: boolean): Promise<void> => {
329348
clearTimeout(timeoutId);
330349
timeoutId = setTimeout(() => {
331350
setNotificationViewed(false);
332-
}, NOTIFICATION_DELAY) as any; // TODO setup tsconfig to fix types
351+
}, NOTIFICATION_DELAY_MS) as any; // TODO setup tsconfig to fix types
352+
// do not continue if `withDelay` is true, otherwise it may set a notification as viewed
353+
return;
333354
}
334355

335356
if (currentNotification) {
@@ -357,14 +378,14 @@ const getCurrentNotification = async (): Promise<PromoNotificationData | null> =
357378
const currentTime = new Date().getTime();
358379

359380
const timeSinceLastNotification = currentTime - (await getLastNotificationTime());
360-
if (timeSinceLastNotification < minPeriod) {
381+
if (timeSinceLastNotification < MIN_PERIOD_MS) {
361382
// Just a check to not show the notification too often
362383
return null;
363384
}
364385

365386
// Check not often than once in 10 minutes
366387
const timeSinceLastCheck = currentTime - notificationCheckTime;
367-
if (notificationCheckTime > 0 && timeSinceLastCheck <= checkTimeoutMs) {
388+
if (notificationCheckTime > 0 && timeSinceLastCheck <= CHECK_TIMEOUT_MS) {
368389
return currentNotification;
369390
}
370391

src/popup/components/PromoNotificationModal/PromoNotificationModal.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ const PromoNotificationModal = observer(() => {
5555
onClick={onCloseHandler}
5656
>
5757
<svg className="icon icon--button">
58-
<use xlinkHref="#cross_gray" />
58+
<use xlinkHref="#cross-white" />
5959
</svg>
6060
</div>
6161
<div className="notify__content">

0 commit comments

Comments
 (0)