Bläddra i källkod

:bug: Addressing reveal bug, in progress...

tags/0.0.3^2
tomit4 3 år sedan
förälder
incheckning
77835c6c5e

+ 2
- 1
.gitignore Visa fil

@@ -6,4 +6,5 @@ dist-ssr
6 6
 **/.env
7 7
 .nyc_output
8 8
 **/generated/_*
9
-**/.vscode
9
+**/.vscode
10
+**/*.vim

+ 2
- 1
backend/lib/routes/membership/reveal.js Visa fil

@@ -50,7 +50,8 @@ module.exports = {
50 50
                 const idsInGroup = memberships.map(
51 51
                     membership => membership.profile_id,
52 52
                 )
53
-
53
+                if (idsInGroup.length > 2)
54
+                    return console.error('ERROR: idsInGroup cannot have more than 2 entries: ', idsInGroup)
54 55
                 // Grab User Info from Users Table
55 56
                 const completeProfile = await profileService.getProfilesFor([profile_id], 'participant')
56 57
 

+ 4
- 1
backend/lib/services/profile/index.js Visa fil

@@ -63,7 +63,10 @@ module.exports = class ProfileService extends Schmervice.Service {
63 63
             tag => this.tagLookup[tag.tag_id],
64 64
         )
65 65
         const complete = new profiler.CompleteProfile(matchingProfile, true)
66
-        return this.setDefaults(complete)
66
+        // TODO: Refactor to use this.setDefaults(), currently does not play
67
+        // nice with reveal functionality
68
+        return complete
69
+        // return this.setDefaults(complete)
67 70
     }
68 71
 
69 72
     async getCompleteProfilesFor(userId, type) {

+ 0
- 1
frontend/src/components/ProfileCard.vue Visa fil

@@ -67,7 +67,6 @@ import PairingButton from './PairingButton.vue'
67 67
 
68 68
 const router = useRouter()
69 69
 const isPaired = ref(true)
70
-// const isPaired = ref(false)
71 70
 
72 71
 const props = defineProps({
73 72
     card: {

+ 3
- 1
frontend/src/entities/response/response.schema.js Visa fil

@@ -8,7 +8,9 @@ const responseSchema = Joi.object({
8 8
     profile_id: Joi.number(),
9 9
     response_id: Joi.number(),
10 10
     response_key_id: Joi.number(),
11
-    val: Joi.string(),
11
+    // TODO: troubleshoot later, suppressed validation warning for now
12
+    // val: Joi.string(),
13
+    val: Joi.any(),
12 14
 })
13 15
 
14 16
 export { responseSchema }

+ 2
- 1
frontend/src/services/grouping.service.js Visa fil

@@ -1,6 +1,6 @@
1 1
 import { db } from '../utils/db.js'
2 2
 import { Grouping, Profile } from '../entities/index.js'
3
-
3
+import { ref } from 'vue'
4 4
 /**
5 5
  * Get Memberships associated with a single Profile from the database and
6 6
  * create a class from the data and
@@ -26,6 +26,7 @@ const fetchMembershipsByProfileId = async profileId => {
26 26
                     `/profile/${profileId}/tags/${grouping.grouping_id}`,
27 27
                 )
28 28
                 grouping.tags = [...targetTags, ...profileTags]
29
+                grouping.revealedFromNotification = ref([])
29 30
                 grouping._loading.value = false
30 31
                 validGroupingInstances.push(grouping)
31 32
             }

+ 4
- 2
frontend/src/services/notification.service.js Visa fil

@@ -52,11 +52,13 @@ class StonkAlert extends Toaster {
52 52
                 is_active: 1,
53 53
                 tag_category: "reveal",
54 54
                 tag_description: parsed.description,
55
-                tag_id: parsed.tag
55
+                tag_id: parsed.tag,
56
+                for_profile_id: foundGrouping.profile.profile_id
56 57
             }
57 58
             const target_desc = parsed.description
58 59
             tagFromNotification[target_desc] = parsed.revealed_info
59
-            foundGrouping.profile.tags.push(tagFromNotification)
60
+            foundGrouping.profile.reveal.push(tagFromNotification)
61
+            foundGrouping.revealedFromNotification.value.push(tagFromNotification)
60 62
         }
61 63
     }
62 64
 }

+ 18
- 9
frontend/src/views/ChatView.vue Visa fil

@@ -15,14 +15,20 @@ main.view--chat
15 15
                 button(@click='reveal(8)') reveal my email
16 16
                 // TODO: Remove later, only for testing
17 17
                 button(@click='checkData()') check data
18
+            // BUG: grouping.revealed[profile.id.value] needs to be deduped
18 19
             p you revealed:
19 20
                 span(v-if="grouping.revealed[profile.id.value]")
20 21
                     ul(v-for="reveal in grouping.revealed[profile.id.value]")
21
-                        li {{ reveal.description }} : {{ profile._profile[reveal.description] }}
22
+                        li {{ reveal.description }}: {{ profile._profile[reveal.description] }}
23
+            // BUG: they revealed doesn't persist, both for loops are currently necessary
22 24
             p they revealed:
23
-                span(v-if="theyRevealed")
24
-                    ul(v-for="reveal in theyRevealed")
25
-                        li {{ reveal.description }} : {{ grouping.profile[reveal.description] }}
25
+                // BUG: persists, but doesn't display upon reveal
26
+                span(v-if="grouping.revealed[target.profile_id]")
27
+                    ul(v-for="reveal in grouping.revealed[target.profile_id]")
28
+                        li {{ reveal.description }}: {{ target[reveal.description] }}
29
+            // BUG: reveals, but does not persist
30
+            ul(v-for="revealed in grouping.revealedFromNotification")
31
+                li(v-if="revealed[revealed.tag_description] !== profile._profile[revealed.tag_description]") {{ revealed.tag_description }}: {{ revealed[revealed.tag_description] }}
26 32
 
27 33
     article
28 34
         template(v-if='isLoading')
@@ -66,14 +72,13 @@ export default {
66 72
         toSend: '',
67 73
         messages: [],
68 74
         grouping: {},
75
+        them: {},
69 76
     }),
70 77
     // TODO: Make sure grouping.profile.profile_id actually exists
71 78
     computed: {
72 79
         theyRevealed() {
73
-            return this.grouping && this.grouping.revealed[this.grouping.profile.profile_id] ?
74
-                this.grouping.revealed[this.grouping.profile.profile_id] :
75
-                []
76
-        }
80
+            return this.them
81
+        },
77 82
     },
78 83
     watch: {
79 84
         async profile() {
@@ -88,6 +93,7 @@ export default {
88 93
         this.loadTargetProfile()
89 94
         currentProfile._loading.value = true
90 95
         this.grouping = this.getGrouping()
96
+        this.them = this.grouping.profile
91 97
         this.messages = await currentProfile.chatter.getHistory(this.grouping.grouping_name)
92 98
         console.log('this.messages :>> ', this.messages)
93 99
         currentProfile.chatter.setOnMessage(this._onMessage)
@@ -100,7 +106,7 @@ export default {
100 106
          },
101 107
         // TODO: remove, only for testing reveal()
102 108
         async checkData() {
103
-            console.log(currentProfile)
109
+            console.log('currentProfile :=>', currentProfile)
104 110
         },
105 111
         /**
106 112
          * Pubnub message callback fires when message event
@@ -113,6 +119,9 @@ export default {
113 119
         },
114 120
         // TODO: test this
115 121
         getGrouping() {
122
+            if (this.$route.params.pid === currentProfile.profile_id) {
123
+                console.warn('WARNING :=> You cannot chat with yourself!!!')
124
+            }
116 125
             return currentProfile.groupings.find(
117 126
                 g => g.profile.profile_id == this.$route.params.pid,
118 127
             )

Laddar…
Avbryt
Spara