浏览代码

Merge branch 'msg-fact' of fyindr/siimee into dev

tags/0.0.1^2
maeda 3 年前
父节点
当前提交
0a3bdd9002
共有 2 个文件被更改,包括 34 次插入11 次删除
  1. 9
    9
      frontend/src/services/chat.service.js
  2. 25
    2
      frontend/src/views/HomeView.vue

+ 9
- 9
frontend/src/services/chat.service.js 查看文件

@@ -13,8 +13,9 @@ const providerMethods = {
13 13
     subscribe: () => console.error('no provider subscribe method set'),
14 14
     listen: () => console.error('no provider listen method set'),
15 15
 }
16
-
17 16
 /**
17
+ * 
18
+ * 
18 19
  * Breaking out as much pubnub specific flavor
19 20
  */
20 21
 const setupPubnub = async uuid => {
@@ -37,15 +38,10 @@ const setupPubnub = async uuid => {
37 38
 }
38 39
 
39 40
 class ChatMessage {
40
-    constructor({ title, description }) {
41
-        ;(this.title = title), (this.description = description)
41
+    constructor(message) {
42
+        this.description = message
42 43
     }
43 44
 }
44
-
45
-const testMessage = new ChatMessage({
46
-    title: 'testing',
47
-    description: 'hello world!',
48
-})
49 45
 const MAIN_CHANNEL = 'Channel-Siimee'
50 46
 
51 47
 /** Singleton that holds all our chat information */
@@ -101,7 +97,10 @@ class Chatter {
101 97
      */
102 98
     async publish(channel, message) {
103 99
         // console.log('publishing message to channel:', channel)
104
-        return providerMethods.publish({ channel, message })
100
+        return providerMethods.publish({ 
101
+            channel,
102
+            message: new ChatMessage(message)
103
+        })
105 104
     }
106 105
     /**
107 106
      * Subscribe to a channels
@@ -129,6 +128,7 @@ class Chatter {
129 128
         this.subscriptions = [MAIN_CHANNEL]
130 129
         console.warn('chatter stop no implemented')
131 130
     }
131
+
132 132
 }
133 133
 
134 134
 export { Chatter }

+ 25
- 2
frontend/src/views/HomeView.vue 查看文件

@@ -12,14 +12,14 @@ 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
-
16 15
 </template>
17 16
 
18 17
 <script>
18
+    import 'wave-ui/dist/wave-ui.css'
19 19
 import ProfileCardList from '../components/ProfileCardList.vue'
20 20
 
21 21
 import { Card } from '../entities'
22
-import { fetchQueueByProfileId, fetchMembershipsByProfileId } from '../services'
22
+import { fetchQueueByProfileId, fetchMembershipsByProfileId, currentProfile } from '../services'
23 23
 import { mixins } from '../utils'
24 24
 
25 25
 /** Callback used to format incoming into card */
@@ -69,6 +69,29 @@ export default {
69 69
             }
70 70
             this.loading = false
71 71
         },
72
+        // this can be placed in utils/notification.js
73
+        notify(payload) {
74
+            this.$waveui.notify({
75
+            message: payload.timetoken,
76
+            timeout: 6000,
77
+            bgColor: 'white',
78
+            color: 'success',
79
+            dismiss: false,
80
+            shadow: true,
81
+            round: true,
82
+            sm: true,
83
+            icon: 'wi-star'
84
+        })
85
+        },
86
+        //  a way to send a message to a user for development purposes and testing
87
+        async chat()  {
88
+           const chatter = currentProfile.chatter
89
+           const res = await chatter.publish(chatter.subscriptions[0],{
90
+            title: 'New Message',
91
+            description: 'This is a new message',
92
+           })
93
+           this.notify(res)
94
+        }
72 95
     },
73 96
 }
74 97
 </script>

正在加载...
取消
保存