Преглед изворни кода

: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 година
родитељ
комит
d319e04acf
2 измењених фајлова са 20 додато и 7 уклоњено
  1. 3
    3
      frontend/src/services/chat.service.js
  2. 17
    4
      frontend/src/views/HomeView.vue

+ 3
- 3
frontend/src/services/chat.service.js Прегледај датотеку

@@ -20,9 +20,9 @@ const providerMethods = {
20 20
  * to notify the frontend ui of a new message
21 21
  */
22 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 Прегледај датотеку

@@ -12,8 +12,10 @@ main.view--home(style="display:flex; flex-direction:column; gap: 40px; margin-to
12 12
     
13 13
     p(v-else-if="matches.length===0") No matches.
14 14
     p(v-else) Loading...
15
+    <w-flex class="wrap">
15 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 19
 </template>
18 20
 
19 21
 <script>
@@ -21,7 +23,7 @@ main.view--home(style="display:flex; flex-direction:column; gap: 40px; margin-to
21 23
 import ProfileCardList from '../components/ProfileCardList.vue'
22 24
 
23 25
 import { Card } from '../entities'
24
-import { fetchQueueByProfileId, fetchMembershipsByProfileId } from '../services'
26
+import { fetchQueueByProfileId, fetchMembershipsByProfileId, currentProfile } from '../services'
25 27
 import { mixins } from '../utils'
26 28
 
27 29
 /** Callback used to format incoming into card */
@@ -71,9 +73,10 @@ export default {
71 73
             }
72 74
             this.loading = false
73 75
         },
74
-        notify() {
76
+        // this can be placed in utils/notification.js
77
+        notify(payload) {
75 78
             this.$waveui.notify({
76
-            message: 'New Message',
79
+            message: payload.timetoken,
77 80
             timeout: 6000,
78 81
             bgColor: 'white',
79 82
             color: 'success',
@@ -84,6 +87,16 @@ export default {
84 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 102
 </script>

Loading…
Откажи
Сачувај