@plusscommunities/pluss-core-app 1.6.1-beta.0 → 1.6.4-beta.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 (31) hide show
  1. package/dist/module/actions/MediaActions.js +10 -1
  2. package/dist/module/actions/MediaActions.js.map +1 -1
  3. package/dist/module/actions/UserSettingsActions.js +14 -0
  4. package/dist/module/actions/UserSettingsActions.js.map +1 -0
  5. package/dist/module/actions/index.js +1 -0
  6. package/dist/module/actions/index.js.map +1 -1
  7. package/dist/module/actions/types.js +3 -0
  8. package/dist/module/actions/types.js.map +1 -1
  9. package/dist/module/components/AutoOffsetImage.js +46 -10
  10. package/dist/module/components/AutoOffsetImage.js.map +1 -1
  11. package/dist/module/components/CommentSection.js +117 -11
  12. package/dist/module/components/CommentSection.js.map +1 -1
  13. package/dist/module/components/index.js +1 -1
  14. package/dist/module/components/index.js.map +1 -1
  15. package/dist/module/js/images/detectFaces.js +11 -9
  16. package/dist/module/js/images/detectFaces.js.map +1 -1
  17. package/dist/module/js/images/findLandmarkRange.js +28 -7
  18. package/dist/module/js/images/findLandmarkRange.js.map +1 -1
  19. package/dist/module/js/images/getScaledOffset.js +1 -1
  20. package/dist/module/js/images/getScaledOffset.js.map +1 -1
  21. package/package.json +1 -1
  22. package/src/actions/MediaActions.js +8 -1
  23. package/src/actions/UserSettingsActions.js +15 -0
  24. package/src/actions/index.js +1 -0
  25. package/src/actions/types.js +3 -0
  26. package/src/components/AutoOffsetImage.js +52 -10
  27. package/src/components/CommentSection.js +95 -9
  28. package/src/components/index.js +1 -1
  29. package/src/js/images/detectFaces.js +11 -13
  30. package/src/js/images/findLandmarkRange.js +32 -6
  31. package/src/js/images/getScaledOffset.js +1 -1
