Pārlūkot izejas kodu

:gears: message factory recieving new messages and consoling from the chatter, TODO write function to trigger frontend notification

tags/0.0.1^2
K Rob 3 gadus atpakaļ
vecāks
revīzija
d319e04acf

+ 3
- 3
frontend/src/services/chat.service.js Parādīt failu

20
  * to notify the frontend ui of a new message
20
  * to notify the frontend ui of a new message
21
  */
21
  */
22
 const messageFactory = {
22
 const messageFactory = {
23
-    success: () => console.log('success message for sent message'),
24
-    received: (e) => console.log('received message for received message', e),
25
-    error: () => console.log('error message for failed message'),
23
+    success: () => console.log('notification for successful sent message'),
24
+    received: (e) => console.log('notification for received message', e.message),
25
+    error: () => console.log('notification for failed message'),
26
 }
26
 }
27
 
27
 
28
 /**
28
 /**

+ 17
- 4
frontend/src/views/HomeView.vue Parādīt failu

12
     
12
     
13
     p(v-else-if="matches.length===0") No matches.
13
     p(v-else-if="matches.length===0") No matches.
14
     p(v-else) Loading...
14
     p(v-else) Loading...
15
+    <w-flex class="wrap">
15
     <w-button @click="notify" bg-color="success"> notify </w-button>
16
     <w-button @click="notify" bg-color="success"> notify </w-button>
16
-    
17
+      <w-button @click="chat" bg-color="error"> chat </w-button>
18
+    </w-flex> 
17
 </template>
19
 </template>
18
 
20
 
19
 <script>
21
 <script>
21
 import ProfileCardList from '../components/ProfileCardList.vue'
23
 import ProfileCardList from '../components/ProfileCardList.vue'
22
 
24
 
23
 import { Card } from '../entities'
25
 import { Card } from '../entities'
24
-import { fetchQueueByProfileId, fetchMembershipsByProfileId } from '../services'
26
+import { fetchQueueByProfileId, fetchMembershipsByProfileId, currentProfile } from '../services'
25
 import { mixins } from '../utils'
27
 import { mixins } from '../utils'
26
 
28
 
27
 /** Callback used to format incoming into card */
29
 /** Callback used to format incoming into card */
71
             }
73
             }
72
             this.loading = false
74
             this.loading = false
73
         },
75
         },
74
-        notify() {
76
+        // this can be placed in utils/notification.js
77
+        notify(payload) {
75
             this.$waveui.notify({
78
             this.$waveui.notify({
76
-            message: 'New Message',
79
+            message: payload.timetoken,
77
             timeout: 6000,
80
             timeout: 6000,
78
             bgColor: 'white',
81
             bgColor: 'white',
79
             color: 'success',
82
             color: 'success',
84
             icon: 'wi-star'
87
             icon: 'wi-star'
85
         })
88
         })
86
         },
89
         },
90
+        //  a way to send a message to a user for development purposes and testing
91
+        async chat()  {
92
+           const chatter = currentProfile.chatter
93
+           const res = await chatter.publish(chatter.subscriptions[0],{
94
+            title: 'New Message',
95
+            description: 'This is a new message',
96
+           })
97
+           this.notify(res)
98
+        }
99
+
87
     },
100
     },
88
 }
101
 }
89
 </script>
102
 </script>

Notiek ielāde…
Atcelt
Saglabāt