Events Reactions Implemented
This commit is contained in:
1 parent
de2c1435fe
commit
3f2871acea
3 files changed
+98
-8
No files matched your search
+53
-7
@@ -24,13 +24,20 @@ exports.newEvent = function newEvent() {
|
||||
QUOTE_REPOST_TRADE: 23,
|
||||
FOLLOW_USER_PROFILE_TRADE_POSTS: 24,
|
||||
UNFOLLOW_USER_PROFILE_TRADE_POSTS: 25,
|
||||
REACTION_LIKE: 100,
|
||||
REACTION_LOVE: 101,
|
||||
REACTION_HAHA: 102,
|
||||
REACTION_WOW: 103,
|
||||
REACTION_SAD: 104,
|
||||
REACTION_ANGRY: 105,
|
||||
REACTION_HUG: 106
|
||||
ADD_REACTION_LIKE: 100,
|
||||
ADD_REACTION_LOVE: 101,
|
||||
ADD_REACTION_HAHA: 102,
|
||||
ADD_REACTION_WOW: 103,
|
||||
ADD_REACTION_SAD: 104,
|
||||
ADD_REACTION_ANGRY: 105,
|
||||
ADD_REACTION_HUG: 106,
|
||||
REMOVE_REACTION_LIKE: 200,
|
||||
REMOVE_REACTION_LOVE: 201,
|
||||
REMOVE_REACTION_HAHA: 202,
|
||||
REMOVE_REACTION_WOW: 203,
|
||||
REMOVE_REACTION_SAD: 204,
|
||||
REMOVE_REACTION_ANGRY: 205,
|
||||
REMOVE_REACTION_HUG: 206
|
||||
}
|
||||
|
||||
return thisObject
|
||||
@@ -152,5 +159,44 @@ exports.newEvent = function newEvent() {
|
||||
}
|
||||
return
|
||||
}
|
||||
/*
|
||||
Is is a Reaction?
|
||||
*/
|
||||
if (
|
||||
event.eventType === EVENT_TYPES.ADD_REACTION_LIKE ||
|
||||
event.eventType === EVENT_TYPES.ADD_REACTION_LOVE ||
|
||||
event.eventType === EVENT_TYPES.ADD_REACTION_HAHA ||
|
||||
event.eventType === EVENT_TYPES.ADD_REACTION_WOW ||
|
||||
event.eventType === EVENT_TYPES.ADD_REACTION_SAD ||
|
||||
event.eventType === EVENT_TYPES.ADD_REACTION_ANGRY ||
|
||||
event.eventType === EVENT_TYPES.ADD_REACTION_HUG
|
||||
) {
|
||||
let targetPost = NT.memory.POSTS.get(event.targetPostHash)
|
||||
|
||||
if (targetPost === undefined) {
|
||||
throw ('Target Post Not Found')
|
||||
}
|
||||
|
||||
targetPost.addReaction(event.eventType - 100)
|
||||
return
|
||||
}
|
||||
if (
|
||||
event.eventType === EVENT_TYPES.REMOVE_REACTION_LIKE ||
|
||||
event.eventType === EVENT_TYPES.REMOVE_REACTION_LOVE ||
|
||||
event.eventType === EVENT_TYPES.REMOVE_REACTION_HAHA ||
|
||||
event.eventType === EVENT_TYPES.REMOVE_REACTION_WOW ||
|
||||
event.eventType === EVENT_TYPES.REMOVE_REACTION_SAD ||
|
||||
event.eventType === EVENT_TYPES.REMOVE_REACTION_ANGRY ||
|
||||
event.eventType === EVENT_TYPES.REMOVE_REACTION_HUG
|
||||
) {
|
||||
let targetPost = NT.memory.POSTS.get(event.targetPostHash)
|
||||
|
||||
if (targetPost === undefined) {
|
||||
throw ('Target Post Not Found')
|
||||
}
|
||||
|
||||
targetPost.removeReaction(event.eventType - 200)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,9 @@ exports.newPost = function newPost() {
|
||||
timestamp: undefined,
|
||||
replies: undefined,
|
||||
targetPost: undefined,
|
||||
reactionsCount: undefined,
|
||||
addReaction: addReaction,
|
||||
removeReactions: removeReaction,
|
||||
initialize: initialize,
|
||||
finalize: finalize
|
||||
}
|
||||
@@ -23,6 +26,25 @@ exports.newPost = function newPost() {
|
||||
QUOTE_REPOST_TRADE: 23
|
||||
}
|
||||
|
||||
const REACTION_TYPES = {
|
||||
REACTION_LIKE: 0,
|
||||
REACTION_LOVE: 1,
|
||||
REACTION_HAHA: 2,
|
||||
REACTION_WOW: 3,
|
||||
REACTION_SAD: 4,
|
||||
REACTION_ANGRY: 5,
|
||||
REACTION_HUG: 6
|
||||
}
|
||||
|
||||
thisObject.reactionsCount = new Map()
|
||||
thisObject.reactionsCount.set(REACTION_TYPES.REACTION_LIKE, 0)
|
||||
thisObject.reactionsCount.set(REACTION_TYPES.REACTION_LOVE, 0)
|
||||
thisObject.reactionsCount.set(REACTION_TYPES.REACTION_HAHA, 0)
|
||||
thisObject.reactionsCount.set(REACTION_TYPES.REACTION_WOW, 0)
|
||||
thisObject.reactionsCount.set(REACTION_TYPES.REACTION_SAD, 0)
|
||||
thisObject.reactionsCount.set(REACTION_TYPES.REACTION_ANGRY, 0)
|
||||
thisObject.reactionsCount.set(REACTION_TYPES.REACTION_HUG, 0)
|
||||
|
||||
return thisObject
|
||||
|
||||
function finalize() {
|
||||
@@ -77,4 +99,24 @@ exports.newPost = function newPost() {
|
||||
thisObject.targetPost.replies.push(thisObject)
|
||||
}
|
||||
}
|
||||
|
||||
function addReaction(reactionType) {
|
||||
let reactionCount = thisObject.reactionsCount.get(reactionType)
|
||||
|
||||
if (reactionCount === undefined) {
|
||||
throw ('Reaction Type Not Supported.')
|
||||
}
|
||||
|
||||
thisObject.reactionsCount.set(reactionType, reactionsCount + 1)
|
||||
}
|
||||
|
||||
function removeReaction(reactionType) {
|
||||
let reactionCount = thisObject.reactionsCount.get(reactionType)
|
||||
|
||||
if (reactionCount === undefined) {
|
||||
throw ('Reaction Type Not Supported.')
|
||||
}
|
||||
|
||||
thisObject.reactionsCount.set(reactionType, reactionsCount - 1)
|
||||
}
|
||||
}
|
||||
@@ -360,7 +360,9 @@ function newGovernanceUserProfileSpace() {
|
||||
}).catch(function (err) {
|
||||
const message = err.message + ' - ' + 'Can not access BSC SCAN servers.'
|
||||
console.log(message)
|
||||
userProfile.payload.uiObject.setErrorMessage(message, 1000)
|
||||
if (userProfile.payload !== undefined) {
|
||||
userProfile.payload.uiObject.setErrorMessage(message, 1000)
|
||||
}
|
||||
waitingForResponses--
|
||||
});
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user