@plusscommunities/pluss-core-app 8.0.28 → 8.0.31

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