Просмотр исходного кода

Merge branch 'brian_dev' of fyindr/siimee into dev

merges storing of info from notifications
tags/0.0.3^2
maeda 3 лет назад
Родитель
Сommit
4fd8f09913

+ 28
- 1
backend/lib/routes/membership/reveal.js Просмотреть файл

@@ -50,12 +50,39 @@ module.exports = {
50 50
                 const idsInGroup = memberships.map(
51 51
                     membership => membership.profile_id,
52 52
                 )
53
+
54
+                // Grab User Info from Users Table
55
+                const completeProfile = await profileService.getProfilesFor([profile_id], 'participant')
56
+
57
+                // Grab the TagAssociation that matches the revealed profile
58
+                // TODO: Check if there are multiple matching tags(?)(there shouldn't be)
59
+                const returnedTag = () => {
60
+                    let matchingTag
61
+                    tags.forEach(tagAssoc => {
62
+                        if (tagAssoc.grouping_id === grouping_id &&
63
+                            tagAssoc.profile_id === profile_id &&
64
+                            tagAssoc.tag_id === tag_id) {
65
+                            matchingTag = tagAssoc
66
+                        }
67
+                    })
68
+                    if (matchingTag)
69
+                        return matchingTag
70
+                    return console.error('ERROR: No matching tagAssociation')
71
+                }
72
+
73
+                const tag_description = returnedTag().tag.tag_description
74
+                // TODO: Refactor completeProfile[0]... code smell
75
+                const revealInfo = completeProfile[0][tag_description]
76
+
53 77
                 idsInGroup.forEach(profile_id => {
54 78
                     request.server.methods.notify(
55 79
                         `${profile_id}.stonk`,
56 80
                         {
57
-                            name: 'REVEALED INFO',
81
+                            name: 'REVEALED_INFO',
82
+                            revealed_info: revealInfo,
83
+                            grouping_id: grouping_id,
58 84
                             tag: tag_id,
85
+                            description: tag_description,
59 86
                             type: 'info',
60 87
                         },
61 88
                         h,

+ 1
- 1
frontend/src/components/SideBar.vue Просмотреть файл

@@ -5,7 +5,7 @@ aside.sidebar.w-flex.column.pa8
5 5
     nav.temp-control-box
6 6
         input(v-model="switchToPID" @keyup.enter="$emit('updatePid', switchToPID)")
7 7
         button(@click="$emit('updatePid', switchToPID)") switch profile
8
-    
8
+
9 9
 </template>
10 10
 
11 11
 <script>

+ 1
- 1
frontend/src/services/chat.service.js Просмотреть файл

@@ -116,7 +116,7 @@ class Chatter {
116 116
         } catch (error) {
117 117
             console.error('[chatter]', error)
118 118
         }
119
-        const channelHistory = pastMessages.channels[channel]
119
+        const channelHistory = pastMessages && pastMessages.channels ? pastMessages.channels[channel] : null
120 120
         console.log('channelHistory :>> ', channelHistory)
121 121
         return channelHistory
122 122
             ? channelHistory.map(msg => ({

+ 25
- 2
frontend/src/services/notification.service.js Просмотреть файл

@@ -1,5 +1,5 @@
1 1
 import { remote } from '../utils/db.js'
2
-
2
+import { currentProfile } from '../services'
3 3
 /**
4 4
  * Base notifier class
5 5
  * @param {number} profileId needed to listen for events for this profile
@@ -29,12 +29,35 @@ class StonkAlert extends Toaster {
29 29
         this.stonks = {}
30 30
         this.listenFor(`${profileId}.${this.event}`, message => {
31 31
             const parsed = JSON.parse(message.data)
32
+            if (parsed.name === 'REVEALED_INFO') {
33
+                this._appendTagsToGrouping(parsed)
34
+            }
32 35
             this.stonks[parsed.name] = parsed
33 36
             waveCb(this._formatToast(parsed), parsed.type)
34 37
         })
35 38
     }
36 39
     _formatToast(parsed) {
37
-        return `${parsed.name}: ${parsed.profile_id} ${parsed.order} at ${parsed.price}`
40
+        if (parsed.revealed_info) {
41
+            return `${parsed.name}: ${parsed.revealed_info} at ${parsed.type}`
42
+        } else {
43
+            return `${parsed.name}: ${parsed.profile_id} ${parsed.order} at ${parsed.price}`
44
+        }
45
+    }
46
+    _appendTagsToGrouping(parsed) {
47
+        const foundGrouping = currentProfile.groupings.find(grouping =>
48
+            grouping.grouping_id === parsed.grouping_id
49
+        )
50
+        if (foundGrouping) {
51
+            const tagFromNotification = {
52
+                is_active: 1,
53
+                tag_category: "reveal",
54
+                tag_description: parsed.description,
55
+                tag_id: parsed.tag
56
+            }
57
+            const target_desc = parsed.description
58
+            tagFromNotification[target_desc] = parsed.revealed_info
59
+            foundGrouping.profile.tags.push(tagFromNotification)
60
+        }
38 61
     }
39 62
 }
40 63
 

+ 13
- 3
frontend/src/views/ChatView.vue Просмотреть файл

@@ -13,10 +13,16 @@ main.view--chat
13 13
             .w-flex.row
14 14
                 button(@click='reveal(7)') reveal my name
15 15
                 button(@click='reveal(8)') reveal my email
16
-            p you revealed: 
17
-                span(v-if="grouping.revealed[profile.id]") {{ grouping.revealed }}
16
+                // TODO: Remove later, only for testing
17
+                button(@click='checkData()') check data
18
+            p you revealed:
19
+                span(v-if="grouping.revealed[profile.id.value]")
20
+                    ul(v-for="reveal in grouping.revealed[profile.id.value]")
21
+                        li {{ reveal.description }} : {{ profile._profile[reveal.description] }}
18 22
             p they revealed:
19
-                span(v-if="grouping.revealed[grouping.profile.profile_id]") {{ grouping.revealed[grouping.profile.profile_id] }}
23
+                span(v-if="grouping.revealed[grouping.profile.profile_id]")
24
+                    ul(v-for="reveal in grouping.revealed[grouping.profile.profile_id]")
25
+                        li {{ reveal.description }} : {{ grouping.profile[reveal.description] }}
20 26
 
21 27
     article
22 28
         template(v-if='isLoading')
@@ -83,6 +89,10 @@ export default {
83 89
         async reveal(tagId) {
84 90
             const grouping = this.getGrouping()
85 91
             await grouping.reveal(currentProfile.id.value, tagId)
92
+         },
93
+        // TODO: remove, only for testing reveal()
94
+        async checkData() {
95
+            console.log(currentProfile)
86 96
         },
87 97
         /**
88 98
          * Pubnub message callback fires when message event

Загрузка…
Отмена
Сохранить