@@ -23,16 +23,13 @@ export const sendmessage = (message, details) => async (dispatch, getState) => {
23
23
) {
24
24
lastMessageObj = {
25
25
showDateInfo : true ,
26
- rendered : true ,
27
26
} ;
28
27
}
29
28
30
29
// Case 2: If there is no messages
31
30
if ( hasInMap && typeof getInMap . message === 'undefined' ) {
32
31
lastMessageObj = {
33
32
showDateInfo : true ,
34
- rendered : true ,
35
-
36
33
} ;
37
34
}
38
35
@@ -165,7 +162,7 @@ export const RecieveMessage = () => (dispatch) => {
165
162
channel : message . channel ,
166
163
to : message . to ,
167
164
...parsed ,
168
- showDateInfo : message . showDateInfo || null ,
165
+ showDateInfo : message . showDateInfo ,
169
166
} ;
170
167
await db . message . add ( final ) ;
171
168
const locatioHref = window . location . href ;
@@ -180,19 +177,23 @@ export const RecieveMessage = () => (dispatch) => {
180
177
messageTone . play ( ) ;
181
178
if ( notificationPermission === 'granted' ) {
182
179
try {
183
- const notificationTitle = `${ message . displayName } ` ;
184
- const notificationOptions = {
185
- body : parsed . message ,
186
- icon : message . photoURL ,
187
- vibrate : [ 100 , 50 , 100 ] ,
188
- data : { url : `https://relp.now.sh/r/${ message . channel } ` } ,
189
- actions : [ { action : 'open_url' , title : 'Read Message' } ] ,
190
- click_action : `https://relp.now.sh/r/${ message . channel } ` ,
191
- } ;
192
- navigator . serviceWorker . getRegistrations ( )
193
- . then ( ( req ) => {
194
- req . showNotification ( notificationTitle , notificationOptions ) ;
195
- } ) ;
180
+ navigator . serviceWorker . ready . then ( ( registration ) => {
181
+ const notificationTitle = `${ message . displayName } ` ;
182
+ const notificationOptions = {
183
+ body : parsed . message ,
184
+ icon : message . photoURL ,
185
+ vibrate : [ 500 , 110 , 500 , 110 , 450 , 110 , 200 , 110 , 170 , 40 , 450 , 110 , 200 , 110 , 170 , 40 , 500 ] ,
186
+ actions : [ { action : 'open_url' , title : 'Read Message' } ] ,
187
+ click_action : `https://relp.now.sh/r/${ message . channel } ` ,
188
+ tag : parsed . channel ,
189
+ renotify : true ,
190
+ requireInteraction : true ,
191
+ } ;
192
+ registration . getRegistrations ( )
193
+ . then ( ( req ) => {
194
+ req . showNotification ( notificationTitle , notificationOptions ) ;
195
+ } ) ;
196
+ } ) ;
196
197
} catch ( err ) {
197
198
console . log ( err ) ;
198
199
}
0 commit comments