@plusscommunities/pluss-core-app 1.4.9 → 1.5.0

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.
Files changed (183) hide show
  1. package/dist/module/actions/FollowerActions.js +34 -0
  2. package/dist/module/actions/FollowerActions.js.map +1 -0
  3. package/dist/module/actions/MediaActions.js +20 -0
  4. package/dist/module/actions/MediaActions.js.map +1 -0
  5. package/dist/module/actions/ResidentActions.js +26 -0
  6. package/dist/module/actions/ResidentActions.js.map +1 -0
  7. package/dist/module/actions/UserActions.js +214 -0
  8. package/dist/module/actions/UserActions.js.map +1 -0
  9. package/dist/module/actions/index.js +5 -0
  10. package/dist/module/actions/index.js.map +1 -0
  11. package/dist/module/actions/types.js +14 -0
  12. package/dist/module/actions/types.js.map +1 -0
  13. package/dist/module/apis/analyticsActions.js +20 -0
  14. package/dist/module/apis/analyticsActions.js.map +1 -0
  15. package/dist/module/apis/contactActions.js +27 -0
  16. package/dist/module/apis/contactActions.js.map +1 -0
  17. package/dist/module/apis/eventActions.js +163 -0
  18. package/dist/module/apis/eventActions.js.map +1 -0
  19. package/dist/module/apis/fileActions.js +96 -0
  20. package/dist/module/apis/fileActions.js.map +1 -0
  21. package/dist/module/apis/followerActions.js +38 -0
  22. package/dist/module/apis/followerActions.js.map +1 -0
  23. package/dist/module/apis/index.js +11 -0
  24. package/dist/module/apis/index.js.map +1 -0
  25. package/dist/module/apis/notificationActions.js +60 -0
  26. package/dist/module/apis/notificationActions.js.map +1 -0
  27. package/dist/module/apis/profileActions.js +14 -0
  28. package/dist/module/apis/profileActions.js.map +1 -0
  29. package/dist/module/apis/reactionActions.js +78 -0
  30. package/dist/module/apis/reactionActions.js.map +1 -0
  31. package/dist/module/apis/typeActions.js +15 -0
  32. package/dist/module/apis/typeActions.js.map +1 -0
  33. package/dist/module/apis/userActions.js +104 -0
  34. package/dist/module/apis/userActions.js.map +1 -0
  35. package/{assets → dist/module/assets}/icons/reactions/heart.png +0 -0
  36. package/{assets → dist/module/assets}/icons/reactions/party.png +0 -0
  37. package/{assets → dist/module/assets}/icons/reactions/sad.png +0 -0
  38. package/{assets → dist/module/assets}/icons/reactions/smile.png +0 -0
  39. package/dist/module/colours.js +149 -0
  40. package/dist/module/colours.js.map +1 -0
  41. package/dist/module/components/AddButton.js +45 -0
  42. package/dist/module/components/AddButton.js.map +1 -0
  43. package/dist/module/components/Attachment.js +59 -0
  44. package/dist/module/components/Attachment.js.map +1 -0
  45. package/dist/module/components/AudienceSelectorLauncher.js +70 -0
  46. package/dist/module/components/AudienceSelectorLauncher.js.map +1 -0
  47. package/dist/module/components/AudienceSelectorPage.js +376 -0
  48. package/dist/module/components/AudienceSelectorPage.js.map +1 -0
  49. package/dist/module/components/BackButton.js +62 -0
  50. package/dist/module/components/BackButton.js.map +1 -0
  51. package/dist/module/components/CategoryTabs.js +171 -0
  52. package/dist/module/components/CategoryTabs.js.map +1 -0
  53. package/dist/module/components/CommentReply.js +363 -0
  54. package/dist/module/components/CommentReply.js.map +1 -0
  55. package/dist/module/components/CommentSection.js +785 -0
  56. package/dist/module/components/CommentSection.js.map +1 -0
  57. package/dist/module/components/ConfirmPopup.js +85 -0
  58. package/dist/module/components/ConfirmPopup.js.map +1 -0
  59. package/dist/module/components/ConfirmationPopup.js +77 -0
  60. package/dist/module/components/ConfirmationPopup.js.map +1 -0
  61. package/dist/module/components/DropDownItem.js +82 -0
  62. package/dist/module/components/DropDownItem.js.map +1 -0
  63. package/dist/module/components/DropDownMenu.js +46 -0
  64. package/dist/module/components/DropDownMenu.js.map +1 -0
  65. package/dist/module/components/EmptyStateMain.js +50 -0
  66. package/dist/module/components/EmptyStateMain.js.map +1 -0
  67. package/dist/module/components/EmptyStateWidget.js +52 -0
  68. package/dist/module/components/EmptyStateWidget.js.map +1 -0
  69. package/dist/module/components/FontScaleButton.js +37 -0
  70. package/dist/module/components/FontScaleButton.js.map +1 -0
  71. package/dist/module/components/FontScalePopup.js +77 -0
  72. package/dist/module/components/FontScalePopup.js.map +1 -0
  73. package/dist/module/components/FormCard.js +28 -0
  74. package/dist/module/components/FormCard.js.map +1 -0
  75. package/dist/module/components/FormCardSection.js +240 -0
  76. package/dist/module/components/FormCardSection.js.map +1 -0
  77. package/dist/module/components/FormCardSectionOptionLauncher.js +77 -0
  78. package/dist/module/components/FormCardSectionOptionLauncher.js.map +1 -0
  79. package/dist/module/components/FormattedText.js +145 -0
  80. package/dist/module/components/FormattedText.js.map +1 -0
  81. package/dist/module/components/GenericInput.js +161 -0
  82. package/dist/module/components/GenericInput.js.map +1 -0
  83. package/dist/module/components/GenericInputSection.js +174 -0
  84. package/dist/module/components/GenericInputSection.js.map +1 -0
  85. package/dist/module/components/Header.js +491 -0
  86. package/dist/module/components/Header.js.map +1 -0
  87. package/dist/module/components/ImagePopup.js +257 -0
  88. package/dist/module/components/ImagePopup.js.map +1 -0
  89. package/dist/module/components/ImageUploadProgress.js +72 -0
  90. package/dist/module/components/ImageUploadProgress.js.map +1 -0
  91. package/dist/module/components/ImageUploader.js +850 -0
  92. package/dist/module/components/ImageUploader.js.map +1 -0
  93. package/dist/module/components/InlineButton.js +72 -0
  94. package/dist/module/components/InlineButton.js.map +1 -0
  95. package/dist/module/components/Input.js +164 -0
  96. package/dist/module/components/Input.js.map +1 -0
  97. package/dist/module/components/LoadingCircles.js +224 -0
  98. package/dist/module/components/LoadingCircles.js.map +1 -0
  99. package/dist/module/components/LoadingIndicator.js +95 -0
  100. package/dist/module/components/LoadingIndicator.js.map +1 -0
  101. package/dist/module/components/LoadingStateWidget.js +51 -0
  102. package/dist/module/components/LoadingStateWidget.js.map +1 -0
  103. package/dist/module/components/MediaPlayer.js +440 -0
  104. package/dist/module/components/MediaPlayer.js.map +1 -0
  105. package/dist/module/components/MiddlePopup.js +46 -0
  106. package/dist/module/components/MiddlePopup.js.map +1 -0
  107. package/dist/module/components/PDFPopup.js +188 -0
  108. package/dist/module/components/PDFPopup.js.map +1 -0
  109. package/dist/module/components/PlussChat.js +997 -0
  110. package/dist/module/components/PlussChat.js.map +1 -0
  111. package/dist/module/components/PlussChatMessage.js +204 -0
  112. package/dist/module/components/PlussChatMessage.js.map +1 -0
  113. package/dist/module/components/PlussChatTime.js +66 -0
  114. package/dist/module/components/PlussChatTime.js.map +1 -0
  115. package/dist/module/components/Popup.js +138 -0
  116. package/dist/module/components/Popup.js.map +1 -0
  117. package/dist/module/components/PopupMenu.js +128 -0
  118. package/dist/module/components/PopupMenu.js.map +1 -0
  119. package/dist/module/components/PositionedImage.js +333 -0
  120. package/dist/module/components/PositionedImage.js.map +1 -0
  121. package/dist/module/components/ProfilePic.js +119 -0
  122. package/dist/module/components/ProfilePic.js.map +1 -0
  123. package/dist/module/components/RadioButton.js +84 -0
  124. package/dist/module/components/RadioButton.js.map +1 -0
  125. package/dist/module/components/Reaction.js +129 -0
  126. package/dist/module/components/Reaction.js.map +1 -0
  127. package/dist/module/components/Reactions.js +84 -0
  128. package/dist/module/components/Reactions.js.map +1 -0
  129. package/dist/module/components/SharingTools.js +162 -0
  130. package/dist/module/components/SharingTools.js.map +1 -0
  131. package/dist/module/components/Spinner.js +25 -0
  132. package/dist/module/components/Spinner.js.map +1 -0
  133. package/dist/module/components/StickyFooter.js +37 -0
  134. package/dist/module/components/StickyFooter.js.map +1 -0
  135. package/dist/module/components/TextStyle.js +34 -0
  136. package/dist/module/components/TextStyle.js.map +1 -0
  137. package/dist/module/components/Toggle.js +70 -0
  138. package/dist/module/components/Toggle.js.map +1 -0
  139. package/dist/module/components/TouchableSearchBar.js +73 -0
  140. package/dist/module/components/TouchableSearchBar.js.map +1 -0
  141. package/dist/module/components/UserListPopup.js +146 -0
  142. package/dist/module/components/UserListPopup.js.map +1 -0
  143. package/dist/module/components/UserListing.js +291 -0
  144. package/dist/module/components/UserListing.js.map +1 -0
  145. package/dist/module/components/VideoPopup.js +123 -0
  146. package/dist/module/components/VideoPopup.js.map +1 -0
  147. package/dist/module/components/WarningPopup.js +87 -0
  148. package/dist/module/components/WarningPopup.js.map +1 -0
  149. package/dist/module/components/expo-image-picker-multiple/ImageBrowser.js +325 -0
  150. package/dist/module/components/expo-image-picker-multiple/ImageBrowser.js.map +1 -0
  151. package/dist/module/components/expo-image-picker-multiple/ImageTile.js +123 -0
  152. package/dist/module/components/expo-image-picker-multiple/ImageTile.js.map +1 -0
  153. package/dist/module/components/index.js +53 -0
  154. package/dist/module/components/index.js.map +1 -0
  155. package/dist/module/components/react-native-expo-image-cropper/ExpoImageManipulator.js +416 -0
  156. package/dist/module/components/react-native-expo-image-cropper/ExpoImageManipulator.js.map +1 -0
  157. package/dist/module/components/react-native-expo-image-cropper/ImageCropOverlay.js +405 -0
  158. package/dist/module/components/react-native-expo-image-cropper/ImageCropOverlay.js.map +1 -0
  159. package/dist/module/config.js +27 -0
  160. package/dist/module/config.js.map +1 -0
  161. package/dist/module/constants.js +16 -0
  162. package/dist/module/constants.js.map +1 -0
  163. package/dist/module/fonts/index.js +2 -0
  164. package/dist/module/fonts/index.js.map +1 -0
  165. package/dist/module/fonts/pluss60-icons.js +5 -0
  166. package/dist/module/fonts/pluss60-icons.js.map +1 -0
  167. package/dist/module/fonts/pluss60-icons.json +1097 -0
  168. package/dist/module/helper.js +436 -0
  169. package/dist/module/helper.js.map +1 -0
  170. package/dist/module/index.js +13 -0
  171. package/dist/module/index.js.map +1 -0
  172. package/dist/module/session.js +54 -0
  173. package/dist/module/session.js.map +1 -0
  174. package/dist/module/styles.js +67 -0
  175. package/dist/module/styles.js.map +1 -0
  176. package/package.json +22 -5
  177. package/src/assets/icons/reactions/heart.png +0 -0
  178. package/src/assets/icons/reactions/party.png +0 -0
  179. package/src/assets/icons/reactions/sad.png +0 -0
  180. package/src/assets/icons/reactions/smile.png +0 -0
  181. package/src/components/CommentReply.js +0 -2
  182. package/src/constants.js +4 -4
  183. package/src/helper.js +4 -4
