evmux-app-framework 0.1.14 → 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.14",
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
 
@@ -169,12 +170,6 @@ let createEventResultObject = (requestName, eventName, result) => {
169
170
  component.window.postMessage(JSON.stringify(eventObj), "*")
170
171
  }
171
172
 
172
- getComponentCount(userAppInstanceId) {
173
- const appInstance = this._userAppInstances[userAppInstanceId]
174
- if (!appInstance || !appInstance.instances) return 0
175
- return Object.keys(appInstance.instances).length
176
- }
177
-
178
173
  setComponentProps(userAppInstanceId, componentId, props) {
179
174
  const appInstance = this._userAppInstances[userAppInstanceId]
180
175
  if (appInstance && appInstance.instances && appInstance.instances[componentId]) {
@@ -182,14 +177,10 @@ let createEventResultObject = (requestName, eventName, result) => {
182
177
  }
183
178
  }
184
179
 
185
- computeVolumeMultiplier(userAppInstanceId, componentId) {
186
- if (this.getComponentCount(userAppInstanceId) <= 1) return 1
187
- const isPrv = componentId.startsWith('live_')
188
- if (this._app && this._app.studioMode && !isPrv) return 0
180
+ getComponentVolumeMultiplier(userAppInstanceId, componentId) {
189
181
  const appInstance = this._userAppInstances[userAppInstanceId]
190
182
  const comp = appInstance && appInstance.instances && appInstance.instances[componentId]
191
- if (this._app && this._app.isLandscapeAndPortraitMode && comp && comp.portraitMode) return 0
192
- return 1
183
+ return comp && comp.volumeMultiplier !== undefined ? comp.volumeMultiplier : 1
193
184
  }
194
185
 
195
186
  signalApp(userAppInstanceId, data){
@@ -264,7 +255,7 @@ let createEventResultObject = (requestName, eventName, result) => {
264
255
  }
265
256
  else if (requestObj.request == availableRequests.getVolumeMultiplier)
266
257
  {
267
- result = { value: this.computeVolumeMultiplier(requestObj.userAppInstanceId, requestObj.componentId) }
258
+ result = { value: this.getComponentVolumeMultiplier(requestObj.userAppInstanceId, requestObj.componentId) }
268
259
  }
269
260
  else {
270
261
  for (let i = 0; i < this._requestHandlers.length; i++)
@@ -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);