evmux-app-framework 0.1.15 → 0.1.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "evmux-app-framework",
3
- "version": "0.1.15",
3
+ "version": "0.1.16",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -56,6 +56,7 @@ export const availableRequests = {
56
56
  accountPlanCapabilities: "accountPlanCapabilities",
57
57
  upgradePopup: "upgradePopup",
58
58
  getVolumeMultiplier: "getVolumeMultiplier",
59
+ addComment: "addComment",
59
60
 
60
61
  }
61
62
 
@@ -6,12 +6,29 @@ import AppsObserverRequestHandlerBase from './AppsObserverRequestHandlerBase'
6
6
 
7
7
  canHandleRequest(requestObj)
8
8
  {
9
- const supportedRequests = ["getComments"];
9
+ const supportedRequests = ["getComments", "addComment"];
10
10
  return supportedRequests.includes(requestObj.request);
11
11
  }
12
-
12
+
13
13
  async handleRequest(requestObj)
14
14
  {
15
+ if (requestObj.request === "addComment") {
16
+ const commentData = requestObj.commentData || {}
17
+ const comment = {
18
+ id: `app_${Date.now()}_${Math.floor(Math.random() * 100000)}`,
19
+ title: commentData.title || '',
20
+ text: commentData.text || '',
21
+ pic: commentData.pic || 'https://publicfiles.evmux.com/static/logo/logo_evmux.png',
22
+ style: 'comment',
23
+ enabled: false,
24
+ created_time: new Date(),
25
+ sn: 'app',
26
+ flags: commentData.flags || {}
27
+ }
28
+ window.mockComments = window.mockComments || []
29
+ window.mockComments.push(comment)
30
+ return {success: true, id: comment.id}
31
+ }
15
32
  return window.mockComments || [{
16
33
  id: '1fsdf',
17
34
  title: 'Sample comment',
@@ -7,8 +7,15 @@ export default class EvmuxAppsApiComments {
7
7
  }
8
8
 
9
9
  async getComments() {
10
-
10
+
11
11
  let reqObj = {request: "getComments", userAppInstanceId: this.evmuxAppsApi._userAppInstanceId, componentId: this.evmuxAppsApi._componentId}
12
12
  return this.evmuxAppsApi._postMessageManager.sendRequestAsync(reqObj);
13
13
  }
14
+
15
+ // push a comment from the app into the studio comments stream
16
+ // commentData: {title, text, pic (optional image url), flags (optional)}
17
+ async addComment(commentData) {
18
+ let reqObj = {request: "addComment", commentData, userAppInstanceId: this.evmuxAppsApi._userAppInstanceId, componentId: this.evmuxAppsApi._componentId}
19
+ return this.evmuxAppsApi._postMessageManager.sendRequestAsync(reqObj)
20
+ }
14
21
  }
@@ -11,6 +11,10 @@ export default class EvmuxAppsApiSocial {
11
11
  return await this.evmuxAppsComments.getComments()
12
12
  }
13
13
 
14
+ async addComment(commentData) {
15
+ return await this.evmuxAppsComments.addComment(commentData)
16
+ }
17
+
14
18
  async getStatistics() {
15
19
  let reqObj = {request: "getStatistics", userAppInstanceId: this.evmuxAppsApi._userAppInstanceId, componentId: this.evmuxAppsApi._componentId}
16
20
  return this.evmuxAppsApi._postMessageManager.sendRequestAsync(reqObj);