@@ -0,0 +1,785 @@
1
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2
+
3
+ import React, { Component } from 'react';
4
+ import { View, Text, TouchableOpacity, Image, StyleSheet } from 'react-native';
5
+ import _ from 'lodash';
6
+ import moment from 'moment';
7
+ import { connect } from 'react-redux';
8
+ import { Icon } from 'react-native-elements';
9
+ import { getPluralS, getThumb300, get1400, getSiteSettingFromState, getFirstName, getPluralOptions } from '../helper';
10
+ import { getMainBrandingColourFromState, TEXT_DARKEST, BG_GREY, TEXT_LIGHT, LINEGREY } from '../colours';
11
+ import { reactionActions, notificationActions } from '../apis';
12
+ import { ConfirmPopup } from './ConfirmPopup';
13
+ import { ProfilePic } from './ProfilePic';
14
+ import { ImagePopup } from './ImagePopup';
15
+ import { InlineButton } from './InlineButton';
16
+ import { Spinner } from './Spinner';
17
+ import { Services } from '../config';
18
+
19
+ class CommentSection extends Component {
20
+ constructor(props) {
21
+ super(props);
22
+
23
+ _defineProperty(this, "onPressDeleteComment", c => {
24
+ this.setState({
25
+ commentToDelete: c
26
+ });
27
+ });
28
+
29
+ _defineProperty(this, "onPressConfirmDelete", () => {
30
+ reactionActions.removeComment(this.state.commentToDelete.Id).then(res => {
31
+ console.log('deleted');
32
+ });
33
+
34
+ const newComments = _.filter(this.state.comments, c => {
35
+ return c.Id !== this.state.commentToDelete.Id;
36
+ });
37
+
38
+ this.setState({
39
+ comments: newComments,
40
+ commentToDelete: null
41
+ });
42
+ });
43
+
44
+ _defineProperty(this, "onPressCancelDelete", () => {
45
+ this.setState({
46
+ commentToDelete: null
47
+ });
48
+ });
49
+
50
+ _defineProperty(this, "onPressReportComment", c => {
51
+ this.setState({
52
+ commentToReport: c
53
+ });
54
+ });
55
+
56
+ _defineProperty(this, "onPressConfirmReport", () => {
57
+ const commentId = this.state.commentToReport.Id;
58
+ this.setState({
59
+ reportLoading: true,
60
+ commentToReport: null
61
+ }, () => {
62
+ reactionActions.reportComment(commentId).then(res => {
63
+ this.setState({
64
+ commentReportedStatus: 'success',
65
+ reportLoading: false
66
+ });
67
+ }).catch(error => {
68
+ console.log('reportComment', error);
69
+ this.setState({
70
+ commentReportedStatus: 'fail',
71
+ reportLoading: false
72
+ });
73
+ });
74
+ });
75
+ });
76
+
77
+ _defineProperty(this, "onPressCancelReport", () => {
78
+ this.setState({
79
+ commentToReport: null
80
+ });
81
+ });
82
+
83
+ _defineProperty(this, "onPressConfirmReportStatus", () => {
84
+ this.setState({
85
+ commentReportedStatus: null
86
+ });
87
+ });
88
+
89
+ _defineProperty(this, "onOpenThread", comment => {
90
+ Services.navigation.navigate('thread', { ...this.props,
91
+ threadId: comment.Id
92
+ });
93
+ });
94
+
95
+ _defineProperty(this, "onMute", () => {
96
+ const {
97
+ entityType,
98
+ entityId
99
+ } = this.props;
100
+ this.setState({
101
+ processing: true
102
+ }, async () => {
103
+ try {
104
+ const {
105
+ data
106
+ } = await notificationActions.muteEntity(entityType, entityId); // console.log('onMute', data);
107
+
108
+ const muteExpiry = moment(data.Expiry);
109
+ this.setState({
110
+ muteExpiry,
111
+ processing: false
112
+ });
113
+ } catch (error) {
114
+ console.error('onMute', error);
115
+ this.setState({
116
+ processing: false
117
+ });
118
+ }
119
+ });
120
+ });
121
+
122
+ _defineProperty(this, "onUnmute", () => {
123
+ const {
124
+ entityType,
125
+ entityId
126
+ } = this.props;
127
+ this.setState({
128
+ processing: true
129
+ }, async () => {
130
+ try {
131
+ const {
132
+ data
133
+ } = await notificationActions.unmuteEntity(entityType, entityId); // console.log('onUnmute', data);
134
+
135
+ this.setState({
136
+ muteExpiry: null,
137
+ processing: false
138
+ });
139
+ } catch (error) {
140
+ console.error('onUnmute', error);
141
+ this.setState({
142
+ processing: false
143
+ });
144
+ }
145
+ });
146
+ });
147
+
148
+ _defineProperty(this, "isMuted", () => {
149
+ const {
150
+ muteExpiry
151
+ } = this.state;
152
+ return muteExpiry && moment() <= muteExpiry;
153
+ });
154
+
155
+ _defineProperty(this, "getMuteRemaining", () => {
156
+ const {
157
+ muteExpiry
158
+ } = this.state;
159
+ const actual = muteExpiry ? moment.duration(muteExpiry.diff(moment())).asHours() : 0;
160
+ return Math.abs(Math.ceil(actual));
161
+ });
162
+
163
+ _defineProperty(this, "getNotificationSate", () => {
164
+ const {
165
+ processing
166
+ } = this.state;
167
+ const {
168
+ entityType,
169
+ entityId,
170
+ notificationsForComments
171
+ } = this.props;
172
+ if (processing || !notificationsForComments) return;
173
+ this.setState({
174
+ processing: true
175
+ }, async () => {
176
+ try {
177
+ const {
178
+ data
179
+ } = await notificationActions.getEntityNotificationSetting(entityType, entityId); // console.log('getNotificationSate', data);
180
+
181
+ const muteExpiry = data ? moment(data.Expiry) : null;
182
+ this.setState({
183
+ muteExpiry,
184
+ muteLoaded: true,
185
+ processing: false
186
+ });
187
+ } catch (error) {
188
+ console.error('getNotificationSate', error);
189
+ this.setState({
190
+ processing: false
191
+ });
192
+ }
193
+ });
194
+ });
195
+
196
+ _defineProperty(this, "isLoading", () => {
197
+ return this.state.commentsLoading;
198
+ });
199
+
200
+ _defineProperty(this, "renderReplyText", c => {
201
+ if (this.props.threadId || this.props.hideReplyButton) {
202
+ return null;
203
+ }
204
+
205
+ const threadComments = _.filter(this.state.comments, innerC => {
206
+ return innerC.ParentId === c.Id;
207
+ });
208
+
209
+ let content = null;
210
+
211
+ if (_.isEmpty(threadComments)) {
212
+ // no replies
213
+ content = /*#__PURE__*/React.createElement(Text, {
214
+ style: [styles.commentRepliesText, {
215
+ color: this.props.colourBrandingMain
216
+ }]
217
+ }, `Reply to ${getFirstName(c.User ? c.User.displayName : 'comment')}`);
218
+ } else {
219
+ // existing replies
220
+ const profilePics = _.take(_.uniqBy(threadComments, c => c.UserId), 3);
221
+
222
+ content = /*#__PURE__*/React.createElement(View, {
223
+ style: styles.multiReplyContainer
224
+ }, profilePics.map((c, i) => {
225
+ return /*#__PURE__*/React.createElement(ProfilePic, {
226
+ style: {
227
+ marginRight: -10
228
+ },
229
+ Diameter: 20,
230
+ ProfilePic: c.User.profilePic
231
+ });
232
+ }), /*#__PURE__*/React.createElement(Text, {
233
+ style: [styles.commentRepliesText, {
234
+ marginLeft: 20,
235
+ color: this.props.colourBrandingMain
236
+ }]
237
+ }, `${threadComments.length} repl${getPluralOptions(threadComments.length, 'y', 'ies')}`));
238
+ }
239
+
240
+ return /*#__PURE__*/React.createElement(View, {
241
+ style: styles.commentReplies
242
+ }, /*#__PURE__*/React.createElement(TouchableOpacity, {
243
+ onPress: () => {
244
+ this.onOpenThread(c);
245
+ }
246
+ }, content));
247
+ });
248
+
249
+ this.state = {
250
+ commentsLoading: false,
251
+ comments: [],
252
+ addingComment: false,
253
+ commentToDelete: null,
254
+ commentToReport: null,
255
+ commentReportedStatus: null,
256
+ reportLoading: false,
257
+ processing: false,
258
+ muteExpiry: null,
259
+ muteLoaded: false
260
+ };
261
+ }
262
+
263
+ componentDidMount() {
264
+ this.getNotificationSate();
265
+
266
+ if (!_.includes(this.props.user.hidden, 'viewComment')) {
267
+ this.getComments();
268
+ }
269
+ }
270
+
271
+ componentWillUnmount() {
272
+ if (this.loadTimer) {
273
+ clearTimeout(this.loadTimer);
274
+ }
275
+ }
276
+
277
+ onPressCommentImage(image) {
278
+ this.setState({
279
+ imagePopupSource: [image],
280
+ imagePopupOpen: true
281
+ });
282
+ }
283
+
284
+ onGoToAdd() {
285
+ this.props.commentReply.focusInput();
286
+ }
287
+
288
+ getAdjustedSize(size) {
289
+ if (this.props.scaleFont) {
290
+ return size + this.props.user.fontScale;
291
+ }
292
+
293
+ return size;
294
+ }
295
+
296
+ getComments() {
297
+ if (!this.state.commentsLoadStarted) {
298
+ var _this$props$commentRe, _this$props$commentRe2;
299
+
300
+ this.setState({
301
+ commentsLoadStarted: true,
302
+ commentsLoading: true
303
+ });
304
+ (_this$props$commentRe = this.props.commentReply) === null || _this$props$commentRe === void 0 ? void 0 : (_this$props$commentRe2 = _this$props$commentRe.current) === null || _this$props$commentRe2 === void 0 ? void 0 : _this$props$commentRe2.loadingStarted();
305
+ this.loadComments();
306
+ }
307
+ }
308
+
309
+ isEmpty() {
310
+ return _.isEmpty(this.state.comments);
311
+ }
312
+
313
+ loadComments() {
314
+ const minTime = this.isEmpty() ? 0 : _.maxBy(this.state.comments, c => {
315
+ return c.Timestamp;
316
+ }).Timestamp;
317
+ reactionActions.getComments(this.props.entityId, this.props.entityType, minTime).then(res => {
318
+ var _this$props$commentRe3, _this$props$commentRe4;
319
+
320
+ this.setState({
321
+ comments: _.sortBy(_.uniqBy(_.filter(_.concat(this.state.comments, res.data), c => {
322
+ if (!this.props.threadId) {
323
+ return true;
324
+ }
325
+
326
+ return c.Id === this.props.threadId || c.ParentId === this.props.threadId;
327
+ }), c => {
328
+ return c.Id;
329
+ }), 'Timestamp'),
330
+ commentsLoading: false
331
+ }, () => {
332
+ if (this.props.onCommentsLoaded) {
333
+ this.props.onCommentsLoaded(this.state.comments.length);
334
+ }
335
+ }); //if (this.props.commentReply) {
336
+
337
+ (_this$props$commentRe3 = this.props.commentReply) === null || _this$props$commentRe3 === void 0 ? void 0 : (_this$props$commentRe4 = _this$props$commentRe3.current) === null || _this$props$commentRe4 === void 0 ? void 0 : _this$props$commentRe4.loadingCompleted(); //}
338
+
339
+ if (this.props.live) {
340
+ this.loadTimer = setTimeout(() => {
341
+ this.loadComments();
342
+ }, this.props.refreshFrequency || 2000);
343
+ }
344
+ });
345
+ }
346
+
347
+ startedAddingComment() {
348
+ this.setState({
349
+ addingComment: true
350
+ });
351
+ }
352
+
353
+ commentAdded(comment) {
354
+ const newComments = this.state.comments;
355
+ newComments.push(comment);
356
+ this.setState({
357
+ addingComment: false,
358
+ comments: newComments
359
+ }, () => {
360
+ if (this.props.onCommentAdded) {
361
+ this.props.onCommentAdded();
362
+ }
363
+ });
364
+ }
365
+
366
+ canRemoveComment(c) {
367
+ if (this.props.user.uid === c.UserId) {
368
+ return true;
369
+ }
370
+
371
+ return _.includes(this.props.user.permissions, this.props.adminPermission);
372
+ }
373
+
374
+ closeCommentGallery() {
375
+ this.setState({
376
+ imagePopupSource: [],
377
+ imagePopupOpen: false
378
+ });
379
+ }
380
+
381
+ renderCommentDeleteConfirm() {
382
+ return /*#__PURE__*/React.createElement(ConfirmPopup, {
383
+ visible: !!this.state.commentToDelete,
384
+ onConfirm: this.onPressConfirmDelete,
385
+ onCancel: this.onPressCancelDelete,
386
+ onClose: this.onPressCancelDelete,
387
+ text: "Are you sure you want to delete this comment?"
388
+ });
389
+ }
390
+
391
+ renderCommentReportConfirm() {
392
+ return /*#__PURE__*/React.createElement(ConfirmPopup, {
393
+ visible: !!this.state.commentToReport,
394
+ onConfirm: this.onPressConfirmReport,
395
+ onCancel: this.onPressCancelReport,
396
+ onClose: this.onPressCancelReport,
397
+ text: "Are you sure?",
398
+ extraContent: /*#__PURE__*/React.createElement(Text, {
399
+ style: styles.commentReportText
400
+ }, "This comment will be reported to our team and considered for deletion")
401
+ });
402
+ }
403
+
404
+ renderCommentReportStatus() {
405
+ const {
406
+ commentReportedStatus
407
+ } = this.state;
408
+ const isSuccess = commentReportedStatus === 'success';
409
+ return /*#__PURE__*/React.createElement(ConfirmPopup, {
410
+ visible: !!commentReportedStatus,
411
+ onConfirm: this.onPressConfirmReportStatus,
412
+ text: isSuccess ? 'Thank you for reporting' : 'Unable to report',
413
+ extraContent: /*#__PURE__*/React.createElement(Text, {
414
+ style: styles.commentReportText
415
+ }, isSuccess ? 'We will review the comment within 24 hours' : 'There was a problem reporting the comment please try again later'),
416
+ hideNo: true,
417
+ yesText: 'Back to Article'
418
+ });
419
+ }
420
+
421
+ renderCommentImage(c) {
422
+ if (_.isEmpty(c.Image)) {
423
+ return null;
424
+ }
425
+
426
+ return /*#__PURE__*/React.createElement(TouchableOpacity, {
427
+ style: styles.commentImageContainer,
428
+ onPress: this.onPressCommentImage.bind(this, get1400(c.Image))
429
+ }, /*#__PURE__*/React.createElement(Image, {
430
+ style: styles.commentImage,
431
+ source: {
432
+ uri: getThumb300(c.Image)
433
+ }
434
+ }));
435
+ }
436
+
437
+ renderComment(c) {
438
+ return /*#__PURE__*/React.createElement(View, {
439
+ style: styles.comment,
440
+ key: c.Id
441
+ }, /*#__PURE__*/React.createElement(View, {
442
+ style: styles.commentFlex
443
+ }, /*#__PURE__*/React.createElement(ProfilePic, {
444
+ ProfilePic: c.User.profilePic,
445
+ Diameter: 40,
446
+ style: styles.commentProfilePic
447
+ }), /*#__PURE__*/React.createElement(View, {
448
+ style: styles.commentBlock
449
+ }, /*#__PURE__*/React.createElement(View, {
450
+ style: styles.commentTitleRow
451
+ }, this.canRemoveComment(c) ? /*#__PURE__*/React.createElement(TouchableOpacity, {
452
+ onPress: this.onPressDeleteComment.bind(this, c)
453
+ }, /*#__PURE__*/React.createElement(View, {
454
+ style: [styles.commentButtonContainer, {
455
+ backgroundColor: this.props.colourBrandingMain
456
+ }]
457
+ }, /*#__PURE__*/React.createElement(Icon, {
458
+ name: "trash",
459
+ type: "font-awesome",
460
+ iconStyle: styles.commentButtonIcon
461
+ }))) : null // (
462
+ // !this.props.disableFlag && (
463
+ // <TouchableOpacity onPress={this.onPressReportComment.bind(this, c)}>
464
+ // <View style={[styles.commentButtonContainer, { backgroundColor: this.props.colourBrandingMain }]}>
465
+ // <Icon name="flag" type="font-awesome" iconStyle={styles.commentButtonIcon} />
466
+ // </View>
467
+ // </TouchableOpacity>
468
+ // )
469
+ // )
470
+ , /*#__PURE__*/React.createElement(Text, {
471
+ style: [styles.commentName, {
472
+ fontSize: this.getAdjustedSize(13)
473
+ }]
474
+ }, c.User.displayName)), !_.isEmpty(c.Comment) && /*#__PURE__*/React.createElement(Text, {
475
+ style: [styles.commentText, {
476
+ fontSize: this.getAdjustedSize(13)
477
+ }]
478
+ }, c.Comment), this.renderCommentImage(c))), /*#__PURE__*/React.createElement(View, {
479
+ style: styles.commentBottom
480
+ }, /*#__PURE__*/React.createElement(Text, {
481
+ style: [styles.commentTime, {
482
+ fontSize: this.getAdjustedSize(13)
483
+ }]
484
+ }, moment.utc(c.Timestamp).local().format('D MMM • h:mma')), this.renderReplyText(c)));
485
+ }
486
+
487
+ renderMute() {
488
+ const {
489
+ notificationsForComments
490
+ } = this.props;
491
+ const {
492
+ muteLoaded,
493
+ muteExpiry,
494
+ processing
495
+ } = this.state;
496
+ if (!notificationsForComments || !muteLoaded) return null;
497
+ if (processing) return /*#__PURE__*/React.createElement(View, {
498
+ style: styles.muteSpinnerContainer
499
+ }, /*#__PURE__*/React.createElement(Spinner, {
500
+ size: 'small',
501
+ color: this.props.colourBrandingMain
502
+ }));
503
+ const isMuted = this.isMuted();
504
+ const hours = this.getMuteRemaining();
505
+ const mutedFor = `Muted for ${hours} hour${getPluralS(hours)}`; // console.log(muteExpiry.format('DD MMM YYYY hh:mm a'));
506
+
507
+ return /*#__PURE__*/React.createElement(View, {
508
+ style: styles.muteContainer
509
+ }, isMuted && muteExpiry ? /*#__PURE__*/React.createElement(Text, {
510
+ style: [{
511
+ color: this.props.colourBrandingMain
512
+ }, styles.mutedForText]
513
+ }, mutedFor) : null, /*#__PURE__*/React.createElement(InlineButton, {
514
+ onPress: isMuted ? this.onUnmute : this.onMute,
515
+ color: "#fff",
516
+ style: [{
517
+ borderColor: this.props.colourBrandingMain
518
+ }, styles.muteButton],
519
+ disabled: processing,
520
+ disabledOpacity: true,
521
+ noText: true
522
+ }, /*#__PURE__*/React.createElement(View, {
523
+ style: styles.muteButtonInner
524
+ }, /*#__PURE__*/React.createElement(Icon, {
525
+ name: isMuted ? 'bell-o' : 'bell-slash-o',
526
+ type: 'font-awesome',
527
+ iconStyle: [{
528
+ color: this.props.colourBrandingMain
529
+ }, styles.muteButtonIcon]
530
+ }), /*#__PURE__*/React.createElement(Text, {
531
+ style: [{
532
+ color: this.props.colourBrandingMain
533
+ }, styles.muteButtonText]
534
+ }, isMuted ? 'Unmute' : 'Mute'))));
535
+ }
536
+
537
+ renderComments() {
538
+ if (this.state.commentsLoading) {
539
+ return /*#__PURE__*/React.createElement(View, {
540
+ style: styles.commentSection
541
+ }, /*#__PURE__*/React.createElement(Spinner, {
542
+ color: this.props.colourBrandingMain
543
+ }));
544
+ }
545
+
546
+ if (this.isEmpty() && !this.state.addingComment) {
547
+ if (_.includes(this.props.user.hidden, 'addComment')) {
548
+ return null;
549
+ }
550
+
551
+ if (!_.isNil(this.props.placeHolder) && _.isEmpty(this.props.placeHolder)) return null;
552
+ return /*#__PURE__*/React.createElement(View, {
553
+ style: styles.commentSection
554
+ }, /*#__PURE__*/React.createElement(Text, {
555
+ style: [styles.commentsEmpty, {
556
+ fontSize: this.getAdjustedSize(15)
557
+ }]
558
+ }, _.isNil(this.props.placeHolder) ? 'Be the first to add a comment!' : this.props.placeHolder));
559
+ }
560
+
561
+ let source = [...this.state.comments];
562
+
563
+ if (this.props.reverseOrder) {
564
+ source = source.reverse();
565
+ }
566
+
567
+ if (!this.props.showReplies && !this.props.threadId) {
568
+ source = _.filter(source, c => {
569
+ return !c.ParentId;
570
+ });
571
+ }
572
+
573
+ return /*#__PURE__*/React.createElement(View, {
574
+ style: styles.commentSection
575
+ }, !this.isEmpty() && /*#__PURE__*/React.createElement(View, {
576
+ style: styles.commentSectionTitleRow
577
+ }, /*#__PURE__*/React.createElement(View, {
578
+ style: {
579
+ alignItems: 'flex-end'
580
+ }
581
+ }, this.renderMute(), !this.props.hideAddComment && this.state.comments.length > 2 && /*#__PURE__*/React.createElement(TouchableOpacity, {
582
+ onPress: this.onGoToAdd.bind(this)
583
+ }, /*#__PURE__*/React.createElement(Text, {
584
+ style: [styles.goToText, {
585
+ color: this.props.colourBrandingMain
586
+ }]
587
+ }, "Add a comment"))), /*#__PURE__*/React.createElement(Text, {
588
+ style: [styles.commentCount, {
589
+ fontSize: this.getAdjustedSize(15)
590
+ }]
591
+ }, this.state.comments.length, ` comment${getPluralS(this.state.comments.length)}`)), this.props.reverseOrder && this.state.addingComment && /*#__PURE__*/React.createElement(Spinner, {
592
+ color: this.props.colourBrandingMain
593
+ }), source.map(c => {
594
+ return this.renderComment(c);
595
+ }), !this.props.reverseOrder && this.state.addingComment && /*#__PURE__*/React.createElement(Spinner, {
596
+ color: this.props.colourBrandingMain
597
+ }));
598
+ }
599
+
600
+ renderCommentImagePopup() {
601
+ return /*#__PURE__*/React.createElement(ImagePopup, {
602
+ visible: this.state.imagePopupOpen,
603
+ images: this.state.imagePopupSource,
604
+ onClose: this.closeCommentGallery.bind(this),
605
+ ref: "commentImagePopup"
606
+ });
607
+ }
608
+
609
+ renderReportLoading() {
610
+ if (!this.state.reportLoading) return null;
611
+ return /*#__PURE__*/React.createElement(View, {
612
+ style: styles.reportLoadingContainer
613
+ }, /*#__PURE__*/React.createElement(Spinner, {
614
+ color: this.props.colourBrandingMain
615
+ }));
616
+ }
617
+
618
+ render() {
619
+ if (_.includes(this.props.user.hidden, 'viewComment')) {
620
+ return null;
621
+ }
622
+
623
+ return /*#__PURE__*/React.createElement(View, {
624
+ style: [styles.commentSectionOuter, this.props.style]
625
+ }, this.renderComments(), this.renderReportLoading(), this.renderCommentDeleteConfirm(), this.renderCommentReportConfirm(), this.renderCommentReportStatus(), this.renderCommentImagePopup());
626
+ }
627
+
628
+ }
629
+
630
+ const styles = StyleSheet.create({
631
+ commentSectionOuter: {
632
+ flex: 1,
633
+ paddingHorizontal: 16
634
+ },
635
+ commentSection: {
636
+ flex: 1,
637
+ paddingVertical: 12,
638
+ borderTopColor: LINEGREY,
639
+ borderTopWidth: 1
640
+ },
641
+ commentCount: {
642
+ fontFamily: 'sf-semibold',
643
+ color: TEXT_DARKEST,
644
+ flex: 1,
645
+ marginTop: 4
646
+ },
647
+ comment: {
648
+ marginTop: 16
649
+ },
650
+ commentFlex: {
651
+ flexDirection: 'row'
652
+ },
653
+ commentProfilePic: {
654
+ marginRight: 8
655
+ },
656
+ commentBlock: {
657
+ flex: 1,
658
+ backgroundColor: BG_GREY,
659
+ borderRadius: 5,
660
+ padding: 8
661
+ },
662
+ commentTitleRow: {
663
+ flexDirection: 'row-reverse',
664
+ alignItems: 'center'
665
+ },
666
+ commentButtonContainer: {
667
+ width: 24,
668
+ height: 24,
669
+ borderRadius: 12,
670
+ alignItems: 'center',
671
+ justifyContent: 'center'
672
+ },
673
+ commentButtonIcon: {
674
+ fontSize: 13,
675
+ color: '#fff'
676
+ },
677
+ commentName: {
678
+ fontFamily: 'sf-semibold',
679
+ color: TEXT_DARKEST,
680
+ flex: 1
681
+ },
682
+ commentText: {
683
+ marginTop: 8,
684
+ fontFamily: 'sf-regular',
685
+ color: TEXT_DARKEST
686
+ },
687
+ commentBottom: {
688
+ flexDirection: 'row-reverse',
689
+ justifyContent: 'space-between',
690
+ alignItems: 'center'
691
+ },
692
+ commentTime: {
693
+ fontFamily: 'sf-regular',
694
+ marginTop: 4,
695
+ color: TEXT_LIGHT,
696
+ textAlign: 'right'
697
+ },
698
+ commentReplies: {
699
+ flex: 1,
700
+ paddingLeft: 48
701
+ },
702
+ commentRepliesText: {
703
+ fontFamily: 'sf-semibold',
704
+ fontSize: 15
705
+ },
706
+ multiReplyContainer: {
707
+ flexDirection: 'row',
708
+ alignItems: 'center',
709
+ paddingVertical: 4
710
+ },
711
+ commentImageContainer: {
712
+ marginTop: 8,
713
+ width: 60,
714
+ height: 60
715
+ },
716
+ commentImage: {
717
+ width: 60,
718
+ height: 60,
719
+ borderRadius: 2
720
+ },
721
+ commentsEmpty: {
722
+ fontFamily: 'sf-semibold',
723
+ color: TEXT_DARKEST
724
+ },
725
+ commentSectionTitleRow: {
726
+ flexDirection: 'row-reverse'
727
+ },
728
+ commentReportText: {
729
+ fontFamily: 'sf-regular',
730
+ fontSize: 14,
731
+ paddingHorizontal: 22,
732
+ textAlign: 'center'
733
+ },
734
+ reportLoadingContainer: {
735
+ paddingVertical: 10
736
+ },
737
+ goToText: {
738
+ marginTop: 4
739
+ },
740
+ muteSpinnerContainer: {
741
+ width: 100,
742
+ marginBottom: 6
743
+ },
744
+ muteContainer: {
745
+ flexDirection: 'row',
746
+ alignItems: 'center',
747
+ justifyContent: 'flex-end',
748
+ marginBottom: 6
749
+ },
750
+ mutedForText: {
751
+ fontFamily: 'sf-semibold',
752
+ fontSize: 13,
753
+ marginRight: 8
754
+ },
755
+ muteButton: {
756
+ borderWidth: 1,
757
+ paddingHorizontal: 8
758
+ },
759
+ muteButtonInner: {
760
+ flexDirection: 'row',
761
+ alignItems: 'center'
762
+ },
763
+ muteButtonIcon: {
764
+ fontSize: 14
765
+ },
766
+ muteButtonText: {
767
+ fontFamily: 'sf-semibold',
768
+ fontSize: 14,
769
+ marginLeft: 6
770
+ }
771
+ });
772
+
773
+ const mapStateToProps = state => {
774
+ return {
775
+ colourBrandingMain: getMainBrandingColourFromState(state),
776
+ user: state.user,
777
+ notificationsForComments: getSiteSettingFromState(state, 'NotificationsForComments', false)
778
+ };
779
+ };
780
+
781
+ const commentSection = connect(mapStateToProps, {}, null, {
782
+ forwardRef: true
783
+ })(CommentSection);
784
+ export { commentSection as CommentSection };
785
+ //# sourceMappingURL=CommentSection.js.map