agora-appbuilder-core 4.0.30-beta-2 → 4.0.30-beta-3

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": "agora-appbuilder-core",
3
- "version": "4.0.30-beta-2",
3
+ "version": "4.0.30-beta-3",
4
4
  "description": "React Native template for RTE app builder",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -37,7 +37,6 @@ export default class RtmEngine {
37
37
  ['channelMessageReceived', () => null],
38
38
  ['channelMemberJoined', () => null],
39
39
  ['channelMemberLeft', () => null],
40
- ['channelAttributesUpdated', () => null],
41
40
  ]);
42
41
  public clientEventsMap = new Map<string, any>([
43
42
  ['connectionStateChanged', () => null],
@@ -67,8 +66,7 @@ export default class RtmEngine {
67
66
  if (
68
67
  event === 'channelMessageReceived' ||
69
68
  event === 'channelMemberJoined' ||
70
- event === 'channelMemberLeft' ||
71
- event === 'channelAttributesUpdated'
69
+ event === 'channelMemberLeft'
72
70
  ) {
73
71
  this.channelEventsMap.set(event, listener);
74
72
  } else if (
@@ -253,7 +251,7 @@ export default class RtmEngine {
253
251
  return acc;
254
252
  }, []);
255
253
 
256
- this.channelEventsMap.get('channelAttributesUpdated')(
254
+ this.channelEventsMap.get('ChannelAttributesUpdated')(
257
255
  channelAttributes,
258
256
  );
259
257
  });
@@ -342,8 +340,21 @@ export default class RtmEngine {
342
340
  let response = {};
343
341
  await this.client
344
342
  .getChannelAttributes(channelId)
345
- .then((attributes: string) => {
346
- response = {attributes};
343
+ .then((attributes: RtmChannelAttribute) => {
344
+ /**
345
+ * Here the attributes received are in the format {[valueOfKey]: valueOfValue} of type RtmChannelAttribute
346
+ * We need to convert it into (array of objects [{key: 'valueOfKey', value: 'valueOfValue}])
347
+ /**
348
+ * 1. Loop through object
349
+ * 2. Create a object {key: "", value: ""} and push into array
350
+ * 3. Return the Array
351
+ */
352
+ const channelAttributes = Object.keys(attributes).reduce((acc, key) => {
353
+ const {value, lastUpdateTs, lastUpdateUserId} = attributes[key];
354
+ acc.push({key, value, lastUpdateTs, lastUpdateUserId});
355
+ return acc;
356
+ }, []);
357
+ response = channelAttributes;
347
358
  })
348
359
  .catch((e: any) => {
349
360
  Promise.reject(e);
@@ -76,8 +76,8 @@ const DefaultConfig = {
76
76
  CHAT_ORG_NAME: '',
77
77
  CHAT_APP_NAME: '',
78
78
  CHAT_URL: '',
79
- CLI_VERSION: '3.0.30-beta-2',
80
- CORE_VERSION: '4.0.30-beta-2',
79
+ CLI_VERSION: '3.0.30-beta-3',
80
+ CORE_VERSION: '4.0.30-beta-3',
81
81
  DISABLE_LANDSCAPE_MODE: false,
82
82
  STT_AUTO_START: false,
83
83
  CLOUD_RECORDING_AUTO_START: false,
@@ -397,16 +397,16 @@ const RtmConfigure = (props: any) => {
397
397
  await engine.current
398
398
  .getChannelAttributes(rtcProps.channel)
399
399
  .then(async data => {
400
- for (const [key, value] of Object.entries(data?.attributes)) {
401
- const {lastUpdateTs, lastUpdateUserId, value: payloadValue} = value;
402
- if (hasJsonStructure(payloadValue as string)) {
403
- const data = {
400
+ for (const item of data) {
401
+ const {key, value, lastUpdateTs, lastUpdateUserId} = item;
402
+ if (hasJsonStructure(value as string)) {
403
+ const evtData = {
404
404
  evt: key,
405
- value: payloadValue,
405
+ value,
406
406
  };
407
407
  // TODOSUP: Add the data to queue, dont add same mulitple events, use set so as to not repeat events
408
408
  EventsQueue.enqueue({
409
- data: data,
409
+ data: evtData,
410
410
  uid: lastUpdateUserId,
411
411
  ts: lastUpdateTs,
412
412
  });
@@ -534,6 +534,36 @@ const RtmConfigure = (props: any) => {
534
534
  });
535
535
  });
536
536
 
537
+ engine.current.addListener(
538
+ 'ChannelAttributesUpdated',
539
+ (attributeList: RtmChannelAttribute[]) => {
540
+ try {
541
+ attributeList.map((attribute: RtmChannelAttribute) => {
542
+ const {key, value, lastUpdateTs, lastUpdateUserId} = attribute;
543
+ const timestamp = getMessageTime(lastUpdateTs);
544
+ const sender = Platform.OS
545
+ ? get32BitUid(lastUpdateUserId)
546
+ : parseInt(lastUpdateUserId);
547
+ eventDispatcher(
548
+ {
549
+ evt: key,
550
+ value,
551
+ },
552
+ sender,
553
+ timestamp,
554
+ );
555
+ });
556
+ } catch (error) {
557
+ logger.error(
558
+ LogSource.Events,
559
+ 'CUSTOM_EVENTS',
560
+ 'error while dispatching through eventDispatcher',
561
+ error,
562
+ );
563
+ }
564
+ },
565
+ );
566
+
537
567
  engine.current.on('messageReceived', (evt: any) => {
538
568
  logger.debug(LogSource.Events, 'CUSTOM_EVENTS', 'messageReceived', evt);
539
569
  const {peerId, ts, text} = evt;
@@ -620,36 +650,6 @@ const RtmConfigure = (props: any) => {
620
650
  }
621
651
  });
622
652
 
623
- engine.current.on(
624
- 'channelAttributesUpdated',
625
- (attributeList: RtmChannelAttribute[]) => {
626
- console.log('channel attributes updated', attributeList);
627
- try {
628
- attributeList.map((attribute: RtmChannelAttribute) => {
629
- const {key, value, lastUpdateTs, lastUpdateUserId} = attribute;
630
- const timestamp = getMessageTime(lastUpdateTs);
631
- const sender = Platform.OS
632
- ? get32BitUid(lastUpdateUserId)
633
- : parseInt(lastUpdateUserId);
634
- eventDispatcher(
635
- {
636
- evt: key,
637
- value,
638
- },
639
- sender,
640
- timestamp,
641
- );
642
- });
643
- } catch (error) {
644
- logger.error(
645
- LogSource.Events,
646
- 'CUSTOM_EVENTS',
647
- 'error while dispatching through eventDispatcher',
648
- error,
649
- );
650
- }
651
- },
652
- );
653
653
  await doLoginAndSetupRTM();
654
654
  };
655
655
 
@@ -131,9 +131,9 @@ export const CopyMeetingInfo = (props?: CopyMeetingInfoProps) => {
131
131
  };
132
132
  return (
133
133
  <>
134
- {isSeparateHostLink ? (
134
+ {isHost ? (
135
135
  <>
136
- <Text style={style.urlTitle}>{getAttendeeLabel()}</Text>
136
+ <Text style={style.urlTitle}>{getHostLabel()}</Text>
137
137
  <Spacer size={11} />
138
138
  <View style={style.container}>
139
139
  <View style={style.urlContainer}>
@@ -146,17 +146,17 @@ export const CopyMeetingInfo = (props?: CopyMeetingInfoProps) => {
146
146
  //@ts-ignore
147
147
  isWebCheck ? urlWeb : {opacity: 1},
148
148
  ]}>
149
- {getShareLink(SHARE_LINK_CONTENT_TYPE.ATTENDEE)}
149
+ {getShareLink(SHARE_LINK_CONTENT_TYPE.HOST)}
150
150
  </Text>
151
151
  </View>
152
- {clipboardIconButton(SHARE_LINK_CONTENT_TYPE.ATTENDEE)}
152
+ {clipboardIconButton(SHARE_LINK_CONTENT_TYPE.HOST)}
153
153
  </View>
154
154
 
155
155
  {showSubLabel && (
156
156
  <>
157
157
  <Spacer size={14} />
158
158
  <Text style={style.helpText}>
159
- {shareRoomAttendeeLinkSubTextLocal}
159
+ {shareRoomHostLinkSubTextLocal}
160
160
  </Text>
161
161
  </>
162
162
  )}
@@ -165,9 +165,9 @@ export const CopyMeetingInfo = (props?: CopyMeetingInfoProps) => {
165
165
  ) : (
166
166
  <></>
167
167
  )}
168
- {isHost ? (
168
+ {isSeparateHostLink ? (
169
169
  <>
170
- <Text style={style.urlTitle}>{getHostLabel()}</Text>
170
+ <Text style={style.urlTitle}>{getAttendeeLabel()}</Text>
171
171
  <Spacer size={11} />
172
172
  <View style={style.container}>
173
173
  <View style={style.urlContainer}>
@@ -180,17 +180,17 @@ export const CopyMeetingInfo = (props?: CopyMeetingInfoProps) => {
180
180
  //@ts-ignore
181
181
  isWebCheck ? urlWeb : {opacity: 1},
182
182
  ]}>
183
- {getShareLink(SHARE_LINK_CONTENT_TYPE.HOST)}
183
+ {getShareLink(SHARE_LINK_CONTENT_TYPE.ATTENDEE)}
184
184
  </Text>
185
185
  </View>
186
- {clipboardIconButton(SHARE_LINK_CONTENT_TYPE.HOST)}
186
+ {clipboardIconButton(SHARE_LINK_CONTENT_TYPE.ATTENDEE)}
187
187
  </View>
188
188
 
189
189
  {showSubLabel && (
190
190
  <>
191
191
  <Spacer size={14} />
192
192
  <Text style={style.helpText}>
193
- {shareRoomHostLinkSubTextLocal}
193
+ {shareRoomAttendeeLinkSubTextLocal}
194
194
  </Text>
195
195
  </>
196
196
  )}