From 9575ee420171994a0b084db940d5b79f1462e77e Mon Sep 17 00:00:00 2001 From: Daniil Mironenko Date: Fri, 20 Dec 2024 22:47:48 +0300 Subject: [PATCH 1/2] defer csat window rendering --- src/entities/csat/model/store.js | 33 ++++++++++++++++++++++++-------- src/pages/feed/ui/Feed.js | 2 +- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/src/entities/csat/model/store.js b/src/entities/csat/model/store.js index 8ef242a..7316347 100644 --- a/src/entities/csat/model/store.js +++ b/src/entities/csat/model/store.js @@ -1,22 +1,39 @@ import { Storage } from '../../../shared/lib/storage.js'; class CSATStore { - constructor() { + constructor(firstShow = 5, showInterval = 30) { this.storage = { csat: Storage.load('csat') || {}, }; + this.callCount = this.storage.csat?.callCount || 0; + + this.firstShow = firstShow; + this.showInterval = showInterval; } - submitted = () => { + submitted = () => { return this.storage.csat?.submitted; }; - submit = () => { - this.storage.csat = { - submitted: true, - }; - Storage.save('csat', this.storage.csat); - }; + submit = () => { + this.storage.csat = { + submitted: true, + callCount: this.callCount, + }; + Storage.save('csat', this.storage.csat); + }; + + shouldShow = () => { + this.callCount += 1; + + this.storage.csat.callCount = this.callCount; + Storage.save('csat', this.storage.csat); + + if (this.callCount === this.firstShow || (this.callCount - this.firstShow) % this.showInterval === 0) { + return true; + } + return false; + }; } export const csatStore = new CSATStore(); diff --git a/src/pages/feed/ui/Feed.js b/src/pages/feed/ui/Feed.js index 76ba6fd..8ea8ca7 100644 --- a/src/pages/feed/ui/Feed.js +++ b/src/pages/feed/ui/Feed.js @@ -30,7 +30,7 @@ export class FeedPage { this.parent.innerHTML = ""; - if (!csatStore.submitted()) { + if (csatStore.shouldShow()) { const iframe = new CSATWindow(); await iframe.render(); } From 59ee040bc86df0de9656579aecd3359de5985336 Mon Sep 17 00:00:00 2001 From: Daniil Mironenko Date: Fri, 20 Dec 2024 22:54:25 +0300 Subject: [PATCH 2/2] change csat window size --- src/widgets/csatWindow/ui/csatWindow.scss | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/widgets/csatWindow/ui/csatWindow.scss b/src/widgets/csatWindow/ui/csatWindow.scss index dbe6b81..28393bf 100644 --- a/src/widgets/csatWindow/ui/csatWindow.scss +++ b/src/widgets/csatWindow/ui/csatWindow.scss @@ -24,11 +24,11 @@ input { //font-family: 'Sansation', sans-serif; &__container { - width: 80%; + width: 75%; height: 80%; max-width: 400px; max-height: 200px; - margin: auto; + margin: 10; padding: 20px; border: 1px solid colors.$white; border-radius: 10px;