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