|
|
@@ -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,6 +29,9 @@ 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
|
})
|
|
|
@@ -40,6 +43,44 @@ class StonkAlert extends Toaster {
|
|
40
|
43
|
return `${parsed.name}: ${parsed.profile_id} ${parsed.order} at ${parsed.price}`
|
|
41
|
44
|
}
|
|
42
|
45
|
}
|
|
|
46
|
+ _appendTagsToGrouping(parsed) {
|
|
|
47
|
+ console.log('_appendTagsToGrouping fired')
|
|
|
48
|
+ // look inside the current profile for the groupings
|
|
|
49
|
+ // get the grouping with the correct grouping id
|
|
|
50
|
+ const foundGrouping = currentProfile.groupings.find(grouping =>
|
|
|
51
|
+ grouping.grouping_id === parsed.grouping_id
|
|
|
52
|
+ )
|
|
|
53
|
+
|
|
|
54
|
+ if (foundGrouping) {
|
|
|
55
|
+ // create a tag from the notification called tagFromNotification
|
|
|
56
|
+ const tagFromNotification = {
|
|
|
57
|
+ grouping_id: parsed.grouping_id,
|
|
|
58
|
+ is_deleted: 0,
|
|
|
59
|
+ profile_id: currentProfile._profile.profile_id,
|
|
|
60
|
+ target_id: foundGrouping.profile.profile_id,
|
|
|
61
|
+ tag: {
|
|
|
62
|
+ is_active: 1,
|
|
|
63
|
+ tag_category: "reveal",
|
|
|
64
|
+ tag_description: parsed.description,
|
|
|
65
|
+ tag_id: parsed.tag
|
|
|
66
|
+ // tag_association:
|
|
|
67
|
+ }
|
|
|
68
|
+ }
|
|
|
69
|
+ const target_desc = `target_${parsed.description}`
|
|
|
70
|
+ tagFromNotification.tag[target_desc] = parsed.revealed_info
|
|
|
71
|
+
|
|
|
72
|
+ // grouping.tags.push(tagFromNotification)
|
|
|
73
|
+ foundGrouping.tags.push(tagFromNotification)
|
|
|
74
|
+ console.log(currentProfile)
|
|
|
75
|
+ // TODO: finish this function, while it is viewable in the console
|
|
|
76
|
+ // afterwards, I am confused as to how to "find the target"
|
|
|
77
|
+
|
|
|
78
|
+ // find the target (other person in the grouping) and store the
|
|
|
79
|
+ // information that came from the notification (target.profile.email
|
|
|
80
|
+ // = email target.profile.name = name)
|
|
|
81
|
+ // find a grouping_id from the notification
|
|
|
82
|
+ }
|
|
|
83
|
+ }
|
|
43
|
84
|
}
|
|
44
|
85
|
|
|
45
|
86
|
export { Toaster, StonkAlert }
|