diff --git a/Client/httpInterface.js b/Client/httpInterface.js index 4736c28c0..7d89e508e 100644 --- a/Client/httpInterface.js +++ b/Client/httpInterface.js @@ -1388,7 +1388,14 @@ exports.newHttpInterface = function newHttpInterface() { project, folder, fileName - ) + ).catch(err => { + let error = { + result: 'Fail Because', + message: err + } + respondWithContent(JSON.stringify(error), httpResponse) + return + }) respondWithContent(response, httpResponse) diff --git a/Network/event.js b/Network/event.js index ecc2b501c..ae9c7c74f 100644 --- a/Network/event.js +++ b/Network/event.js @@ -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 + } } } \ No newline at end of file diff --git a/Network/post.js b/Network/post.js index bac0a1a1c..95bbe1eb1 100644 --- a/Network/post.js +++ b/Network/post.js @@ -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) + } } \ No newline at end of file diff --git a/Projects/Foundations/CL/Utilities/Plugins.js b/Projects/Foundations/CL/Utilities/Plugins.js index 7a639c1bc..bc149c038 100644 --- a/Projects/Foundations/CL/Utilities/Plugins.js +++ b/Projects/Foundations/CL/Utilities/Plugins.js @@ -38,7 +38,7 @@ exports.newFoundationsUtilitiesPlugins = function () { function onFileRead(err, file) { if (err) { console.log('[WARN] getPluginFileContent -> File not Found -> Path = ' + path) - reject() + reject('File not Found') return } resolve(file.toString()) diff --git a/Projects/Governance/Plugins/Workspaces/Token-Distribution-Superalgos.json b/Projects/Governance/Plugins/Workspaces/Token-Distribution-Superalgos.json index bdc690cc9..d291f7327 100644 --- a/Projects/Governance/Plugins/Workspaces/Token-Distribution-Superalgos.json +++ b/Projects/Governance/Plugins/Workspaces/Token-Distribution-Superalgos.json @@ -1214,34 +1214,6 @@ "isRunning": false } } - }, - { - "type": "Plugin File", - "name": "test", - "config": "{\"project\":\"Governance\",\"fileName\":\"test\",\"folderName\":\"User-Profiles\",\"nodeType\":\"User Profile\",\"saveWithWorkspace\":true}", - "project": "Foundations", - "id": "752c1c55-e983-4ead-a52c-4193015469fc", - "savedPayload": { - "position": { - "x": 35572.314597728066, - "y": 10724.773136533244 - }, - "targetPosition": { - "x": 35605.314597728066, - "y": 10678.773136533244 - }, - "floatingObject": { - "isPinned": false, - "isFrozen": false, - "isCollapsed": false, - "angleToParent": 2, - "distanceToParent": 3, - "arrangementStyle": 0 - }, - "uiObject": { - "isRunning": false - } - } } ], "id": "2c899fe9-1335-4e9f-b2d0-45a83e478fd0", diff --git a/Projects/Governance/UI/Spaces/User-Profile-Space/UserProfile.js b/Projects/Governance/UI/Spaces/User-Profile-Space/UserProfile.js index c5914e797..18b2be814 100644 --- a/Projects/Governance/UI/Spaces/User-Profile-Space/UserProfile.js +++ b/Projects/Governance/UI/Spaces/User-Profile-Space/UserProfile.js @@ -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-- }); }