@@ -27,9 +27,7 @@ export default class GleapNotificationManager {
27
27
return this . instance ;
28
28
}
29
29
30
- constructor ( ) {
31
-
32
- }
30
+ constructor ( ) { }
33
31
34
32
updateTabBarNotificationCount ( ) {
35
33
GleapEventManager . notifyEvent ( "unread-count-changed" , this . unreadCount ) ;
@@ -58,7 +56,14 @@ export default class GleapNotificationManager {
58
56
this . unreadNotificationsKey
59
57
) ;
60
58
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
+ }
62
67
this . renderNotifications ( ) ;
63
68
}
64
69
}
@@ -95,7 +100,7 @@ export default class GleapNotificationManager {
95
100
GleapAudioManager . ping ( ) ;
96
101
}
97
102
}
98
- if ( this . notifications . length > 3 ) {
103
+ if ( this . notifications . length > 2 ) {
99
104
this . notifications . shift ( ) ;
100
105
}
101
106
@@ -125,7 +130,6 @@ export default class GleapNotificationManager {
125
130
// Render the notifications.
126
131
for ( var i = 0 ; i < this . notifications . length ; i ++ ) {
127
132
const notification = this . notifications [ i ] ;
128
-
129
133
var content = notification . data . text ;
130
134
131
135
// Try replacing the session name.
@@ -149,31 +153,45 @@ export default class GleapNotificationManager {
149
153
150
154
if ( notification . data . news ) {
151
155
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
+ ) {
153
160
return `<div class="gleap-notification-item-news-preview">${ notification . data . previewText } </div>` ;
154
161
}
155
162
156
- return `${ notification . data . sender ? `
163
+ return `${
164
+ notification . data . sender
165
+ ? `
157
166
<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 } " />`
160
170
} ${ notification . data . sender . name } </div>`
161
- : ""
162
- } `;
171
+ : ""
172
+ } `;
163
173
} ;
164
174
165
175
// News preview
166
176
elem . className = "gleap-notification-item-news" ;
167
177
elem . innerHTML = `
168
178
<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
+ }
170
186
<div class="gleap-notification-item-news-content">
171
187
<div class="gleap-notification-item-news-content-title">${ content } </div>
172
188
${ renderDescription ( ) }
173
189
</div>
174
190
</div>` ;
175
191
} 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
+ ) ;
177
195
if ( progress < 100 ) {
178
196
progress += 4 ;
179
197
}
@@ -199,15 +217,17 @@ export default class GleapNotificationManager {
199
217
// Notification item.
200
218
elem . className = "gleap-notification-item" ;
201
219
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
+ }
206
225
<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
+ }
211
231
<div class="gleap-notification-item-content">${ content } </div>
212
232
</div>` ;
213
233
}
@@ -245,9 +265,9 @@ export default class GleapNotificationManager {
245
265
this . notificationContainer . classList . remove ( classNoButton ) ;
246
266
if (
247
267
flowConfig . feedbackButtonPosition ===
248
- GleapFeedbackButtonManager . FEEDBACK_BUTTON_CLASSIC_LEFT ||
268
+ GleapFeedbackButtonManager . FEEDBACK_BUTTON_CLASSIC_LEFT ||
249
269
flowConfig . feedbackButtonPosition ===
250
- GleapFeedbackButtonManager . FEEDBACK_BUTTON_BOTTOM_LEFT
270
+ GleapFeedbackButtonManager . FEEDBACK_BUTTON_BOTTOM_LEFT
251
271
) {
252
272
this . notificationContainer . classList . add ( classLeft ) ;
253
273
}
@@ -265,6 +285,9 @@ export default class GleapNotificationManager {
265
285
}
266
286
}
267
287
268
- this . notificationContainer . setAttribute ( "dir" , GleapTranslationManager . getInstance ( ) . isRTLLayout ? "rtl" : "ltr" ) ;
288
+ this . notificationContainer . setAttribute (
289
+ "dir" ,
290
+ GleapTranslationManager . getInstance ( ) . isRTLLayout ? "rtl" : "ltr"
291
+ ) ;
269
292
}
270
293
}
0 commit comments