@@ -1,4 +1,4 @@
1
- import { IMAGE_LIBRARY_LOADED, STOCK_IMAGES_LOADED, IMAGE_FOLDER_UPDATED } from './types';
1
+ import { IMAGE_LIBRARY_LOADED, STOCK_IMAGES_LOADED, IMAGE_FOLDER_UPDATED, SAVE_IMAGE_POSITION } from './types';
2
2
  export const stockImagesLoaded = images => {
3
3
  return {
4
4
  type: STOCK_IMAGES_LOADED,
@@ -17,4 +17,13 @@ export const imageFolderUpdated = folder => {
17
17
  payload: folder
18
18
  };
19
19
  };
20
+ export const saveImagePosition = (uri, positions) => {
21
+ return {
22
+ type: SAVE_IMAGE_POSITION,
23
+ payload: {
24
+ uri,
25
+ positions
26
+ }
27
+ };
28
+ };
20
29
  //# sourceMappingURL=MediaActions.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["MediaActions.js"],"names":["IMAGE_LIBRARY_LOADED","STOCK_IMAGES_LOADED","IMAGE_FOLDER_UPDATED","stockImagesLoaded","images","type","payload","imageLibraryLoaded","library","imageFolderUpdated","folder"],"mappings":"AAAA,SAASA,oBAAT,EAA+BC,mBAA/B,EAAoDC,oBAApD,QAAgF,SAAhF;AAEA,OAAO,MAAMC,iBAAiB,GAAGC,MAAM,IAAI;AACzC,SAAO;AACLC,IAAAA,IAAI,EAAEJ,mBADD;AAELK,IAAAA,OAAO,EAAEF;AAFJ,GAAP;AAID,CALM;AAOP,OAAO,MAAMG,kBAAkB,GAAGC,OAAO,IAAI;AAC3C,SAAO;AACLH,IAAAA,IAAI,EAAEL,oBADD;AAELM,IAAAA,OAAO,EAAEE;AAFJ,GAAP;AAID,CALM;AAOP,OAAO,MAAMC,kBAAkB,GAAGC,MAAM,IAAI;AAC1C,SAAO;AACLL,IAAAA,IAAI,EAAEH,oBADD;AAELI,IAAAA,OAAO,EAAEI;AAFJ,GAAP;AAID,CALM","sourcesContent":["import { IMAGE_LIBRARY_LOADED, STOCK_IMAGES_LOADED, IMAGE_FOLDER_UPDATED } from './types';\n\nexport const stockImagesLoaded = images => {\n return {\n type: STOCK_IMAGES_LOADED,\n payload: images,\n };\n};\n\nexport const imageLibraryLoaded = library => {\n return {\n type: IMAGE_LIBRARY_LOADED,\n payload: library,\n };\n};\n\nexport const imageFolderUpdated = folder => {\n return {\n type: IMAGE_FOLDER_UPDATED,\n payload: folder,\n };\n};\n"]}
1
+ {"version":3,"sources":["MediaActions.js"],"names":["IMAGE_LIBRARY_LOADED","STOCK_IMAGES_LOADED","IMAGE_FOLDER_UPDATED","SAVE_IMAGE_POSITION","stockImagesLoaded","images","type","payload","imageLibraryLoaded","library","imageFolderUpdated","folder","saveImagePosition","uri","positions"],"mappings":"AAAA,SAASA,oBAAT,EAA+BC,mBAA/B,EAAoDC,oBAApD,EAA0EC,mBAA1E,QAAqG,SAArG;AAEA,OAAO,MAAMC,iBAAiB,GAAGC,MAAM,IAAI;AACzC,SAAO;AACLC,IAAAA,IAAI,EAAEL,mBADD;AAELM,IAAAA,OAAO,EAAEF;AAFJ,GAAP;AAID,CALM;AAOP,OAAO,MAAMG,kBAAkB,GAAGC,OAAO,IAAI;AAC3C,SAAO;AACLH,IAAAA,IAAI,EAAEN,oBADD;AAELO,IAAAA,OAAO,EAAEE;AAFJ,GAAP;AAID,CALM;AAOP,OAAO,MAAMC,kBAAkB,GAAGC,MAAM,IAAI;AAC1C,SAAO;AACLL,IAAAA,IAAI,EAAEJ,oBADD;AAELK,IAAAA,OAAO,EAAEI;AAFJ,GAAP;AAID,CALM;AAOP,OAAO,MAAMC,iBAAiB,GAAG,CAACC,GAAD,EAAMC,SAAN,KAAoB;AACnD,SAAO;AACLR,IAAAA,IAAI,EAAEH,mBADD;AAELI,IAAAA,OAAO,EAAE;AAAEM,MAAAA,GAAF;AAAOC,MAAAA;AAAP;AAFJ,GAAP;AAID,CALM","sourcesContent":["import { IMAGE_LIBRARY_LOADED, STOCK_IMAGES_LOADED, IMAGE_FOLDER_UPDATED, SAVE_IMAGE_POSITION } from './types';\n\nexport const stockImagesLoaded = images => {\n return {\n type: STOCK_IMAGES_LOADED,\n payload: images,\n };\n};\n\nexport const imageLibraryLoaded = library => {\n return {\n type: IMAGE_LIBRARY_LOADED,\n payload: library,\n };\n};\n\nexport const imageFolderUpdated = folder => {\n return {\n type: IMAGE_FOLDER_UPDATED,\n payload: folder,\n };\n};\n\nexport const saveImagePosition = (uri, positions) => {\n return {\n type: SAVE_IMAGE_POSITION,\n payload: { uri, positions },\n };\n};\n"]}
@@ -0,0 +1,14 @@
1
+ import { BLOCK_USER, UNBLOCK_USER } from './types';
2
+ export const blockUser = userId => {
3
+ return {
4
+ type: BLOCK_USER,
5
+ payload: userId
6
+ };
7
+ };
8
+ export const unblockUser = userId => {
9
+ return {
10
+ type: UNBLOCK_USER,
11
+ payload: userId
12
+ };
13
+ };
14
+ //# sourceMappingURL=UserSettingsActions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["UserSettingsActions.js"],"names":["BLOCK_USER","UNBLOCK_USER","blockUser","userId","type","payload","unblockUser"],"mappings":"AAAA,SAASA,UAAT,EAAqBC,YAArB,QAAyC,SAAzC;AAEA,OAAO,MAAMC,SAAS,GAAGC,MAAM,IAAI;AACjC,SAAO;AACLC,IAAAA,IAAI,EAAEJ,UADD;AAELK,IAAAA,OAAO,EAAEF;AAFJ,GAAP;AAID,CALM;AAOP,OAAO,MAAMG,WAAW,GAAGH,MAAM,IAAI;AACnC,SAAO;AACLC,IAAAA,IAAI,EAAEH,YADD;AAELI,IAAAA,OAAO,EAAEF;AAFJ,GAAP;AAID,CALM","sourcesContent":["import { BLOCK_USER, UNBLOCK_USER } from './types';\n\nexport const blockUser = userId => {\n return {\n type: BLOCK_USER,\n payload: userId,\n };\n};\n\nexport const unblockUser = userId => {\n return {\n type: UNBLOCK_USER,\n payload: userId,\n };\n};\n"]}
@@ -2,4 +2,5 @@ export * from './MediaActions';
2
2
  export * from './FollowerActions';
3
3
  export * from './ResidentActions';
4
4
  export * from './UserActions';
5
+ export * from './UserSettingsActions';
5
6
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["index.js"],"names":[],"mappings":"AAAA,cAAc,gBAAd;AACA,cAAc,mBAAd;AACA,cAAc,mBAAd;AACA,cAAc,eAAd","sourcesContent":["export * from './MediaActions';\nexport * from './FollowerActions';\nexport * from './ResidentActions';\nexport * from './UserActions';\n"]}
1
+ {"version":3,"sources":["index.js"],"names":[],"mappings":"AAAA,cAAc,gBAAd;AACA,cAAc,mBAAd;AACA,cAAc,mBAAd;AACA,cAAc,eAAd;AACA,cAAc,uBAAd","sourcesContent":["export * from './MediaActions';\nexport * from './FollowerActions';\nexport * from './ResidentActions';\nexport * from './UserActions';\nexport * from './UserSettingsActions';\n"]}
@@ -3,6 +3,7 @@ export const CHANGE_ROLE = 'CHANGE_ROLE';
3
3
  export const IMAGE_LIBRARY_LOADED = 'IMAGE_LIBRARY_LOADED';
4
4
  export const STOCK_IMAGES_LOADED = 'STOCK_IMAGES_LOADED';
5
5
  export const IMAGE_FOLDER_UPDATED = 'IMAGE_FOLDER_UPDATED';
6
+ export const SAVE_IMAGE_POSITION = 'SAVE_IMAGE_POSITION';
6
7
  export const LOAD_FOLLOWERS = 'LOAD_FOLLOWERS';
7
8
  export const ADD_FOLLOWER = 'ADD_FOLLOWER';
8
9
  export const REMOVE_FOLLOWER = 'REMOVE_FOLLOWER';
@@ -11,4 +12,6 @@ export const LOADED_RESIDENTS = 'LOADED_RESIDENTS';
11
12
  export const LOADED_LINKED_USERS = 'LOADED_LINKED_USERS';
12
13
  export const LOADED_LINKED_TO_USERS = 'LOADED_LINKED_TO_USERS';
13
14
  export const UPDATE_USER_STATE = 'UPDATE_USER_STATE';
