@plusscommunities/pluss-core-app 8.0.0 → 8.0.1-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 (320) hide show
  1. package/dist/module/actions/FollowerActions.js +4 -4
  2. package/dist/module/actions/FollowerActions.js.map +1 -1
  3. package/dist/module/actions/MediaActions.js +1 -1
  4. package/dist/module/actions/MediaActions.js.map +1 -1
  5. package/dist/module/actions/ResidentActions.js +1 -1
  6. package/dist/module/actions/ResidentActions.js.map +1 -1
  7. package/dist/module/actions/UserActions.js +1 -1
  8. package/dist/module/actions/UserActions.js.map +1 -1
  9. package/dist/module/actions/UserSettingsActions.js +1 -1
  10. package/dist/module/actions/UserSettingsActions.js.map +1 -1
  11. package/dist/module/actions/index.js +5 -5
  12. package/dist/module/actions/index.js.map +1 -1
  13. package/dist/module/actions/types.js +16 -16
  14. package/dist/module/actions/types.js.map +1 -1
  15. package/dist/module/apis/analyticsActions.js +5 -5
  16. package/dist/module/apis/analyticsActions.js.map +1 -1
  17. package/dist/module/apis/contactActions.js +6 -6
  18. package/dist/module/apis/contactActions.js.map +1 -1
  19. package/dist/module/apis/eventActions.js +28 -28
  20. package/dist/module/apis/eventActions.js.map +1 -1
  21. package/dist/module/apis/fileActions.js +15 -15
  22. package/dist/module/apis/fileActions.js.map +1 -1
  23. package/dist/module/apis/followerActions.js +8 -8
  24. package/dist/module/apis/followerActions.js.map +1 -1
  25. package/dist/module/apis/index.js +12 -12
  26. package/dist/module/apis/index.js.map +1 -1
  27. package/dist/module/apis/notificationActions.js +17 -17
  28. package/dist/module/apis/notificationActions.js.map +1 -1
  29. package/dist/module/apis/profileActions.js +4 -4
  30. package/dist/module/apis/profileActions.js.map +1 -1
  31. package/dist/module/apis/reactionActions.js +15 -15
  32. package/dist/module/apis/reactionActions.js.map +1 -1
  33. package/dist/module/apis/settingActions.js +6 -6
  34. package/dist/module/apis/settingActions.js.map +1 -1
  35. package/dist/module/apis/stringActions.js +8 -8
  36. package/dist/module/apis/stringActions.js.map +1 -1
  37. package/dist/module/apis/typeActions.js +4 -4
  38. package/dist/module/apis/typeActions.js.map +1 -1
  39. package/dist/module/apis/userActions.js +8 -8
  40. package/dist/module/apis/userActions.js.map +1 -1
  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/colours.js +26 -29
  48. package/dist/module/colours.js.map +1 -1
  49. package/dist/module/components/AddButton.js +8 -8
  50. package/dist/module/components/AddButton.js.map +1 -1
  51. package/dist/module/components/AddToCalendarButton.js +30 -29
  52. package/dist/module/components/AddToCalendarButton.js.map +1 -1
  53. package/dist/module/components/Attachment.js +10 -9
  54. package/dist/module/components/Attachment.js.map +1 -1
  55. package/dist/module/components/AudienceSelectorLauncher.js +11 -11
  56. package/dist/module/components/AudienceSelectorLauncher.js.map +1 -1
  57. package/dist/module/components/AudienceSelectorPage.js +45 -44
  58. package/dist/module/components/AudienceSelectorPage.js.map +1 -1
  59. package/dist/module/components/AutoOffsetImage.js +13 -13
  60. package/dist/module/components/AutoOffsetImage.js.map +1 -1
  61. package/dist/module/components/BackButton.js +10 -10
  62. package/dist/module/components/BackButton.js.map +1 -1
  63. package/dist/module/components/CalendarPopup.js +21 -21
  64. package/dist/module/components/CalendarPopup.js.map +1 -1
  65. package/dist/module/components/CategoryTabs.js +30 -29
  66. package/dist/module/components/CategoryTabs.js.map +1 -1
  67. package/dist/module/components/CommentReply.js +43 -37
  68. package/dist/module/components/CommentReply.js.map +1 -1
  69. package/dist/module/components/CommentSection.js +74 -74
  70. package/dist/module/components/CommentSection.js.map +1 -1
  71. package/dist/module/components/ConfirmPopup.js +21 -20
  72. package/dist/module/components/ConfirmPopup.js.map +1 -1
  73. package/dist/module/components/ConfirmationPopup.js +11 -11
  74. package/dist/module/components/ConfirmationPopup.js.map +1 -1
  75. package/dist/module/components/DocumentUploader.js +50 -50
  76. package/dist/module/components/DocumentUploader.js.map +1 -1
  77. package/dist/module/components/DropDownItem.js +14 -13
  78. package/dist/module/components/DropDownItem.js.map +1 -1
  79. package/dist/module/components/DropDownMenu.js +5 -5
  80. package/dist/module/components/DropDownMenu.js.map +1 -1
  81. package/dist/module/components/EmptyStateMain.js +10 -9
  82. package/dist/module/components/EmptyStateMain.js.map +1 -1
  83. package/dist/module/components/EmptyStateWidget.js +7 -6
  84. package/dist/module/components/EmptyStateWidget.js.map +1 -1
  85. package/dist/module/components/FontScaleButton.js +5 -4
  86. package/dist/module/components/FontScaleButton.js.map +1 -1
  87. package/dist/module/components/FontScalePopup.js +11 -10
  88. package/dist/module/components/FontScalePopup.js.map +1 -1
  89. package/dist/module/components/Forbidden.js +13 -13
  90. package/dist/module/components/Forbidden.js.map +1 -1
  91. package/dist/module/components/FormCard.js +4 -4
  92. package/dist/module/components/FormCard.js.map +1 -1
  93. package/dist/module/components/FormCardSection.js +20 -18
  94. package/dist/module/components/FormCardSection.js.map +1 -1
  95. package/dist/module/components/FormCardSectionOptionLauncher.js +13 -12
  96. package/dist/module/components/FormCardSectionOptionLauncher.js.map +1 -1
  97. package/dist/module/components/FormattedText.js +18 -16
  98. package/dist/module/components/FormattedText.js.map +1 -1
  99. package/dist/module/components/GenericInput.js +24 -21
  100. package/dist/module/components/GenericInput.js.map +1 -1
  101. package/dist/module/components/GenericInputSection.js +27 -26
  102. package/dist/module/components/GenericInputSection.js.map +1 -1
  103. package/dist/module/components/Header.js +70 -69
  104. package/dist/module/components/Header.js.map +1 -1
  105. package/dist/module/components/Icon.js +109 -0
  106. package/dist/module/components/Icon.js.map +1 -0
  107. package/dist/module/components/ImagePopup.js +211 -73
  108. package/dist/module/components/ImagePopup.js.map +1 -1
  109. package/dist/module/components/ImageUploadProgress.js +10 -9
  110. package/dist/module/components/ImageUploadProgress.js.map +1 -1
  111. package/dist/module/components/ImageUploader.js +116 -96
  112. package/dist/module/components/ImageUploader.js.map +1 -1
  113. package/dist/module/components/InlineButton.js +9 -8
  114. package/dist/module/components/InlineButton.js.map +1 -1
  115. package/dist/module/components/Input.js +28 -26
  116. package/dist/module/components/Input.js.map +1 -1
  117. package/dist/module/components/LoadingCircles.js +20 -20
  118. package/dist/module/components/LoadingCircles.js.map +1 -1
  119. package/dist/module/components/LoadingIndicator.js +11 -11
  120. package/dist/module/components/LoadingIndicator.js.map +1 -1
  121. package/dist/module/components/LoadingStateWidget.js +5 -5
  122. package/dist/module/components/LoadingStateWidget.js.map +1 -1
  123. package/dist/module/components/MediaPlayer.js +31 -31
  124. package/dist/module/components/MediaPlayer.js.map +1 -1
  125. package/dist/module/components/MiddlePopup.js +17 -11
  126. package/dist/module/components/MiddlePopup.js.map +1 -1
  127. package/dist/module/components/PDFPopup.js +52 -39
  128. package/dist/module/components/PDFPopup.js.map +1 -1
  129. package/dist/module/components/PlussChat.js +168 -149
  130. package/dist/module/components/PlussChat.js.map +1 -1
  131. package/dist/module/components/PlussChatMessage.js +42 -42
  132. package/dist/module/components/PlussChatMessage.js.map +1 -1
  133. package/dist/module/components/PlussChatTime.js +18 -17
  134. package/dist/module/components/PlussChatTime.js.map +1 -1
  135. package/dist/module/components/Popup.js +20 -19
  136. package/dist/module/components/Popup.js.map +1 -1
  137. package/dist/module/components/PopupMenu.js +15 -14
  138. package/dist/module/components/PopupMenu.js.map +1 -1
  139. package/dist/module/components/PositionedImage.js +20 -20
  140. package/dist/module/components/PositionedImage.js.map +1 -1
  141. package/dist/module/components/ProfilePic.js +10 -10
  142. package/dist/module/components/ProfilePic.js.map +1 -1
  143. package/dist/module/components/RadioButton.js +10 -9
  144. package/dist/module/components/RadioButton.js.map +1 -1
  145. package/dist/module/components/Reaction.js +18 -17
  146. package/dist/module/components/Reaction.js.map +1 -1
  147. package/dist/module/components/Reactions.js +7 -7
  148. package/dist/module/components/Reactions.js.map +1 -1
  149. package/dist/module/components/SharingTools.js +78 -43
  150. package/dist/module/components/SharingTools.js.map +1 -1
  151. package/dist/module/components/Spinner.js +5 -5
  152. package/dist/module/components/Spinner.js.map +1 -1
  153. package/dist/module/components/StickyFooter.js +6 -6
  154. package/dist/module/components/StickyFooter.js.map +1 -1
  155. package/dist/module/components/Text.js +57 -0
  156. package/dist/module/components/Text.js.map +1 -0
  157. package/dist/module/components/TickIcon.js +6 -6
  158. package/dist/module/components/TickIcon.js.map +1 -1
  159. package/dist/module/components/Toggle.js +10 -9
  160. package/dist/module/components/Toggle.js.map +1 -1
  161. package/dist/module/components/TouchableSearchBar.js +18 -17
  162. package/dist/module/components/TouchableSearchBar.js.map +1 -1
  163. package/dist/module/components/UserListPopup.js +20 -19
  164. package/dist/module/components/UserListPopup.js.map +1 -1
  165. package/dist/module/components/UserListing.js +41 -40
  166. package/dist/module/components/UserListing.js.map +1 -1
  167. package/dist/module/components/VideoPopup.js +20 -20
  168. package/dist/module/components/VideoPopup.js.map +1 -1
  169. package/dist/module/components/WarningPopup.js +21 -20
  170. package/dist/module/components/WarningPopup.js.map +1 -1
  171. package/dist/module/components/expo-image-picker-multiple/ImageBrowser.js +13 -13
  172. package/dist/module/components/expo-image-picker-multiple/ImageBrowser.js.map +1 -1
  173. package/dist/module/components/expo-image-picker-multiple/ImageTile.js +24 -23
  174. package/dist/module/components/expo-image-picker-multiple/ImageTile.js.map +1 -1
  175. package/dist/module/components/index.js +59 -58
  176. package/dist/module/components/index.js.map +1 -1
  177. package/dist/module/components/react-native-expo-image-cropper/ExpoImageManipulator.js +94 -64
  178. package/dist/module/components/react-native-expo-image-cropper/ExpoImageManipulator.js.map +1 -1
  179. package/dist/module/components/react-native-expo-image-cropper/ImageCropOverlay.js +64 -64
  180. package/dist/module/components/react-native-expo-image-cropper/ImageCropOverlay.js.map +1 -1
  181. package/dist/module/config.js +15 -10
  182. package/dist/module/config.js.map +1 -1
  183. package/dist/module/constants.js +3 -4
  184. package/dist/module/constants.js.map +1 -1
  185. package/dist/module/helper.js +83 -82
  186. package/dist/module/helper.js.map +1 -1
  187. package/dist/module/index.js +12 -12
  188. package/dist/module/index.js.map +1 -1
  189. package/dist/module/js/images/detectFaces.js +11 -10
  190. package/dist/module/js/images/detectFaces.js.map +1 -1
  191. package/dist/module/js/images/findLandmarkRange.js +8 -8
  192. package/dist/module/js/images/findLandmarkRange.js.map +1 -1
  193. package/dist/module/js/images/getScaledOffset.js.map +1 -1
  194. package/dist/module/js/site/getSiteLevelFromState.js +2 -2
  195. package/dist/module/js/site/getSiteLevelFromState.js.map +1 -1
  196. package/dist/module/js/site/isTVEnabled.js +2 -2
  197. package/dist/module/js/site/isTVEnabled.js.map +1 -1
  198. package/dist/module/session.js +6 -6
  199. package/dist/module/session.js.map +1 -1
  200. package/dist/module/styles.js +17 -17
  201. package/dist/module/styles.js.map +1 -1
  202. package/dist/module/withNavigationFocus.js +30 -0
  203. package/dist/module/withNavigationFocus.js.map +1 -0
  204. package/package.json +71 -68
  205. package/src/actions/FollowerActions.js +36 -32
  206. package/src/actions/MediaActions.js +25 -20
  207. package/src/actions/ResidentActions.js +26 -21
  208. package/src/actions/UserActions.js +22 -22
  209. package/src/actions/UserSettingsActions.js +11 -11
  210. package/src/actions/index.js +5 -5
  211. package/src/actions/types.js +16 -16
  212. package/src/apis/analyticsActions.js +17 -17
  213. package/src/apis/contactActions.js +20 -20
  214. package/src/apis/eventActions.js +153 -144
  215. package/src/apis/fileActions.js +96 -86
  216. package/src/apis/followerActions.js +29 -29
  217. package/src/apis/index.js +12 -12
  218. package/src/apis/notificationActions.js +44 -44
  219. package/src/apis/profileActions.js +8 -8
  220. package/src/apis/reactionActions.js +81 -73
  221. package/src/apis/settingActions.js +15 -15
  222. package/src/apis/stringActions.js +29 -25
  223. package/src/apis/typeActions.js +10 -10
  224. package/src/apis/userActions.js +93 -93
  225. package/src/assets/icons/fontawesome/fa-brands-400.ttf +0 -0
  226. package/src/assets/icons/fontawesome/fa-light-300.ttf +0 -0
  227. package/src/assets/icons/fontawesome/fa-regular-400.ttf +0 -0
  228. package/src/assets/icons/fontawesome/fa-solid-900.ttf +0 -0
  229. package/src/assets/icons/fontawesome/fa-thin-100.ttf +0 -0
  230. package/src/assets/icons/fontawesome/fa7-glyphmap.json +4205 -0
  231. package/src/colours.js +116 -96
  232. package/src/components/AddButton.js +32 -27
  233. package/src/components/AddToCalendarButton.js +236 -202
  234. package/src/components/Attachment.js +59 -36
  235. package/src/components/AudienceSelectorLauncher.js +52 -48
  236. package/src/components/AudienceSelectorPage.js +353 -311
  237. package/src/components/AutoOffsetImage.js +237 -196
  238. package/src/components/BackButton.js +57 -41
  239. package/src/components/CalendarPopup.js +127 -97
  240. package/src/components/CategoryTabs.js +208 -163
  241. package/src/components/CommentReply.js +370 -309
  242. package/src/components/CommentSection.js +974 -781
  243. package/src/components/ConfirmPopup.js +141 -110
  244. package/src/components/ConfirmationPopup.js +80 -69
  245. package/src/components/DocumentUploader.js +245 -215
  246. package/src/components/DropDownItem.js +70 -60
  247. package/src/components/DropDownMenu.js +31 -27
  248. package/src/components/EmptyStateMain.js +51 -44
  249. package/src/components/EmptyStateWidget.js +47 -38
  250. package/src/components/FontScaleButton.js +29 -25
  251. package/src/components/FontScalePopup.js +67 -56
  252. package/src/components/Forbidden.js +48 -46
  253. package/src/components/FormCard.js +21 -17
  254. package/src/components/FormCardSection.js +284 -233
  255. package/src/components/FormCardSectionOptionLauncher.js +72 -46
  256. package/src/components/FormattedText.js +128 -111
  257. package/src/components/GenericInput.js +168 -136
  258. package/src/components/GenericInputSection.js +209 -161
  259. package/src/components/Header.js +620 -474
  260. package/src/components/Icon.js +119 -0
  261. package/src/components/ImagePopup.js +425 -221
  262. package/src/components/ImageUploadProgress.js +49 -41
  263. package/src/components/ImageUploader.js +968 -797
  264. package/src/components/InlineButton.js +79 -69
  265. package/src/components/Input.js +190 -156
  266. package/src/components/LoadingCircles.js +233 -233
  267. package/src/components/LoadingIndicator.js +87 -76
  268. package/src/components/LoadingStateWidget.js +47 -37
  269. package/src/components/MediaPlayer.js +416 -387
  270. package/src/components/MiddlePopup.js +62 -33
  271. package/src/components/PDFPopup.js +212 -159
  272. package/src/components/PlussChat.js +1224 -1025
  273. package/src/components/PlussChatMessage.js +329 -298
  274. package/src/components/PlussChatTime.js +57 -53
  275. package/src/components/Popup.js +138 -116
  276. package/src/components/PopupMenu.js +140 -110
  277. package/src/components/PositionedImage.js +281 -237
  278. package/src/components/ProfilePic.js +122 -113
  279. package/src/components/RadioButton.js +76 -52
  280. package/src/components/Reaction.js +134 -96
  281. package/src/components/Reactions.js +65 -63
  282. package/src/components/SharingTools.js +185 -134
  283. package/src/components/Spinner.js +13 -13
  284. package/src/components/StickyFooter.js +36 -26
  285. package/src/components/Text.js +62 -0
  286. package/src/components/TickIcon.js +20 -20
  287. package/src/components/Toggle.js +74 -73
  288. package/src/components/TouchableSearchBar.js +68 -50
  289. package/src/components/UserListPopup.js +161 -124
  290. package/src/components/UserListing.js +273 -238
  291. package/src/components/VideoPopup.js +110 -96
  292. package/src/components/WarningPopup.js +92 -71
  293. package/src/components/expo-image-picker-multiple/ImageBrowser.js +288 -256
  294. package/src/components/expo-image-picker-multiple/ImageTile.js +108 -84
  295. package/src/components/index.js +59 -58
  296. package/src/components/react-native-expo-image-cropper/ExpoImageManipulator.js +444 -359
  297. package/src/components/react-native-expo-image-cropper/ImageCropOverlay.js +420 -324
  298. package/src/config.js +26 -21
  299. package/src/constants.js +8 -10
  300. package/src/helper.js +469 -438
  301. package/src/index.js +24 -12
  302. package/src/js/images/detectFaces.js +28 -21
  303. package/src/js/images/findLandmarkRange.js +97 -90
  304. package/src/js/images/getScaledOffset.js +80 -75
  305. package/src/js/site/getSiteLevelFromState.js +26 -26
  306. package/src/js/site/isTVEnabled.js +10 -10
  307. package/src/session.js +32 -32
  308. package/src/styles.js +61 -61
  309. package/src/withNavigationFocus.js +28 -0
  310. package/dist/module/components/TextStyle.js +0 -45
  311. package/dist/module/components/TextStyle.js.map +0 -1
  312. package/dist/module/fonts/index.js +0 -2
  313. package/dist/module/fonts/index.js.map +0 -1
  314. package/dist/module/fonts/pluss60-icons.js +0 -5
  315. package/dist/module/fonts/pluss60-icons.js.map +0 -1
  316. package/dist/module/fonts/pluss60-icons.json +0 -1097
  317. package/src/components/TextStyle.js +0 -48
  318. package/src/fonts/index.js +0 -1
  319. package/src/fonts/pluss60-icons.js +0 -7
  320. package/src/fonts/pluss60-icons.json +0 -1097
