@@ -59,9 +59,27 @@ const handlebarsFallbackHelper = (value, fallbackValue) => {
59
59
return new Handlebars . SafeString ( out ) ;
60
60
} ;
61
61
62
+ /**
63
+ * Handlebars helper which displays single or plural noun
64
+ *
65
+ * Example:
66
+ * ```
67
+ * {{pluralize count resource resources}}
68
+ * ```
69
+ * Will output `resource` if `count` equals or less than 1; otherwise `resources`
70
+ *
71
+ * @param {Number } count quantity
72
+ * @param {String } single noun
73
+ * @param {String } plural nouns
74
+ */
75
+ const handlebarsPluralizeHelper = ( number , single , plural ) => {
76
+ return number > 1 ? plural : single ;
77
+ } ;
78
+
62
79
// register handlebars helpers
63
80
Handlebars . registerHelper ( "showMore" , handlebarsShowMoreHelper ) ;
64
81
Handlebars . registerHelper ( "fallback" , handlebarsFallbackHelper ) ;
82
+ Handlebars . registerHelper ( "pluralize" , handlebarsPluralizeHelper ) ;
65
83
66
84
export const renderGoTo = ( goTo , contents ) => {
67
85
let goToHandlebars = "" ;
@@ -319,12 +337,6 @@ const getNotificationRule = (notification) => {
319
337
) ;
320
338
}
321
339
322
- if ( notification . contents . textIsPlural != null ) {
323
- match =
324
- match &&
325
- notification . contents . textIsPlural === _notificationRule . textIsPlural ;
326
- }
327
-
328
340
return match ;
329
341
} ) ;
330
342
@@ -352,7 +364,6 @@ const isNotificationRuleEqual = (rule1, rule2) => {
352
364
"projectRole" ,
353
365
"topcoderRole" ,
354
366
"originator" ,
355
- "textIsPlural" ,
356
367
] ;
357
368
const essentialRule1 = _ . pick ( rule1 , ESSENTIAL_RULE_PROPERTIES ) ;
358
369
const essentialRule2 = _ . pick ( rule2 , ESSENTIAL_RULE_PROPERTIES ) ;
@@ -579,17 +590,6 @@ export const preRenderNotifications = (notifications) => {
579
590
580
591
// --- TaaS --- //
581
592
582
- const prepareTaaSNotificationContents = ( eventType , contents ) => {
583
- if ( eventType === EVENT_TYPE . TAAS . RESOURCE_BOOKING_EXPIRATION ) {
584
- return {
585
- ...contents ,
586
- textIsPlural : contents . numOfExpiringResourceBookings > 1 ,
587
- } ;
588
- }
589
-
590
- return contents ;
591
- } ;
592
-
593
593
export const prepareTaaSNotifications = ( rawNotifications ) => {
594
594
const notifications = rawNotifications . map ( ( rawNotification ) => ( {
595
595
id : `${ rawNotification . id } ` ,
@@ -603,10 +603,7 @@ export const prepareTaaSNotifications = (rawNotifications) => {
603
603
date : rawNotification . createdAt ,
604
604
isRead : rawNotification . read ,
605
605
seen : rawNotification . seen ,
606
- contents : prepareTaaSNotificationContents (
607
- rawNotification . type ,
608
- rawNotification . contents
609
- ) ,
606
+ contents : rawNotification . contents ,
610
607
version : rawNotification . version ,
611
608
} ) ) ;
612
609
0 commit comments