15
+ export const BLOCK_USER = 'BLOCK_USER';
16
+ export const UNBLOCK_USER = 'UNBLOCK_USER';
14
17
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["types.js"],"names":["LOGOUT","CHANGE_ROLE","IMAGE_LIBRARY_LOADED","STOCK_IMAGES_LOADED","IMAGE_FOLDER_UPDATED","LOAD_FOLLOWERS","ADD_FOLLOWER","REMOVE_FOLLOWER","UPDATE_RESIDENTS","LOADED_RESIDENTS","LOADED_LINKED_USERS","LOADED_LINKED_TO_USERS","UPDATE_USER_STATE"],"mappings":"AAAA,OAAO,MAAMA,MAAM,GAAG,QAAf;AACP,OAAO,MAAMC,WAAW,GAAG,aAApB;AACP,OAAO,MAAMC,oBAAoB,GAAG,sBAA7B;AACP,OAAO,MAAMC,mBAAmB,GAAG,qBAA5B;AACP,OAAO,MAAMC,oBAAoB,GAAG,sBAA7B;AACP,OAAO,MAAMC,cAAc,GAAG,gBAAvB;AACP,OAAO,MAAMC,YAAY,GAAG,cAArB;AACP,OAAO,MAAMC,eAAe,GAAG,iBAAxB;AACP,OAAO,MAAMC,gBAAgB,GAAG,kBAAzB;AACP,OAAO,MAAMC,gBAAgB,GAAG,kBAAzB;AACP,OAAO,MAAMC,mBAAmB,GAAG,qBAA5B;AACP,OAAO,MAAMC,sBAAsB,GAAG,wBAA/B;AACP,OAAO,MAAMC,iBAAiB,GAAG,mBAA1B","sourcesContent":["export const LOGOUT = 'LOGOUT';\nexport const CHANGE_ROLE = 'CHANGE_ROLE';\nexport const IMAGE_LIBRARY_LOADED = 'IMAGE_LIBRARY_LOADED';\nexport const STOCK_IMAGES_LOADED = 'STOCK_IMAGES_LOADED';\nexport const IMAGE_FOLDER_UPDATED = 'IMAGE_FOLDER_UPDATED';\nexport const LOAD_FOLLOWERS = 'LOAD_FOLLOWERS';\nexport const ADD_FOLLOWER = 'ADD_FOLLOWER';\nexport const REMOVE_FOLLOWER = 'REMOVE_FOLLOWER';\nexport const UPDATE_RESIDENTS = 'UPDATE_RESIDENTS';\nexport const LOADED_RESIDENTS = 'LOADED_RESIDENTS';\nexport const LOADED_LINKED_USERS = 'LOADED_LINKED_USERS';\nexport const LOADED_LINKED_TO_USERS = 'LOADED_LINKED_TO_USERS';\nexport const UPDATE_USER_STATE = 'UPDATE_USER_STATE';\n"]}
1
+ {"version":3,"sources":["types.js"],"names":["LOGOUT","CHANGE_ROLE","IMAGE_LIBRARY_LOADED","STOCK_IMAGES_LOADED","IMAGE_FOLDER_UPDATED","SAVE_IMAGE_POSITION","LOAD_FOLLOWERS","ADD_FOLLOWER","REMOVE_FOLLOWER","UPDATE_RESIDENTS","LOADED_RESIDENTS","LOADED_LINKED_USERS","LOADED_LINKED_TO_USERS","UPDATE_USER_STATE","BLOCK_USER","UNBLOCK_USER"],"mappings":"AAAA,OAAO,MAAMA,MAAM,GAAG,QAAf;AACP,OAAO,MAAMC,WAAW,GAAG,aAApB;AACP,OAAO,MAAMC,oBAAoB,GAAG,sBAA7B;AACP,OAAO,MAAMC,mBAAmB,GAAG,qBAA5B;AACP,OAAO,MAAMC,oBAAoB,GAAG,sBAA7B;AACP,OAAO,MAAMC,mBAAmB,GAAG,qBAA5B;AACP,OAAO,MAAMC,cAAc,GAAG,gBAAvB;AACP,OAAO,MAAMC,YAAY,GAAG,cAArB;AACP,OAAO,MAAMC,eAAe,GAAG,iBAAxB;AACP,OAAO,MAAMC,gBAAgB,GAAG,kBAAzB;AACP,OAAO,MAAMC,gBAAgB,GAAG,kBAAzB;AACP,OAAO,MAAMC,mBAAmB,GAAG,qBAA5B;AACP,OAAO,MAAMC,sBAAsB,GAAG,wBAA/B;AACP,OAAO,MAAMC,iBAAiB,GAAG,mBAA1B;AACP,OAAO,MAAMC,UAAU,GAAG,YAAnB;AACP,OAAO,MAAMC,YAAY,GAAG,cAArB","sourcesContent":["export const LOGOUT = 'LOGOUT';\nexport const CHANGE_ROLE = 'CHANGE_ROLE';\nexport const IMAGE_LIBRARY_LOADED = 'IMAGE_LIBRARY_LOADED';\nexport const STOCK_IMAGES_LOADED = 'STOCK_IMAGES_LOADED';\nexport const IMAGE_FOLDER_UPDATED = 'IMAGE_FOLDER_UPDATED';\nexport const SAVE_IMAGE_POSITION = 'SAVE_IMAGE_POSITION';\nexport const LOAD_FOLLOWERS = 'LOAD_FOLLOWERS';\nexport const ADD_FOLLOWER = 'ADD_FOLLOWER';\nexport const REMOVE_FOLLOWER = 'REMOVE_FOLLOWER';\nexport const UPDATE_RESIDENTS = 'UPDATE_RESIDENTS';\nexport const LOADED_RESIDENTS = 'LOADED_RESIDENTS';\nexport const LOADED_LINKED_USERS = 'LOADED_LINKED_USERS';\nexport const LOADED_LINKED_TO_USERS = 'LOADED_LINKED_TO_USERS';\nexport const UPDATE_USER_STATE = 'UPDATE_USER_STATE';\nexport const BLOCK_USER = 'BLOCK_USER';\nexport const UNBLOCK_USER = 'UNBLOCK_USER';\n"]}
@@ -2,8 +2,10 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
2
2
 
3
3
  import React, { Component } from 'react';
4
4
  import { View, Animated, StyleSheet } from 'react-native';
5
+ import { connect } from 'react-redux';
5
6
  import moment from 'moment';
6
- import { findLandmarkRange, getScaledOffset, get300 } from '../helper';
7
+ import { findLandmarkRange, getScaledOffset, get300, detectFaces } from '../helper';
8
+ import { saveImagePosition } from '../actions';
7
9
 