package/src/helper.js CHANGED
@@ -1,525 +1,556 @@
1
- import _ from 'lodash';
2
- import React from 'react';
3
- import { Platform, StatusBar, Dimensions, Text } from 'react-native';
4
- import Constants from 'expo-constants';
5
- import Config from './config';
6
- import { LINEGREY } from './colours';
7
- import { getSessionTokenAWS } from './session';
1
+ import _ from "lodash";
2
+ import React from "react";
3
+ import { Platform, StatusBar, Dimensions } from "react-native";
4
+ import { Text } from "./components";
5
+ import Constants from "expo-constants";
6
+ import Config from "./config";
7
+ import { LINEGREY } from "./colours";
8
+ import { getSessionTokenAWS } from "./session";
8
9
 
9
10
  // seperated files to export
10
- import detectFaces from './js/images/detectFaces';
11
- import findLandmarkRange from './js/images/findLandmarkRange';
12
- import getScaledOffset from './js/images/getScaledOffset';
11
+ import detectFaces from "./js/images/detectFaces";
12
+ import findLandmarkRange from "./js/images/findLandmarkRange";
13
+ import getScaledOffset from "./js/images/getScaledOffset";
13
14
 
14
- import getSiteLevelFromState from './js/site/getSiteLevelFromState';
15
- import isTVEnabled from './js/site/isTVEnabled';
15
+ import getSiteLevelFromState from "./js/site/getSiteLevelFromState";
16
+ import isTVEnabled from "./js/site/isTVEnabled";
16
17
 
