@@ -27,9 +27,7 @@ export default class GleapNotificationManager {
2727 return this . instance ;
2828 }
2929
30- constructor ( ) {
31-
32- }
30+ constructor ( ) { }
3331
3432 updateTabBarNotificationCount ( ) {
3533 GleapEventManager . notifyEvent ( "unread-count-changed" , this . unreadCount ) ;
@@ -58,7 +56,14 @@ export default class GleapNotificationManager {
5856 this . unreadNotificationsKey
5957 ) ;
6058 if ( notificationsFromCache && notificationsFromCache . length > 0 ) {
61- this . notifications = notificationsFromCache ;
59+ if ( notificationsFromCache . length > 2 ) {
60+ this . notifications = notificationsFromCache . splice (
61+ 0 ,
62+ notificationsFromCache . length - 2
63+ ) ;
64+ } else {
65+ this . notifications = notificationsFromCache ;
66+ }
6267 this . renderNotifications ( ) ;
6368 }
6469 }
@@ -95,7 +100,7 @@ export default class GleapNotificationManager {
95100 GleapAudioManager . ping ( ) ;
96101 }
97102 }
98- if ( this . notifications . length > 3 ) {
103+ if ( this . notifications . length > 2 ) {
99104 this . notifications . shift ( ) ;
100105 }
101106
@@ -125,7 +130,6 @@ export default class GleapNotificationManager {
125130 // Render the notifications.
126131 for ( var i = 0 ; i < this . notifications . length ; i ++ ) {
127132 const notification = this . notifications [ i ] ;
128-
129133 var content = notification . data . text ;
130134
131135 // Try replacing the session name.
@@ -149,31 +153,45 @@ export default class GleapNotificationManager {
149153
150154 if ( notification . data . news ) {
151155 const renderDescription = ( ) => {
152- if ( notification . data . previewText && notification . data . previewText . length > 0 ) {
156+ if (
157+ notification . data . previewText &&
158+ notification . data . previewText . length > 0
159+ ) {
153160 return `<div class="gleap-notification-item-news-preview">${ notification . data . previewText } </div>` ;
154161 }
155162
156- return `${ notification . data . sender ? `
163+ return `${
164+ notification . data . sender
165+ ? `
157166 <div class="gleap-notification-item-news-sender">
158- ${ notification . data . sender . profileImageUrl &&
159- `<img src="${ notification . data . sender . profileImageUrl } " />`
167+ ${
168+ notification . data . sender . profileImageUrl &&
169+ `<img src="${ notification . data . sender . profileImageUrl } " />`
160170 } ${ notification . data . sender . name } </div>`
161- : ""
162- } `;
171+ : ""
172+ } `;
163173 } ;
164174
165175 // News preview
166176 elem . className = "gleap-notification-item-news" ;
167177 elem . innerHTML = `
168178 <div class="gleap-notification-item-news-container">
169- ${ notification . data . coverImageUrl && notification . data . coverImageUrl !== "" && ! notification . data . coverImageUrl . includes ( "NewsImagePlaceholder" ) ? `<img class="gleap-notification-item-news-image" src="${ notification . data . coverImageUrl } " />` : '' }
179+ ${
180+ notification . data . coverImageUrl &&
181+ notification . data . coverImageUrl !== "" &&
182+ ! notification . data . coverImageUrl . includes ( "NewsImagePlaceholder" )
183+ ? `<img class="gleap-notification-item-news-image" src="${ notification . data . coverImageUrl } " />`
184+ : ""
185+ }
170186 <div class="gleap-notification-item-news-content">
171187 <div class="gleap-notification-item-news-content-title">${ content } </div>
172188 ${ renderDescription ( ) }
173189 </div>
174190 </div>` ;
175191 } else if ( notification . data . checklist ) {
176- var progress = Math . round ( notification . data . currentStep / notification . data . totalSteps * 100 ) ;
192+ var progress = Math . round (
193+ ( notification . data . currentStep / notification . data . totalSteps ) * 100
194+ ) ;
177195 if ( progress < 100 ) {
178196 progress += 4 ;
179197 }
@@ -199,15 +217,17 @@ export default class GleapNotificationManager {
199217 // Notification item.
200218 elem . className = "gleap-notification-item" ;
201219 elem . innerHTML = `
202- ${ notification . data . sender &&
203- notification . data . sender . profileImageUrl &&
204- `<img src="${ notification . data . sender . profileImageUrl } " />`
205- }
220+ ${
221+ notification . data . sender &&
222+ notification . data . sender . profileImageUrl &&
223+ `<img src="${ notification . data . sender . profileImageUrl } " />`
224+ }
206225 <div class="gleap-notification-item-container">
207- ${ notification . data . sender
208- ? `<div class="gleap-notification-item-sender">${ notification . data . sender . name } </div>`
209- : ""
210- }
226+ ${
227+ notification . data . sender
228+ ? `<div class="gleap-notification-item-sender">${ notification . data . sender . name } </div>`
229+ : ""
230+ }
211231 <div class="gleap-notification-item-content">${ content } </div>
212232 </div>` ;
213233 }
@@ -245,9 +265,9 @@ export default class GleapNotificationManager {
245265 this . notificationContainer . classList . remove ( classNoButton ) ;
246266 if (
247267 flowConfig . feedbackButtonPosition ===
248- GleapFeedbackButtonManager . FEEDBACK_BUTTON_CLASSIC_LEFT ||
268+ GleapFeedbackButtonManager . FEEDBACK_BUTTON_CLASSIC_LEFT ||
249269 flowConfig . feedbackButtonPosition ===
250- GleapFeedbackButtonManager . FEEDBACK_BUTTON_BOTTOM_LEFT
270+ GleapFeedbackButtonManager . FEEDBACK_BUTTON_BOTTOM_LEFT
251271 ) {
252272 this . notificationContainer . classList . add ( classLeft ) ;
253273 }
@@ -265,6 +285,9 @@ export default class GleapNotificationManager {
265285 }
266286 }
267287
268- this . notificationContainer . setAttribute ( "dir" , GleapTranslationManager . getInstance ( ) . isRTLLayout ? "rtl" : "ltr" ) ;
288+ this . notificationContainer . setAttribute (
289+ "dir" ,
290+ GleapTranslationManager . getInstance ( ) . isRTLLayout ? "rtl" : "ltr"
291+ ) ;
269292 }
270293}
0 commit comments