8
10
  class AutoOffsetImage extends Component {
9
11
  constructor(props) {
@@ -26,9 +28,33 @@ class AutoOffsetImage extends Component {
26
28
  _defineProperty(this, "positionImage", async () => {
27
29
  try {
28
30
  const startTime = moment().valueOf();
31
+ let cachedValues; // check local cache
32
+
33
+ if (this.props.imagePositions && this.props.imagePositions[this.props.uri]) {
34
+ cachedValues = this.props.imagePositions[this.props.uri];
35
+ } // check remote cache
36
+
37
+
38
+ if (!cachedValues) {
39
+ try {
40
+ const response = await stringActions.getString('plussSpace', `imagefaces_${encodeURIComponent(this.props.uri)}`);
41
+ cachedValues = response.data;
42
+ } catch (e) {
43
+ console.log('errored from cache');
44
+ } // run face detection locally
45
+
46
+
47
+ if (!cachedValues || !cachedValues.faces || !cachedValues.image || _.isEmpty(cachedValues.faces) && moment().add(-1, 'w').valueOf() > moment(cachedValues.timestamp).valueOf()) {
48
+ cachedValues = await detectFaces(this.props.uri);
49
+ }
50
+
51
+ this.props.saveImagePosition(this.props.uri, cachedValues);
52
+ }
53
+
29
54
  const image = await findLandmarkRange(this.props.uri, {
30
55
  targetWidth: this.props.width,
31
- targetHeight: this.props.height
56
+ targetHeight: this.props.height,
57
+ cachedValues
32
58
  });
33
59
  const scaledOffset = getScaledOffset(image.width, image.height, this.props.width, this.props.height);
34
60
  const {
@@ -44,18 +70,18 @@ class AutoOffsetImage extends Component {
44
70
 
45
71
  if (landmarkStart.y < imageBounds.start.y) {
46
72
  // move up
47
- offset.y = -Math.max(landmarkStart.y - height * this.paddingFactor, 0); // move top to 5% above start of landmark
73
+ offset.y = -Math.max(landmarkStart.y - this.props.height * this.paddingFactor, 0); // move top to 5% above start of landmark
48
74
  } else if (landmarkEnd.y > imageBounds.end.y) {
49
75
  // move down
50
- offset.y = -Math.max(landmarkEnd.y + height * this.paddingFactor - height, 0); // move bottom to 5% below end of landmark
76
+ offset.y = -Math.max(landmarkEnd.y + this.props.height * this.paddingFactor - this.props.height, 0); // move bottom to 5% below end of landmark
51
77
  }
52
78
 
53
79
  if (landmarkStart.x < imageBounds.start.x) {
54
- // move up
55
- offset.x = -Math.max(landmarkStart.x - width * this.paddingFactor, 0); // move left edge to 5% left of start of landmark
80
+ // move right
81
+ offset.x = -Math.max(landmarkStart.x - this.props.width * this.paddingFactor, 0); // move left edge to 5% left of start of landmark
56
82
  } else if (landmarkEnd.x > imageBounds.end.x) {
57
- // move down
58
- offset.x = -Math.max(landmarkEnd.x + width * this.paddingFactor - width, 0); // move right edge to 5% left of end of landmark
83
+ // move left
84
+ offset.x = -Math.max(landmarkEnd.x + this.props.width * this.paddingFactor - this.props.width, 0); // move right edge to 5% left of end of landmark
59
85
  }
60
86
 
61
87
  this.setState({
@@ -69,7 +95,7 @@ class AutoOffsetImage extends Component {
69
95
  });
70
96
  const endTime = moment().valueOf();
71
97
 
72
- if (endTime - startTime < 300) {
98
+ if (endTime - startTime < 500) {
73
99
  Animated.timing(this.state.blurRadius, {
74
100
  toValue: 0,
75
101
  duration: 0,
@@ -133,5 +159,15 @@ const styles = StyleSheet.create({
133
159
  resizeMode: 'cover'
134
160
  }
135
161
  });
136
- export default AutoOffsetImage;
162
+
163
+ const mapStateToProps = state => {
164
+ return {
165
+ imagePositions: state.media.positions
166
+ };
167
+ };
168
+
169
+ const autoOffsetImage = connect(mapStateToProps, {
170
+ saveImagePosition
171
+ })(AutoOffsetImage);
172
+ export { autoOffsetImage as AutoOffsetImage };
137
173
  //# sourceMappingURL=AutoOffsetImage.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["AutoOffsetImage.js"],"names":["React","Component","View","Animated","StyleSheet","moment","findLandmarkRange","getScaledOffset","get300","AutoOffsetImage","constructor","props","event","nativeEvent","source","uri","state","imageLoaded","setState","sequence","delay","timing","blurRadius","toValue","duration","useNativeDriver","start","startTime","valueOf","image","targetWidth","width","targetHeight","height","scaledOffset","landmarkStart","end","landmarkEnd","bounds","imageBounds","offset","y","Math","max","paddingFactor","x","imageStyle","top","left","imageSource","endTime","e","Value","componentDidMount","positionImage","componentDidUpdate","prevProps","render","styles","container","style","onLoad","children","create","overflow","position","resizeMode"],"mappings":";;AAAA,OAAOA,KAAP,IAAgBC,SAAhB,QAAiC,OAAjC;AACA,SAASC,IAAT,EAAeC,QAAf,EAAyBC,UAAzB,QAA2C,cAA3C;AACA,OAAOC,MAAP,MAAmB,QAAnB;AACA,SAASC,iBAAT,EAA4BC,eAA5B,EAA6CC,MAA7C,QAA2D,WAA3D;;AAEA,MAAMC,eAAN,SAA8BR,SAA9B,CAAwC;AACtCS,EAAAA,WAAW,CAACC,KAAD,EAAQ;AACjB,UAAMA,KAAN;;AADiB,oCAyBVC,KAAK,IAAI;AAChB,UAAIA,KAAK,CAACC,WAAN,CAAkBC,MAAlB,CAAyBC,GAAzB,KAAiC,KAAKJ,KAAL,CAAWI,GAA5C,IAAmD,CAAC,KAAKC,KAAL,CAAWC,WAAnE,EAAgF;AAC9E;AACA,aAAKC,QAAL,CAAc;AACZD,UAAAA,WAAW,EAAE;AADD,SAAd;AAGAd,QAAAA,QAAQ,CAACgB,QAAT,CAAkB,CAChBhB,QAAQ,CAACiB,KAAT,CAAe,GAAf,CADgB,EAEhBjB,QAAQ,CAACkB,MAAT,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AAU,EAAE,KAAK5C,KAAL,CAAWM,UADzB;AAEE,MAAA,MAAM,EAAE;AAAEP,QAAAA,GAAG,EAAE,KAAKC,KAAL,CAAWiC;AAAlB,OAFV;AAGE,MAAA,KAAK,EAAE,CAACS,MAAM,CAAC7B,KAAR,EAAe,KAAKb,KAAL,CAAW8B,UAA1B,CAHT;AAIE,MAAA,MAAM,EAAE,KAAKe;AAJf,MAVF,EAgBG,KAAKlD,KAAL,CAAWmD,QAhBd,CADF;AAoBD;;AAlHqC;;AAqHxC,MAAMJ,MAAM,GAAGtD,UAAU,CAAC2D,MAAX,CAAkB;AAC/BJ,EAAAA,SAAS,EAAE;AACTK,IAAAA,QAAQ,EAAE;AADD,GADoB;AAI/BnC,EAAAA,KAAK,EAAE;AACLoC,IAAAA,QAAQ,EAAE,UADL;AAELlB,IAAAA,GAAG,EAAE,CAFA;AAGLC,IAAAA,IAAI,EAAE,CAHD;AAILkB,IAAAA,UAAU,EAAE;AAJP;AAJwB,CAAlB,CAAf;AAYA,eAAezD,eAAf","sourcesContent":["import React, { Component } from 'react';\nimport { View, Animated, StyleSheet } from 'react-native';\nimport moment from 'moment';\nimport { findLandmarkRange, getScaledOffset, get300 } from '../helper';\n\nclass AutoOffsetImage extends Component {\n constructor(props) {\n super(props);\n\n this.paddingFactor = this.props.paddingFactor || 0.1;\n\n this.state = {\n imageStyle: {\n width: this.props.width,\n height: this.props.height,\n },\n blurRadius: new Animated.Value(100),\n imageSource: get300(this.props.uri),\n };\n }\n\n componentDidMount() {\n this.positionImage();\n }\n\n componentDidUpdate(prevProps) {\n if (prevProps.uri !== this.props.uri || prevProps.height !== this.props.height || prevProps.width !== this.props.width) {\n this.positionImage();\n }\n }\n\n onLoad = event => {\n if (event.nativeEvent.source.uri === this.props.uri && !this.state.imageLoaded) {\n //unblur\n this.setState({\n imageLoaded: true,\n });\n Animated.sequence([\n Animated.delay(200),\n Animated.timing(this.state.blurRadius, {\n toValue: 0,\n duration: 500,\n useNativeDriver: false,\n }),\n ]).start();\n }\n };\n\n positionImage = async () => {\n try {\n const startTime = moment().valueOf();\n const image = await findLandmarkRange(this.props.uri, { targetWidth: this.props.width, targetHeight: this.props.height });\n const scaledOffset = getScaledOffset(image.width, image.height, this.props.width, this.props.height);\n\n const { start: landmarkStart, end: landmarkEnd } = image;\n const { bounds: imageBounds, offset, width, height } = scaledOffset;\n\n if (landmarkStart.y < imageBounds.start.y) {\n // move up\n offset.y = -Math.max(landmarkStart.y - height * this.paddingFactor, 0); // move top to 5% above start of landmark\n } else if (landmarkEnd.y > imageBounds.end.y) {\n // move down\n offset.y = -Math.max(landmarkEnd.y + height * this.paddingFactor - height, 0); // move bottom to 5% below end of landmark\n }\n\n if (landmarkStart.x < imageBounds.start.x) {\n // move up\n offset.x = -Math.max(landmarkStart.x - width * this.paddingFactor, 0); // move left edge to 5% left of start of landmark\n } else if (landmarkEnd.x > imageBounds.end.x) {\n // move down\n offset.x = -Math.max(landmarkEnd.x + width * this.paddingFactor - width, 0); // move right edge to 5% left of end of landmark\n }\n\n this.setState({\n imageStyle: {\n width,\n height,\n top: offset.y,\n left: offset.x,\n },\n imageSource: this.props.uri,\n });\n\n const endTime = moment().valueOf();\n if (endTime - startTime < 300) {\n Animated.timing(this.state.blurRadius, {\n toValue: 0,\n duration: 0,\n useNativeDriver: false,\n }).start();\n }\n } catch (e) {\n this.setState({\n imageSource: this.props.uri,\n });\n }\n };\n\n render() {\n return (\n <View\n style={[\n styles.container,\n {\n width: this.props.width,\n height: this.props.height,\n },\n this.props.style,\n ]}\n >\n <Animated.Image\n blurRadius={this.state.blurRadius}\n source={{ uri: this.state.imageSource }}\n style={[styles.image, this.state.imageStyle]}\n onLoad={this.onLoad}\n />\n {this.props.children}\n </View>\n );\n }\n}\n\nconst styles = StyleSheet.create({\n container: {\n overflow: 'hidden',\n },\n image: {\n position: 'absolute',\n top: 0,\n left: 0,\n resizeMode: 'cover',\n },\n});\n\nexport default AutoOffsetImage;\n"]}
1
+ {"version":3,"sources":["AutoOffsetImage.js"],"names":["React","Component","View","Animated","StyleSheet","connect","moment","findLandmarkRange","getScaledOffset","get300","detectFaces","saveImagePosition","AutoOffsetImage","constructor","props","event","nativeEvent","source","uri","state","imageLoaded","setState","sequence","delay","timing","blurRadius","toValue","duration","useNativeDriver","start","startTime","valueOf","cachedValues","imagePositions","response","stringActions","getString","encodeURIComponent","data","e","console","log","faces","image","_","isEmpty","add","timestamp","targetWidth","width","targetHeight","height","scaledOffset","landmarkStart","end","landmarkEnd","bounds","imageBounds","offset","y","Math","max","paddingFactor","x","imageStyle","top","left","imageSource","endTime","Value","componentDidMount","positionImage","componentDidUpdate","prevProps","render","styles","container","style","onLoad","children","create","overflow","position","resizeMode","mapStateToProps","media","positions","autoOffsetImage"],"mappings":";;AAAA,OAAOA,KAAP,IAAgBC,SAAhB,QAAiC,OAAjC;AACA,SAASC,IAAT,EAAeC,QAAf,EAAyBC,UAAzB,QAA2C,cAA3C;AACA,SAASC,OAAT,QAAwB,aAAxB;AACA,OAAOC,MAAP,MAAmB,QAAnB;AACA,SAASC,iBAAT,EAA4BC,eAA5B,EAA6CC,MAA7C,EAAqDC,WAArD,QAAwE,WAAxE;AACA,SAASC,iBAAT,QAAkC,YAAlC;;AAEA,MAAMC,eAAN,SAA8BX,SAA9B,CAAwC;AACtCY,EAAAA,WAAW,CAACC,KAAD,EAAQ;AACjB,UAAMA,KAAN;;AADiB,oCAyBVC,KAAK,IAAI;AAChB,UAAIA,KAAK,CAACC,WAAN,CAAkBC,MAAlB,CAAyBC,GAAzB,KAAiC,KAAKJ,KAAL,CAAWI,GAA5C,IAAmD,CAAC,KAAKC,KAAL,CAAWC,WAAnE,EAAgF;AAC9E;AACA,aAAKC,QAAL,CAAc;AACZD,UAAAA,WAAW,EAAE;AADD,SAAd;AAGAjB,QAAAA,QAAQ,CAACmB,QAAT,CAAkB,CAChBnB,QAAQ,CAACoB,KAAT,CAAe,GAAf,CADgB,EAEhBpB,QAAQ,CAACqB,MAAT,CAAg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,EAAE,KAAK1D,KAAL,CAAWM,UADzB;AAEE,MAAA,MAAM,EAAE;AAAEP,QAAAA,GAAG,EAAE,KAAKC,KAAL,CAAWgD;AAAlB,OAFV;AAGE,MAAA,KAAK,EAAE,CAACQ,MAAM,CAAChC,KAAR,EAAe,KAAKxB,KAAL,CAAW6C,UAA1B,CAHT;AAIE,MAAA,MAAM,EAAE,KAAKc;AAJf,MAVF,EAgBG,KAAKhE,KAAL,CAAWiE,QAhBd,CADF;AAoBD;;AAnJqC;;AAsJxC,MAAMJ,MAAM,GAAGvE,UAAU,CAAC4E,MAAX,CAAkB;AAC/BJ,EAAAA,SAAS,EAAE;AACTK,IAAAA,QAAQ,EAAE;AADD,GADoB;AAI/BtC,EAAAA,KAAK,EAAE;AACLuC,IAAAA,QAAQ,EAAE,UADL;AAELjB,IAAAA,GAAG,EAAE,CAFA;AAGLC,IAAAA,IAAI,EAAE,CAHD;AAILiB,IAAAA,UAAU,EAAE;AAJP;AAJwB,CAAlB,CAAf;;AAYA,MAAMC,eAAe,GAAGjE,KAAK,IAAI;AAC/B,SAAO;AACLc,IAAAA,cAAc,EAAEd,KAAK,CAACkE,KAAN,CAAYC;AADvB,GAAP;AAGD,CAJD;;AAMA,MAAMC,eAAe,GAAGlF,OAAO,CAAC+E,eAAD,EAAkB;AAAEzE,EAAAA;AAAF,CAAlB,CAAP,CAAgDC,eAAhD,CAAxB;AACA,SAAS2E,eAAe,IAAI3E,eAA5B","sourcesContent":["import React, { Component } from 'react';\nimport { View, Animated, StyleSheet } from 'react-native';\nimport { connect } from 'react-redux';\nimport moment from 'moment';\nimport { findLandmarkRange, getScaledOffset, get300, detectFaces } from '../helper';\nimport { saveImagePosition } from '../actions';\n\nclass AutoOffsetImage extends Component {\n constructor(props) {\n super(props);\n\n this.paddingFactor = this.props.paddingFactor || 0.1;\n\n this.state = {\n imageStyle: {\n width: this.props.width,\n height: this.props.height,\n },\n blurRadius: new Animated.Value(100),\n imageSource: get300(this.props.uri),\n };\n }\n\n componentDidMount() {\n this.positionImage();\n }\n\n componentDidUpdate(prevProps) {\n if (prevProps.uri !== this.props.uri || prevProps.height !== this.props.height || prevProps.width !== this.props.width) {\n this.positionImage();\n }\n }\n\n onLoad = event => {\n if (event.nativeEvent.source.uri === this.props.uri && !this.state.imageLoaded) {\n //unblur\n this.setState({\n imageLoaded: true,\n });\n Animated.sequence([\n Animated.delay(200),\n Animated.timing(this.state.blurRadius, {\n toValue: 0,\n duration: 500,\n useNativeDriver: false,\n }),\n ]).start();\n }\n };\n\n positionImage = async () => {\n try {\n const startTime = moment().valueOf();\n\n let cachedValues;\n // check local cache\n if (this.props.imagePositions && this.props.imagePositions[this.props.uri]) {\n cachedValues = this.props.imagePositions[this.props.uri];\n }\n // check remote cache\n if (!cachedValues) {\n try {\n const response = await stringActions.getString('plussSpace', `imagefaces_${encodeURIComponent(this.props.uri)}`);\n cachedValues = response.data;\n } catch (e) {\n console.log('errored from cache');\n }\n // run face detection locally\n if (\n !cachedValues ||\n !cachedValues.faces ||\n !cachedValues.image ||\n (_.isEmpty(cachedValues.faces) &&\n moment()\n .add(-1, 'w')\n .valueOf() > moment(cachedValues.timestamp).valueOf())\n ) {\n cachedValues = await detectFaces(this.props.uri);\n }\n this.props.saveImagePosition(this.props.uri, cachedValues);\n }\n\n const image = await findLandmarkRange(this.props.uri, {\n targetWidth: this.props.width,\n targetHeight: this.props.height,\n cachedValues,\n });\n const scaledOffset = getScaledOffset(image.width, image.height, this.props.width, this.props.height);\n\n const { start: landmarkStart, end: landmarkEnd } = image;\n const { bounds: imageBounds, offset, width, height } = scaledOffset;\n\n if (landmarkStart.y < imageBounds.start.y) {\n // move up\n offset.y = -Math.max(landmarkStart.y - this.props.height * this.paddingFactor, 0); // move top to 5% above start of landmark\n } else if (landmarkEnd.y > imageBounds.end.y) {\n // move down\n offset.y = -Math.max(landmarkEnd.y + this.props.height * this.paddingFactor - this.props.height, 0); // move bottom to 5% below end of landmark\n }\n\n if (landmarkStart.x < imageBounds.start.x) {\n // move right\n offset.x = -Math.max(landmarkStart.x - this.props.width * this.paddingFactor, 0); // move left edge to 5% left of start of landmark\n } else if (landmarkEnd.x > imageBounds.end.x) {\n // move left\n offset.x = -Math.max(landmarkEnd.x + this.props.width * this.paddingFactor - this.props.width, 0); // move right edge to 5% left of end of landmark\n }\n\n this.setState({\n imageStyle: {\n width,\n height,\n top: offset.y,\n left: offset.x,\n },\n imageSource: this.props.uri,\n });\n\n const endTime = moment().valueOf();\n if (endTime - startTime < 500) {\n Animated.timing(this.state.blurRadius, {\n toValue: 0,\n duration: 0,\n useNativeDriver: false,\n }).start();\n }\n } catch (e) {\n this.setState({\n imageSource: this.props.uri,\n });\n }\n };\n\n render() {\n return (\n <View\n style={[\n styles.container,\n {\n width: this.props.width,\n height: this.props.height,\n },\n this.props.style,\n ]}\n >\n <Animated.Image\n blurRadius={this.state.blurRadius}\n source={{ uri: this.state.imageSource }}\n style={[styles.image, this.state.imageStyle]}\n onLoad={this.onLoad}\n />\n {this.props.children}\n </View>\n );\n }\n}\n\nconst styles = StyleSheet.create({\n container: {\n overflow: 'hidden',\n },\n image: {\n position: 'absolute',\n top: 0,\n left: 0,\n resizeMode: 'cover',\n },\n});\n\nconst mapStateToProps = state => {\n return {\n imagePositions: state.media.positions,\n };\n};\n\nconst autoOffsetImage = connect(mapStateToProps, { saveImagePosition })(AutoOffsetImage);\nexport { autoOffsetImage as AutoOffsetImage };\n"]}
@@ -9,6 +9,7 @@ import { Icon } from 'react-native-elements';
9
9
  import { getPluralS, getThumb300, get1400, getSiteSettingFromState, getFirstName, getPluralOptions } from '../helper';
10
10
  import { getMainBrandingColourFromState, TEXT_DARKEST, BG_GREY, TEXT_LIGHT, LINEGREY } from '../colours';
11
11
  import { reactionActions, notificationActions } from '../apis';
12
+ import { blockUser, unblockUser } from '../actions';
12
13
  import { ConfirmPopup } from './ConfirmPopup';
13
14
  import { ProfilePic } from './ProfilePic';
14
15
  import { ImagePopup } from './ImagePopup';
@@ -53,6 +54,46 @@ class CommentSection extends Component {
53
54
  });
54
55
  });
55
56
 
57
+ _defineProperty(this, "onPressBlockUser", c => {
58
+ this.setState({
59
+ commentToBlock: c
60
+ });
61
+ });
62
+
63
+ _defineProperty(this, "onPressConfirmBlock", () => {
64
+ const userId = this.state.commentToBlock.UserId;
65
+ this.props.blockUser(userId);
66
+ this.setState({
67
+ commentToBlock: null
68
+ });
69
+ });
70
+
71
+ _defineProperty(this, "onPressCancelBlock", () => {
72
+ this.setState({
73
+ commentToBlock: null
74
+ });
75
+ });
76
+
77
+ _defineProperty(this, "onPressUnblockUser", c => {
78
+ this.setState({
79
+ commentToUnblock: c
80
+ });
81
+ });
82
+
83
+ _defineProperty(this, "onPressConfirmUnblock", () => {
84
+ const userId = this.state.commentToUnblock.UserId;
85
+ this.props.unblockUser(userId);
86
+ this.setState({
87
+ commentToUnblock: null
88
+ });
89
+ });
90
+
91
+ _defineProperty(this, "onPressCancelUnblock", () => {
92
+ this.setState({
93
+ commentToUnblock: null
94
+ });
95
+ });
96
+
56
97
  _defineProperty(this, "onPressConfirmReport", () => {
57
98
  const commentId = this.state.commentToReport.Id;
58
99
  this.setState({
@@ -197,7 +238,15 @@ class CommentSection extends Component {
197
238
  return this.state.commentsLoading;
198
239
  });
199
240
 
200
- _defineProperty(this, "renderReplyText", c => {
241
+ _defineProperty(this, "isUserBlocked", c => {
242
+ return _.includes(this.props.blockedUsers, c.UserId);
243
+ });
244
+
245
+ _defineProperty(this, "canBlockComment", c => {
246
+ return this.props.user.uid !== c.UserId;
247
+ });
248
+
249
+ _defineProperty(this, "renderReplyText", (c, isUserBlocked) => {
201
250
  if (this.props.threadId || this.props.hideReplyButton) {
202
251
  return null;
203
252
  }
@@ -214,7 +263,7 @@ class CommentSection extends Component {
214
263
  style: [styles.commentRepliesText, {
215
264
  color: this.props.colourBrandingMain
216
265
  }]
217
- }, `Reply to ${getFirstName(c.User ? c.User.displayName : 'comment')}`);
266
+ }, `Reply to ${getFirstName(!isUserBlocked && c.User ? c.User.displayName : 'comment')}`);
218
267
  } else {
219
268
  // existing replies
220
269
  const profilePics = _.take(_.uniqBy(threadComments, c => c.UserId), 3);
@@ -401,6 +450,32 @@ class CommentSection extends Component {
401
450
  });
402
451
  }
403
452
 
453
+ renderCommentBlockConfirm() {
454
+ return /*#__PURE__*/React.createElement(ConfirmPopup, {
455
+ visible: !!this.state.commentToBlock,
456
+ onConfirm: this.onPressConfirmBlock,
457
+ onCancel: this.onPressCancelBlock,
458
+ onClose: this.onPressCancelBlock,
459
+ text: "Are you sure you want to block this user?",
460
+ extraContent: /*#__PURE__*/React.createElement(Text, {
461
+ style: styles.commentReportText
462
+ }, "You will no longer see comments made by this user")
463
+ });
464
+ }
465
+
466
+ renderCommentUnblockConfirm() {
467
+ return /*#__PURE__*/React.createElement(ConfirmPopup, {
468
+ visible: !!this.state.commentToUnblock,
469
+ onConfirm: this.onPressConfirmUnblock,
470
+ onCancel: this.onPressCancelUnblock,
471
+ onClose: this.onPressCancelUnblock,
472
+ text: "Are you sure you want to unblock this user?",
473
+ extraContent: /*#__PURE__*/React.createElement(Text, {
474
+ style: styles.commentReportText
475
+ }, "You will once again see comments made by this user")
476
+ });
477
+ }
478
+
404
479
  renderCommentReportStatus() {
405
480
  const {
406
481
  commentReportedStatus
@@ -414,7 +489,7 @@ class CommentSection extends Component {
414
489
  style: styles.commentReportText
415
490
  }, isSuccess ? 'We will review the comment within 24 hours' : 'There was a problem reporting the comment please try again later'),
416
491
  hideNo: true,
417
- yesText: 'Back to Article'
492
+ yesText: 'Done'
418
493
  });
419
494
  }
420
495
 
@@ -435,13 +510,14 @@ class CommentSection extends Component {
435
510
  }
436
511
 
437
512
  renderComment(c) {
513
+ const isUserBlocked = this.isUserBlocked(c);
438
514
  return /*#__PURE__*/React.createElement(View, {
439
515
  style: styles.comment,
440
516
  key: c.Id
441
517
  }, /*#__PURE__*/React.createElement(View, {
442
518
  style: styles.commentFlex
443
519
  }, /*#__PURE__*/React.createElement(ProfilePic, {
444
- ProfilePic: c.User.profilePic,
520
+ ProfilePic: isUserBlocked ? null : c.User.profilePic,
445
521
  Diameter: 40,
446
522
  style: styles.commentProfilePic
447
523
  }), /*#__PURE__*/React.createElement(View, {
@@ -468,21 +544,47 @@ class CommentSection extends Component {
468
544
  name: "flag",
469
545
  type: "font-awesome",
470
546
  iconStyle: styles.commentButtonIcon
471
- }))), /*#__PURE__*/React.createElement(Text, {
547
+ }))), !this.props.disableFlag && this.canBlockComment(c) && (isUserBlocked ? /*#__PURE__*/React.createElement(TouchableOpacity, {
548
+ style: {
549
+ marginRight: 8
550
+ },
551
+ onPress: this.onPressUnblockUser.bind(this, c)
552
+ }, /*#__PURE__*/React.createElement(View, {
553
+ style: [styles.commentButtonContainer, {
554
+ backgroundColor: this.props.colourBrandingMain
555
+ }]
556
+ }, /*#__PURE__*/React.createElement(Icon, {
557
+ name: "user-plus",
558
+ type: "font-awesome",
559
+ iconStyle: styles.commentButtonIcon
560
+ }))) : /*#__PURE__*/React.createElement(TouchableOpacity, {
561
+ style: {
562
+ marginRight: 8
563
+ },
564
+ onPress: this.onPressBlockUser.bind(this, c)
565
+ }, /*#__PURE__*/React.createElement(View, {
566
+ style: [styles.commentButtonContainer, {
567
+ backgroundColor: this.props.colourBrandingMain
568
+ }]
569
+ }, /*#__PURE__*/React.createElement(Icon, {
570
+ name: "user-times",
571
+ type: "font-awesome",
572
+ iconStyle: styles.commentButtonIcon
573
+ })))), /*#__PURE__*/React.createElement(Text, {
472
574
  style: [styles.commentName, {
473
575
  fontSize: this.getAdjustedSize(13)
474
576
  }]
475
- }, c.User.displayName)), !_.isEmpty(c.Comment) && /*#__PURE__*/React.createElement(Text, {
577
+ }, isUserBlocked ? '[blocked user]' : c.User.displayName)), !_.isEmpty(c.Comment) && /*#__PURE__*/React.createElement(Text, {
476
578
  style: [styles.commentText, {
477
579
  fontSize: this.getAdjustedSize(13)
478
580
  }]
479
- }, c.Comment), this.renderCommentImage(c))), /*#__PURE__*/React.createElement(View, {
581
+ }, isUserBlocked ? '[hidden]' : c.Comment), !isUserBlocked && this.renderCommentImage(c))), /*#__PURE__*/React.createElement(View, {
480
582
  style: styles.commentBottom
481
583
  }, /*#__PURE__*/React.createElement(Text, {
482
584
  style: [styles.commentTime, {
483
585
  fontSize: this.getAdjustedSize(13)
484
586
  }]
485
- }, moment.utc(c.Timestamp).local().format('D MMM • h:mma')), this.renderReplyText(c)));
587
+ }, moment.utc(c.Timestamp).local().format('D MMM • h:mma')), this.renderReplyText(c, isUserBlocked)));
486
588
  }