17
- const TIMESTAMP_FORMAT = 'D MMM • h:mma';
18
- const DATE_FORMAT = 'D MMM YYYY';
18
+ const TIMESTAMP_FORMAT = "D MMM • h:mma";
19
+ const DATE_FORMAT = "D MMM YYYY";
19
20
 
20
21
  const getUrl = (baseAction, action, query) => {
21
- const { baseAPIUrl, baseStage } = Config.env;
22
- let queryPart = '';
23
- if (query) {
24
- _.keys(query).forEach((key, index) => {
25
- queryPart += `${index === 0 ? '?' : '&'}${key}=${encodeURIComponent(query[key])}`;
26
- });
27
- }
28
- return `${baseAPIUrl}/${baseAction}-${baseStage}/${action}${queryPart}`;
22
+ const { baseAPIUrl, baseStage } = Config.env;
23
+ let queryPart = "";
24
+ if (query) {
25
+ _.keys(query).forEach((key, index) => {
26
+ queryPart += `${index === 0 ? "?" : "&"}${key}=${encodeURIComponent(query[key])}`;
27
+ });
28
+ }
29
+ return `${baseAPIUrl}/${baseAction}-${baseStage}/${action}${queryPart}`;
29
30
  };
30
31
 
31
32
  const getAuthTokenHeader = () => {
32
- return new Promise((resolve, reject) => {
33
- getSessionTokenAWS().then(idToken => {
34
- resolve(`Bearer ${idToken}`);
35
- });
36
- });
33
+ return new Promise((resolve, reject) => {
34
+ getSessionTokenAWS().then((idToken) => {
35
+ resolve(`Bearer ${idToken}`);
36
+ });
37
+ });
37
38
  };
38
39
 
39
40
  const getShadowStyle = () => {
40
- if (Platform.OS === 'ios') {
41
- return {
42
- shadowColor: '#000',
43
- shadowOffset: {
44
- width: 0,
45
- height: 1,
46
- },
47
- shadowOpacity: 0.1,
48
- shadowRadius: 3,
49
- backgroundColor: '#fff',
50
- };
51
- }
52
- return {
53
- borderColor: LINEGREY,
54
- backgroundColor: '#fff',
55
- elevation: 8,
56
- };
57
- };
58
-
59
- const StatusBarHeight = size => {
60
- return getStatusBarHeight() + size;
41
+ if (Platform.OS === "ios") {
42
+ return {
43
+ shadowColor: "#000",
44
+ shadowOffset: {
45
+ width: 0,
46
+ height: 1,
47
+ },
48
+ shadowOpacity: 0.1,
49
+ shadowRadius: 3,
50
+ backgroundColor: "#fff",
51
+ };
52
+ }
53
+ return {
54
+ borderColor: LINEGREY,
55
+ backgroundColor: "#fff",
56
+ elevation: 8,
57
+ };
58
+ };
59
+
60
+ const StatusBarHeight = (size) => {
61
+ return getStatusBarHeight() + size;
61
62
  };
62
63
 
63
64
  const getStatusBarHeight = () => {
64
- return Platform.OS === 'ios' ? Constants.statusBarHeight : StatusBar.currentHeight;
65
+ return Platform.OS === "ios"
66
+ ? Constants.statusBarHeight
67
+ : StatusBar.currentHeight;
65
68
  };
66
69
 
67
70
  const getSiteSettingFromState = (state, key, defaultValue) => {
68
- if (state && state.user && state.user.siteSettings && !_.isUndefined(state.user.siteSettings[key])) {
69
- return state.user.siteSettings[key];
70
- }
71
- return defaultValue || null;
71
+ if (
72
+ state &&
73
+ state.user &&
74
+ state.user.siteSettings &&
75
+ !_.isUndefined(state.user.siteSettings[key])
76
+ ) {
77
+ return state.user.siteSettings[key];
78
+ }
79
+ return defaultValue || null;
72
80
  };
73
81
 
74
82
  const getValueOrDefault = (value, def) => {
75
- return !_.isUndefined(value) ? value : def;
83
+ return !_.isUndefined(value) ? value : def;
76
84
  };
77
85
 