487
589
 
488
590
  renderMute() {
@@ -623,7 +725,7 @@ class CommentSection extends Component {
623
725
 
624
726
  return /*#__PURE__*/React.createElement(View, {
625
727
  style: [styles.commentSectionOuter, this.props.style]
626
- }, this.renderComments(), this.renderReportLoading(), this.renderCommentDeleteConfirm(), this.renderCommentReportConfirm(), this.renderCommentReportStatus(), this.renderCommentImagePopup());
728
+ }, this.renderComments(), this.renderReportLoading(), this.renderCommentDeleteConfirm(), this.renderCommentReportConfirm(), this.renderCommentBlockConfirm(), this.renderCommentUnblockConfirm(), this.renderCommentReportStatus(), this.renderCommentImagePopup());
627
729
  }
628
730
 
629
731
  }
@@ -775,11 +877,15 @@ const mapStateToProps = state => {
775
877
  return {
776
878
  colourBrandingMain: getMainBrandingColourFromState(state),
777
879
  user: state.user,
778
- notificationsForComments: getSiteSettingFromState(state, 'NotificationsForComments', false)
880
+ notificationsForComments: getSiteSettingFromState(state, 'NotificationsForComments', false),
881
+ blockedUsers: state.userSettings.blockedUsers || []
779
882
  };
780
883
  };
781
884
 
782
- const commentSection = connect(mapStateToProps, {}, null, {
885
+ const commentSection = connect(mapStateToProps, {
886
+ blockUser,
887
+ unblockUser
888
+ }, null, {
783
889
  forwardRef: true
784
890
  })(CommentSection);
785
891
  export { commentSection as CommentSection };