78
- const getExtension = url => {
79
- if (!url) {
80
- return null;
81
- }
82
- const fileSplit = url.split('.');
83
- return fileSplit[fileSplit.length - 1].toLowerCase();
86
+ const getExtension = (url) => {
87
+ if (!url) {
88
+ return null;
89
+ }
90
+ const fileSplit = url.split(".");
91
+ return fileSplit[fileSplit.length - 1].toLowerCase();
84
92
  };
85
93
 
86
94
  const getFileName = (url, noExtension) => {
87
- if (!url) {
88
- return null;
89
- }
90
- const fileSplit = url.split('/');
91
- const name = fileSplit[fileSplit.length - 1].toLowerCase();
92
- if (!noExtension) {
93
- return name;
94
- }
95
- return name.split('.')[0];
96
- };
97
-
98
- const isVideo = url => {
99
- const extension = getExtension(url);
100
- return ['mov', 'mp4'].includes(extension);
101
- };
102
-
103
- const isVideoUrl = url => {
104
- const urlToCheck = getValidUrl(url);
105
- if (isVideo(urlToCheck)) {
106
- return true;
107
- }
108
- if (isYoutube(urlToCheck)) {
109
- return true;
110
- }
111
- if (isVimeo(urlToCheck)) {
112
- return true;
113
- }
114
- return false;
115
- };
116
-
117
- const isStockImage = url => {
118
- return url.indexOf('https://pluss60-dev-uploads.s3.ap-southeast-2.amazonaws.com/uploads/library') !== -1;
119
- };
120
-
121
- const getThumb300 = url => {
122
- if (!url) {
123
- return url;
124
- }
125
- if (isVideo(url)) {
126
- return 'https://pluss60-demo-uploads.s3.ap-southeast-2.amazonaws.com/uploads/users/ap-southeast-2:97769b56-25ec-41c0-a73c-6c2c4140f629/public/9d0bbec64614b1ed654a03f7e7/movie.jpg';
127
- }
128
- if (url.indexOf('https://plussprdstorage.blob.core.windows.net/') !== -1) {
129
- return url.replace('https://plussprdstorage.blob.core.windows.net/', 'https://plusscdn.azureedge.net/');
130
- }
131
- if (url.indexOf('https://plusscdn.azureedge.net/') !== -1) {
132
- return url
133
- .replace('/uploads/', '/uploads-thumb/')
134
- .replace('/general/', '/general300/')
135
- .replace('/uploads1400/', '/uploads-thumb/')
136
- .replace('/general1400/', '/general300/');
137
- }
138
- if (isStockImage(url) || url.indexOf(Config.env.baseUploadsUrl) !== -1) {
139
- const extension = getExtension(url);
140
- let urlToUse = url;
141
- if (extension !== 'jpg') {
142
- urlToUse = `${url.substring(0, url.length - extension.length)}jpg`;
143
- }
144
- return urlToUse.replace('/1400/', '/thumb300/').replace('/uploads/', '/thumb300/');
145
- }
146
- return url;
147
- };
148
-
149
- const get1400 = url => {
150
- if (!url) {
151
- return url;
152
- }
153
- if (url.indexOf('https://plussprdstorage.blob.core.windows.net/') !== -1) {
154
- return url.replace('https://plussprdstorage.blob.core.windows.net/', 'https://plusscdn.azureedge.net/');
155
- }
156
- if (url.indexOf('https://plusscdn.azureedge.net/') !== -1) {
157
- return url.replace('/uploads/', '/uploads1400/').replace('/general/', '/general1400/');
158
- }
159
- if (isStockImage(url) || url.indexOf(Config.env.baseUploadsUrl) !== -1) {
160
- const extension = getExtension(url);
161
- let urlToUse = url;
162
- if (extension !== 'jpg') {
163
- urlToUse = `${url.substring(0, url.length - extension.length)}jpg`;
164
- }
165
- return urlToUse.replace('/uploads/', '/1400/');
166
- }
167
- return url;
168
- };
169
-
170
- const get300 = url => {
171
- if (!url) {
172
- return url;
173
- }
174
- if (isStockImage(url) || url.indexOf(Config.env.baseUploadsUrl) !== -1) {
175
- const extension = getExtension(url);
176
- let urlToUse = url;
177
- if (extension !== 'jpg') {
178
- urlToUse = `${url.substring(0, url.length - extension.length)}jpg`;
179
- }
180
- return urlToUse.replace('/uploads/', '/300/').replace('/1400/', '/300/');
181
- }
182
- return url;
183
- };
184
-
185
- const getMimeType = url => {
186
- const extension = getExtension(url);
187
- switch (extension) {
188
- case 'mov':
189
- return 'video/quicktime';
190
- case 'mp4':
191
- return 'video/mp4';
192
- default:
193
- return 'image/jpeg';
194
- }
195
- };
196
-
197
- const getCompressed = url => {
198
- if (!url || typeof url !== 'string') return '';
199
- return url.replace('/uploads/', '/compressed/');
200
- };
201
-
202
- const imageExists = url => {
203
- return new Promise(resolve => {
204
- fetch(url, { method: 'HEAD', cache: 'no-cache' })
205
- .then(response => {
206
- resolve(response.status === 200);
207
- })
208
- .catch(() => {
209
- resolve(false);
210
- });
211
- });
95
+ if (!url) {
96
+ return null;
97
+ }
98
+ const fileSplit = url.split("/");
99
+ const name = fileSplit[fileSplit.length - 1].toLowerCase();
100
+ if (!noExtension) {
101
+ return name;
102
+ }
103
+ return name.split(".")[0];
104
+ };
105
+
106
+ const isVideo = (url) => {
107
+ const extension = getExtension(url);
108
+ return ["mov", "mp4"].includes(extension);
109
+ };
110
+
111
+ const isVideoUrl = (url) => {
112
+ const urlToCheck = getValidUrl(url);
113
+ if (isVideo(urlToCheck)) {
114
+ return true;
115
+ }
116
+ if (isYoutube(urlToCheck)) {
117
+ return true;
118
+ }
119
+ if (isVimeo(urlToCheck)) {
120
+ return true;
121
+ }
122
+ return false;
123
+ };
124
+
125
+ const isStockImage = (url) => {
126
+ return (
127
+ url.indexOf(
128
+ "https://pluss60-dev-uploads.s3.ap-southeast-2.amazonaws.com/uploads/library",
129
+ ) !== -1
130
+ );
131
+ };
132
+
133
+ const getThumb300 = (url) => {
134
+ if (!url) {
135
+ return url;
136
+ }
137
+ if (isVideo(url)) {
138
+ return "https://pluss60-demo-uploads.s3.ap-southeast-2.amazonaws.com/uploads/users/ap-southeast-2:97769b56-25ec-41c0-a73c-6c2c4140f629/public/9d0bbec64614b1ed654a03f7e7/movie.jpg";
139
+ }
140
+ if (url.indexOf("https://plussprdstorage.blob.core.windows.net/") !== -1) {
141
+ return url.replace(
142
+ "https://plussprdstorage.blob.core.windows.net/",
143
+ "https://plusscdn.azureedge.net/",
144
+ );
145
+ }
146
+ if (url.indexOf("https://plusscdn.azureedge.net/") !== -1) {
147
+ return url
148
+ .replace("/uploads/", "/uploads-thumb/")
149
+ .replace("/general/", "/general300/")
150
+ .replace("/uploads1400/", "/uploads-thumb/")
151
+ .replace("/general1400/", "/general300/");
152
+ }
153
+ if (isStockImage(url) || url.indexOf(Config.env.baseUploadsUrl) !== -1) {
154
+ const extension = getExtension(url);
155
+ let urlToUse = url;
156
+ if (extension !== "jpg") {
157
+ urlToUse = `${url.substring(0, url.length - extension.length)}jpg`;
158
+ }
159
+ return urlToUse
160
+ .replace("/1400/", "/thumb300/")
161
+ .replace("/uploads/", "/thumb300/");
162
+ }
163
+ return url;
164
+ };
165
+
166
+ const get1400 = (url) => {
167
+ if (!url) {
168
+ return url;
169
+ }
170
+ if (url.indexOf("https://plussprdstorage.blob.core.windows.net/") !== -1) {
171
+ return url.replace(
172
+ "https://plussprdstorage.blob.core.windows.net/",
173
+ "https://plusscdn.azureedge.net/",
174
+ );
175
+ }
176
+ if (url.indexOf("https://plusscdn.azureedge.net/") !== -1) {
177
+ return url
178
+ .replace("/uploads/", "/uploads1400/")
179
+ .replace("/general/", "/general1400/");
180
+ }
181
+ if (isStockImage(url) || url.indexOf(Config.env.baseUploadsUrl) !== -1) {
182
+ const extension = getExtension(url);
183
+ let urlToUse = url;
184
+ if (extension !== "jpg") {
185
+ urlToUse = `${url.substring(0, url.length - extension.length)}jpg`;
186
+ }
187
+ return urlToUse.replace("/uploads/", "/1400/");
188
+ }
189
+ return url;
190
+ };
191
+
192
+ const get300 = (url) => {
193
+ if (!url) {
194
+ return url;
195
+ }
196
+ if (isStockImage(url) || url.indexOf(Config.env.baseUploadsUrl) !== -1) {
197
+ const extension = getExtension(url);
198
+ let urlToUse = url;
199
+ if (extension !== "jpg") {
200
+ urlToUse = `${url.substring(0, url.length - extension.length)}jpg`;
201
+ }
202
+ return urlToUse.replace("/uploads/", "/300/").replace("/1400/", "/300/");
203
+ }
204
+ return url;
205
+ };
206
+
207
+ const getMimeType = (url) => {
208
+ const extension = getExtension(url);
209
+ switch (extension) {
210
+ case "mov":
211
+ return "video/quicktime";
212
+ case "mp4":
213
+ return "video/mp4";
214
+ default:
215
+ return "image/jpeg";
216
+ }
217
+ };
218
+
219
+ const getCompressed = (url) => {
220
+ if (!url || typeof url !== "string") return "";
221
+ return url.replace("/uploads/", "/compressed/");
222
+ };
223
+
224
+ const imageExists = (url) => {
225
+ return new Promise((resolve) => {
226
+ fetch(url, { method: "HEAD", cache: "no-cache" })
227
+ .then((response) => {
228
+ resolve(response.status === 200);
229
+ })
230
+ .catch(() => {
231
+ resolve(false);
232
+ });
233
+ });
212
234
  };
213
235
 
214
236
  const formatTime = (hours, minutes) => {
215
- const period = hours >= 12 ? 'pm' : 'am';
237
+ const period = hours >= 12 ? "pm" : "am";
216
238
 
217
- // Convert 24-hour format to 12-hour format
218
- const adjustedHours = hours > 12 ? hours - 12 : hours === 0 ? 12 : hours;
239
+ // Convert 24-hour format to 12-hour format
240
+ const adjustedHours = hours > 12 ? hours - 12 : hours === 0 ? 12 : hours;
219
241
 
220
- // Ensure minutes are two digits
221
- const adjustedMinutes = String(minutes).padStart(2, '0');
242
+ // Ensure minutes are two digits
243
+ const adjustedMinutes = String(minutes).padStart(2, "0");
222
244
 
223
- return `${adjustedHours}:${adjustedMinutes}${period}`;
245
+ return `${adjustedHours}:${adjustedMinutes}${period}`;
224
246
  };
225
247
 
226
248
  const minutesToString = (minutes, isTimeOfDay) => {
227
- const hours = Math.floor(minutes / 60);
228
- const remainingMinutes = minutes % 60;
249
+ const hours = Math.floor(minutes / 60);
250
+ const remainingMinutes = minutes % 60;
229
251
 
230
- if (isTimeOfDay) {
231
- return formatTime(hours, remainingMinutes);
232
- }
252
+ if (isTimeOfDay) {
253
+ return formatTime(hours, remainingMinutes);
254
+ }
233
255
 
234
- const hoursString = hours > 1 ? `${hours} hours` : `${hours} hour`;
235
- const minutesString = remainingMinutes > 1 ? `${remainingMinutes} minutes` : `${remainingMinutes} minute`;
256
+ const hoursString = hours > 1 ? `${hours} hours` : `${hours} hour`;
257
+ const minutesString =
258
+ remainingMinutes > 1
259
+ ? `${remainingMinutes} minutes`
260
+ : `${remainingMinutes} minute`;
236
261
 
237
- if (hours && remainingMinutes) {
238
- return `${hoursString} ${minutesString}`;
239
- }
240
- if (hours) {
241
- return hoursString;
242
- }
243
- if (remainingMinutes) {
244
- return minutesString;
245
- }
246
- return '0 minutes';
262
+ if (hours && remainingMinutes) {
263
+ return `${hoursString} ${minutesString}`;
264
+ }
265
+ if (hours) {
266
+ return hoursString;
267
+ }
268
+ if (remainingMinutes) {
269
+ return minutesString;
270
+ }
271
+ return "0 minutes";
247
272
  };
248
273
 
249
- const getPluralS = count => {
250
- return count === 1 ? '' : 's';
274
+ const getPluralS = (count) => {
275
+ return count === 1 ? "" : "s";
251
276
  };
252
277
 
253
278
  const getPluralOptions = (count, singular, plural) => {
254
- if (count === 1) {
255
- return singular;
256
- }
257
- return plural;
279
+ if (count === 1) {
280
+ return singular;
281
+ }
282
+ return plural;
258
283
  };
259
284
 
260
- const isEmail = email => {
261
- if (_.isEmpty(email)) {
262
- return false;
263
- }
264
- const atpos = email.indexOf('@');
265
- const dotpos = email.lastIndexOf('.');
266
- if (atpos < 1 || dotpos < atpos + 2 || dotpos + 2 >= email.length) {
267
- return false;
268
- }
269
- return true;
285
+ const isEmail = (email) => {
286
+ if (_.isEmpty(email)) {
287
+ return false;
288
+ }
289
+ const atpos = email.indexOf("@");
290
+ const dotpos = email.lastIndexOf(".");
291
+ if (atpos < 1 || dotpos < atpos + 2 || dotpos + 2 >= email.length) {
292
+ return false;
293
+ }
294
+ return true;
270
295
  };
271
296
 
272
- const randomString = (name = '') => {
273
- return `xxxxxxxx4xxxyxxxxxxxxxxxxx${name}`.replace(/[xy]/g, c => {
274
- // eslint-disable-next-line
275
- var r = (Math.random() * 16) | 0,
276
- v = c === 'x' ? r : (r & 0x3) | 0x8;
277
- return v.toString(16);
278
- });
297
+ const randomString = (name = "") => {
298
+ return `xxxxxxxx4xxxyxxxxxxxxxxxxx${name}`.replace(/[xy]/g, (c) => {
299
+ // eslint-disable-next-line
300
+ var r = (Math.random() * 16) | 0,
301
+ v = c === "x" ? r : (r & 0x3) | 0x8;
302
+ return v.toString(16);
303
+ });
279
304
  };
280
305
 
281
306
  const generateImageName = (name, source) => {
282
- let result = randomString(name);
283
- if (source) {
284
- result += `.${_.last(source.split('.'))}`;
285
- }
286
- return result;
307
+ let result = randomString(name);
308
+ if (source) {
309
+ result += `.${_.last(source.split("."))}`;
310
+ }
311
+ return result;
287
312
  };
288
313
 
289
- const getSite = site => {
290
- return site === 'plussSpace' || site === 'hq' ? Config.env.preferredSite : site;
314
+ const getSite = (site) => {
315
+ return site === "plussSpace" || site === "hq"
316
+ ? Config.env.preferredSite
317
+ : site;
291
318
  };
292
319
 
293
- const getTakeoverThumb = uri => {
294
- const filename = uri.split('/').pop();
295
- switch (filename) {
296
- default:
297
- return { uri };
298
- }
320
+ const getTakeoverThumb = (uri) => {
321
+ const filename = uri.split("/").pop();
322
+ switch (filename) {
323
+ default:
324
+ return { uri };
325
+ }
299
326
  };
300
327
 
301
- const getTakeoverImage = uri => {
302
- const filename = uri.split('/').pop();
303
- switch (filename) {
304
- default:
305
- return { uri };
306
- }
328
+ const getTakeoverImage = (uri) => {
329
+ const filename = uri.split("/").pop();
330
+ switch (filename) {
331
+ default:
332
+ return { uri };
333
+ }
307
334
  };
308
335
 
309
336
  const getImageSource = (uri, isThumb) => {
310
- if (uri == null) return null;
311
- if (isThumb) return getTakeoverThumb(uri);
312
- return getTakeoverImage(uri);
337
+ if (uri == null) return null;
338
+ if (isThumb) return getTakeoverThumb(uri);
339
+ return getTakeoverImage(uri);
313
340
  };
314
341
 
315
- const getFirstName = name => {
316
- if (_.isEmpty(name)) {
317
- return name;
318
- }
319
- return name.split(' ')[0];
342
+ const getFirstName = (name) => {
343
+ if (_.isEmpty(name)) {
344
+ return name;
345
+ }
346
+ return name.split(" ")[0];
320
347
  };
321
348
 
322
349
  const usersToSearchResult = (contacts, excludedUserIds) => {
323
- let result = [];
324
- contacts.forEach(user => {
325
- result.push({
326
- displayName: user.displayName,
327
- id: user.objectID || user.id || user.ID || user.userId || user.Id,
328
- profilePic: user.profilePic || user.photoURL || null,
329
- unit: user.unit,
330
- });
331
- });
332
- result = _.reject(result, contact => {
333
- return _.includes(excludedUserIds, contact.id);
334
- });
335
- return result;
350
+ let result = [];
351
+ contacts.forEach((user) => {
352
+ result.push({
353
+ displayName: user.displayName,
354
+ id: user.objectID || user.id || user.ID || user.userId || user.Id,
355
+ profilePic: user.profilePic || user.photoURL || null,
356
+ unit: user.unit,
357
+ });
358
+ });
359
+ result = _.reject(result, (contact) => {
360
+ return _.includes(excludedUserIds, contact.id);
361
+ });
362
+ return result;
336
363
  };
337
364
 
338
365
  const searchUsers = (source, term) => {
339
- if (_.isEmpty(term)) {
340
- return source;
341
- }
342
- return _.filter(source, user => {
343
- const split = user.displayName.split(' ');
344
- return _.some(split, part => {
345
- return part.toLowerCase().indexOf(term.toLowerCase()) === 0;
346
- });
347
- });
366
+ if (_.isEmpty(term)) {
367
+ return source;
368
+ }
369
+ return _.filter(source, (user) => {
370
+ const split = user.displayName.split(" ");
371
+ return _.some(split, (part) => {
372
+ return part.toLowerCase().indexOf(term.toLowerCase()) === 0;
373
+ });
374
+ });
348
375
  };
349
376
 
350
- const getTabSettingsFromState = state => {
351
- const tabSettings = (state.user && state.user.interface) || getSiteSettingFromState(state, 'TabSettings', null);
352
- return tabSettings;
377
+ const getTabSettingsFromState = (state) => {
378
+ const tabSettings =
379
+ (state.user && state.user.interface) ||
380
+ getSiteSettingFromState(state, "TabSettings", null);
381
+ return tabSettings;
353
382
  };
354
383
 
355
- const getEnabledTabsFromState = state => {
356
- const tabSettings = getTabSettingsFromState(state);
357
- return tabSettings ? tabSettings.filter(tab => tab.isEnabled) : [];
384
+ const getEnabledTabsFromState = (state) => {
385
+ const tabSettings = getTabSettingsFromState(state);
386
+ return tabSettings ? tabSettings.filter((tab) => tab.isEnabled) : [];
358
387
  };
359
388
 
360
389
  const getReactions = () => {
361
- return [
362
- {
363
- key: 'heart',
364
- icon: require('./assets/icons/reactions/heart.png'),
365
- },
366
- {
367
- key: 'smile',
368
- icon: require('./assets/icons/reactions/smile.png'),
369
- },
370
- {
371
- key: 'sad',
372
- icon: require('./assets/icons/reactions/sad.png'),
373
- },
374
- {
375
- key: 'party',
376
- icon: require('./assets/icons/reactions/party.png'),
377
- },
378
- ];
390
+ return [
391
+ {
392
+ key: "heart",
393
+ icon: require("./assets/icons/reactions/heart.png"),
394
+ },
395
+ {
396
+ key: "smile",
397
+ icon: require("./assets/icons/reactions/smile.png"),
398
+ },
399
+ {
400
+ key: "sad",
401
+ icon: require("./assets/icons/reactions/sad.png"),
402
+ },
403
+ {
404
+ key: "party",
405
+ icon: require("./assets/icons/reactions/party.png"),
406
+ },
407
+ ];
379
408
  };
380
409
 
381
410
  const hasReacted = (reactions, userId) => {
382
- return _.some(reactions, r => {
383
- return !!r[userId];
384
- });
411
+ return _.some(reactions, (r) => {
412
+ return !!r[userId];
413
+ });
385
414
  };
386
415
 
387
416
  const isTablet = () => {
388
- return Dimensions.get('screen').width > 600;
389
- };
390
-
391
- const isVimeo = url => {
392
- if (_.isEmpty(url)) {
393
- return false;
394
- }
395
- if (url.indexOf('https://vimeo.com/') === 0) {
396
- return true;
397
- }
398
- if (url.indexOf('https://player.vimeo.com/video/') === 0) {
399
- return true;
400
- }
401
- };
402
-
403
- const getVimeoEmbed = url => {
404
- if (_.isEmpty(url)) {
405
- return '';
406
- }
407
- if (url.indexOf('https://vimeo.com/') === 0) {
408
- const vimeoId = 'lol'; //TODO
409
- return `https://player.vimeo.com/video/${vimeoId}`;
410
- }
411
- return url; //TODO
412
- };
413
-
414
- const isYoutube = url => {
415
- if (_.isUndefined(url) || _.isEmpty(url)) {
416
- return false;
417
- }
418
- const regExp = /^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=|\?v=)([^#\&\?]*).*/;
419
- const match = url.match(regExp);
420
- if (match && match[2].length === 11) {
421
- return true;
422
- }
423
- return false;
424
- };
425
-
426
- const getYoutubeEmbed = url => {
427
- const regExp = /^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=|\?v=)([^#\&\?]*).*/;
428
- const match = url.match(regExp);
429
- return `https://www.youtube.com/embed/${match[2]}?autoplay=0`;
430
- };
431
-
432
- const getValidUrl = (url = '') => {
433
- let newUrl = decodeURIComponent(url);
434
- newUrl = newUrl.trim().replace(/\s/g, '');
435
-
436
- if (/^(:\/\/)/.test(newUrl)) {
437
- return `https${newUrl}`;
438
- }
439
- if (!/^(f|ht)tps?:\/\//i.test(newUrl)) {
440
- return `https://${newUrl}`;
441
- }
442
-
443
- return newUrl;
444
- };
445
-
446
- const getUserPreview = user => {
447
- return {
448
- id: user.uid,
449
- displayName: user.displayName,
450
- profilePic: user.profilePic || null,
451
- };
452
- };
453
-
454
- const allowComments = canComment => {
455
- if (canComment === false) {
456
- return false;
457
- }
458
- if (canComment === true) {
459
- return true;
460
- }
461
- return Config.env.defaultAllowComments;
417
+ return Dimensions.get("screen").width > 600;
418
+ };
419
+
420
+ const isVimeo = (url) => {
421
+ if (_.isEmpty(url)) {
422
+ return false;
423
+ }
424
+ if (url.indexOf("https://vimeo.com/") === 0) {
425
+ return true;
426
+ }
427
+ if (url.indexOf("https://player.vimeo.com/video/") === 0) {
428
+ return true;
429
+ }
430
+ };
431
+
432
+ const getVimeoEmbed = (url) => {
433
+ if (_.isEmpty(url)) {
434
+ return "";
435
+ }
436
+ if (url.indexOf("https://vimeo.com/") === 0) {
437
+ const vimeoId = "lol"; //TODO
438
+ return `https://player.vimeo.com/video/${vimeoId}`;
439
+ }
440
+ return url; //TODO
441
+ };
442
+
443
+ const isYoutube = (url) => {
444
+ if (_.isUndefined(url) || _.isEmpty(url)) {
445
+ return false;
446
+ }
447
+ const regExp =
448
+ /^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=|\?v=)([^#\&\?]*).*/;
449
+ const match = url.match(regExp);
450
+ if (match && match[2].length === 11) {
451
+ return true;
452
+ }
453
+ return false;
454
+ };
455
+
456
+ const getYoutubeEmbed = (url) => {
457
+ const regExp =
458
+ /^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=|\?v=)([^#\&\?]*).*/;
459
+ const match = url.match(regExp);
460
+ return `https://www.youtube.com/embed/${match[2]}?autoplay=0`;
461
+ };
462
+
463
+ const getValidUrl = (url = "") => {
464
+ let newUrl = decodeURIComponent(url);
465
+ newUrl = newUrl.trim().replace(/\s/g, "");
466
+
467
+ if (/^(:\/\/)/.test(newUrl)) {
468
+ return `https${newUrl}`;
469
+ }
470
+ if (!/^(f|ht)tps?:\/\//i.test(newUrl)) {
471
+ return `https://${newUrl}`;
472
+ }
473
+
474
+ return newUrl;
475
+ };
476
+
477
+ const getUserPreview = (user) => {
478
+ return {
479
+ id: user.uid,
480
+ displayName: user.displayName,
481
+ profilePic: user.profilePic || null,
482
+ };
483
+ };
484
+
485
+ const allowComments = (canComment) => {
486
+ if (canComment === false) {
487
+ return false;
488
+ }
489
+ if (canComment === true) {
490
+ return true;
491
+ }
492
+ return Config.env.defaultAllowComments;
462
493
  };
463
494
 
464
495
  const toParagraphed = (text, style) => {
465
- if (!text) {
466
- return text;
467
- }
468
- const textSplit = text.split('\n');
469
- return _.map(textSplit, (t, i) => {
470
- return (
471
- <Text key={`paragraph_${i}`} style={style}>
472
- {t}
473
- </Text>
474
- );
475
- });
496
+ if (!text) {
497
+ return text;
498
+ }
499
+ const textSplit = text.split("\n");
500
+ return _.map(textSplit, (t, i) => {
501
+ return (
502
+ <Text key={`paragraph_${i}`} style={style}>
503
+ {t}
504
+ </Text>
505
+ );
506
+ });
476
507
  };
477
508
 
478
509
  export {
479
- TIMESTAMP_FORMAT,
480
- DATE_FORMAT,
481
- getUrl,
482
- getAuthTokenHeader,
483
- getShadowStyle,
484
- StatusBarHeight,
485
- getStatusBarHeight,
486
- getSiteSettingFromState,
487
- getValueOrDefault,
488
- getExtension,
489
- getFileName,
490
- isVideo,
491
- get300,
492
- getThumb300,
493
- get1400,
494
- getMimeType,
495
- getCompressed,
496
- imageExists,
497
- getPluralS,
498
- getPluralOptions,
499
- isEmail,
500
- formatTime,
501
- minutesToString,
502
- randomString,
503
- generateImageName,
504
- getSite,
505
- getImageSource,
506
- getFirstName,
507
- usersToSearchResult,
508
- searchUsers,
509
- getEnabledTabsFromState,
510
- getReactions,
511
- hasReacted,
512
- isTablet,
513
- isYoutube,
514
- getYoutubeEmbed,
515
- getValidUrl,
516
- getUserPreview,
517
- allowComments,
518
- toParagraphed,
519
- isVideoUrl,
520
- detectFaces,
521
- findLandmarkRange,
522
- getScaledOffset,
523
- getSiteLevelFromState,
524
- isTVEnabled,
510
+ TIMESTAMP_FORMAT,
511
+ DATE_FORMAT,
512
+ getUrl,
513
+ getAuthTokenHeader,
514
+ getShadowStyle,
515
+ StatusBarHeight,
516
+ getStatusBarHeight,
517
+ getSiteSettingFromState,
518
+ getValueOrDefault,
519
+ getExtension,
520
+ getFileName,
521
+ isVideo,
522
+ get300,
523
+ getThumb300,
524
+ get1400,
525
+ getMimeType,
526
+ getCompressed,
527
+ imageExists,
528
+ getPluralS,
529
+ getPluralOptions,
530
+ isEmail,
531
+ formatTime,
532
+ minutesToString,
533
+ randomString,
534
+ generateImageName,
535
+ getSite,
536
+ getImageSource,
537
+ getFirstName,
538
+ usersToSearchResult,
539
+ searchUsers,
540
+ getEnabledTabsFromState,
541
+ getReactions,
542
+ hasReacted,
543
+ isTablet,
544
+ isYoutube,
545
+ getYoutubeEmbed,
546
+ getValidUrl,
547
+ getUserPreview,
548
+ allowComments,
549
+ toParagraphed,
550
+ isVideoUrl,
551
+ detectFaces,
552
+ findLandmarkRange,
553
+ getScaledOffset,
554
+ getSiteLevelFromState,
555
+ isTVEnabled,
525
556
  };