author
int64
658
755k
date
stringlengths
19
19
timezone
int64
-46,800
43.2k
hash
stringlengths
40
40
message
stringlengths
5
490
mods
list
language
stringclasses
20 values
license
stringclasses
3 values
repo
stringlengths
5
68
original_message
stringlengths
12
491
129,187
16.05.2019 17:06:47
14,400
b5c329371764a44df9d1bdafd30fe5045e14872d
[native] Use Reanimated where we can in ImageGalleryImage We can't use it for that part that interfaces with `lottie-react-native`, unfortunately.
[ { "change_type": "MODIFY", "old_path": "native/media/image-gallery-image.react.js", "new_path": "native/media/image-gallery-image.react.js", "diff": "@@ -23,16 +23,24 @@ import\nGenericTouchable,\n{ TOUCHABLE_STATE }\nfrom 'react-native-gesture-handler/touchables/GenericTouchable';\n+import\n+ Reanimated,\n+ { Easing as ReanimatedEasing }\n+from 'react-native-reanimated';\nexport type GalleryImageInfo = {|\n...Dimensions,\nuri: string,\n|};\n-const animationSpec = {\n+const animatedSpec = {\nduration: 400,\neasing: Easing.inOut(Easing.ease),\nuseNativeDriver: true,\n};\n+const reanimatedSpec = {\n+ duration: 400,\n+ easing: ReanimatedEasing.inOut(ReanimatedEasing.ease),\n+};\ntype Props = {|\nimageInfo: GalleryImageInfo,\n@@ -62,18 +70,21 @@ class ImageGalleryImage extends React.PureComponent<Props> {\nsetFocus: PropTypes.func.isRequired,\nscreenWidth: PropTypes.number.isRequired,\n};\n- focusProgress = new Animated.Value(0);\n+ focusProgress = new Reanimated.Value(0);\nbuttonsStyle: ViewStyle;\n- backdropProgress = new Animated.Value(0);\n+ backdropProgress = new Reanimated.Value(0);\nimageStyle: ImageStyle;\ncheckProgress = new Animated.Value(0);\nconstructor(props: Props) {\nsuper(props);\n- const buttonsScale = this.focusProgress.interpolate({\n+ const buttonsScale = Reanimated.interpolate(\n+ this.focusProgress,\n+ {\ninputRange: [ 0, 1 ],\noutputRange: [ 1.3, 1 ],\n- });\n+ },\n+ );\nthis.buttonsStyle = {\n...styles.buttons,\nopacity: this.focusProgress,\n@@ -81,14 +92,20 @@ class ImageGalleryImage extends React.PureComponent<Props> {\n{ scale: buttonsScale },\n],\n};\n- const backdropOpacity = this.backdropProgress.interpolate({\n+ const backdropOpacity = Reanimated.interpolate(\n+ this.backdropProgress,\n+ {\ninputRange: [ 0, 1 ],\noutputRange: [ 1, 0.2 ],\n- });\n- const imageScale = this.focusProgress.interpolate({\n+ },\n+ );\n+ const imageScale = Reanimated.interpolate(\n+ this.focusProgress,\n+ {\ninputRange: [ 0, 1 ],\noutputRange: [ 1, 1.3 ],\n- });\n+ },\n+ );\nthis.imageStyle = {\nopacity: backdropOpacity,\ntransform: [\n@@ -107,34 +124,34 @@ class ImageGalleryImage extends React.PureComponent<Props> {\nconst isActive = ImageGalleryImage.isActive(this.props);\nconst wasActive = ImageGalleryImage.isActive(prevProps);\nif (isActive && !wasActive) {\n- Animated.timing(\n+ Reanimated.timing(\nthis.backdropProgress,\n- { ...animationSpec, toValue: 1 },\n+ { ...reanimatedSpec, toValue: 1 },\n).start();\n- Animated.timing(\n+ Reanimated.timing(\nthis.focusProgress,\n- { ...animationSpec, toValue: 1 },\n+ { ...reanimatedSpec, toValue: 1 },\n).start();\n} else if (!isActive && wasActive) {\n- Animated.timing(\n+ Reanimated.timing(\nthis.backdropProgress,\n- { ...animationSpec, toValue: 0 },\n+ { ...reanimatedSpec, toValue: 0 },\n).start();\n- Animated.timing(\n+ Reanimated.timing(\nthis.focusProgress,\n- { ...animationSpec, toValue: 0 },\n+ { ...reanimatedSpec, toValue: 0 },\n).start();\n}\nif (this.props.isQueued && !prevProps.isQueued) {\nAnimated.timing(\nthis.checkProgress,\n- { ...animationSpec, toValue: 1 },\n+ { ...animatedSpec, toValue: 1 },\n).start();\n} else if (!this.props.isQueued && prevProps.isQueued) {\nAnimated.timing(\nthis.checkProgress,\n- { ...animationSpec, toValue: 0 },\n+ { ...animatedSpec, toValue: 0 },\n).start();\n}\n}\n@@ -190,25 +207,25 @@ class ImageGalleryImage extends React.PureComponent<Props> {\nonStateChange={this.onBackdropStateChange}\ndelayPressOut={1}\n>\n- <Animated.Image\n+ <Reanimated.Image\nsource={source}\nstyle={[ this.imageStyle, dimensionsStyle ]}\n/>\n- <Animated.View style={this.buttonsStyle}>\n+ <Reanimated.View style={this.buttonsStyle}>\n<LottieView\nsource={require('../animations/check.json')}\nprogress={this.checkProgress}\nstyle={styles.checkAnimation}\nresizeMode=\"cover\"\n/>\n- </Animated.View>\n+ </Reanimated.View>\n</GenericTouchable>\n- <Animated.View\n+ <Reanimated.View\nstyle={this.buttonsStyle}\npointerEvents={active ? 'box-none' : 'none'}\n>\n{buttons}\n- </Animated.View>\n+ </Reanimated.View>\n</View>\n);\n}\n@@ -231,9 +248,9 @@ class ImageGalleryImage extends React.PureComponent<Props> {\n(to === TOUCHABLE_STATE.UNDETERMINED ||\nto === TOUCHABLE_STATE.MOVED_OUTSIDE)\n) {\n- Animated.timing(\n+ Reanimated.timing(\nthis.backdropProgress,\n- { ...animationSpec, duration: 150, toValue: 0 },\n+ { ...reanimatedSpec, duration: 150, toValue: 0 },\n).start();\n}\n}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Use Reanimated where we can in ImageGalleryImage We can't use it for that part that interfaces with `lottie-react-native`, unfortunately.
129,187
16.05.2019 17:15:22
14,400
d2004dd3acee015329b0eb50a7b05888a4e3ec50
[native] Animate appearance of ImageGalleryKeyboard send queue button
[ { "change_type": "MODIFY", "old_path": "native/media/image-gallery-keyboard.react.js", "new_path": "native/media/image-gallery-keyboard.react.js", "diff": "@@ -4,6 +4,7 @@ import type { GalleryImageInfo } from './image-gallery-image.react';\nimport type { AppState } from '../redux/redux-setup';\nimport { type Dimensions, dimensionsPropType } from 'lib/types/media-types';\nimport type { ViewToken } from 'react-native/Libraries/Lists/ViewabilityHelper';\n+import type { ViewStyle } from '../types/styles';\nimport * as React from 'react';\nimport {\n@@ -30,6 +31,12 @@ import {\ncontentBottomOffset,\n} from '../selectors/dimension-selectors';\nimport ImageGalleryImage from './image-gallery-image.react';\n+import Animated, { Easing } from 'react-native-reanimated';\n+\n+const animationSpec = {\n+ duration: 400,\n+ easing: Easing.inOut(Easing.ease),\n+};\ntype Props = {|\n// Redux state\n@@ -54,9 +61,25 @@ class ImageGalleryKeyboard extends React.PureComponent<Props, State> {\nfetchingPhotos = false;\nflatList: ?FlatList;\nviewableIndices: number[] = [];\n+ queueModeProgress = new Animated.Value(0);\n+ sendButtonStyle: ViewStyle;\nconstructor(props: Props) {\nsuper(props);\n+ const sendButtonScale = Animated.interpolate(\n+ this.queueModeProgress,\n+ {\n+ inputRange: [ 0, 1 ],\n+ outputRange: [ 1.3, 1 ],\n+ },\n+ );\n+ this.sendButtonStyle = {\n+ ...styles.sendButton,\n+ opacity: this.queueModeProgress,\n+ transform: [\n+ { scale: sendButtonScale },\n+ ],\n+ };\nthis.state = {\nimageInfos: null,\nerror: null,\n@@ -85,9 +108,22 @@ class ImageGalleryKeyboard extends React.PureComponent<Props, State> {\nthis.setState({ screenWidth: width });\n}\n- const { flatList, viewableIndices } = this;\n- const { imageInfos, focusedImageURI, queuedImageURIs } = this.state;\n+ const { queuedImageURIs } = this.state;\nconst prevQueuedImageURIs = prevState.queuedImageURIs;\n+ if (queuedImageURIs && !prevQueuedImageURIs) {\n+ Animated.timing(\n+ this.queueModeProgress,\n+ { ...animationSpec, toValue: 1 },\n+ ).start();\n+ } else if (!queuedImageURIs && prevQueuedImageURIs) {\n+ Animated.timing(\n+ this.queueModeProgress,\n+ { ...animationSpec, toValue: 0 },\n+ ).start();\n+ }\n+\n+ const { flatList, viewableIndices } = this;\n+ const { imageInfos, focusedImageURI } = this.state;\nif (flatList && imageInfos) {\nlet newURI;\nif (focusedImageURI && focusedImageURI !== prevState.focusedImageURI) {\n@@ -273,29 +309,25 @@ class ImageGalleryKeyboard extends React.PureComponent<Props, State> {\n);\n}\n- let floatingSendButton = null;\nconst { queuedImageURIs } = this.state;\n- if (queuedImageURIs && queuedImageURIs.size > 0) {\n- floatingSendButton = (\n+ const queueCount = queuedImageURIs ? queuedImageURIs.size : 0;\n+ return (\n+ <View style={styles.container} onLayout={this.onContainerLayout}>\n+ {content}\n<TouchableOpacity\nonPress={this.sendQueuedImages}\n- style={styles.sendButton}\nactiveOpacity={0.6}\n+ style={styles.sendButtonContainer}\n>\n+ <Animated.View style={this.sendButtonStyle}>\n<Icon name=\"send\" style={styles.sendIcon} />\n<View style={styles.queueCountBubble}>\n<Text style={styles.queueCountText}>\n- {queuedImageURIs.size}\n+ {queueCount}\n</Text>\n</View>\n+ </Animated.View>\n</TouchableOpacity>\n- );\n- }\n-\n- return (\n- <View style={styles.container} onLayout={this.onContainerLayout}>\n- {content}\n- {floatingSendButton}\n</View>\n);\n}\n@@ -418,10 +450,12 @@ const styles = StyleSheet.create({\nflex: 1,\nmarginBottom: contentBottomOffset,\n},\n- sendButton: {\n+ sendButtonContainer: {\nposition: 'absolute',\nbottom: 30,\nright: 30,\n+ },\n+ sendButton: {\nbackgroundColor: '#7ED321',\nborderRadius: 30,\npaddingLeft: 14,\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Animate appearance of ImageGalleryKeyboard send queue button
129,187
16.05.2019 17:27:11
14,400
a9ae10431203f0ac9e4aa4fb6ee21f51da53b384
[native] Avoid double backdrop animation issue in ImageGalleryImage
[ { "change_type": "MODIFY", "old_path": "native/media/image-gallery-image.react.js", "new_path": "native/media/image-gallery-image.react.js", "diff": "@@ -73,6 +73,7 @@ class ImageGalleryImage extends React.PureComponent<Props> {\nfocusProgress = new Reanimated.Value(0);\nbuttonsStyle: ViewStyle;\nbackdropProgress = new Reanimated.Value(0);\n+ animatingBackdropToZero = false;\nimageStyle: ImageStyle;\ncheckProgress = new Animated.Value(0);\n@@ -133,10 +134,13 @@ class ImageGalleryImage extends React.PureComponent<Props> {\n{ ...reanimatedSpec, toValue: 1 },\n).start();\n} else if (!isActive && wasActive) {\n+ if (!this.animatingBackdropToZero) {\n+ this.animatingBackdropToZero = true;\nReanimated.timing(\nthis.backdropProgress,\n{ ...reanimatedSpec, toValue: 0 },\n- ).start();\n+ ).start(this.onAnimatingBackdropToZeroCompletion);\n+ }\nReanimated.timing(\nthis.focusProgress,\n{ ...reanimatedSpec, toValue: 0 },\n@@ -241,17 +245,21 @@ class ImageGalleryImage extends React.PureComponent<Props> {\n}\nonBackdropStateChange = (from: number, to: number) => {\n+ if (ImageGalleryImage.isActive(this.props)) {\n+ return;\n+ }\nif (to === TOUCHABLE_STATE.BEGAN) {\nthis.backdropProgress.setValue(1);\n} else if (\n- !ImageGalleryImage.isActive(this.props) &&\n+ !this.animatingBackdropToZero &&\n(to === TOUCHABLE_STATE.UNDETERMINED ||\nto === TOUCHABLE_STATE.MOVED_OUTSIDE)\n) {\n+ this.animatingBackdropToZero = true;\nReanimated.timing(\nthis.backdropProgress,\n{ ...reanimatedSpec, duration: 150, toValue: 0 },\n- ).start();\n+ ).start(this.onAnimatingBackdropToZeroCompletion);\n}\n}\n@@ -263,6 +271,10 @@ class ImageGalleryImage extends React.PureComponent<Props> {\nthis.props.setImageQueued(this.props.imageInfo, true);\n}\n+ onAnimatingBackdropToZeroCompletion = ({ finished }) => {\n+ this.animatingBackdropToZero = false;\n+ }\n+\n}\nconst buttonStyle = {\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Avoid double backdrop animation issue in ImageGalleryImage
129,187
16.05.2019 17:41:47
14,400
1e455db29ed0908065a8c6c1ad52983cebc740b3
[native] Min width of 150 for ImageGalleryImage
[ { "change_type": "MODIFY", "old_path": "native/media/image-gallery-image.react.js", "new_path": "native/media/image-gallery-image.react.js", "diff": "@@ -167,10 +167,13 @@ class ImageGalleryImage extends React.PureComponent<Props> {\nconst active = ImageGalleryImage.isActive(this.props);\nconst dimensionsStyle = {\nheight: containerHeight,\n- width: Math.min(\n+ width: Math.max(\n+ Math.min(\nwidth / height * containerHeight,\nthis.props.screenWidth,\n),\n+ 150,\n+ ),\n};\nlet buttons = null;\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Min width of 150 for ImageGalleryImage
129,187
18.05.2019 10:36:59
14,400
4c8b7da136af71d55a56f311c82ae02bc461f3f0
[native] Lock Android 4.4 in ImageGalleryKeyboard queue mode Has a shorter draw stack depth so it avoids crashes.
[ { "change_type": "MODIFY", "old_path": "native/media/image-gallery-keyboard.react.js", "new_path": "native/media/image-gallery-keyboard.react.js", "diff": "@@ -245,7 +245,10 @@ class ImageGalleryKeyboard extends React.PureComponent<Props, State> {\n}\nget queueModeActive() {\n- return !!this.state.queuedImageURIs;\n+ // On old Android 4.4 devices, we get a stack overflow just trying to draw\n+ // the buttons for standard mode, so we force queue mode on always.\n+ return !!this.state.queuedImageURIs ||\n+ (Platform.OS === \"android\" && Platform.Version < 21);\n}\nrenderItem = (row: { item: GalleryImageInfo }) => {\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Lock Android 4.4 in ImageGalleryKeyboard queue mode Has a shorter draw stack depth so it avoids crashes.
129,187
18.05.2019 10:13:34
14,400
5084aa9e65bb8e9eda38dee4a74ac7b57640773d
[native] Avoid using GenericTouchable on Android 4.4
[ { "change_type": "MODIFY", "old_path": "native/media/image-gallery-image.react.js", "new_path": "native/media/image-gallery-image.react.js", "diff": "@@ -27,6 +27,7 @@ import\nReanimated,\n{ Easing as ReanimatedEasing }\nfrom 'react-native-reanimated';\n+import invariant from 'invariant';\nexport type GalleryImageInfo = {|\n...Dimensions,\n@@ -41,6 +42,7 @@ const reanimatedSpec = {\nduration: 400,\neasing: ReanimatedEasing.inOut(ReanimatedEasing.ease),\n};\n+const isAndroid44 = Platform.OS === \"android\" && Platform.Version < 21;\ntype Props = {|\nimageInfo: GalleryImageInfo,\n@@ -70,15 +72,17 @@ class ImageGalleryImage extends React.PureComponent<Props> {\nsetFocus: PropTypes.func.isRequired,\nscreenWidth: PropTypes.number.isRequired,\n};\n+ backdrop: ?TouchableOpacity;\nfocusProgress = new Reanimated.Value(0);\nbuttonsStyle: ViewStyle;\n- backdropProgress = new Reanimated.Value(0);\n+ backdropProgress: ?Reanimated.Value;\nanimatingBackdropToZero = false;\nimageStyle: ImageStyle;\ncheckProgress = new Animated.Value(0);\nconstructor(props: Props) {\nsuper(props);\n+\nconst buttonsScale = Reanimated.interpolate(\nthis.focusProgress,\n{\n@@ -93,18 +97,27 @@ class ImageGalleryImage extends React.PureComponent<Props> {\n{ scale: buttonsScale },\n],\n};\n- const backdropOpacity = Reanimated.interpolate(\n- this.backdropProgress,\n+\n+ const imageScale = Reanimated.interpolate(\n+ this.focusProgress,\n{\ninputRange: [ 0, 1 ],\n- outputRange: [ 1, 0.2 ],\n+ outputRange: [ 1, 1.3 ],\n},\n);\n- const imageScale = Reanimated.interpolate(\n- this.focusProgress,\n+ if (isAndroid44) {\n+ this.imageStyle = {\n+ transform: [\n+ { scale: imageScale },\n+ ],\n+ };\n+ } else {\n+ this.backdropProgress = new Reanimated.Value(0);\n+ const backdropOpacity = Reanimated.interpolate(\n+ this.backdropProgress,\n{\ninputRange: [ 0, 1 ],\n- outputRange: [ 1, 1.3 ],\n+ outputRange: [ 1, 0.2 ],\n},\n);\nthis.imageStyle = {\n@@ -114,6 +127,7 @@ class ImageGalleryImage extends React.PureComponent<Props> {\n],\n};\n}\n+ }\nstatic isActive(props: Props) {\nreturn props.isFocused || props.isQueued;\n@@ -124,23 +138,32 @@ class ImageGalleryImage extends React.PureComponent<Props> {\nconst isActive = ImageGalleryImage.isActive(this.props);\nconst wasActive = ImageGalleryImage.isActive(prevProps);\n+ const { backdrop, backdropProgress } = this;\nif (isActive && !wasActive) {\n+ if (backdropProgress) {\nReanimated.timing(\n- this.backdropProgress,\n+ backdropProgress,\n{ ...reanimatedSpec, toValue: 1 },\n).start();\n+ }\n+ if (backdrop) {\n+ backdrop.setOpacityTo(0.2, 0);\n+ }\nReanimated.timing(\nthis.focusProgress,\n{ ...reanimatedSpec, toValue: 1 },\n).start();\n} else if (!isActive && wasActive) {\n- if (!this.animatingBackdropToZero) {\n+ if (backdropProgress && !this.animatingBackdropToZero) {\nthis.animatingBackdropToZero = true;\nReanimated.timing(\n- this.backdropProgress,\n+ backdropProgress,\n{ ...reanimatedSpec, toValue: 0 },\n).start(this.onAnimatingBackdropToZeroCompletion);\n}\n+ if (backdrop) {\n+ backdrop.setOpacityTo(1, 0);\n+ }\nReanimated.timing(\nthis.focusProgress,\n{ ...reanimatedSpec, toValue: 0 },\n@@ -207,29 +230,56 @@ class ImageGalleryImage extends React.PureComponent<Props> {\n);\n}\n- return (\n- <View style={[ styles.container, dimensionsStyle ]}>\n- <GenericTouchable\n- onPress={this.onPressBackdrop}\n- onStateChange={this.onBackdropStateChange}\n- delayPressOut={1}\n- >\n+ const image = (\n<Reanimated.Image\nsource={source}\nstyle={[ this.imageStyle, dimensionsStyle ]}\n/>\n- <Reanimated.View style={this.buttonsStyle}>\n+ );\n+ const checkAnimation = (\n<LottieView\nsource={require('../animations/check.json')}\nprogress={this.checkProgress}\nstyle={styles.checkAnimation}\nresizeMode=\"cover\"\n/>\n+ );\n+\n+ if (isAndroid44) {\n+ const backdropStyle = {\n+ opacity: active ? 0.2 : 1,\n+ };\n+ return (\n+ <View style={[ styles.container, dimensionsStyle ]}>\n+ <TouchableOpacity\n+ onPress={this.onPressBackdrop}\n+ style={backdropStyle}\n+ ref={this.backdropRef}\n+ >\n+ {image}\n+ </TouchableOpacity>\n+ <Reanimated.View style={this.buttonsStyle} pointerEvents=\"none\">\n+ {checkAnimation}\n+ </Reanimated.View>\n+ </View>\n+ );\n+ }\n+\n+ return (\n+ <View style={[ styles.container, dimensionsStyle ]}>\n+ <GenericTouchable\n+ onPress={this.onPressBackdrop}\n+ onStateChange={this.onBackdropStateChange}\n+ delayPressOut={1}\n+ >\n+ {image}\n+ <Reanimated.View style={this.buttonsStyle}>\n+ {checkAnimation}\n</Reanimated.View>\n</GenericTouchable>\n<Reanimated.View\nstyle={this.buttonsStyle}\n- pointerEvents={active ? 'box-none' : 'none'}\n+ pointerEvents={active ? \"box-none\" : \"none\"}\n>\n{buttons}\n</Reanimated.View>\n@@ -237,6 +287,10 @@ class ImageGalleryImage extends React.PureComponent<Props> {\n);\n}\n+ backdropRef = (backdrop: ?TouchableOpacity) => {\n+ this.backdrop = backdrop;\n+ }\n+\nonPressBackdrop = () => {\nif (this.props.isQueued) {\nthis.props.setImageQueued(this.props.imageInfo, false);\n@@ -251,8 +305,10 @@ class ImageGalleryImage extends React.PureComponent<Props> {\nif (ImageGalleryImage.isActive(this.props)) {\nreturn;\n}\n+ const { backdropProgress } = this;\n+ invariant(backdropProgress, \"should be set\");\nif (to === TOUCHABLE_STATE.BEGAN) {\n- this.backdropProgress.setValue(1);\n+ backdropProgress.setValue(1);\n} else if (\n!this.animatingBackdropToZero &&\n(to === TOUCHABLE_STATE.UNDETERMINED ||\n@@ -260,7 +316,7 @@ class ImageGalleryImage extends React.PureComponent<Props> {\n) {\nthis.animatingBackdropToZero = true;\nReanimated.timing(\n- this.backdropProgress,\n+ backdropProgress,\n{ ...reanimatedSpec, duration: 150, toValue: 0 },\n).start(this.onAnimatingBackdropToZeroCompletion);\n}\n@@ -274,7 +330,7 @@ class ImageGalleryImage extends React.PureComponent<Props> {\nthis.props.setImageQueued(this.props.imageInfo, true);\n}\n- onAnimatingBackdropToZeroCompletion = ({ finished }) => {\n+ onAnimatingBackdropToZeroCompletion = ({ finished }: { finished: bool }) => {\nthis.animatingBackdropToZero = false;\n}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Avoid using GenericTouchable on Android 4.4
129,187
21.05.2019 13:51:43
14,400
9f25df78732be2f4ef2232076b16ab0081f463da
[native] Add RCTBlob support to iOS
[ { "change_type": "MODIFY", "old_path": "native/ios/Podfile", "new_path": "native/ios/Podfile", "diff": "@@ -17,6 +17,7 @@ target 'SquadCal' do\n'RCTImage',\n'RCTLinkingIOS',\n'RCTCameraRoll',\n+ 'RCTBlob',\n]\npod 'yoga', :path => '../../node_modules/react-native/ReactCommon/yoga'\n" }, { "change_type": "MODIFY", "old_path": "native/ios/Podfile.lock", "new_path": "native/ios/Podfile.lock", "diff": "@@ -153,6 +153,7 @@ DEPENDENCIES:\n- React/CxxBridge (from `../../node_modules/react-native`)\n- React/DevSupport (from `../../node_modules/react-native`)\n- React/RCTAnimation (from `../../node_modules/react-native`)\n+ - React/RCTBlob (from `../../node_modules/react-native`)\n- React/RCTCameraRoll (from `../../node_modules/react-native`)\n- React/RCTImage (from `../../node_modules/react-native`)\n- React/RCTLinkingIOS (from `../../node_modules/react-native`)\n@@ -251,6 +252,6 @@ SPEC CHECKSUMS:\nSDWebImage: 3f3f0c02f09798048c47a5ed0a13f17b063572d8\nyoga: 596e61c9b57751d08a22b07aba310dbd3e65ab75\n-PODFILE CHECKSUM: 4eb375e902364646a45875bc7e829aa6b00f5de5\n+PODFILE CHECKSUM: 4e4591f1770ff5cc15c73ae1a206faacb23b2a5b\nCOCOAPODS: 1.6.1\n" }, { "change_type": "MODIFY", "old_path": "native/ios/SquadCal.xcodeproj/project.pbxproj", "new_path": "native/ios/SquadCal.xcodeproj/project.pbxproj", "diff": "37EFE215F3DF4D559A6113EF /* MaterialCommunityIcons.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 21637FDCB85C48C78A1E0D0F /* MaterialCommunityIcons.ttf */; };\n50114777890342C69E1A0D53 /* Feather.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 1BACB9A55ECC42C38F5FE331 /* Feather.ttf */; };\n5E9157361DD0AC6A00FF2AA8 /* libRCTAnimation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5E9157331DD0AC6500FF2AA8 /* libRCTAnimation.a */; };\n+ 7F203569229475B300EEC30F /* libRCTBlob.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7F20354A2294720D00EEC30F /* libRCTBlob.a */; };\n7F761E602201141E001B6FB7 /* JavaScriptCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7F761E292201141E001B6FB7 /* JavaScriptCore.framework */; };\n7FB58ABE1E7F6BD500B4C1B1 /* Anaheim-Regular.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 7FB58ABB1E7F6BC600B4C1B1 /* Anaheim-Regular.ttf */; };\n7FB58ABF1E7F6BD600B4C1B1 /* Anaheim-Regular.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 7FB58ABB1E7F6BC600B4C1B1 /* Anaheim-Regular.ttf */; };\nremoteGlobalIDString = 139D7E881E25C6D100323FB7;\nremoteInfo = \"double-conversion\";\n};\n+ 7F2035492294720D00EEC30F /* PBXContainerItemProxy */ = {\n+ isa = PBXContainerItemProxy;\n+ containerPortal = 7F2035422294720D00EEC30F /* RCTBlob.xcodeproj */;\n+ proxyType = 2;\n+ remoteGlobalIDString = 358F4ED71D1E81A9004DF814;\n+ remoteInfo = RCTBlob;\n+ };\n+ 7F20354B2294720D00EEC30F /* PBXContainerItemProxy */ = {\n+ isa = PBXContainerItemProxy;\n+ containerPortal = 7F2035422294720D00EEC30F /* RCTBlob.xcodeproj */;\n+ proxyType = 2;\n+ remoteGlobalIDString = ADD01A681E09402E00F6D226;\n+ remoteInfo = \"RCTBlob-tvOS\";\n+ };\n7F3DD3FE20521A4B00A0D652 /* PBXContainerItemProxy */ = {\nisa = PBXContainerItemProxy;\ncontainerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */;\n6D556981F43D459CB36250F9 /* Zocial.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = Zocial.ttf; path = \"../node_modules/react-native-vector-icons/Fonts/Zocial.ttf\"; sourceTree = \"<group>\"; };\n76DBEB73A008439E97F240AC /* Entypo.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = Entypo.ttf; path = \"../node_modules/react-native-vector-icons/Fonts/Entypo.ttf\"; sourceTree = \"<group>\"; };\n78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = \"wrapper.pb-project\"; name = RCTLinking.xcodeproj; path = \"../node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj\"; sourceTree = \"<group>\"; };\n+ 7F2035422294720D00EEC30F /* RCTBlob.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = \"wrapper.pb-project\"; name = RCTBlob.xcodeproj; path = \"../../node_modules/react-native/Libraries/Blob/RCTBlob.xcodeproj\"; sourceTree = \"<group>\"; };\n7F761E292201141E001B6FB7 /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; };\n7FB58ABB1E7F6BC600B4C1B1 /* Anaheim-Regular.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = \"Anaheim-Regular.ttf\"; sourceTree = \"<group>\"; };\n7FB58ABC1E7F6BC600B4C1B1 /* OpenSans-Regular.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = \"OpenSans-Regular.ttf\"; sourceTree = \"<group>\"; };\n00C302E91ABCBA2D00DB3ED1 /* libRCTNetwork.a in Frameworks */,\n832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */,\n139FDEF61B0652A700C62182 /* libRCTWebSocket.a in Frameworks */,\n+ 7F203569229475B300EEC30F /* libRCTBlob.a in Frameworks */,\n164ABF33429CFE672F0D2509 /* libPods-SquadCal.a in Frameworks */,\n);\nrunOnlyForDeploymentPostprocessing = 0;\nname = Products;\nsourceTree = \"<group>\";\n};\n+ 7F2035432294720D00EEC30F /* Products */ = {\n+ isa = PBXGroup;\n+ children = (\n+ 7F20354A2294720D00EEC30F /* libRCTBlob.a */,\n+ 7F20354C2294720D00EEC30F /* libRCTBlob-tvOS.a */,\n+ );\n+ name = Products;\n+ sourceTree = \"<group>\";\n+ };\n7FF0870B1E833C3F000A1ACF /* Frameworks */ = {\nisa = PBXGroup;\nchildren = (\n832341AE1AAA6A7D00B99B32 /* Libraries */ = {\nisa = PBXGroup;\nchildren = (\n+ 7F2035422294720D00EEC30F /* RCTBlob.xcodeproj */,\n5E91572D1DD0AC6500FF2AA8 /* RCTAnimation.xcodeproj */,\n146833FF1AC3E56700842450 /* React.xcodeproj */,\n00C302BB1ABCB91800DB3ED1 /* RCTImage.xcodeproj */,\n83CBBA001A601CBA00E9B192 /* Products */,\n6534411766BE4CA4B0AB0A78 /* Resources */,\n7FF0870B1E833C3F000A1ACF /* Frameworks */,\n- 7F5B10C02005349C00FE096A /* Recovered References */,\n2D16E6871FA4F8E400B85C8A /* Frameworks */,\nD533B93718E3B9684B508006 /* Pods */,\n);\nProductGroup = 5E91572E1DD0AC6500FF2AA8 /* Products */;\nProjectRef = 5E91572D1DD0AC6500FF2AA8 /* RCTAnimation.xcodeproj */;\n},\n+ {\n+ ProductGroup = 7F2035432294720D00EEC30F /* Products */;\n+ ProjectRef = 7F2035422294720D00EEC30F /* RCTBlob.xcodeproj */;\n+ },\n{\nProductGroup = 00C302BC1ABCB91800DB3ED1 /* Products */;\nProjectRef = 00C302BB1ABCB91800DB3ED1 /* RCTImage.xcodeproj */;\nremoteRef = 7F033BB11F01B5E100700D63 /* PBXContainerItemProxy */;\nsourceTree = BUILT_PRODUCTS_DIR;\n};\n+ 7F20354A2294720D00EEC30F /* libRCTBlob.a */ = {\n+ isa = PBXReferenceProxy;\n+ fileType = archive.ar;\n+ path = libRCTBlob.a;\n+ remoteRef = 7F2035492294720D00EEC30F /* PBXContainerItemProxy */;\n+ sourceTree = BUILT_PRODUCTS_DIR;\n+ };\n+ 7F20354C2294720D00EEC30F /* libRCTBlob-tvOS.a */ = {\n+ isa = PBXReferenceProxy;\n+ fileType = archive.ar;\n+ path = \"libRCTBlob-tvOS.a\";\n+ remoteRef = 7F20354B2294720D00EEC30F /* PBXContainerItemProxy */;\n+ sourceTree = BUILT_PRODUCTS_DIR;\n+ };\n7F3DD3FF20521A4B00A0D652 /* libReact.a */ = {\nisa = PBXReferenceProxy;\nfileType = archive.ar;\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Add RCTBlob support to iOS
129,187
22.05.2019 00:16:57
14,400
706881920df525ff4483eb5ad834e2e19d93cf3f
[web] Move multimedia message actions to ChatInputStateContainer
[ { "change_type": "MODIFY", "old_path": "web/chat/chat-input-bar.react.js", "new_path": "web/chat/chat-input-bar.react.js", "diff": "@@ -17,7 +17,6 @@ import {\n} from 'lib/types/thread-types';\nimport {\ntype RawTextMessageInfo,\n- type RawMultimediaMessageInfo,\ntype SendMessageResult,\nmessageTypes,\n} from 'lib/types/message-types';\n@@ -39,7 +38,6 @@ import { connect } from 'lib/utils/redux-utils';\nimport {\nsendTextMessageActionTypes,\nsendTextMessage,\n- createLocalMultimediaMessageActionType,\n} from 'lib/actions/message-actions';\nimport {\njoinThreadActionTypes,\n@@ -286,10 +284,7 @@ class ChatInputBar extends React.PureComponent<Props> {\nthis.dispatchTextMessageAction(text);\n}\n- const { pendingUploads } = this.props.chatInputState;\n- if (pendingUploads.length > 0) {\n- this.dispatchMultimediaMessageAction(pendingUploads);\n- }\n+ this.props.chatInputState.createMultimediaMessage();\n}\ndispatchTextMessageAction(text: string) {\n@@ -353,40 +348,6 @@ class ChatInputBar extends React.PureComponent<Props> {\nthis.props.chatInputState.appendFiles([...event.target.files]);\n}\n- dispatchMultimediaMessageAction(\n- pendingUploads: $ReadOnlyArray<PendingMultimediaUpload>,\n- ) {\n- const localID = `local${this.props.nextLocalID}`;\n- const creatorID = this.props.viewerID;\n- invariant(creatorID, \"should have viewer ID in order to send a message\");\n- const messageInfo = ({\n- type: messageTypes.MULTIMEDIA,\n- localID,\n- threadID: this.props.threadInfo.id,\n- creatorID,\n- time: Date.now(),\n- media: pendingUploads.map(\n- ({ localID, serverID, uri, mediaType, dimensions }) => ({\n- id: serverID ? serverID : localID,\n- uri,\n- type: mediaType,\n- dimensions,\n- }),\n- ),\n- }: RawMultimediaMessageInfo);\n- // This call triggers a setState in ChatInputStateContainer. We hope that\n- // propagates quicker than the createLocalMultimediaMessageActionType call\n- // below, since ChatInputStateContainer's appendFiles (which handles the\n- // upload) relies on the aforementioned setState to know which pending\n- // uploads are associated to local messages and thus necessitate Redux\n- // actions to update the messageStore.\n- this.props.chatInputState.assignPendingUploads(localID);\n- this.props.dispatchActionPayload(\n- createLocalMultimediaMessageActionType,\n- messageInfo,\n- );\n- }\n-\nonClickJoin = (event: SyntheticEvent<HTMLAnchorElement>) => {\nevent.preventDefault();\nthis.props.dispatchActionPromise(\n" }, { "change_type": "MODIFY", "old_path": "web/chat/chat-input-state-container.react.js", "new_path": "web/chat/chat-input-state-container.react.js", "diff": "import type { AppState } from '../redux-setup';\nimport type { UploadMultimediaResult } from 'lib/types/media-types';\n-import type { DispatchActionPayload } from 'lib/utils/action-utils';\n+import type {\n+ DispatchActionPayload,\n+ DispatchActionPromise,\n+} from 'lib/utils/action-utils';\nimport type { PendingMultimediaUpload } from './chat-input-state';\n+import {\n+ messageTypes,\n+ type RawMessageInfo,\n+ type RawMultimediaMessageInfo,\n+ type SendMessageResult,\n+} from 'lib/types/message-types';\nimport * as React from 'react';\nimport PropTypes from 'prop-types';\n@@ -12,11 +21,10 @@ import _memoize from 'lodash/memoize';\nimport _keyBy from 'lodash/fp/keyBy';\nimport _omit from 'lodash/fp/omit';\nimport _flow from 'lodash/fp/flow';\n-import _omitBy from 'lodash/fp/omitBy';\nimport _map from 'lodash/fp/map';\nimport _groupBy from 'lodash/fp/groupBy';\nimport _partition from 'lodash/fp/partition';\n-import _mapValues from 'lodash/fp/mapValues';\n+import invariant from 'invariant';\nimport { connect } from 'lib/utils/redux-utils';\nimport {\n@@ -25,6 +33,11 @@ import {\nassignMediaServerURIToMessageActionType,\ndeleteUpload,\n} from 'lib/actions/upload-actions';\n+import {\n+ createLocalMultimediaMessageActionType,\n+ sendMultimediaMessageActionTypes,\n+ sendMultimediaMessage,\n+} from 'lib/actions/message-actions';\nimport ChatMessageList from './chat-message-list.react';\nimport { validateFile, preloadImage } from '../utils/media-utils';\n@@ -36,8 +49,12 @@ type Props = {|\nsetModal: (modal: ?React.Node) => void,\n// Redux state\nactiveChatThreadID: ?string,\n+ viewerID: ?string,\n+ nextLocalID: number,\n+ messageStoreMessages: { [id: string]: RawMessageInfo },\n// Redux dispatch functions\ndispatchActionPayload: DispatchActionPayload,\n+ dispatchActionPromise: DispatchActionPromise,\n// async functions that hit server APIs\nuploadMultimedia: (\nmultimedia: Object,\n@@ -45,6 +62,11 @@ type Props = {|\nabortHandler: (abort: () => void) => void,\n) => Promise<UploadMultimediaResult>,\ndeleteUpload: (id: string) => Promise<void>,\n+ sendMultimediaMessage: (\n+ threadID: string,\n+ localID: string,\n+ mediaIDs: $ReadOnlyArray<string>,\n+ ) => Promise<SendMessageResult>,\n|};\ntype State = {|\npendingUploads:\n@@ -56,15 +78,200 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\nstatic propTypes = {\nsetModal: PropTypes.func.isRequired,\nactiveChatThreadID: PropTypes.string,\n+ viewerID: PropTypes.string,\n+ nextLocalID: PropTypes.number.isRequired,\n+ messageStoreMessages: PropTypes.object.isRequired,\ndispatchActionPayload: PropTypes.func.isRequired,\n+ dispatchActionPromise: PropTypes.func.isRequired,\nuploadMultimedia: PropTypes.func.isRequired,\ndeleteUpload: PropTypes.func.isRequired,\n+ sendMultimediaMessage: PropTypes.func.isRequired,\n};\nstate = {\npendingUploads: {},\ndrafts: {},\n};\n+ static completedMessageIDs(state: State) {\n+ const completed = new Map();\n+ for (let threadID in state.pendingUploads) {\n+ const pendingUploads = state.pendingUploads[threadID];\n+ for (let localUploadID in pendingUploads) {\n+ const upload = pendingUploads[localUploadID];\n+ const { messageID, serverID, failed } = upload;\n+ if (!messageID || !messageID.startsWith(\"local\")) {\n+ continue;\n+ }\n+ if (!serverID || failed) {\n+ completed.set(messageID, false);\n+ continue;\n+ }\n+ if (completed.get(messageID) === undefined) {\n+ completed.set(messageID, true);\n+ }\n+ }\n+ }\n+ const messageIDs = new Set();\n+ for (let [ messageID, isCompleted ] of completed) {\n+ if (isCompleted) {\n+ messageIDs.add(messageID);\n+ }\n+ }\n+ return messageIDs;\n+ }\n+\n+ componentDidUpdate(prevProps: Props, prevState: State) {\n+ const previouslyAssignedMessageIDs = new Set();\n+ for (let threadID in prevState.pendingUploads) {\n+ const pendingUploads = prevState.pendingUploads[threadID];\n+ for (let localUploadID in pendingUploads) {\n+ const { messageID } = pendingUploads[localUploadID];\n+ if (messageID) {\n+ previouslyAssignedMessageIDs.add(messageID);\n+ }\n+ }\n+ }\n+\n+ const newlyAssignedUploads = new Map();\n+ for (let threadID in this.state.pendingUploads) {\n+ const pendingUploads = this.state.pendingUploads[threadID];\n+ for (let localUploadID in pendingUploads) {\n+ const upload = pendingUploads[localUploadID];\n+ const { messageID } = upload;\n+ if (\n+ !messageID ||\n+ !messageID.startsWith(\"local\") ||\n+ previouslyAssignedMessageIDs.has(messageID)\n+ ) {\n+ continue;\n+ }\n+ let assignedUploads = newlyAssignedUploads.get(messageID);\n+ if (!assignedUploads) {\n+ assignedUploads = { threadID, uploads: [] };\n+ newlyAssignedUploads.set(messageID, assignedUploads);\n+ }\n+ assignedUploads.uploads.push(upload);\n+ }\n+ }\n+\n+ const newMessageInfos = new Map();\n+ for (let [ messageID, assignedUploads ] of newlyAssignedUploads) {\n+ const { uploads, threadID } = assignedUploads;\n+ const creatorID = this.props.viewerID;\n+ invariant(creatorID, \"need viewer ID in order to send a message\");\n+ const messageInfo = ({\n+ type: messageTypes.MULTIMEDIA,\n+ localID: messageID,\n+ threadID,\n+ creatorID,\n+ time: Date.now(),\n+ media: uploads.map(\n+ ({ localID, serverID, uri, mediaType, dimensions }) => ({\n+ id: serverID ? serverID : localID,\n+ uri,\n+ type: mediaType,\n+ dimensions,\n+ }),\n+ ),\n+ }: RawMultimediaMessageInfo);\n+ newMessageInfos.set(messageID, messageInfo);\n+ }\n+\n+ const currentlyCompleted =\n+ ChatInputStateContainer.completedMessageIDs(this.state);\n+ const previouslyCompleted =\n+ ChatInputStateContainer.completedMessageIDs(prevState);\n+ for (let messageID of currentlyCompleted) {\n+ if (previouslyCompleted.has(messageID)) {\n+ continue;\n+ }\n+ let rawMessageInfo = newMessageInfos.get(messageID);\n+ if (rawMessageInfo) {\n+ newMessageInfos.delete(messageID);\n+ } else {\n+ rawMessageInfo = this.getRawMultimediaMessageInfo(messageID);\n+ }\n+ this.sendMultimediaMessage(rawMessageInfo);\n+ }\n+\n+ for (let [ messageID, messageInfo ] of newMessageInfos) {\n+ this.props.dispatchActionPayload(\n+ createLocalMultimediaMessageActionType,\n+ messageInfo,\n+ );\n+ }\n+ }\n+\n+ getRawMultimediaMessageInfo(\n+ localMessageID: string,\n+ ): RawMultimediaMessageInfo {\n+ const rawMessageInfo = this.props.messageStoreMessages[localMessageID];\n+ invariant(\n+ rawMessageInfo,\n+ `rawMessageInfo ${localMessageID} should exist in sendMultimediaMessage`,\n+ );\n+ invariant(\n+ rawMessageInfo.type === messageTypes.MULTIMEDIA,\n+ `rawMessageInfo ${localMessageID} should be messageTypes.MULTIMEDIA`,\n+ );\n+ return rawMessageInfo;\n+ }\n+\n+ sendMultimediaMessage(messageInfo: RawMultimediaMessageInfo) {\n+ this.props.dispatchActionPromise(\n+ sendMultimediaMessageActionTypes,\n+ this.sendMultimediaMessageAction(messageInfo),\n+ undefined,\n+ messageInfo,\n+ );\n+ }\n+\n+ async sendMultimediaMessageAction(messageInfo: RawMultimediaMessageInfo) {\n+ const { localID, threadID, media } = messageInfo;\n+ invariant(\n+ localID !== null && localID !== undefined,\n+ \"localID should be set\",\n+ );\n+ try {\n+ const result = await this.props.sendMultimediaMessage(\n+ threadID,\n+ localID,\n+ media.map(({ id }) => id),\n+ );\n+ this.setState(prevState => {\n+ const prevUploads = prevState.pendingUploads[threadID];\n+ const newUploads = {};\n+ for (let localUploadID in prevUploads) {\n+ const upload = prevUploads[localUploadID];\n+ if (upload.messageID !== localID) {\n+ newUploads[localUploadID] = upload;\n+ } else if (!upload.uriIsReal) {\n+ newUploads[localUploadID] = {\n+ ...upload,\n+ messageID: result.id,\n+ };\n+ }\n+ }\n+ return {\n+ pendingUploads: {\n+ ...prevState.pendingUploads,\n+ [threadID]: newUploads,\n+ },\n+ };\n+ });\n+ return {\n+ localID,\n+ serverID: result.id,\n+ threadID,\n+ time: result.time,\n+ };\n+ } catch (e) {\n+ e.localID = localID;\n+ e.threadID = threadID;\n+ throw e;\n+ }\n+ }\n+\nchatInputStateSelector = _memoize((threadID: string) => createSelector(\n(state: State) => state.pendingUploads[threadID],\n(state: State) => state.drafts[threadID],\n@@ -92,15 +299,19 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\nthis.appendFiles(threadID, files),\ncancelPendingUpload: (localUploadID: string) =>\nthis.cancelPendingUpload(threadID, localUploadID),\n- assignPendingUploads: (localMessageID: string) =>\n- this.assignPendingUploads(threadID, localMessageID),\n+ createMultimediaMessage: () =>\n+ this.createMultimediaMessage(threadID),\nsetDraft: (draft: string) => this.setDraft(threadID, draft),\nsetProgress: (localUploadID: string, percent: number) =>\nthis.setProgress(threadID, localUploadID, percent),\nmessageHasUploadFailure: (localMessageID: string) =>\nthis.messageHasUploadFailure(threadAssignedUploads[localMessageID]),\n- retryUploads: (localMessageID: string) =>\n- this.retryUploads(threadID, threadAssignedUploads[localMessageID]),\n+ retryMultimediaMessage: (localMessageID: string) =>\n+ this.retryMultimediaMessage(\n+ threadID,\n+ localMessageID,\n+ threadAssignedUploads[localMessageID],\n+ ),\n};\n},\n));\n@@ -192,7 +403,12 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\nconst uploadAfterSuccess =\nthis.state.pendingUploads[threadID][upload.localID];\n- if (uploadAfterSuccess && uploadAfterSuccess.messageID) {\n+ invariant(\n+ uploadAfterSuccess,\n+ `pendingUpload ${upload.localID}/${result.id} for ${threadID} missing ` +\n+ `after upload`,\n+ );\n+ if (uploadAfterSuccess.messageID) {\nthis.props.dispatchActionPayload(\nassignMediaServerIDToMessageActionType,\n{\n@@ -206,38 +422,37 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\nthis.setState(prevState => {\nconst uploads = prevState.pendingUploads[threadID];\nconst currentUpload = uploads[upload.localID];\n- if (!currentUpload) {\n- return {};\n- }\n- let newUploads;\n- if (currentUpload.messageID) {\n- // If the messageID is already set, then there is no need to keep\n- // tracking this upload. The above action dispatch should ensure no\n- // pointers to this localID exist.\n- newUploads = _omit([ upload.localID ])(uploads);\n- } else {\n- // Otherwise, the message hasn't been sent yet, so the uploads are still\n- // pending. We'll mark the serverID in our local state.\n- newUploads = {\n+ invariant(\n+ currentUpload,\n+ `pendingUpload ${upload.localID}/${result.id} for ${threadID} ` +\n+ `missing while assigning serverID`,\n+ );\n+ return {\n+ pendingUploads: {\n+ ...prevState.pendingUploads,\n+ [threadID]: {\n...uploads,\n[upload.localID]: {\n...currentUpload,\nserverID: result.id,\nabort: null,\n},\n- };\n- }\n- return {\n- pendingUploads: {\n- ...prevState.pendingUploads,\n- [threadID]: newUploads,\n+ },\n},\n};\n});\nawait preloadImage(result.uri);\n- const replaceURI = upload => this.props.dispatchActionPayload(\n+ const uploadAfterPreload =\n+ this.state.pendingUploads[threadID][upload.localID];\n+ invariant(\n+ uploadAfterPreload,\n+ `pendingUpload ${upload.localID}/${result.id} for ${threadID} missing ` +\n+ `after preload`,\n+ );\n+ if (uploadAfterPreload.messageID) {\n+ this.props.dispatchActionPayload(\nassignMediaServerURIToMessageActionType,\n{\nmessageID: uploadAfterPreload.messageID,\n@@ -247,47 +462,41 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\nserverURI: result.uri,\n},\n);\n+ }\n- const uploadAfterPreload =\n- this.state.pendingUploads[threadID][upload.localID];\n- if (!uploadAfterPreload || uploadAfterPreload.messageID) {\n- replaceURI(uploadAfterPreload);\n- } else {\nthis.setState(prevState => {\nconst uploads = prevState.pendingUploads[threadID];\nconst currentUpload = uploads[upload.localID];\n- if (!currentUpload) {\n- replaceURI(currentUpload);\n- return {};\n+ invariant(\n+ currentUpload,\n+ `pendingUpload ${upload.localID}/${result.id} for ${threadID} ` +\n+ `missing while assigning URI`,\n+ );\n+ const { messageID } = currentUpload;\n+ if (messageID && !messageID.startsWith(\"local\")) {\n+ const newPendingUploads = _omit([ upload.localID ])(uploads);\n+ return {\n+ pendingUploads: {\n+ ...prevState.pendingUploads,\n+ [threadID]: newPendingUploads,\n+ },\n+ };\n}\n- let newUploads;\n- if (currentUpload.messageID) {\n- // If the messageID is already set, then there is no need to keep\n- // tracking this upload. The above action dispatch should ensure no\n- // pointers to this localID exist.\n- newUploads = _omit([ upload.localID ])(uploads);\n- replaceURI(currentUpload);\n- } else {\n- // Otherwise, the message hasn't been sent yet, so the uploads are still\n- // pending. We'll mark the serverID in our local state.\n- newUploads = {\n+ return {\n+ pendingUploads: {\n+ ...prevState.pendingUploads,\n+ [threadID]: {\n...uploads,\n[upload.localID]: {\n...currentUpload,\nuri: result.uri,\nuriIsReal: true,\n},\n- };\n- }\n- return {\n- pendingUploads: {\n- ...prevState.pendingUploads,\n- [threadID]: newUploads,\n+ },\n},\n};\n});\n}\n- }\nhandleAbortCallback(\nthreadID: string,\n@@ -389,24 +598,33 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\n);\n}\n- assignPendingUploads(threadID: string, localMessageID: string) {\n+ // Creates a MultimediaMessage from the unassigned pending uploads,\n+ // if there are any\n+ createMultimediaMessage(threadID: string) {\n+ const localMessageID = `local${this.props.nextLocalID}`;\nthis.setState(prevState => {\nconst currentPendingUploads = prevState.pendingUploads[threadID];\n- if (\n- !currentPendingUploads ||\n- Object.keys(currentPendingUploads).length === 0\n- ) {\n+ if (!currentPendingUploads) {\nreturn {};\n}\n- const newPendingUploads = _flow(\n- _omitBy('serverID'),\n- _mapValues(\n- (pendingUpload: PendingMultimediaUpload) => ({\n- ...pendingUpload,\n+ const newPendingUploads = {};\n+ let uploadAssigned = false;\n+ for (let localUploadID in currentPendingUploads) {\n+ const upload = currentPendingUploads[localUploadID];\n+ if (upload.messageID) {\n+ newPendingUploads[localUploadID] = upload;\n+ } else {\n+ const newUpload = {\n+ ...upload,\nmessageID: localMessageID,\n- }),\n- ),\n- )(currentPendingUploads);\n+ };\n+ uploadAssigned = true;\n+ newPendingUploads[localUploadID] = newUpload;\n+ }\n+ }\n+ if (!uploadAssigned) {\n+ return {};\n+ }\nreturn {\npendingUploads: {\n...prevState.pendingUploads,\n@@ -464,13 +682,23 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\nreturn pendingUploads.some(upload => upload.failed);\n}\n- retryUploads(\n+ retryMultimediaMessage(\nthreadID: string,\n+ localMessageID: string,\npendingUploads: ?$ReadOnlyArray<PendingMultimediaUpload>,\n) {\n+ const completed = ChatInputStateContainer.completedMessageIDs(this.state);\n+ if (completed.has(localMessageID)) {\n+ const rawMessageInfo = this.getRawMultimediaMessageInfo(localMessageID);\n+ const newRawMessageInfo = { ...rawMessageInfo, time: Date.now() };\n+ this.sendMultimediaMessage(newRawMessageInfo);\n+ return;\n+ }\n+\nif (!pendingUploads) {\nreturn;\n}\n+\nconst uploadIDsToRetry = new Set();\nconst uploadsToRetry = [];\nfor (let pendingUpload of pendingUploads) {\n@@ -490,6 +718,7 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\nreturn {};\n}\nconst newPendingUploads = {};\n+ let pendingUploadChanged = false;\nfor (let localID in pendingUploads) {\nconst pendingUpload = pendingUploads[localID];\nif (uploadIDsToRetry.has(localID) && !pendingUpload.serverID) {\n@@ -499,10 +728,14 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\nprogressPercent: 0,\nabort: null,\n};\n+ pendingUploadChanged = true;\n} else {\nnewPendingUploads[localID] = pendingUpload;\n}\n}\n+ if (!pendingUploadChanged) {\n+ return {};\n+ }\nreturn {\npendingUploads: {\n...prevState.pendingUploads,\n@@ -533,6 +766,9 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\nexport default connect(\n(state: AppState) => ({\nactiveChatThreadID: state.navInfo.activeChatThreadID,\n+ viewerID: state.currentUserInfo && state.currentUserInfo.id,\n+ nextLocalID: state.nextLocalID,\n+ messageStoreMessages: state.messageStore.messages,\n}),\n- { uploadMultimedia, deleteUpload },\n+ { uploadMultimedia, deleteUpload, sendMultimediaMessage },\n)(ChatInputStateContainer);\n" }, { "change_type": "MODIFY", "old_path": "web/chat/chat-input-state.js", "new_path": "web/chat/chat-input-state.js", "diff": "@@ -13,9 +13,7 @@ export type PendingMultimediaUpload = {|\nlocalID: string,\n// Pending uploads are assigned a serverID once they are complete\nserverID: ?string,\n- // Pending uploads are assigned a messageID once they are sent. serverID and\n- // messageID shouldn't both be set, as in that case the upload is no longer\n- // pending and should be cleared out\n+ // Pending uploads are assigned a messageID once they are sent\nmessageID: ?string,\n// This is set to truthy if the upload fails for whatever reason\nfailed: ?string,\n@@ -53,11 +51,11 @@ export type ChatInputState = {|\ndraft: string,\nappendFiles: (files: $ReadOnlyArray<File>) => Promise<void>,\ncancelPendingUpload: (localUploadID: string) => void,\n- assignPendingUploads: (localMessageID: string) => void,\n+ createMultimediaMessage: () => void,\nsetDraft: (draft: string) => void,\nsetProgress: (localUploadID: string, percent: number) => void,\nmessageHasUploadFailure: (localMessageID: string) => bool,\n- retryUploads: (localMessageID: string) => void,\n+ retryMultimediaMessage: (localMessageID: string) => void,\n|};\nconst arrayOfUploadsPropType =\nPropTypes.arrayOf(pendingMultimediaUploadPropType);\n@@ -67,9 +65,9 @@ export const chatInputStatePropType = PropTypes.shape({\ndraft: PropTypes.string.isRequired,\nappendFiles: PropTypes.func.isRequired,\ncancelPendingUpload: PropTypes.func.isRequired,\n- assignPendingUploads: PropTypes.func.isRequired,\n+ createMultimediaMessage: PropTypes.func.isRequired,\nsetDraft: PropTypes.func.isRequired,\nsetProgress: PropTypes.func.isRequired,\nmessageHasUploadFailure: PropTypes.func.isRequired,\n- retryUploads: PropTypes.func.isRequired,\n+ retryMultimediaMessage: PropTypes.func.isRequired,\n});\n" }, { "change_type": "MODIFY", "old_path": "web/chat/failed-send.react.js", "new_path": "web/chat/failed-send.react.js", "diff": "@@ -9,7 +9,6 @@ import {\ntype SendMessageResult,\ntype RawComposableMessageInfo,\ntype RawTextMessageInfo,\n- type RawMultimediaMessageInfo,\nassertComposableMessageType,\n} from 'lib/types/message-types';\nimport { type ThreadInfo, threadInfoPropType } from 'lib/types/thread-types';\n@@ -29,8 +28,6 @@ import { connect } from 'lib/utils/redux-utils';\nimport {\nsendTextMessageActionTypes,\nsendTextMessage,\n- sendMultimediaMessageActionTypes,\n- sendMultimediaMessage,\n} from 'lib/actions/message-actions';\nimport css from './chat-message-list.css';\n@@ -93,19 +90,9 @@ class FailedSend extends React.PureComponent<Props> {\nnewRawMessageInfo,\n);\n} else if (rawMessageInfo.type === messageTypes.MULTIMEDIA) {\n- const newRawMessageInfo = { ...rawMessageInfo, time: Date.now() };\n- const { localID } = newRawMessageInfo;\n+ const { localID } = rawMessageInfo;\ninvariant(localID, \"failed RawMessageInfo should have localID\");\n- if (this.props.chatInputState.messageHasUploadFailure(localID)) {\n- this.props.chatInputState.retryUploads(localID);\n- } else {\n- this.props.dispatchActionPromise(\n- sendMultimediaMessageActionTypes,\n- this.sendMultimediaMessageAction(newRawMessageInfo),\n- undefined,\n- newRawMessageInfo,\n- );\n- }\n+ this.props.chatInputState.retryMultimediaMessage(localID);\n}\n}\n@@ -134,31 +121,6 @@ class FailedSend extends React.PureComponent<Props> {\n}\n}\n- async sendMultimediaMessageAction(messageInfo: RawMultimediaMessageInfo) {\n- try {\n- const { localID } = messageInfo;\n- invariant(\n- localID !== null && localID !== undefined,\n- \"localID should be set\",\n- );\n- const result = await this.props.sendMultimediaMessage(\n- messageInfo.threadID,\n- localID,\n- messageInfo.media.map(({ id }) => id),\n- );\n- return {\n- localID,\n- serverID: result.id,\n- threadID: messageInfo.threadID,\n- time: result.time,\n- };\n- } catch (e) {\n- e.localID = messageInfo.localID;\n- e.threadID = messageInfo.threadID;\n- throw e;\n- }\n- }\n-\n}\nexport default connect(\n@@ -175,5 +137,5 @@ export default connect(\n);\nreturn { rawMessageInfo };\n},\n- { sendTextMessage, sendMultimediaMessage },\n+ { sendTextMessage },\n)(FailedSend);\n" }, { "change_type": "MODIFY", "old_path": "web/chat/multimedia-message.react.js", "new_path": "web/chat/multimedia-message.react.js", "diff": "@@ -4,33 +4,19 @@ import {\ntype ChatMessageInfoItem,\nchatMessageItemPropType,\n} from 'lib/selectors/chat-selectors';\n-import {\n- messageTypes,\n- type SendMessageResult,\n- type RawMultimediaMessageInfo,\n-} from 'lib/types/message-types';\n+import { messageTypes } from 'lib/types/message-types';\nimport {\nchatInputStatePropType,\ntype ChatInputState,\n} from './chat-input-state';\nimport type { MessagePositionInfo } from './message.react';\nimport { type ThreadInfo, threadInfoPropType } from 'lib/types/thread-types';\n-import type { AppState } from '../redux-setup';\n-import type { DispatchActionPromise } from 'lib/utils/action-utils';\nimport * as React from 'react';\nimport invariant from 'invariant';\nimport PropTypes from 'prop-types';\nimport classNames from 'classnames';\n-import { messageKey } from 'lib/shared/message-utils';\n-import { connect } from 'lib/utils/redux-utils';\n-import {\n- sendMultimediaMessageActionTypes,\n- sendMultimediaMessage,\n-} from 'lib/actions/message-actions';\n-import { messageID } from 'lib/shared/message-utils';\n-\nimport css from './chat-message-list.css';\nimport Multimedia from './multimedia.react';\nimport ComposedMessage from './composed-message.react';\n@@ -41,16 +27,6 @@ type Props = {|\nsetMouseOver: (messagePositionInfo: MessagePositionInfo) => void,\nchatInputState: ChatInputState,\nsetModal: (modal: ?React.Node) => void,\n- // Redux state\n- rawMessageInfo: RawMultimediaMessageInfo,\n- // Redux dispatch functions\n- dispatchActionPromise: DispatchActionPromise,\n- // async functions that hit server APIs\n- sendMultimediaMessage: (\n- threadID: string,\n- localID: string,\n- mediaIDs: $ReadOnlyArray<string>,\n- ) => Promise<SendMessageResult>,\n|};\nclass MultimediaMessage extends React.PureComponent<Props> {\n@@ -60,66 +36,8 @@ class MultimediaMessage extends React.PureComponent<Props> {\nsetMouseOver: PropTypes.func.isRequired,\nchatInputState: chatInputStatePropType.isRequired,\nsetModal: PropTypes.func.isRequired,\n- rawMessageInfo: PropTypes.object.isRequired,\n- dispatchActionPromise: PropTypes.func.isRequired,\n- sendMultimediaMessage: PropTypes.func.isRequired,\n};\n- componentDidMount() {\n- if (MultimediaMessage.multimediaUploadComplete(this.props)) {\n- this.sendMultimediaMessage();\n- }\n- }\n-\n- componentDidUpdate(prevProps: Props) {\n- if (\n- !MultimediaMessage.multimediaUploadComplete(prevProps) &&\n- MultimediaMessage.multimediaUploadComplete(this.props)\n- ) {\n- this.sendMultimediaMessage();\n- }\n- }\n-\n- sendMultimediaMessage() {\n- const { rawMessageInfo } = this.props;\n- if (rawMessageInfo.id) {\n- return;\n- }\n- this.props.dispatchActionPromise(\n- sendMultimediaMessageActionTypes,\n- this.sendMultimediaMessageAction(rawMessageInfo),\n- undefined,\n- rawMessageInfo,\n- );\n- }\n-\n- static multimediaUploadComplete(props: Props) {\n- const { messageInfo } = props.item;\n- invariant(\n- messageInfo.type === messageTypes.MULTIMEDIA,\n- \"MultimediaMessage should only be used for messageTypes.MULTIMEDIA\",\n- );\n- if (messageInfo.id) {\n- return true;\n- }\n- if (MultimediaMessage.multimediaUploadFailed(props)) {\n- return false;\n- }\n- const { localID, media } = messageInfo;\n- const pendingUploads = localID\n- ? props.chatInputState.assignedUploads[localID]\n- : null;\n- if (!pendingUploads) {\n- return true;\n- }\n- return messageInfo.media.every(media => {\n- const pendingUpload = pendingUploads.find(\n- upload => upload.localID === media.id,\n- );\n- return !pendingUpload || pendingUpload.serverID;\n- });\n- }\n-\nstatic multimediaUploadFailed(props: Props) {\nconst { messageInfo } = props.item;\ninvariant(\n@@ -190,47 +108,6 @@ class MultimediaMessage extends React.PureComponent<Props> {\n);\n}\n- async sendMultimediaMessageAction(messageInfo: RawMultimediaMessageInfo) {\n- try {\n- const { localID } = messageInfo;\n- invariant(\n- localID !== null && localID !== undefined,\n- \"localID should be set\",\n- );\n- const result = await this.props.sendMultimediaMessage(\n- messageInfo.threadID,\n- localID,\n- messageInfo.media.map(({ id }) => id),\n- );\n- return {\n- localID,\n- serverID: result.id,\n- threadID: messageInfo.threadID,\n- time: result.time,\n- };\n- } catch (e) {\n- e.localID = messageInfo.localID;\n- e.threadID = messageInfo.threadID;\n- throw e;\n- }\n- }\n-\n}\n-export default connect(\n- (state: AppState, ownProps: { item: ChatMessageInfoItem }) => {\n- const { messageInfo } = ownProps.item;\n- invariant(\n- messageInfo.type === messageTypes.MULTIMEDIA,\n- \"MultimediaMessage should only be used for messageTypes.MULTIMEDIA\",\n- );\n- const id = messageID(messageInfo);\n- const rawMessageInfo = state.messageStore.messages[id];\n- invariant(\n- rawMessageInfo.type === messageTypes.MULTIMEDIA,\n- \"MultimediaMessage should only be used for messageTypes.MULTIMEDIA\",\n- );\n- return { rawMessageInfo };\n- },\n- { sendMultimediaMessage },\n-)(MultimediaMessage);\n+export default MultimediaMessage;\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[web] Move multimedia message actions to ChatInputStateContainer
129,187
22.05.2019 20:04:46
14,400
22b1fa63ccb6f271db49d2b6d07f21610b3405da
[native] Introducing Chat component Will handle `MessageStorePruner` going forward
[ { "change_type": "MODIFY", "old_path": "native/app.react.js", "new_path": "native/app.react.js", "diff": "@@ -89,7 +89,6 @@ import { saveMessageInfos } from './push/utils';\nimport NotificationBody from './push/notification-body.react';\nimport ErrorBoundary from './error-boundary.react';\nimport { AppRouteName } from './navigation/route-names';\n-import MessageStorePruner from './chat/message-store-pruner.react';\nimport DisconnectedBarVisibilityHandler\nfrom './navigation/disconnected-bar-visibility-handler.react';\nimport DimensionsUpdater from './redux/dimensions-updater.react';\n@@ -626,7 +625,6 @@ class AppWithNavigationState extends React.PureComponent<Props> {\nnotificationBodyComponent={NotificationBody}\nref={this.inAppNotificationRef}\n/>\n- <MessageStorePruner />\n<DisconnectedBarVisibilityHandler />\n<DimensionsUpdater />\n<ConnectivityUpdater />\n" }, { "change_type": "ADD", "old_path": null, "new_path": "native/chat/chat-navigator.react.js", "diff": "+// @flow\n+\n+import type {\n+ NavigationScreenProp,\n+ NavigationStateRoute,\n+} from 'react-navigation';\n+\n+import * as React from 'react';\n+import { Platform } from 'react-native';\n+import { createStackNavigator } from 'react-navigation';\n+\n+import ChatThreadList from './chat-thread-list.react';\n+import MessageListContainer from './message-list-container.react';\n+import ComposeThread from './compose-thread.react';\n+import ThreadSettings from './settings/thread-settings.react';\n+import { getChatScreen } from './chat-screen-registry';\n+import DeleteThread from './settings/delete-thread.react';\n+import ChatIcon from './chat-icon.react';\n+import ChatLabel from './chat-label.react';\n+import {\n+ ComposeThreadRouteName,\n+ DeleteThreadRouteName,\n+ ThreadSettingsRouteName,\n+ MessageListRouteName,\n+ ChatThreadListRouteName,\n+} from '../navigation/route-names';\n+import Header from '../navigation/header.react';\n+\n+const ChatNavigator = createStackNavigator(\n+ {\n+ [ChatThreadListRouteName]: ChatThreadList,\n+ [MessageListRouteName]: MessageListContainer,\n+ [ComposeThreadRouteName]: ComposeThread,\n+ [ThreadSettingsRouteName]: ThreadSettings,\n+ [DeleteThreadRouteName]: DeleteThread,\n+ },\n+ {\n+ defaultNavigationOptions: {\n+ header: Header,\n+ },\n+ cardStyle: {\n+ backgroundColor: \"#E9E9EF\",\n+ },\n+ },\n+);\n+ChatNavigator.navigationOptions = ({ navigation }) => ({\n+ tabBarLabel: Platform.OS === \"android\"\n+ ? ({ tintColor }) => <ChatLabel color={tintColor} />\n+ : \"Chat\",\n+ tabBarIcon: ({ tintColor }) => <ChatIcon color={tintColor} />,\n+ tabBarOnPress: ({ navigation, defaultHandler }: {\n+ navigation: NavigationScreenProp<NavigationStateRoute>,\n+ defaultHandler: () => void,\n+ }) => {\n+ if (!navigation.isFocused()) {\n+ defaultHandler();\n+ return;\n+ }\n+ const state = navigation.state;\n+ if (state.index === 0) {\n+ return;\n+ }\n+ const currentRoute = state.routes[state.index];\n+ const chatScreen = getChatScreen(currentRoute.key);\n+ if (!chatScreen) {\n+ return;\n+ }\n+ if (chatScreen.canReset) {\n+ navigation.goBack(state.routes[1].key);\n+ }\n+ },\n+});\n+\n+export default ChatNavigator;\n" }, { "change_type": "MODIFY", "old_path": "native/chat/chat.react.js", "new_path": "native/chat/chat.react.js", "diff": "// @flow\n-import type {\n- NavigationScreenProp,\n- NavigationStateRoute,\n-} from 'react-navigation';\n-\nimport * as React from 'react';\n-import { Platform, StyleSheet } from 'react-native';\n-import { createStackNavigator } from 'react-navigation';\nimport hoistNonReactStatics from 'hoist-non-react-statics';\n+import { StyleSheet } from 'react-native';\n-import ChatThreadList from './chat-thread-list.react';\n-import MessageListContainer from './message-list-container.react';\n-import ComposeThread from './compose-thread.react';\n-import ThreadSettings from './settings/thread-settings.react';\n-import { getChatScreen } from './chat-screen-registry';\n-import DeleteThread from './settings/delete-thread.react';\n-import ChatIcon from './chat-icon.react';\n-import ChatLabel from './chat-label.react';\n-import {\n- ComposeThreadRouteName,\n- DeleteThreadRouteName,\n- ThreadSettingsRouteName,\n- MessageListRouteName,\n- ChatThreadListRouteName,\n-} from '../navigation/route-names';\n-import Header from '../navigation/header.react';\n+import ChatNavigator from './chat-navigator.react';\nimport KeyboardAvoidingView from '../components/keyboard-avoiding-view.react';\n+import MessageStorePruner from './message-store-pruner.react';\n-const Chat = createStackNavigator(\n- {\n- [ChatThreadListRouteName]: ChatThreadList,\n- [MessageListRouteName]: MessageListContainer,\n- [ComposeThreadRouteName]: ComposeThread,\n- [ThreadSettingsRouteName]: ThreadSettings,\n- [DeleteThreadRouteName]: DeleteThread,\n- },\n- {\n- defaultNavigationOptions: {\n- header: Header,\n- },\n- cardStyle: {\n- backgroundColor: \"#E9E9EF\",\n- },\n- },\n+type Props = {|\n+|};\n+class Chat extends React.PureComponent<Props> {\n+\n+ render() {\n+ return (\n+ <KeyboardAvoidingView style={styles.keyboardAvoidingView}>\n+ <ChatNavigator {...this.props} />\n+ <MessageStorePruner />\n+ </KeyboardAvoidingView>\n);\n-Chat.navigationOptions = ({ navigation }) => ({\n- tabBarLabel: Platform.OS === \"android\"\n- ? ({ tintColor }) => <ChatLabel color={tintColor} />\n- : \"Chat\",\n- tabBarIcon: ({ tintColor }) => <ChatIcon color={tintColor} />,\n- tabBarOnPress: ({ navigation, defaultHandler }: {\n- navigation: NavigationScreenProp<NavigationStateRoute>,\n- defaultHandler: () => void,\n- }) => {\n- if (!navigation.isFocused()) {\n- defaultHandler();\n- return;\n}\n- const state = navigation.state;\n- if (state.index === 0) {\n- return;\n- }\n- const currentRoute = state.routes[state.index];\n- const chatScreen = getChatScreen(currentRoute.key);\n- if (!chatScreen) {\n- return;\n- }\n- if (chatScreen.canReset) {\n- navigation.goBack(state.routes[1].key);\n+\n}\n- },\n-});\nconst styles = StyleSheet.create({\nkeyboardAvoidingView: {\n@@ -79,11 +29,6 @@ const styles = StyleSheet.create({\n},\n});\n-const KeyboardAvoidingChat = (props: *) => (\n- <KeyboardAvoidingView style={styles.keyboardAvoidingView}>\n- <Chat {...props} />\n- </KeyboardAvoidingView>\n-);\n-hoistNonReactStatics(KeyboardAvoidingChat, Chat);\n+hoistNonReactStatics(Chat, ChatNavigator);\n-export default KeyboardAvoidingChat;\n+export default Chat;\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Introducing Chat component Will handle `MessageStorePruner` going forward
129,187
24.05.2019 11:42:40
14,400
70be2cd172b1dd7bc16e916c9374a29d6397324a
[native] Avoid ImageGalleryKeyboard.sendImages getting triggered more than once
[ { "change_type": "MODIFY", "old_path": "native/media/image-gallery-keyboard.react.js", "new_path": "native/media/image-gallery-keyboard.react.js", "diff": "@@ -63,6 +63,7 @@ class ImageGalleryKeyboard extends React.PureComponent<Props, State> {\nviewableIndices: number[] = [];\nqueueModeProgress = new Animated.Value(0);\nsendButtonStyle: ViewStyle;\n+ imagesSelected = false;\nconstructor(props: Props) {\nsuper(props);\n@@ -421,6 +422,10 @@ class ImageGalleryKeyboard extends React.PureComponent<Props, State> {\n}\nsendImages(imageInfos: $ReadOnlyArray<GalleryImageInfo>) {\n+ if (this.imagesSelected) {\n+ return;\n+ }\n+ this.imagesSelected = true;\nKeyboardRegistry.onItemSelected(imageGalleryKeyboardName, imageInfos);\n}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Avoid ImageGalleryKeyboard.sendImages getting triggered more than once
129,187
24.05.2019 11:43:05
14,400
0bab71de34a17387090021c6dd9df15b32d7f5ac
[web] Clean up some unnecessary media code
[ { "change_type": "MODIFY", "old_path": "web/chat/chat-input-state-container.react.js", "new_path": "web/chat/chat-input-state-container.react.js", "diff": "@@ -302,8 +302,6 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\ncreateMultimediaMessage: () =>\nthis.createMultimediaMessage(threadID),\nsetDraft: (draft: string) => this.setDraft(threadID, draft),\n- setProgress: (localUploadID: string, percent: number) =>\n- this.setProgress(threadID, localUploadID, percent),\nmessageHasUploadFailure: (localMessageID: string) =>\nthis.messageHasUploadFailure(threadAssignedUploads[localMessageID]),\nretryMultimediaMessage: (localMessageID: string) =>\n" }, { "change_type": "MODIFY", "old_path": "web/chat/chat-input-state.js", "new_path": "web/chat/chat-input-state.js", "diff": "@@ -53,7 +53,6 @@ export type ChatInputState = {|\ncancelPendingUpload: (localUploadID: string) => void,\ncreateMultimediaMessage: () => void,\nsetDraft: (draft: string) => void,\n- setProgress: (localUploadID: string, percent: number) => void,\nmessageHasUploadFailure: (localMessageID: string) => bool,\nretryMultimediaMessage: (localMessageID: string) => void,\n|};\n@@ -67,7 +66,6 @@ export const chatInputStatePropType = PropTypes.shape({\ncancelPendingUpload: PropTypes.func.isRequired,\ncreateMultimediaMessage: PropTypes.func.isRequired,\nsetDraft: PropTypes.func.isRequired,\n- setProgress: PropTypes.func.isRequired,\nmessageHasUploadFailure: PropTypes.func.isRequired,\nretryMultimediaMessage: PropTypes.func.isRequired,\n});\n" }, { "change_type": "MODIFY", "old_path": "web/utils/media-utils.js", "new_path": "web/utils/media-utils.js", "diff": "@@ -47,11 +47,7 @@ async function validateFile(file: File): Promise<?FileValidationResult> {\nif (!fileInfo) {\nreturn null;\n}\n- const { name, mime } = fileInfo;\n- const mediaType = mimeTypesToMediaTypes[mime];\n- if (!mediaType) {\n- return null;\n- }\n+ const { name, mime, mediaType } = fileInfo;\nlet dimensions = null;\nif (mediaType === \"photo\") {\ndimensions = await getPhotoDimensions(file);\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[web] Clean up some unnecessary media code
129,187
24.05.2019 12:29:13
14,400
8ec98536e2fb6e03d1e5c9e6e602c3ef73bb3ebf
[native] Get rid of preloadImage logic We don't need the dimensions (we get them already from native API), and we're using `FastImage` anyways so no point using `Image.prefetch`.
[ { "change_type": "DELETE", "old_path": "native/utils/media-utils.js", "new_path": null, "diff": "-// @flow\n-\n-import type { Dimensions } from 'lib/types/media-types';\n-\n-import { Image } from 'react-native';\n-\n-async function preloadImage(uri: string): Promise<Dimensions> {\n- const [ dimensions ] = await Promise.all([\n- fetchSize(uri),\n- Image.prefetch(uri),\n- ]);\n- return dimensions;\n-}\n-\n-function fetchSize(uri: string): Promise<Dimensions> {\n- return new Promise((resolve, reject) => {\n- const success = (width, height) => resolve({ height, width });\n- Image.getSize(uri, success, reject);\n- });\n-}\n-\n-export {\n- preloadImage,\n-};\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Get rid of preloadImage logic We don't need the dimensions (we get them already from native API), and we're using `FastImage` anyways so no point using `Image.prefetch`.
129,187
24.05.2019 13:13:04
14,400
67fb94390f03c5d8148e43ba8ee4074414b2ca49
Make abortHandler optional on uploadMultimedia
[ { "change_type": "MODIFY", "old_path": "lib/actions/upload-actions.js", "new_path": "lib/actions/upload-actions.js", "diff": "@@ -7,7 +7,7 @@ async function uploadMultimedia(\nfetchJSON: FetchJSON,\nmultimedia: Object,\nonProgress: (percent: number) => void,\n- abortHandler: (abort: () => void) => void,\n+ abortHandler?: (abort: () => void) => void,\n): Promise<UploadMultimediaResult> {\nconst response = await fetchJSON(\n'upload_multimedia',\n" }, { "change_type": "MODIFY", "old_path": "web/chat/chat-input-state-container.react.js", "new_path": "web/chat/chat-input-state-container.react.js", "diff": "@@ -59,7 +59,7 @@ type Props = {|\nuploadMultimedia: (\nmultimedia: Object,\nonProgress: (percent: number) => void,\n- abortHandler: (abort: () => void) => void,\n+ abortHandler?: (abort: () => void) => void,\n) => Promise<UploadMultimediaResult>,\ndeleteUpload: (id: string) => Promise<void>,\nsendMultimediaMessage: (\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Make abortHandler optional on uploadMultimedia
129,187
24.05.2019 13:17:08
14,400
5b1fee81c8029488ae1086900316d3869d0eb014
[native] Actually upload images
[ { "change_type": "MODIFY", "old_path": "native/chat/chat-input-bar.react.js", "new_path": "native/chat/chat-input-bar.react.js", "diff": "@@ -71,6 +71,7 @@ import {\nimageGalleryKeyboardName,\nimageGalleryBackgroundColor,\n} from '../media/image-gallery-keyboard.react';\n+import { ChatInputStateContext } from './chat-input-state';\nconst draftKeyFromThreadID =\n(threadID: string) => `${threadID}/message_composer`;\n@@ -117,6 +118,7 @@ class ChatInputBar extends React.PureComponent<Props, State> {\nsendTextMessage: PropTypes.func.isRequired,\njoinThread: PropTypes.func.isRequired,\n};\n+ static contextType = ChatInputStateContext;\nstatic kbInitialProps = {\nbackgroundColor: imageGalleryBackgroundColor,\n};\n@@ -422,13 +424,13 @@ class ChatInputBar extends React.PureComponent<Props, State> {\n}: RawTextMessageInfo);\nthis.props.dispatchActionPromise(\nsendTextMessageActionTypes,\n- this.sendMessageAction(messageInfo),\n+ this.sendTextMessageAction(messageInfo),\nundefined,\nmessageInfo,\n);\n}\n- async sendMessageAction(messageInfo: RawTextMessageInfo) {\n+ async sendTextMessageAction(messageInfo: RawTextMessageInfo) {\ntry {\nconst { localID } = messageInfo;\ninvariant(\n@@ -518,6 +520,9 @@ class ChatInputBar extends React.PureComponent<Props, State> {\nimageInfos: $ReadOnlyArray<GalleryImageInfo>,\n) => {\nKeyboardUtils.dismiss();\n+ const chatInputState = this.context;\n+ invariant(chatInputState, \"chatInputState should be set in ChatInputBar\");\n+ chatInputState.sendMultimediaMessage(this.props.threadInfo.id, imageInfos);\n}\n}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "native/chat/chat-input-state.js", "diff": "+// @flow\n+\n+import type { Dimensions } from 'lib/types/media-types';\n+import type { GalleryImageInfo } from '../media/image-gallery-image.react';\n+\n+import * as React from 'react';\n+\n+export type PendingMultimediaUpload = {|\n+ failed: ?string,\n+ progressPercent: number,\n+|};\n+\n+export type PendingMultimediaUploads = {\n+ [localMessageID: string]: {\n+ [localUploadID: string]: PendingMultimediaUpload,\n+ },\n+};\n+\n+export type ChatInputState = {|\n+ pendingUploads: PendingMultimediaUploads,\n+ sendMultimediaMessage: (\n+ threadID: string,\n+ imageInfos: $ReadOnlyArray<GalleryImageInfo>,\n+ ) => Promise<void>,\n+ messageHasUploadFailure: (localMessageID: string) => bool,\n+ retryMultimediaMessage: (localMessageID: string) => Promise<void>,\n+|};\n+\n+const ChatInputStateContext = React.createContext<?ChatInputState>(null);\n+\n+export {\n+ ChatInputStateContext,\n+};\n" }, { "change_type": "MODIFY", "old_path": "native/chat/chat.react.js", "new_path": "native/chat/chat.react.js", "diff": "// @flow\n+import type {\n+ PendingMultimediaUploads,\n+ ChatInputState,\n+} from './chat-input-state';\n+import type { GalleryImageInfo } from '../media/image-gallery-image.react';\n+import type { AppState } from '../redux/redux-setup';\n+import type {\n+ DispatchActionPayload,\n+ DispatchActionPromise,\n+} from 'lib/utils/action-utils';\n+import type { UploadMultimediaResult } from 'lib/types/media-types';\n+import {\n+ messageTypes,\n+ type RawMessageInfo,\n+ type RawMultimediaMessageInfo,\n+ type SendMessageResult,\n+} from 'lib/types/message-types';\n+import type { NativeImageInfo } from '../utils/media-utils';\n+\nimport * as React from 'react';\n-import hoistNonReactStatics from 'hoist-non-react-statics';\n+import PropTypes from 'prop-types';\n+import invariant from 'invariant';\nimport { StyleSheet } from 'react-native';\n+import hoistNonReactStatics from 'hoist-non-react-statics';\n+\n+import { connect } from 'lib/utils/redux-utils';\n+import {\n+ uploadMultimedia,\n+} from 'lib/actions/upload-actions';\n+import {\n+ createLocalMultimediaMessageActionType,\n+ sendMultimediaMessageActionTypes,\n+ sendMultimediaMessage,\n+} from 'lib/actions/message-actions';\nimport ChatNavigator from './chat-navigator.react';\nimport KeyboardAvoidingView from '../components/keyboard-avoiding-view.react';\nimport MessageStorePruner from './message-store-pruner.react';\n+import { ChatInputStateContext } from './chat-input-state';\n+import { validateMedia } from '../utils/media-utils';\n+\n+let nextLocalUploadID = 0;\n+type ImageInfo = {|\n+ ...NativeImageInfo,\n+ localID: string,\n+|};\ntype Props = {|\n+ // Redux state\n+ viewerID: ?string,\n+ nextLocalID: number,\n+ messageStoreMessages: { [id: string]: RawMessageInfo },\n+ // Redux dispatch functions\n+ dispatchActionPayload: DispatchActionPayload,\n+ dispatchActionPromise: DispatchActionPromise,\n+ // async functions that hit server APIs\n+ uploadMultimedia: (\n+ multimedia: Object,\n+ onProgress: (percent: number) => void,\n+ abortHandler?: (abort: () => void) => void,\n+ ) => Promise<UploadMultimediaResult>,\n+ sendMultimediaMessage: (\n+ threadID: string,\n+ localID: string,\n+ mediaIDs: $ReadOnlyArray<string>,\n+ ) => Promise<SendMessageResult>,\n+|};\n+type State = {|\n+ pendingUploads: PendingMultimediaUploads,\n|};\n-class Chat extends React.PureComponent<Props> {\n+class Chat extends React.PureComponent<Props, State> {\n+\n+ static propTypes = {\n+ viewerID: PropTypes.string,\n+ nextLocalID: PropTypes.number.isRequired,\n+ messageStoreMessages: PropTypes.object.isRequired,\n+ dispatchActionPayload: PropTypes.func.isRequired,\n+ dispatchActionPromise: PropTypes.func.isRequired,\n+ uploadMultimedia: PropTypes.func.isRequired,\n+ sendMultimediaMessage: PropTypes.func.isRequired,\n+ };\n+ chatInputState: ChatInputState;\n+\n+ constructor(props: Props) {\n+ super(props);\n+ this.state = {\n+ pendingUploads: {},\n+ };\n+ this.updateChatInputState();\n+ }\n+\n+ updateChatInputState() {\n+ this.chatInputState = {\n+ pendingUploads: this.state.pendingUploads,\n+ sendMultimediaMessage: this.sendMultimediaMessage,\n+ messageHasUploadFailure: this.messageHasUploadFailure,\n+ retryMultimediaMessage: this.retryMultimediaMessage,\n+ };\n+ }\n+\n+ componentDidUpdate(prevProps: Props, prevState: State) {\n+ if (this.state.pendingUploads !== prevState.pendingUploads) {\n+ this.updateChatInputState();\n+ }\n+ }\n+\n+ sendMultimediaMessage = async (\n+ threadID: string,\n+ inputImageInfos: $ReadOnlyArray<GalleryImageInfo>,\n+ ) => {\n+ const validationResults = await Promise.all(\n+ inputImageInfos.map(validateMedia),\n+ );\n+ const imageInfos = validationResults.filter(Boolean).map(imageInfo => ({\n+ ...imageInfo,\n+ localID: `localUpload${nextLocalUploadID++}`,\n+ }));\n+ const localMessageID = `local${this.props.nextLocalID}`;\n+\n+ const pendingUploads = {};\n+ for (let { localID } of imageInfos) {\n+ pendingUploads[localID] = {\n+ failed: null,\n+ progressPercent: 0,\n+ };\n+ }\n+\n+ this.setState(\n+ prevState => {\n+ return {\n+ pendingUploads: {\n+ ...prevState.pendingUploads,\n+ [localMessageID]: pendingUploads,\n+ },\n+ };\n+ },\n+ () => {\n+ const creatorID = this.props.viewerID;\n+ invariant(creatorID, \"need viewer ID in order to send a message\");\n+ const messageInfo = ({\n+ type: messageTypes.MULTIMEDIA,\n+ localID: localMessageID,\n+ threadID,\n+ creatorID,\n+ time: Date.now(),\n+ media: imageInfos.map(\n+ ({ localID, uri, dimensions }) => ({\n+ id: localID,\n+ uri,\n+ type: \"photo\",\n+ dimensions,\n+ }),\n+ ),\n+ }: RawMultimediaMessageInfo);\n+ this.props.dispatchActionPayload(\n+ createLocalMultimediaMessageActionType,\n+ messageInfo,\n+ );\n+ },\n+ );\n+\n+ await Promise.all(\n+ imageInfos.map(imageInfo => this.uploadFile(localMessageID, imageInfo)),\n+ );\n+ }\n+\n+ async uploadFile(localMessageID: string, imageInfo: ImageInfo) {\n+ const { localID, uri, name, mime } = imageInfo;\n+ let result;\n+ try {\n+ result = await this.props.uploadMultimedia(\n+ { uri, name, type: mime },\n+ (percent: number) => this.setProgress(\n+ localMessageID,\n+ localID,\n+ percent,\n+ ),\n+ );\n+ } catch (e) {\n+ this.handleUploadFailure(localMessageID, localID, e);\n+ return;\n+ }\n+ }\n+\n+ setProgress(\n+ localMessageID: string,\n+ localUploadID: string,\n+ progressPercent: number,\n+ ) {\n+ this.setState(prevState => {\n+ const pendingUploads = prevState.pendingUploads[localMessageID];\n+ if (!pendingUploads) {\n+ return {};\n+ }\n+ const pendingUpload = pendingUploads[localUploadID];\n+ if (!pendingUpload) {\n+ return {};\n+ }\n+ const newPendingUploads = {\n+ ...pendingUploads,\n+ [localUploadID]: {\n+ ...pendingUpload,\n+ progressPercent,\n+ },\n+ };\n+ return {\n+ pendingUploads: {\n+ ...prevState.pendingUploads,\n+ [localMessageID]: newPendingUploads,\n+ },\n+ };\n+ });\n+ }\n+\n+ handleUploadFailure(\n+ localMessageID: string,\n+ localUploadID: string,\n+ e: any,\n+ ) {\n+ this.setState(prevState => {\n+ const uploads = prevState.pendingUploads[localMessageID];\n+ const upload = uploads[localUploadID];\n+ if (!upload) {\n+ // The upload has been completed before it failed\n+ return {};\n+ }\n+ const failed = (e instanceof Error && e.message)\n+ ? e.message\n+ : \"failed\";\n+ return {\n+ pendingUploads: {\n+ ...prevState.pendingUploads,\n+ [localMessageID]: {\n+ ...uploads,\n+ [localUploadID]: {\n+ ...upload,\n+ failed,\n+ progressPercent: 0,\n+ },\n+ },\n+ },\n+ };\n+ });\n+ }\n+\n+ messageHasUploadFailure = (localMessageID: string) => {\n+ const pendingUploads = this.state.pendingUploads[localMessageID];\n+ if (!pendingUploads) {\n+ return false;\n+ }\n+ for (let localUploadID in pendingUploads) {\n+ const { failed } = pendingUploads[localUploadID];\n+ if (failed) {\n+ return true;\n+ }\n+ }\n+ return false;\n+ }\n+\n+ retryMultimediaMessage = async (localMessageID: string) => {\n+ }\nrender() {\nreturn (\n+ <ChatInputStateContext.Provider value={this.chatInputState}>\n<KeyboardAvoidingView style={styles.keyboardAvoidingView}>\n<ChatNavigator {...this.props} />\n<MessageStorePruner />\n</KeyboardAvoidingView>\n+ </ChatInputStateContext.Provider>\n);\n}\n@@ -29,6 +281,15 @@ const styles = StyleSheet.create({\n},\n});\n-hoistNonReactStatics(Chat, ChatNavigator);\n+const ReduxWrappedChat = connect(\n+ (state: AppState) => ({\n+ viewerID: state.currentUserInfo && state.currentUserInfo.id,\n+ nextLocalID: state.nextLocalID,\n+ messageStoreMessages: state.messageStore.messages,\n+ }),\n+ { uploadMultimedia, sendMultimediaMessage },\n+)(Chat);\n+\n+hoistNonReactStatics(ReduxWrappedChat, ChatNavigator);\n-export default Chat;\n+export default ReduxWrappedChat;\n" }, { "change_type": "ADD", "old_path": null, "new_path": "native/utils/media-utils.js", "diff": "+// @flow\n+\n+import type { Dimensions, MediaType } from 'lib/types/media-types';\n+import type { GalleryImageInfo } from '../media/image-gallery-image.react';\n+\n+import str2ab from 'string-to-arraybuffer';\n+import { Platform } from 'react-native';\n+\n+import { fileInfoFromData } from 'lib/utils/media-utils';\n+\n+function blobToDataURI(blob: Blob): Promise<string> {\n+ const fileReader = new FileReader();\n+ return new Promise((resolve, reject) => {\n+ fileReader.onerror = error => {\n+ fileReader.abort();\n+ reject(error);\n+ };\n+ fileReader.onload = event => {\n+ resolve(event.target.result);\n+ };\n+ fileReader.readAsDataURL(blob);\n+ });\n+}\n+\n+export type NativeImageInfo = {|\n+ uri: string,\n+ dimensions: Dimensions,\n+ name: string,\n+ mime: string,\n+ mediaType: MediaType,\n+|};\n+async function validateMedia(\n+ imageInfo: GalleryImageInfo,\n+): Promise<?NativeImageInfo> {\n+ const { uri: inputURI, ...dimensions } = imageInfo;\n+ const response = await fetch(inputURI);\n+ const blob = await response.blob();\n+\n+ const dataURI = await blobToDataURI(blob);\n+ const arrayBuffer = str2ab(dataURI);\n+ const uint8Array = new Uint8Array(arrayBuffer);\n+\n+ const blobName = blob.data.name;\n+ const fileInfo = fileInfoFromData(new Uint8Array(arrayBuffer), blobName);\n+ if (!fileInfo) {\n+ return null;\n+ }\n+\n+ const { name, mime, mediaType } = fileInfo;\n+ const uri = Platform.OS === \"ios\" ? dataURI : inputURI;\n+ return { uri, dimensions, name, mime, mediaType };\n+}\n+\n+export {\n+ validateMedia,\n+};\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Actually upload images
129,187
24.05.2019 15:25:14
14,400
bfba4fe8abeb1f33aad4ae07302b085ba01c5c0c
updateMultimediaMessageMediaActionType Replaces `assignMediaServerIDToMessageActionType` and `assignMediaServerURIToMessageActionType`
[ { "change_type": "MODIFY", "old_path": "lib/actions/upload-actions.js", "new_path": "lib/actions/upload-actions.js", "diff": "@@ -18,10 +18,8 @@ async function uploadMultimedia(\nreturn { id: uploadResult.id, uri: uploadResult.uri };\n}\n-const assignMediaServerIDToMessageActionType =\n- \"ASSIGN_MEDIA_SERVER_ID_TO_MESSAGE\";\n-const assignMediaServerURIToMessageActionType =\n- \"ASSIGN_MEDIA_SERVER_URI_TO_MESSAGE\";\n+const updateMultimediaMessageMediaActionType =\n+ \"UPDATE_MULTIMEDIA_MESSAGE_MEDIA\";\nasync function deleteUpload(\nfetchJSON: FetchJSON,\n@@ -32,7 +30,6 @@ async function deleteUpload(\nexport {\nuploadMultimedia,\n- assignMediaServerIDToMessageActionType,\n- assignMediaServerURIToMessageActionType,\n+ updateMultimediaMessageMediaActionType,\ndeleteUpload,\n};\n" }, { "change_type": "MODIFY", "old_path": "lib/reducers/message-reducer.js", "new_path": "lib/reducers/message-reducer.js", "diff": "@@ -77,8 +77,7 @@ import {\n} from '../actions/message-actions';\nimport threadWatcher from '../shared/thread-watcher';\nimport {\n- assignMediaServerIDToMessageActionType,\n- assignMediaServerURIToMessageActionType,\n+ updateMultimediaMessageMediaActionType,\n} from '../actions/upload-actions';\nimport { unshimMessageInfos } from '../shared/unshim-utils';\n@@ -755,8 +754,8 @@ function reduceMessageStore(\nlocal: _omit(messageIDsToPrune)(messageStore.local),\ncurrentAsOf: messageStore.currentAsOf,\n};\n- } else if (action.type === assignMediaServerIDToMessageActionType) {\n- const { messageID, mediaLocalID, mediaServerID } = action.payload;\n+ } else if (action.type === updateMultimediaMessageMediaActionType) {\n+ const { messageID, currentMediaID, mediaUpdate } = action.payload;\nconst message = messageStore.messages[messageID];\ninvariant(message, `message with ID ${messageID} could not be found`);\ninvariant(\n@@ -766,54 +765,19 @@ function reduceMessageStore(\nlet replaced = false;\nconst media = message.media.map(\nsingleMedia => {\n- if (singleMedia.id !== mediaLocalID) {\n+ if (singleMedia.id !== currentMediaID) {\nreturn singleMedia;\n}\nreplaced = true;\nreturn {\n...singleMedia,\n- id: mediaServerID,\n+ ...mediaUpdate,\n};\n},\n);\ninvariant(\nreplaced,\n- `message ${messageID} did not contain media with ID ${mediaLocalID}`,\n- );\n- return {\n- ...messageStore,\n- messages: {\n- ...messageStore.messages,\n- [messageID]: {\n- ...message,\n- media,\n- },\n- },\n- };\n- } else if (action.type === assignMediaServerURIToMessageActionType) {\n- const { messageID, mediaID, serverURI } = action.payload;\n- const message = messageStore.messages[messageID];\n- invariant(message, `message with ID ${messageID} could not be found`);\n- invariant(\n- message.type === messageTypes.MULTIMEDIA,\n- `message with ID ${messageID} is not messageTypes.MULTIMEDIA`,\n- );\n- let replaced = false;\n- const media = message.media.map(\n- singleMedia => {\n- if (singleMedia.id !== mediaID) {\n- return singleMedia;\n- }\n- replaced = true;\n- return {\n- ...singleMedia,\n- uri: serverURI,\n- };\n- },\n- );\n- invariant(\n- replaced,\n- `message ${messageID} did not contain media with ID ${mediaID}`,\n+ `message ${messageID} did not contain media with ID ${currentMediaID}`,\n);\nreturn {\n...messageStore,\n" }, { "change_type": "MODIFY", "old_path": "lib/types/media-types.js", "new_path": "lib/types/media-types.js", "diff": "@@ -35,16 +35,13 @@ export type UploadMultimediaResult = {|\nuri: string,\n|};\n-export type AssignMediaServerIDToMessagePayload = {|\n+export type UpdateMultimediaMessageMediaPayload = {|\nmessageID: string,\n- mediaLocalID: string,\n- mediaServerID: string,\n-|};\n-\n-export type AssignMediaServerURIToMessagePayload = {|\n- messageID: string,\n- mediaID: string,\n- serverURI: string,\n+ currentMediaID: string,\n+ mediaUpdate: $Shape<{|\n+ id: string,\n+ uri: string,\n+ |}>,\n|};\nexport type UploadDeletionRequest = {|\n" }, { "change_type": "MODIFY", "old_path": "lib/types/redux-types.js", "new_path": "lib/types/redux-types.js", "diff": "@@ -68,10 +68,7 @@ import type {\nActivityUpdateSuccessPayload,\nQueueActivityUpdatesPayload,\n} from './activity-types';\n-import type {\n- AssignMediaServerIDToMessagePayload,\n- AssignMediaServerURIToMessagePayload,\n-} from './media-types';\n+import type { UpdateMultimediaMessageMediaPayload } from './media-types';\nexport type BaseAppState<NavInfo: BaseNavInfo> = {\nnavInfo: NavInfo,\n@@ -638,11 +635,8 @@ export type BaseAction =\npayload?: void,\nloadingInfo: LoadingInfo,\n|} | {|\n- type: \"ASSIGN_MEDIA_SERVER_ID_TO_MESSAGE\",\n- payload: AssignMediaServerIDToMessagePayload,\n- |} | {|\n- type: \"ASSIGN_MEDIA_SERVER_URI_TO_MESSAGE\",\n- payload: AssignMediaServerURIToMessagePayload,\n+ type: \"UPDATE_MULTIMEDIA_MESSAGE_MEDIA\",\n+ payload: UpdateMultimediaMessageMediaPayload,\n|} | {|\ntype: \"CREATE_LOCAL_MULTIMEDIA_MESSAGE\",\npayload: RawMultimediaMessageInfo,\n" }, { "change_type": "MODIFY", "old_path": "web/chat/chat-input-state-container.react.js", "new_path": "web/chat/chat-input-state-container.react.js", "diff": "@@ -29,8 +29,7 @@ import invariant from 'invariant';\nimport { connect } from 'lib/utils/redux-utils';\nimport {\nuploadMultimedia,\n- assignMediaServerIDToMessageActionType,\n- assignMediaServerURIToMessageActionType,\n+ updateMultimediaMessageMediaActionType,\ndeleteUpload,\n} from 'lib/actions/upload-actions';\nimport {\n@@ -408,11 +407,13 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\n);\nif (uploadAfterSuccess.messageID) {\nthis.props.dispatchActionPayload(\n- assignMediaServerIDToMessageActionType,\n+ updateMultimediaMessageMediaActionType,\n{\nmessageID: uploadAfterSuccess.messageID,\n- mediaLocalID: upload.localID,\n- mediaServerID: result.id,\n+ currentMediaID: upload.localID,\n+ mediaUpdate: {\n+ id: result.id,\n+ },\n},\n);\n}\n@@ -451,13 +452,15 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\n);\nif (uploadAfterPreload.messageID) {\nthis.props.dispatchActionPayload(\n- assignMediaServerURIToMessageActionType,\n+ updateMultimediaMessageMediaActionType,\n{\nmessageID: uploadAfterPreload.messageID,\n- mediaID: uploadAfterPreload.serverID\n+ currentMediaID: uploadAfterPreload.serverID\n? uploadAfterPreload.serverID\n: uploadAfterPreload.localID,\n- serverURI: result.uri,\n+ mediaUpdate: {\n+ uri: result.uri,\n+ },\n},\n);\n}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
updateMultimediaMessageMediaActionType Replaces `assignMediaServerIDToMessageActionType` and `assignMediaServerURIToMessageActionType`
129,187
24.05.2019 15:34:18
14,400
c20db7377c8aeacb6aa89bd2b29b4b0b6cb1d1ea
[native] Use selector for ChatInputState
[ { "change_type": "MODIFY", "old_path": "native/chat/chat.react.js", "new_path": "native/chat/chat.react.js", "diff": "@@ -24,6 +24,7 @@ import PropTypes from 'prop-types';\nimport invariant from 'invariant';\nimport { StyleSheet } from 'react-native';\nimport hoistNonReactStatics from 'hoist-non-react-statics';\n+import { createSelector } from 'reselect';\nimport { connect } from 'lib/utils/redux-utils';\nimport {\n@@ -81,30 +82,19 @@ class Chat extends React.PureComponent<Props, State> {\nuploadMultimedia: PropTypes.func.isRequired,\nsendMultimediaMessage: PropTypes.func.isRequired,\n};\n- chatInputState: ChatInputState;\n-\n- constructor(props: Props) {\n- super(props);\n- this.state = {\n+ state = {\npendingUploads: {},\n};\n- this.updateChatInputState();\n- }\n- updateChatInputState() {\n- this.chatInputState = {\n- pendingUploads: this.state.pendingUploads,\n+ chatInputStateSelector = createSelector(\n+ (state: State) => state.pendingUploads,\n+ (pendingUploads: PendingMultimediaUploads) => ({\n+ pendingUploads,\nsendMultimediaMessage: this.sendMultimediaMessage,\nmessageHasUploadFailure: this.messageHasUploadFailure,\nretryMultimediaMessage: this.retryMultimediaMessage,\n- };\n- }\n-\n- componentDidUpdate(prevProps: Props, prevState: State) {\n- if (this.state.pendingUploads !== prevState.pendingUploads) {\n- this.updateChatInputState();\n- }\n- }\n+ }),\n+ );\nsendMultimediaMessage = async (\nthreadID: string,\n@@ -263,8 +253,9 @@ class Chat extends React.PureComponent<Props, State> {\n}\nrender() {\n+ const chatInputState = this.chatInputStateSelector(this.state);\nreturn (\n- <ChatInputStateContext.Provider value={this.chatInputState}>\n+ <ChatInputStateContext.Provider value={chatInputState}>\n<KeyboardAvoidingView style={styles.keyboardAvoidingView}>\n<ChatNavigator {...this.props} />\n<MessageStorePruner />\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Use selector for ChatInputState
129,187
29.05.2019 17:21:58
14,400
0137de0d209e2e4df9730d03396266196eceb696
[web] Only retry failed uploads for requested message ID
[ { "change_type": "MODIFY", "old_path": "web/chat/chat-input-state-container.react.js", "new_path": "web/chat/chat-input-state-container.react.js", "diff": "@@ -207,7 +207,7 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\nconst rawMessageInfo = this.props.messageStoreMessages[localMessageID];\ninvariant(\nrawMessageInfo,\n- `rawMessageInfo ${localMessageID} should exist in sendMultimediaMessage`,\n+ `rawMessageInfo ${localMessageID} should exist`,\n);\ninvariant(\nrawMessageInfo.type === messageTypes.MULTIMEDIA,\n@@ -703,13 +703,14 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\nconst uploadIDsToRetry = new Set();\nconst uploadsToRetry = [];\nfor (let pendingUpload of pendingUploads) {\n- if (pendingUpload.serverID) {\n+ const { serverID, messageID, localID, abort } = pendingUpload;\n+ if (serverID || messageID !== localMessageID) {\ncontinue;\n}\n- if (pendingUpload.abort) {\n- pendingUpload.abort();\n+ if (abort) {\n+ abort();\n}\n- uploadIDsToRetry.add(pendingUpload.localID);\n+ uploadIDsToRetry.add(localID);\nuploadsToRetry.push(pendingUpload);\n}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[web] Only retry failed uploads for requested message ID
129,187
29.05.2019 18:34:42
14,400
5dacd2daedc92601cf83cd3f9f8721942e6bd881
[native] Avoid storing dataURIs in Redux
[ { "change_type": "MODIFY", "old_path": "native/chat/chat-input-state.js", "new_path": "native/chat/chat-input-state.js", "diff": "@@ -6,6 +6,10 @@ import type { GalleryImageInfo } from '../media/image-gallery-image.react';\nimport * as React from 'react';\nexport type PendingMultimediaUpload = {|\n+ // On some platforms (iOS) the URI we get isn't something that can be passed\n+ // to an Image or be uploaded by fetch. We therefore convert it to a data URI,\n+ // but avoid storing that string in Redux as it's quite long.\n+ dataURI: ?string,\nfailed: ?string,\nprogressPercent: number,\n|};\n" }, { "change_type": "MODIFY", "old_path": "native/chat/chat.react.js", "new_path": "native/chat/chat.react.js", "diff": "@@ -29,6 +29,7 @@ import { createSelector } from 'reselect';\nimport { connect } from 'lib/utils/redux-utils';\nimport {\nuploadMultimedia,\n+ updateMultimediaMessageMediaActionType,\n} from 'lib/actions/upload-actions';\nimport {\ncreateLocalMultimediaMessageActionType,\n@@ -110,8 +111,9 @@ class Chat extends React.PureComponent<Props, State> {\nconst localMessageID = `local${this.props.nextLocalID}`;\nconst pendingUploads = {};\n- for (let { localID } of imageInfos) {\n+ for (let { localID, dataURI } of imageInfos) {\npendingUploads[localID] = {\n+ dataURI,\nfailed: null,\nprogressPercent: 0,\n};\n@@ -157,7 +159,8 @@ class Chat extends React.PureComponent<Props, State> {\n}\nasync uploadFile(localMessageID: string, imageInfo: ImageInfo) {\n- const { localID, uri, name, mime } = imageInfo;\n+ const { localID, uri: nativeURI, dataURI, name, mime } = imageInfo;\n+ const uri = dataURI ? dataURI : nativeURI;\nlet result;\ntry {\nresult = await this.props.uploadMultimedia(\n@@ -172,6 +175,17 @@ class Chat extends React.PureComponent<Props, State> {\nthis.handleUploadFailure(localMessageID, localID, e);\nreturn;\n}\n+ this.props.dispatchActionPayload(\n+ updateMultimediaMessageMediaActionType,\n+ {\n+ messageID: localMessageID,\n+ currentMediaID: localID,\n+ mediaUpdate: {\n+ id: result.id,\n+ uri: result.uri,\n+ },\n+ },\n+ );\n}\nsetProgress(\n" }, { "change_type": "MODIFY", "old_path": "native/utils/media-utils.js", "new_path": "native/utils/media-utils.js", "diff": "@@ -24,6 +24,7 @@ function blobToDataURI(blob: Blob): Promise<string> {\nexport type NativeImageInfo = {|\nuri: string,\n+ dataURI: ?string,\ndimensions: Dimensions,\nname: string,\nmime: string,\n@@ -32,8 +33,8 @@ export type NativeImageInfo = {|\nasync function validateMedia(\nimageInfo: GalleryImageInfo,\n): Promise<?NativeImageInfo> {\n- const { uri: inputURI, ...dimensions } = imageInfo;\n- const response = await fetch(inputURI);\n+ const { uri, ...dimensions } = imageInfo;\n+ const response = await fetch(uri);\nconst blob = await response.blob();\nconst dataURI = await blobToDataURI(blob);\n@@ -47,8 +48,18 @@ async function validateMedia(\n}\nconst { name, mime, mediaType } = fileInfo;\n- const uri = Platform.OS === \"ios\" ? dataURI : inputURI;\n- return { uri, dimensions, name, mime, mediaType };\n+ return {\n+ uri,\n+ // On iOS, the URI we receive from the native side doesn't render with Image\n+ // and can't upload with fetch. Thus we need to use the dataURI for those\n+ // things, but we have to be careful to avoid storing it in Redux, as it's\n+ // quite long.\n+ dataURI: Platform.OS === \"ios\" ? dataURI : null,\n+ dimensions,\n+ name,\n+ mime,\n+ mediaType,\n+ };\n}\nexport {\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Avoid storing dataURIs in Redux
129,187
29.05.2019 18:36:48
14,400
f4b75760f4011c8c90eb60a59a877a26d38e2afe
[native] Keep pendingUploads state updated and actually send MultimediaMessage
[ { "change_type": "MODIFY", "old_path": "native/chat/chat.react.js", "new_path": "native/chat/chat.react.js", "diff": "@@ -48,6 +48,7 @@ type ImageInfo = {|\n...NativeImageInfo,\nlocalID: string,\n|};\n+type CompletedUploads = { [localMessageID: string]: ?Set<string> };\ntype Props = {|\n// Redux state\n@@ -87,6 +88,155 @@ class Chat extends React.PureComponent<Props, State> {\npendingUploads: {},\n};\n+ static getCompletedUploads(props: Props, state: State): CompletedUploads {\n+ const completedUploads = {};\n+ for (let localMessageID in state.pendingUploads) {\n+ const messagePendingUploads = state.pendingUploads[localMessageID];\n+ const rawMessageInfo = props.messageStoreMessages[localMessageID];\n+ if (!rawMessageInfo) {\n+ continue;\n+ }\n+ invariant(\n+ rawMessageInfo.type === messageTypes.MULTIMEDIA,\n+ `${localMessageID} should be messageTypes.MULTIMEDIA`,\n+ );\n+\n+ const completed = [];\n+ let allUploadsComplete = true;\n+ for (let localUploadID in messagePendingUploads) {\n+ const media = rawMessageInfo.media.find(\n+ media => media.id === localUploadID,\n+ );\n+ if (media) {\n+ allUploadsComplete = false;\n+ } else {\n+ completed.push(localUploadID);\n+ }\n+ }\n+\n+ if (allUploadsComplete) {\n+ completedUploads[localMessageID] = null;\n+ } else if (completed.length > 0) {\n+ completedUploads[localMessageID] = new Set(completed);\n+ }\n+ }\n+ return completedUploads;\n+ }\n+\n+ componentDidUpdate(prevProps: Props, prevState: State) {\n+ const currentlyComplete = Chat.getCompletedUploads(this.props, this.state);\n+ const previouslyComplete = Chat.getCompletedUploads(prevProps, prevState);\n+\n+ const newPendingUploads = {};\n+ let pendingUploadsChanged = false;\n+ const readyMessageIDs = [];\n+ for (let localMessageID in this.state.pendingUploads) {\n+ const messagePendingUploads = this.state.pendingUploads[localMessageID];\n+ const prevRawMessageInfo = prevProps.messageStoreMessages[localMessageID];\n+ const rawMessageInfo = this.props.messageStoreMessages[localMessageID];\n+ const completedUploadIDs = currentlyComplete[localMessageID];\n+ const previouslyCompletedUploadIDs = previouslyComplete[localMessageID];\n+\n+ if (!rawMessageInfo && prevRawMessageInfo) {\n+ // A previously failed message got pruned out\n+ pendingUploadsChanged = true;\n+ continue;\n+ } else if (completedUploadIDs === null) {\n+ // All of this message's uploads have been completed\n+ if (previouslyCompletedUploadIDs !== null) {\n+ readyMessageIDs.push(localMessageID);\n+ pendingUploadsChanged = true;\n+ }\n+ continue;\n+ } else if (!completedUploadIDs) {\n+ // Nothing has been completed\n+ newPendingUploads[localMessageID] = messagePendingUploads;\n+ continue;\n+ }\n+\n+ const newUploads = {};\n+ let uploadsChanged = false;\n+ for (let localUploadID in messagePendingUploads) {\n+ if (!completedUploadIDs.has(localUploadID)) {\n+ newUploads[localUploadID] = messagePendingUploads[localUploadID];\n+ continue;\n+ }\n+ if (\n+ !previouslyCompletedUploadIDs ||\n+ !previouslyCompletedUploadIDs.has(localUploadID)\n+ ) {\n+ uploadsChanged = true;\n+ }\n+ }\n+\n+ const numOldUploads = Object.keys(messagePendingUploads).length;\n+ const numNewUploads = Object.keys(newUploads).length;\n+ const allUploadsComplete = numNewUploads === 0;\n+ const someUploadsComplete = numNewUploads > numOldUploads;\n+ if (!allUploadsComplete && !someUploadsComplete) {\n+ newPendingUploads[localMessageID] = messagePendingUploads;\n+ } else if (!allUploadsComplete) {\n+ newPendingUploads[localMessageID] = newUploads;\n+ }\n+\n+ if (uploadsChanged) {\n+ pendingUploadsChanged = true;\n+ if (allUploadsComplete) {\n+ readyMessageIDs.push(localMessageID);\n+ }\n+ }\n+ }\n+ if (pendingUploadsChanged) {\n+ this.setState({ pendingUploads: newPendingUploads });\n+ }\n+\n+ for (let localMessageID of readyMessageIDs) {\n+ const rawMessageInfo = this.props.messageStoreMessages[localMessageID];\n+ if (!rawMessageInfo) {\n+ continue;\n+ }\n+ invariant(\n+ rawMessageInfo.type === messageTypes.MULTIMEDIA,\n+ `${localMessageID} should be messageTypes.MULTIMEDIA`,\n+ );\n+ this.dispatchMultimediaMessageAction(rawMessageInfo);\n+ }\n+ }\n+\n+ dispatchMultimediaMessageAction(messageInfo: RawMultimediaMessageInfo) {\n+ this.props.dispatchActionPromise(\n+ sendMultimediaMessageActionTypes,\n+ this.sendMultimediaMessageAction(messageInfo),\n+ undefined,\n+ messageInfo,\n+ );\n+ }\n+\n+ async sendMultimediaMessageAction(messageInfo: RawMultimediaMessageInfo) {\n+ const { localID, threadID, media } = messageInfo;\n+ invariant(\n+ localID !== null && localID !== undefined,\n+ \"localID should be set\",\n+ );\n+ try {\n+ const result = await this.props.sendMultimediaMessage(\n+ threadID,\n+ localID,\n+ media.map(({ id }) => id),\n+ );\n+ return {\n+ localID,\n+ serverID: result.id,\n+ threadID,\n+ time: result.time,\n+ };\n+ } catch (e) {\n+ e.localID = localID;\n+ e.threadID = threadID;\n+ throw e;\n+ }\n+ }\n+\nchatInputStateSelector = createSelector(\n(state: State) => state.pendingUploads,\n(pendingUploads: PendingMultimediaUploads) => ({\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Keep pendingUploads state updated and actually send MultimediaMessage
129,187
29.05.2019 19:41:47
14,400
9c225b87e31b2e053bf61476565ec6b968570066
[native] Separate Chat state into ChatInputStateContainer We need to move the chat input state up the component hierarchy so that `MultimediaModal` has access to its context.
[ { "change_type": "ADD", "old_path": null, "new_path": "native/chat/chat-input-state-container.react.js", "diff": "+// @flow\n+\n+import type { PendingMultimediaUploads } from './chat-input-state';\n+import type { GalleryImageInfo } from '../media/image-gallery-image.react';\n+import type { AppState } from '../redux/redux-setup';\n+import type {\n+ DispatchActionPayload,\n+ DispatchActionPromise,\n+} from 'lib/utils/action-utils';\n+import type { UploadMultimediaResult } from 'lib/types/media-types';\n+import {\n+ messageTypes,\n+ type RawMessageInfo,\n+ type RawMultimediaMessageInfo,\n+ type SendMessageResult,\n+} from 'lib/types/message-types';\n+import type { NativeImageInfo } from '../utils/media-utils';\n+\n+import * as React from 'react';\n+import PropTypes from 'prop-types';\n+import invariant from 'invariant';\n+import { createSelector } from 'reselect';\n+\n+import { connect } from 'lib/utils/redux-utils';\n+import {\n+ uploadMultimedia,\n+ updateMultimediaMessageMediaActionType,\n+} from 'lib/actions/upload-actions';\n+import {\n+ createLocalMultimediaMessageActionType,\n+ sendMultimediaMessageActionTypes,\n+ sendMultimediaMessage,\n+} from 'lib/actions/message-actions';\n+\n+import { ChatInputStateContext } from './chat-input-state';\n+import { validateMedia } from '../utils/media-utils';\n+\n+let nextLocalUploadID = 0;\n+type ImageInfo = {|\n+ ...NativeImageInfo,\n+ localID: string,\n+|};\n+type CompletedUploads = { [localMessageID: string]: ?Set<string> };\n+\n+type Props = {|\n+ children: React.Node,\n+ // Redux state\n+ viewerID: ?string,\n+ nextLocalID: number,\n+ messageStoreMessages: { [id: string]: RawMessageInfo },\n+ // Redux dispatch functions\n+ dispatchActionPayload: DispatchActionPayload,\n+ dispatchActionPromise: DispatchActionPromise,\n+ // async functions that hit server APIs\n+ uploadMultimedia: (\n+ multimedia: Object,\n+ onProgress: (percent: number) => void,\n+ abortHandler?: (abort: () => void) => void,\n+ ) => Promise<UploadMultimediaResult>,\n+ sendMultimediaMessage: (\n+ threadID: string,\n+ localID: string,\n+ mediaIDs: $ReadOnlyArray<string>,\n+ ) => Promise<SendMessageResult>,\n+|};\n+type State = {|\n+ pendingUploads: PendingMultimediaUploads,\n+|};\n+class ChatInputStateContainer extends React.PureComponent<Props, State> {\n+\n+ static propTypes = {\n+ children: PropTypes.node.isRequired,\n+ viewerID: PropTypes.string,\n+ nextLocalID: PropTypes.number.isRequired,\n+ messageStoreMessages: PropTypes.object.isRequired,\n+ dispatchActionPayload: PropTypes.func.isRequired,\n+ dispatchActionPromise: PropTypes.func.isRequired,\n+ uploadMultimedia: PropTypes.func.isRequired,\n+ sendMultimediaMessage: PropTypes.func.isRequired,\n+ };\n+ state = {\n+ pendingUploads: {},\n+ };\n+\n+ static getCompletedUploads(props: Props, state: State): CompletedUploads {\n+ const completedUploads = {};\n+ for (let localMessageID in state.pendingUploads) {\n+ const messagePendingUploads = state.pendingUploads[localMessageID];\n+ const rawMessageInfo = props.messageStoreMessages[localMessageID];\n+ if (!rawMessageInfo) {\n+ continue;\n+ }\n+ invariant(\n+ rawMessageInfo.type === messageTypes.MULTIMEDIA,\n+ `${localMessageID} should be messageTypes.MULTIMEDIA`,\n+ );\n+\n+ const completed = [];\n+ let allUploadsComplete = true;\n+ for (let localUploadID in messagePendingUploads) {\n+ const media = rawMessageInfo.media.find(\n+ media => media.id === localUploadID,\n+ );\n+ if (media) {\n+ allUploadsComplete = false;\n+ } else {\n+ completed.push(localUploadID);\n+ }\n+ }\n+\n+ if (allUploadsComplete) {\n+ completedUploads[localMessageID] = null;\n+ } else if (completed.length > 0) {\n+ completedUploads[localMessageID] = new Set(completed);\n+ }\n+ }\n+ return completedUploads;\n+ }\n+\n+ componentDidUpdate(prevProps: Props, prevState: State) {\n+ const currentlyComplete = ChatInputStateContainer.getCompletedUploads(\n+ this.props,\n+ this.state,\n+ );\n+ const previouslyComplete = ChatInputStateContainer.getCompletedUploads(\n+ prevProps,\n+ prevState,\n+ );\n+\n+ const newPendingUploads = {};\n+ let pendingUploadsChanged = false;\n+ const readyMessageIDs = [];\n+ for (let localMessageID in this.state.pendingUploads) {\n+ const messagePendingUploads = this.state.pendingUploads[localMessageID];\n+ const prevRawMessageInfo = prevProps.messageStoreMessages[localMessageID];\n+ const rawMessageInfo = this.props.messageStoreMessages[localMessageID];\n+ const completedUploadIDs = currentlyComplete[localMessageID];\n+ const previouslyCompletedUploadIDs = previouslyComplete[localMessageID];\n+\n+ if (!rawMessageInfo && prevRawMessageInfo) {\n+ // A previously failed message got pruned out\n+ pendingUploadsChanged = true;\n+ continue;\n+ } else if (completedUploadIDs === null) {\n+ // All of this message's uploads have been completed\n+ if (previouslyCompletedUploadIDs !== null) {\n+ readyMessageIDs.push(localMessageID);\n+ pendingUploadsChanged = true;\n+ }\n+ continue;\n+ } else if (!completedUploadIDs) {\n+ // Nothing has been completed\n+ newPendingUploads[localMessageID] = messagePendingUploads;\n+ continue;\n+ }\n+\n+ const newUploads = {};\n+ let uploadsChanged = false;\n+ for (let localUploadID in messagePendingUploads) {\n+ if (!completedUploadIDs.has(localUploadID)) {\n+ newUploads[localUploadID] = messagePendingUploads[localUploadID];\n+ continue;\n+ }\n+ if (\n+ !previouslyCompletedUploadIDs ||\n+ !previouslyCompletedUploadIDs.has(localUploadID)\n+ ) {\n+ uploadsChanged = true;\n+ }\n+ }\n+\n+ const numOldUploads = Object.keys(messagePendingUploads).length;\n+ const numNewUploads = Object.keys(newUploads).length;\n+ const allUploadsComplete = numNewUploads === 0;\n+ const someUploadsComplete = numNewUploads > numOldUploads;\n+ if (!allUploadsComplete && !someUploadsComplete) {\n+ newPendingUploads[localMessageID] = messagePendingUploads;\n+ } else if (!allUploadsComplete) {\n+ newPendingUploads[localMessageID] = newUploads;\n+ }\n+\n+ if (uploadsChanged) {\n+ pendingUploadsChanged = true;\n+ if (allUploadsComplete) {\n+ readyMessageIDs.push(localMessageID);\n+ }\n+ }\n+ }\n+ if (pendingUploadsChanged) {\n+ this.setState({ pendingUploads: newPendingUploads });\n+ }\n+\n+ for (let localMessageID of readyMessageIDs) {\n+ const rawMessageInfo = this.props.messageStoreMessages[localMessageID];\n+ if (!rawMessageInfo) {\n+ continue;\n+ }\n+ invariant(\n+ rawMessageInfo.type === messageTypes.MULTIMEDIA,\n+ `${localMessageID} should be messageTypes.MULTIMEDIA`,\n+ );\n+ this.dispatchMultimediaMessageAction(rawMessageInfo);\n+ }\n+ }\n+\n+ dispatchMultimediaMessageAction(messageInfo: RawMultimediaMessageInfo) {\n+ this.props.dispatchActionPromise(\n+ sendMultimediaMessageActionTypes,\n+ this.sendMultimediaMessageAction(messageInfo),\n+ undefined,\n+ messageInfo,\n+ );\n+ }\n+\n+ async sendMultimediaMessageAction(messageInfo: RawMultimediaMessageInfo) {\n+ const { localID, threadID, media } = messageInfo;\n+ invariant(\n+ localID !== null && localID !== undefined,\n+ \"localID should be set\",\n+ );\n+ try {\n+ const result = await this.props.sendMultimediaMessage(\n+ threadID,\n+ localID,\n+ media.map(({ id }) => id),\n+ );\n+ return {\n+ localID,\n+ serverID: result.id,\n+ threadID,\n+ time: result.time,\n+ };\n+ } catch (e) {\n+ e.localID = localID;\n+ e.threadID = threadID;\n+ throw e;\n+ }\n+ }\n+\n+ chatInputStateSelector = createSelector(\n+ (state: State) => state.pendingUploads,\n+ (pendingUploads: PendingMultimediaUploads) => ({\n+ pendingUploads,\n+ sendMultimediaMessage: this.sendMultimediaMessage,\n+ messageHasUploadFailure: this.messageHasUploadFailure,\n+ retryMultimediaMessage: this.retryMultimediaMessage,\n+ }),\n+ );\n+\n+ sendMultimediaMessage = async (\n+ threadID: string,\n+ inputImageInfos: $ReadOnlyArray<GalleryImageInfo>,\n+ ) => {\n+ const validationResults = await Promise.all(\n+ inputImageInfos.map(validateMedia),\n+ );\n+ const imageInfos = validationResults.filter(Boolean).map(imageInfo => ({\n+ ...imageInfo,\n+ localID: `localUpload${nextLocalUploadID++}`,\n+ }));\n+ const localMessageID = `local${this.props.nextLocalID}`;\n+\n+ const pendingUploads = {};\n+ for (let { localID, dataURI } of imageInfos) {\n+ pendingUploads[localID] = {\n+ dataURI,\n+ failed: null,\n+ progressPercent: 0,\n+ };\n+ }\n+\n+ this.setState(\n+ prevState => {\n+ return {\n+ pendingUploads: {\n+ ...prevState.pendingUploads,\n+ [localMessageID]: pendingUploads,\n+ },\n+ };\n+ },\n+ () => {\n+ const creatorID = this.props.viewerID;\n+ invariant(creatorID, \"need viewer ID in order to send a message\");\n+ const messageInfo = ({\n+ type: messageTypes.MULTIMEDIA,\n+ localID: localMessageID,\n+ threadID,\n+ creatorID,\n+ time: Date.now(),\n+ media: imageInfos.map(\n+ ({ localID, uri, dimensions }) => ({\n+ id: localID,\n+ uri,\n+ type: \"photo\",\n+ dimensions,\n+ }),\n+ ),\n+ }: RawMultimediaMessageInfo);\n+ this.props.dispatchActionPayload(\n+ createLocalMultimediaMessageActionType,\n+ messageInfo,\n+ );\n+ },\n+ );\n+\n+ await Promise.all(\n+ imageInfos.map(imageInfo => this.uploadFile(localMessageID, imageInfo)),\n+ );\n+ }\n+\n+ async uploadFile(localMessageID: string, imageInfo: ImageInfo) {\n+ const { localID, uri: nativeURI, dataURI, name, mime } = imageInfo;\n+ const uri = dataURI ? dataURI : nativeURI;\n+ let result;\n+ try {\n+ result = await this.props.uploadMultimedia(\n+ { uri, name, type: mime },\n+ (percent: number) => this.setProgress(\n+ localMessageID,\n+ localID,\n+ percent,\n+ ),\n+ );\n+ } catch (e) {\n+ this.handleUploadFailure(localMessageID, localID, e);\n+ return;\n+ }\n+ this.props.dispatchActionPayload(\n+ updateMultimediaMessageMediaActionType,\n+ {\n+ messageID: localMessageID,\n+ currentMediaID: localID,\n+ mediaUpdate: {\n+ id: result.id,\n+ uri: result.uri,\n+ },\n+ },\n+ );\n+ }\n+\n+ setProgress(\n+ localMessageID: string,\n+ localUploadID: string,\n+ progressPercent: number,\n+ ) {\n+ this.setState(prevState => {\n+ const pendingUploads = prevState.pendingUploads[localMessageID];\n+ if (!pendingUploads) {\n+ return {};\n+ }\n+ const pendingUpload = pendingUploads[localUploadID];\n+ if (!pendingUpload) {\n+ return {};\n+ }\n+ const newPendingUploads = {\n+ ...pendingUploads,\n+ [localUploadID]: {\n+ ...pendingUpload,\n+ progressPercent,\n+ },\n+ };\n+ return {\n+ pendingUploads: {\n+ ...prevState.pendingUploads,\n+ [localMessageID]: newPendingUploads,\n+ },\n+ };\n+ });\n+ }\n+\n+ handleUploadFailure(\n+ localMessageID: string,\n+ localUploadID: string,\n+ e: any,\n+ ) {\n+ this.setState(prevState => {\n+ const uploads = prevState.pendingUploads[localMessageID];\n+ const upload = uploads[localUploadID];\n+ if (!upload) {\n+ // The upload has been completed before it failed\n+ return {};\n+ }\n+ const failed = (e instanceof Error && e.message)\n+ ? e.message\n+ : \"failed\";\n+ return {\n+ pendingUploads: {\n+ ...prevState.pendingUploads,\n+ [localMessageID]: {\n+ ...uploads,\n+ [localUploadID]: {\n+ ...upload,\n+ failed,\n+ progressPercent: 0,\n+ },\n+ },\n+ },\n+ };\n+ });\n+ }\n+\n+ messageHasUploadFailure = (localMessageID: string) => {\n+ const pendingUploads = this.state.pendingUploads[localMessageID];\n+ if (!pendingUploads) {\n+ return false;\n+ }\n+ for (let localUploadID in pendingUploads) {\n+ const { failed } = pendingUploads[localUploadID];\n+ if (failed) {\n+ return true;\n+ }\n+ }\n+ return false;\n+ }\n+\n+ retryMultimediaMessage = async (localMessageID: string) => {\n+ }\n+\n+ render() {\n+ const chatInputState = this.chatInputStateSelector(this.state);\n+ return (\n+ <ChatInputStateContext.Provider value={chatInputState}>\n+ {this.props.children}\n+ </ChatInputStateContext.Provider>\n+ );\n+ }\n+\n+}\n+\n+export default connect(\n+ (state: AppState) => ({\n+ viewerID: state.currentUserInfo && state.currentUserInfo.id,\n+ nextLocalID: state.nextLocalID,\n+ messageStoreMessages: state.messageStore.messages,\n+ }),\n+ { uploadMultimedia, sendMultimediaMessage },\n+)(ChatInputStateContainer);\n" }, { "change_type": "MODIFY", "old_path": "native/chat/chat.react.js", "new_path": "native/chat/chat.react.js", "diff": "// @flow\n-import type {\n- PendingMultimediaUploads,\n- ChatInputState,\n-} from './chat-input-state';\n-import type { GalleryImageInfo } from '../media/image-gallery-image.react';\n-import type { AppState } from '../redux/redux-setup';\n-import type {\n- DispatchActionPayload,\n- DispatchActionPromise,\n-} from 'lib/utils/action-utils';\n-import type { UploadMultimediaResult } from 'lib/types/media-types';\n-import {\n- messageTypes,\n- type RawMessageInfo,\n- type RawMultimediaMessageInfo,\n- type SendMessageResult,\n-} from 'lib/types/message-types';\n-import type { NativeImageInfo } from '../utils/media-utils';\n-\nimport * as React from 'react';\n-import PropTypes from 'prop-types';\n-import invariant from 'invariant';\nimport { StyleSheet } from 'react-native';\nimport hoistNonReactStatics from 'hoist-non-react-statics';\n-import { createSelector } from 'reselect';\n-\n-import { connect } from 'lib/utils/redux-utils';\n-import {\n- uploadMultimedia,\n- updateMultimediaMessageMediaActionType,\n-} from 'lib/actions/upload-actions';\n-import {\n- createLocalMultimediaMessageActionType,\n- sendMultimediaMessageActionTypes,\n- sendMultimediaMessage,\n-} from 'lib/actions/message-actions';\nimport ChatNavigator from './chat-navigator.react';\nimport KeyboardAvoidingView from '../components/keyboard-avoiding-view.react';\nimport MessageStorePruner from './message-store-pruner.react';\n-import { ChatInputStateContext } from './chat-input-state';\n-import { validateMedia } from '../utils/media-utils';\n-\n-let nextLocalUploadID = 0;\n-type ImageInfo = {|\n- ...NativeImageInfo,\n- localID: string,\n-|};\n-type CompletedUploads = { [localMessageID: string]: ?Set<string> };\n-\n-type Props = {|\n- // Redux state\n- viewerID: ?string,\n- nextLocalID: number,\n- messageStoreMessages: { [id: string]: RawMessageInfo },\n- // Redux dispatch functions\n- dispatchActionPayload: DispatchActionPayload,\n- dispatchActionPromise: DispatchActionPromise,\n- // async functions that hit server APIs\n- uploadMultimedia: (\n- multimedia: Object,\n- onProgress: (percent: number) => void,\n- abortHandler?: (abort: () => void) => void,\n- ) => Promise<UploadMultimediaResult>,\n- sendMultimediaMessage: (\n- threadID: string,\n- localID: string,\n- mediaIDs: $ReadOnlyArray<string>,\n- ) => Promise<SendMessageResult>,\n-|};\n-type State = {|\n- pendingUploads: PendingMultimediaUploads,\n-|};\n-class Chat extends React.PureComponent<Props, State> {\n-\n- static propTypes = {\n- viewerID: PropTypes.string,\n- nextLocalID: PropTypes.number.isRequired,\n- messageStoreMessages: PropTypes.object.isRequired,\n- dispatchActionPayload: PropTypes.func.isRequired,\n- dispatchActionPromise: PropTypes.func.isRequired,\n- uploadMultimedia: PropTypes.func.isRequired,\n- sendMultimediaMessage: PropTypes.func.isRequired,\n- };\n- state = {\n- pendingUploads: {},\n- };\n-\n- static getCompletedUploads(props: Props, state: State): CompletedUploads {\n- const completedUploads = {};\n- for (let localMessageID in state.pendingUploads) {\n- const messagePendingUploads = state.pendingUploads[localMessageID];\n- const rawMessageInfo = props.messageStoreMessages[localMessageID];\n- if (!rawMessageInfo) {\n- continue;\n- }\n- invariant(\n- rawMessageInfo.type === messageTypes.MULTIMEDIA,\n- `${localMessageID} should be messageTypes.MULTIMEDIA`,\n- );\n-\n- const completed = [];\n- let allUploadsComplete = true;\n- for (let localUploadID in messagePendingUploads) {\n- const media = rawMessageInfo.media.find(\n- media => media.id === localUploadID,\n- );\n- if (media) {\n- allUploadsComplete = false;\n- } else {\n- completed.push(localUploadID);\n- }\n- }\n-\n- if (allUploadsComplete) {\n- completedUploads[localMessageID] = null;\n- } else if (completed.length > 0) {\n- completedUploads[localMessageID] = new Set(completed);\n- }\n- }\n- return completedUploads;\n- }\n-\n- componentDidUpdate(prevProps: Props, prevState: State) {\n- const currentlyComplete = Chat.getCompletedUploads(this.props, this.state);\n- const previouslyComplete = Chat.getCompletedUploads(prevProps, prevState);\n-\n- const newPendingUploads = {};\n- let pendingUploadsChanged = false;\n- const readyMessageIDs = [];\n- for (let localMessageID in this.state.pendingUploads) {\n- const messagePendingUploads = this.state.pendingUploads[localMessageID];\n- const prevRawMessageInfo = prevProps.messageStoreMessages[localMessageID];\n- const rawMessageInfo = this.props.messageStoreMessages[localMessageID];\n- const completedUploadIDs = currentlyComplete[localMessageID];\n- const previouslyCompletedUploadIDs = previouslyComplete[localMessageID];\n-\n- if (!rawMessageInfo && prevRawMessageInfo) {\n- // A previously failed message got pruned out\n- pendingUploadsChanged = true;\n- continue;\n- } else if (completedUploadIDs === null) {\n- // All of this message's uploads have been completed\n- if (previouslyCompletedUploadIDs !== null) {\n- readyMessageIDs.push(localMessageID);\n- pendingUploadsChanged = true;\n- }\n- continue;\n- } else if (!completedUploadIDs) {\n- // Nothing has been completed\n- newPendingUploads[localMessageID] = messagePendingUploads;\n- continue;\n- }\n-\n- const newUploads = {};\n- let uploadsChanged = false;\n- for (let localUploadID in messagePendingUploads) {\n- if (!completedUploadIDs.has(localUploadID)) {\n- newUploads[localUploadID] = messagePendingUploads[localUploadID];\n- continue;\n- }\n- if (\n- !previouslyCompletedUploadIDs ||\n- !previouslyCompletedUploadIDs.has(localUploadID)\n- ) {\n- uploadsChanged = true;\n- }\n- }\n-\n- const numOldUploads = Object.keys(messagePendingUploads).length;\n- const numNewUploads = Object.keys(newUploads).length;\n- const allUploadsComplete = numNewUploads === 0;\n- const someUploadsComplete = numNewUploads > numOldUploads;\n- if (!allUploadsComplete && !someUploadsComplete) {\n- newPendingUploads[localMessageID] = messagePendingUploads;\n- } else if (!allUploadsComplete) {\n- newPendingUploads[localMessageID] = newUploads;\n- }\n-\n- if (uploadsChanged) {\n- pendingUploadsChanged = true;\n- if (allUploadsComplete) {\n- readyMessageIDs.push(localMessageID);\n- }\n- }\n- }\n- if (pendingUploadsChanged) {\n- this.setState({ pendingUploads: newPendingUploads });\n- }\n-\n- for (let localMessageID of readyMessageIDs) {\n- const rawMessageInfo = this.props.messageStoreMessages[localMessageID];\n- if (!rawMessageInfo) {\n- continue;\n- }\n- invariant(\n- rawMessageInfo.type === messageTypes.MULTIMEDIA,\n- `${localMessageID} should be messageTypes.MULTIMEDIA`,\n- );\n- this.dispatchMultimediaMessageAction(rawMessageInfo);\n- }\n- }\n-\n- dispatchMultimediaMessageAction(messageInfo: RawMultimediaMessageInfo) {\n- this.props.dispatchActionPromise(\n- sendMultimediaMessageActionTypes,\n- this.sendMultimediaMessageAction(messageInfo),\n- undefined,\n- messageInfo,\n- );\n- }\n-\n- async sendMultimediaMessageAction(messageInfo: RawMultimediaMessageInfo) {\n- const { localID, threadID, media } = messageInfo;\n- invariant(\n- localID !== null && localID !== undefined,\n- \"localID should be set\",\n- );\n- try {\n- const result = await this.props.sendMultimediaMessage(\n- threadID,\n- localID,\n- media.map(({ id }) => id),\n- );\n- return {\n- localID,\n- serverID: result.id,\n- threadID,\n- time: result.time,\n- };\n- } catch (e) {\n- e.localID = localID;\n- e.threadID = threadID;\n- throw e;\n- }\n- }\n-\n- chatInputStateSelector = createSelector(\n- (state: State) => state.pendingUploads,\n- (pendingUploads: PendingMultimediaUploads) => ({\n- pendingUploads,\n- sendMultimediaMessage: this.sendMultimediaMessage,\n- messageHasUploadFailure: this.messageHasUploadFailure,\n- retryMultimediaMessage: this.retryMultimediaMessage,\n- }),\n- );\n-\n- sendMultimediaMessage = async (\n- threadID: string,\n- inputImageInfos: $ReadOnlyArray<GalleryImageInfo>,\n- ) => {\n- const validationResults = await Promise.all(\n- inputImageInfos.map(validateMedia),\n- );\n- const imageInfos = validationResults.filter(Boolean).map(imageInfo => ({\n- ...imageInfo,\n- localID: `localUpload${nextLocalUploadID++}`,\n- }));\n- const localMessageID = `local${this.props.nextLocalID}`;\n-\n- const pendingUploads = {};\n- for (let { localID, dataURI } of imageInfos) {\n- pendingUploads[localID] = {\n- dataURI,\n- failed: null,\n- progressPercent: 0,\n- };\n- }\n-\n- this.setState(\n- prevState => {\n- return {\n- pendingUploads: {\n- ...prevState.pendingUploads,\n- [localMessageID]: pendingUploads,\n- },\n- };\n- },\n- () => {\n- const creatorID = this.props.viewerID;\n- invariant(creatorID, \"need viewer ID in order to send a message\");\n- const messageInfo = ({\n- type: messageTypes.MULTIMEDIA,\n- localID: localMessageID,\n- threadID,\n- creatorID,\n- time: Date.now(),\n- media: imageInfos.map(\n- ({ localID, uri, dimensions }) => ({\n- id: localID,\n- uri,\n- type: \"photo\",\n- dimensions,\n- }),\n- ),\n- }: RawMultimediaMessageInfo);\n- this.props.dispatchActionPayload(\n- createLocalMultimediaMessageActionType,\n- messageInfo,\n- );\n- },\n- );\n-\n- await Promise.all(\n- imageInfos.map(imageInfo => this.uploadFile(localMessageID, imageInfo)),\n- );\n- }\n-\n- async uploadFile(localMessageID: string, imageInfo: ImageInfo) {\n- const { localID, uri: nativeURI, dataURI, name, mime } = imageInfo;\n- const uri = dataURI ? dataURI : nativeURI;\n- let result;\n- try {\n- result = await this.props.uploadMultimedia(\n- { uri, name, type: mime },\n- (percent: number) => this.setProgress(\n- localMessageID,\n- localID,\n- percent,\n- ),\n- );\n- } catch (e) {\n- this.handleUploadFailure(localMessageID, localID, e);\n- return;\n- }\n- this.props.dispatchActionPayload(\n- updateMultimediaMessageMediaActionType,\n- {\n- messageID: localMessageID,\n- currentMediaID: localID,\n- mediaUpdate: {\n- id: result.id,\n- uri: result.uri,\n- },\n- },\n- );\n- }\n-\n- setProgress(\n- localMessageID: string,\n- localUploadID: string,\n- progressPercent: number,\n- ) {\n- this.setState(prevState => {\n- const pendingUploads = prevState.pendingUploads[localMessageID];\n- if (!pendingUploads) {\n- return {};\n- }\n- const pendingUpload = pendingUploads[localUploadID];\n- if (!pendingUpload) {\n- return {};\n- }\n- const newPendingUploads = {\n- ...pendingUploads,\n- [localUploadID]: {\n- ...pendingUpload,\n- progressPercent,\n- },\n- };\n- return {\n- pendingUploads: {\n- ...prevState.pendingUploads,\n- [localMessageID]: newPendingUploads,\n- },\n- };\n- });\n- }\n-\n- handleUploadFailure(\n- localMessageID: string,\n- localUploadID: string,\n- e: any,\n- ) {\n- this.setState(prevState => {\n- const uploads = prevState.pendingUploads[localMessageID];\n- const upload = uploads[localUploadID];\n- if (!upload) {\n- // The upload has been completed before it failed\n- return {};\n- }\n- const failed = (e instanceof Error && e.message)\n- ? e.message\n- : \"failed\";\n- return {\n- pendingUploads: {\n- ...prevState.pendingUploads,\n- [localMessageID]: {\n- ...uploads,\n- [localUploadID]: {\n- ...upload,\n- failed,\n- progressPercent: 0,\n- },\n- },\n- },\n- };\n- });\n- }\n- messageHasUploadFailure = (localMessageID: string) => {\n- const pendingUploads = this.state.pendingUploads[localMessageID];\n- if (!pendingUploads) {\n- return false;\n- }\n- for (let localUploadID in pendingUploads) {\n- const { failed } = pendingUploads[localUploadID];\n- if (failed) {\n- return true;\n- }\n- }\n- return false;\n- }\n-\n- retryMultimediaMessage = async (localMessageID: string) => {\n- }\n+class Chat extends React.PureComponent<{}> {\nrender() {\n- const chatInputState = this.chatInputStateSelector(this.state);\nreturn (\n- <ChatInputStateContext.Provider value={chatInputState}>\n<KeyboardAvoidingView style={styles.keyboardAvoidingView}>\n<ChatNavigator {...this.props} />\n<MessageStorePruner />\n</KeyboardAvoidingView>\n- </ChatInputStateContext.Provider>\n);\n}\n@@ -436,15 +27,6 @@ const styles = StyleSheet.create({\n},\n});\n-const ReduxWrappedChat = connect(\n- (state: AppState) => ({\n- viewerID: state.currentUserInfo && state.currentUserInfo.id,\n- nextLocalID: state.nextLocalID,\n- messageStoreMessages: state.messageStore.messages,\n- }),\n- { uploadMultimedia, sendMultimediaMessage },\n-)(Chat);\n-\n-hoistNonReactStatics(ReduxWrappedChat, ChatNavigator);\n+hoistNonReactStatics(Chat, ChatNavigator);\n-export default ReduxWrappedChat;\n+export default Chat;\n" }, { "change_type": "MODIFY", "old_path": "native/navigation/navigation-setup.js", "new_path": "native/navigation/navigation-setup.js", "diff": "@@ -101,6 +101,7 @@ import ColorPickerModal from '../chat/settings/color-picker-modal.react';\nimport ComposeSubthreadModal from '../chat/settings/compose-subthread-modal.react';\nimport { createLightboxNavigator } from '../media/lightbox-navigator.react';\nimport MultimediaModal from '../media/multimedia-modal.react';\n+import ChatInputStateContainer from '../chat/chat-input-state-container.react';\nuseScreens();\n@@ -218,7 +219,11 @@ class WrappedAppNavigator\n}\nrender() {\n- return <AppNavigator navigation={this.props.navigation} />;\n+ return (\n+ <ChatInputStateContainer>\n+ <AppNavigator navigation={this.props.navigation} />\n+ </ChatInputStateContainer>\n+ );\n}\n}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Separate Chat state into ChatInputStateContainer We need to move the chat input state up the component hierarchy so that `MultimediaModal` has access to its context.
129,187
29.05.2019 20:12:43
14,400
173a7b779d028495692a3bcb9f189dd269cb4b6e
[native] Avoid contextType because of uncertainty around PureComponent
[ { "change_type": "MODIFY", "old_path": "native/media/lightbox-navigator.react.js", "new_path": "native/media/lightbox-navigator.react.js", "diff": "@@ -177,10 +177,12 @@ function withLightboxPositionContext<\nReact.ElementConfig<ComponentType>,\n{ lightboxPosition: ?Animated.Value },\n>> {\n- static contextType = LightboxPositionContext;\nrender() {\n- const lightboxPosition = this.context;\n- return <Component {...this.props} lightboxPosition={lightboxPosition} />;\n+ return (\n+ <LightboxPositionContext.Consumer>\n+ {value => (<Component {...this.props} lightboxPosition={value} />)}\n+ </LightboxPositionContext.Consumer>\n+ );\n}\n}\nreturn LightboxPositionHOC;\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Avoid contextType because of uncertainty around PureComponent
129,187
29.05.2019 22:38:27
14,400
2e506b17e19d3535a0dc054569fbc6f037218144
[native] Rework base64 -> int array logic to work on native iOS
[ { "change_type": "ADD", "old_path": null, "new_path": "native/flow-typed/npm/base-64_v0.1.x.js", "diff": "+// flow-typed signature: 99981df5e2f24724e1bfd8292d17dfe8\n+// flow-typed version: b43dff3e0e/base-64_v0.1.x/flow_>=v0.25.x\n+\n+declare module 'base-64' {\n+ declare module.exports: {\n+ version: string;\n+ /**\n+ * This function takes a byte string (the input parameter) and encodes it according to base64.\n+ * The input data must be in the form of a string containing only characters\n+ * in the range from U+0000 to U+00FF, each representing a binary byte with values 0x00 to 0xFF.\n+ * The base64.encode() function is designed to be fully compatible\n+ * with btoa() as described in the HTML Standard.\n+ * see: https://html.spec.whatwg.org/multipage/webappapis.html#dom-windowbase64-btoa\n+ */\n+ encode(input: string): string;\n+ /**\n+ * This function takes a base64-encoded string (the input parameter) and decodes it.\n+ * The return value is in the form of a string containing only characters in\n+ * the range from U+0000 to U+00FF, each representing a binary byte with values 0x00 to 0xFF.\n+ * The base64.decode() function is designed to be fully compatible\n+ * with atob() as described in the HTML Standard.\n+ * see: https://html.spec.whatwg.org/multipage/webappapis.html#dom-windowbase64-atob\n+ */\n+ decode(input: string): string;\n+ };\n+}\n" }, { "change_type": "DELETE", "old_path": "native/flow-typed/npm/string-to-arraybuffer_vx.x.x.js", "new_path": null, "diff": "-// flow-typed signature: 20d28fd2b7a69a3caf7f92a8ac1a410b\n-// flow-typed version: <<STUB>>/string-to-arraybuffer_v^1.0.2/flow_v0.92.0\n-\n-/**\n- * This is an autogenerated libdef stub for:\n- *\n- * 'string-to-arraybuffer'\n- *\n- * Fill this stub out by replacing all the `any` types.\n- *\n- * Once filled out, we encourage you to share your work with the\n- * community by sending a pull request to:\n- * https://github.com/flowtype/flow-typed\n- */\n-\n-declare module 'string-to-arraybuffer' {\n- declare module.exports: any;\n-}\n-\n-/**\n- * We include stubs for each file inside this npm package in case you need to\n- * require those files directly. Feel free to delete any files that aren't\n- * needed.\n- */\n-declare module 'string-to-arraybuffer/test' {\n- declare module.exports: any;\n-}\n-\n-// Filename aliases\n-declare module 'string-to-arraybuffer/index' {\n- declare module.exports: $Exports<'string-to-arraybuffer'>;\n-}\n-declare module 'string-to-arraybuffer/index.js' {\n- declare module.exports: $Exports<'string-to-arraybuffer'>;\n-}\n-declare module 'string-to-arraybuffer/test.js' {\n- declare module.exports: $Exports<'string-to-arraybuffer/test'>;\n-}\n" }, { "change_type": "MODIFY", "old_path": "native/package.json", "new_path": "native/package.json", "diff": "\"@react-native-community/cameraroll\": \"^1.0.5\",\n\"@react-native-community/netinfo\": \"^2.0.0\",\n\"@react-navigation/core\": \"3.2.0\",\n+ \"base-64\": \"^0.1.0\",\n\"color\": \"^2.0.0\",\n\"find-root\": \"^1.1.0\",\n\"fs-extra\": \"^6.0.1\",\n\"redux-thunk\": \"^2.2.0\",\n\"reselect\": \"^3.0.1\",\n\"shallowequal\": \"^1.0.2\",\n- \"string-to-arraybuffer\": \"^1.0.2\",\n\"tinycolor2\": \"^1.4.1\",\n\"url-parse\": \"^1.1.9\"\n},\n" }, { "change_type": "MODIFY", "old_path": "native/utils/media-utils.js", "new_path": "native/utils/media-utils.js", "diff": "import type { Dimensions, MediaType } from 'lib/types/media-types';\nimport type { GalleryImageInfo } from '../media/image-gallery-image.react';\n-import str2ab from 'string-to-arraybuffer';\nimport { Platform } from 'react-native';\n+import base64 from 'base-64';\nimport { fileInfoFromData } from 'lib/utils/media-utils';\n@@ -22,6 +22,41 @@ function blobToDataURI(blob: Blob): Promise<string> {\n});\n}\n+function stringToIntArray(str: string): Uint8Array {\n+ const array = new Uint8Array(str.length);\n+ for (let i = 0; i < str.length; i++) {\n+ array[i] = str.charCodeAt(i);\n+ }\n+ return array;\n+}\n+\n+function dataURIToIntArray(dataURI: string): Uint8Array {\n+ let uri = dataURI;\n+ uri = uri.replace(/\\r?\\n/g, '');\n+ const firstComma = uri.indexOf(',');\n+ if (-1 === firstComma || firstComma <= 4) {\n+ throw new TypeError('malformed data-URI');\n+ }\n+ const meta = uri.substring(5, firstComma).split(';');\n+\n+ let base64Encoded = false;\n+ let charset = 'US-ASCII';\n+ for (let i = 0; i < meta.length; i++) {\n+ if (meta[i] === 'base64') {\n+ base64Encoded = true;\n+ } else if (meta[i].indexOf('charset=') === 0) {\n+ charset = meta[i].substring(8);\n+ }\n+ }\n+\n+ let data = unescape(uri.substring(firstComma + 1));\n+ if (base64Encoded) {\n+ data = base64.decode(data);\n+ }\n+\n+ return stringToIntArray(data);\n+}\n+\nexport type NativeImageInfo = {|\nuri: string,\ndataURI: ?string,\n@@ -38,11 +73,10 @@ async function validateMedia(\nconst blob = await response.blob();\nconst dataURI = await blobToDataURI(blob);\n- const arrayBuffer = str2ab(dataURI);\n- const uint8Array = new Uint8Array(arrayBuffer);\n+ const intArray = dataURIToIntArray(dataURI);\nconst blobName = blob.data.name;\n- const fileInfo = fileInfoFromData(new Uint8Array(arrayBuffer), blobName);\n+ const fileInfo = fileInfoFromData(intArray, blobName);\nif (!fileInfo) {\nreturn null;\n}\n" }, { "change_type": "MODIFY", "old_path": "yarn.lock", "new_path": "yarn.lock", "diff": "@@ -2429,11 +2429,6 @@ asynckit@^0.4.0:\nresolved \"https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79\"\nintegrity sha1-x57Zf380y48robyXkLzDZkdLS3k=\n-atob-lite@^2.0.0:\n- version \"2.0.0\"\n- resolved \"https://registry.yarnpkg.com/atob-lite/-/atob-lite-2.0.0.tgz#0fef5ad46f1bd7a8502c65727f0367d5ee43d696\"\n- integrity sha1-D+9a1G8b16hQLGVyfwNn1e5D1pY=\n-\natob@^2.1.1:\nversion \"2.1.2\"\nresolved \"https://registry.yarnpkg.com/atob/-/atob-2.1.2.tgz#6d9517eb9e030d2436666651e86bd9f6f13533c9\"\n@@ -2600,6 +2595,11 @@ balanced-match@^1.0.0:\nresolved \"https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767\"\nintegrity sha1-ibTRmasr7kneFk6gK4nORi1xt2c=\n+base-64@^0.1.0:\n+ version \"0.1.0\"\n+ resolved \"https://registry.yarnpkg.com/base-64/-/base-64-0.1.0.tgz#780a99c84e7d600260361511c4877613bf24f6bb\"\n+ integrity sha1-eAqZyE59YAJgNhURxId2E78k9rs=\n+\nbase64-js@^1.0.2, base64-js@^1.1.2, base64-js@^1.2.3:\nversion \"1.3.0\"\nresolved \"https://registry.yarnpkg.com/base64-js/-/base64-js-1.3.0.tgz#cab1e6118f051095e58b5281aea8c1cd22bfc0e3\"\n@@ -6316,11 +6316,6 @@ is-arrayish@^0.3.1:\nresolved \"https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.3.2.tgz#4574a2ae56f7ab206896fb431eaeed066fdf8f03\"\nintegrity sha512-eVRqCvVlZbuw3GrM63ovNSNAeA1K16kaR/LRY/92w0zxQ5/1YzwblUX652i4Xs9RwAGjW9d9y6X88t8OaAJfWQ==\n-is-base64@^0.1.0:\n- version \"0.1.0\"\n- resolved \"https://registry.yarnpkg.com/is-base64/-/is-base64-0.1.0.tgz#a6f20610c6ef4863a51cba32bc0222544b932622\"\n- integrity sha512-WRRyllsGXJM7ZN7gPTCCQ/6wNPTRDwiWdPK66l5sJzcU/oOzcIcRRf0Rux8bkpox/1yjt0F6VJRsQOIG2qz5sg==\n-\nis-binary-path@^1.0.0:\nversion \"1.0.1\"\nresolved \"https://registry.yarnpkg.com/is-binary-path/-/is-binary-path-1.0.1.tgz#75f16642b480f187a711c814161fd3a4a7655898\"\n@@ -12258,14 +12253,6 @@ string-length@^2.0.0:\nastral-regex \"^1.0.0\"\nstrip-ansi \"^4.0.0\"\n-string-to-arraybuffer@^1.0.2:\n- version \"1.0.2\"\n- resolved \"https://registry.yarnpkg.com/string-to-arraybuffer/-/string-to-arraybuffer-1.0.2.tgz#161147fbadea02e28b0935002cec4c40f1ca7f0a\"\n- integrity sha512-DaGZidzi93dwjQen5I2osxR9ERS/R7B1PFyufNMnzhj+fmlDQAc1DSDIJVJhgI8Oq221efIMbABUBdPHDRt43Q==\n- dependencies:\n- atob-lite \"^2.0.0\"\n- is-base64 \"^0.1.0\"\n-\nstring-width@^1.0.1:\nversion \"1.0.2\"\nresolved \"https://registry.yarnpkg.com/string-width/-/string-width-1.0.2.tgz#118bdf5b8cdc51a2a7e70d211e07e2b0b9b107d3\"\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Rework base64 -> int array logic to work on native iOS
129,187
29.05.2019 22:52:42
14,400
4e4224fee3508a6bd1afdc729a6ed3ec7b125074
[native] Update Multimedia to handle uploads (1) Add `messageID` and `index` to `Media` to make `MediaInfo` (2) Pass `ChatInputState` through to `Multimedia` using context (3) Use `Image` to render local URIs (4) Remove `dataURI` from `PendingMultimediaUpload` (no longer needed after (5) Don't show the new URI version until it is loaded
[ { "change_type": "MODIFY", "old_path": "lib/types/media-types.js", "new_path": "lib/types/media-types.js", "diff": "@@ -21,13 +21,27 @@ export type Media = {|\ndimensions: Dimensions,\n|};\n+export type MediaInfo = {|\n+ ...Media,\n+ index: number,\n+ messageID: string,\n+|};\n+\nexport const mediaTypePropType = PropTypes.oneOf([ \"photo\", \"video\" ]);\n-export const mediaPropType = PropTypes.shape({\n+const mediaPropTypes = {\nid: PropTypes.string.isRequired,\nuri: PropTypes.string.isRequired,\ntype: mediaTypePropType.isRequired,\ndimensions: dimensionsPropType.isRequired,\n+};\n+\n+export const mediaPropType = PropTypes.shape(mediaPropTypes);\n+\n+export const mediaInfoPropType = PropTypes.shape({\n+ ...mediaPropTypes,\n+ index: PropTypes.number.isRequired,\n+ messageID: PropTypes.string.isRequired,\n});\nexport type UploadMultimediaResult = {|\n" }, { "change_type": "MODIFY", "old_path": "native/chat/chat-input-state-container.react.js", "new_path": "native/chat/chat-input-state-container.react.js", "diff": "@@ -261,9 +261,8 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\nconst localMessageID = `local${this.props.nextLocalID}`;\nconst pendingUploads = {};\n- for (let { localID, dataURI } of imageInfos) {\n+ for (let { localID } of imageInfos) {\npendingUploads[localID] = {\n- dataURI,\nfailed: null,\nprogressPercent: 0,\n};\n" }, { "change_type": "MODIFY", "old_path": "native/chat/chat-input-state.js", "new_path": "native/chat/chat-input-state.js", "diff": "@@ -4,22 +4,28 @@ import type { Dimensions } from 'lib/types/media-types';\nimport type { GalleryImageInfo } from '../media/image-gallery-image.react';\nimport * as React from 'react';\n+import PropTypes from 'prop-types';\nexport type PendingMultimediaUpload = {|\n- // On some platforms (iOS) the URI we get isn't something that can be passed\n- // to an Image or be uploaded by fetch. We therefore convert it to a data URI,\n- // but avoid storing that string in Redux as it's quite long.\n- dataURI: ?string,\nfailed: ?string,\nprogressPercent: number,\n|};\n+const pendingMultimediaUploadPropType = PropTypes.shape({\n+ failed: PropTypes.string,\n+ progressPercent: PropTypes.number.isRequired,\n+});\n+\nexport type PendingMultimediaUploads = {\n[localMessageID: string]: {\n[localUploadID: string]: PendingMultimediaUpload,\n},\n};\n+const pendingMultimediaUploadsPropType = PropTypes.objectOf(\n+ PropTypes.objectOf(pendingMultimediaUploadPropType),\n+);\n+\nexport type ChatInputState = {|\npendingUploads: PendingMultimediaUploads,\nsendMultimediaMessage: (\n@@ -30,8 +36,39 @@ export type ChatInputState = {|\nretryMultimediaMessage: (localMessageID: string) => Promise<void>,\n|};\n+const chatInputStatePropType = PropTypes.shape({\n+ pendingUploads: pendingMultimediaUploadsPropType.isRequired,\n+ sendMultimediaMessage: PropTypes.func.isRequired,\n+ messageHasUploadFailure: PropTypes.func.isRequired,\n+ retryMultimediaMessage: PropTypes.func.isRequired,\n+});\n+\nconst ChatInputStateContext = React.createContext<?ChatInputState>(null);\n+function withChatInputState<\n+ AllProps: {},\n+ ComponentType: React.ComponentType<AllProps>,\n+>(Component: ComponentType): React.ComponentType<$Diff<\n+ React.ElementConfig<ComponentType>,\n+ { chatInputState: ?ChatInputState },\n+>> {\n+ class ChatInputStateHOC extends React.PureComponent<$Diff<\n+ React.ElementConfig<ComponentType>,\n+ { chatInputState: ?ChatInputState },\n+ >> {\n+ render() {\n+ return (\n+ <ChatInputStateContext.Consumer>\n+ {value => (<Component {...this.props} chatInputState={value} />)}\n+ </ChatInputStateContext.Consumer>\n+ );\n+ }\n+ }\n+ return ChatInputStateHOC;\n+}\n+\nexport {\n+ chatInputStatePropType,\nChatInputStateContext,\n+ withChatInputState,\n};\n" }, { "change_type": "MODIFY", "old_path": "native/chat/multimedia-message-multimedia.react.js", "new_path": "native/chat/multimedia-message-multimedia.react.js", "diff": "// @flow\n-import { type Media, mediaPropType } from 'lib/types/media-types';\n+import { type MediaInfo, mediaInfoPropType } from 'lib/types/media-types';\nimport type { ImageStyle } from '../types/styles';\nimport {\ntype Navigate,\n@@ -24,7 +24,7 @@ import { modalsClosedSelector } from '../selectors/nav-selectors';\nimport { withLightboxPositionContext } from '../media/lightbox-navigator.react';\ntype Props = {|\n- media: Media,\n+ mediaInfo: MediaInfo,\nnavigate: Navigate,\nverticalBounds: ?VerticalBounds,\nstyle?: ImageStyle,\n@@ -40,7 +40,7 @@ type State = {|\nclass MultimediaMessageMultimedia extends React.PureComponent<Props, State> {\nstatic propTypes = {\n- media: mediaPropType.isRequired,\n+ mediaInfo: mediaInfoPropType.isRequired,\nnavigate: PropTypes.func.isRequired,\nverticalBounds: verticalBoundsPropType,\nmodalsClosed: PropTypes.bool.isRequired,\n@@ -86,7 +86,7 @@ class MultimediaMessageMultimedia extends React.PureComponent<Props, State> {\n}\nrender() {\n- const { media, style } = this.props;\n+ const { mediaInfo, style } = this.props;\nconst wrapperStyles = [ styles.expand ];\nif (this.state.hidden && this.state.opacity) {\nwrapperStyles.push({ opacity: this.state.opacity });\n@@ -95,7 +95,7 @@ class MultimediaMessageMultimedia extends React.PureComponent<Props, State> {\n<TouchableWithoutFeedback onPress={this.onPress}>\n<View style={[ styles.expand, style ]} ref={this.viewRef}>\n<Animated.View style={wrapperStyles}>\n- <Multimedia media={media} />\n+ <Multimedia mediaInfo={mediaInfo} />\n</Animated.View>\n</View>\n</TouchableWithoutFeedback>\n@@ -113,10 +113,10 @@ class MultimediaMessageMultimedia extends React.PureComponent<Props, State> {\n}\nview.measure((x, y, width, height, pageX, pageY) => {\nconst coordinates = { x: pageX, y: pageY, width, height };\n- const { media, navigate } = this.props;\n+ const { mediaInfo, navigate } = this.props;\nnavigate({\nrouteName: MultimediaModalRouteName,\n- params: { media, initialCoordinates: coordinates, verticalBounds },\n+ params: { mediaInfo, initialCoordinates: coordinates, verticalBounds },\n});\nthis.setState({ hidden: true });\n});\n" }, { "change_type": "MODIFY", "old_path": "native/chat/multimedia-message.react.js", "new_path": "native/chat/multimedia-message.react.js", "diff": "@@ -24,7 +24,7 @@ import {\nimport PropTypes from 'prop-types';\nimport invariant from 'invariant';\n-import { messageKey } from 'lib/shared/message-utils';\n+import { messageKey, messageID } from 'lib/shared/message-utils';\nimport ComposedMessage from './composed-message.react';\nimport MultimediaMessageMultimedia from './multimedia-message-multimedia.react';\n@@ -154,7 +154,7 @@ class MultimediaMessage extends React.PureComponent<Props> {\nconst { messageInfo } = this.props.item;\ninvariant(messageInfo.media.length > 0, \"should have media\");\nif (messageInfo.media.length === 1) {\n- return this.renderImage(messageInfo.media[0]);\n+ return this.renderImage(messageInfo.media[0], 0);\n}\nconst mediaPerRow = getMediaPerRow(messageInfo.media.length);\n@@ -170,7 +170,7 @@ class MultimediaMessage extends React.PureComponent<Props> {\nconst style = j + 1 < mediaPerRow\n? styles.imageBeforeImage\n: null;\n- row.push(this.renderImage(media, style));\n+ row.push(this.renderImage(media, i + j, style));\n}\nfor (; j < mediaPerRow; j++) {\nconst key = `filler${j}`;\n@@ -192,14 +192,24 @@ class MultimediaMessage extends React.PureComponent<Props> {\nreturn <View style={styles.grid}>{rows}</View>;\n}\n- renderImage(media: Media, style?: ?ImageStyle): React.Node {\n+ renderImage(\n+ media: Media,\n+ index: number,\n+ style?: ?ImageStyle,\n+ ): React.Node {\n+ const id = messageID(this.props.item.messageInfo);\n+ const mediaInfo = {\n+ ...media,\n+ messageID: id,\n+ index,\n+ };\nreturn (\n<MultimediaMessageMultimedia\n- media={media}\n+ mediaInfo={mediaInfo}\nnavigate={this.props.navigate}\nverticalBounds={this.props.verticalBounds}\nstyle={style}\n- key={media.id}\n+ key={index}\n/>\n);\n}\n" }, { "change_type": "MODIFY", "old_path": "native/flow-typed/npm/@react-native-community/cameraroll_vx.x.x.js", "new_path": "native/flow-typed/npm/@react-native-community/cameraroll_vx.x.x.js", "diff": "-// flow-typed signature: 37863e77b7d2e550db26df6c1745a22c\n-// flow-typed version: <<STUB>>/@react-native-community/cameraroll_v^1.0.4/flow_v0.92.0\n+// flow-typed signature: 3f4414dfa9d8b9e10e1a2f23aae1dfb0\n+// flow-typed version: <<STUB>>/@react-native-community/cameraroll_v^1.0.5/flow_v0.92.0\n/**\n* This is an autogenerated libdef stub for:\n" }, { "change_type": "MODIFY", "old_path": "native/media/image-gallery-image.react.js", "new_path": "native/media/image-gallery-image.react.js", "diff": "@@ -6,7 +6,6 @@ import type { ViewStyle, ImageStyle } from '../types/styles';\nimport * as React from 'react';\nimport PropTypes from 'prop-types';\nimport {\n- Image,\nTouchableOpacity,\nStyleSheet,\nView,\n" }, { "change_type": "MODIFY", "old_path": "native/media/multimedia-modal.react.js", "new_path": "native/media/multimedia-modal.react.js", "diff": "@@ -7,8 +7,8 @@ import type {\nNavigationTransitionProps,\n} from 'react-navigation';\nimport {\n- type Media,\n- mediaPropType,\n+ type MediaInfo,\n+ mediaInfoPropType,\ntype Dimensions,\ndimensionsPropType,\n} from 'lib/types/media-types';\n@@ -195,7 +195,7 @@ type LayoutCoordinates = $ReadOnly<{|\ntype NavProp = NavigationScreenProp<{|\n...NavigationLeafRoute,\nparams: {|\n- media: Media,\n+ mediaInfo: MediaInfo,\ninitialCoordinates: LayoutCoordinates,\nverticalBounds: VerticalBounds,\n|},\n@@ -216,7 +216,7 @@ class MultimediaModal extends React.PureComponent<Props> {\nnavigation: PropTypes.shape({\nstate: PropTypes.shape({\nparams: PropTypes.shape({\n- media: mediaPropType.isRequired,\n+ mediaInfo: mediaInfoPropType.isRequired,\ninitialCoordinates: PropTypes.shape({\nx: PropTypes.number.isRequired,\ny: PropTypes.number.isRequired,\n@@ -831,7 +831,7 @@ class MultimediaModal extends React.PureComponent<Props> {\nmaxWidth -= 100;\n}\n- const { dimensions } = this.props.navigation.state.params.media;\n+ const { dimensions } = this.props.navigation.state.params.mediaInfo;\nif (dimensions.height < maxHeight && dimensions.width < maxWidth) {\nreturn dimensions;\n}\n@@ -892,7 +892,7 @@ class MultimediaModal extends React.PureComponent<Props> {\n}\nrender() {\n- const { media } = this.props.navigation.state.params;\n+ const { mediaInfo } = this.props.navigation.state.params;\nconst statusBar = MultimediaModal.isActive(this.props)\n? <ConnectedStatusBar barStyle=\"light-content\" />\n: null;\n@@ -907,7 +907,7 @@ class MultimediaModal extends React.PureComponent<Props> {\n<Animated.View style={[ styles.backdrop, backdropStyle ]} />\n<View style={this.contentContainerStyle}>\n<Animated.View style={this.imageContainerStyle}>\n- <Multimedia media={media} spinnerColor=\"white\" />\n+ <Multimedia mediaInfo={mediaInfo} spinnerColor=\"white\" />\n</Animated.View>\n</View>\n<Animated.View style={[\n" }, { "change_type": "MODIFY", "old_path": "native/media/multimedia.react.js", "new_path": "native/media/multimedia.react.js", "diff": "// @flow\n-import { type Media, mediaPropType } from 'lib/types/media-types';\n-import {\n- type ConnectionStatus,\n- connectionStatusPropType,\n-} from 'lib/types/socket-types';\n-import type { AppState } from '../redux/redux-setup';\n+import { type MediaInfo, mediaInfoPropType } from 'lib/types/media-types';\nimport * as React from 'react';\nimport PropTypes from 'prop-types';\n-import { View, StyleSheet, ActivityIndicator } from 'react-native';\n-import FastImage from 'react-native-fast-image';\n+import { View, Image, StyleSheet } from 'react-native';\n-import { connect } from 'lib/utils/redux-utils';\n+import {\n+ type ChatInputState,\n+ chatInputStatePropType,\n+ withChatInputState,\n+} from '../chat/chat-input-state';\n+import RemoteImage from './remote-image.react';\ntype Props = {|\n- media: Media,\n+ mediaInfo: MediaInfo,\nspinnerColor: \"black\" | \"white\",\n- // Redux state\n- connectionStatus: ConnectionStatus,\n+ chatInputState: ?ChatInputState,\n|};\ntype State = {|\n- attempt: number,\n- loaded: bool,\n+ currentURI: string,\n+ departingURI: ?string,\n|};\nclass Multimedia extends React.PureComponent<Props, State> {\nstatic propTypes = {\n- media: mediaPropType.isRequired,\n+ mediaInfo: mediaInfoPropType.isRequired,\nspinnerColor: PropTypes.oneOf([ \"black\", \"white\" ]).isRequired,\n- connectionStatus: connectionStatusPropType.isRequired,\n+ chatInputState: chatInputStatePropType,\n};\nstatic defaultProps = {\nspinnerColor: \"black\",\n};\n- state = {\n- attempt: 0,\n- loaded: false,\n+\n+ constructor(props: Props) {\n+ super(props);\n+ this.state = {\n+ currentURI: props.mediaInfo.uri,\n+ departingURI: null,\n};\n+ }\ncomponentDidUpdate(prevProps: Props) {\n- if (\n- !this.state.loaded &&\n- this.props.connectionStatus === \"connected\" &&\n- prevProps.connectionStatus !== \"connected\"\n- ) {\n- this.setState(prevState => ({ attempt: prevState.attempt + 1 }));\n+ const newURI = this.props.mediaInfo.uri;\n+ const oldURI = prevProps.mediaInfo.uri;\n+ if (newURI !== oldURI && !this.state.departingURI) {\n+ this.setState({ currentURI: newURI, departingURI: oldURI });\n+ } else if (newURI !== oldURI) {\n+ this.setState({ currentURI: newURI });\n}\n}\nrender() {\n- let spinner = null;\n- if (!this.state.loaded) {\n- spinner = (\n- <View style={styles.spinnerContainer}>\n- <ActivityIndicator\n- color={this.props.spinnerColor}\n- size=\"large\"\n- />\n+ const images = [];\n+ const { currentURI, departingURI } = this.state;\n+ if (departingURI) {\n+ images.push(this.renderURI(currentURI, true));\n+ images.push(this.renderURI(departingURI, true));\n+ } else {\n+ images.push(this.renderURI(currentURI));\n+ }\n+\n+ return (\n+ <View style={styles.container}>\n+ {images}\n</View>\n);\n}\n- const { media } = this.props;\n- const { uri } = media;\n+ static isRemoteURI(uri: string) {\n+ return uri.startsWith(\"http\");\n+ }\n+\n+ renderURI(uri: string, invisibleLoad?: bool = false) {\n+ if (Multimedia.isRemoteURI(uri)) {\n+ return (\n+ <RemoteImage\n+ uri={uri}\n+ onLoad={this.onRemoteImageLoad}\n+ spinnerColor={this.props.spinnerColor}\n+ style={styles.image}\n+ invisibleLoad={invisibleLoad}\n+ key={uri}\n+ />\n+ );\n+ } else {\nconst source = { uri };\nreturn (\n- <View style={styles.container}>\n- {spinner}\n- <FastImage\n+ <Image\nsource={source}\nonLoad={this.onLoad}\nstyle={styles.image}\n- key={this.state.attempt}\n+ key={uri}\n/>\n- </View>\n);\n}\n+ }\n+\n+ onRemoteImageLoad = (uri: string) => {\n+ if (this.state.departingURI) {\n+ this.setState({ departingURI: null });\n+ }\n+ }\nonLoad = () => {\n- this.setState({ loaded: true });\n+ if (this.state.departingURI) {\n+ this.setState({ departingURI: null });\n+ }\n}\n}\n@@ -89,21 +116,12 @@ const styles = StyleSheet.create({\nflex: 1,\n},\nimage: {\n- flex: 1,\n- },\n- spinnerContainer: {\nposition: 'absolute',\ntop: 0,\nbottom: 0,\nleft: 0,\nright: 0,\n- justifyContent: 'center',\n- alignItems: 'center',\n},\n});\n-export default connect(\n- (state: AppState) => ({\n- connectionStatus: state.connection.status,\n- }),\n-)(Multimedia);\n+export default withChatInputState(Multimedia);\n" }, { "change_type": "ADD", "old_path": null, "new_path": "native/media/remote-image.react.js", "diff": "+// @flow\n+\n+import {\n+ type ConnectionStatus,\n+ connectionStatusPropType,\n+} from 'lib/types/socket-types';\n+import type { AppState } from '../redux/redux-setup';\n+import type { ImageStyle } from '../types/styles';\n+\n+import * as React from 'react';\n+import PropTypes from 'prop-types';\n+import { View, StyleSheet, ActivityIndicator } from 'react-native';\n+import FastImage from 'react-native-fast-image';\n+\n+import { connect } from 'lib/utils/redux-utils';\n+\n+type Props = {|\n+ uri: string,\n+ onLoad: (uri: string) => void,\n+ spinnerColor: \"black\" | \"white\",\n+ style: ImageStyle,\n+ invisibleLoad: bool,\n+ // Redux state\n+ connectionStatus: ConnectionStatus,\n+|};\n+type State = {|\n+ attempt: number,\n+ loaded: bool,\n+|};\n+class Image extends React.PureComponent<Props, State> {\n+\n+ static propTypes = {\n+ uri: PropTypes.string.isRequired,\n+ onLoad: PropTypes.func.isRequired,\n+ spinnerColor: PropTypes.oneOf([ \"black\", \"white\" ]).isRequired,\n+ invisibleLoad: PropTypes.bool.isRequired,\n+ connectionStatus: connectionStatusPropType.isRequired,\n+ };\n+ state = {\n+ attempt: 0,\n+ loaded: false,\n+ };\n+\n+ componentDidUpdate(prevProps: Props, prevState: State) {\n+ if (\n+ !this.state.loaded &&\n+ this.props.connectionStatus === \"connected\" &&\n+ prevProps.connectionStatus !== \"connected\"\n+ ) {\n+ this.setState(prevState => ({ attempt: prevState.attempt + 1 }));\n+ }\n+ if (this.state.loaded && !prevState.loaded) {\n+ this.props.onLoad && this.props.onLoad(this.props.uri);\n+ }\n+ }\n+\n+ render() {\n+ let spinner = null;\n+ if (!this.state.loaded && !this.props.invisibleLoad) {\n+ spinner = (\n+ <View style={styles.spinnerContainer}>\n+ <ActivityIndicator\n+ color={this.props.spinnerColor}\n+ size=\"large\"\n+ />\n+ </View>\n+ );\n+ }\n+\n+ const source = { uri: this.props.uri };\n+ const containerStyle = !this.state.loaded && this.props.invisibleLoad\n+ ? styles.invisibleContainer\n+ : styles.container;\n+ return (\n+ <View style={containerStyle}>\n+ {spinner}\n+ <FastImage\n+ source={source}\n+ onLoad={this.onLoad}\n+ style={this.props.style}\n+ key={this.state.attempt}\n+ />\n+ </View>\n+ );\n+ }\n+\n+ onLoad = () => {\n+ this.setState({ loaded: true });\n+ }\n+\n+}\n+\n+const styles = StyleSheet.create({\n+ container: {\n+ flex: 1,\n+ },\n+ invisibleContainer: {\n+ flex: 1,\n+ opacity: 0,\n+ },\n+ spinnerContainer: {\n+ position: 'absolute',\n+ top: 0,\n+ bottom: 0,\n+ left: 0,\n+ right: 0,\n+ justifyContent: 'center',\n+ alignItems: 'center',\n+ },\n+});\n+\n+export default connect(\n+ (state: AppState) => ({\n+ connectionStatus: state.connection.status,\n+ }),\n+)(Image);\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Update Multimedia to handle uploads (1) Add `messageID` and `index` to `Media` to make `MediaInfo` (2) Pass `ChatInputState` through to `Multimedia` using context (3) Use `Image` to render local URIs (4) Remove `dataURI` from `PendingMultimediaUpload` (no longer needed after #3) (5) Don't show the new URI version until it is loaded
129,187
30.05.2019 01:33:21
14,400
2369d88ba0be6da8cdf6fbbe07808dc3e647794b
[native] Pass PendingUpload into MultimediaMessageMultimedia
[ { "change_type": "MODIFY", "old_path": "native/chat/chat-input-state.js", "new_path": "native/chat/chat-input-state.js", "diff": "@@ -68,6 +68,7 @@ function withChatInputState<\n}\nexport {\n+ pendingMultimediaUploadPropType,\nchatInputStatePropType,\nChatInputStateContext,\nwithChatInputState,\n" }, { "change_type": "MODIFY", "old_path": "native/chat/multimedia-message-multimedia.react.js", "new_path": "native/chat/multimedia-message-multimedia.react.js", "diff": "@@ -10,28 +10,26 @@ import {\ntype VerticalBounds,\nverticalBoundsPropType,\n} from '../media/vertical-bounds';\n-import type { AppState } from '../redux/redux-setup';\n+import {\n+ type PendingMultimediaUpload,\n+ pendingMultimediaUploadPropType,\n+} from './chat-input-state';\nimport * as React from 'react';\nimport PropTypes from 'prop-types';\nimport { View, TouchableWithoutFeedback, StyleSheet } from 'react-native';\nimport Animated from 'react-native-reanimated';\n-import { connect } from 'lib/utils/redux-utils';\n-\nimport Multimedia from '../media/multimedia.react';\n-import { modalsClosedSelector } from '../selectors/nav-selectors';\n-import { withLightboxPositionContext } from '../media/lightbox-navigator.react';\ntype Props = {|\nmediaInfo: MediaInfo,\nnavigate: Navigate,\nverticalBounds: ?VerticalBounds,\nstyle?: ImageStyle,\n- // Redux state\nmodalsClosed: bool,\n- // withLightboxPositionContext\nlightboxPosition: ?Animated.Value,\n+ pendingUpload: ?PendingMultimediaUpload,\n|};\ntype State = {|\nhidden: bool,\n@@ -45,6 +43,7 @@ class MultimediaMessageMultimedia extends React.PureComponent<Props, State> {\nverticalBounds: verticalBoundsPropType,\nmodalsClosed: PropTypes.bool.isRequired,\nlightboxPosition: PropTypes.instanceOf(Animated.Value),\n+ pendingUpload: pendingMultimediaUploadPropType,\n};\nview: ?View;\n@@ -130,10 +129,4 @@ const styles = StyleSheet.create({\n},\n});\n-export default withLightboxPositionContext(\n- connect(\n- (state: AppState) => ({\n- modalsClosed: modalsClosedSelector(state),\n- }),\n- )(MultimediaMessageMultimedia),\n-);\n+export default MultimediaMessageMultimedia;\n" }, { "change_type": "MODIFY", "old_path": "native/chat/multimedia-message.react.js", "new_path": "native/chat/multimedia-message.react.js", "diff": "@@ -13,6 +13,7 @@ import {\ntype VerticalBounds,\nverticalBoundsPropType,\n} from '../media/vertical-bounds';\n+import type { AppState } from '../redux/redux-setup';\nimport * as React from 'react';\nimport {\n@@ -23,11 +24,20 @@ import {\n} from 'react-native';\nimport PropTypes from 'prop-types';\nimport invariant from 'invariant';\n+import Animated from 'react-native-reanimated';\nimport { messageKey, messageID } from 'lib/shared/message-utils';\n+import { connect } from 'lib/utils/redux-utils';\nimport ComposedMessage from './composed-message.react';\nimport MultimediaMessageMultimedia from './multimedia-message-multimedia.react';\n+import { modalsClosedSelector } from '../selectors/nav-selectors';\n+import { withLightboxPositionContext } from '../media/lightbox-navigator.react';\n+import {\n+ type ChatInputState,\n+ chatInputStatePropType,\n+ withChatInputState,\n+} from './chat-input-state';\nexport type ChatMultimediaMessageInfoItem = {|\nitemType: \"message\",\n@@ -112,6 +122,12 @@ type Props = {|\nnavigate: Navigate,\ntoggleFocus: (messageKey: string) => void,\nverticalBounds: ?VerticalBounds,\n+ // Redux state\n+ modalsClosed: bool,\n+ // withLightboxPositionContext\n+ lightboxPosition: ?Animated.Value,\n+ // withChatInputState\n+ chatInputState: ?ChatInputState,\n|};\nclass MultimediaMessage extends React.PureComponent<Props> {\n@@ -120,6 +136,9 @@ class MultimediaMessage extends React.PureComponent<Props> {\nnavigate: PropTypes.func.isRequired,\ntoggleFocus: PropTypes.func.isRequired,\nverticalBounds: verticalBoundsPropType,\n+ modalsClosed: PropTypes.bool.isRequired,\n+ lightboxPosition: PropTypes.instanceOf(Animated.Value),\n+ chatInputState: chatInputStatePropType,\n};\nrender() {\n@@ -203,12 +222,19 @@ class MultimediaMessage extends React.PureComponent<Props> {\nmessageID: id,\nindex,\n};\n+ const { chatInputState } = this.props;\n+ const pendingUpload = chatInputState\n+ && chatInputState[id]\n+ && chatInputState[id][media.id];\nreturn (\n<MultimediaMessageMultimedia\nmediaInfo={mediaInfo}\nnavigate={this.props.navigate}\nverticalBounds={this.props.verticalBounds}\nstyle={style}\n+ modalsClosed={this.props.modalsClosed}\n+ lightboxPosition={this.props.lightboxPosition}\n+ pendingUpload={pendingUpload}\nkey={index}\n/>\n);\n@@ -247,8 +273,19 @@ const styles = StyleSheet.create({\n},\n});\n+\n+const WrappedMultimediaMessage = withChatInputState(\n+ withLightboxPositionContext(\n+ connect(\n+ (state: AppState) => ({\n+ modalsClosed: modalsClosedSelector(state),\n+ }),\n+ )(MultimediaMessage),\n+ ),\n+);\n+\nexport {\n- MultimediaMessage,\n+ WrappedMultimediaMessage as MultimediaMessage,\nmultimediaMessageContentHeight,\nmultimediaMessageItemHeight,\n};\n" }, { "change_type": "MODIFY", "old_path": "native/media/multimedia.react.js", "new_path": "native/media/multimedia.react.js", "diff": "@@ -6,17 +6,11 @@ import * as React from 'react';\nimport PropTypes from 'prop-types';\nimport { View, Image, StyleSheet } from 'react-native';\n-import {\n- type ChatInputState,\n- chatInputStatePropType,\n- withChatInputState,\n-} from '../chat/chat-input-state';\nimport RemoteImage from './remote-image.react';\ntype Props = {|\nmediaInfo: MediaInfo,\nspinnerColor: \"black\" | \"white\",\n- chatInputState: ?ChatInputState,\n|};\ntype State = {|\ncurrentURI: string,\n@@ -27,7 +21,6 @@ class Multimedia extends React.PureComponent<Props, State> {\nstatic propTypes = {\nmediaInfo: mediaInfoPropType.isRequired,\nspinnerColor: PropTypes.oneOf([ \"black\", \"white\" ]).isRequired,\n- chatInputState: chatInputStatePropType,\n};\nstatic defaultProps = {\nspinnerColor: \"black\",\n@@ -60,7 +53,6 @@ class Multimedia extends React.PureComponent<Props, State> {\n} else {\nimages.push(this.renderURI(currentURI));\n}\n-\nreturn (\n<View style={styles.container}>\n{images}\n@@ -68,12 +60,8 @@ class Multimedia extends React.PureComponent<Props, State> {\n);\n}\n- static isRemoteURI(uri: string) {\n- return uri.startsWith(\"http\");\n- }\n-\nrenderURI(uri: string, invisibleLoad?: bool = false) {\n- if (Multimedia.isRemoteURI(uri)) {\n+ if (uri.startsWith(\"http\")) {\nreturn (\n<RemoteImage\nuri={uri}\n@@ -124,4 +112,4 @@ const styles = StyleSheet.create({\n},\n});\n-export default withChatInputState(Multimedia);\n+export default Multimedia;\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Pass PendingUpload into MultimediaMessageMultimedia
129,187
09.06.2019 17:30:43
14,400
b52325eac5ebddb564569d9f9b3f0b27ef729c68
[lib] Support dayStrings from 0-1000 AD
[ { "change_type": "MODIFY", "old_path": "lib/utils/date-utils.js", "new_path": "lib/utils/date-utils.js", "diff": "@@ -68,7 +68,7 @@ function prettyDate(dayString: string): string {\n}\nfunction dateFromString(dayString: string): Date {\n- const matches = dayString.match(/^([0-9]{4})-([0-1][0-9])-([0-3][0-9])$/);\n+ const matches = dayString.match(/^([0-9]+)-([0-1][0-9])-([0-3][0-9])$/);\ninvariant(matches && matches.length === 4, `invalid dayString ${dayString}`);\nreturn getDate(\nparseInt(matches[1]),\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[lib] Support dayStrings from 0-1000 AD
129,187
10.06.2019 15:43:46
14,400
d4ef35d220496b465f294d267cae056b94ca03a3
[native] react-native-svg
[ { "change_type": "MODIFY", "old_path": "native/android/app/build.gradle", "new_path": "native/android/app/build.gradle", "diff": "@@ -147,6 +147,7 @@ android {\n}\ndependencies {\n+ implementation project(':react-native-svg')\nimplementation project(':lottie-react-native')\nimplementation project(':@react-native-community_cameraroll')\nimplementation project(':react-native-firebase')\n" }, { "change_type": "MODIFY", "old_path": "native/android/app/src/main/java/org/squadcal/MainApplication.java", "new_path": "native/android/app/src/main/java/org/squadcal/MainApplication.java", "diff": "@@ -3,6 +3,7 @@ package org.squadcal;\nimport android.app.Application;\nimport com.facebook.react.ReactApplication;\n+import com.horcrux.svg.SvgPackage;\nimport com.airbnb.android.react.lottie.LottiePackage;\nimport com.reactnativecommunity.cameraroll.CameraRollPackage;\nimport io.invertase.firebase.RNFirebasePackage;\n@@ -40,6 +41,7 @@ public class MainApplication extends Application implements ReactApplication {\nprotected List<ReactPackage> getPackages() {\nreturn Arrays.<ReactPackage>asList(\nnew MainReactPackage(),\n+ new SvgPackage(),\nnew LottiePackage(),\nnew CameraRollPackage(),\nnew RNFirebasePackage(),\n" }, { "change_type": "MODIFY", "old_path": "native/android/settings.gradle", "new_path": "native/android/settings.gradle", "diff": "rootProject.name = 'SquadCal'\n+include ':react-native-svg'\n+project(':react-native-svg').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-svg/android')\ninclude ':lottie-react-native'\nproject(':lottie-react-native').projectDir = new File(rootProject.projectDir, '../node_modules/lottie-react-native/src/android')\ninclude ':@react-native-community_cameraroll'\n" }, { "change_type": "ADD", "old_path": null, "new_path": "native/flow-typed/npm/react-native-svg_vx.x.x.js", "diff": "+// flow-typed signature: 3db989c787f1398502458adc8b7db5a0\n+// flow-typed version: <<STUB>>/react-native-svg_v^9.5.1/flow_v0.92.0\n+\n+/**\n+ * This is an autogenerated libdef stub for:\n+ *\n+ * 'react-native-svg'\n+ *\n+ * Fill this stub out by replacing all the `any` types.\n+ *\n+ * Once filled out, we encourage you to share your work with the\n+ * community by sending a pull request to:\n+ * https://github.com/flowtype/flow-typed\n+ */\n+\n+declare module 'react-native-svg' {\n+ declare module.exports: any;\n+}\n+\n+/**\n+ * We include stubs for each file inside this npm package in case you need to\n+ * require those files directly. Feel free to delete any files that aren't\n+ * needed.\n+ */\n+declare module 'react-native-svg/elements/Circle' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-svg/elements/ClipPath' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-svg/elements/Defs' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-svg/elements/Ellipse' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-svg/elements/G' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-svg/elements/Image' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-svg/elements/Line' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-svg/elements/LinearGradient' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-svg/elements/Mask' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-svg/elements/Path' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-svg/elements/Pattern' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-svg/elements/Polygon' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-svg/elements/Polyline' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-svg/elements/RadialGradient' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-svg/elements/Rect' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-svg/elements/Shape' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-svg/elements/Stop' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-svg/elements/Svg' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-svg/elements/Symbol' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-svg/elements/Text' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-svg/elements/TextPath' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-svg/elements/TSpan' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-svg/elements/Use' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-svg/index.web' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-svg/lib/extract/extractBrush' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-svg/lib/extract/extractClipPath' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-svg/lib/extract/extractColor' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-svg/lib/extract/extractFill' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-svg/lib/extract/extractGradient' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-svg/lib/extract/extractLengthList' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-svg/lib/extract/extractOpacity' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-svg/lib/extract/extractPolyPoints' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-svg/lib/extract/extractProps' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-svg/lib/extract/extractResponder' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-svg/lib/extract/extractStroke' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-svg/lib/extract/extractText' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-svg/lib/extract/extractTransform' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-svg/lib/extract/extractViewBox' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-svg/lib/extract/transform' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-svg/lib/Matrix2D' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-svg/lib/resolve' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-svg/lib/SvgTouchableMixin' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-svg/lib/units' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-svg/lib/util' {\n+ declare module.exports: any;\n+}\n+\n+// Filename aliases\n+declare module 'react-native-svg/elements/Circle.js' {\n+ declare module.exports: $Exports<'react-native-svg/elements/Circle'>;\n+}\n+declare module 'react-native-svg/elements/ClipPath.js' {\n+ declare module.exports: $Exports<'react-native-svg/elements/ClipPath'>;\n+}\n+declare module 'react-native-svg/elements/Defs.js' {\n+ declare module.exports: $Exports<'react-native-svg/elements/Defs'>;\n+}\n+declare module 'react-native-svg/elements/Ellipse.js' {\n+ declare module.exports: $Exports<'react-native-svg/elements/Ellipse'>;\n+}\n+declare module 'react-native-svg/elements/G.js' {\n+ declare module.exports: $Exports<'react-native-svg/elements/G'>;\n+}\n+declare module 'react-native-svg/elements/Image.js' {\n+ declare module.exports: $Exports<'react-native-svg/elements/Image'>;\n+}\n+declare module 'react-native-svg/elements/Line.js' {\n+ declare module.exports: $Exports<'react-native-svg/elements/Line'>;\n+}\n+declare module 'react-native-svg/elements/LinearGradient.js' {\n+ declare module.exports: $Exports<'react-native-svg/elements/LinearGradient'>;\n+}\n+declare module 'react-native-svg/elements/Mask.js' {\n+ declare module.exports: $Exports<'react-native-svg/elements/Mask'>;\n+}\n+declare module 'react-native-svg/elements/Path.js' {\n+ declare module.exports: $Exports<'react-native-svg/elements/Path'>;\n+}\n+declare module 'react-native-svg/elements/Pattern.js' {\n+ declare module.exports: $Exports<'react-native-svg/elements/Pattern'>;\n+}\n+declare module 'react-native-svg/elements/Polygon.js' {\n+ declare module.exports: $Exports<'react-native-svg/elements/Polygon'>;\n+}\n+declare module 'react-native-svg/elements/Polyline.js' {\n+ declare module.exports: $Exports<'react-native-svg/elements/Polyline'>;\n+}\n+declare module 'react-native-svg/elements/RadialGradient.js' {\n+ declare module.exports: $Exports<'react-native-svg/elements/RadialGradient'>;\n+}\n+declare module 'react-native-svg/elements/Rect.js' {\n+ declare module.exports: $Exports<'react-native-svg/elements/Rect'>;\n+}\n+declare module 'react-native-svg/elements/Shape.js' {\n+ declare module.exports: $Exports<'react-native-svg/elements/Shape'>;\n+}\n+declare module 'react-native-svg/elements/Stop.js' {\n+ declare module.exports: $Exports<'react-native-svg/elements/Stop'>;\n+}\n+declare module 'react-native-svg/elements/Svg.js' {\n+ declare module.exports: $Exports<'react-native-svg/elements/Svg'>;\n+}\n+declare module 'react-native-svg/elements/Symbol.js' {\n+ declare module.exports: $Exports<'react-native-svg/elements/Symbol'>;\n+}\n+declare module 'react-native-svg/elements/Text.js' {\n+ declare module.exports: $Exports<'react-native-svg/elements/Text'>;\n+}\n+declare module 'react-native-svg/elements/TextPath.js' {\n+ declare module.exports: $Exports<'react-native-svg/elements/TextPath'>;\n+}\n+declare module 'react-native-svg/elements/TSpan.js' {\n+ declare module.exports: $Exports<'react-native-svg/elements/TSpan'>;\n+}\n+declare module 'react-native-svg/elements/Use.js' {\n+ declare module.exports: $Exports<'react-native-svg/elements/Use'>;\n+}\n+declare module 'react-native-svg/index' {\n+ declare module.exports: $Exports<'react-native-svg'>;\n+}\n+declare module 'react-native-svg/index.js' {\n+ declare module.exports: $Exports<'react-native-svg'>;\n+}\n+declare module 'react-native-svg/index.web.js' {\n+ declare module.exports: $Exports<'react-native-svg/index.web'>;\n+}\n+declare module 'react-native-svg/lib/extract/extractBrush.js' {\n+ declare module.exports: $Exports<'react-native-svg/lib/extract/extractBrush'>;\n+}\n+declare module 'react-native-svg/lib/extract/extractClipPath.js' {\n+ declare module.exports: $Exports<'react-native-svg/lib/extract/extractClipPath'>;\n+}\n+declare module 'react-native-svg/lib/extract/extractColor.js' {\n+ declare module.exports: $Exports<'react-native-svg/lib/extract/extractColor'>;\n+}\n+declare module 'react-native-svg/lib/extract/extractFill.js' {\n+ declare module.exports: $Exports<'react-native-svg/lib/extract/extractFill'>;\n+}\n+declare module 'react-native-svg/lib/extract/extractGradient.js' {\n+ declare module.exports: $Exports<'react-native-svg/lib/extract/extractGradient'>;\n+}\n+declare module 'react-native-svg/lib/extract/extractLengthList.js' {\n+ declare module.exports: $Exports<'react-native-svg/lib/extract/extractLengthList'>;\n+}\n+declare module 'react-native-svg/lib/extract/extractOpacity.js' {\n+ declare module.exports: $Exports<'react-native-svg/lib/extract/extractOpacity'>;\n+}\n+declare module 'react-native-svg/lib/extract/extractPolyPoints.js' {\n+ declare module.exports: $Exports<'react-native-svg/lib/extract/extractPolyPoints'>;\n+}\n+declare module 'react-native-svg/lib/extract/extractProps.js' {\n+ declare module.exports: $Exports<'react-native-svg/lib/extract/extractProps'>;\n+}\n+declare module 'react-native-svg/lib/extract/extractResponder.js' {\n+ declare module.exports: $Exports<'react-native-svg/lib/extract/extractResponder'>;\n+}\n+declare module 'react-native-svg/lib/extract/extractStroke.js' {\n+ declare module.exports: $Exports<'react-native-svg/lib/extract/extractStroke'>;\n+}\n+declare module 'react-native-svg/lib/extract/extractText.js' {\n+ declare module.exports: $Exports<'react-native-svg/lib/extract/extractText'>;\n+}\n+declare module 'react-native-svg/lib/extract/extractTransform.js' {\n+ declare module.exports: $Exports<'react-native-svg/lib/extract/extractTransform'>;\n+}\n+declare module 'react-native-svg/lib/extract/extractViewBox.js' {\n+ declare module.exports: $Exports<'react-native-svg/lib/extract/extractViewBox'>;\n+}\n+declare module 'react-native-svg/lib/extract/transform.js' {\n+ declare module.exports: $Exports<'react-native-svg/lib/extract/transform'>;\n+}\n+declare module 'react-native-svg/lib/Matrix2D.js' {\n+ declare module.exports: $Exports<'react-native-svg/lib/Matrix2D'>;\n+}\n+declare module 'react-native-svg/lib/resolve.js' {\n+ declare module.exports: $Exports<'react-native-svg/lib/resolve'>;\n+}\n+declare module 'react-native-svg/lib/SvgTouchableMixin.js' {\n+ declare module.exports: $Exports<'react-native-svg/lib/SvgTouchableMixin'>;\n+}\n+declare module 'react-native-svg/lib/units.js' {\n+ declare module.exports: $Exports<'react-native-svg/lib/units'>;\n+}\n+declare module 'react-native-svg/lib/util.js' {\n+ declare module.exports: $Exports<'react-native-svg/lib/util'>;\n+}\n" }, { "change_type": "MODIFY", "old_path": "native/ios/Podfile", "new_path": "native/ios/Podfile", "diff": "@@ -42,6 +42,7 @@ target 'SquadCal' do\npod 'react-native-keyboard-input', :path => '../../node_modules/react-native-keyboard-input'\npod 'react-native-cameraroll', :path => '../../node_modules/@react-native-community/cameraroll'\npod 'lottie-react-native', :path => '../../node_modules/lottie-react-native'\n+ pod 'RNSVG', :path => '../../node_modules/react-native-svg'\ntarget 'SquadCalTests' do\ninherit! :search_paths\n" }, { "change_type": "MODIFY", "old_path": "native/ios/Podfile.lock", "new_path": "native/ios/Podfile.lock", "diff": "@@ -40,7 +40,7 @@ PODS:\n- React/Core (= 0.59.4)\n- react-native-async-storage (1.3.0):\n- React\n- - react-native-cameraroll (1.0.4):\n+ - react-native-cameraroll (1.0.5):\n- React\n- react-native-exit-app (0.1.0):\n- React\n@@ -122,6 +122,8 @@ PODS:\n- React\n- RNScreens (1.0.0-alpha.17):\n- React\n+ - RNSVG (9.5.1):\n+ - React\n- RNVectorIcons (4.6.0):\n- React\n- SDWebImage/Core (4.4.6)\n@@ -164,6 +166,7 @@ DEPENDENCIES:\n- RNKeychain (from `../../node_modules/react-native-keychain`)\n- RNReanimated (from `../../node_modules/react-native-reanimated`)\n- RNScreens (from `../../node_modules/react-native-screens`)\n+ - RNSVG (from `../../node_modules/react-native-svg`)\n- RNVectorIcons (from `../../node_modules/react-native-vector-icons`)\n- yoga (from `../../node_modules/react-native/ReactCommon/yoga`)\n@@ -217,6 +220,8 @@ EXTERNAL SOURCES:\n:path: \"../../node_modules/react-native-reanimated\"\nRNScreens:\n:path: \"../../node_modules/react-native-screens\"\n+ RNSVG:\n+ :path: \"../../node_modules/react-native-svg\"\nRNVectorIcons:\n:path: \"../../node_modules/react-native-vector-icons\"\nyoga:\n@@ -234,7 +239,7 @@ SPEC CHECKSUMS:\nlottie-react-native: 3d8181d43619b1fe804c828bd5a09d20fe8bdea7\nReact: 5cb71fb1a15b5ce04794ab49e24b48ebe4c94e65\nreact-native-async-storage: 6aa3086d7b4f45e49adc8e087b4a03e47279aa1b\n- react-native-cameraroll: 63207a7daac2786786b301545a709c19f285aec6\n+ react-native-cameraroll: b1faef9f2ea27b07bdf818b8043909a93f797eca\nreact-native-exit-app: 3f9b8c2f2071f7e51fba21dfac9fc235c1764e84\nreact-native-fast-image: 21d2d84a46b12cacbe7958ab6414fe828c094f82\nreact-native-keyboard-input: 83520632cab76a827bdf1db0aa1c87a047f7c18b\n@@ -248,10 +253,11 @@ SPEC CHECKSUMS:\nRNKeychain: 3aa3cf891a09a0d18d306862ab2bb9e106079b24\nRNReanimated: c8dd490ca98a4edcba229bfa49f2516c95a43afb\nRNScreens: 000c9e6e31c9a483688943155107e4ca9394d37a\n+ RNSVG: 0eb087cfb5d7937be93c45b163b26352a647e681\nRNVectorIcons: a3c395829c56e2cb054a0730126298bf805a2dca\nSDWebImage: 3f3f0c02f09798048c47a5ed0a13f17b063572d8\nyoga: 596e61c9b57751d08a22b07aba310dbd3e65ab75\n-PODFILE CHECKSUM: 4e4591f1770ff5cc15c73ae1a206faacb23b2a5b\n+PODFILE CHECKSUM: 2c1283b3653368eadc003796b177c252a2323cde\nCOCOAPODS: 1.6.1\n" }, { "change_type": "MODIFY", "old_path": "native/package.json", "new_path": "native/package.json", "diff": "\"react-native-screens\": \"1.0.0-alpha.17\",\n\"react-native-segmented-control-tab\": \"^3.2.1\",\n\"react-native-splash-screen\": \"^3.1.1\",\n+ \"react-native-svg\": \"^9.5.1\",\n\"react-native-vector-icons\": \"^4.5.0\",\n\"react-navigation\": \"3.5.1\",\n\"react-navigation-redux-helpers\": \"^3.0.2\",\n" }, { "change_type": "MODIFY", "old_path": "yarn.lock", "new_path": "yarn.lock", "diff": "@@ -10699,6 +10699,11 @@ react-native-splash-screen@^3.1.1:\nresolved \"https://registry.yarnpkg.com/react-native-splash-screen/-/react-native-splash-screen-3.1.1.tgz#1a4e46c9fdce53ff52af2a2cb4181788c4e30b30\"\nintegrity sha512-PU2YocOSGbLjL9Vgcq/cwMNuHHKNjjuPpa1IPMuWo+6EB/fSZ5VOmxSa7+eucQe3631s3NhGuk3eHKahU03a4Q==\n+react-native-svg@^9.5.1:\n+ version \"9.5.1\"\n+ resolved \"https://registry.yarnpkg.com/react-native-svg/-/react-native-svg-9.5.1.tgz#eb21fa7eb5d71649620541e6549c6ed425d80240\"\n+ integrity sha512-cRGfomzG/5LEwuJ6ct3m5yccckeI9aj8BNYwDPVxOeJ84LuJuvk5OqcjlYNeEzOWmWiH+QrFXfpLH1ag04bUeQ==\n+\nreact-native-swipe-gestures@^1.0.2:\nversion \"1.0.2\"\nresolved \"https://registry.yarnpkg.com/react-native-swipe-gestures/-/react-native-swipe-gestures-1.0.2.tgz#914e1a72a94bc55b322b4622a01103ab879296dd\"\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] react-native-svg
129,187
10.06.2019 15:43:53
14,400
9835f2225fc585cebf3c7dfb072ac23f4b54ee68
[native] Update lodash libdef
[ { "change_type": "MODIFY", "old_path": "native/flow-typed/npm/lodash_v4.x.x.js", "new_path": "native/flow-typed/npm/lodash_v4.x.x.js", "diff": "-// flow-typed signature: 978ec408ef4dc26808325571d235d3ca\n-// flow-typed version: 9f33da9d84/lodash_v4.x.x/flow_>=v0.63.x\n+// flow-typed signature: 8b15b6ecab988d6153afcfcf2876bbed\n+// flow-typed version: 07f4c5ae3d/lodash_v4.x.x/flow_>=v0.63.x\ndeclare module \"lodash\" {\ndeclare type Path = $ReadOnlyArray<string | number> | string | number;\n@@ -1245,7 +1245,7 @@ declare module \"lodash\" {\n): Object;\nomitBy<A, T>(object: void | null, predicate?: ?OPredicate<A, T>): {};\npick(object?: ?Object, ...props: Array<string>): Object;\n- pick(object?: ?Object, props: Array<string>): Object;\n+ pick(object?: ?Object, props: $ReadOnlyArray<string>): Object;\npickBy<A, T: { [id: any]: A } | { [id: number]: A }>(\nobject: T,\npredicate?: ?OPredicate<A, T>\n@@ -2946,8 +2946,10 @@ declare module \"lodash/fp\" {\npredicate: OPredicate<A>\n): (object: T) => Object;\nomitBy<A, T: { [id: any]: A }>(predicate: OPredicate<A>, object: T): Object;\n- pick(props: Array<string>): (object: Object) => Object;\n- pick(props: Array<string>, object: Object): Object;\n+ pick(...props: Array<string | {}>): Object;\n+ pick(props: $ReadOnlyArray<string>, object: Object): Object;\n+ pick(...props: Array<string>): (object: Object) => Object;\n+ pick(props: $ReadOnlyArray<string>): (object: Object) => Object;\npickAll(props: Array<string>): (object: Object) => Object;\npickAll(props: Array<string>, object: Object): Object;\npickBy<A, T: { [id: any]: A }>(\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Update lodash libdef
129,187
10.06.2019 15:46:28
14,400
6cc60e9c739a8b54614983786195c66d6fd12c64
[native] react-native-circular-progress
[ { "change_type": "ADD", "old_path": null, "new_path": "native/flow-typed/npm/react-native-circular-progress_vx.x.x.js", "diff": "+// flow-typed signature: 3d557683a8bc8bb1049681b512e99651\n+// flow-typed version: <<STUB>>/react-native-circular-progress_v^1.1.0/flow_v0.92.0\n+\n+/**\n+ * This is an autogenerated libdef stub for:\n+ *\n+ * 'react-native-circular-progress'\n+ *\n+ * Fill this stub out by replacing all the `any` types.\n+ *\n+ * Once filled out, we encourage you to share your work with the\n+ * community by sending a pull request to:\n+ * https://github.com/flowtype/flow-typed\n+ */\n+\n+declare module 'react-native-circular-progress' {\n+ declare module.exports: any;\n+}\n+\n+/**\n+ * We include stubs for each file inside this npm package in case you need to\n+ * require those files directly. Feel free to delete any files that aren't\n+ * needed.\n+ */\n+declare module 'react-native-circular-progress/src/AnimatedCircularProgress' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-circular-progress/src/CircularProgress' {\n+ declare module.exports: any;\n+}\n+\n+// Filename aliases\n+declare module 'react-native-circular-progress/index' {\n+ declare module.exports: $Exports<'react-native-circular-progress'>;\n+}\n+declare module 'react-native-circular-progress/index.js' {\n+ declare module.exports: $Exports<'react-native-circular-progress'>;\n+}\n+declare module 'react-native-circular-progress/src/AnimatedCircularProgress.js' {\n+ declare module.exports: $Exports<'react-native-circular-progress/src/AnimatedCircularProgress'>;\n+}\n+declare module 'react-native-circular-progress/src/CircularProgress.js' {\n+ declare module.exports: $Exports<'react-native-circular-progress/src/CircularProgress'>;\n+}\n" }, { "change_type": "MODIFY", "old_path": "native/package.json", "new_path": "native/package.json", "diff": "\"lottie-react-native\": \"^2.6.1\",\n\"react\": \"16.8.3\",\n\"react-native\": \"0.59.4\",\n+ \"react-native-circular-progress\": \"^1.1.0\",\n\"react-native-exit-app\": \"git+https://github.com/wumke/react-native-exit-app.git#460d40aaacb1aa95d7ed5f21e7906ba930c74301\",\n\"react-native-fast-image\": \"^5.2.0\",\n\"react-native-firebase\": \"^5.3.1\",\n" }, { "change_type": "MODIFY", "old_path": "yarn.lock", "new_path": "yarn.lock", "diff": "@@ -10579,6 +10579,13 @@ react-linkify@^0.2.2:\nprop-types \"^15.5.8\"\ntlds \"^1.57.0\"\n+react-native-circular-progress@^1.1.0:\n+ version \"1.1.0\"\n+ resolved \"https://registry.yarnpkg.com/react-native-circular-progress/-/react-native-circular-progress-1.1.0.tgz#5cb3efe570796226c59bf15a35250fb8b0d45025\"\n+ integrity sha512-4Fx7hDGUJyLHTc9fThnXmsW+ea3wjNC8xUwoTCnaL6W29ki9IJQZY9QiDzwtReDxHW6CvNiEzeYB3obNgOfUrQ==\n+ dependencies:\n+ prop-types \"^15.6.2\"\n+\n\"react-native-exit-app@git+https://github.com/wumke/react-native-exit-app.git#460d40aaacb1aa95d7ed5f21e7906ba930c74301\":\nversion \"1.0.0\"\nresolved \"git+https://github.com/wumke/react-native-exit-app.git#460d40aaacb1aa95d7ed5f21e7906ba930c74301\"\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] react-native-circular-progress
129,187
12.06.2019 20:34:15
14,400
5c0f52ade381d73ab6d04fce06b9e896ddac23c7
[native] Filter CameraRoll.getPhotos to our MIME types
[ { "change_type": "MODIFY", "old_path": "native/chat/chat-input-state-container.react.js", "new_path": "native/chat/chat-input-state-container.react.js", "diff": "@@ -260,6 +260,15 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\n}));\nconst localMessageID = `local${this.props.nextLocalID}`;\n+ if (imageInfos.length < validationResults.length) {\n+ // Since we filter our MIME types in our calls to CameraRoll,\n+ // this should never be triggered\n+ console.log('unexpected MIME type found');\n+ }\n+ if (imageInfos.length === 0) {\n+ return;\n+ }\n+\nconst pendingUploads = {};\nfor (let { localID } of imageInfos) {\npendingUploads[localID] = {\n" }, { "change_type": "MODIFY", "old_path": "native/media/image-gallery-keyboard.react.js", "new_path": "native/media/image-gallery-keyboard.react.js", "diff": "@@ -24,6 +24,7 @@ import CameraRoll from '@react-native-community/cameraroll';\nimport Icon from 'react-native-vector-icons/FontAwesome';\nimport { connect } from 'lib/utils/redux-utils';\n+import { mimeTypesToMediaTypes } from 'lib/utils/media-utils';\nimport { store } from '../redux/redux-setup';\nimport {\n@@ -172,6 +173,7 @@ class ImageGalleryKeyboard extends React.PureComponent<Props, State> {\nif (after) {\nbase.after = after;\n}\n+ base.mimeTypes = Object.keys(mimeTypesToMediaTypes);\nreturn base;\n}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Filter CameraRoll.getPhotos to our MIME types
129,187
12.06.2019 20:36:23
14,400
a3baee5b588e49921cb8da8771a8ae130e34dc69
[native] Fix bug in passing pendingUpload to MultimediaMessage
[ { "change_type": "MODIFY", "old_path": "native/chat/multimedia-message.react.js", "new_path": "native/chat/multimedia-message.react.js", "diff": "@@ -224,8 +224,9 @@ class MultimediaMessage extends React.PureComponent<Props> {\n};\nconst { chatInputState } = this.props;\nconst pendingUpload = chatInputState\n- && chatInputState[id]\n- && chatInputState[id][media.id];\n+ && chatInputState.pendingUploads\n+ && chatInputState.pendingUploads[id]\n+ && chatInputState.pendingUploads[id][media.id];\nreturn (\n<MultimediaMessageMultimedia\nmediaInfo={mediaInfo}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Fix bug in passing pendingUpload to MultimediaMessage
129,187
12.06.2019 20:39:26
14,400
c6e63c25564f988d6afdfa9f710c6c21f8e7791d
[native] Convert image/heic to image/jpeg on iOS quality=0.7
[ { "change_type": "MODIFY", "old_path": "native/chat/chat-input-state-container.react.js", "new_path": "native/chat/chat-input-state-container.react.js", "diff": "@@ -14,7 +14,7 @@ import {\ntype RawMultimediaMessageInfo,\ntype SendMessageResult,\n} from 'lib/types/message-types';\n-import type { NativeImageInfo } from '../utils/media-utils';\n+import type { MediaValidationResult } from '../utils/media-utils';\nimport * as React from 'react';\nimport PropTypes from 'prop-types';\n@@ -33,11 +33,11 @@ import {\n} from 'lib/actions/message-actions';\nimport { ChatInputStateContext } from './chat-input-state';\n-import { validateMedia } from '../utils/media-utils';\n+import { validateMedia, convertMedia } from '../utils/media-utils';\nlet nextLocalUploadID = 0;\ntype ImageInfo = {|\n- ...NativeImageInfo,\n+ ...$Exact<MediaValidationResult>,\nlocalID: string,\n|};\ntype CompletedUploads = { [localMessageID: string]: ?Set<string> };\n@@ -317,12 +317,22 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\n}\nasync uploadFile(localMessageID: string, imageInfo: ImageInfo) {\n- const { localID, uri: nativeURI, dataURI, name, mime } = imageInfo;\n- const uri = dataURI ? dataURI : nativeURI;\n+ const { localID } = imageInfo;\n+ const conversionResult = await convertMedia(imageInfo);\n+ if (!conversionResult) {\n+ this.handleUploadFailure(\n+ localMessageID,\n+ localID,\n+ new Error(\"conversion failed\"),\n+ );\n+ return;\n+ }\n+ const { uploadURI, name, mime, mediaType } = conversionResult;\n+\nlet result;\ntry {\nresult = await this.props.uploadMultimedia(\n- { uri, name, type: mime },\n+ { uri: uploadURI, name, type: mime },\n(percent: number) => this.setProgress(\nlocalMessageID,\nlocalID,\n@@ -341,6 +351,7 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\nmediaUpdate: {\nid: result.id,\nuri: result.uri,\n+ mediaType,\n},\n},\n);\n" }, { "change_type": "MODIFY", "old_path": "native/ios/Podfile", "new_path": "native/ios/Podfile", "diff": "@@ -43,6 +43,7 @@ target 'SquadCal' do\npod 'react-native-cameraroll', :path => '../../node_modules/@react-native-community/cameraroll'\npod 'lottie-react-native', :path => '../../node_modules/lottie-react-native'\npod 'RNSVG', :path => '../../node_modules/react-native-svg'\n+ pod 'RNHeicConverter', :path => '../../node_modules/react-native-heic-converter/ios'\ntarget 'SquadCalTests' do\ninherit! :search_paths\n" }, { "change_type": "MODIFY", "old_path": "native/ios/Podfile.lock", "new_path": "native/ios/Podfile.lock", "diff": "@@ -116,6 +116,8 @@ PODS:\n- React/RCTBlob\n- RNGestureHandler (1.1.0):\n- React\n+ - RNHeicConverter (1.0.0):\n+ - React\n- RNKeychain (3.0.0):\n- React\n- RNReanimated (1.0.1):\n@@ -163,6 +165,7 @@ DEPENDENCIES:\n- React/RCTText (from `../../node_modules/react-native`)\n- React/RCTWebSocket (from `../../node_modules/react-native`)\n- RNGestureHandler (from `../../node_modules/react-native-gesture-handler`)\n+ - RNHeicConverter (from `../../node_modules/react-native-heic-converter/ios`)\n- RNKeychain (from `../../node_modules/react-native-keychain`)\n- RNReanimated (from `../../node_modules/react-native-reanimated`)\n- RNScreens (from `../../node_modules/react-native-screens`)\n@@ -214,6 +217,8 @@ EXTERNAL SOURCES:\n:path: \"../../node_modules/react-native-splash-screen\"\nRNGestureHandler:\n:path: \"../../node_modules/react-native-gesture-handler\"\n+ RNHeicConverter:\n+ :path: \"../../node_modules/react-native-heic-converter/ios\"\nRNKeychain:\n:path: \"../../node_modules/react-native-keychain\"\nRNReanimated:\n@@ -250,6 +255,7 @@ SPEC CHECKSUMS:\nreact-native-orientation-locker: 132a63bab4dddd2a5709f6f7935ad9676b0af7c5\nreact-native-splash-screen: 353334c5ae82d8c74501ea7cbb916cb7cb20c8bf\nRNGestureHandler: 8a75e1d2f83d73aba148653252953e4bcf363b98\n+ RNHeicConverter: 6cee6a94c1331cb136cdffe9e791491b00aae4f9\nRNKeychain: 3aa3cf891a09a0d18d306862ab2bb9e106079b24\nRNReanimated: c8dd490ca98a4edcba229bfa49f2516c95a43afb\nRNScreens: 000c9e6e31c9a483688943155107e4ca9394d37a\n@@ -258,6 +264,6 @@ SPEC CHECKSUMS:\nSDWebImage: 3f3f0c02f09798048c47a5ed0a13f17b063572d8\nyoga: 596e61c9b57751d08a22b07aba310dbd3e65ab75\n-PODFILE CHECKSUM: 2c1283b3653368eadc003796b177c252a2323cde\n+PODFILE CHECKSUM: e83a37fa952cddae025cbd6b30a3e88d1a488a45\nCOCOAPODS: 1.6.1\n" }, { "change_type": "MODIFY", "old_path": "native/package.json", "new_path": "native/package.json", "diff": "\"react-native-firebase\": \"^5.3.1\",\n\"react-native-floating-action\": \"^1.9.0\",\n\"react-native-gesture-handler\": \"git+https://git@github.com/kmagiera/react-native-gesture-handler.git#99dce5e787f0c0e87cf748bc78d32fb65fcdb0e8\",\n+ \"react-native-heic-converter\": \"^1.2.0\",\n\"react-native-hyperlink\": \"git+https://git@github.com/ashoat/react-native-hyperlink.git#both\",\n\"react-native-in-app-notification\": \"^2.1.0\",\n\"react-native-keyboard-input\": \"^5.3.1\",\n" }, { "change_type": "MODIFY", "old_path": "native/utils/media-utils.js", "new_path": "native/utils/media-utils.js", "diff": "@@ -5,8 +5,33 @@ import type { GalleryImageInfo } from '../media/image-gallery-image.react';\nimport { Platform } from 'react-native';\nimport base64 from 'base-64';\n+import HeicConverter from 'react-native-heic-converter';\n-import { fileInfoFromData } from 'lib/utils/media-utils';\n+import {\n+ fileInfoFromData,\n+ mimeTypesToMediaTypes,\n+} from 'lib/utils/media-utils';\n+\n+type ReactNativeBlob = Blob & { data: { type: string, name: string } };\n+export type MediaValidationResult = {\n+ uri: string,\n+ dimensions: Dimensions,\n+ mediaType: MediaType,\n+ blob: ReactNativeBlob,\n+};\n+async function validateMedia(\n+ imageInfo: GalleryImageInfo,\n+): Promise<?MediaValidationResult> {\n+ const { uri, ...dimensions } = imageInfo;\n+ const response = await fetch(uri);\n+ const blob = await response.blob();\n+ const reportedMIME = blob.data.type;\n+ const mediaType = mimeTypesToMediaTypes[reportedMIME];\n+ if (!mediaType) {\n+ return null;\n+ }\n+ return { uri, dimensions, mediaType, blob };\n+}\nfunction blobToDataURI(blob: Blob): Promise<string> {\nconst fileReader = new FileReader();\n@@ -57,20 +82,39 @@ function dataURIToIntArray(dataURI: string): Uint8Array {\nreturn stringToIntArray(data);\n}\n-export type NativeImageInfo = {|\n- uri: string,\n- dataURI: ?string,\n- dimensions: Dimensions,\n+function getHEICAssetLibraryURI(uri: string) {\n+ if (!uri.startsWith('ph://')) {\n+ return uri;\n+ }\n+ const photoKitID = uri.substr(5);\n+ const hash = photoKitID.split('/')[0];\n+ return `assets-library://asset/asset.heic?id=${hash}&ext=heic`;\n+}\n+\n+type MediaConversionResult = {|\n+ uploadURI: string,\nname: string,\nmime: string,\nmediaType: MediaType,\n|};\n-async function validateMedia(\n- imageInfo: GalleryImageInfo,\n-): Promise<?NativeImageInfo> {\n- const { uri, ...dimensions } = imageInfo;\n- const response = await fetch(uri);\n- const blob = await response.blob();\n+async function convertMedia(\n+ validationResult: MediaValidationResult,\n+): Promise<?MediaConversionResult> {\n+ const { uri } = validationResult;\n+ let { blob } = validationResult;\n+\n+ const reportedMIME = blob.data.type;\n+ if (Platform.OS === \"ios\" && reportedMIME === \"image/heic\") {\n+ const assetLibraryURI = getHEICAssetLibraryURI(uri);\n+ const { success, path } = await HeicConverter.convert({\n+ path: assetLibraryURI,\n+ quality: 0.7,\n+ });\n+ if (success) {\n+ const jpegResponse = await fetch(path);\n+ blob = await jpegResponse.blob();\n+ }\n+ }\nconst dataURI = await blobToDataURI(blob);\nconst intArray = dataURIToIntArray(dataURI);\n@@ -83,13 +127,7 @@ async function validateMedia(\nconst { name, mime, mediaType } = fileInfo;\nreturn {\n- uri,\n- // On iOS, the URI we receive from the native side doesn't render with Image\n- // and can't upload with fetch. Thus we need to use the dataURI for those\n- // things, but we have to be careful to avoid storing it in Redux, as it's\n- // quite long.\n- dataURI: Platform.OS === \"ios\" ? dataURI : null,\n- dimensions,\n+ uploadURI: Platform.OS === \"ios\" ? dataURI : uri,\nname,\nmime,\nmediaType,\n@@ -98,4 +136,5 @@ async function validateMedia(\nexport {\nvalidateMedia,\n+ convertMedia,\n};\n" }, { "change_type": "ADD", "old_path": null, "new_path": "patches/react-native-heic-converter+1.2.0.patch", "diff": "+diff --git a/node_modules/react-native-heic-converter/ios/RNHeicConverter.podspec b/node_modules/react-native-heic-converter/ios/RNHeicConverter.podspec\n+index 36a41ac..4861d6c 100644\n+--- a/node_modules/react-native-heic-converter/ios/RNHeicConverter.podspec\n++++ b/node_modules/react-native-heic-converter/ios/RNHeicConverter.podspec\n+@@ -4,15 +4,15 @@ Pod::Spec.new do |s|\n+ s.version = \"1.0.0\"\n+ s.summary = \"RNHeicConverter\"\n+ s.description = <<-DESC\n+- RNHeicConverter\n++ RNHeicConverter2\n+ DESC\n+- s.homepage = \"\"\n++ s.homepage = \"https://github.com/maxim-kolesnikov/react-native-heic-converter\"\n+ s.license = \"MIT\"\n+ # s.license = { :type => \"MIT\", :file => \"FILE_LICENSE\" }\n+ s.author = { \"author\" => \"author@domain.cn\" }\n+ s.platform = :ios, \"7.0\"\n+- s.source = { :git => \"https://github.com/author/RNHeicConverter.git\", :tag => \"master\" }\n+- s.source_files = \"RNHeicConverter/**/*.{h,m}\"\n++ s.source = { :git => \"https://github.com/maxim-kolesnikov/react-native-heic-converter.git\", :tag => s.version }\n++ s.source_files = \"**/*.{h,m}\"\n+ s.requires_arc = true\n+\n+\n" }, { "change_type": "MODIFY", "old_path": "yarn.lock", "new_path": "yarn.lock", "diff": "@@ -10616,6 +10616,11 @@ react-native-floating-action@^1.9.0:\ninvariant \"^2.2.2\"\nprop-types \"^15.5.10\"\n+react-native-heic-converter@^1.2.0:\n+ version \"1.2.0\"\n+ resolved \"https://registry.yarnpkg.com/react-native-heic-converter/-/react-native-heic-converter-1.2.0.tgz#1391b37a5ab0c21181561a7529271fd89809fc65\"\n+ integrity sha512-xMx3ASil698ABJFLXHkYTvFzouO4Y7P+rQ7UEzr1qgfkgcua4vOCvt/D2y94YJ7LWCKEo0XNnJir1+ThpU/15Q==\n+\n\"react-native-hyperlink@git+https://git@github.com/ashoat/react-native-hyperlink.git#both\":\nversion \"0.0.12\"\nresolved \"git+https://git@github.com/ashoat/react-native-hyperlink.git#0c872d5be30ba6382c926e78ad1545a97f586f85\"\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Convert image/heic to image/jpeg on iOS quality=0.7
129,187
12.06.2019 22:13:04
14,400
9a6f987857056d76bd8a8acdc688fff0bd3e7cbe
[native] Use react-native-image-resizer to resize Also to convert from HEIC
[ { "change_type": "MODIFY", "old_path": "native/android/app/build.gradle", "new_path": "native/android/app/build.gradle", "diff": "@@ -147,6 +147,7 @@ android {\n}\ndependencies {\n+ implementation project(':react-native-image-resizer')\nimplementation project(':react-native-svg')\nimplementation project(':lottie-react-native')\nimplementation project(':@react-native-community_cameraroll')\n" }, { "change_type": "MODIFY", "old_path": "native/android/app/src/main/java/org/squadcal/MainApplication.java", "new_path": "native/android/app/src/main/java/org/squadcal/MainApplication.java", "diff": "@@ -3,6 +3,7 @@ package org.squadcal;\nimport android.app.Application;\nimport com.facebook.react.ReactApplication;\n+import fr.bamlab.rnimageresizer.ImageResizerPackage;\nimport com.horcrux.svg.SvgPackage;\nimport com.airbnb.android.react.lottie.LottiePackage;\nimport com.reactnativecommunity.cameraroll.CameraRollPackage;\n@@ -41,6 +42,7 @@ public class MainApplication extends Application implements ReactApplication {\nprotected List<ReactPackage> getPackages() {\nreturn Arrays.<ReactPackage>asList(\nnew MainReactPackage(),\n+ new ImageResizerPackage(),\nnew SvgPackage(),\nnew LottiePackage(),\nnew CameraRollPackage(),\n" }, { "change_type": "MODIFY", "old_path": "native/android/settings.gradle", "new_path": "native/android/settings.gradle", "diff": "rootProject.name = 'SquadCal'\n+include ':react-native-image-resizer'\n+project(':react-native-image-resizer').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-image-resizer/android')\ninclude ':react-native-svg'\nproject(':react-native-svg').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-svg/android')\ninclude ':lottie-react-native'\n" }, { "change_type": "MODIFY", "old_path": "native/chat/chat-input-state-container.react.js", "new_path": "native/chat/chat-input-state-container.react.js", "diff": "@@ -327,9 +327,16 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\n);\nreturn;\n}\n- const { uploadURI, name, mime, mediaType } = conversionResult;\n+ const {\n+ uploadURI,\n+ shouldDisposePath,\n+ name,\n+ mime,\n+ mediaType,\n+ } = conversionResult;\nlet result;\n+ let success = true;\ntry {\nresult = await this.props.uploadMultimedia(\n{ uri: uploadURI, name, type: mime },\n@@ -341,6 +348,9 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\n);\n} catch (e) {\nthis.handleUploadFailure(localMessageID, localID, e);\n+ success = false;\n+ }\n+ if (!success) {\nreturn;\n}\nthis.props.dispatchActionPayload(\n" }, { "change_type": "MODIFY", "old_path": "native/ios/Podfile", "new_path": "native/ios/Podfile", "diff": "@@ -43,7 +43,7 @@ target 'SquadCal' do\npod 'react-native-cameraroll', :path => '../../node_modules/@react-native-community/cameraroll'\npod 'lottie-react-native', :path => '../../node_modules/lottie-react-native'\npod 'RNSVG', :path => '../../node_modules/react-native-svg'\n- pod 'RNHeicConverter', :path => '../../node_modules/react-native-heic-converter/ios'\n+ pod 'react-native-image-resizer', :path => '../../node_modules/react-native-image-resizer'\ntarget 'SquadCalTests' do\ninherit! :search_paths\n" }, { "change_type": "MODIFY", "old_path": "native/ios/Podfile.lock", "new_path": "native/ios/Podfile.lock", "diff": "@@ -50,6 +50,8 @@ PODS:\n- SDWebImage/Core\n- SDWebImage/GIF\n- SDWebImage/WebP\n+ - react-native-image-resizer (1.0.1):\n+ - React\n- react-native-keyboard-input (5.3.1):\n- React\n- react-native-keyboard-tracking-view\n@@ -116,8 +118,6 @@ PODS:\n- React/RCTBlob\n- RNGestureHandler (1.1.0):\n- React\n- - RNHeicConverter (1.0.0):\n- - React\n- RNKeychain (3.0.0):\n- React\n- RNReanimated (1.0.1):\n@@ -146,6 +146,7 @@ DEPENDENCIES:\n- \"react-native-cameraroll (from `../../node_modules/@react-native-community/cameraroll`)\"\n- react-native-exit-app (from `../../node_modules/react-native-exit-app`)\n- react-native-fast-image (from `../../node_modules/react-native-fast-image`)\n+ - react-native-image-resizer (from `../../node_modules/react-native-image-resizer`)\n- react-native-keyboard-input (from `../../node_modules/react-native-keyboard-input`)\n- react-native-keyboard-tracking-view (from `../../node_modules/react-native-keyboard-tracking-view`)\n- \"react-native-netinfo (from `../../node_modules/@react-native-community/netinfo`)\"\n@@ -165,7 +166,6 @@ DEPENDENCIES:\n- React/RCTText (from `../../node_modules/react-native`)\n- React/RCTWebSocket (from `../../node_modules/react-native`)\n- RNGestureHandler (from `../../node_modules/react-native-gesture-handler`)\n- - RNHeicConverter (from `../../node_modules/react-native-heic-converter/ios`)\n- RNKeychain (from `../../node_modules/react-native-keychain`)\n- RNReanimated (from `../../node_modules/react-native-reanimated`)\n- RNScreens (from `../../node_modules/react-native-screens`)\n@@ -201,6 +201,8 @@ EXTERNAL SOURCES:\n:path: \"../../node_modules/react-native-exit-app\"\nreact-native-fast-image:\n:path: \"../../node_modules/react-native-fast-image\"\n+ react-native-image-resizer:\n+ :path: \"../../node_modules/react-native-image-resizer\"\nreact-native-keyboard-input:\n:path: \"../../node_modules/react-native-keyboard-input\"\nreact-native-keyboard-tracking-view:\n@@ -217,8 +219,6 @@ EXTERNAL SOURCES:\n:path: \"../../node_modules/react-native-splash-screen\"\nRNGestureHandler:\n:path: \"../../node_modules/react-native-gesture-handler\"\n- RNHeicConverter:\n- :path: \"../../node_modules/react-native-heic-converter/ios\"\nRNKeychain:\n:path: \"../../node_modules/react-native-keychain\"\nRNReanimated:\n@@ -247,6 +247,7 @@ SPEC CHECKSUMS:\nreact-native-cameraroll: b1faef9f2ea27b07bdf818b8043909a93f797eca\nreact-native-exit-app: 3f9b8c2f2071f7e51fba21dfac9fc235c1764e84\nreact-native-fast-image: 21d2d84a46b12cacbe7958ab6414fe828c094f82\n+ react-native-image-resizer: 48eb06a18a6d0a632ffa162a51ca61a68fb5322f\nreact-native-keyboard-input: 83520632cab76a827bdf1db0aa1c87a047f7c18b\nreact-native-keyboard-tracking-view: bf1f758a529e1e87f8a76044414b168251d59d37\nreact-native-netinfo: d6ff19d6b0fff3c617d01949f87e9976e7ecc9a9\n@@ -255,7 +256,6 @@ SPEC CHECKSUMS:\nreact-native-orientation-locker: 132a63bab4dddd2a5709f6f7935ad9676b0af7c5\nreact-native-splash-screen: 353334c5ae82d8c74501ea7cbb916cb7cb20c8bf\nRNGestureHandler: 8a75e1d2f83d73aba148653252953e4bcf363b98\n- RNHeicConverter: 6cee6a94c1331cb136cdffe9e791491b00aae4f9\nRNKeychain: 3aa3cf891a09a0d18d306862ab2bb9e106079b24\nRNReanimated: c8dd490ca98a4edcba229bfa49f2516c95a43afb\nRNScreens: 000c9e6e31c9a483688943155107e4ca9394d37a\n@@ -264,6 +264,6 @@ SPEC CHECKSUMS:\nSDWebImage: 3f3f0c02f09798048c47a5ed0a13f17b063572d8\nyoga: 596e61c9b57751d08a22b07aba310dbd3e65ab75\n-PODFILE CHECKSUM: e83a37fa952cddae025cbd6b30a3e88d1a488a45\n+PODFILE CHECKSUM: c854be7f2da33ebedc540e03582c25dd1d7818d9\nCOCOAPODS: 1.6.1\n" }, { "change_type": "MODIFY", "old_path": "native/package.json", "new_path": "native/package.json", "diff": "\"react-native-firebase\": \"^5.3.1\",\n\"react-native-floating-action\": \"^1.9.0\",\n\"react-native-gesture-handler\": \"git+https://git@github.com/kmagiera/react-native-gesture-handler.git#99dce5e787f0c0e87cf748bc78d32fb65fcdb0e8\",\n- \"react-native-heic-converter\": \"^1.2.0\",\n\"react-native-hyperlink\": \"git+https://git@github.com/ashoat/react-native-hyperlink.git#both\",\n+ \"react-native-image-resizer\": \"^1.0.1\",\n\"react-native-in-app-notification\": \"^2.1.0\",\n\"react-native-keyboard-input\": \"^5.3.1\",\n\"react-native-keychain\": \"^3.0.0\",\n" }, { "change_type": "MODIFY", "old_path": "native/utils/media-utils.js", "new_path": "native/utils/media-utils.js", "diff": "@@ -5,14 +5,16 @@ import type { GalleryImageInfo } from '../media/image-gallery-image.react';\nimport { Platform } from 'react-native';\nimport base64 from 'base-64';\n-import HeicConverter from 'react-native-heic-converter';\n+import ImageResizer from 'react-native-image-resizer';\nimport {\nfileInfoFromData,\nmimeTypesToMediaTypes,\n} from 'lib/utils/media-utils';\n-type ReactNativeBlob = Blob & { data: { type: string, name: string } };\n+type ReactNativeBlob =\n+ & Blob\n+ & { data: { type: string, name: string, size: number } };\nexport type MediaValidationResult = {\nuri: string,\ndimensions: Dimensions,\n@@ -82,17 +84,9 @@ function dataURIToIntArray(dataURI: string): Uint8Array {\nreturn stringToIntArray(data);\n}\n-function getHEICAssetLibraryURI(uri: string) {\n- if (!uri.startsWith('ph://')) {\n- return uri;\n- }\n- const photoKitID = uri.substr(5);\n- const hash = photoKitID.split('/')[0];\n- return `assets-library://asset/asset.heic?id=${hash}&ext=heic`;\n-}\n-\ntype MediaConversionResult = {|\nuploadURI: string,\n+ shouldDisposePath: ?string,\nname: string,\nmime: string,\nmediaType: MediaType,\n@@ -103,17 +97,26 @@ async function convertMedia(\nconst { uri } = validationResult;\nlet { blob } = validationResult;\n- const reportedMIME = blob.data.type;\n- if (Platform.OS === \"ios\" && reportedMIME === \"image/heic\") {\n- const assetLibraryURI = getHEICAssetLibraryURI(uri);\n- const { success, path } = await HeicConverter.convert({\n- path: assetLibraryURI,\n- quality: 0.7,\n- });\n- if (success) {\n- const jpegResponse = await fetch(path);\n- blob = await jpegResponse.blob();\n- }\n+ const { type: reportedMIME, size } = blob.data;\n+ if (reportedMIME === \"image/heic\" || size > 500000) {\n+ try {\n+ const compressFormat = reportedMIME === \"image/png\" ? \"PNG\" : \"JPEG\";\n+ const { uri: resizedURI, path, name } =\n+ await ImageResizer.createResizedImage(\n+ uri,\n+ 3000,\n+ 2000,\n+ compressFormat,\n+ 0.92,\n+ );\n+ return {\n+ uploadURI: resizedURI,\n+ shouldDisposePath: path,\n+ name,\n+ mime: \"image/jpeg\",\n+ mediaType: \"photo\",\n+ };\n+ } catch (e) { }\n}\nconst dataURI = await blobToDataURI(blob);\n@@ -128,6 +131,7 @@ async function convertMedia(\nconst { name, mime, mediaType } = fileInfo;\nreturn {\nuploadURI: Platform.OS === \"ios\" ? dataURI : uri,\n+ shouldDisposePath: null,\nname,\nmime,\nmediaType,\n" }, { "change_type": "MODIFY", "old_path": "yarn.lock", "new_path": "yarn.lock", "diff": "@@ -10616,11 +10616,6 @@ react-native-floating-action@^1.9.0:\ninvariant \"^2.2.2\"\nprop-types \"^15.5.10\"\n-react-native-heic-converter@^1.2.0:\n- version \"1.2.0\"\n- resolved \"https://registry.yarnpkg.com/react-native-heic-converter/-/react-native-heic-converter-1.2.0.tgz#1391b37a5ab0c21181561a7529271fd89809fc65\"\n- integrity sha512-xMx3ASil698ABJFLXHkYTvFzouO4Y7P+rQ7UEzr1qgfkgcua4vOCvt/D2y94YJ7LWCKEo0XNnJir1+ThpU/15Q==\n-\n\"react-native-hyperlink@git+https://git@github.com/ashoat/react-native-hyperlink.git#both\":\nversion \"0.0.12\"\nresolved \"git+https://git@github.com/ashoat/react-native-hyperlink.git#0c872d5be30ba6382c926e78ad1545a97f586f85\"\n@@ -10628,6 +10623,11 @@ react-native-heic-converter@^1.2.0:\nlinkify-it \"^1.2.0\"\nmdurl \"^1.0.0\"\n+react-native-image-resizer@^1.0.1:\n+ version \"1.0.1\"\n+ resolved \"https://registry.yarnpkg.com/react-native-image-resizer/-/react-native-image-resizer-1.0.1.tgz#e9eeb7f81596ffc490f822897952b046c07ee95c\"\n+ integrity sha512-upBF/9TIs4twg19dSkSaDW/MzMpNbysEXtPuapu3GqvOuGIYHKQ30v6httDn7rIb6uCcNIWL1BwZJM2cDt/C9Q==\n+\nreact-native-in-app-notification@^2.1.0:\nversion \"2.2.0\"\nresolved \"https://registry.yarnpkg.com/react-native-in-app-notification/-/react-native-in-app-notification-2.2.0.tgz#690a9ef75bd0eecc15de77468f009a762c9f1748\"\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Use react-native-image-resizer to resize Also to convert from HEIC
129,187
12.06.2019 22:36:35
14,400
e5ee3cb8d367031f36b4af5c3717601f2ee727fa
[server] validateAndConvert uploads
[ { "change_type": "MODIFY", "old_path": "server/src/creators/upload-creator.js", "new_path": "server/src/creators/upload-creator.js", "diff": "@@ -20,7 +20,7 @@ function uploadExtras(upload: UploadInput) {\nreturn JSON.stringify({ height, width });\n}\n-type UploadInput = {|\n+export type UploadInput = {|\nname: string,\nmime: string,\nmediaType: MediaType,\n" }, { "change_type": "ADD", "old_path": null, "new_path": "server/src/uploads/media-utils.js", "diff": "+// @flow\n+\n+import type { UploadInput } from '../creators/upload-creator';\n+\n+import { fileInfoFromData } from 'lib/utils/media-utils';\n+\n+async function validateAndConvert(\n+ initialData: Buffer,\n+ initialName: string,\n+ size: number, // in bytes\n+): Promise<?UploadInput> {\n+ const fileInfo = fileInfoFromData(initialData, initialName);\n+ if (!fileInfo) {\n+ return null;\n+ }\n+ if (fileInfo.mime === \"image/heic\") {\n+ // This should've gotten converted on the client\n+ return null;\n+ }\n+ return { ...fileInfo, buffer: initialData };\n+}\n+\n+export {\n+ validateAndConvert,\n+};\n" }, { "change_type": "MODIFY", "old_path": "server/src/uploads/uploads.js", "new_path": "server/src/uploads/uploads.js", "diff": "@@ -9,12 +9,12 @@ import type {\nimport multer from 'multer';\n-import { fileInfoFromData } from 'lib/utils/media-utils';\nimport { ServerError } from 'lib/utils/errors';\nimport createUploads from '../creators/upload-creator';\nimport { fetchUpload } from '../fetchers/upload-fetchers';\nimport { deleteUpload } from '../deleters/upload-deleters';\n+import { validateAndConvert } from './media-utils';\nconst upload = multer();\nconst multerProcessor = upload.array('multimedia');\n@@ -39,14 +39,16 @@ async function multimediaUploadResponder(\nif (!files) {\nthrow new ServerError('invalid_parameters');\n}\n- const uploadInfos = files.map(multerFile => {\n- const { buffer, originalname } = multerFile;\n- const fileInfo = fileInfoFromData(buffer, originalname);\n- if (!fileInfo) {\n- return null;\n- }\n- return { ...fileInfo, buffer };\n- }).filter(Boolean);\n+ const validationResults = await Promise.all(\n+ files.map(\n+ ({ buffer, size, originalname }) => validateAndConvert(\n+ buffer,\n+ originalname,\n+ size,\n+ ),\n+ ),\n+ );\n+ const uploadInfos = validationResults.filter(Boolean);\nif (uploadInfos.length === 0) {\nthrow new ServerError('invalid_parameters');\n}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[server] validateAndConvert uploads
129,187
12.06.2019 22:54:47
14,400
74623620ff91f1553424f4c8c43349fd6f8bbb96
[server] sharp
[ { "change_type": "ADD", "old_path": null, "new_path": "server/flow-typed/npm/sharp_vx.x.x.js", "diff": "+// flow-typed signature: ecd3ba494e381f4c05fa81c05c61f574\n+// flow-typed version: <<STUB>>/sharp_v^0.22.1/flow_v0.89.0\n+\n+/**\n+ * This is an autogenerated libdef stub for:\n+ *\n+ * 'sharp'\n+ *\n+ * Fill this stub out by replacing all the `any` types.\n+ *\n+ * Once filled out, we encourage you to share your work with the\n+ * community by sending a pull request to:\n+ * https://github.com/flowtype/flow-typed\n+ */\n+\n+declare module 'sharp' {\n+ declare module.exports: any;\n+}\n+\n+/**\n+ * We include stubs for each file inside this npm package in case you need to\n+ * require those files directly. Feel free to delete any files that aren't\n+ * needed.\n+ */\n+declare module 'sharp/install/dll-copy' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'sharp/install/libvips' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'sharp/lib/agent' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'sharp/lib/channel' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'sharp/lib/colour' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'sharp/lib/composite' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'sharp/lib/constructor' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'sharp/lib/index' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'sharp/lib/input' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'sharp/lib/is' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'sharp/lib/libvips' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'sharp/lib/operation' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'sharp/lib/output' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'sharp/lib/platform' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'sharp/lib/resize' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'sharp/lib/utility' {\n+ declare module.exports: any;\n+}\n+\n+// Filename aliases\n+declare module 'sharp/install/dll-copy.js' {\n+ declare module.exports: $Exports<'sharp/install/dll-copy'>;\n+}\n+declare module 'sharp/install/libvips.js' {\n+ declare module.exports: $Exports<'sharp/install/libvips'>;\n+}\n+declare module 'sharp/lib/agent.js' {\n+ declare module.exports: $Exports<'sharp/lib/agent'>;\n+}\n+declare module 'sharp/lib/channel.js' {\n+ declare module.exports: $Exports<'sharp/lib/channel'>;\n+}\n+declare module 'sharp/lib/colour.js' {\n+ declare module.exports: $Exports<'sharp/lib/colour'>;\n+}\n+declare module 'sharp/lib/composite.js' {\n+ declare module.exports: $Exports<'sharp/lib/composite'>;\n+}\n+declare module 'sharp/lib/constructor.js' {\n+ declare module.exports: $Exports<'sharp/lib/constructor'>;\n+}\n+declare module 'sharp/lib/index.js' {\n+ declare module.exports: $Exports<'sharp/lib/index'>;\n+}\n+declare module 'sharp/lib/input.js' {\n+ declare module.exports: $Exports<'sharp/lib/input'>;\n+}\n+declare module 'sharp/lib/is.js' {\n+ declare module.exports: $Exports<'sharp/lib/is'>;\n+}\n+declare module 'sharp/lib/libvips.js' {\n+ declare module.exports: $Exports<'sharp/lib/libvips'>;\n+}\n+declare module 'sharp/lib/operation.js' {\n+ declare module.exports: $Exports<'sharp/lib/operation'>;\n+}\n+declare module 'sharp/lib/output.js' {\n+ declare module.exports: $Exports<'sharp/lib/output'>;\n+}\n+declare module 'sharp/lib/platform.js' {\n+ declare module.exports: $Exports<'sharp/lib/platform'>;\n+}\n+declare module 'sharp/lib/resize.js' {\n+ declare module.exports: $Exports<'sharp/lib/resize'>;\n+}\n+declare module 'sharp/lib/utility.js' {\n+ declare module.exports: $Exports<'sharp/lib/utility'>;\n+}\n" }, { "change_type": "MODIFY", "old_path": "server/package.json", "new_path": "server/package.json", "diff": "\"react-router\": \"^4.2.0\",\n\"redis\": \"^2.8.0\",\n\"redux\": \"^4.0.1\",\n+ \"sharp\": \"^0.22.1\",\n\"sql-template-strings\": \"^2.2.2\",\n\"stream-cache\": \"^0.0.2\",\n\"tcomb\": \"^3.2.24\",\n" }, { "change_type": "MODIFY", "old_path": "yarn.lock", "new_path": "yarn.lock", "diff": "@@ -2665,6 +2665,14 @@ binary@~0.3.0:\nbuffers \"~0.1.1\"\nchainsaw \"~0.1.0\"\n+bl@^1.0.0:\n+ version \"1.2.2\"\n+ resolved \"https://registry.yarnpkg.com/bl/-/bl-1.2.2.tgz#a160911717103c07410cef63ef51b397c025af9c\"\n+ integrity sha512-e8tQYnZodmebYDWGH7KMRvtzKXaJHx3BbilrgZCfvyLUYdKpK1t5PSPmpkny/SgiTSCnjfLW7v5rlONXVFkQEA==\n+ dependencies:\n+ readable-stream \"^2.3.5\"\n+ safe-buffer \"^5.1.1\"\n+\nbluebird@3.5.1:\nversion \"3.5.1\"\nresolved \"https://registry.yarnpkg.com/bluebird/-/bluebird-3.5.1.tgz#d9551f9de98f1fcda1e683d17ee91a0602ee2eb9\"\n@@ -2883,6 +2891,19 @@ btoa-lite@^1.0.0:\nresolved \"https://registry.yarnpkg.com/btoa-lite/-/btoa-lite-1.0.0.tgz#337766da15801210fdd956c22e9c6891ab9d0337\"\nintegrity sha1-M3dm2hWAEhD92VbCLpxokaudAzc=\n+buffer-alloc-unsafe@^1.1.0:\n+ version \"1.1.0\"\n+ resolved \"https://registry.yarnpkg.com/buffer-alloc-unsafe/-/buffer-alloc-unsafe-1.1.0.tgz#bd7dc26ae2972d0eda253be061dba992349c19f0\"\n+ integrity sha512-TEM2iMIEQdJ2yjPJoSIsldnleVaAk1oW3DBVUykyOLsEsFmEc9kn+SFFPz+gl54KQNxlDnAwCXosOS9Okx2xAg==\n+\n+buffer-alloc@^1.2.0:\n+ version \"1.2.0\"\n+ resolved \"https://registry.yarnpkg.com/buffer-alloc/-/buffer-alloc-1.2.0.tgz#890dd90d923a873e08e10e5fd51a57e5b7cce0ec\"\n+ integrity sha512-CFsHQgjtW1UChdXgbyJGtnm+O/uLQeZdtbDo8mfUgYXCHSM1wgrVxXm6bSyrUuErEb+4sYVGCzASBRot7zyrow==\n+ dependencies:\n+ buffer-alloc-unsafe \"^1.1.0\"\n+ buffer-fill \"^1.0.0\"\n+\nbuffer-crc32@^0.2.13:\nversion \"0.2.13\"\nresolved \"https://registry.yarnpkg.com/buffer-crc32/-/buffer-crc32-0.2.13.tgz#0d333e3f00eac50aa1454abd30ef8c2a5d9a7242\"\n@@ -2893,6 +2914,11 @@ buffer-equal-constant-time@1.0.1:\nresolved \"https://registry.yarnpkg.com/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz#f8e71132f7ffe6e01a5c9697a4c6f3e48d5cc819\"\nintegrity sha1-+OcRMvf/5uAaXJaXpMbz5I1cyBk=\n+buffer-fill@^1.0.0:\n+ version \"1.0.0\"\n+ resolved \"https://registry.yarnpkg.com/buffer-fill/-/buffer-fill-1.0.0.tgz#f8f78b76789888ef39f205cd637f68e702122b2c\"\n+ integrity sha1-+PeLdniYiO858gXNY39o5wISKyw=\n+\nbuffer-from@^1.0.0:\nversion \"1.1.1\"\nresolved \"https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef\"\n@@ -3419,6 +3445,14 @@ color@^3.0.0:\ncolor-convert \"^1.9.1\"\ncolor-string \"^1.5.2\"\n+color@^3.1.1:\n+ version \"3.1.2\"\n+ resolved \"https://registry.yarnpkg.com/color/-/color-3.1.2.tgz#68148e7f85d41ad7649c5fa8c8106f098d229e10\"\n+ integrity sha512-vXTJhHebByxZn3lDvDJYw4lR5+uB3vuoHsuYA5AKuxRVn5wzzIfQKGLBmgdVRHKTJYeK5rvJcHnrd0Li49CFpg==\n+ dependencies:\n+ color-convert \"^1.9.1\"\n+ color-string \"^1.5.2\"\n+\ncolormin@^1.0.5:\nversion \"1.1.2\"\nresolved \"https://registry.yarnpkg.com/colormin/-/colormin-1.1.2.tgz#ea2f7420a72b96881a38aae59ec124a6f7298133\"\n@@ -4116,7 +4150,7 @@ decode-uri-component@^0.2.0:\nresolved \"https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.0.tgz#eb3913333458775cb84cd1a1fae062106bb87545\"\nintegrity sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU=\n-decompress-response@^3.2.0:\n+decompress-response@^3.2.0, decompress-response@^3.3.0:\nversion \"3.3.0\"\nresolved \"https://registry.yarnpkg.com/decompress-response/-/decompress-response-3.3.0.tgz#80a4dd323748384bfa248083622aedec982adff3\"\nintegrity sha1-gKTdMjdIOEv6JICDYirt7Jgq3/M=\n@@ -4259,7 +4293,7 @@ detect-file@^1.0.0:\nresolved \"https://registry.yarnpkg.com/detect-file/-/detect-file-1.0.0.tgz#f0d66d03672a825cb1b73bdb3fe62310c8e552b7\"\nintegrity sha1-8NZtA2cqglyxtzvbP+YjEMjlUrc=\n-detect-libc@^1.0.2:\n+detect-libc@^1.0.2, detect-libc@^1.0.3:\nversion \"1.0.3\"\nresolved \"https://registry.yarnpkg.com/detect-libc/-/detect-libc-1.0.3.tgz#fa137c4bd698edf55cd5cd02ac559f91a4c4ba9b\"\nintegrity sha1-+hN8S9aY7fVc1c0CrFWfkaTEups=\n@@ -4776,6 +4810,11 @@ expand-range@^1.8.1:\ndependencies:\nfill-range \"^2.1.0\"\n+expand-template@^2.0.3:\n+ version \"2.0.3\"\n+ resolved \"https://registry.yarnpkg.com/expand-template/-/expand-template-2.0.3.tgz#6e14b3fcee0f3a6340ecb57d2e8918692052a47c\"\n+ integrity sha512-XYfuKMvj4O35f/pOXLObndIRvyQ+/+6AhODh+OKWj9S9498pHHn/IMszH+gt0fBCRWMNfk1ZSp5x3AifmnI2vg==\n+\nexpand-tilde@^2.0.0, expand-tilde@^2.0.2:\nversion \"2.0.2\"\nresolved \"https://registry.yarnpkg.com/expand-tilde/-/expand-tilde-2.0.2.tgz#97e801aa052df02454de46b02bf621642cdc8502\"\n@@ -5312,6 +5351,16 @@ from2@^2.1.0:\ninherits \"^2.0.1\"\nreadable-stream \"^2.0.0\"\n+fs-constants@^1.0.0:\n+ version \"1.0.0\"\n+ resolved \"https://registry.yarnpkg.com/fs-constants/-/fs-constants-1.0.0.tgz#6be0de9be998ce16af8afc24497b9ee9b7ccd9ad\"\n+ integrity sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==\n+\n+fs-copy-file-sync@^1.1.1:\n+ version \"1.1.1\"\n+ resolved \"https://registry.yarnpkg.com/fs-copy-file-sync/-/fs-copy-file-sync-1.1.1.tgz#11bf32c096c10d126e5f6b36d06eece776062918\"\n+ integrity sha512-2QY5eeqVv4m2PfyMiEuy9adxNP+ajf+8AR05cEi+OAzPcOj90hvFImeZhTmKLBgSd9EvG33jsD7ZRxsx9dThkQ==\n+\nfs-extra@^0.30.0:\nversion \"0.30.0\"\nresolved \"https://registry.yarnpkg.com/fs-extra/-/fs-extra-0.30.0.tgz#f233ffcc08d4da7d432daa449776989db1df93f0\"\n@@ -5535,6 +5584,11 @@ getpass@^0.1.1:\ndependencies:\nassert-plus \"^1.0.0\"\n+github-from-package@0.0.0:\n+ version \"0.0.0\"\n+ resolved \"https://registry.yarnpkg.com/github-from-package/-/github-from-package-0.0.0.tgz#97fb5d96bfde8973313f20e8288ef9a167fa64ce\"\n+ integrity sha1-l/tdlr/eiXMxPyDoKI75oWf6ZM4=\n+\nglob-base@^0.3.0:\nversion \"0.3.0\"\nresolved \"https://registry.yarnpkg.com/glob-base/-/glob-base-0.3.0.tgz#dbb164f6221b1c0b1ccf82aea328b497df0ea3c4\"\n@@ -8436,7 +8490,7 @@ minimist@~0.0.1:\nresolved \"https://registry.yarnpkg.com/minimist/-/minimist-0.0.10.tgz#de3f98543dbf96082be48ad1a0c7cda836301dcf\"\nintegrity sha1-3j+YVD2/lggr5IrRoMfNqDYwHc8=\n-minipass@^2.2.1, minipass@^2.3.3:\n+minipass@^2.2.1, minipass@^2.3.3, minipass@^2.3.5:\nversion \"2.3.5\"\nresolved \"https://registry.yarnpkg.com/minipass/-/minipass-2.3.5.tgz#cacebe492022497f656b0f0f51e2682a9ed2d848\"\nintegrity sha512-Gi1W4k059gyRbyVUZQ4mEqLm0YIUiGYfvxhF6SIlk3ui1WVxMTGfGdQ2SInh3PDrRTVvPKgULkpJtT4RH10+VA==\n@@ -8451,6 +8505,13 @@ minizlib@^1.1.0:\ndependencies:\nminipass \"^2.2.1\"\n+minizlib@^1.2.1:\n+ version \"1.2.1\"\n+ resolved \"https://registry.yarnpkg.com/minizlib/-/minizlib-1.2.1.tgz#dd27ea6136243c7c880684e8672bb3a45fd9b614\"\n+ integrity sha512-7+4oTUOWKg7AuL3vloEWekXY2/D20cevzsrNT2kGWm+39J9hGTCBv8VI5Pm5lXZ/o3/mdR4f8rflAPhnQb8mPA==\n+ dependencies:\n+ minipass \"^2.2.1\"\n+\nmississippi@^3.0.0:\nversion \"3.0.0\"\nresolved \"https://registry.yarnpkg.com/mississippi/-/mississippi-3.0.0.tgz#ea0a3291f97e0b5e8776b363d5f0a12d94c67022\"\n@@ -8597,6 +8658,11 @@ nan@^2.0.0, nan@^2.9.2:\nresolved \"https://registry.yarnpkg.com/nan/-/nan-2.11.1.tgz#90e22bccb8ca57ea4cd37cc83d3819b52eea6766\"\nintegrity sha512-iji6k87OSXa0CcrLl9z+ZiYSuR2o+c0bGuNmXdrhTQTakxytAFsC56SArGYoiHlJlFoHSnvmhpceZJaXkVuOtA==\n+nan@^2.13.2:\n+ version \"2.14.0\"\n+ resolved \"https://registry.yarnpkg.com/nan/-/nan-2.14.0.tgz#7818f722027b2459a86f0295d434d1fc2336c52c\"\n+ integrity sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg==\n+\nnanomatch@^1.2.9:\nversion \"1.2.13\"\nresolved \"https://registry.yarnpkg.com/nanomatch/-/nanomatch-1.2.13.tgz#b87a8aa4fc0de8fe6be88895b38983ff265bd119\"\n@@ -8614,6 +8680,11 @@ nanomatch@^1.2.9:\nsnapdragon \"^0.8.1\"\nto-regex \"^3.0.1\"\n+napi-build-utils@^1.0.1:\n+ version \"1.0.1\"\n+ resolved \"https://registry.yarnpkg.com/napi-build-utils/-/napi-build-utils-1.0.1.tgz#1381a0f92c39d66bf19852e7873432fc2123e508\"\n+ integrity sha512-boQj1WFgQH3v4clhu3mTNfP+vOBxorDlE8EKiMjUlLG3C4qAESnn9AxIOkFgTR2c9LtzNjPrjS60cT27ZKBhaA==\n+\nnatural-compare@^1.4.0:\nversion \"1.4.0\"\nresolved \"https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7\"\n@@ -8643,6 +8714,13 @@ nice-try@^1.0.4:\nresolved \"https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.5.tgz#a3378a7696ce7d223e88fc9b764bd7ef1089e366\"\nintegrity sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==\n+node-abi@^2.7.0:\n+ version \"2.8.0\"\n+ resolved \"https://registry.yarnpkg.com/node-abi/-/node-abi-2.8.0.tgz#bd2e88dbe6a6871e6dd08553e0605779325737ec\"\n+ integrity sha512-1/aa2clS0pue0HjckL62CsbhWWU35HARvBDXcJtYKbYR7LnIutmpxmXbuDMV9kEviD2lP/wACOgWmmwljghHyQ==\n+ dependencies:\n+ semver \"^5.4.1\"\n+\nnode-fetch@^1.0.1:\nversion \"1.7.3\"\nresolved \"https://registry.yarnpkg.com/node-fetch/-/node-fetch-1.7.3.tgz#980f6f72d85211a5347c6b2bc18c5b84c3eb47ef\"\n@@ -8794,6 +8872,11 @@ nodemon@^1.18.9:\nundefsafe \"^2.0.2\"\nupdate-notifier \"^2.5.0\"\n+noop-logger@^0.1.1:\n+ version \"0.1.1\"\n+ resolved \"https://registry.yarnpkg.com/noop-logger/-/noop-logger-0.1.1.tgz#94a2b1633c4f1317553007d8966fd0e841b6a4c2\"\n+ integrity sha1-lKKxYzxPExdVMAfYlm/Q6EG2pMI=\n+\nnopt@^4.0.1:\nversion \"4.0.1\"\nresolved \"https://registry.yarnpkg.com/nopt/-/nopt-4.0.1.tgz#d0d4685afd5415193c8c7505602d0d17cd64474d\"\n@@ -8875,7 +8958,7 @@ npmlog@^2.0.4:\nare-we-there-yet \"~1.1.2\"\ngauge \"~1.2.5\"\n-npmlog@^4.0.2:\n+npmlog@^4.0.1, npmlog@^4.0.2, npmlog@^4.1.2:\nversion \"4.1.2\"\nresolved \"https://registry.yarnpkg.com/npmlog/-/npmlog-4.1.2.tgz#08a7f2a8bf734604779a9efa4ad5cc717abb954b\"\nintegrity sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg==\n@@ -9111,7 +9194,7 @@ os-browserify@^0.3.0:\nresolved \"https://registry.yarnpkg.com/os-browserify/-/os-browserify-0.3.0.tgz#854373c7f5c2315914fc9bfc6bd8238fdda1ec27\"\nintegrity sha1-hUNzx/XCMVkU/Jv8a9gjj92h7Cc=\n-os-homedir@^1.0.0:\n+os-homedir@^1.0.0, os-homedir@^1.0.1:\nversion \"1.0.2\"\nresolved \"https://registry.yarnpkg.com/os-homedir/-/os-homedir-1.0.2.tgz#ffbc4988336e0e833de0c168c7ef152121aa7fb3\"\nintegrity sha1-/7xJiDNuDoM94MFox+8VISGqf7M=\n@@ -10098,6 +10181,28 @@ postinstall-postinstall@^2.0.0:\nresolved \"https://registry.yarnpkg.com/postinstall-postinstall/-/postinstall-postinstall-2.0.0.tgz#7ba6711b4420575c4f561638836a81faad47f43f\"\nintegrity sha512-3f6qWexsHiT4WKtZc5DRb0FPLilHtARi5KpY4fqban/DJNn8/YhZH8U7dVKVz51WbOxEnR31gV+qYQhvEdHtdQ==\n+prebuild-install@^5.3.0:\n+ version \"5.3.0\"\n+ resolved \"https://registry.yarnpkg.com/prebuild-install/-/prebuild-install-5.3.0.tgz#58b4d8344e03590990931ee088dd5401b03004c8\"\n+ integrity sha512-aaLVANlj4HgZweKttFNUVNRxDukytuIuxeK2boIMHjagNJCiVKWFsKF4tCE3ql3GbrD2tExPQ7/pwtEJcHNZeg==\n+ dependencies:\n+ detect-libc \"^1.0.3\"\n+ expand-template \"^2.0.3\"\n+ github-from-package \"0.0.0\"\n+ minimist \"^1.2.0\"\n+ mkdirp \"^0.5.1\"\n+ napi-build-utils \"^1.0.1\"\n+ node-abi \"^2.7.0\"\n+ noop-logger \"^0.1.1\"\n+ npmlog \"^4.0.1\"\n+ os-homedir \"^1.0.1\"\n+ pump \"^2.0.1\"\n+ rc \"^1.2.7\"\n+ simple-get \"^2.7.0\"\n+ tar-fs \"^1.13.0\"\n+ tunnel-agent \"^0.6.0\"\n+ which-pm-runs \"^1.0.0\"\n+\nprelude-ls@~1.1.2:\nversion \"1.1.2\"\nresolved \"https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54\"\n@@ -10269,7 +10374,15 @@ public-encrypt@^4.0.0:\nrandombytes \"^2.0.1\"\nsafe-buffer \"^5.1.2\"\n-pump@^2.0.0:\n+pump@^1.0.0:\n+ version \"1.0.3\"\n+ resolved \"https://registry.yarnpkg.com/pump/-/pump-1.0.3.tgz#5dfe8311c33bbf6fc18261f9f34702c47c08a954\"\n+ integrity sha512-8k0JupWme55+9tCVE+FS5ULT3K6AbgqrGa58lTT49RpyfwwcGedHqaC5LlQNdEAumn/wFsu6aPwkuPMioy8kqw==\n+ dependencies:\n+ end-of-stream \"^1.1.0\"\n+ once \"^1.3.1\"\n+\n+pump@^2.0.0, pump@^2.0.1:\nversion \"2.0.1\"\nresolved \"https://registry.yarnpkg.com/pump/-/pump-2.0.1.tgz#12399add6e4cf7526d973cbc8b5ce2e2908b3909\"\nintegrity sha512-ruPMNRkN3MHP1cWJc9OWr+T/xDP0jhXYCLfJcBuX54hhfIBnaQmAUMfDcG4DM5UMWByBbJY69QSphm3jtDKIkA==\n@@ -11035,7 +11148,7 @@ read-pkg@^3.0.0:\nnormalize-package-data \"^2.3.2\"\npath-type \"^3.0.0\"\n-\"readable-stream@1 || 2\", readable-stream@^2.0.0, readable-stream@^2.0.1, readable-stream@^2.0.2, readable-stream@^2.0.4, readable-stream@^2.0.6, readable-stream@^2.1.5, readable-stream@^2.2.2, readable-stream@^2.3.3, readable-stream@^2.3.6:\n+\"readable-stream@1 || 2\", readable-stream@^2.0.0, readable-stream@^2.0.1, readable-stream@^2.0.2, readable-stream@^2.0.4, readable-stream@^2.0.6, readable-stream@^2.1.5, readable-stream@^2.2.2, readable-stream@^2.3.0, readable-stream@^2.3.3, readable-stream@^2.3.5, readable-stream@^2.3.6:\nversion \"2.3.6\"\nresolved \"https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.6.tgz#b11c27d88b8ff1fbe070643cf94b0c79ae1b0aaf\"\nintegrity sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==\n@@ -11724,6 +11837,11 @@ semver-diff@^2.0.0:\nresolved \"https://registry.yarnpkg.com/semver/-/semver-5.6.0.tgz#7e74256fbaa49c75aa7c7a205cc22799cac80004\"\nintegrity sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==\n+semver@^6.0.0:\n+ version \"6.1.1\"\n+ resolved \"https://registry.yarnpkg.com/semver/-/semver-6.1.1.tgz#53f53da9b30b2103cd4f15eab3a18ecbcb210c9b\"\n+ integrity sha512-rWYq2e5iYW+fFe/oPPtYJxYgjBm8sC4rmoGdUOgBB7VnwKt6HrL793l2voH1UlsyYZpJ4g0wfjnTEO1s1NP2eQ==\n+\nsend@0.16.2:\nversion \"0.16.2\"\nresolved \"https://registry.yarnpkg.com/send/-/send-0.16.2.tgz#6ecca1e0f8c156d141597559848df64730a6bbc1\"\n@@ -11829,6 +11947,22 @@ shallowequal@^1.0.2, shallowequal@^1.1.0:\nresolved \"https://registry.yarnpkg.com/shallowequal/-/shallowequal-1.1.0.tgz#188d521de95b9087404fd4dcb68b13df0ae4e7f8\"\nintegrity sha512-y0m1JoUZSlPAjXVtPPW70aZWfIL/dSP7AFkRnniLCrK/8MDKog3TySTBmckD+RObVxH0v4Tox67+F14PdED2oQ==\n+sharp@^0.22.1:\n+ version \"0.22.1\"\n+ resolved \"https://registry.yarnpkg.com/sharp/-/sharp-0.22.1.tgz#a67c0e75567f03dd5a7861b901fec04072c5b0f4\"\n+ integrity sha512-lXzSk/FL5b/MpWrT1pQZneKe25stVjEbl6uhhJcTULm7PhmJgKKRbTDM/vtjyUuC/RLqL2PRyC4rpKwbv3soEw==\n+ dependencies:\n+ color \"^3.1.1\"\n+ detect-libc \"^1.0.3\"\n+ fs-copy-file-sync \"^1.1.1\"\n+ nan \"^2.13.2\"\n+ npmlog \"^4.1.2\"\n+ prebuild-install \"^5.3.0\"\n+ semver \"^6.0.0\"\n+ simple-get \"^3.0.3\"\n+ tar \"^4.4.8\"\n+ tunnel-agent \"^0.6.0\"\n+\nshebang-command@^1.2.0:\nversion \"1.2.0\"\nresolved \"https://registry.yarnpkg.com/shebang-command/-/shebang-command-1.2.0.tgz#44aac65b695b03398968c39f363fee5deafdf1ea\"\n@@ -11861,6 +11995,29 @@ signal-exit@^3.0.0, signal-exit@^3.0.2:\nresolved \"https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d\"\nintegrity sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=\n+simple-concat@^1.0.0:\n+ version \"1.0.0\"\n+ resolved \"https://registry.yarnpkg.com/simple-concat/-/simple-concat-1.0.0.tgz#7344cbb8b6e26fb27d66b2fc86f9f6d5997521c6\"\n+ integrity sha1-c0TLuLbib7J9ZrL8hvn21Zl1IcY=\n+\n+simple-get@^2.7.0:\n+ version \"2.8.1\"\n+ resolved \"https://registry.yarnpkg.com/simple-get/-/simple-get-2.8.1.tgz#0e22e91d4575d87620620bc91308d57a77f44b5d\"\n+ integrity sha512-lSSHRSw3mQNUGPAYRqo7xy9dhKmxFXIjLjp4KHpf99GEH2VH7C3AM+Qfx6du6jhfUi6Vm7XnbEVEf7Wb6N8jRw==\n+ dependencies:\n+ decompress-response \"^3.3.0\"\n+ once \"^1.3.1\"\n+ simple-concat \"^1.0.0\"\n+\n+simple-get@^3.0.3:\n+ version \"3.0.3\"\n+ resolved \"https://registry.yarnpkg.com/simple-get/-/simple-get-3.0.3.tgz#924528ac3f9d7718ce5e9ec1b1a69c0be4d62efa\"\n+ integrity sha512-Wvre/Jq5vgoz31Z9stYWPLn0PqRqmBDpFSdypAnHu5AvRVCYPRYGnvryNLiXu8GOBNDH82J2FRHUGMjjHUpXFw==\n+ dependencies:\n+ decompress-response \"^3.3.0\"\n+ once \"^1.3.1\"\n+ simple-concat \"^1.0.0\"\n+\nsimple-plist@^1.0.0:\nversion \"1.0.0\"\nresolved \"https://registry.yarnpkg.com/simple-plist/-/simple-plist-1.0.0.tgz#bed3085633b22f371e111f45d159a1ccf94b81eb\"\n@@ -12479,6 +12636,29 @@ tapable@^1.0.0, tapable@^1.1.0:\nresolved \"https://registry.yarnpkg.com/tapable/-/tapable-1.1.1.tgz#4d297923c5a72a42360de2ab52dadfaaec00018e\"\nintegrity sha512-9I2ydhj8Z9veORCw5PRm4u9uebCn0mcCa6scWoNcbZ6dAtoo2618u9UUzxgmsCOreJpqDDuv61LvwofW7hLcBA==\n+tar-fs@^1.13.0:\n+ version \"1.16.3\"\n+ resolved \"https://registry.yarnpkg.com/tar-fs/-/tar-fs-1.16.3.tgz#966a628841da2c4010406a82167cbd5e0c72d509\"\n+ integrity sha512-NvCeXpYx7OsmOh8zIOP/ebG55zZmxLE0etfWRbWok+q2Qo8x/vOR/IJT1taADXPe+jsiu9axDb3X4B+iIgNlKw==\n+ dependencies:\n+ chownr \"^1.0.1\"\n+ mkdirp \"^0.5.1\"\n+ pump \"^1.0.0\"\n+ tar-stream \"^1.1.2\"\n+\n+tar-stream@^1.1.2:\n+ version \"1.6.2\"\n+ resolved \"https://registry.yarnpkg.com/tar-stream/-/tar-stream-1.6.2.tgz#8ea55dab37972253d9a9af90fdcd559ae435c555\"\n+ integrity sha512-rzS0heiNf8Xn7/mpdSVVSMAWAoy9bfb1WOTYC78Z0UQKeKa/CWS8FOq0lKGNa8DWKAn9gxjCvMLYc5PGXYlK2A==\n+ dependencies:\n+ bl \"^1.0.0\"\n+ buffer-alloc \"^1.2.0\"\n+ end-of-stream \"^1.0.0\"\n+ fs-constants \"^1.0.0\"\n+ readable-stream \"^2.3.0\"\n+ to-buffer \"^1.1.1\"\n+ xtend \"^4.0.0\"\n+\ntar@^4:\nversion \"4.4.6\"\nresolved \"https://registry.yarnpkg.com/tar/-/tar-4.4.6.tgz#63110f09c00b4e60ac8bcfe1bf3c8660235fbc9b\"\n@@ -12492,6 +12672,19 @@ tar@^4:\nsafe-buffer \"^5.1.2\"\nyallist \"^3.0.2\"\n+tar@^4.4.8:\n+ version \"4.4.10\"\n+ resolved \"https://registry.yarnpkg.com/tar/-/tar-4.4.10.tgz#946b2810b9a5e0b26140cf78bea6b0b0d689eba1\"\n+ integrity sha512-g2SVs5QIxvo6OLp0GudTqEf05maawKUxXru104iaayWA09551tFCTI8f1Asb4lPfkBr91k07iL4c11XO3/b0tA==\n+ dependencies:\n+ chownr \"^1.1.1\"\n+ fs-minipass \"^1.2.5\"\n+ minipass \"^2.3.5\"\n+ minizlib \"^1.2.1\"\n+ mkdirp \"^0.5.0\"\n+ safe-buffer \"^5.1.2\"\n+ yallist \"^3.0.3\"\n+\ntcomb@^3.2.24:\nversion \"3.2.27\"\nresolved \"https://registry.yarnpkg.com/tcomb/-/tcomb-3.2.27.tgz#f4928bfc536b959d21a47e5f5f1ca2b2e4b7188a\"\n@@ -12638,6 +12831,11 @@ to-arraybuffer@^1.0.0:\nresolved \"https://registry.yarnpkg.com/to-arraybuffer/-/to-arraybuffer-1.0.1.tgz#7d229b1fcc637e466ca081180836a7aabff83f43\"\nintegrity sha1-fSKbH8xjfkZsoIEYCDanqr/4P0M=\n+to-buffer@^1.1.1:\n+ version \"1.1.1\"\n+ resolved \"https://registry.yarnpkg.com/to-buffer/-/to-buffer-1.1.1.tgz#493bd48f62d7c43fcded313a03dcadb2e1213a80\"\n+ integrity sha512-lx9B5iv7msuFYE3dytT+KE5tap+rNYw+K4jVkb9R/asAb+pbBSM17jtunHplhBe6RRJdZx3Pn2Jph24O32mOVg==\n+\nto-fast-properties@^2.0.0:\nversion \"2.0.0\"\nresolved \"https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-2.0.0.tgz#dc5e698cbd079265bc73e0377681a4e4e83f616e\"\n@@ -13372,6 +13570,11 @@ which-module@^2.0.0:\nresolved \"https://registry.yarnpkg.com/which-module/-/which-module-2.0.0.tgz#d9ef07dce77b9902b8a3a8fa4b31c3e3f7e6e87a\"\nintegrity sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=\n+which-pm-runs@^1.0.0:\n+ version \"1.0.0\"\n+ resolved \"https://registry.yarnpkg.com/which-pm-runs/-/which-pm-runs-1.0.0.tgz#670b3afbc552e0b55df6b7780ca74615f23ad1cb\"\n+ integrity sha1-Zws6+8VS4LVd9rd4DKdGFfI60cs=\n+\nwhich@^1.2.14, which@^1.2.9, which@^1.3.0:\nversion \"1.3.1\"\nresolved \"https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a\"\n@@ -13573,6 +13776,11 @@ yallist@^3.0.0, yallist@^3.0.2:\nresolved \"https://registry.yarnpkg.com/yallist/-/yallist-3.0.2.tgz#8452b4bb7e83c7c188d8041c1a837c773d6d8bb9\"\nintegrity sha1-hFK0u36Dx8GI2AQcGoN8dz1ti7k=\n+yallist@^3.0.3:\n+ version \"3.0.3\"\n+ resolved \"https://registry.yarnpkg.com/yallist/-/yallist-3.0.3.tgz#b4b049e314be545e3ce802236d6cd22cd91c3de9\"\n+ integrity sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==\n+\nyargs-parser@^10.1.0:\nversion \"10.1.0\"\nresolved \"https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-10.1.0.tgz#7202265b89f7e9e9f2e5765e0fe735a905edbaa8\"\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[server] sharp
129,187
12.06.2019 22:55:53
14,400
29de915765c903365d18ed0d26c558920da6e52d
[server] Convert large size files down
[ { "change_type": "MODIFY", "old_path": "server/src/uploads/media-utils.js", "new_path": "server/src/uploads/media-utils.js", "diff": "import type { UploadInput } from '../creators/upload-creator';\n+import sharp from 'sharp';\n+\nimport { fileInfoFromData } from 'lib/utils/media-utils';\n+const fiveMegabytes = 5 * 1024 * 1024;\n+\nasync function validateAndConvert(\n- initialData: Buffer,\n+ initialBuffer: Buffer,\ninitialName: string,\nsize: number, // in bytes\n): Promise<?UploadInput> {\n- const fileInfo = fileInfoFromData(initialData, initialName);\n+ const fileInfo = fileInfoFromData(initialBuffer, initialName);\nif (!fileInfo) {\nreturn null;\n}\n- if (fileInfo.mime === \"image/heic\") {\n+\n+ const { mime } = fileInfo;\n+ if (mime === \"image/heic\") {\n// This should've gotten converted on the client\nreturn null;\n}\n- return { ...fileInfo, buffer: initialData };\n+ if (size < fiveMegabytes && (mime === \"image/png\" || mime === \"image/jpeg\")) {\n+ return { ...fileInfo, buffer: initialBuffer };\n+ }\n+\n+ let sharpImage;\n+ try {\n+ sharpImage = sharp(initialBuffer);\n+ } catch (e) {\n+ return null;\n+ }\n+ sharpImage = sharpImage.resize(\n+ 3000,\n+ 2000,\n+ { fit: 'inside', withoutEnlargement: true },\n+ );\n+\n+ if (mime === \"image/png\" || mime === \"image/gif\") {\n+ sharpImage = sharpImage.png();\n+ } else {\n+ sharpImage = sharpImage.jpeg({ quality: 92 });\n+ }\n+\n+ const convertedBuffer = await sharpImage.toBuffer();\n+ const convertedFileInfo = fileInfoFromData(convertedBuffer, initialName);\n+ if (!convertedFileInfo) {\n+ return null;\n+ }\n+ return { ...convertedFileInfo, buffer: convertedBuffer };\n}\nexport {\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[server] Convert large size files down
129,187
12.06.2019 23:21:53
14,400
9986c60b05977ea1a08fcaae431cbfeef67dfb69
[lib] Throttle XHR onprogress callback
[ { "change_type": "MODIFY", "old_path": "lib/utils/upload-blob.js", "new_path": "lib/utils/upload-blob.js", "diff": "@@ -4,6 +4,7 @@ import type { FetchJSONOptions, FetchJSONServerResponse } from './fetch-json';\nimport invariant from 'invariant';\nimport _cloneDeep from 'lodash/fp/cloneDeep';\n+import _throttle from 'lodash/throttle';\nimport { getConfig } from './config';\n@@ -64,9 +65,10 @@ function uploadBlob(\nif (options && options.onProgress) {\nconst { onProgress } = options;\n- xhr.upload.onprogress = ({ loaded, total }) => {\n- onProgress(loaded / total);\n- };\n+ xhr.upload.onprogress = _throttle(\n+ ({ loaded, total }) => onProgress(loaded / total),\n+ 150,\n+ );\n}\nlet failed = false;\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[lib] Throttle XHR onprogress callback
129,187
12.06.2019 23:27:19
14,400
abb60379214c59bd22f04154210e307b33292c7c
[native] react-native-fs
[ { "change_type": "MODIFY", "old_path": "native/.flowconfig", "new_path": "native/.flowconfig", "diff": "; Ignore metro\n.*/node_modules/metro/.*\n+.*/node_modules/react-native-fs/FS.common.js\n+\n[include]\n../lib\n" }, { "change_type": "MODIFY", "old_path": "native/android/app/build.gradle", "new_path": "native/android/app/build.gradle", "diff": "@@ -147,6 +147,7 @@ android {\n}\ndependencies {\n+ implementation project(':react-native-fs')\nimplementation project(':react-native-image-resizer')\nimplementation project(':react-native-svg')\nimplementation project(':lottie-react-native')\n" }, { "change_type": "MODIFY", "old_path": "native/android/app/src/main/java/org/squadcal/MainApplication.java", "new_path": "native/android/app/src/main/java/org/squadcal/MainApplication.java", "diff": "@@ -3,6 +3,7 @@ package org.squadcal;\nimport android.app.Application;\nimport com.facebook.react.ReactApplication;\n+import com.rnfs.RNFSPackage;\nimport fr.bamlab.rnimageresizer.ImageResizerPackage;\nimport com.horcrux.svg.SvgPackage;\nimport com.airbnb.android.react.lottie.LottiePackage;\n@@ -42,6 +43,7 @@ public class MainApplication extends Application implements ReactApplication {\nprotected List<ReactPackage> getPackages() {\nreturn Arrays.<ReactPackage>asList(\nnew MainReactPackage(),\n+ new RNFSPackage(),\nnew ImageResizerPackage(),\nnew SvgPackage(),\nnew LottiePackage(),\n" }, { "change_type": "MODIFY", "old_path": "native/android/settings.gradle", "new_path": "native/android/settings.gradle", "diff": "rootProject.name = 'SquadCal'\n+include ':react-native-fs'\n+project(':react-native-fs').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fs/android')\ninclude ':react-native-image-resizer'\nproject(':react-native-image-resizer').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-image-resizer/android')\ninclude ':react-native-svg'\n" }, { "change_type": "ADD", "old_path": null, "new_path": "native/flow-typed/npm/react-native-fs_vx.x.x.js", "diff": "+// flow-typed signature: dda9c6e6907650235702802d62933b88\n+// flow-typed version: <<STUB>>/react-native-fs_v^2.13.3/flow_v0.92.0\n+\n+/**\n+ * This is an autogenerated libdef stub for:\n+ *\n+ * 'react-native-fs'\n+ *\n+ * Fill this stub out by replacing all the `any` types.\n+ *\n+ * Once filled out, we encourage you to share your work with the\n+ * community by sending a pull request to:\n+ * https://github.com/flowtype/flow-typed\n+ */\n+\n+declare module 'react-native-fs' {\n+ declare module.exports: any;\n+}\n+\n+/**\n+ * We include stubs for each file inside this npm package in case you need to\n+ * require those files directly. Feel free to delete any files that aren't\n+ * needed.\n+ */\n+declare module 'react-native-fs/FS.common' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-fs/IntegrationTests/FSTest' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-fs/IntegrationTests/IntegrationTestHarnessTest' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-fs/IntegrationTests/IntegrationTestsApp' {\n+ declare module.exports: any;\n+}\n+\n+// Filename aliases\n+declare module 'react-native-fs/FS.common.js' {\n+ declare module.exports: $Exports<'react-native-fs/FS.common'>;\n+}\n+declare module 'react-native-fs/IntegrationTests/FSTest.js' {\n+ declare module.exports: $Exports<'react-native-fs/IntegrationTests/FSTest'>;\n+}\n+declare module 'react-native-fs/IntegrationTests/IntegrationTestHarnessTest.js' {\n+ declare module.exports: $Exports<'react-native-fs/IntegrationTests/IntegrationTestHarnessTest'>;\n+}\n+declare module 'react-native-fs/IntegrationTests/IntegrationTestsApp.js' {\n+ declare module.exports: $Exports<'react-native-fs/IntegrationTests/IntegrationTestsApp'>;\n+}\n" }, { "change_type": "MODIFY", "old_path": "native/ios/Podfile", "new_path": "native/ios/Podfile", "diff": "@@ -44,6 +44,7 @@ target 'SquadCal' do\npod 'lottie-react-native', :path => '../../node_modules/lottie-react-native'\npod 'RNSVG', :path => '../../node_modules/react-native-svg'\npod 'react-native-image-resizer', :path => '../../node_modules/react-native-image-resizer'\n+ pod 'RNFS', :path => '../../node_modules/react-native-fs'\ntarget 'SquadCalTests' do\ninherit! :search_paths\n" }, { "change_type": "MODIFY", "old_path": "native/ios/Podfile.lock", "new_path": "native/ios/Podfile.lock", "diff": "@@ -116,6 +116,8 @@ PODS:\n- React/Core\n- React/fishhook\n- React/RCTBlob\n+ - RNFS (2.13.3):\n+ - React\n- RNGestureHandler (1.1.0):\n- React\n- RNKeychain (3.0.0):\n@@ -165,6 +167,7 @@ DEPENDENCIES:\n- React/RCTNetwork (from `../../node_modules/react-native`)\n- React/RCTText (from `../../node_modules/react-native`)\n- React/RCTWebSocket (from `../../node_modules/react-native`)\n+ - RNFS (from `../../node_modules/react-native-fs`)\n- RNGestureHandler (from `../../node_modules/react-native-gesture-handler`)\n- RNKeychain (from `../../node_modules/react-native-keychain`)\n- RNReanimated (from `../../node_modules/react-native-reanimated`)\n@@ -217,6 +220,8 @@ EXTERNAL SOURCES:\n:path: \"../../node_modules/react-native-orientation-locker\"\nreact-native-splash-screen:\n:path: \"../../node_modules/react-native-splash-screen\"\n+ RNFS:\n+ :path: \"../../node_modules/react-native-fs\"\nRNGestureHandler:\n:path: \"../../node_modules/react-native-gesture-handler\"\nRNKeychain:\n@@ -255,6 +260,7 @@ SPEC CHECKSUMS:\nreact-native-onepassword: 5b2b7f425f9db40932703e65d350b78cbc598047\nreact-native-orientation-locker: 132a63bab4dddd2a5709f6f7935ad9676b0af7c5\nreact-native-splash-screen: 353334c5ae82d8c74501ea7cbb916cb7cb20c8bf\n+ RNFS: c9bbde46b0d59619f8e7b735991c60e0f73d22c1\nRNGestureHandler: 8a75e1d2f83d73aba148653252953e4bcf363b98\nRNKeychain: 3aa3cf891a09a0d18d306862ab2bb9e106079b24\nRNReanimated: c8dd490ca98a4edcba229bfa49f2516c95a43afb\n@@ -264,6 +270,6 @@ SPEC CHECKSUMS:\nSDWebImage: 3f3f0c02f09798048c47a5ed0a13f17b063572d8\nyoga: 596e61c9b57751d08a22b07aba310dbd3e65ab75\n-PODFILE CHECKSUM: c854be7f2da33ebedc540e03582c25dd1d7818d9\n+PODFILE CHECKSUM: ae819defa5963e229fa7c2bc475e5b8771d60ba1\nCOCOAPODS: 1.6.1\n" }, { "change_type": "MODIFY", "old_path": "native/package.json", "new_path": "native/package.json", "diff": "\"react-native-fast-image\": \"^5.2.0\",\n\"react-native-firebase\": \"^5.3.1\",\n\"react-native-floating-action\": \"^1.9.0\",\n+ \"react-native-fs\": \"^2.13.3\",\n\"react-native-gesture-handler\": \"git+https://git@github.com/kmagiera/react-native-gesture-handler.git#99dce5e787f0c0e87cf748bc78d32fb65fcdb0e8\",\n\"react-native-hyperlink\": \"git+https://git@github.com/ashoat/react-native-hyperlink.git#both\",\n\"react-native-image-resizer\": \"^1.0.1\",\n" }, { "change_type": "MODIFY", "old_path": "yarn.lock", "new_path": "yarn.lock", "diff": "@@ -10721,6 +10721,14 @@ react-native-floating-action@^1.9.0:\nresolved \"https://registry.yarnpkg.com/react-native-floating-action/-/react-native-floating-action-1.13.0.tgz#876ab9227c4eda8630020a6a3adc20041870edf3\"\nintegrity sha512-KqqaEO/nIdims+reWq1pPPDptKqEuG9N8Pt+FtnuVUr35HvyWfiwBf91o9ZMRuO2S+X9AKnq+xuy1iuQK77eQQ==\n+react-native-fs@^2.13.3:\n+ version \"2.13.3\"\n+ resolved \"https://registry.yarnpkg.com/react-native-fs/-/react-native-fs-2.13.3.tgz#a422f0ecd8a093a7e99d8d51ff51440e090a18a8\"\n+ integrity sha512-B62LSSAEYQGItg7KVTzTVVCxezOYFBYp4DMVFbdoZUd1mZVFdqR2sy1HY1mye1VI/Lf3IbxSyZEQ0GmrrdwLjg==\n+ dependencies:\n+ base-64 \"^0.1.0\"\n+ utf8 \"^2.1.1\"\n+\n\"react-native-gesture-handler@git+https://git@github.com/kmagiera/react-native-gesture-handler.git#99dce5e787f0c0e87cf748bc78d32fb65fcdb0e8\":\nversion \"1.1.0\"\nresolved \"git+https://git@github.com/kmagiera/react-native-gesture-handler.git#99dce5e787f0c0e87cf748bc78d32fb65fcdb0e8\"\n@@ -13211,6 +13219,11 @@ utf-8-validate@^5.0.1:\ndependencies:\nnode-gyp-build \"~3.4.0\"\n+utf8@^2.1.1:\n+ version \"2.1.2\"\n+ resolved \"https://registry.yarnpkg.com/utf8/-/utf8-2.1.2.tgz#1fa0d9270e9be850d9b05027f63519bf46457d96\"\n+ integrity sha1-H6DZJw6b6FDZsFAn9jUZv0ZFfZY=\n+\nutil-deprecate@^1.0.1, util-deprecate@~1.0.1:\nversion \"1.0.2\"\nresolved \"https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf\"\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] react-native-fs
129,187
12.06.2019 23:39:19
14,400
ce62c5a4c93616ee7771c1b23a9b4f28eaaa3e01
[native] Delete temporary downscaled file after uploading
[ { "change_type": "MODIFY", "old_path": "native/chat/chat-input-state-container.react.js", "new_path": "native/chat/chat-input-state-container.react.js", "diff": "@@ -20,6 +20,7 @@ import * as React from 'react';\nimport PropTypes from 'prop-types';\nimport invariant from 'invariant';\nimport { createSelector } from 'reselect';\n+import filesystem from 'react-native-fs';\nimport { connect } from 'lib/utils/redux-utils';\nimport {\n@@ -336,7 +337,6 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\n} = conversionResult;\nlet result;\n- let success = true;\ntry {\nresult = await this.props.uploadMultimedia(\n{ uri: uploadURI, name, type: mime },\n@@ -348,11 +348,8 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\n);\n} catch (e) {\nthis.handleUploadFailure(localMessageID, localID, e);\n- success = false;\n- }\n- if (!success) {\n- return;\n}\n+ if (result) {\nthis.props.dispatchActionPayload(\nupdateMultimediaMessageMediaActionType,\n{\n@@ -366,6 +363,13 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\n},\n);\n}\n+ if (!shouldDisposePath) {\n+ return;\n+ }\n+ try {\n+ await filesystem.unlink(shouldDisposePath);\n+ } catch (e) { }\n+ }\nsetProgress(\nlocalMessageID: string,\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Delete temporary downscaled file after uploading
129,187
12.06.2019 23:49:06
14,400
ff32a2a1385b2961503d4b55d56e8551c7bc0d0f
[server] Store upload creation time in DB
[ { "change_type": "MODIFY", "old_path": "server/src/creators/upload-creator.js", "new_path": "server/src/creators/upload-creator.js", "diff": "@@ -44,12 +44,13 @@ async function createUploads(\nuploadInfo.mime,\nuploadInfo.buffer,\nsecret,\n+ Date.now(),\nuploadExtras(uploadInfo),\n]);\nconst insertQuery = SQL`\n- INSERT INTO uploads(id, uploader, type,\n- filename, mime, content, secret, extra)\n+ INSERT INTO uploads(id, uploader, type, filename,\n+ mime, content, secret, creation_time, extra)\nVALUES ${uploadRows}\n`;\nawait dbQuery(insertQuery);\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[server] Store upload creation time in DB
129,187
13.06.2019 00:51:35
14,400
40e9471167a3d45019adb73b7095bb3277697e81
[native] react-native-progress Has a dependency on ReactART
[ { "change_type": "ADD", "old_path": null, "new_path": "native/flow-typed/npm/react-native-progress_vx.x.x.js", "diff": "+// flow-typed signature: baa3115e9b489de81d6b02e097d53fe8\n+// flow-typed version: <<STUB>>/react-native-progress_v^3.6.0/flow_v0.92.0\n+\n+/**\n+ * This is an autogenerated libdef stub for:\n+ *\n+ * 'react-native-progress'\n+ *\n+ * Fill this stub out by replacing all the `any` types.\n+ *\n+ * Once filled out, we encourage you to share your work with the\n+ * community by sending a pull request to:\n+ * https://github.com/flowtype/flow-typed\n+ */\n+\n+declare module 'react-native-progress' {\n+ declare module.exports: any;\n+}\n+\n+/**\n+ * We include stubs for each file inside this npm package in case you need to\n+ * require those files directly. Feel free to delete any files that aren't\n+ * needed.\n+ */\n+declare module 'react-native-progress/Bar' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-progress/Circle' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-progress/CircleSnail' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-progress/Pie' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-progress/Shapes/Arc' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-progress/Shapes/Circle' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-progress/Shapes/Sector' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-progress/withAnimation' {\n+ declare module.exports: any;\n+}\n+\n+// Filename aliases\n+declare module 'react-native-progress/Bar.js' {\n+ declare module.exports: $Exports<'react-native-progress/Bar'>;\n+}\n+declare module 'react-native-progress/Circle.js' {\n+ declare module.exports: $Exports<'react-native-progress/Circle'>;\n+}\n+declare module 'react-native-progress/CircleSnail.js' {\n+ declare module.exports: $Exports<'react-native-progress/CircleSnail'>;\n+}\n+declare module 'react-native-progress/index' {\n+ declare module.exports: $Exports<'react-native-progress'>;\n+}\n+declare module 'react-native-progress/index.js' {\n+ declare module.exports: $Exports<'react-native-progress'>;\n+}\n+declare module 'react-native-progress/Pie.js' {\n+ declare module.exports: $Exports<'react-native-progress/Pie'>;\n+}\n+declare module 'react-native-progress/Shapes/Arc.js' {\n+ declare module.exports: $Exports<'react-native-progress/Shapes/Arc'>;\n+}\n+declare module 'react-native-progress/Shapes/Circle.js' {\n+ declare module.exports: $Exports<'react-native-progress/Shapes/Circle'>;\n+}\n+declare module 'react-native-progress/Shapes/Sector.js' {\n+ declare module.exports: $Exports<'react-native-progress/Shapes/Sector'>;\n+}\n+declare module 'react-native-progress/withAnimation.js' {\n+ declare module.exports: $Exports<'react-native-progress/withAnimation'>;\n+}\n" }, { "change_type": "MODIFY", "old_path": "native/ios/Podfile", "new_path": "native/ios/Podfile", "diff": "@@ -18,6 +18,7 @@ target 'SquadCal' do\n'RCTLinkingIOS',\n'RCTCameraRoll',\n'RCTBlob',\n+ 'ART',\n]\npod 'yoga', :path => '../../node_modules/react-native/ReactCommon/yoga'\n" }, { "change_type": "MODIFY", "old_path": "native/ios/Podfile.lock", "new_path": "native/ios/Podfile.lock", "diff": "@@ -68,6 +68,8 @@ PODS:\n- React\n- react-native-splash-screen (3.1.1):\n- React\n+ - React/ART (0.59.4):\n+ - React/Core\n- React/Core (0.59.4):\n- yoga (= 0.59.4.React)\n- React/CxxBridge (0.59.4):\n@@ -154,6 +156,7 @@ DEPENDENCIES:\n- react-native-onepassword (from `../../node_modules/react-native-onepassword`)\n- react-native-orientation-locker (from `../../node_modules/react-native-orientation-locker`)\n- react-native-splash-screen (from `../../node_modules/react-native-splash-screen`)\n+ - React/ART (from `../../node_modules/react-native`)\n- React/Core (from `../../node_modules/react-native`)\n- React/CxxBridge (from `../../node_modules/react-native`)\n- React/DevSupport (from `../../node_modules/react-native`)\n@@ -264,6 +267,6 @@ SPEC CHECKSUMS:\nSDWebImage: 3f3f0c02f09798048c47a5ed0a13f17b063572d8\nyoga: 596e61c9b57751d08a22b07aba310dbd3e65ab75\n-PODFILE CHECKSUM: e635d99ac1ac04e337c8e37d89213dcf86d730ca\n+PODFILE CHECKSUM: 557d6ad2cd7fd4073717f3c874bbe0ea71279370\nCOCOAPODS: 1.6.1\n" }, { "change_type": "MODIFY", "old_path": "native/ios/SquadCal.xcodeproj/project.pbxproj", "new_path": "native/ios/SquadCal.xcodeproj/project.pbxproj", "diff": "50114777890342C69E1A0D53 /* Feather.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 1BACB9A55ECC42C38F5FE331 /* Feather.ttf */; };\n5E9157361DD0AC6A00FF2AA8 /* libRCTAnimation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5E9157331DD0AC6500FF2AA8 /* libRCTAnimation.a */; };\n7F203569229475B300EEC30F /* libRCTBlob.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7F20354A2294720D00EEC30F /* libRCTBlob.a */; };\n+ 7F29576322B20D6200113FB6 /* libART.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7F29574022B20D4300113FB6 /* libART.a */; };\n7F761E602201141E001B6FB7 /* JavaScriptCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7F761E292201141E001B6FB7 /* JavaScriptCore.framework */; };\n7FB58ABE1E7F6BD500B4C1B1 /* Anaheim-Regular.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 7FB58ABB1E7F6BC600B4C1B1 /* Anaheim-Regular.ttf */; };\n7FB58ABF1E7F6BD600B4C1B1 /* Anaheim-Regular.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 7FB58ABB1E7F6BC600B4C1B1 /* Anaheim-Regular.ttf */; };\nremoteGlobalIDString = ADD01A681E09402E00F6D226;\nremoteInfo = \"RCTBlob-tvOS\";\n};\n+ 7F29573F22B20D4300113FB6 /* PBXContainerItemProxy */ = {\n+ isa = PBXContainerItemProxy;\n+ containerPortal = 7F29573A22B20D4300113FB6 /* ART.xcodeproj */;\n+ proxyType = 2;\n+ remoteGlobalIDString = 0CF68AC11AF0540F00FF9E5C;\n+ remoteInfo = ART;\n+ };\n+ 7F29574122B20D4300113FB6 /* PBXContainerItemProxy */ = {\n+ isa = PBXContainerItemProxy;\n+ containerPortal = 7F29573A22B20D4300113FB6 /* ART.xcodeproj */;\n+ proxyType = 2;\n+ remoteGlobalIDString = 323A12871E5F266B004975B8;\n+ remoteInfo = \"ART-tvOS\";\n+ };\n7F3DD3FE20521A4B00A0D652 /* PBXContainerItemProxy */ = {\nisa = PBXContainerItemProxy;\ncontainerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */;\n76DBEB73A008439E97F240AC /* Entypo.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = Entypo.ttf; path = \"../node_modules/react-native-vector-icons/Fonts/Entypo.ttf\"; sourceTree = \"<group>\"; };\n78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = \"wrapper.pb-project\"; name = RCTLinking.xcodeproj; path = \"../node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj\"; sourceTree = \"<group>\"; };\n7F2035422294720D00EEC30F /* RCTBlob.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = \"wrapper.pb-project\"; name = RCTBlob.xcodeproj; path = \"../../node_modules/react-native/Libraries/Blob/RCTBlob.xcodeproj\"; sourceTree = \"<group>\"; };\n+ 7F29573A22B20D4300113FB6 /* ART.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = \"wrapper.pb-project\"; name = ART.xcodeproj; path = \"../../node_modules/react-native/Libraries/ART/ART.xcodeproj\"; sourceTree = \"<group>\"; };\n7F761E292201141E001B6FB7 /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; };\n7FB58ABB1E7F6BC600B4C1B1 /* Anaheim-Regular.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = \"Anaheim-Regular.ttf\"; sourceTree = \"<group>\"; };\n7FB58ABC1E7F6BC600B4C1B1 /* OpenSans-Regular.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = \"OpenSans-Regular.ttf\"; sourceTree = \"<group>\"; };\n832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */,\n139FDEF61B0652A700C62182 /* libRCTWebSocket.a in Frameworks */,\n7F203569229475B300EEC30F /* libRCTBlob.a in Frameworks */,\n+ 7F29576322B20D6200113FB6 /* libART.a in Frameworks */,\n164ABF33429CFE672F0D2509 /* libPods-SquadCal.a in Frameworks */,\n);\nrunOnlyForDeploymentPostprocessing = 0;\nname = Products;\nsourceTree = \"<group>\";\n};\n+ 7F29573B22B20D4300113FB6 /* Products */ = {\n+ isa = PBXGroup;\n+ children = (\n+ 7F29574022B20D4300113FB6 /* libART.a */,\n+ 7F29574222B20D4300113FB6 /* libART-tvOS.a */,\n+ );\n+ name = Products;\n+ sourceTree = \"<group>\";\n+ };\n7FF0870B1E833C3F000A1ACF /* Frameworks */ = {\nisa = PBXGroup;\nchildren = (\n00C302D31ABCB9D200DB3ED1 /* RCTNetwork.xcodeproj */,\n832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */,\n139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */,\n+ 7F29573A22B20D4300113FB6 /* ART.xcodeproj */,\n);\nname = Libraries;\nsourceTree = \"<group>\";\nproductRefGroup = 83CBBA001A601CBA00E9B192 /* Products */;\nprojectDirPath = \"\";\nprojectReferences = (\n+ {\n+ ProductGroup = 7F29573B22B20D4300113FB6 /* Products */;\n+ ProjectRef = 7F29573A22B20D4300113FB6 /* ART.xcodeproj */;\n+ },\n{\nProductGroup = 5E91572E1DD0AC6500FF2AA8 /* Products */;\nProjectRef = 5E91572D1DD0AC6500FF2AA8 /* RCTAnimation.xcodeproj */;\nremoteRef = 7F20354B2294720D00EEC30F /* PBXContainerItemProxy */;\nsourceTree = BUILT_PRODUCTS_DIR;\n};\n+ 7F29574022B20D4300113FB6 /* libART.a */ = {\n+ isa = PBXReferenceProxy;\n+ fileType = archive.ar;\n+ path = libART.a;\n+ remoteRef = 7F29573F22B20D4300113FB6 /* PBXContainerItemProxy */;\n+ sourceTree = BUILT_PRODUCTS_DIR;\n+ };\n+ 7F29574222B20D4300113FB6 /* libART-tvOS.a */ = {\n+ isa = PBXReferenceProxy;\n+ fileType = archive.ar;\n+ path = \"libART-tvOS.a\";\n+ remoteRef = 7F29574122B20D4300113FB6 /* PBXContainerItemProxy */;\n+ sourceTree = BUILT_PRODUCTS_DIR;\n+ };\n7F3DD3FF20521A4B00A0D652 /* libReact.a */ = {\nisa = PBXReferenceProxy;\nfileType = archive.ar;\n" }, { "change_type": "MODIFY", "old_path": "native/package.json", "new_path": "native/package.json", "diff": "\"react-native-notifications\": \"git+https://git@github.com/ashoat/react-native-notifications.git\",\n\"react-native-onepassword\": \"git+https://git@github.com/DriveWealth/react-native-onepassword.git#aed794d8c6f0f2560b62a0012449abf6f1b3576c\",\n\"react-native-orientation-locker\": \"^1.1.5\",\n+ \"react-native-progress\": \"^3.6.0\",\n\"react-native-reanimated\": \"git+https://git@github.com/kmagiera/react-native-reanimated.git#0a6405dc21ed76185969a2970f642911519a59c1\",\n\"react-native-screens\": \"1.0.0-alpha.17\",\n\"react-native-segmented-control-tab\": \"^3.2.1\",\n" }, { "change_type": "MODIFY", "old_path": "yarn.lock", "new_path": "yarn.lock", "diff": "@@ -10305,6 +10305,15 @@ prop-types@^15.5.10, prop-types@^15.5.4, prop-types@^15.5.7, prop-types@^15.5.8,\nloose-envify \"^1.3.1\"\nobject-assign \"^4.1.1\"\n+prop-types@^15.7.2:\n+ version \"15.7.2\"\n+ resolved \"https://registry.yarnpkg.com/prop-types/-/prop-types-15.7.2.tgz#52c41e75b8c87e72b9d9360e0206b99dcbffa6c5\"\n+ integrity sha512-8QQikdH7//R2vurIJSutZ1smHYTcLpRWEOlHnzcWHmBYrOGUysKwSsrC89BCiFj3CbrfJ/nXFdJepOVrY1GCHQ==\n+ dependencies:\n+ loose-envify \"^1.4.0\"\n+ object-assign \"^4.1.1\"\n+ react-is \"^16.8.1\"\n+\nprotobufjs@^5.0.3:\nversion \"5.0.3\"\nresolved \"https://registry.yarnpkg.com/protobufjs/-/protobufjs-5.0.3.tgz#e4dfe9fb67c90b2630d15868249bcc4961467a17\"\n@@ -10673,7 +10682,7 @@ react-is@^16.6.3:\nresolved \"https://registry.yarnpkg.com/react-is/-/react-is-16.7.0.tgz#c1bd21c64f1f1364c6f70695ec02d69392f41bfa\"\nintegrity sha512-Z0VRQdF4NPDoI0tsXVMLkJLiwEBa+RP66g0xDHxgxysxSoCUccSten4RTF/UFvZF1dZvZ9Zu1sx+MDXwcOR34g==\n-react-is@^16.8.3, react-is@^16.8.4:\n+react-is@^16.8.1, react-is@^16.8.3, react-is@^16.8.4:\nversion \"16.8.6\"\nresolved \"https://registry.yarnpkg.com/react-is/-/react-is-16.8.6.tgz#5bbc1e2d29141c9fbdfed456343fe2bc430a6a16\"\nintegrity sha512-aUk3bHfZ2bRSVFFbbeVS4i+lNPZr3/WM5jT2J5omUVV1zzcs1nAaf3l51ctA5FFvCRbhrH0bdAsRRQddFJZPtA==\n@@ -10785,6 +10794,13 @@ react-native-orientation-locker@^1.1.5:\nresolved \"https://registry.yarnpkg.com/react-native-orientation-locker/-/react-native-orientation-locker-1.1.5.tgz#695babee0e0b97a9620a12bb677792d0b9b88ef8\"\nintegrity sha512-RY2kwXK1SNq8+nQN0xVCTdi0A08FnUtzR4dOOEm2dGUUIcxSqnseE7adx5cr+oqwd0WUqb043MS+NKDPMUCmMA==\n+react-native-progress@^3.6.0:\n+ version \"3.6.0\"\n+ resolved \"https://registry.yarnpkg.com/react-native-progress/-/react-native-progress-3.6.0.tgz#feaf37491f91bb421207fd761e20cb7258a2a3a6\"\n+ integrity sha512-zzTe595xaaskyfR5OzaGrU4O0R+YkgdEw+EspgGD7wh8Hu0fs6ue3xLW+HEbTjOCn62pCRivwi3NxbpWNBCC7Q==\n+ dependencies:\n+ prop-types \"^15.7.2\"\n+\n\"react-native-reanimated@git+https://git@github.com/kmagiera/react-native-reanimated.git#0a6405dc21ed76185969a2970f642911519a59c1\":\nversion \"1.0.1\"\nresolved \"git+https://git@github.com/kmagiera/react-native-reanimated.git#0a6405dc21ed76185969a2970f642911519a59c1\"\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] react-native-progress Has a dependency on ReactART
129,187
13.06.2019 01:19:34
14,400
f179204050c59090e31f5f3811b20e36697a0cac
[native] Display progress of upload on each image
[ { "change_type": "MODIFY", "old_path": "native/chat/multimedia-message-multimedia.react.js", "new_path": "native/chat/multimedia-message-multimedia.react.js", "diff": "@@ -19,6 +19,8 @@ import * as React from 'react';\nimport PropTypes from 'prop-types';\nimport { View, TouchableWithoutFeedback, StyleSheet } from 'react-native';\nimport Animated from 'react-native-reanimated';\n+import * as Progress from 'react-native-progress';\n+import Icon from 'react-native-vector-icons/Feather';\nimport Multimedia from '../media/multimedia.react';\n@@ -85,16 +87,55 @@ class MultimediaMessageMultimedia extends React.PureComponent<Props, State> {\n}\nrender() {\n- const { mediaInfo, style } = this.props;\n+ const { mediaInfo, pendingUpload, style } = this.props;\n+\n+ let failed = mediaInfo.id.startsWith('localUpload');\n+ let progressPercent = 1;\n+ if (pendingUpload) {\n+ ({ progressPercent, failed } = pendingUpload);\n+ }\n+\n+ let progressIndicator;\n+ if (failed) {\n+ progressIndicator = (\n+ <View style={styles.centerContainer}>\n+ <Icon\n+ name=\"alert-circle\"\n+ style={styles.uploadError}\n+ size={64}\n+ />\n+ </View>\n+ );\n+ } else if (progressPercent !== 1) {\n+ progressIndicator = (\n+ <View style={styles.centerContainer}>\n+ <Progress.Circle\n+ size={100}\n+ indeterminate={progressPercent === 0}\n+ progress={progressPercent}\n+ borderWidth={5}\n+ fill=\"#DDDDDD\"\n+ unfilledColor=\"#DDDDDD\"\n+ color=\"#88BB88\"\n+ thickness={15}\n+ showsText={true}\n+ textStyle={styles.progressIndicatorText}\n+ />\n+ </View>\n+ );\n+ }\n+\nconst wrapperStyles = [ styles.expand ];\nif (this.state.hidden && this.state.opacity) {\nwrapperStyles.push({ opacity: this.state.opacity });\n}\n+\nreturn (\n<TouchableWithoutFeedback onPress={this.onPress}>\n<View style={[ styles.expand, style ]} ref={this.viewRef}>\n<Animated.View style={wrapperStyles}>\n<Multimedia mediaInfo={mediaInfo} />\n+ {progressIndicator}\n</Animated.View>\n</View>\n</TouchableWithoutFeedback>\n@@ -127,6 +168,25 @@ const styles = StyleSheet.create({\nexpand: {\nflex: 1,\n},\n+ centerContainer: {\n+ position: 'absolute',\n+ top: 0,\n+ bottom: 0,\n+ left: 0,\n+ right: 0,\n+ alignItems: 'center',\n+ justifyContent: 'center',\n+ },\n+ progressIndicatorText: {\n+ color: 'black',\n+ fontSize: 21,\n+ },\n+ uploadError: {\n+ color: \"white\",\n+ textShadowColor: \"#000\",\n+ textShadowOffset: { width: 0, height: 1 },\n+ textShadowRadius: 1,\n+ },\n});\nexport default MultimediaMessageMultimedia;\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Display progress of upload on each image
129,187
13.06.2019 18:25:21
14,400
2793ec81d4faab630d063579761cc3ea19f7ffb2
[native] Unify conception of sendFailed for MultimediaMessage Across `multimediaMessageItemHeight`, `MultimediaMessage`, and `FailedSend`
[ { "change_type": "MODIFY", "old_path": "native/chat/chat-input-state-container.react.js", "new_path": "native/chat/chat-input-state-container.react.js", "diff": "@@ -139,11 +139,11 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\nconst previouslyCompletedUploadIDs = previouslyComplete[localMessageID];\nif (!rawMessageInfo && prevRawMessageInfo) {\n- // A previously failed message got pruned out\npendingUploadsChanged = true;\ncontinue;\n} else if (completedUploadIDs === null) {\n// All of this message's uploads have been completed\n+ newPendingUploads[localMessageID] = {};\nif (previouslyCompletedUploadIDs !== null) {\nreadyMessageIDs.push(localMessageID);\npendingUploadsChanged = true;\n@@ -160,9 +160,7 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\nfor (let localUploadID in messagePendingUploads) {\nif (!completedUploadIDs.has(localUploadID)) {\nnewUploads[localUploadID] = messagePendingUploads[localUploadID];\n- continue;\n- }\n- if (\n+ } else if (\n!previouslyCompletedUploadIDs ||\n!previouslyCompletedUploadIDs.has(localUploadID)\n) {\n@@ -170,21 +168,12 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\n}\n}\n- const numOldUploads = Object.keys(messagePendingUploads).length;\nconst numNewUploads = Object.keys(newUploads).length;\n- const allUploadsComplete = numNewUploads === 0;\n- const someUploadsComplete = numNewUploads > numOldUploads;\n- if (!allUploadsComplete && !someUploadsComplete) {\n- newPendingUploads[localMessageID] = messagePendingUploads;\n- } else if (!allUploadsComplete) {\n- newPendingUploads[localMessageID] = newUploads;\n- }\n-\nif (uploadsChanged) {\npendingUploadsChanged = true;\n- if (allUploadsComplete) {\n- readyMessageIDs.push(localMessageID);\n- }\n+ newPendingUploads[localMessageID] = newUploads;\n+ } else {\n+ newPendingUploads[localMessageID] = messagePendingUploads;\n}\n}\nif (pendingUploadsChanged) {\n" }, { "change_type": "MODIFY", "old_path": "native/chat/chat-input-state.js", "new_path": "native/chat/chat-input-state.js", "diff": "@@ -16,14 +16,20 @@ const pendingMultimediaUploadPropType = PropTypes.shape({\nprogressPercent: PropTypes.number.isRequired,\n});\n-export type PendingMultimediaUploads = {\n- [localMessageID: string]: {\n+export type MessagePendingUploads = {\n[localUploadID: string]: PendingMultimediaUpload,\n- },\n+};\n+\n+const messagePendingUploadsPropType = PropTypes.objectOf(\n+ pendingMultimediaUploadPropType,\n+);\n+\n+export type PendingMultimediaUploads = {\n+ [localMessageID: string]: MessagePendingUploads,\n};\nconst pendingMultimediaUploadsPropType = PropTypes.objectOf(\n- PropTypes.objectOf(pendingMultimediaUploadPropType),\n+ messagePendingUploadsPropType,\n);\nexport type ChatInputState = {|\n@@ -68,6 +74,7 @@ function withChatInputState<\n}\nexport {\n+ messagePendingUploadsPropType,\npendingMultimediaUploadPropType,\nchatInputStatePropType,\nChatInputStateContext,\n" }, { "change_type": "MODIFY", "old_path": "native/chat/failed-send.react.js", "new_path": "native/chat/failed-send.react.js", "diff": "@@ -28,7 +28,7 @@ import Button from '../components/button.react';\ntype Props = {|\nitem: ChatMessageInfoItemWithHeight,\n// Redux state\n- rawMessageInfo: RawMessageInfo,\n+ rawMessageInfo: ?RawMessageInfo,\n// Redux dispatch functions\ndispatchActionPromise: DispatchActionPromise,\n// async functions that hit server APIs\n@@ -42,24 +42,13 @@ class FailedSend extends React.PureComponent<Props> {\nstatic propTypes = {\nitem: chatMessageItemPropType.isRequired,\n- rawMessageInfo: PropTypes.object.isRequired,\n+ rawMessageInfo: PropTypes.object,\ndispatchActionPromise: PropTypes.func.isRequired,\nsendTextMessage: PropTypes.func.isRequired,\n};\nrender() {\n- const { isViewer } = this.props.item.messageInfo.creator;\n- if (!isViewer) {\n- return null;\n- }\n- const { id } = this.props.item.messageInfo;\n- if (id !== null && id !== undefined) {\n- return null;\n- }\n- const sendFailed = this.props.item.localMessageInfo\n- ? this.props.item.localMessageInfo.sendFailed\n- : null;\n- if (!sendFailed) {\n+ if (!this.props.rawMessageInfo) {\nreturn null;\n}\nreturn (\n@@ -78,6 +67,9 @@ class FailedSend extends React.PureComponent<Props> {\nretrySend = () => {\nconst { rawMessageInfo } = this.props;\n+ if (!rawMessageInfo) {\n+ return;\n+ }\nif (rawMessageInfo.type === messageTypes.TEXT) {\nconst newRawMessageInfo = {\n...rawMessageInfo,\n" }, { "change_type": "MODIFY", "old_path": "native/chat/message-list-container.react.js", "new_path": "native/chat/message-list-container.react.js", "diff": "@@ -26,7 +26,11 @@ import invariant from 'invariant';\nimport { connect } from 'lib/utils/redux-utils';\nimport { threadInfoSelector } from 'lib/selectors/thread-selectors';\nimport { messageListData } from 'lib/selectors/chat-selectors';\n-import { messageKey, robotextToRawString } from 'lib/shared/message-utils';\n+import {\n+ messageKey,\n+ messageID,\n+ robotextToRawString,\n+} from 'lib/shared/message-utils';\nimport { onlyEmojiRegex } from 'lib/shared/emojis';\nimport MessageList from './message-list.react';\n@@ -40,6 +44,11 @@ import {\ntextMessageMaxWidthSelector,\ncomposedMessageMaxWidthSelector,\n} from './composed-message-width';\n+import {\n+ type ChatInputState,\n+ chatInputStatePropType,\n+ withChatInputState,\n+} from './chat-input-state';\nexport type ChatMessageItemWithHeight =\n{| itemType: \"loader\" |} |\n@@ -59,6 +68,8 @@ type Props = {|\nmessageListData: $ReadOnlyArray<ChatMessageItem>,\ntextMessageMaxWidth: number,\ncomposedMessageMaxWidth: number,\n+ // withChatInputState\n+ chatInputState: ?ChatInputState,\n|};\ntype State = {|\ntextToMeasure: TextToMeasure[],\n@@ -82,6 +93,7 @@ class MessageListContainer extends React.PureComponent<Props, State> {\nmessageListData: PropTypes.arrayOf(chatMessageItemPropType).isRequired,\ntextMessageMaxWidth: PropTypes.number.isRequired,\ncomposedMessageMaxWidth: PropTypes.number.isRequired,\n+ chatInputState: chatInputStatePropType,\n};\nstatic navigationOptions = ({ navigation }) => ({\nheaderTitle: (\n@@ -185,7 +197,13 @@ class MessageListContainer extends React.PureComponent<Props, State> {\nconst oldNavThreadInfo = MessageListContainer.getThreadInfo(prevProps);\nconst newNavThreadInfo = MessageListContainer.getThreadInfo(this.props);\n- if (newListData === oldListData && newNavThreadInfo === oldNavThreadInfo) {\n+ const oldChatInputState = prevProps.chatInputState;\n+ const newChatInputState = this.props.chatInputState;\n+ if (\n+ newListData === oldListData &&\n+ newNavThreadInfo === oldNavThreadInfo &&\n+ newChatInputState === oldChatInputState\n+ ) {\nreturn;\n}\n@@ -254,19 +272,23 @@ class MessageListContainer extends React.PureComponent<Props, State> {\n}\nmergeHeightsIntoListData(textHeights?: Map<string, number>) {\n- const listData = this.props.messageListData;\n+ const { messageListData: listData, chatInputState } = this.props;\nconst threadInfo = MessageListContainer.getThreadInfo(this.props);\nconst listDataWithHeights = listData.map((item: ChatMessageItem) => {\nif (item.itemType !== \"message\") {\nreturn item;\n}\nconst { messageInfo } = item;\n- const id = messageKey(messageInfo);\n+ const key = messageKey(messageInfo);\nif (messageInfo.type === messageTypes.MULTIMEDIA) {\n// Conditional due to Flow...\nconst localMessageInfo = item.localMessageInfo\n? item.localMessageInfo\n: null;\n+ const id = messageID(messageInfo);\n+ const pendingUploads = chatInputState\n+ && chatInputState.pendingUploads\n+ && chatInputState.pendingUploads[id];\nreturn {\nitemType: \"message\",\nmessageShapeType: \"multimedia\",\n@@ -276,6 +298,7 @@ class MessageListContainer extends React.PureComponent<Props, State> {\nstartsConversation: item.startsConversation,\nstartsCluster: item.startsCluster,\nendsCluster: item.endsCluster,\n+ pendingUploads,\ncontentHeight: multimediaMessageContentHeight(\nmessageInfo,\nthis.props.composedMessageMaxWidth,\n@@ -283,10 +306,10 @@ class MessageListContainer extends React.PureComponent<Props, State> {\n};\n}\ninvariant(textHeights, \"textHeights not set\");\n- const textHeight = textHeights.get(id);\n+ const textHeight = textHeights.get(key);\ninvariant(\ntextHeight !== null && textHeight !== undefined,\n- `height for ${id} should be set`,\n+ `height for ${key} should be set`,\n);\nif (messageInfo.type === messageTypes.TEXT) {\n// Conditional due to Flow...\n@@ -363,4 +386,4 @@ export default connect(\ncomposedMessageMaxWidth: composedMessageMaxWidthSelector(state),\n};\n},\n-)(MessageListContainer);\n+)(withChatInputState(MessageListContainer));\n" }, { "change_type": "MODIFY", "old_path": "native/chat/multimedia-message-multimedia.react.js", "new_path": "native/chat/multimedia-message-multimedia.react.js", "diff": "@@ -31,6 +31,7 @@ type Props = {|\nstyle?: ImageStyle,\nmodalsClosed: bool,\nlightboxPosition: ?Animated.Value,\n+ inProgress: bool,\npendingUpload: ?PendingMultimediaUpload,\n|};\ntype State = {|\n@@ -45,6 +46,7 @@ class MultimediaMessageMultimedia extends React.PureComponent<Props, State> {\nverticalBounds: verticalBoundsPropType,\nmodalsClosed: PropTypes.bool.isRequired,\nlightboxPosition: PropTypes.instanceOf(Animated.Value),\n+ inProgress: PropTypes.bool.isRequired,\npendingUpload: pendingMultimediaUploadPropType,\n};\nview: ?View;\n@@ -87,9 +89,9 @@ class MultimediaMessageMultimedia extends React.PureComponent<Props, State> {\n}\nrender() {\n- const { mediaInfo, pendingUpload, style } = this.props;\n+ const { mediaInfo, pendingUpload, style, inProgress } = this.props;\n- let failed = mediaInfo.id.startsWith('localUpload');\n+ let failed = mediaInfo.id.startsWith('localUpload') && !inProgress;\nlet progressPercent = 1;\nif (pendingUpload) {\n({ progressPercent, failed } = pendingUpload);\n" }, { "change_type": "MODIFY", "old_path": "native/chat/multimedia-message.react.js", "new_path": "native/chat/multimedia-message.react.js", "diff": "@@ -14,6 +14,7 @@ import {\nverticalBoundsPropType,\n} from '../media/vertical-bounds';\nimport type { AppState } from '../redux/redux-setup';\n+import type { MessagePendingUploads } from './chat-input-state';\nimport * as React from 'react';\nimport {\n@@ -33,11 +34,6 @@ import ComposedMessage from './composed-message.react';\nimport MultimediaMessageMultimedia from './multimedia-message-multimedia.react';\nimport { modalsClosedSelector } from '../selectors/nav-selectors';\nimport { withLightboxPositionContext } from '../media/lightbox-navigator.react';\n-import {\n- type ChatInputState,\n- chatInputStatePropType,\n- withChatInputState,\n-} from './chat-input-state';\nexport type ChatMultimediaMessageInfoItem = {|\nitemType: \"message\",\n@@ -48,6 +44,7 @@ export type ChatMultimediaMessageInfoItem = {|\nstartsConversation: bool,\nstartsCluster: bool,\nendsCluster: bool,\n+ pendingUploads: ?MessagePendingUploads,\ncontentHeight: number,\n|};\n@@ -92,6 +89,32 @@ function multimediaMessageContentHeight(\nreturn numRows * imageHeight + (numRows - 1) * spaceBetweenImages;\n}\n+function sendFailed(item: ChatMultimediaMessageInfoItem) {\n+ const { messageInfo, localMessageInfo, pendingUploads } = item;\n+ const { id: serverID } = messageInfo;\n+ if (serverID !== null && serverID !== undefined) {\n+ return false;\n+ }\n+\n+ const { isViewer } = messageInfo.creator;\n+ if (!isViewer) {\n+ return false;\n+ }\n+\n+ if (localMessageInfo && localMessageInfo.sendFailed) {\n+ return true;\n+ }\n+\n+ for (let media of messageInfo.media) {\n+ const pendingUpload = pendingUploads && pendingUploads[media.id];\n+ if (pendingUpload && pendingUpload.failed) {\n+ return true;\n+ }\n+ }\n+\n+ return !pendingUploads;\n+}\n+\nfunction multimediaMessageItemHeight(\nitem: ChatMultimediaMessageInfoItem,\nviewerID: ?string,\n@@ -106,12 +129,7 @@ function multimediaMessageItemHeight(\nif (endsCluster) {\nheight += 7; // extra padding at the end of a cluster\n}\n- if (\n- isViewer &&\n- id !== null && id !== undefined &&\n- item.localMessageInfo &&\n- item.localMessageInfo.sendFailed\n- ) {\n+ if (sendFailed(item)) {\nheight += 22; // extra padding for sendFailed\n}\nreturn height;\n@@ -126,8 +144,6 @@ type Props = {|\nmodalsClosed: bool,\n// withLightboxPositionContext\nlightboxPosition: ?Animated.Value,\n- // withChatInputState\n- chatInputState: ?ChatInputState,\n|};\nclass MultimediaMessage extends React.PureComponent<Props> {\n@@ -138,25 +154,14 @@ class MultimediaMessage extends React.PureComponent<Props> {\nverticalBounds: verticalBoundsPropType,\nmodalsClosed: PropTypes.bool.isRequired,\nlightboxPosition: PropTypes.instanceOf(Animated.Value),\n- chatInputState: chatInputStatePropType,\n};\nrender() {\n- const { messageInfo, contentHeight } = this.props.item;\n- const { id, creator } = messageInfo;\n- const { isViewer } = creator;\n- const heightStyle = { height: contentHeight };\n-\n- const sendFailed =\n- isViewer &&\n- (id === null || id === undefined) &&\n- this.props.item.localMessageInfo &&\n- this.props.item.localMessageInfo.sendFailed;\n-\n+ const heightStyle = { height: this.props.item.contentHeight };\nreturn (\n<ComposedMessage\nitem={this.props.item}\n- sendFailed={!!sendFailed}\n+ sendFailed={sendFailed(this.props.item)}\nborderRadius={16}\nstyle={styles.row}\n>\n@@ -216,17 +221,13 @@ class MultimediaMessage extends React.PureComponent<Props> {\nindex: number,\nstyle?: ?ImageStyle,\n): React.Node {\n- const id = messageID(this.props.item.messageInfo);\n+ const { pendingUploads, messageInfo } = this.props.item;\nconst mediaInfo = {\n...media,\n- messageID: id,\n+ messageID: messageID(messageInfo),\nindex,\n};\n- const { chatInputState } = this.props;\n- const pendingUpload = chatInputState\n- && chatInputState.pendingUploads\n- && chatInputState.pendingUploads[id]\n- && chatInputState.pendingUploads[id][media.id];\n+ const pendingUpload = pendingUploads && pendingUploads[media.id];\nreturn (\n<MultimediaMessageMultimedia\nmediaInfo={mediaInfo}\n@@ -235,6 +236,7 @@ class MultimediaMessage extends React.PureComponent<Props> {\nstyle={style}\nmodalsClosed={this.props.modalsClosed}\nlightboxPosition={this.props.lightboxPosition}\n+ inProgress={!!pendingUploads}\npendingUpload={pendingUpload}\nkey={index}\n/>\n@@ -274,15 +276,13 @@ const styles = StyleSheet.create({\n},\n});\n-\n-const WrappedMultimediaMessage = withChatInputState(\n+const WrappedMultimediaMessage =\nwithLightboxPositionContext(\nconnect(\n(state: AppState) => ({\nmodalsClosed: modalsClosedSelector(state),\n}),\n)(MultimediaMessage),\n- ),\n);\nexport {\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Unify conception of sendFailed for MultimediaMessage Across `multimediaMessageItemHeight`, `MultimediaMessage`, and `FailedSend`
129,187
14.06.2019 19:23:24
14,400
c0bbdce91a73d5e2904764cef00b15c9395c6ea7
[native] Correct dimensions after resize
[ { "change_type": "MODIFY", "old_path": "lib/types/media-types.js", "new_path": "lib/types/media-types.js", "diff": "@@ -52,10 +52,7 @@ export type UploadMultimediaResult = {|\nexport type UpdateMultimediaMessageMediaPayload = {|\nmessageID: string,\ncurrentMediaID: string,\n- mediaUpdate: $Shape<{|\n- id: string,\n- uri: string,\n- |}>,\n+ mediaUpdate: $Shape<Media>,\n|};\nexport type UploadDeletionRequest = {|\n" }, { "change_type": "MODIFY", "old_path": "native/chat/chat-input-state-container.react.js", "new_path": "native/chat/chat-input-state-container.react.js", "diff": "@@ -347,7 +347,8 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\nmediaUpdate: {\nid: result.id,\nuri: result.uri,\n- mediaType,\n+ type: mediaType,\n+ dimensions: conversionResult.dimensions,\n},\n},\n);\n" }, { "change_type": "MODIFY", "old_path": "native/utils/media-utils.js", "new_path": "native/utils/media-utils.js", "diff": "import type { Dimensions, MediaType } from 'lib/types/media-types';\nimport type { GalleryImageInfo } from '../media/image-gallery-image.react';\n-import { Platform } from 'react-native';\n+import { Platform, Image } from 'react-native';\nimport base64 from 'base-64';\nimport ImageResizer from 'react-native-image-resizer';\n@@ -84,17 +84,28 @@ function dataURIToIntArray(dataURI: string): Uint8Array {\nreturn stringToIntArray(data);\n}\n+function getDimensions(uri: string): Promise<Dimensions> {\n+ return new Promise((resolve, reject) => {\n+ Image.getSize(\n+ uri,\n+ (width: number, height: number) => resolve({ height, width }),\n+ reject,\n+ );\n+ });\n+}\n+\ntype MediaConversionResult = {|\nuploadURI: string,\nshouldDisposePath: ?string,\nname: string,\nmime: string,\nmediaType: MediaType,\n+ dimensions: Dimensions,\n|};\nasync function convertMedia(\nvalidationResult: MediaValidationResult,\n): Promise<?MediaConversionResult> {\n- const { uri } = validationResult;\n+ const { uri, dimensions } = validationResult;\nlet { blob } = validationResult;\nconst { type: reportedMIME, size } = blob.data;\n@@ -109,12 +120,14 @@ async function convertMedia(\ncompressFormat,\n0.92,\n);\n+ const resizedDimensions = await getDimensions(resizedURI);\nreturn {\nuploadURI: resizedURI,\nshouldDisposePath: path,\nname,\nmime: \"image/jpeg\",\nmediaType: \"photo\",\n+ dimensions: resizedDimensions,\n};\n} catch (e) { }\n}\n@@ -135,6 +148,7 @@ async function convertMedia(\nname,\nmime,\nmediaType,\n+ dimensions,\n};\n}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Correct dimensions after resize
129,187
14.06.2019 20:13:54
14,400
9a37a4faea7b73bc1510b4749d365717f44e39e5
[native] Allow user to retry MultimediaMessage when it fails
[ { "change_type": "MODIFY", "old_path": "native/chat/chat-input-state-container.react.js", "new_path": "native/chat/chat-input-state-container.react.js", "diff": "@@ -301,7 +301,14 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\n},\n);\n- await Promise.all(\n+ await this.uploadFiles(localMessageID, imageInfos);\n+ }\n+\n+ uploadFiles(\n+ localMessageID: string,\n+ imageInfos: $ReadOnlyArray<ImageInfo>,\n+ ) {\n+ return Promise.all(\nimageInfos.map(imageInfo => this.uploadFile(localMessageID, imageInfo)),\n);\n}\n@@ -437,6 +444,82 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\n}\nretryMultimediaMessage = async (localMessageID: string) => {\n+ const rawMessageInfo = this.props.messageStoreMessages[localMessageID];\n+ invariant(\n+ rawMessageInfo && rawMessageInfo.type === messageTypes.MULTIMEDIA,\n+ \"messageStore should contain entry for message being retried\",\n+ );\n+\n+ const incompleteMedia = rawMessageInfo.media.filter(\n+ ({ id }) => id.startsWith('localUpload'),\n+ );\n+ if (incompleteMedia.length === 0) {\n+ const newRawMessageInfo = { ...rawMessageInfo, time: Date.now() };\n+ this.dispatchMultimediaMessageAction(newRawMessageInfo);\n+ this.setState(prevState => ({\n+ pendingUploads: {\n+ ...prevState.pendingUploads,\n+ [localMessageID]: {},\n+ },\n+ }));\n+ return;\n+ }\n+\n+ let pendingUploads = this.state.pendingUploads[localMessageID];\n+ if (!pendingUploads) {\n+ pendingUploads = {};\n+ }\n+\n+ const retryMedia = incompleteMedia.filter(\n+ ({ id }) => (!pendingUploads[id] || pendingUploads[id].failed),\n+ );\n+ if (retryMedia.length === 0) {\n+ // All media are already in the process of being uploaded\n+ return;\n+ }\n+\n+ const imageGalleryImages = retryMedia.map(\n+ ({ dimensions, uri }) => ({ ...dimensions, uri }),\n+ );\n+ const validationResults = await Promise.all(\n+ imageGalleryImages.map(validateMedia),\n+ );\n+\n+ const imageInfos = [];\n+ for (let i = 0; i < validationResults.length; i++) {\n+ const result = validationResults[i];\n+ if (!result) {\n+ continue;\n+ }\n+ const { id } = retryMedia[i];\n+ imageInfos.push({\n+ ...result,\n+ localID: id,\n+ });\n+ }\n+ if (imageInfos.length < validationResults.length) {\n+ // Since we filter our MIME types in our calls to CameraRoll,\n+ // this should never be triggered\n+ console.log('unexpected MIME type found');\n+ }\n+ if (imageInfos.length === 0) {\n+ return;\n+ }\n+\n+ for (let { localID } of imageInfos) {\n+ pendingUploads[localID] = {\n+ failed: null,\n+ progressPercent: 0,\n+ };\n+ }\n+ this.setState(prevState => ({\n+ pendingUploads: {\n+ ...prevState.pendingUploads,\n+ [localMessageID]: pendingUploads,\n+ },\n+ }));\n+\n+ await this.uploadFiles(localMessageID, imageInfos);\n}\nrender() {\n" }, { "change_type": "MODIFY", "old_path": "native/chat/failed-send.react.js", "new_path": "native/chat/failed-send.react.js", "diff": "@@ -22,6 +22,11 @@ import {\nsendTextMessageActionTypes,\nsendTextMessage,\n} from 'lib/actions/message-actions';\n+import {\n+ type ChatInputState,\n+ chatInputStatePropType,\n+ withChatInputState,\n+} from './chat-input-state';\nimport Button from '../components/button.react';\n@@ -37,6 +42,8 @@ type Props = {|\nlocalID: string,\ntext: string,\n) => Promise<SendMessageResult>,\n+ // withChatInputState\n+ chatInputState: ?ChatInputState,\n|};\nclass FailedSend extends React.PureComponent<Props> {\n@@ -45,6 +52,7 @@ class FailedSend extends React.PureComponent<Props> {\nrawMessageInfo: PropTypes.object,\ndispatchActionPromise: PropTypes.func.isRequired,\nsendTextMessage: PropTypes.func.isRequired,\n+ chatInputState: chatInputStatePropType,\n};\nrender() {\n@@ -77,14 +85,23 @@ class FailedSend extends React.PureComponent<Props> {\n};\nthis.props.dispatchActionPromise(\nsendTextMessageActionTypes,\n- this.sendMessageAction(newRawMessageInfo),\n+ this.sendTextMessageAction(newRawMessageInfo),\nundefined,\nnewRawMessageInfo,\n);\n+ } else if (rawMessageInfo.type === messageTypes.MULTIMEDIA) {\n+ const { localID } = rawMessageInfo;\n+ invariant(localID, \"failed RawMessageInfo should have localID\");\n+ const { chatInputState } = this.props;\n+ invariant(\n+ chatInputState,\n+ `chatInputState should be initialized before user can hit retry`,\n+ );\n+ chatInputState.retryMultimediaMessage(localID);\n}\n}\n- async sendMessageAction(messageInfo: RawTextMessageInfo) {\n+ async sendTextMessageAction(messageInfo: RawTextMessageInfo) {\ntry {\nconst { localID } = messageInfo;\ninvariant(\n@@ -137,4 +154,4 @@ export default connect(\n};\n},\n{ sendTextMessage },\n-)(FailedSend);\n+)(withChatInputState(FailedSend));\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Allow user to retry MultimediaMessage when it fails
129,187
14.06.2019 23:59:41
14,400
d66fc0aa367e6f43fedeb7e82d58185170df5ba5
Reset chat input state when viewerID changes
[ { "change_type": "MODIFY", "old_path": "native/chat/chat-input-state-container.react.js", "new_path": "native/chat/chat-input-state-container.react.js", "diff": "@@ -119,6 +119,11 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\n}\ncomponentDidUpdate(prevProps: Props, prevState: State) {\n+ if (this.props.viewerID !== prevProps.viewerID) {\n+ this.setState({ pendingUploads: {} });\n+ return;\n+ }\n+\nconst currentlyComplete = ChatInputStateContainer.getCompletedUploads(\nthis.props,\nthis.state,\n" }, { "change_type": "MODIFY", "old_path": "web/chat/chat-input-state-container.react.js", "new_path": "web/chat/chat-input-state-container.react.js", "diff": "@@ -120,6 +120,11 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\n}\ncomponentDidUpdate(prevProps: Props, prevState: State) {\n+ if (this.props.viewerID !== prevProps.viewerID) {\n+ this.setState({ pendingUploads: {} });\n+ return;\n+ }\n+\nconst previouslyAssignedMessageIDs = new Set();\nfor (let threadID in prevState.pendingUploads) {\nconst pendingUploads = prevState.pendingUploads[threadID];\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Reset chat input state when viewerID changes
129,187
15.06.2019 00:43:47
14,400
c49e598f537a2f73237be34c01a64e3cb6d53cc5
[native] Tune image compression parameters
[ { "change_type": "MODIFY", "old_path": "native/utils/media-utils.js", "new_path": "native/utils/media-utils.js", "diff": "@@ -27,7 +27,7 @@ async function validateMedia(\nconst { uri, ...dimensions } = imageInfo;\nconst response = await fetch(uri);\nconst blob = await response.blob();\n- const reportedMIME = blob.data.type;\n+ const reportedMIME = blob.type;\nconst mediaType = mimeTypesToMediaTypes[reportedMIME];\nif (!mediaType) {\nreturn null;\n@@ -108,17 +108,22 @@ async function convertMedia(\nconst { uri, dimensions } = validationResult;\nlet { blob } = validationResult;\n- const { type: reportedMIME, size } = blob.data;\n- if (reportedMIME === \"image/heic\" || size > 500000) {\n+ const { type: reportedMIME, size } = blob;\n+ if (\n+ reportedMIME === \"image/heic\" ||\n+ size > 5e6 ||\n+ (size > 5e5 && (dimensions.width > 3000 || dimensions.height > 2000))\n+ ) {\ntry {\nconst compressFormat = reportedMIME === \"image/png\" ? \"PNG\" : \"JPEG\";\n+ const compressQuality = size > 5e6 ? 92 : 100;\nconst { uri: resizedURI, path, name } =\nawait ImageResizer.createResizedImage(\nuri,\n3000,\n2000,\ncompressFormat,\n- 0.92,\n+ compressQuality,\n);\nconst resizedDimensions = await getDimensions(resizedURI);\nreturn {\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Tune image compression parameters
129,187
18.06.2019 15:13:33
14,400
53d6a0d018a9dd9604360e3e7e4016b263023c74
Type memoized functions instead of using existential operator
[ { "change_type": "MODIFY", "old_path": "lib/selectors/chat-selectors.js", "new_path": "lib/selectors/chat-selectors.js", "diff": "@@ -244,11 +244,7 @@ function createChatMessageItems(\nreturn [...chatMessageItems, ({ itemType: \"loader\" }: ChatMessageItem)];\n}\n-const baseMessageListData: (\n- threadID: string,\n-) => (\n- state: BaseAppState<*>,\n-) => ChatMessageItem[] = (threadID: string) => createSelector(\n+const baseMessageListData = (threadID: string) => createSelector(\n(state: BaseAppState<*>) => state.messageStore,\n(state: BaseAppState<*>) => state.currentUserInfo &&\nstate.currentUserInfo.id,\n@@ -267,7 +263,11 @@ const baseMessageListData: (\nthreadInfos,\n),\n);\n-const messageListData = _memoize<*, *>(baseMessageListData);\n+const messageListData: (\n+ threadID: string,\n+) => (\n+ state: BaseAppState<*>,\n+) => ChatMessageItem[] = _memoize(baseMessageListData);\nexport {\ncreateChatThreadItem,\n" }, { "change_type": "MODIFY", "old_path": "lib/selectors/loading-selectors.js", "new_path": "lib/selectors/loading-selectors.js", "diff": "@@ -55,7 +55,12 @@ const baseCreateLoadingStatusSelector = (\n);\n};\n-const createLoadingStatusSelector = _memoize<*, *>(\n+const createLoadingStatusSelector: (\n+ actionTypes: ActionTypes<*, *, *>,\n+ overrideKey?: string,\n+) => (\n+ state: BaseAppState<*>,\n+) => LoadingStatus = _memoize(\nbaseCreateLoadingStatusSelector,\ngetTrackingKey,\n);\n" }, { "change_type": "MODIFY", "old_path": "lib/selectors/thread-selectors.js", "new_path": "lib/selectors/thread-selectors.js", "diff": "@@ -189,11 +189,7 @@ const unreadCount: (state: BaseAppState<*>) => number = createSelector(\n)(threadInfos),\n);\n-const baseOtherUsersButNoOtherAdmins: (\n- threadID: string,\n-) => (\n- state: BaseAppState<*>,\n-) => bool = (threadID: string) => createSelector(\n+const baseOtherUsersButNoOtherAdmins = (threadID: string) => createSelector(\n(state: BaseAppState<*>) => state.threadStore.threadInfos[threadID],\nrelativeMemberInfoSelectorForMembersOfThread(threadID),\n(threadInfo: ?RawThreadInfo, members: RelativeMemberInfo[]): bool => {\n@@ -220,8 +216,11 @@ const baseOtherUsersButNoOtherAdmins: (\n},\n);\n-const otherUsersButNoOtherAdmins =\n- _memoize<*, *>(baseOtherUsersButNoOtherAdmins);\n+const otherUsersButNoOtherAdmins: (\n+ threadID: string,\n+) => (\n+ state: BaseAppState<*>,\n+) => bool = _memoize(baseOtherUsersButNoOtherAdmins);\nfunction mostRecentReadThread(\nmessageStore: MessageStore,\n" }, { "change_type": "MODIFY", "old_path": "lib/selectors/user-selectors.js", "new_path": "lib/selectors/user-selectors.js", "diff": "@@ -49,13 +49,11 @@ function userIDsToRelativeUserInfos(\n}\n// Includes current user at the start\n-const baseRelativeMemberInfoSelectorForMembersOfThread: (\n- threadID: string,\n-) => (\n- state: BaseAppState<*>,\n-) => RelativeMemberInfo[] = (threadID: string) => createSelector(\n+const baseRelativeMemberInfoSelectorForMembersOfThread =\n+ (threadID: string) => createSelector(\n(state: BaseAppState<*>) => state.threadStore.threadInfos[threadID],\n- (state: BaseAppState<*>) => state.currentUserInfo && state.currentUserInfo.id,\n+ (state: BaseAppState<*>) => state.currentUserInfo\n+ && state.currentUserInfo.id,\n(state: BaseAppState<*>) => state.userInfos,\n(\nthreadInfo: ?RawThreadInfo,\n@@ -93,19 +91,20 @@ const baseRelativeMemberInfoSelectorForMembersOfThread: (\n},\n);\n-const relativeMemberInfoSelectorForMembersOfThread = _memoize<*, *>(\n+const relativeMemberInfoSelectorForMembersOfThread: (\n+ threadID: string,\n+) => (\n+ state: BaseAppState<*>,\n+) => RelativeMemberInfo[] = _memoize(\nbaseRelativeMemberInfoSelectorForMembersOfThread,\n);\n// If threadID is null, then all users except the logged-in user are returned\n-const baseUserInfoSelectorForOtherMembersOfThread: (\n- threadID: ?string,\n-) => (\n- state: BaseAppState<*>,\n-) => {[id: string]: AccountUserInfo} = (threadID: ?string) => createSelector(\n+const baseUserInfoSelectorForOtherMembersOfThread =\n+ (threadID: ?string) => createSelector(\n(state: BaseAppState<*>) => state.userInfos,\n- (state: BaseAppState<*>) => state.currentUserInfo &&\n- state.currentUserInfo.id,\n+ (state: BaseAppState<*>) => state.currentUserInfo\n+ && state.currentUserInfo.id,\n(state: BaseAppState<*>) =>\nthreadID && state.threadStore.threadInfos[threadID]\n? state.threadStore.threadInfos[threadID].members\n@@ -132,7 +131,11 @@ const baseUserInfoSelectorForOtherMembersOfThread: (\n},\n);\n-const userInfoSelectorForOtherMembersOfThread = _memoize<*, *>(\n+const userInfoSelectorForOtherMembersOfThread: (\n+ threadID: ?string,\n+) => (\n+ state: BaseAppState<*>,\n+) => {[id: string]: AccountUserInfo} = _memoize(\nbaseUserInfoSelectorForOtherMembersOfThread,\n);\n@@ -144,16 +147,17 @@ function searchIndexFromUserInfos(userInfos: {[id: string]: AccountUserInfo}) {\nreturn searchIndex;\n}\n-const baseUserSearchIndexForOtherMembersOfThread: (\n- threadID: ?string,\n-) => (\n- state: BaseAppState<*>,\n-) => SearchIndex = (threadID: ?string) => createSelector(\n+const baseUserSearchIndexForOtherMembersOfThread =\n+ (threadID: ?string) => createSelector(\nuserInfoSelectorForOtherMembersOfThread(threadID),\nsearchIndexFromUserInfos,\n);\n-const userSearchIndexForOtherMembersOfThread = _memoize<*, *>(\n+const userSearchIndexForOtherMembersOfThread: (\n+ threadID: ?string,\n+) => (\n+ state: BaseAppState<*>,\n+) => SearchIndex = _memoize(\nbaseUserSearchIndexForOtherMembersOfThread,\n);\n" }, { "change_type": "MODIFY", "old_path": "native/selectors/nav-selectors.js", "new_path": "native/selectors/nav-selectors.js", "diff": "@@ -29,15 +29,14 @@ import {\ngetThreadIDFromParams,\n} from '../utils/navigation-utils';\n-const baseCreateIsForegroundSelector: (\n- routeName: string,\n-) => (state: AppState) => bool = (routeName: string) => createSelector(\n+const baseCreateIsForegroundSelector = (routeName: string) => createSelector(\n(state: AppState) => state.navInfo.navigationState,\n(navigationState: NavigationState) =>\nnavigationState.routes[navigationState.index].routeName === routeName,\n);\n-const createIsForegroundSelector =\n- _memoize<*, *>(baseCreateIsForegroundSelector);\n+const createIsForegroundSelector: (\n+ routeName: string,\n+) => (state: AppState) => bool = _memoize(baseCreateIsForegroundSelector);\nconst appLoggedInSelector: (state: AppState) => bool = createSelector(\n(state: AppState) => state.navInfo.navigationState,\n@@ -52,9 +51,7 @@ const foregroundKeySelector: (state: AppState) => string = createSelector(\nnavigationState.routes[navigationState.index].key,\n);\n-const baseCreateActiveTabSelector: (\n- routeName: string,\n-) => (state: AppState) => bool = (routeName: string) => createSelector(\n+const baseCreateActiveTabSelector = (routeName: string) => createSelector(\n(state: AppState) => state.navInfo.navigationState,\n(navigationState: NavigationState) => {\nconst currentRootSubroute = navigationState.routes[navigationState.index];\n@@ -70,7 +67,9 @@ const baseCreateActiveTabSelector: (\nreturn tabRoute.routes[tabRoute.index].routeName === routeName;\n},\n);\n-const createActiveTabSelector = _memoize<*, *>(baseCreateActiveTabSelector);\n+const createActiveTabSelector: (\n+ routeName: string,\n+) => (state: AppState) => bool = _memoize(baseCreateActiveTabSelector);\nconst modalsClosedSelector: (state: AppState) => bool = createSelector(\n(state: AppState) => state.navInfo.navigationState,\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Type memoized functions instead of using existential operator
129,187
19.06.2019 13:57:27
14,400
dc0b55bc509f3a10e3e013846630552efe493918
Avoid returning localhost URIs to Android emulator on upload
[ { "change_type": "MODIFY", "old_path": "lib/shared/media-utils.js", "new_path": "lib/shared/media-utils.js", "diff": "@@ -5,9 +5,19 @@ import type {\nMultimediaMessageInfo,\nRawMultimediaMessageInfo,\n} from '../types/message-types';\n+import type { PlatformDetails } from '../types/device-types';\nimport invariant from 'invariant';\n+const localhostRegex = /^http:\\/\\/localhost/;\n+function shimUploadURI(uri: string, platformDetails: ?PlatformDetails) {\n+ if (!platformDetails || platformDetails.platform !== \"android\") {\n+ return uri;\n+ }\n+ // We do this for testing in the Android emulator\n+ return uri.replace(localhostRegex, \"http://10.0.2.2\");\n+}\n+\nfunction contentStringForMediaArray(media: $ReadOnlyArray<Media>): string {\ninvariant(media.length > 0, \"there should be some media\");\nif (media.length === 1) {\n@@ -36,6 +46,7 @@ function multimediaMessagePreview(\n}\nexport {\n+ shimUploadURI,\ncontentStringForMediaArray,\nmultimediaMessagePreview,\n};\n" }, { "change_type": "MODIFY", "old_path": "lib/shared/message-utils.js", "new_path": "lib/shared/message-utils.js", "diff": "@@ -24,7 +24,7 @@ import _maxBy from 'lodash/fp/maxBy';\nimport { prettyDate } from '../utils/date-utils';\nimport { userIDsToRelativeUserInfos } from '../selectors/user-selectors';\n-import { multimediaMessagePreview } from './media-utils';\n+import { shimUploadURI, multimediaMessagePreview } from './media-utils';\nimport { stringForUser } from './user-utils';\n// Prefers localID\n@@ -595,8 +595,6 @@ function combineTruncationStatuses(\n}\n}\n-const localhostRegex = /^http:\\/\\/localhost/;\n-\nfunction shimUnsupportedRawMessageInfos(\nrawMessageInfos: $ReadOnlyArray<RawMessageInfo>,\nplatformDetails: ?PlatformDetails,\n@@ -610,16 +608,13 @@ function shimUnsupportedRawMessageInfos(\n}\nconst { id } = rawMessageInfo;\ninvariant(id !== null && id !== undefined, \"id should be set on server\");\n- let unsupportedMessageInfo = rawMessageInfo;\n- if (platformDetails && platformDetails.platform === \"android\") {\n- unsupportedMessageInfo = {\n- ...unsupportedMessageInfo,\n- media: unsupportedMessageInfo.media.map(media => ({\n+ const unsupportedMessageInfo = {\n+ ...rawMessageInfo,\n+ media: rawMessageInfo.media.map(media => ({\n...media,\n- uri: media.uri.replace(localhostRegex, \"http://10.0.2.2\"),\n+ uri: shimUploadURI(media.uri, platformDetails),\n})),\n};\n- }\nreturn {\ntype: messageTypes.UNSUPPORTED,\nid,\n" }, { "change_type": "MODIFY", "old_path": "server/src/creators/upload-creator.js", "new_path": "server/src/creators/upload-creator.js", "diff": "@@ -7,6 +7,7 @@ import crypto from 'crypto';\nimport sizeOf from 'buffer-image-size';\nimport { ServerError } from 'lib/utils/errors';\n+import { shimUploadURI } from 'lib/shared/media-utils';\nimport { dbQuery, SQL } from '../database';\nimport createIDs from './id-creator';\n@@ -57,7 +58,10 @@ async function createUploads(\nreturn uploadRows.map(row => ({\nid: row[0],\n- uri: getUploadURL(row[0], row[6]),\n+ uri: shimUploadURI(\n+ getUploadURL(row[0], row[6]),\n+ viewer.platformDetails,\n+ ),\n}));\n}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Avoid returning localhost URIs to Android emulator on upload
129,187
19.06.2019 16:54:40
14,400
3ff87ca86b2c1a7c7c9a9a66fa518f3cd85a1766
[native] Round individual MultimediaMessageMultimedia corners
[ { "change_type": "MODIFY", "old_path": "native/chat/composed-message.react.js", "new_path": "native/chat/composed-message.react.js", "diff": "@@ -15,7 +15,7 @@ import { stringForUser } from 'lib/shared/user-utils';\nimport { connect } from 'lib/utils/redux-utils';\nimport FailedSend from './failed-send.react';\n-import RoundedMessageContainer from './rounded-message-container.react';\n+import { RoundedMessageContainer } from './rounded-message-container.react';\nimport { composedMessageMaxWidthSelector } from './composed-message-width';\ntype Props = {|\n" }, { "change_type": "MODIFY", "old_path": "native/chat/multimedia-message-multimedia.react.js", "new_path": "native/chat/multimedia-message-multimedia.react.js", "diff": "@@ -134,7 +134,7 @@ class MultimediaMessageMultimedia extends React.PureComponent<Props, State> {\nreturn (\n<TouchableWithoutFeedback onPress={this.onPress}>\n- <View style={[ styles.expand, style ]} ref={this.viewRef}>\n+ <View style={[ styles.multimediaContainer, style ]} ref={this.viewRef}>\n<Animated.View style={wrapperStyles}>\n<Multimedia mediaInfo={mediaInfo} />\n{progressIndicator}\n@@ -167,6 +167,10 @@ class MultimediaMessageMultimedia extends React.PureComponent<Props, State> {\n}\nconst styles = StyleSheet.create({\n+ multimediaContainer: {\n+ flex: 1,\n+ overflow: 'hidden',\n+ },\nexpand: {\nflex: 1,\n},\n" }, { "change_type": "MODIFY", "old_path": "native/chat/multimedia-message.react.js", "new_path": "native/chat/multimedia-message.react.js", "diff": "@@ -34,6 +34,11 @@ import ComposedMessage from './composed-message.react';\nimport MultimediaMessageMultimedia from './multimedia-message-multimedia.react';\nimport { modalsClosedSelector } from '../selectors/nav-selectors';\nimport { withLightboxPositionContext } from '../media/lightbox-navigator.react';\n+import {\n+ type Corners,\n+ allCorners,\n+ getRoundedContainerStyle,\n+} from './rounded-message-container.react';\nexport type ChatMultimediaMessageInfoItem = {|\nitemType: \"message\",\n@@ -135,6 +140,8 @@ function multimediaMessageItemHeight(\nreturn height;\n}\n+const borderRadius = 16;\n+\ntype Props = {|\nitem: ChatMultimediaMessageInfoItem,\nnavigate: Navigate,\n@@ -162,7 +169,7 @@ class MultimediaMessage extends React.PureComponent<Props> {\n<ComposedMessage\nitem={this.props.item}\nsendFailed={sendFailed(this.props.item)}\n- borderRadius={16}\n+ borderRadius={borderRadius}\nstyle={styles.row}\n>\n<TouchableWithoutFeedback onLongPress={this.onLongPress}>\n@@ -178,7 +185,11 @@ class MultimediaMessage extends React.PureComponent<Props> {\nconst { messageInfo } = this.props.item;\ninvariant(messageInfo.media.length > 0, \"should have media\");\nif (messageInfo.media.length === 1) {\n- return this.renderImage(messageInfo.media[0], 0);\n+ return this.renderImage(\n+ messageInfo.media[0],\n+ 0,\n+ this.getCornerStyle(allCorners),\n+ );\n}\nconst mediaPerRow = getMediaPerRow(messageInfo.media.length);\n@@ -187,13 +198,34 @@ class MultimediaMessage extends React.PureComponent<Props> {\nconst rows = [];\nfor (let i = 0; i < messageInfo.media.length; i += mediaPerRow) {\nconst rowMedia = messageInfo.media.slice(i, i + mediaPerRow);\n+ const firstRow = i === 0;\n+ const lastRow = i + mediaPerRow >= messageInfo.media.length;\n+\nconst row = [];\nlet j = 0;\nfor (; j < rowMedia.length; j++) {\nconst media = rowMedia[j];\n- const style = j + 1 < mediaPerRow\n- ? styles.imageBeforeImage\n- : null;\n+ const firstInRow = j === 0;\n+ const lastInRow = j + 1 === rowMedia.length;\n+ const inLastColumn = j + 1 === mediaPerRow;\n+\n+ const style = [];\n+ if (!lastInRow) {\n+ style.push(styles.imageBeforeImage);\n+ }\n+ if (firstRow && firstInRow) {\n+ style.push(this.getCornerStyle({ topLeft: true }));\n+ }\n+ if (firstRow && inLastColumn) {\n+ style.push(this.getCornerStyle({ topRight: true }));\n+ }\n+ if (lastRow && firstInRow) {\n+ style.push(this.getCornerStyle({ bottomLeft: true }));\n+ }\n+ if (lastRow && inLastColumn) {\n+ style.push(this.getCornerStyle({ bottomRight: true }));\n+ }\n+\nrow.push(this.renderImage(media, i + j, style));\n}\nfor (; j < mediaPerRow; j++) {\n@@ -204,9 +236,9 @@ class MultimediaMessage extends React.PureComponent<Props> {\nrow.push(<View style={[ style, styles.filler ]} key={key} />);\n}\n- const rowStyle = i + mediaPerRow < messageInfo.media.length\n- ? [ styles.row, styles.rowAboveRow ]\n- : styles.row;\n+ const rowStyle = lastRow\n+ ? styles.row\n+ : [ styles.row, styles.rowAboveRow ];\nrows.push(\n<View style={rowStyle} key={i}>\n{row}\n@@ -216,10 +248,14 @@ class MultimediaMessage extends React.PureComponent<Props> {\nreturn <View style={styles.grid}>{rows}</View>;\n}\n+ getCornerStyle(corners: Corners) {\n+ return getRoundedContainerStyle(this.props.item, corners, borderRadius);\n+ }\n+\nrenderImage(\nmedia: Media,\nindex: number,\n- style?: ?ImageStyle,\n+ style: ImageStyle,\n): React.Node {\nconst { pendingUploads, messageInfo } = this.props.item;\nconst mediaInfo = {\n" }, { "change_type": "MODIFY", "old_path": "native/chat/rounded-message-container.react.js", "new_path": "native/chat/rounded-message-container.react.js", "diff": "@@ -8,6 +8,46 @@ import * as React from 'react';\nimport PropTypes from 'prop-types';\nimport { StyleSheet, View, ViewPropTypes } from 'react-native';\n+export type Corners = $Shape<{|\n+ topLeft: bool,\n+ topRight: bool,\n+ bottomLeft: bool,\n+ bottomRight: bool,\n+|}>;\n+const allCorners = {\n+ topLeft: true,\n+ topRight: true,\n+ bottomLeft: true,\n+ bottomRight: true,\n+};\n+function getRoundedContainerStyle(\n+ item: ChatMessageInfoItemWithHeight,\n+ corners: Corners,\n+ borderRadius?: number = 8,\n+) {\n+ const { startsCluster, endsCluster } = item;\n+ const { isViewer } = item.messageInfo.creator;\n+ const { topLeft, topRight, bottomLeft, bottomRight } = corners;\n+ return {\n+ borderTopLeftRadius:\n+ topLeft && !isViewer && !startsCluster\n+ ? 0\n+ : borderRadius,\n+ borderTopRightRadius:\n+ topRight && isViewer && !startsCluster\n+ ? 0\n+ : borderRadius,\n+ borderBottomLeftRadius:\n+ bottomLeft && !isViewer && !endsCluster\n+ ? 0\n+ : borderRadius,\n+ borderBottomRightRadius:\n+ bottomRight && isViewer && !endsCluster\n+ ? 0\n+ : borderRadius,\n+ };\n+}\n+\ntype Props = {|\nitem: ChatMessageInfoItemWithHeight,\nborderRadius: number,\n@@ -28,21 +68,13 @@ class RoundedMessageContainer extends React.PureComponent<Props> {\nrender() {\nconst { item, borderRadius, style } = this.props;\n- const { isViewer } = item.messageInfo.creator;\n-\n- const messageStyle = {\n- borderTopRightRadius:\n- isViewer && !item.startsCluster ? 0 : borderRadius,\n- borderBottomRightRadius:\n- isViewer && !item.endsCluster ? 0 : borderRadius,\n- borderTopLeftRadius:\n- !isViewer && !item.startsCluster ? 0 : borderRadius,\n- borderBottomLeftRadius:\n- !isViewer && !item.endsCluster ? 0 : borderRadius,\n- };\n-\n+ const cornerStyle = getRoundedContainerStyle(\n+ item,\n+ allCorners,\n+ borderRadius,\n+ );\nreturn (\n- <View style={[styles.message, messageStyle, style]}>\n+ <View style={[styles.message, cornerStyle, style]}>\n{this.props.children}\n</View>\n);\n@@ -56,4 +88,8 @@ const styles = StyleSheet.create({\n},\n});\n-export default RoundedMessageContainer;\n+export {\n+ allCorners,\n+ getRoundedContainerStyle,\n+ RoundedMessageContainer,\n+};\n" }, { "change_type": "MODIFY", "old_path": "native/chat/text-message.react.js", "new_path": "native/chat/text-message.react.js", "diff": "@@ -22,7 +22,7 @@ import { onlyEmojiRegex } from 'lib/shared/emojis';\nimport Tooltip from '../components/tooltip.react';\nimport ComposedMessage from './composed-message.react';\n-import RoundedMessageContainer from './rounded-message-container.react';\n+import { RoundedMessageContainer } from './rounded-message-container.react';\nexport type ChatTextMessageInfoItemWithHeight = {|\nitemType: \"message\",\n" }, { "change_type": "MODIFY", "old_path": "native/media/remote-image.react.js", "new_path": "native/media/remote-image.react.js", "diff": "@@ -27,7 +27,7 @@ type State = {|\nattempt: number,\nloaded: bool,\n|};\n-class Image extends React.PureComponent<Props, State> {\n+class RemoteImage extends React.PureComponent<Props, State> {\nstatic propTypes = {\nuri: PropTypes.string.isRequired,\n@@ -113,4 +113,4 @@ export default connect(\n(state: AppState) => ({\nconnectionStatus: state.connection.status,\n}),\n-)(Image);\n+)(RemoteImage);\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Round individual MultimediaMessageMultimedia corners
129,187
19.06.2019 17:10:22
14,400
359ea49e3947b57595ff1eae1d3ad68d2694f7d1
[native] Hoist MessageListContainer statics
[ { "change_type": "MODIFY", "old_path": "native/chat/message-list-container.react.js", "new_path": "native/chat/message-list-container.react.js", "diff": "@@ -22,6 +22,7 @@ import PropTypes from 'prop-types';\nimport { View, Platform, StyleSheet, ActivityIndicator } from 'react-native';\nimport _differenceWith from 'lodash/fp/differenceWith';\nimport invariant from 'invariant';\n+import hoistNonReactStatics from 'hoist-non-react-statics';\nimport { connect } from 'lib/utils/redux-utils';\nimport { threadInfoSelector } from 'lib/selectors/thread-selectors';\n@@ -376,7 +377,7 @@ const styles = StyleSheet.create({\n},\n});\n-export default connect(\n+const ConnectedMessageListContainer = connect(\n(state: AppState, ownProps: { navigation: NavProp }) => {\nconst threadID = ownProps.navigation.state.params.threadInfo.id;\nreturn {\n@@ -387,3 +388,7 @@ export default connect(\n};\n},\n)(withChatInputState(MessageListContainer));\n+\n+hoistNonReactStatics(ConnectedMessageListContainer, MessageListContainer);\n+\n+export default ConnectedMessageListContainer;\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Hoist MessageListContainer statics
129,187
19.06.2019 17:57:59
14,400
7abf20c17abbd9599be2fcd272f5dbde620b81cd
[native] Clean up dataURIToIntArray
[ { "change_type": "MODIFY", "old_path": "native/utils/media-utils.js", "new_path": "native/utils/media-utils.js", "diff": "@@ -58,23 +58,15 @@ function stringToIntArray(str: string): Uint8Array {\n}\nfunction dataURIToIntArray(dataURI: string): Uint8Array {\n- let uri = dataURI;\n- uri = uri.replace(/\\r?\\n/g, '');\n+ const uri = dataURI.replace(/\\r?\\n/g, '');\n+\nconst firstComma = uri.indexOf(',');\n- if (-1 === firstComma || firstComma <= 4) {\n+ if (firstComma <= 4) {\nthrow new TypeError('malformed data-URI');\n}\n- const meta = uri.substring(5, firstComma).split(';');\n- let base64Encoded = false;\n- let charset = 'US-ASCII';\n- for (let i = 0; i < meta.length; i++) {\n- if (meta[i] === 'base64') {\n- base64Encoded = true;\n- } else if (meta[i].indexOf('charset=') === 0) {\n- charset = meta[i].substring(8);\n- }\n- }\n+ const meta = uri.substring(5, firstComma).split(';');\n+ const base64Encoded = meta.some(metum => metum === 'base64');\nlet data = unescape(uri.substring(firstComma + 1));\nif (base64Encoded) {\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Clean up dataURIToIntArray
129,187
19.06.2019 19:11:12
14,400
137f1e513694a914ead27a29d6b7584343c49a18
[lib] Handle empty filename in fileInfoFromData
[ { "change_type": "MODIFY", "old_path": "lib/utils/media-utils.js", "new_path": "lib/utils/media-utils.js", "diff": "@@ -18,7 +18,10 @@ function fileInfoFromData(\nif (!mediaType) {\nreturn null;\n}\n- const [ readableFileName, extension ] = fileName.split('.');\n+ let [ readableFileName ] = fileName.split('.');\n+ if (!readableFileName) {\n+ readableFileName = Math.random().toString(36).slice(-5);\n+ }\nconst maxReadableLength = 255 - ext.length - 1;\nconst fixedFileName =\n`${readableFileName.substring(0, maxReadableLength)}.${ext}`;\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[lib] Handle empty filename in fileInfoFromData
129,187
19.06.2019 19:13:46
14,400
d1ddda010499971028a3969ed99536dee0006f3e
[native] Tooltip to save image
[ { "change_type": "MODIFY", "old_path": "lib/types/media-types.js", "new_path": "lib/types/media-types.js", "diff": "@@ -25,6 +25,7 @@ export type MediaInfo = {|\n...Media,\nindex: number,\nmessageID: string,\n+ messageKey: string,\n|};\nexport const mediaTypePropType = PropTypes.oneOf([ \"photo\", \"video\" ]);\n" }, { "change_type": "MODIFY", "old_path": "native/chat/message.react.js", "new_path": "native/chat/message.react.js", "diff": "@@ -121,8 +121,11 @@ class Message extends React.PureComponent<Props> {\n<MultimediaMessage\nitem={this.props.item}\nnavigate={this.props.navigate}\n+ focused={this.props.focused}\ntoggleFocus={this.props.toggleFocus}\nverticalBounds={this.props.verticalBounds}\n+ keyboardShowing={this.props.keyboardShowing}\n+ setScrollDisabled={this.props.setScrollDisabled}\n/>\n);\n} else {\n" }, { "change_type": "MODIFY", "old_path": "native/chat/multimedia-message-multimedia.react.js", "new_path": "native/chat/multimedia-message-multimedia.react.js", "diff": "@@ -14,15 +14,19 @@ import {\ntype PendingMultimediaUpload,\npendingMultimediaUploadPropType,\n} from './chat-input-state';\n+import type { TooltipItemData } from '../components/tooltip.react';\nimport * as React from 'react';\nimport PropTypes from 'prop-types';\n-import { View, TouchableWithoutFeedback, StyleSheet } from 'react-native';\n+import { View, StyleSheet } from 'react-native';\nimport Animated from 'react-native-reanimated';\nimport * as Progress from 'react-native-progress';\nimport Icon from 'react-native-vector-icons/Feather';\n+import { KeyboardUtils } from 'react-native-keyboard-input';\n+import invariant from 'invariant';\nimport Multimedia from '../media/multimedia.react';\n+import Tooltip from '../components/tooltip.react';\ntype Props = {|\nmediaInfo: MediaInfo,\n@@ -33,6 +37,10 @@ type Props = {|\nlightboxPosition: ?Animated.Value,\ninProgress: bool,\npendingUpload: ?PendingMultimediaUpload,\n+ keyboardShowing: bool,\n+ messageFocused: bool,\n+ toggleMessageFocus: (messageKey: string) => void,\n+ setScrollDisabled: (scrollDisabled: bool) => void,\n|};\ntype State = {|\nhidden: bool,\n@@ -48,8 +56,14 @@ class MultimediaMessageMultimedia extends React.PureComponent<Props, State> {\nlightboxPosition: PropTypes.instanceOf(Animated.Value),\ninProgress: PropTypes.bool.isRequired,\npendingUpload: pendingMultimediaUploadPropType,\n+ keyboardShowing: PropTypes.bool.isRequired,\n+ messageFocused: PropTypes.bool.isRequired,\n+ toggleMessageFocus: PropTypes.func.isRequired,\n+ setScrollDisabled: PropTypes.func.isRequired,\n};\nview: ?View;\n+ tooltipConfig: $ReadOnlyArray<TooltipItemData>;\n+ tooltip: ?Tooltip;\nconstructor(props: Props) {\nsuper(props);\n@@ -57,6 +71,9 @@ class MultimediaMessageMultimedia extends React.PureComponent<Props, State> {\nhidden: false,\nopacity: this.getOpacity(),\n};\n+ this.tooltipConfig = [\n+ { label: \"Save\", onPress: this.onPressSave },\n+ ];\n}\nstatic getDerivedStateFromProps(props: Props, state: State) {\n@@ -132,15 +149,28 @@ class MultimediaMessageMultimedia extends React.PureComponent<Props, State> {\nwrapperStyles.push({ opacity: this.state.opacity });\n}\n- return (\n- <TouchableWithoutFeedback onPress={this.onPress}>\n+ const multimedia = (\n<View style={[ styles.multimediaContainer, style ]} ref={this.viewRef}>\n<Animated.View style={wrapperStyles}>\n<Multimedia mediaInfo={mediaInfo} />\n{progressIndicator}\n</Animated.View>\n</View>\n- </TouchableWithoutFeedback>\n+ );\n+\n+ return (\n+ <Tooltip\n+ buttonComponent={multimedia}\n+ items={this.tooltipConfig}\n+ componentWrapperStyle={styles.expand}\n+ componentContainerStyle={styles.expand}\n+ labelStyle={styles.popoverLabelStyle}\n+ onOpenTooltipMenu={this.onFocus}\n+ onCloseTooltipMenu={this.onBlur}\n+ onPressOverride={this.onPress}\n+ onLongPress={this.onLongPress}\n+ innerRef={this.tooltipRef}\n+ />\n);\n}\n@@ -148,11 +178,18 @@ class MultimediaMessageMultimedia extends React.PureComponent<Props, State> {\nthis.view = view;\n}\n+ tooltipRef = (tooltip: ?Tooltip) => {\n+ this.tooltip = tooltip;\n+ }\n+\nonPress = () => {\n- const { view, props: { verticalBounds } } = this;\n+ const { view, props: { verticalBounds }, tooltip } = this;\nif (!view || !verticalBounds) {\nreturn;\n}\n+ if (tooltip) {\n+ tooltip.hideModal();\n+ }\nview.measure((x, y, width, height, pageX, pageY) => {\nconst coordinates = { x: pageX, y: pageY, width, height };\nconst { mediaInfo, navigate } = this.props;\n@@ -164,6 +201,37 @@ class MultimediaMessageMultimedia extends React.PureComponent<Props, State> {\n});\n}\n+ onFocus = () => {\n+ this.props.setScrollDisabled(true);\n+ if (!this.props.messageFocused) {\n+ this.props.toggleMessageFocus(this.props.mediaInfo.messageKey);\n+ }\n+ }\n+\n+ onBlur = () => {\n+ this.props.setScrollDisabled(false);\n+ if (this.props.messageFocused) {\n+ this.props.toggleMessageFocus(this.props.mediaInfo.messageKey);\n+ }\n+ }\n+\n+ onPressSave = () => {\n+ }\n+\n+ onLongPress = () => {\n+ if (this.props.keyboardShowing) {\n+ KeyboardUtils.dismiss();\n+ return;\n+ }\n+ const tooltip = this.tooltip;\n+ invariant(tooltip, \"tooltip should be set\");\n+ if (this.props.messageFocused) {\n+ tooltip.hideModal();\n+ } else {\n+ tooltip.openModal();\n+ }\n+ }\n+\n}\nconst styles = StyleSheet.create({\n@@ -193,6 +261,10 @@ const styles = StyleSheet.create({\ntextShadowOffset: { width: 0, height: 1 },\ntextShadowRadius: 1,\n},\n+ popoverLabelStyle: {\n+ textAlign: 'center',\n+ color: '#444',\n+ },\n});\nexport default MultimediaMessageMultimedia;\n" }, { "change_type": "MODIFY", "old_path": "native/chat/multimedia-message.react.js", "new_path": "native/chat/multimedia-message.react.js", "diff": "@@ -17,12 +17,7 @@ import type { AppState } from '../redux/redux-setup';\nimport type { MessagePendingUploads } from './chat-input-state';\nimport * as React from 'react';\n-import {\n- Text,\n- StyleSheet,\n- TouchableWithoutFeedback,\n- View,\n-} from 'react-native';\n+import { Text, StyleSheet, View } from 'react-native';\nimport PropTypes from 'prop-types';\nimport invariant from 'invariant';\nimport Animated from 'react-native-reanimated';\n@@ -145,8 +140,11 @@ const borderRadius = 16;\ntype Props = {|\nitem: ChatMultimediaMessageInfoItem,\nnavigate: Navigate,\n+ focused: bool,\ntoggleFocus: (messageKey: string) => void,\nverticalBounds: ?VerticalBounds,\n+ keyboardShowing: bool,\n+ setScrollDisabled: (scrollDisabled: bool) => void,\n// Redux state\nmodalsClosed: bool,\n// withLightboxPositionContext\n@@ -157,8 +155,11 @@ class MultimediaMessage extends React.PureComponent<Props> {\nstatic propTypes = {\nitem: chatMessageItemPropType.isRequired,\nnavigate: PropTypes.func.isRequired,\n+ focused: PropTypes.bool.isRequired,\ntoggleFocus: PropTypes.func.isRequired,\nverticalBounds: verticalBoundsPropType,\n+ keyboardShowing: PropTypes.bool.isRequired,\n+ setScrollDisabled: PropTypes.func.isRequired,\nmodalsClosed: PropTypes.bool.isRequired,\nlightboxPosition: PropTypes.instanceOf(Animated.Value),\n};\n@@ -172,11 +173,9 @@ class MultimediaMessage extends React.PureComponent<Props> {\nborderRadius={borderRadius}\nstyle={styles.row}\n>\n- <TouchableWithoutFeedback onLongPress={this.onLongPress}>\n<View style={[heightStyle, styles.container]}>\n{this.renderContent()}\n</View>\n- </TouchableWithoutFeedback>\n</ComposedMessage>\n);\n}\n@@ -261,6 +260,7 @@ class MultimediaMessage extends React.PureComponent<Props> {\nconst mediaInfo = {\n...media,\nmessageID: messageID(messageInfo),\n+ messageKey: messageKey(messageInfo),\nindex,\n};\nconst pendingUpload = pendingUploads && pendingUploads[media.id];\n@@ -274,15 +274,15 @@ class MultimediaMessage extends React.PureComponent<Props> {\nlightboxPosition={this.props.lightboxPosition}\ninProgress={!!pendingUploads}\npendingUpload={pendingUpload}\n+ keyboardShowing={this.props.keyboardShowing}\n+ setScrollDisabled={this.props.setScrollDisabled}\n+ messageFocused={this.props.focused}\n+ toggleMessageFocus={this.props.toggleFocus}\nkey={index}\n/>\n);\n}\n- onLongPress = () => {\n- this.props.toggleFocus(messageKey(this.props.item.messageInfo));\n- }\n-\n}\nconst spaceBetweenImages = 4;\n" }, { "change_type": "MODIFY", "old_path": "native/components/tooltip.react.js", "new_path": "native/components/tooltip.react.js", "diff": "@@ -24,7 +24,7 @@ import { connect } from 'lib/utils/redux-utils';\nimport TooltipItem, { type Label, labelPropType } from './tooltip-item.react';\nimport { dimensionsSelector } from '../selectors/dimension-selectors';\n-export type TooltipItemData = { +label: Label, onPress: () => void };\n+export type TooltipItemData = { +label: Label, onPress: () => mixed };\ntype Props = {\nbuttonComponent: React.Node,\n@@ -49,6 +49,7 @@ type Props = {\nopacityChangeDuration?: number,\ninnerRef?: (tooltip: ?Tooltip) => void,\nonPressOverride?: () => void,\n+ onLongPress?: () => void,\n// Redux state\ndimensions: Dimensions,\n};\n@@ -98,6 +99,7 @@ class Tooltip extends React.PureComponent<Props, State> {\nopacityChangeDuration: PropTypes.number,\ninnerRef: PropTypes.func,\nonPressOverride: PropTypes.func,\n+ onLongPress: PropTypes.func,\ndimensions: dimensionsPropType.isRequired,\n};\nstatic defaultProps = {\n@@ -313,7 +315,7 @@ class Tooltip extends React.PureComponent<Props, State> {\nref={this.wrapperRef}\nstyle={this.props.componentWrapperStyle}\nonPress={this.onPress}\n- onLongPress={this.onPress}\n+ onLongPress={this.onLongPress}\ndelayLongPress={this.props.delayLongPress}\nactiveOpacity={1.0}\n>\n@@ -380,6 +382,7 @@ class Tooltip extends React.PureComponent<Props, State> {\n<TouchableOpacity\nonPress={this.onPress}\nactiveOpacity={1.0}\n+ style={this.props.componentContainerStyle}\n>\n{this.props.buttonComponent}\n</TouchableOpacity>\n@@ -462,6 +465,16 @@ class Tooltip extends React.PureComponent<Props, State> {\n}\n}\n+ onLongPress = () => {\n+ if (this.props.onLongPress) {\n+ this.props.onLongPress();\n+ } else if (this.props.onPressOverride) {\n+ this.props.onPressOverride();\n+ } else {\n+ this.toggle();\n+ }\n+ }\n+\ntoggle = () => {\nif (this.state.isModalOpen) {\nthis.hideModal();\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Tooltip to save image
129,187
19.06.2019 19:15:04
14,400
9262d827e2b8d271c8d0dff03ca1ec27d7e74118
[native] Save image
[ { "change_type": "MODIFY", "old_path": "native/android/app/src/main/AndroidManifest.xml", "new_path": "native/android/app/src/main/AndroidManifest.xml", "diff": "<uses-permission android:name=\"android.permission.READ_PHONE_STATE\" tools:node=\"remove\" />\n<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\" />\n<uses-permission android:name=\"android.permission.READ_EXTERNAL_STORAGE\" />\n+ <uses-permission android:name=\"android.permission.WRITE_EXTERNAL_STORAGE\" />\n<application\nandroid:name=\".MainApplication\"\n" }, { "change_type": "MODIFY", "old_path": "native/chat/multimedia-message-multimedia.react.js", "new_path": "native/chat/multimedia-message-multimedia.react.js", "diff": "@@ -27,6 +27,7 @@ import invariant from 'invariant';\nimport Multimedia from '../media/multimedia.react';\nimport Tooltip from '../components/tooltip.react';\n+import { saveImage } from '../media/save-image';\ntype Props = {|\nmediaInfo: MediaInfo,\n@@ -216,6 +217,7 @@ class MultimediaMessageMultimedia extends React.PureComponent<Props, State> {\n}\nonPressSave = () => {\n+ return saveImage(this.props.mediaInfo);\n}\nonLongPress = () => {\n" }, { "change_type": "ADD", "old_path": null, "new_path": "native/media/save-image.js", "diff": "+// @flow\n+\n+import type { MediaInfo } from 'lib/types/media-types';\n+\n+import { Platform, PermissionsAndroid } from 'react-native';\n+import filesystem from 'react-native-fs';\n+import CameraRoll from '@react-native-community/cameraroll';\n+import invariant from 'invariant';\n+\n+import { fileInfoFromData } from 'lib/utils/media-utils';\n+\n+import { blobToDataURI, dataURIToIntArray } from '../utils/media-utils';\n+\n+function saveImage(mediaInfo: MediaInfo) {\n+ if (Platform.OS === \"android\") {\n+ return saveImageAndroid(mediaInfo);\n+ } else if (Platform.OS === \"ios\") {\n+ return saveImageIOS(mediaInfo);\n+ } else {\n+ invariant(false, `saveImage unsupported on ${Platform.OS}`);\n+ }\n+}\n+\n+async function saveImageAndroid(mediaInfo: MediaInfo) {\n+ const hasPermission = await getAndroidPermissions();\n+ if (!hasPermission) {\n+ return;\n+ }\n+ const saveFolder = `${filesystem.PicturesDirectoryPath}/SquadCal`;\n+ await filesystem.mkdir(saveFolder);\n+ await saveToDisk(mediaInfo.uri, saveFolder);\n+}\n+\n+async function getAndroidPermissions() {\n+ try {\n+ const granted = await PermissionsAndroid.request(\n+ PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE,\n+ {\n+ title: \"Save Photo\",\n+ message: \"Requesting access to your external storage\",\n+ },\n+ )\n+ if (granted !== PermissionsAndroid.RESULTS.GRANTED) {\n+ throw new Error('android_permissions');\n+ }\n+ return true;\n+ } catch (err) {\n+ return false;\n+ }\n+}\n+\n+async function saveImageIOS(mediaInfo: MediaInfo) {\n+ const { uri, type } = mediaInfo;\n+\n+ let tempFile;\n+ if (uri.startsWith(\"http\")) {\n+ tempFile = await saveToDisk(uri, filesystem.TemporaryDirectoryPath);\n+ }\n+\n+ const saveURI = tempFile ? `file://${tempFile}` : uri;\n+ const result = await CameraRoll.saveToCameraRoll(saveURI, type);\n+\n+ if (tempFile) {\n+ await filesystem.unlink(tempFile);\n+ }\n+}\n+\n+async function saveToDisk(uri: string, directory: string) {\n+ const response = await fetch(uri);\n+ const blob = await response.blob();\n+ const dataURI = await blobToDataURI(blob);\n+ const firstComma = dataURI.indexOf(',');\n+ invariant(firstComma > 4, 'malformed data-URI');\n+ const base64 = dataURI.substring(firstComma + 1);\n+\n+ const intArray = dataURIToIntArray(dataURI);\n+ const fileName = blob.data.name ? blob.data.name : \"\";\n+ const fileInfo = fileInfoFromData(intArray, fileName);\n+ invariant(fileInfo, 'unsupported media type');\n+ const { name, mime } = fileInfo;\n+ const filePath = `${directory}/${name}`;\n+\n+ await filesystem.writeFile(filePath, base64, 'base64');\n+ return filePath;\n+}\n+\n+export {\n+ saveImage,\n+};\n" }, { "change_type": "MODIFY", "old_path": "native/utils/media-utils.js", "new_path": "native/utils/media-utils.js", "diff": "@@ -151,5 +151,7 @@ async function convertMedia(\nexport {\nvalidateMedia,\n+ blobToDataURI,\n+ dataURIToIntArray,\nconvertMedia,\n};\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Save image
129,187
19.06.2019 19:57:36
14,400
5b4c698d02c08882e28b81df9e42a242baff9951
[lib] lib/utils/media-utils -> lib/utils/file-utils To distinguish against `lib/shared/media-utils`
[ { "change_type": "RENAME", "old_path": "lib/utils/media-utils.js", "new_path": "lib/utils/file-utils.js", "diff": "" }, { "change_type": "MODIFY", "old_path": "native/media/image-gallery-keyboard.react.js", "new_path": "native/media/image-gallery-keyboard.react.js", "diff": "@@ -24,7 +24,7 @@ import CameraRoll from '@react-native-community/cameraroll';\nimport Icon from 'react-native-vector-icons/FontAwesome';\nimport { connect } from 'lib/utils/redux-utils';\n-import { mimeTypesToMediaTypes } from 'lib/utils/media-utils';\n+import { mimeTypesToMediaTypes } from 'lib/utils/file-utils';\nimport { store } from '../redux/redux-setup';\nimport {\n" }, { "change_type": "MODIFY", "old_path": "native/media/save-image.js", "new_path": "native/media/save-image.js", "diff": "@@ -7,7 +7,7 @@ import filesystem from 'react-native-fs';\nimport CameraRoll from '@react-native-community/cameraroll';\nimport invariant from 'invariant';\n-import { fileInfoFromData } from 'lib/utils/media-utils';\n+import { fileInfoFromData } from 'lib/utils/file-utils';\nimport { blobToDataURI, dataURIToIntArray } from '../utils/media-utils';\n" }, { "change_type": "MODIFY", "old_path": "native/utils/media-utils.js", "new_path": "native/utils/media-utils.js", "diff": "@@ -10,7 +10,7 @@ import ImageResizer from 'react-native-image-resizer';\nimport {\nfileInfoFromData,\nmimeTypesToMediaTypes,\n-} from 'lib/utils/media-utils';\n+} from 'lib/utils/file-utils';\ntype ReactNativeBlob =\n& Blob\n" }, { "change_type": "MODIFY", "old_path": "server/src/uploads/media-utils.js", "new_path": "server/src/uploads/media-utils.js", "diff": "@@ -4,7 +4,7 @@ import type { UploadInput } from '../creators/upload-creator';\nimport sharp from 'sharp';\n-import { fileInfoFromData } from 'lib/utils/media-utils';\n+import { fileInfoFromData } from 'lib/utils/file-utils';\nconst fiveMegabytes = 5 * 1024 * 1024;\n" }, { "change_type": "MODIFY", "old_path": "web/utils/media-utils.js", "new_path": "web/utils/media-utils.js", "diff": "@@ -5,7 +5,7 @@ import type { MediaType, Dimensions } from 'lib/types/media-types';\nimport {\nfileInfoFromData,\nmimeTypesToMediaTypes,\n-} from 'lib/utils/media-utils';\n+} from 'lib/utils/file-utils';\nfunction blobToArrayBuffer(blob: Blob): Promise<ArrayBuffer> {\nconst fileReader = new FileReader();\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[lib] lib/utils/media-utils -> lib/utils/file-utils To distinguish against `lib/shared/media-utils`
129,187
19.06.2019 21:16:44
14,400
ccc70485db66a664e72643103acb395bfdc4bcec
[native] Move media/vertical-bounds to types/lightbox-types
[ { "change_type": "MODIFY", "old_path": "native/chat/message-list.react.js", "new_path": "native/chat/message-list.react.js", "diff": "@@ -8,7 +8,7 @@ import type { FetchMessageInfosPayload } from 'lib/types/message-types';\nimport type { DispatchActionPromise } from 'lib/utils/action-utils';\nimport type { ChatMessageItemWithHeight } from './message-list-container.react';\nimport type { Navigate } from '../navigation/route-names';\n-import type { VerticalBounds } from '../media/vertical-bounds';\n+import type { VerticalBounds } from '../types/lightbox-types';\nimport * as React from 'react';\nimport PropTypes from 'prop-types';\n" }, { "change_type": "MODIFY", "old_path": "native/chat/message.react.js", "new_path": "native/chat/message.react.js", "diff": "@@ -14,7 +14,7 @@ import type { Navigate } from '../navigation/route-names';\nimport {\ntype VerticalBounds,\nverticalBoundsPropType,\n-} from '../media/vertical-bounds';\n+} from '../types/lightbox-types';\nimport * as React from 'react';\nimport {\n" }, { "change_type": "MODIFY", "old_path": "native/chat/multimedia-message-multimedia.react.js", "new_path": "native/chat/multimedia-message-multimedia.react.js", "diff": "@@ -9,7 +9,7 @@ import {\nimport {\ntype VerticalBounds,\nverticalBoundsPropType,\n-} from '../media/vertical-bounds';\n+} from '../types/lightbox-types';\nimport {\ntype PendingMultimediaUpload,\npendingMultimediaUploadPropType,\n" }, { "change_type": "MODIFY", "old_path": "native/chat/multimedia-message.react.js", "new_path": "native/chat/multimedia-message.react.js", "diff": "@@ -12,7 +12,7 @@ import type { Navigate } from '../navigation/route-names';\nimport {\ntype VerticalBounds,\nverticalBoundsPropType,\n-} from '../media/vertical-bounds';\n+} from '../types/lightbox-types';\nimport type { AppState } from '../redux/redux-setup';\nimport type { MessagePendingUploads } from './chat-input-state';\n" }, { "change_type": "MODIFY", "old_path": "native/media/multimedia-modal.react.js", "new_path": "native/media/multimedia-modal.react.js", "diff": "@@ -13,7 +13,10 @@ import {\ndimensionsPropType,\n} from 'lib/types/media-types';\nimport type { AppState } from '../redux/redux-setup';\n-import { type VerticalBounds, verticalBoundsPropType } from './vertical-bounds';\n+import {\n+ type VerticalBounds,\n+ verticalBoundsPropType,\n+} from '../types/lightbox-types';\nimport * as React from 'react';\nimport {\n" }, { "change_type": "RENAME", "old_path": "native/media/vertical-bounds.js", "new_path": "native/types/lightbox-types.js", "diff": "" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Move media/vertical-bounds to types/lightbox-types
129,187
19.06.2019 23:33:24
14,400
993c9f0731169971bf82b1bcd6e3400d0548b6db
[native] LayoutCoordinates -> lightbox-types
[ { "change_type": "MODIFY", "old_path": "native/media/multimedia-modal.react.js", "new_path": "native/media/multimedia-modal.react.js", "diff": "@@ -16,6 +16,8 @@ import type { AppState } from '../redux/redux-setup';\nimport {\ntype VerticalBounds,\nverticalBoundsPropType,\n+ type LayoutCoordinates,\n+ layoutCoordinatesPropType,\n} from '../types/lightbox-types';\nimport * as React from 'react';\n@@ -189,12 +191,6 @@ function runDecay(\n];\n}\n-type LayoutCoordinates = $ReadOnly<{|\n- x: number,\n- y: number,\n- width: number,\n- height: number,\n-|}>;\ntype NavProp = NavigationScreenProp<{|\n...NavigationLeafRoute,\nparams: {|\n@@ -220,12 +216,7 @@ class MultimediaModal extends React.PureComponent<Props> {\nstate: PropTypes.shape({\nparams: PropTypes.shape({\nmediaInfo: mediaInfoPropType.isRequired,\n- initialCoordinates: PropTypes.shape({\n- x: PropTypes.number.isRequired,\n- y: PropTypes.number.isRequired,\n- width: PropTypes.number.isRequired,\n- height: PropTypes.number.isRequired,\n- }).isRequired,\n+ initialCoordinates: layoutCoordinatesPropType.isRequired,\nverticalBounds: verticalBoundsPropType.isRequired,\n}).isRequired,\n}).isRequired,\n" }, { "change_type": "MODIFY", "old_path": "native/types/lightbox-types.js", "new_path": "native/types/lightbox-types.js", "diff": "@@ -11,3 +11,17 @@ export const verticalBoundsPropType = PropTypes.shape({\ny: PropTypes.number.isRequired,\nheight: PropTypes.number.isRequired,\n});\n+\n+export type LayoutCoordinates = $ReadOnly<{|\n+ x: number,\n+ y: number,\n+ width: number,\n+ height: number,\n+|}>;\n+\n+export const layoutCoordinatesPropType = PropTypes.shape({\n+ x: PropTypes.number.isRequired,\n+ y: PropTypes.number.isRequired,\n+ width: PropTypes.number.isRequired,\n+ height: PropTypes.number.isRequired,\n+});\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] LayoutCoordinates -> lightbox-types
129,187
19.06.2019 22:20:15
14,400
020c9583ddc1ba2de9f7965be0244096326e5770
[native] MultimediaMessage: inProgress -> postInProgress
[ { "change_type": "MODIFY", "old_path": "native/chat/multimedia-message-multimedia.react.js", "new_path": "native/chat/multimedia-message-multimedia.react.js", "diff": "@@ -36,7 +36,7 @@ type Props = {|\nstyle?: ImageStyle,\nmodalsClosed: bool,\nlightboxPosition: ?Animated.Value,\n- inProgress: bool,\n+ postInProgress: bool,\npendingUpload: ?PendingMultimediaUpload,\nkeyboardShowing: bool,\nmessageFocused: bool,\n@@ -55,7 +55,7 @@ class MultimediaMessageMultimedia extends React.PureComponent<Props, State> {\nverticalBounds: verticalBoundsPropType,\nmodalsClosed: PropTypes.bool.isRequired,\nlightboxPosition: PropTypes.instanceOf(Animated.Value),\n- inProgress: PropTypes.bool.isRequired,\n+ postInProgress: PropTypes.bool.isRequired,\npendingUpload: pendingMultimediaUploadPropType,\nkeyboardShowing: PropTypes.bool.isRequired,\nmessageFocused: PropTypes.bool.isRequired,\n@@ -107,9 +107,9 @@ class MultimediaMessageMultimedia extends React.PureComponent<Props, State> {\n}\nrender() {\n- const { mediaInfo, pendingUpload, style, inProgress } = this.props;\n+ const { mediaInfo, pendingUpload, style, postInProgress } = this.props;\n- let failed = mediaInfo.id.startsWith('localUpload') && !inProgress;\n+ let failed = mediaInfo.id.startsWith('localUpload') && !postInProgress;\nlet progressPercent = 1;\nif (pendingUpload) {\n({ progressPercent, failed } = pendingUpload);\n" }, { "change_type": "MODIFY", "old_path": "native/chat/multimedia-message.react.js", "new_path": "native/chat/multimedia-message.react.js", "diff": "@@ -272,7 +272,7 @@ class MultimediaMessage extends React.PureComponent<Props> {\nstyle={style}\nmodalsClosed={this.props.modalsClosed}\nlightboxPosition={this.props.lightboxPosition}\n- inProgress={!!pendingUploads}\n+ postInProgress={!!pendingUploads}\npendingUpload={pendingUpload}\nkeyboardShowing={this.props.keyboardShowing}\nsetScrollDisabled={this.props.setScrollDisabled}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] MultimediaMessage: inProgress -> postInProgress
129,187
19.06.2019 23:51:12
14,400
987dd765d6c4c1f0e19d635dac2f2264525c6bde
[native] Corners -> lib/types/media-types
[ { "change_type": "MODIFY", "old_path": "lib/types/media-types.js", "new_path": "lib/types/media-types.js", "diff": "@@ -21,6 +21,13 @@ export type Media = {|\ndimensions: Dimensions,\n|};\n+export type Corners = $Shape<{|\n+ topLeft: bool,\n+ topRight: bool,\n+ bottomLeft: bool,\n+ bottomRight: bool,\n+|}>;\n+\nexport type MediaInfo = {|\n...Media,\nindex: number,\n@@ -39,6 +46,13 @@ const mediaPropTypes = {\nexport const mediaPropType = PropTypes.shape(mediaPropTypes);\n+export const cornersPropType = PropTypes.shape({\n+ topLeft: PropTypes.bool,\n+ topRight: PropTypes.bool,\n+ bottomLeft: PropTypes.bool,\n+ bottomRight: PropTypes.bool,\n+});\n+\nexport const mediaInfoPropType = PropTypes.shape({\n...mediaPropTypes,\nindex: PropTypes.number.isRequired,\n" }, { "change_type": "MODIFY", "old_path": "native/chat/multimedia-message.react.js", "new_path": "native/chat/multimedia-message.react.js", "diff": "@@ -5,7 +5,7 @@ import type {\nMultimediaMessageInfo,\nLocalMessageInfo,\n} from 'lib/types/message-types';\n-import type { Media } from 'lib/types/media-types';\n+import type { Media, Corners } from 'lib/types/media-types';\nimport type { ImageStyle } from '../types/styles';\nimport type { ThreadInfo } from 'lib/types/thread-types';\nimport type { Navigate } from '../navigation/route-names';\n@@ -30,7 +30,6 @@ import MultimediaMessageMultimedia from './multimedia-message-multimedia.react';\nimport { modalsClosedSelector } from '../selectors/nav-selectors';\nimport { withLightboxPositionContext } from '../media/lightbox-navigator.react';\nimport {\n- type Corners,\nallCorners,\ngetRoundedContainerStyle,\n} from './rounded-message-container.react';\n" }, { "change_type": "MODIFY", "old_path": "native/chat/rounded-message-container.react.js", "new_path": "native/chat/rounded-message-container.react.js", "diff": "import type { ChatMessageInfoItemWithHeight } from './message.react';\nimport { chatMessageItemPropType } from 'lib/selectors/chat-selectors';\nimport type { ViewStyle } from '../types/styles';\n+import type { Corners } from 'lib/types/media-types';\nimport * as React from 'react';\nimport PropTypes from 'prop-types';\nimport { StyleSheet, View, ViewPropTypes } from 'react-native';\n-export type Corners = $Shape<{|\n- topLeft: bool,\n- topRight: bool,\n- bottomLeft: bool,\n- bottomRight: bool,\n-|}>;\nconst allCorners = {\ntopLeft: true,\ntopRight: true,\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Corners -> lib/types/media-types
129,187
19.06.2019 23:54:08
14,400
ddff5f00891a28bb1103beac2c932157408d0415
[native] Add corners to MediaInfo
[ { "change_type": "MODIFY", "old_path": "lib/types/media-types.js", "new_path": "lib/types/media-types.js", "diff": "@@ -30,6 +30,7 @@ export type Corners = $Shape<{|\nexport type MediaInfo = {|\n...Media,\n+ corners: Corners,\nindex: number,\nmessageID: string,\nmessageKey: string,\n@@ -55,8 +56,10 @@ export const cornersPropType = PropTypes.shape({\nexport const mediaInfoPropType = PropTypes.shape({\n...mediaPropTypes,\n+ corners: cornersPropType.isRequired,\nindex: PropTypes.number.isRequired,\nmessageID: PropTypes.string.isRequired,\n+ messageKey: PropTypes.string.isRequired,\n});\nexport type UploadMultimediaResult = {|\n" }, { "change_type": "MODIFY", "old_path": "native/chat/multimedia-message.react.js", "new_path": "native/chat/multimedia-message.react.js", "diff": "@@ -31,6 +31,7 @@ import { modalsClosedSelector } from '../selectors/nav-selectors';\nimport { withLightboxPositionContext } from '../media/lightbox-navigator.react';\nimport {\nallCorners,\n+ filterCorners,\ngetRoundedContainerStyle,\n} from './rounded-message-container.react';\n@@ -186,7 +187,7 @@ class MultimediaMessage extends React.PureComponent<Props> {\nreturn this.renderImage(\nmessageInfo.media[0],\n0,\n- this.getCornerStyle(allCorners),\n+ allCorners,\n);\n}\n@@ -206,25 +207,14 @@ class MultimediaMessage extends React.PureComponent<Props> {\nconst firstInRow = j === 0;\nconst lastInRow = j + 1 === rowMedia.length;\nconst inLastColumn = j + 1 === mediaPerRow;\n-\n- const style = [];\n- if (!lastInRow) {\n- style.push(styles.imageBeforeImage);\n- }\n- if (firstRow && firstInRow) {\n- style.push(this.getCornerStyle({ topLeft: true }));\n- }\n- if (firstRow && inLastColumn) {\n- style.push(this.getCornerStyle({ topRight: true }));\n- }\n- if (lastRow && firstInRow) {\n- style.push(this.getCornerStyle({ bottomLeft: true }));\n- }\n- if (lastRow && inLastColumn) {\n- style.push(this.getCornerStyle({ bottomRight: true }));\n- }\n-\n- row.push(this.renderImage(media, i + j, style));\n+ const corners = {\n+ topLeft: firstRow && firstInRow,\n+ topRight: firstRow && inLastColumn,\n+ bottomLeft: lastRow && firstInRow,\n+ bottomRight: lastRow && inLastColumn,\n+ };\n+ const style = lastInRow ? null : styles.imageBeforeImage;\n+ row.push(this.renderImage(media, i + j, corners, style));\n}\nfor (; j < mediaPerRow; j++) {\nconst key = `filler${j}`;\n@@ -246,18 +236,21 @@ class MultimediaMessage extends React.PureComponent<Props> {\nreturn <View style={styles.grid}>{rows}</View>;\n}\n- getCornerStyle(corners: Corners) {\n- return getRoundedContainerStyle(this.props.item, corners, borderRadius);\n- }\n-\nrenderImage(\nmedia: Media,\nindex: number,\n- style: ImageStyle,\n+ corners: Corners,\n+ style?: ImageStyle,\n): React.Node {\n+ const filteredCorners = filterCorners(corners, this.props.item);\n+ const roundedStyle = getRoundedContainerStyle(\n+ filteredCorners,\n+ borderRadius,\n+ );\nconst { pendingUploads, messageInfo } = this.props.item;\nconst mediaInfo = {\n...media,\n+ corners: filteredCorners,\nmessageID: messageID(messageInfo),\nmessageKey: messageKey(messageInfo),\nindex,\n@@ -268,7 +261,7 @@ class MultimediaMessage extends React.PureComponent<Props> {\nmediaInfo={mediaInfo}\nnavigate={this.props.navigate}\nverticalBounds={this.props.verticalBounds}\n- style={style}\n+ style={[ style, roundedStyle ]}\nmodalsClosed={this.props.modalsClosed}\nlightboxPosition={this.props.lightboxPosition}\npostInProgress={!!pendingUploads}\n" }, { "change_type": "MODIFY", "old_path": "native/chat/rounded-message-container.react.js", "new_path": "native/chat/rounded-message-container.react.js", "diff": "@@ -9,6 +9,21 @@ import * as React from 'react';\nimport PropTypes from 'prop-types';\nimport { StyleSheet, View, ViewPropTypes } from 'react-native';\n+function filterCorners(\n+ corners: Corners,\n+ item: ChatMessageInfoItemWithHeight,\n+) {\n+ const { startsCluster, endsCluster } = item;\n+ const { isViewer } = item.messageInfo.creator;\n+ const { topLeft, topRight, bottomLeft, bottomRight } = corners;\n+ return {\n+ topLeft: topLeft && !isViewer && !startsCluster,\n+ topRight: topRight && isViewer && !startsCluster,\n+ bottomLeft: bottomLeft && !isViewer && !endsCluster,\n+ bottomRight: bottomRight && isViewer && !endsCluster,\n+ };\n+}\n+\nconst allCorners = {\ntopLeft: true,\ntopRight: true,\n@@ -16,30 +31,15 @@ const allCorners = {\nbottomRight: true,\n};\nfunction getRoundedContainerStyle(\n- item: ChatMessageInfoItemWithHeight,\ncorners: Corners,\nborderRadius?: number = 8,\n) {\n- const { startsCluster, endsCluster } = item;\n- const { isViewer } = item.messageInfo.creator;\nconst { topLeft, topRight, bottomLeft, bottomRight } = corners;\nreturn {\n- borderTopLeftRadius:\n- topLeft && !isViewer && !startsCluster\n- ? 0\n- : borderRadius,\n- borderTopRightRadius:\n- topRight && isViewer && !startsCluster\n- ? 0\n- : borderRadius,\n- borderBottomLeftRadius:\n- bottomLeft && !isViewer && !endsCluster\n- ? 0\n- : borderRadius,\n- borderBottomRightRadius:\n- bottomRight && isViewer && !endsCluster\n- ? 0\n- : borderRadius,\n+ borderTopLeftRadius: topLeft ? 0 : borderRadius,\n+ borderTopRightRadius: topRight ? 0 : borderRadius,\n+ borderBottomLeftRadius: bottomLeft ? 0 : borderRadius,\n+ borderBottomRightRadius: bottomRight ? 0 : borderRadius,\n};\n}\n@@ -64,8 +64,7 @@ class RoundedMessageContainer extends React.PureComponent<Props> {\nrender() {\nconst { item, borderRadius, style } = this.props;\nconst cornerStyle = getRoundedContainerStyle(\n- item,\n- allCorners,\n+ filterCorners(allCorners, item),\nborderRadius,\n);\nreturn (\n@@ -85,6 +84,7 @@ const styles = StyleSheet.create({\nexport {\nallCorners,\n+ filterCorners,\ngetRoundedContainerStyle,\nRoundedMessageContainer,\n};\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Add corners to MediaInfo
129,187
20.06.2019 00:11:10
14,400
ec4ede85e9b02c1fb658d2b74cfae6fa05609397
[native] Introduce LightboxNavigator-based Tooltip
[ { "change_type": "ADD", "old_path": null, "new_path": "native/chat/inline-multimedia.react.js", "diff": "+// @flow\n+\n+import { type MediaInfo, mediaInfoPropType } from 'lib/types/media-types';\n+import type { ImageStyle } from '../types/styles';\n+import {\n+ type PendingMultimediaUpload,\n+ pendingMultimediaUploadPropType,\n+} from './chat-input-state';\n+\n+import * as React from 'react';\n+import PropTypes from 'prop-types';\n+import { View, TouchableOpacity, StyleSheet } from 'react-native';\n+import Icon from 'react-native-vector-icons/Feather';\n+import * as Progress from 'react-native-progress';\n+\n+import Multimedia from '../media/multimedia.react';\n+\n+type Props = {|\n+ mediaInfo: MediaInfo,\n+ style: ImageStyle,\n+ onPress: () => void,\n+ onLongPress: () => void,\n+ postInProgress: bool,\n+ pendingUpload: ?PendingMultimediaUpload,\n+|};\n+class InlineMultimedia extends React.PureComponent<Props> {\n+\n+ static propTypes = {\n+ mediaInfo: mediaInfoPropType.isRequired,\n+ onPress: PropTypes.func.isRequired,\n+ onLongPress: PropTypes.func.isRequired,\n+ postInProgress: PropTypes.bool.isRequired,\n+ pendingUpload: pendingMultimediaUploadPropType,\n+ };\n+\n+ render() {\n+ const { mediaInfo, pendingUpload, style, postInProgress } = this.props;\n+\n+ let failed = mediaInfo.id.startsWith('localUpload') && !postInProgress;\n+ let progressPercent = 1;\n+ if (pendingUpload) {\n+ ({ progressPercent, failed } = pendingUpload);\n+ }\n+\n+ let progressIndicator;\n+ if (failed) {\n+ progressIndicator = (\n+ <View style={styles.centerContainer}>\n+ <Icon\n+ name=\"alert-circle\"\n+ style={styles.uploadError}\n+ size={64}\n+ />\n+ </View>\n+ );\n+ } else if (progressPercent !== 1) {\n+ progressIndicator = (\n+ <View style={styles.centerContainer}>\n+ <Progress.Circle\n+ size={100}\n+ indeterminate={progressPercent === 0}\n+ progress={progressPercent}\n+ borderWidth={5}\n+ fill=\"#DDDDDD\"\n+ unfilledColor=\"#DDDDDD\"\n+ color=\"#88BB88\"\n+ thickness={15}\n+ showsText={true}\n+ textStyle={styles.progressIndicatorText}\n+ />\n+ </View>\n+ );\n+ }\n+\n+\n+ return (\n+ <TouchableOpacity\n+ onPress={this.props.onPress}\n+ onLongPress={this.props.onLongPress}\n+ style={styles.expand}\n+ >\n+ <View style={[ styles.multimediaContainer, style ]}>\n+ <Multimedia mediaInfo={mediaInfo} />\n+ {progressIndicator}\n+ </View>\n+ </TouchableOpacity>\n+ );\n+ }\n+\n+}\n+\n+const styles = StyleSheet.create({\n+ expand: {\n+ flex: 1,\n+ },\n+ multimediaContainer: {\n+ flex: 1,\n+ overflow: 'hidden',\n+ },\n+ centerContainer: {\n+ position: 'absolute',\n+ top: 0,\n+ bottom: 0,\n+ left: 0,\n+ right: 0,\n+ alignItems: 'center',\n+ justifyContent: 'center',\n+ },\n+ progressIndicatorText: {\n+ color: 'black',\n+ fontSize: 21,\n+ },\n+ uploadError: {\n+ color: \"white\",\n+ textShadowColor: \"#000\",\n+ textShadowOffset: { width: 0, height: 1 },\n+ textShadowRadius: 1,\n+ },\n+});\n+\n+export default InlineMultimedia;\n" }, { "change_type": "MODIFY", "old_path": "native/chat/multimedia-message.react.js", "new_path": "native/chat/multimedia-message.react.js", "diff": "@@ -314,6 +314,7 @@ const WrappedMultimediaMessage =\n);\nexport {\n+ borderRadius as multimediaMessageBorderRadius,\nWrappedMultimediaMessage as MultimediaMessage,\nmultimediaMessageContentHeight,\nmultimediaMessageItemHeight,\n" }, { "change_type": "ADD", "old_path": null, "new_path": "native/chat/multimedia-tooltip-button.react.js", "diff": "+// @flow\n+\n+import { type MediaInfo, mediaInfoPropType } from 'lib/types/media-types';\n+import {\n+ type VerticalBounds,\n+ verticalBoundsPropType,\n+ type LayoutCoordinates,\n+ layoutCoordinatesPropType,\n+} from '../types/lightbox-types';\n+\n+import * as React from 'react';\n+import PropTypes from 'prop-types';\n+\n+import {\n+ type ChatInputState,\n+ chatInputStatePropType,\n+ withChatInputState,\n+} from './chat-input-state';\n+import InlineMultimedia from './inline-multimedia.react';\n+import { multimediaMessageBorderRadius } from './multimedia-message.react';\n+import { getRoundedContainerStyle } from './rounded-message-container.react';\n+\n+type Props = {|\n+ mediaInfo: MediaInfo,\n+ initialCoordinates: LayoutCoordinates,\n+ verticalBounds: VerticalBounds,\n+ // withChatInputState\n+ chatInputState: ?ChatInputState,\n+|};\n+class MultimediaTooltipButton extends React.PureComponent<Props> {\n+\n+ static propTypes = {\n+ mediaInfo: mediaInfoPropType.isRequired,\n+ initialCoordinates: layoutCoordinatesPropType.isRequired,\n+ verticalBounds: verticalBoundsPropType.isRequired,\n+ chatInputState: chatInputStatePropType,\n+ };\n+\n+ render() {\n+ const { chatInputState, mediaInfo } = this.props;\n+\n+ const { id: mediaID, messageID } = mediaInfo;\n+ const pendingUploads = chatInputState\n+ && chatInputState.pendingUploads\n+ && chatInputState.pendingUploads[messageID];\n+ const pendingUpload = pendingUploads && pendingUploads[mediaID];\n+ const postInProgress = !!pendingUploads;\n+\n+ const roundedStyle = getRoundedContainerStyle(\n+ mediaInfo.corners,\n+ multimediaMessageBorderRadius,\n+ );\n+\n+ return (\n+ <InlineMultimedia\n+ mediaInfo={mediaInfo}\n+ style={roundedStyle}\n+ onPress={this.onPress}\n+ onLongPress={this.onPress}\n+ postInProgress={postInProgress}\n+ pendingUpload={pendingUpload}\n+ />\n+ );\n+ }\n+\n+ onPress = () => {\n+ }\n+\n+}\n+\n+export default withChatInputState(MultimediaTooltipButton);\n" }, { "change_type": "ADD", "old_path": null, "new_path": "native/chat/multimedia-tooltip-modal.react.js", "diff": "+// @flow\n+\n+import type { MediaInfo } from 'lib/types/media-types';\n+\n+import { createTooltip } from '../components/tooltip2.react';\n+\n+import MultimediaTooltipButton from './multimedia-tooltip-button.react';\n+import { saveImage } from '../media/save-image';\n+\n+type CustomProps = {\n+ mediaInfo: MediaInfo,\n+};\n+\n+function onPressSave(props: CustomProps) {\n+ return saveImage(props.mediaInfo);\n+}\n+\n+const MultimediaTooltipModal = createTooltip(\n+ MultimediaTooltipButton,\n+ [\n+ { text: \"Save\", onPress: onPressSave }\n+ ],\n+);\n+\n+export default MultimediaTooltipModal;\n" }, { "change_type": "ADD", "old_path": null, "new_path": "native/components/tooltip2.react.js", "diff": "+// @flow\n+\n+import type {\n+ NavigationScreenProp,\n+ NavigationLeafRoute,\n+ NavigationScene,\n+ NavigationTransitionProps,\n+} from 'react-navigation';\n+import {\n+ type VerticalBounds,\n+ verticalBoundsPropType,\n+ type LayoutCoordinates,\n+ layoutCoordinatesPropType,\n+} from '../types/lightbox-types';\n+import type { AppState } from '../redux/redux-setup';\n+import { type Dimensions, dimensionsPropType } from 'lib/types/media-types';\n+\n+import * as React from 'react';\n+import Animated, { Easing } from 'react-native-reanimated';\n+import { View, StyleSheet } from 'react-native';\n+import PropTypes from 'prop-types';\n+\n+import { connect } from 'lib/utils/redux-utils';\n+\n+import {\n+ contentBottomOffset,\n+ dimensionsSelector,\n+} from '../selectors/dimension-selectors';\n+\n+const {\n+ Value,\n+} = Animated;\n+\n+type TooltipEntry<CustomProps> = {|\n+ text: string,\n+ onPress: (props: CustomProps) => mixed,\n+|};\n+type TooltipSpec<CustomProps> = $ReadOnlyArray<TooltipEntry<CustomProps>>;\n+\n+type NavParams<CustomProps> = {\n+ ...CustomProps,\n+ initialCoordinates: LayoutCoordinates,\n+ verticalBounds: VerticalBounds,\n+};\n+\n+type NavProp<NavParams> = NavigationScreenProp<{|\n+ ...NavigationLeafRoute,\n+ params: NavParams,\n+|}>;\n+\n+type TooltipProps<NavParams> = {\n+ navigation: NavProp<NavParams>,\n+ scene: NavigationScene,\n+ transitionProps: NavigationTransitionProps,\n+ position: Value,\n+ screenDimensions: Dimensions,\n+};\n+function createTooltip<\n+ CustomProps: {},\n+ NavParamsType: NavParams<CustomProps>,\n+ TooltipPropsType: TooltipProps<NavParamsType>,\n+ ButtonComponentType: React.ComponentType<NavParamsType>,\n+ TooltipComponent: React.ComponentType<TooltipPropsType>,\n+>(\n+ ButtonComponent: ButtonComponentType,\n+ tooltipSpec: TooltipSpec<CustomProps>,\n+): TooltipComponent {\n+ class Tooltip extends React.PureComponent<TooltipPropsType> {\n+\n+ static propTypes = {\n+ navigation: PropTypes.shape({\n+ state: PropTypes.shape({\n+ params: PropTypes.shape({\n+ initialCoordinates: layoutCoordinatesPropType.isRequired,\n+ verticalBounds: verticalBoundsPropType.isRequired,\n+ }).isRequired,\n+ }).isRequired,\n+ goBack: PropTypes.func.isRequired,\n+ }).isRequired,\n+ transitionProps: PropTypes.object.isRequired,\n+ scene: PropTypes.object.isRequired,\n+ position: PropTypes.instanceOf(Value).isRequired,\n+ screenDimensions: dimensionsPropType.isRequired,\n+ };\n+\n+ get contentContainerStyle() {\n+ const { verticalBounds } = this.props.navigation.state.params;\n+ const fullScreenHeight = this.props.screenDimensions.height\n+ + contentBottomOffset;\n+ const top = verticalBounds.y;\n+ const bottom = fullScreenHeight - verticalBounds.y - verticalBounds.height;\n+ const verticalStyle = { marginTop: top, marginBottom: bottom };\n+ return [ styles.contentContainer, verticalStyle ];\n+ }\n+\n+ get buttonStyle() {\n+ const { params } = this.props.navigation.state;\n+ const { initialCoordinates, verticalBounds } = params;\n+ const { x, y, width, height } = initialCoordinates;\n+ return {\n+ width,\n+ height,\n+ marginTop: y - verticalBounds.y,\n+ marginLeft: x,\n+ };\n+ }\n+\n+ render() {\n+ const { params } = this.props.navigation.state;\n+ return (\n+ <View style={this.contentContainerStyle}>\n+ <View style={this.buttonStyle}>\n+ <ButtonComponent {...params} />\n+ </View>\n+ </View>\n+ );\n+ // TODO handle opacity animation (or not?)\n+ }\n+\n+ }\n+ return connect(\n+ (state: AppState) => ({\n+ screenDimensions: dimensionsSelector(state),\n+ }),\n+ )(Tooltip);\n+}\n+\n+const styles = StyleSheet.create({\n+ contentContainer: {\n+ flex: 1,\n+ overflow: \"hidden\",\n+ },\n+});\n+\n+export {\n+ createTooltip,\n+};\n" }, { "change_type": "MODIFY", "old_path": "native/navigation/navigation-setup.js", "new_path": "native/navigation/navigation-setup.js", "diff": "@@ -88,6 +88,7 @@ import {\nColorPickerModalRouteName,\nComposeSubthreadModalRouteName,\nMultimediaModalRouteName,\n+ MultimediaTooltipModalRouteName,\naccountModals,\n} from './route-names';\nimport {\n@@ -101,6 +102,7 @@ import ColorPickerModal from '../chat/settings/color-picker-modal.react';\nimport ComposeSubthreadModal from '../chat/settings/compose-subthread-modal.react';\nimport { createLightboxNavigator } from '../media/lightbox-navigator.react';\nimport MultimediaModal from '../media/multimedia-modal.react';\n+import MultimediaTooltipModal from '../chat/multimedia-tooltip-modal.react';\nimport ChatInputStateContainer from '../chat/chat-input-state-container.react';\nuseScreens();\n@@ -163,6 +165,7 @@ const AppNavigator = createLightboxNavigator(\n{\n[TabNavigatorRouteName]: TabNavigator,\n[MultimediaModalRouteName]: MultimediaModal,\n+ [MultimediaTooltipModalRouteName]: MultimediaTooltipModal,\n},\n);\n" }, { "change_type": "MODIFY", "old_path": "native/navigation/route-names.js", "new_path": "native/navigation/route-names.js", "diff": "@@ -36,6 +36,7 @@ export const CustomServerModalRouteName = 'CustomServerModal';\nexport const ColorPickerModalRouteName = 'ColorPickerModal';\nexport const ComposeSubthreadModalRouteName = 'ComposeSubthreadModal';\nexport const MultimediaModalRouteName = 'MultimediaModal';\n+export const MultimediaTooltipModalRouteName = 'MultimediaTooltipModal';\nexport const accountModals = [\nLoggedOutModalRouteName,\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Introduce LightboxNavigator-based Tooltip
129,187
20.06.2019 00:20:24
14,400
434466e408e0baf7f940ec0d404aa03882fef311
[native] Use new Tooltip for MultimediaMessage
[ { "change_type": "MODIFY", "old_path": "native/chat/multimedia-message-multimedia.react.js", "new_path": "native/chat/multimedia-message-multimedia.react.js", "diff": "@@ -5,6 +5,7 @@ import type { ImageStyle } from '../types/styles';\nimport {\ntype Navigate,\nMultimediaModalRouteName,\n+ MultimediaTooltipModalRouteName,\n} from '../navigation/route-names';\nimport {\ntype VerticalBounds,\n@@ -14,26 +15,22 @@ import {\ntype PendingMultimediaUpload,\npendingMultimediaUploadPropType,\n} from './chat-input-state';\n-import type { TooltipItemData } from '../components/tooltip.react';\nimport * as React from 'react';\nimport PropTypes from 'prop-types';\nimport { View, StyleSheet } from 'react-native';\nimport Animated from 'react-native-reanimated';\n-import * as Progress from 'react-native-progress';\n-import Icon from 'react-native-vector-icons/Feather';\nimport { KeyboardUtils } from 'react-native-keyboard-input';\nimport invariant from 'invariant';\n-import Multimedia from '../media/multimedia.react';\n-import Tooltip from '../components/tooltip.react';\n+import InlineMultimedia from './inline-multimedia.react';\nimport { saveImage } from '../media/save-image';\ntype Props = {|\nmediaInfo: MediaInfo,\nnavigate: Navigate,\nverticalBounds: ?VerticalBounds,\n- style?: ImageStyle,\n+ style: ImageStyle,\nmodalsClosed: bool,\nlightboxPosition: ?Animated.Value,\npostInProgress: bool,\n@@ -63,8 +60,6 @@ class MultimediaMessageMultimedia extends React.PureComponent<Props, State> {\nsetScrollDisabled: PropTypes.func.isRequired,\n};\nview: ?View;\n- tooltipConfig: $ReadOnlyArray<TooltipItemData>;\n- tooltip: ?Tooltip;\nconstructor(props: Props) {\nsuper(props);\n@@ -72,9 +67,6 @@ class MultimediaMessageMultimedia extends React.PureComponent<Props, State> {\nhidden: false,\nopacity: this.getOpacity(),\n};\n- this.tooltipConfig = [\n- { label: \"Save\", onPress: this.onPressSave },\n- ];\n}\nstatic getDerivedStateFromProps(props: Props, state: State) {\n@@ -107,71 +99,25 @@ class MultimediaMessageMultimedia extends React.PureComponent<Props, State> {\n}\nrender() {\n- const { mediaInfo, pendingUpload, style, postInProgress } = this.props;\n-\n- let failed = mediaInfo.id.startsWith('localUpload') && !postInProgress;\n- let progressPercent = 1;\n- if (pendingUpload) {\n- ({ progressPercent, failed } = pendingUpload);\n- }\n-\n- let progressIndicator;\n- if (failed) {\n- progressIndicator = (\n- <View style={styles.centerContainer}>\n- <Icon\n- name=\"alert-circle\"\n- style={styles.uploadError}\n- size={64}\n- />\n- </View>\n- );\n- } else if (progressPercent !== 1) {\n- progressIndicator = (\n- <View style={styles.centerContainer}>\n- <Progress.Circle\n- size={100}\n- indeterminate={progressPercent === 0}\n- progress={progressPercent}\n- borderWidth={5}\n- fill=\"#DDDDDD\"\n- unfilledColor=\"#DDDDDD\"\n- color=\"#88BB88\"\n- thickness={15}\n- showsText={true}\n- textStyle={styles.progressIndicatorText}\n- />\n- </View>\n- );\n- }\n-\nconst wrapperStyles = [ styles.expand ];\nif (this.state.hidden && this.state.opacity) {\nwrapperStyles.push({ opacity: this.state.opacity });\n}\n- const multimedia = (\n- <View style={[ styles.multimediaContainer, style ]} ref={this.viewRef}>\n- <Animated.View style={wrapperStyles}>\n- <Multimedia mediaInfo={mediaInfo} />\n- {progressIndicator}\n- </Animated.View>\n- </View>\n- );\n-\n+ const { mediaInfo, pendingUpload, style, postInProgress } = this.props;\nreturn (\n- <Tooltip\n- buttonComponent={multimedia}\n- items={this.tooltipConfig}\n- componentWrapperStyle={styles.expand}\n- componentContainerStyle={styles.expand}\n- labelStyle={styles.popoverLabelStyle}\n- onOpenTooltipMenu={this.onFocus}\n- onCloseTooltipMenu={this.onBlur}\n- onPressOverride={this.onPress}\n+ <Animated.View style={wrapperStyles}>\n+ <View style={styles.expand} ref={this.viewRef}>\n+ <InlineMultimedia\n+ mediaInfo={this.props.mediaInfo}\n+ style={this.props.style}\n+ onPress={this.onPress}\nonLongPress={this.onLongPress}\n- innerRef={this.tooltipRef}\n+ postInProgress={this.props.postInProgress}\n+ pendingUpload={this.props.pendingUpload}\n/>\n+ </View>\n+ </Animated.View>\n);\n}\n@@ -179,18 +125,11 @@ class MultimediaMessageMultimedia extends React.PureComponent<Props, State> {\nthis.view = view;\n}\n- tooltipRef = (tooltip: ?Tooltip) => {\n- this.tooltip = tooltip;\n- }\n-\nonPress = () => {\n- const { view, props: { verticalBounds }, tooltip } = this;\n+ const { view, props: { verticalBounds } } = this;\nif (!view || !verticalBounds) {\nreturn;\n}\n- if (tooltip) {\n- tooltip.hideModal();\n- }\nview.measure((x, y, width, height, pageX, pageY) => {\nconst coordinates = { x: pageX, y: pageY, width, height };\nconst { mediaInfo, navigate } = this.props;\n@@ -203,6 +142,7 @@ class MultimediaMessageMultimedia extends React.PureComponent<Props, State> {\n}\nonFocus = () => {\n+ // TODO\nthis.props.setScrollDisabled(true);\nif (!this.props.messageFocused) {\nthis.props.toggleMessageFocus(this.props.mediaInfo.messageKey);\n@@ -210,6 +150,7 @@ class MultimediaMessageMultimedia extends React.PureComponent<Props, State> {\n}\nonBlur = () => {\n+ // TODO\nthis.props.setScrollDisabled(false);\nif (this.props.messageFocused) {\nthis.props.toggleMessageFocus(this.props.mediaInfo.messageKey);\n@@ -217,6 +158,7 @@ class MultimediaMessageMultimedia extends React.PureComponent<Props, State> {\n}\nonPressSave = () => {\n+ // TODO\nreturn saveImage(this.props.mediaInfo);\n}\n@@ -225,48 +167,26 @@ class MultimediaMessageMultimedia extends React.PureComponent<Props, State> {\nKeyboardUtils.dismiss();\nreturn;\n}\n- const tooltip = this.tooltip;\n- invariant(tooltip, \"tooltip should be set\");\n- if (this.props.messageFocused) {\n- tooltip.hideModal();\n- } else {\n- tooltip.openModal();\n+ const { view, props: { verticalBounds } } = this;\n+ if (!view || !verticalBounds) {\n+ return;\n}\n+ view.measure((x, y, width, height, pageX, pageY) => {\n+ const coordinates = { x: pageX, y: pageY, width, height };\n+ const { mediaInfo, navigate } = this.props;\n+ navigate({\n+ routeName: MultimediaTooltipModalRouteName,\n+ params: { mediaInfo, initialCoordinates: coordinates, verticalBounds },\n+ });\n+ });\n}\n}\nconst styles = StyleSheet.create({\n- multimediaContainer: {\n- flex: 1,\n- overflow: 'hidden',\n- },\nexpand: {\nflex: 1,\n},\n- centerContainer: {\n- position: 'absolute',\n- top: 0,\n- bottom: 0,\n- left: 0,\n- right: 0,\n- alignItems: 'center',\n- justifyContent: 'center',\n- },\n- progressIndicatorText: {\n- color: 'black',\n- fontSize: 21,\n- },\n- uploadError: {\n- color: \"white\",\n- textShadowColor: \"#000\",\n- textShadowOffset: { width: 0, height: 1 },\n- textShadowRadius: 1,\n- },\n- popoverLabelStyle: {\n- textAlign: 'center',\n- color: '#444',\n- },\n});\nexport default MultimediaMessageMultimedia;\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Use new Tooltip for MultimediaMessage
129,187
20.06.2019 15:19:18
14,400
603932526434d08244758f5e8eacbd5e03890c34
[native] Backdrop for new Tooltip And ability to close it
[ { "change_type": "MODIFY", "old_path": "native/chat/multimedia-message-multimedia.react.js", "new_path": "native/chat/multimedia-message-multimedia.react.js", "diff": "@@ -157,11 +157,6 @@ class MultimediaMessageMultimedia extends React.PureComponent<Props, State> {\n}\n}\n- onPressSave = () => {\n- // TODO\n- return saveImage(this.props.mediaInfo);\n- }\n-\nonLongPress = () => {\nif (this.props.keyboardShowing) {\nKeyboardUtils.dismiss();\n" }, { "change_type": "MODIFY", "old_path": "native/chat/multimedia-tooltip-button.react.js", "new_path": "native/chat/multimedia-tooltip-button.react.js", "diff": "@@ -7,6 +7,10 @@ import {\ntype LayoutCoordinates,\nlayoutCoordinatesPropType,\n} from '../types/lightbox-types';\n+import type {\n+ NavigationScreenProp,\n+ NavigationLeafRoute,\n+} from 'react-navigation';\nimport * as React from 'react';\nimport PropTypes from 'prop-types';\n@@ -20,24 +24,39 @@ import InlineMultimedia from './inline-multimedia.react';\nimport { multimediaMessageBorderRadius } from './multimedia-message.react';\nimport { getRoundedContainerStyle } from './rounded-message-container.react';\n-type Props = {|\n+type NavProp = NavigationScreenProp<{|\n+ ...NavigationLeafRoute,\n+ params: {\nmediaInfo: MediaInfo,\ninitialCoordinates: LayoutCoordinates,\nverticalBounds: VerticalBounds,\n+ },\n+|}>;\n+\n+type Props = {\n+ navigation: NavProp,\n// withChatInputState\nchatInputState: ?ChatInputState,\n-|};\n+};\nclass MultimediaTooltipButton extends React.PureComponent<Props> {\nstatic propTypes = {\n+ navigation: PropTypes.shape({\n+ state: PropTypes.shape({\n+ params: PropTypes.shape({\nmediaInfo: mediaInfoPropType.isRequired,\ninitialCoordinates: layoutCoordinatesPropType.isRequired,\nverticalBounds: verticalBoundsPropType.isRequired,\n+ }).isRequired,\n+ }).isRequired,\n+ goBack: PropTypes.func.isRequired,\n+ }).isRequired,\nchatInputState: chatInputStatePropType,\n};\nrender() {\n- const { chatInputState, mediaInfo } = this.props;\n+ const { chatInputState } = this.props;\n+ const { mediaInfo } = this.props.navigation.state.params;\nconst { id: mediaID, messageID } = mediaInfo;\nconst pendingUploads = chatInputState\n@@ -64,6 +83,7 @@ class MultimediaTooltipButton extends React.PureComponent<Props> {\n}\nonPress = () => {\n+ this.props.navigation.goBack();\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "native/components/tooltip2.react.js", "new_path": "native/components/tooltip2.react.js", "diff": "@@ -17,7 +17,7 @@ import { type Dimensions, dimensionsPropType } from 'lib/types/media-types';\nimport * as React from 'react';\nimport Animated, { Easing } from 'react-native-reanimated';\n-import { View, StyleSheet } from 'react-native';\n+import { View, StyleSheet, TouchableWithoutFeedback } from 'react-native';\nimport PropTypes from 'prop-types';\nimport { connect } from 'lib/utils/redux-utils';\n@@ -37,19 +37,21 @@ type TooltipEntry<CustomProps> = {|\n|};\ntype TooltipSpec<CustomProps> = $ReadOnlyArray<TooltipEntry<CustomProps>>;\n-type NavParams<CustomProps> = {\n+type NavProp<CustomProps> = NavigationScreenProp<{|\n+ ...NavigationLeafRoute,\n+ params: {\n...CustomProps,\ninitialCoordinates: LayoutCoordinates,\nverticalBounds: VerticalBounds,\n-};\n-\n-type NavProp<NavParams> = NavigationScreenProp<{|\n- ...NavigationLeafRoute,\n- params: NavParams,\n+ },\n|}>;\n-type TooltipProps<NavParams> = {\n- navigation: NavProp<NavParams>,\n+type ButtonProps<Navigation> = {\n+ navigation: Navigation,\n+};\n+\n+type TooltipProps<Navigation> = {\n+ navigation: Navigation,\nscene: NavigationScene,\ntransitionProps: NavigationTransitionProps,\nposition: Value,\n@@ -57,9 +59,9 @@ type TooltipProps<NavParams> = {\n};\nfunction createTooltip<\nCustomProps: {},\n- NavParamsType: NavParams<CustomProps>,\n- TooltipPropsType: TooltipProps<NavParamsType>,\n- ButtonComponentType: React.ComponentType<NavParamsType>,\n+ Navigation: NavProp<CustomProps>,\n+ TooltipPropsType: TooltipProps<Navigation>,\n+ ButtonComponentType: React.ComponentType<ButtonProps<Navigation>>,\nTooltipComponent: React.ComponentType<TooltipPropsType>,\n>(\nButtonComponent: ButtonComponentType,\n@@ -88,7 +90,8 @@ function createTooltip<\nconst fullScreenHeight = this.props.screenDimensions.height\n+ contentBottomOffset;\nconst top = verticalBounds.y;\n- const bottom = fullScreenHeight - verticalBounds.y - verticalBounds.height;\n+ const bottom = fullScreenHeight\n+ - verticalBounds.y - verticalBounds.height;\nconst verticalStyle = { marginTop: top, marginBottom: bottom };\nreturn [ styles.contentContainer, verticalStyle ];\n}\n@@ -106,15 +109,22 @@ function createTooltip<\n}\nrender() {\n- const { params } = this.props.navigation.state;\n+ const { navigation } = this.props;\nreturn (\n+ <TouchableWithoutFeedback onPress={this.onPressBackdrop}>\n+ <View style={styles.backdrop}>\n<View style={this.contentContainerStyle}>\n<View style={this.buttonStyle}>\n- <ButtonComponent {...params} />\n+ <ButtonComponent navigation={navigation} />\n+ </View>\n</View>\n</View>\n+ </TouchableWithoutFeedback>\n);\n- // TODO handle opacity animation (or not?)\n+ }\n+\n+ onPressBackdrop = () => {\n+ this.props.navigation.goBack();\n}\n}\n@@ -126,6 +136,11 @@ function createTooltip<\n}\nconst styles = StyleSheet.create({\n+ backdrop: {\n+ flex: 1,\n+ opacity: 0.7,\n+ backgroundColor: 'black',\n+ },\ncontentContainer: {\nflex: 1,\noverflow: \"hidden\",\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Backdrop for new Tooltip And ability to close it
129,187
20.06.2019 15:58:13
14,400
b013aae0977e566224b43fe2d3ccda0dd18fb25e
[native] Use selector to avoid unnecessary rerenders in MessageList
[ { "change_type": "MODIFY", "old_path": "native/chat/message-list.react.js", "new_path": "native/chat/message-list.react.js", "diff": "@@ -21,6 +21,7 @@ import {\nimport _sum from 'lodash/fp/sum';\nimport _find from 'lodash/fp/find';\nimport { KeyboardUtils } from 'react-native-keyboard-input';\n+import { createSelector } from 'reselect';\nimport { messageKey } from 'lib/shared/message-utils';\nimport { connect } from 'lib/utils/redux-utils';\n@@ -70,6 +71,16 @@ type State = {|\nscrollDisabled: bool,\nmessageListVerticalBounds: ?VerticalBounds,\nkeyboardShowing: bool,\n+ flatListExtraData: FlatListExtraData,\n+|};\n+type PropsAndState = {|\n+ ...Props,\n+ ...State,\n+|};\n+type FlatListExtraData = {|\n+ keyboardShowing: bool,\n+ messageListVerticalBounds: ?VerticalBounds,\n+ focusedMessageKey: ?string,\n|};\nclass MessageList extends React.PureComponent<Props, State> {\n@@ -84,17 +95,53 @@ class MessageList extends React.PureComponent<Props, State> {\nfetchMessagesBeforeCursor: PropTypes.func.isRequired,\nfetchMostRecentMessages: PropTypes.func.isRequired,\n};\n- state = {\n+ loadingFromScroll = false;\n+ flatListContainer: ?View;\n+ keyboardShowListener: ?Object;\n+ keyboardDismissListener: ?Object;\n+\n+ constructor(props: Props) {\n+ super(props);\n+ this.state = {\nfocusedMessageKey: null,\nscrollDisabled: false,\nmessageListVerticalBounds: null,\nkeyboardShowing: false,\n+ flatListExtraData: {\n+ keyboardShowing: props.imageGalleryOpen,\n+ messageListVerticalBounds: null,\n+ focusedMessageKey: null,\n+ },\n};\n- loadingFromScroll = false;\n- flatListContainer: ?View;\n+ }\n- keyboardShowListener: ?Object;\n- keyboardDismissListener: ?Object;\n+ static flatListExtraDataSelector = createSelector(\n+ (propsAndState: PropsAndState) => propsAndState.keyboardShowing,\n+ (propsAndState: PropsAndState) => propsAndState.messageListVerticalBounds,\n+ (propsAndState: PropsAndState) => propsAndState.imageGalleryOpen,\n+ (propsAndState: PropsAndState) => propsAndState.focusedMessageKey,\n+ (\n+ keyboardShowing: bool,\n+ messageListVerticalBounds: ?VerticalBounds,\n+ imageGalleryOpen: bool,\n+ focusedMessageKey: ?string,\n+ ) => ({\n+ keyboardShowing: keyboardShowing || imageGalleryOpen,\n+ messageListVerticalBounds,\n+ focusedMessageKey,\n+ }),\n+ );\n+\n+ static getDerivedStateFromProps(props: Props, state: State) {\n+ const flatListExtraData = MessageList.flatListExtraDataSelector({\n+ ...props,\n+ ...state,\n+ });\n+ if (flatListExtraData !== state.flatListExtraData) {\n+ return { flatListExtraData };\n+ }\n+ return null;\n+ }\nkeyboardShow = () => {\nthis.setState({ keyboardShowing: true });\n@@ -172,10 +219,13 @@ class MessageList extends React.PureComponent<Props, State> {\n);\n}\nconst messageInfoItem: ChatMessageInfoItemWithHeight = row.item;\n+ const {\n+ keyboardShowing,\n+ messageListVerticalBounds,\n+ focusedMessageKey,\n+ } = this.state.flatListExtraData;\nconst focused =\n- messageKey(messageInfoItem.messageInfo) === this.state.focusedMessageKey;\n- const keyboardShowing =\n- this.state.keyboardShowing || this.props.imageGalleryOpen;\n+ messageKey(messageInfoItem.messageInfo) === focusedMessageKey;\nreturn (\n<Message\nitem={messageInfoItem}\n@@ -183,7 +233,7 @@ class MessageList extends React.PureComponent<Props, State> {\nnavigate={this.props.navigate}\ntoggleFocus={this.toggleMessageFocus}\nsetScrollDisabled={this.setScrollDisabled}\n- verticalBounds={this.state.messageListVerticalBounds}\n+ verticalBounds={messageListVerticalBounds}\nkeyboardShowing={keyboardShowing}\n/>\n);\n@@ -256,7 +306,7 @@ class MessageList extends React.PureComponent<Props, State> {\nListFooterComponent={footer}\nscrollsToTop={false}\nscrollEnabled={!this.state.scrollDisabled}\n- extraData={this.state}\n+ extraData={this.state.flatListExtraData}\n/>\n</View>\n);\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Use selector to avoid unnecessary rerenders in MessageList
129,187
20.06.2019 16:04:03
14,400
8a11f38064daa7681b782cbffed50eef8bcd7f01
[native] Determine modalsClosed in MessageList Avoids Redux-connecting `MultimediaMessage`
[ { "change_type": "MODIFY", "old_path": "native/chat/message-list.react.js", "new_path": "native/chat/message-list.react.js", "diff": "@@ -46,6 +46,7 @@ import {\naddKeyboardDismissListener,\nremoveKeyboardListener,\n} from '../keyboard';\n+import { modalsClosedSelector } from '../selectors/nav-selectors';\ntype Props = {|\nthreadInfo: ThreadInfo,\n@@ -55,6 +56,7 @@ type Props = {|\n// Redux state\nviewerID: ?string,\nstartReached: bool,\n+ modalsClosed: bool,\n// Redux dispatch functions\ndispatchActionPromise: DispatchActionPromise,\n// async functions that hit server APIs\n@@ -78,6 +80,7 @@ type PropsAndState = {|\n...State,\n|};\ntype FlatListExtraData = {|\n+ modalsClosed: bool,\nkeyboardShowing: bool,\nmessageListVerticalBounds: ?VerticalBounds,\nfocusedMessageKey: ?string,\n@@ -91,6 +94,7 @@ class MessageList extends React.PureComponent<Props, State> {\nimageGalleryOpen: PropTypes.bool.isRequired,\nviewerID: PropTypes.string,\nstartReached: PropTypes.bool.isRequired,\n+ modalsClosed: PropTypes.bool.isRequired,\ndispatchActionPromise: PropTypes.func.isRequired,\nfetchMessagesBeforeCursor: PropTypes.func.isRequired,\nfetchMostRecentMessages: PropTypes.func.isRequired,\n@@ -108,6 +112,7 @@ class MessageList extends React.PureComponent<Props, State> {\nmessageListVerticalBounds: null,\nkeyboardShowing: false,\nflatListExtraData: {\n+ modalsClosed: props.modalsClosed,\nkeyboardShowing: props.imageGalleryOpen,\nmessageListVerticalBounds: null,\nfocusedMessageKey: null,\n@@ -116,16 +121,19 @@ class MessageList extends React.PureComponent<Props, State> {\n}\nstatic flatListExtraDataSelector = createSelector(\n+ (propsAndState: PropsAndState) => propsAndState.modalsClosed,\n(propsAndState: PropsAndState) => propsAndState.keyboardShowing,\n(propsAndState: PropsAndState) => propsAndState.messageListVerticalBounds,\n(propsAndState: PropsAndState) => propsAndState.imageGalleryOpen,\n(propsAndState: PropsAndState) => propsAndState.focusedMessageKey,\n(\n+ modalsClosed: bool,\nkeyboardShowing: bool,\nmessageListVerticalBounds: ?VerticalBounds,\nimageGalleryOpen: bool,\nfocusedMessageKey: ?string,\n) => ({\n+ modalsClosed,\nkeyboardShowing: keyboardShowing || imageGalleryOpen,\nmessageListVerticalBounds,\nfocusedMessageKey,\n@@ -220,6 +228,7 @@ class MessageList extends React.PureComponent<Props, State> {\n}\nconst messageInfoItem: ChatMessageInfoItemWithHeight = row.item;\nconst {\n+ modalsClosed,\nkeyboardShowing,\nmessageListVerticalBounds,\nfocusedMessageKey,\n@@ -235,6 +244,7 @@ class MessageList extends React.PureComponent<Props, State> {\nsetScrollDisabled={this.setScrollDisabled}\nverticalBounds={messageListVerticalBounds}\nkeyboardShowing={keyboardShowing}\n+ modalsClosed={modalsClosed}\n/>\n);\n}\n@@ -406,6 +416,7 @@ export default connect(\nviewerID: state.currentUserInfo && state.currentUserInfo.id,\nstartReached: !!(state.messageStore.threads[threadID] &&\nstate.messageStore.threads[threadID].startReached),\n+ modalsClosed: modalsClosedSelector(state),\n};\n},\n{ fetchMessagesBeforeCursor, fetchMostRecentMessages },\n" }, { "change_type": "MODIFY", "old_path": "native/chat/message.react.js", "new_path": "native/chat/message.react.js", "diff": "@@ -74,6 +74,7 @@ type Props = {|\nsetScrollDisabled: (scrollDisabled: bool) => void,\nverticalBounds: ?VerticalBounds,\nkeyboardShowing: bool,\n+ modalsClosed: bool,\n|};\nclass Message extends React.PureComponent<Props> {\n@@ -85,6 +86,7 @@ class Message extends React.PureComponent<Props> {\nsetScrollDisabled: PropTypes.func.isRequired,\nverticalBounds: verticalBoundsPropType,\nkeyboardShowing: PropTypes.bool.isRequired,\n+ modalsClosed: PropTypes.bool.isRequired,\n};\ncomponentDidUpdate(prevProps: Props) {\n@@ -126,6 +128,7 @@ class Message extends React.PureComponent<Props> {\nverticalBounds={this.props.verticalBounds}\nkeyboardShowing={this.props.keyboardShowing}\nsetScrollDisabled={this.props.setScrollDisabled}\n+ modalsClosed={this.props.modalsClosed}\n/>\n);\n} else {\n" }, { "change_type": "MODIFY", "old_path": "native/chat/multimedia-message.react.js", "new_path": "native/chat/multimedia-message.react.js", "diff": "@@ -13,7 +13,6 @@ import {\ntype VerticalBounds,\nverticalBoundsPropType,\n} from '../types/lightbox-types';\n-import type { AppState } from '../redux/redux-setup';\nimport type { MessagePendingUploads } from './chat-input-state';\nimport * as React from 'react';\n@@ -23,11 +22,9 @@ import invariant from 'invariant';\nimport Animated from 'react-native-reanimated';\nimport { messageKey, messageID } from 'lib/shared/message-utils';\n-import { connect } from 'lib/utils/redux-utils';\nimport ComposedMessage from './composed-message.react';\nimport MultimediaMessageMultimedia from './multimedia-message-multimedia.react';\n-import { modalsClosedSelector } from '../selectors/nav-selectors';\nimport { withLightboxPositionContext } from '../media/lightbox-navigator.react';\nimport {\nallCorners,\n@@ -145,7 +142,6 @@ type Props = {|\nverticalBounds: ?VerticalBounds,\nkeyboardShowing: bool,\nsetScrollDisabled: (scrollDisabled: bool) => void,\n- // Redux state\nmodalsClosed: bool,\n// withLightboxPositionContext\nlightboxPosition: ?Animated.Value,\n@@ -304,14 +300,7 @@ const styles = StyleSheet.create({\n},\n});\n-const WrappedMultimediaMessage =\n- withLightboxPositionContext(\n- connect(\n- (state: AppState) => ({\n- modalsClosed: modalsClosedSelector(state),\n- }),\n- )(MultimediaMessage),\n- );\n+const WrappedMultimediaMessage = withLightboxPositionContext(MultimediaMessage);\nexport {\nborderRadius as multimediaMessageBorderRadius,\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Determine modalsClosed in MessageList Avoids Redux-connecting `MultimediaMessage`
129,187
20.06.2019 16:11:59
14,400
c40b0f57de3dbabe8734045380e8be47e66bf33c
[native] Determine scrollDisabled in MessageList based on modalsClosed
[ { "change_type": "MODIFY", "old_path": "native/chat/message-list.react.js", "new_path": "native/chat/message-list.react.js", "diff": "@@ -214,6 +214,12 @@ class MessageList extends React.PureComponent<Props, State> {\n) {\nthis.loadingFromScroll = false;\n}\n+\n+ if (this.props.modalsClosed && !prevProps.modalsClosed) {\n+ this.setState({ scrollDisabled: false });\n+ } else if (!this.props.modalsClosed && prevProps.modalsClosed) {\n+ this.setState({ scrollDisabled: true });\n+ }\n}\nrenderItem = (row: { item: ChatMessageItemWithHeight }) => {\n" }, { "change_type": "MODIFY", "old_path": "native/chat/message.react.js", "new_path": "native/chat/message.react.js", "diff": "@@ -127,7 +127,6 @@ class Message extends React.PureComponent<Props> {\ntoggleFocus={this.props.toggleFocus}\nverticalBounds={this.props.verticalBounds}\nkeyboardShowing={this.props.keyboardShowing}\n- setScrollDisabled={this.props.setScrollDisabled}\nmodalsClosed={this.props.modalsClosed}\n/>\n);\n" }, { "change_type": "MODIFY", "old_path": "native/chat/multimedia-message-multimedia.react.js", "new_path": "native/chat/multimedia-message-multimedia.react.js", "diff": "@@ -38,7 +38,6 @@ type Props = {|\nkeyboardShowing: bool,\nmessageFocused: bool,\ntoggleMessageFocus: (messageKey: string) => void,\n- setScrollDisabled: (scrollDisabled: bool) => void,\n|};\ntype State = {|\nhidden: bool,\n@@ -57,7 +56,6 @@ class MultimediaMessageMultimedia extends React.PureComponent<Props, State> {\nkeyboardShowing: PropTypes.bool.isRequired,\nmessageFocused: PropTypes.bool.isRequired,\ntoggleMessageFocus: PropTypes.func.isRequired,\n- setScrollDisabled: PropTypes.func.isRequired,\n};\nview: ?View;\n@@ -143,7 +141,6 @@ class MultimediaMessageMultimedia extends React.PureComponent<Props, State> {\nonFocus = () => {\n// TODO\n- this.props.setScrollDisabled(true);\nif (!this.props.messageFocused) {\nthis.props.toggleMessageFocus(this.props.mediaInfo.messageKey);\n}\n@@ -151,7 +148,6 @@ class MultimediaMessageMultimedia extends React.PureComponent<Props, State> {\nonBlur = () => {\n// TODO\n- this.props.setScrollDisabled(false);\nif (this.props.messageFocused) {\nthis.props.toggleMessageFocus(this.props.mediaInfo.messageKey);\n}\n" }, { "change_type": "MODIFY", "old_path": "native/chat/multimedia-message.react.js", "new_path": "native/chat/multimedia-message.react.js", "diff": "@@ -141,7 +141,6 @@ type Props = {|\ntoggleFocus: (messageKey: string) => void,\nverticalBounds: ?VerticalBounds,\nkeyboardShowing: bool,\n- setScrollDisabled: (scrollDisabled: bool) => void,\nmodalsClosed: bool,\n// withLightboxPositionContext\nlightboxPosition: ?Animated.Value,\n@@ -155,7 +154,6 @@ class MultimediaMessage extends React.PureComponent<Props> {\ntoggleFocus: PropTypes.func.isRequired,\nverticalBounds: verticalBoundsPropType,\nkeyboardShowing: PropTypes.bool.isRequired,\n- setScrollDisabled: PropTypes.func.isRequired,\nmodalsClosed: PropTypes.bool.isRequired,\nlightboxPosition: PropTypes.instanceOf(Animated.Value),\n};\n@@ -263,7 +261,6 @@ class MultimediaMessage extends React.PureComponent<Props> {\npostInProgress={!!pendingUploads}\npendingUpload={pendingUpload}\nkeyboardShowing={this.props.keyboardShowing}\n- setScrollDisabled={this.props.setScrollDisabled}\nmessageFocused={this.props.focused}\ntoggleMessageFocus={this.props.toggleFocus}\nkey={index}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Determine scrollDisabled in MessageList based on modalsClosed
129,187
20.06.2019 16:41:44
14,400
187cd55251937b749d0a37fd40b3aa9d718472eb
[native] Fix toggleMessageFocus for MultimediaMessage
[ { "change_type": "MODIFY", "old_path": "native/chat/multimedia-message-multimedia.react.js", "new_path": "native/chat/multimedia-message-multimedia.react.js", "diff": "@@ -139,20 +139,6 @@ class MultimediaMessageMultimedia extends React.PureComponent<Props, State> {\n});\n}\n- onFocus = () => {\n- // TODO\n- if (!this.props.messageFocused) {\n- this.props.toggleMessageFocus(this.props.mediaInfo.messageKey);\n- }\n- }\n-\n- onBlur = () => {\n- // TODO\n- if (this.props.messageFocused) {\n- this.props.toggleMessageFocus(this.props.mediaInfo.messageKey);\n- }\n- }\n-\nonLongPress = () => {\nif (this.props.keyboardShowing) {\nKeyboardUtils.dismiss();\n@@ -162,6 +148,9 @@ class MultimediaMessageMultimedia extends React.PureComponent<Props, State> {\nif (!view || !verticalBounds) {\nreturn;\n}\n+ if (!this.props.messageFocused) {\n+ this.props.toggleMessageFocus(this.props.mediaInfo.messageKey);\n+ }\nview.measure((x, y, width, height, pageX, pageY) => {\nconst coordinates = { x: pageX, y: pageY, width, height };\nconst { mediaInfo, navigate } = this.props;\n" }, { "change_type": "MODIFY", "old_path": "native/chat/multimedia-message.react.js", "new_path": "native/chat/multimedia-message.react.js", "diff": "@@ -158,6 +158,16 @@ class MultimediaMessage extends React.PureComponent<Props> {\nlightboxPosition: PropTypes.instanceOf(Animated.Value),\n};\n+ componentDidUpdate(prevProps: Props) {\n+ if (\n+ this.props.modalsClosed &&\n+ !prevProps.modalsClosed &&\n+ this.props.focused\n+ ) {\n+ this.props.toggleFocus(messageKey(this.props.item.messageInfo));\n+ }\n+ }\n+\nrender() {\nconst heightStyle = { height: this.props.item.contentHeight };\nreturn (\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Fix toggleMessageFocus for MultimediaMessage
129,187
20.06.2019 17:00:36
14,400
72eeabb32bdf5af03f1c9299ffa8a5ce114b953f
[native] Fix Message borderRadius determination
[ { "change_type": "MODIFY", "old_path": "native/chat/rounded-message-container.react.js", "new_path": "native/chat/rounded-message-container.react.js", "diff": "@@ -17,10 +17,10 @@ function filterCorners(\nconst { isViewer } = item.messageInfo.creator;\nconst { topLeft, topRight, bottomLeft, bottomRight } = corners;\nreturn {\n- topLeft: topLeft && !isViewer && !startsCluster,\n- topRight: topRight && isViewer && !startsCluster,\n- bottomLeft: bottomLeft && !isViewer && !endsCluster,\n- bottomRight: bottomRight && isViewer && !endsCluster,\n+ topLeft: topLeft && (isViewer || startsCluster),\n+ topRight: topRight && (!isViewer || startsCluster),\n+ bottomLeft: bottomLeft && (isViewer || endsCluster),\n+ bottomRight: bottomRight && (!isViewer || endsCluster),\n};\n}\n@@ -36,10 +36,10 @@ function getRoundedContainerStyle(\n) {\nconst { topLeft, topRight, bottomLeft, bottomRight } = corners;\nreturn {\n- borderTopLeftRadius: topLeft ? 0 : borderRadius,\n- borderTopRightRadius: topRight ? 0 : borderRadius,\n- borderBottomLeftRadius: bottomLeft ? 0 : borderRadius,\n- borderBottomRightRadius: bottomRight ? 0 : borderRadius,\n+ borderTopLeftRadius: topLeft ? borderRadius : 0,\n+ borderTopRightRadius: topRight ? borderRadius : 0,\n+ borderBottomLeftRadius: bottomLeft ? borderRadius : 0,\n+ borderBottomRightRadius: bottomRight ? borderRadius : 0,\n};\n}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Fix Message borderRadius determination
129,187
20.06.2019 17:00:58
14,400
e2189333184bab6962044363f60937350c06dd53
[native] Extract Timestamp out of Message
[ { "change_type": "MODIFY", "old_path": "native/chat/message.react.js", "new_path": "native/chat/message.react.js", "diff": "@@ -18,21 +18,14 @@ import {\nimport * as React from 'react';\nimport {\n- Text,\n- StyleSheet,\nView,\nLayoutAnimation,\nTouchableWithoutFeedback,\nPlatform,\n} from 'react-native';\n-import _isEqual from 'lodash/fp/isEqual';\n-import invariant from 'invariant';\nimport PropTypes from 'prop-types';\nimport { KeyboardUtils } from 'react-native-keyboard-input';\n-import { longAbsoluteDate } from 'lib/utils/date-utils';\n-import { threadInfoSelector } from 'lib/selectors/thread-selectors';\n-\nimport { TextMessage, textMessageItemHeight } from './text-message.react';\nimport {\nRobotextMessage,\n@@ -42,6 +35,7 @@ import {\nMultimediaMessage,\nmultimediaMessageItemHeight,\n} from './multimedia-message.react';\n+import Timestamp from './timestamp.react';\nexport type ChatMessageInfoItemWithHeight =\n| ChatRobotextMessageInfoItemWithHeight\n@@ -102,9 +96,7 @@ class Message extends React.PureComponent<Props> {\nlet conversationHeader = null;\nif (this.props.focused || this.props.item.startsConversation) {\nconversationHeader = (\n- <Text style={styles.conversationHeader}>\n- {longAbsoluteDate(this.props.item.messageInfo.time).toUpperCase()}\n- </Text>\n+ <Timestamp time={this.props.item.messageInfo.time} />\n);\n}\nlet message;\n@@ -159,17 +151,6 @@ class Message extends React.PureComponent<Props> {\n}\n-const styles = StyleSheet.create({\n- conversationHeader: {\n- color: '#777777',\n- fontSize: 14,\n- paddingTop: 1,\n- paddingBottom: 7,\n- alignSelf: 'center',\n- height: 26,\n- },\n-});\n-\nexport {\nMessage,\nmessageItemHeight,\n" }, { "change_type": "ADD", "old_path": null, "new_path": "native/chat/timestamp.react.js", "diff": "+// @flow\n+\n+import * as React from 'react';\n+import {\n+ Text,\n+ StyleSheet,\n+} from 'react-native';\n+\n+import { longAbsoluteDate } from 'lib/utils/date-utils';\n+\n+type Props = {|\n+ time: number,\n+|};\n+function Timestamp(props: Props) {\n+ return (\n+ <Text style={styles.conversationHeader} numberOfLines={1}>\n+ {longAbsoluteDate(props.time).toUpperCase()}\n+ </Text>\n+ );\n+}\n+\n+const styles = StyleSheet.create({\n+ conversationHeader: {\n+ color: '#777777',\n+ fontSize: 14,\n+ paddingTop: 1,\n+ paddingBottom: 7,\n+ alignSelf: 'center',\n+ height: 26,\n+ },\n+});\n+\n+export default Timestamp;\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Extract Timestamp out of Message
129,187
20.06.2019 17:23:47
14,400
5a14dc882f9eda4e470c8085c839c2afe7bf7950
[native] Show light-colored timestamp in MultimediaTooltipButton
[ { "change_type": "MODIFY", "old_path": "native/chat/message.react.js", "new_path": "native/chat/message.react.js", "diff": "@@ -96,7 +96,7 @@ class Message extends React.PureComponent<Props> {\nlet conversationHeader = null;\nif (this.props.focused || this.props.item.startsConversation) {\nconversationHeader = (\n- <Timestamp time={this.props.item.messageInfo.time} />\n+ <Timestamp time={this.props.item.messageInfo.time} color=\"dark\" />\n);\n}\nlet message;\n" }, { "change_type": "MODIFY", "old_path": "native/chat/multimedia-tooltip-button.react.js", "new_path": "native/chat/multimedia-tooltip-button.react.js", "diff": "// @flow\n-import { type MediaInfo, mediaInfoPropType } from 'lib/types/media-types';\n+import {\n+ type MediaInfo,\n+ mediaInfoPropType,\n+ type Dimensions,\n+ dimensionsPropType,\n+} from 'lib/types/media-types';\nimport {\ntype VerticalBounds,\nverticalBoundsPropType,\n@@ -11,9 +16,14 @@ import type {\nNavigationScreenProp,\nNavigationLeafRoute,\n} from 'react-navigation';\n+import type { RawMessageInfo } from 'lib/types/message-types';\n+import type { AppState } from '../redux/redux-setup';\nimport * as React from 'react';\nimport PropTypes from 'prop-types';\n+import { View } from 'react-native';\n+\n+import { connect } from 'lib/utils/redux-utils';\nimport {\ntype ChatInputState,\n@@ -23,6 +33,8 @@ import {\nimport InlineMultimedia from './inline-multimedia.react';\nimport { multimediaMessageBorderRadius } from './multimedia-message.react';\nimport { getRoundedContainerStyle } from './rounded-message-container.react';\n+import Timestamp from './timestamp.react';\n+import { dimensionsSelector } from '../selectors/dimension-selectors';\ntype NavProp = NavigationScreenProp<{|\n...NavigationLeafRoute,\n@@ -35,6 +47,9 @@ type NavProp = NavigationScreenProp<{|\ntype Props = {\nnavigation: NavProp,\n+ // Redux state\n+ rawMessageInfo: ?RawMessageInfo,\n+ screenDimensions: Dimensions,\n// withChatInputState\nchatInputState: ?ChatInputState,\n};\n@@ -51,9 +66,21 @@ class MultimediaTooltipButton extends React.PureComponent<Props> {\n}).isRequired,\ngoBack: PropTypes.func.isRequired,\n}).isRequired,\n+ rawMessageInfo: PropTypes.object,\n+ screenDimensions: dimensionsPropType.isRequired,\nchatInputState: chatInputStatePropType,\n};\n+ get timestampStyle() {\n+ const { initialCoordinates } = this.props.navigation.state.params;\n+ return {\n+ position: 'absolute',\n+ left: -initialCoordinates.x,\n+ width: this.props.screenDimensions.width,\n+ top: -26,\n+ };\n+ }\n+\nrender() {\nconst { chatInputState } = this.props;\nconst { mediaInfo } = this.props.navigation.state.params;\n@@ -70,7 +97,19 @@ class MultimediaTooltipButton extends React.PureComponent<Props> {\nmultimediaMessageBorderRadius,\n);\n+ let timestamp = null;\n+ if (this.props.rawMessageInfo) {\n+ const { time } = this.props.rawMessageInfo;\n+ timestamp = (\n+ <View style={this.timestampStyle}>\n+ <Timestamp time={time} color=\"light\" />\n+ </View>\n+ );\n+ }\n+\nreturn (\n+ <React.Fragment>\n+ {timestamp}\n<InlineMultimedia\nmediaInfo={mediaInfo}\nstyle={roundedStyle}\n@@ -79,6 +118,7 @@ class MultimediaTooltipButton extends React.PureComponent<Props> {\npostInProgress={postInProgress}\npendingUpload={pendingUpload}\n/>\n+ </React.Fragment>\n);\n}\n@@ -88,4 +128,13 @@ class MultimediaTooltipButton extends React.PureComponent<Props> {\n}\n-export default withChatInputState(MultimediaTooltipButton);\n+export default connect(\n+ (state: AppState, ownProps: { navigation: NavProp }) => {\n+ const { messageID } = ownProps.navigation.state.params.mediaInfo;\n+ const rawMessageInfo = state.messageStore.messages[messageID];\n+ return {\n+ rawMessageInfo,\n+ screenDimensions: dimensionsSelector(state),\n+ };\n+ },\n+)(withChatInputState(MultimediaTooltipButton));\n" }, { "change_type": "MODIFY", "old_path": "native/chat/timestamp.react.js", "new_path": "native/chat/timestamp.react.js", "diff": "@@ -10,24 +10,33 @@ import { longAbsoluteDate } from 'lib/utils/date-utils';\ntype Props = {|\ntime: number,\n+ color: 'light' | 'dark',\n|};\nfunction Timestamp(props: Props) {\n+ const style = props.color === 'light'\n+ ? [ styles.timestamp, styles.light ]\n+ : [ styles.timestamp, styles.dark ];\nreturn (\n- <Text style={styles.conversationHeader} numberOfLines={1}>\n+ <Text style={style} numberOfLines={1}>\n{longAbsoluteDate(props.time).toUpperCase()}\n</Text>\n);\n}\nconst styles = StyleSheet.create({\n- conversationHeader: {\n- color: '#777777',\n+ timestamp: {\nfontSize: 14,\npaddingTop: 1,\npaddingBottom: 7,\nalignSelf: 'center',\nheight: 26,\n},\n+ dark: {\n+ color: '#777777',\n+ },\n+ light: {\n+ color: 'white',\n+ },\n});\nexport default Timestamp;\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Show light-colored timestamp in MultimediaTooltipButton
129,187
20.06.2019 18:16:36
14,400
9889fab200f825b2d93c20fc63826605e1c99e0f
[native] Animate Tooltip opacity
[ { "change_type": "MODIFY", "old_path": "native/components/tooltip2.react.js", "new_path": "native/components/tooltip2.react.js", "diff": "@@ -29,6 +29,8 @@ import {\nconst {\nValue,\n+ Extrapolate,\n+ interpolate,\n} = Animated;\ntype TooltipEntry<CustomProps> = {|\n@@ -84,6 +86,29 @@ function createTooltip<\nposition: PropTypes.instanceOf(Value).isRequired,\nscreenDimensions: dimensionsPropType.isRequired,\n};\n+ tooltipOpacity: Value;\n+\n+ constructor(props: TooltipPropsType) {\n+ super(props);\n+\n+ const { position } = props;\n+ const { index } = props.scene;\n+ this.tooltipOpacity = interpolate(\n+ position,\n+ {\n+ inputRange: [ index - 1, index ],\n+ outputRange: [ 0, 1 ],\n+ extrapolate: Extrapolate.CLAMP,\n+ },\n+ );\n+ }\n+\n+ get opacityStyle() {\n+ return {\n+ flex: 1,\n+ opacity: this.tooltipOpacity,\n+ };\n+ }\nget contentContainerStyle() {\nconst { verticalBounds } = this.props.navigation.state.params;\n@@ -112,6 +137,7 @@ function createTooltip<\nconst { navigation } = this.props;\nreturn (\n<TouchableWithoutFeedback onPress={this.onPressBackdrop}>\n+ <Animated.View style={this.opacityStyle}>\n<View style={styles.backdrop}>\n<View style={this.contentContainerStyle}>\n<View style={this.buttonStyle}>\n@@ -119,6 +145,7 @@ function createTooltip<\n</View>\n</View>\n</View>\n+ </Animated.View>\n</TouchableWithoutFeedback>\n);\n}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Animate Tooltip opacity
129,187
10.07.2019 12:04:19
14,400
72745011d41e6f918ba6f8ecf95b828b39a33865
[native] Include imageHeight in ChatMultimediaMessageInfoItem
[ { "change_type": "MODIFY", "old_path": "native/chat/message-list-container.react.js", "new_path": "native/chat/message-list-container.react.js", "diff": "@@ -40,7 +40,7 @@ import ThreadSettingsButton from './thread-settings-button.react';\nimport { registerChatScreen } from './chat-screen-registry';\nimport TextHeightMeasurer from '../text-height-measurer.react';\nimport ChatInputBar from './chat-input-bar.react';\n-import { multimediaMessageContentHeight } from './multimedia-message.react';\n+import { multimediaMessageContentHeights } from './multimedia-message.react';\nimport {\ntextMessageMaxWidthSelector,\ncomposedMessageMaxWidthSelector,\n@@ -290,6 +290,10 @@ class MessageListContainer extends React.PureComponent<Props, State> {\nconst pendingUploads = chatInputState\n&& chatInputState.pendingUploads\n&& chatInputState.pendingUploads[id];\n+ const heights = multimediaMessageContentHeights(\n+ messageInfo,\n+ this.props.composedMessageMaxWidth,\n+ );\nreturn {\nitemType: \"message\",\nmessageShapeType: \"multimedia\",\n@@ -300,10 +304,7 @@ class MessageListContainer extends React.PureComponent<Props, State> {\nstartsCluster: item.startsCluster,\nendsCluster: item.endsCluster,\npendingUploads,\n- contentHeight: multimediaMessageContentHeight(\n- messageInfo,\n- this.props.composedMessageMaxWidth,\n- ),\n+ ...heights,\n};\n}\ninvariant(textHeights, \"textHeights not set\");\n" }, { "change_type": "MODIFY", "old_path": "native/chat/multimedia-message.react.js", "new_path": "native/chat/multimedia-message.react.js", "diff": "@@ -32,7 +32,12 @@ import {\ngetRoundedContainerStyle,\n} from './rounded-message-container.react';\n+type ContentHeights = {|\n+ imageHeight: number,\n+ contentHeight: number,\n+|};\nexport type ChatMultimediaMessageInfoItem = {|\n+ ...ContentHeights,\nitemType: \"message\",\nmessageShapeType: \"multimedia\",\nmessageInfo: MultimediaMessageInfo,\n@@ -42,7 +47,6 @@ export type ChatMultimediaMessageInfoItem = {|\nstartsCluster: bool,\nendsCluster: bool,\npendingUploads: ?MessagePendingUploads,\n- contentHeight: number,\n|};\nfunction getMediaPerRow(mediaCount: number) {\n@@ -61,10 +65,12 @@ function getMediaPerRow(mediaCount: number) {\n}\n}\n-function multimediaMessageContentHeight(\n+// Called by MessageListContainer\n+// The results are merged into ChatMultimediaMessageInfoItem\n+function multimediaMessageContentHeights(\nmessageInfo: MultimediaMessageInfo,\ncomposedMessageMaxWidth: number,\n-): number {\n+): ContentHeights {\ninvariant(messageInfo.media.length > 0, \"should have media\");\nif (messageInfo.media.length === 1) {\nconst [ media ] = messageInfo.media;\n@@ -75,7 +81,7 @@ function multimediaMessageContentHeight(\nif (imageHeight < 50) {\nimageHeight = 50;\n}\n- return imageHeight;\n+ return { imageHeight, contentHeight: imageHeight };\n}\nconst mediaPerRow = getMediaPerRow(messageInfo.media.length);\n@@ -83,7 +89,10 @@ function multimediaMessageContentHeight(\nconst imageHeight = (composedMessageMaxWidth - marginSpace) / mediaPerRow;\nconst numRows = Math.ceil(messageInfo.media.length / mediaPerRow);\n- return numRows * imageHeight + (numRows - 1) * spaceBetweenImages;\n+ const contentHeight = numRows * imageHeight\n+ + (numRows - 1) * spaceBetweenImages;\n+\n+ return { imageHeight, contentHeight };\n}\nfunction sendFailed(item: ChatMultimediaMessageInfoItem) {\n@@ -112,6 +121,8 @@ function sendFailed(item: ChatMultimediaMessageInfoItem) {\nreturn !pendingUploads;\n}\n+// Called by Message\n+// Given a ChatMultimediaMessageInfoItem, determines exact height of row\nfunction multimediaMessageItemHeight(\nitem: ChatMultimediaMessageInfoItem,\nviewerID: ?string,\n@@ -312,6 +323,6 @@ const WrappedMultimediaMessage = withLightboxPositionContext(MultimediaMessage);\nexport {\nborderRadius as multimediaMessageBorderRadius,\nWrappedMultimediaMessage as MultimediaMessage,\n- multimediaMessageContentHeight,\n+ multimediaMessageContentHeights,\nmultimediaMessageItemHeight,\n};\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Include imageHeight in ChatMultimediaMessageInfoItem
129,187
10.07.2019 12:04:51
14,400
9f704ed0aa49cc8a2692acbd09431826d2bf7334
[native] Position Timestamp in MultimediaTooltipButton correctly Uses `verticalOffset` determined in `MultimediaMessage`
[ { "change_type": "MODIFY", "old_path": "native/chat/multimedia-message-multimedia.react.js", "new_path": "native/chat/multimedia-message-multimedia.react.js", "diff": "@@ -30,6 +30,7 @@ type Props = {|\nmediaInfo: MediaInfo,\nnavigate: Navigate,\nverticalBounds: ?VerticalBounds,\n+ verticalOffset: number,\nstyle: ImageStyle,\nmodalsClosed: bool,\nlightboxPosition: ?Animated.Value,\n@@ -49,6 +50,7 @@ class MultimediaMessageMultimedia extends React.PureComponent<Props, State> {\nmediaInfo: mediaInfoPropType.isRequired,\nnavigate: PropTypes.func.isRequired,\nverticalBounds: verticalBoundsPropType,\n+ verticalOffset: PropTypes.number.isRequired,\nmodalsClosed: PropTypes.bool.isRequired,\nlightboxPosition: PropTypes.instanceOf(Animated.Value),\npostInProgress: PropTypes.bool.isRequired,\n@@ -144,7 +146,7 @@ class MultimediaMessageMultimedia extends React.PureComponent<Props, State> {\nKeyboardUtils.dismiss();\nreturn;\n}\n- const { view, props: { verticalBounds } } = this;\n+ const { view, props: { verticalBounds, verticalOffset } } = this;\nif (!view || !verticalBounds) {\nreturn;\n}\n@@ -156,7 +158,12 @@ class MultimediaMessageMultimedia extends React.PureComponent<Props, State> {\nconst { mediaInfo, navigate } = this.props;\nnavigate({\nrouteName: MultimediaTooltipModalRouteName,\n- params: { mediaInfo, initialCoordinates: coordinates, verticalBounds },\n+ params: {\n+ mediaInfo,\n+ initialCoordinates: coordinates,\n+ verticalOffset,\n+ verticalBounds,\n+ },\n});\n});\n}\n" }, { "change_type": "MODIFY", "old_path": "native/chat/multimedia-message.react.js", "new_path": "native/chat/multimedia-message.react.js", "diff": "@@ -196,21 +196,28 @@ class MultimediaMessage extends React.PureComponent<Props> {\n}\nrenderContent(): React.Node {\n- const { messageInfo } = this.props.item;\n+ const { messageInfo, imageHeight } = this.props.item;\ninvariant(messageInfo.media.length > 0, \"should have media\");\nif (messageInfo.media.length === 1) {\nreturn this.renderImage(\nmessageInfo.media[0],\n0,\n+ 0,\nallCorners,\n);\n}\nconst mediaPerRow = getMediaPerRow(messageInfo.media.length);\nconst numRows = Math.ceil(messageInfo.media.length / mediaPerRow);\n+ const rowHeight = imageHeight + spaceBetweenImages;\nconst rows = [];\n- for (let i = 0; i < messageInfo.media.length; i += mediaPerRow) {\n+ let verticalOffset = 0;\n+ for (\n+ let i = 0, verticalOffset = 0;\n+ i < messageInfo.media.length;\n+ i += mediaPerRow, verticalOffset += rowHeight\n+ ) {\nconst rowMedia = messageInfo.media.slice(i, i + mediaPerRow);\nconst firstRow = i === 0;\nconst lastRow = i + mediaPerRow >= messageInfo.media.length;\n@@ -229,7 +236,13 @@ class MultimediaMessage extends React.PureComponent<Props> {\nbottomRight: lastRow && inLastColumn,\n};\nconst style = lastInRow ? null : styles.imageBeforeImage;\n- row.push(this.renderImage(media, i + j, corners, style));\n+ row.push(this.renderImage(\n+ media,\n+ i + j,\n+ verticalOffset,\n+ corners,\n+ style,\n+ ));\n}\nfor (; j < mediaPerRow; j++) {\nconst key = `filler${j}`;\n@@ -254,6 +267,7 @@ class MultimediaMessage extends React.PureComponent<Props> {\nrenderImage(\nmedia: Media,\nindex: number,\n+ verticalOffset: number,\ncorners: Corners,\nstyle?: ImageStyle,\n): React.Node {\n@@ -276,6 +290,7 @@ class MultimediaMessage extends React.PureComponent<Props> {\nmediaInfo={mediaInfo}\nnavigate={this.props.navigate}\nverticalBounds={this.props.verticalBounds}\n+ verticalOffset={verticalOffset}\nstyle={[ style, roundedStyle ]}\nmodalsClosed={this.props.modalsClosed}\nlightboxPosition={this.props.lightboxPosition}\n" }, { "change_type": "MODIFY", "old_path": "native/chat/multimedia-tooltip-button.react.js", "new_path": "native/chat/multimedia-tooltip-button.react.js", "diff": "@@ -42,6 +42,7 @@ type NavProp = NavigationScreenProp<{|\nmediaInfo: MediaInfo,\ninitialCoordinates: LayoutCoordinates,\nverticalBounds: VerticalBounds,\n+ verticalOffset: number,\n},\n|}>;\n@@ -62,6 +63,7 @@ class MultimediaTooltipButton extends React.PureComponent<Props> {\nmediaInfo: mediaInfoPropType.isRequired,\ninitialCoordinates: layoutCoordinatesPropType.isRequired,\nverticalBounds: verticalBoundsPropType.isRequired,\n+ verticalOffset: PropTypes.number.isRequired,\n}).isRequired,\n}).isRequired,\ngoBack: PropTypes.func.isRequired,\n@@ -72,12 +74,13 @@ class MultimediaTooltipButton extends React.PureComponent<Props> {\n};\nget timestampStyle() {\n- const { initialCoordinates } = this.props.navigation.state.params;\n+ const { initialCoordinates, verticalOffset } = this.props.navigation.state.params;\n+ const top = -26 - verticalOffset;\nreturn {\nposition: 'absolute',\nleft: -initialCoordinates.x,\nwidth: this.props.screenDimensions.width,\n- top: -26,\n+ top,\n};\n}\n" }, { "change_type": "MODIFY", "old_path": "native/chat/multimedia-tooltip-modal.react.js", "new_path": "native/chat/multimedia-tooltip-modal.react.js", "diff": "@@ -9,6 +9,7 @@ import { saveImage } from '../media/save-image';\ntype CustomProps = {\nmediaInfo: MediaInfo,\n+ verticalOffset: number,\n};\nfunction onPressSave(props: CustomProps) {\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Position Timestamp in MultimediaTooltipButton correctly Uses `verticalOffset` determined in `MultimediaMessage`
129,187
10.07.2019 12:14:32
14,400
c8179b2ab0f0afdadb1431afa469930734ca59f5
[native] Avoid simultaneous MultimediaModal and MultimediaTooltipModal
[ { "change_type": "MODIFY", "old_path": "native/chat/multimedia-message-multimedia.react.js", "new_path": "native/chat/multimedia-message-multimedia.react.js", "diff": "@@ -60,6 +60,7 @@ class MultimediaMessageMultimedia extends React.PureComponent<Props, State> {\ntoggleMessageFocus: PropTypes.func.isRequired,\n};\nview: ?View;\n+ clickable = true;\nconstructor(props: Props) {\nsuper(props);\n@@ -92,10 +93,13 @@ class MultimediaMessageMultimedia extends React.PureComponent<Props, State> {\n}\ncomponentDidUpdate(prevProps: Props) {\n- const { lightboxPosition } = this.props;\n- if (lightboxPosition !== prevProps.lightboxPosition) {\n+ if (this.props.lightboxPosition !== prevProps.lightboxPosition) {\nthis.setState({ opacity: this.getOpacity() });\n}\n+\n+ if (this.props.modalsClosed && !prevProps.modalsClosed) {\n+ this.clickable = true;\n+ }\n}\nrender() {\n@@ -130,6 +134,12 @@ class MultimediaMessageMultimedia extends React.PureComponent<Props, State> {\nif (!view || !verticalBounds) {\nreturn;\n}\n+\n+ if (!this.clickable) {\n+ return;\n+ }\n+ this.clickable = false;\n+\nview.measure((x, y, width, height, pageX, pageY) => {\nconst coordinates = { x: pageX, y: pageY, width, height };\nconst { mediaInfo, navigate } = this.props;\n@@ -146,13 +156,21 @@ class MultimediaMessageMultimedia extends React.PureComponent<Props, State> {\nKeyboardUtils.dismiss();\nreturn;\n}\n+\nconst { view, props: { verticalBounds, verticalOffset } } = this;\nif (!view || !verticalBounds) {\nreturn;\n}\n+\n+ if (!this.clickable) {\n+ return;\n+ }\n+ this.clickable = false;\n+\nif (!this.props.messageFocused) {\nthis.props.toggleMessageFocus(this.props.mediaInfo.messageKey);\n}\n+\nview.measure((x, y, width, height, pageX, pageY) => {\nconst coordinates = { x: pageX, y: pageY, width, height };\nconst { mediaInfo, navigate } = this.props;\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Avoid simultaneous MultimediaModal and MultimediaTooltipModal
129,187
10.07.2019 12:18:19
14,400
a289463930bb0c30832cff2c8cdce217df46a6a7
[server] Include localID in RawMultimediaMessageInfo passed from server This allows the client to dedup properly in certain failure cases
[ { "change_type": "MODIFY", "old_path": "server/src/fetchers/message-fetchers.js", "new_path": "server/src/fetchers/message-fetchers.js", "diff": "@@ -13,6 +13,7 @@ import {\ntype MessageTruncationStatuses,\ntype FetchMessageInfosResult,\ntype RawTextMessageInfo,\n+ type RawMultimediaMessageInfo,\n} from 'lib/types/message-types';\nimport { threadPermissions } from 'lib/types/thread-types';\nimport type { Viewer } from '../session/viewer';\n@@ -380,7 +381,7 @@ function rawMessageInfoFromRows(\n});\n}\nconst [ row ] = rows;\n- return {\n+ const rawMultimediaMessageInfo: RawMultimediaMessageInfo = {\ntype: messageTypes.MULTIMEDIA,\nid: row.id.toString(),\nthreadID: row.threadID.toString(),\n@@ -388,6 +389,11 @@ function rawMessageInfoFromRows(\ncreatorID: row.creatorID.toString(),\nmedia,\n};\n+ const localID = localIDFromCreationString(viewer, row.creation);\n+ if (localID) {\n+ rawMultimediaMessageInfo.localID = localID;\n+ }\n+ return rawMultimediaMessageInfo;\n} else {\ninvariant(false, `unrecognized messageType ${type}`);\n}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[server] Include localID in RawMultimediaMessageInfo passed from server This allows the client to dedup properly in certain failure cases
129,187
10.07.2019 12:51:38
14,400
d6bad969c889bff56c1e5412a22805ff5ead341f
[server] Include localID whenever possible when returning messages
[ { "change_type": "MODIFY", "old_path": "server/src/fetchers/message-fetchers.js", "new_path": "server/src/fetchers/message-fetchers.js", "diff": "@@ -150,6 +150,7 @@ type MessageSQLResult = {|\n|};\nfunction parseMessageSQLResult(\nrows: $ReadOnlyArray<Object>,\n+ viewer?: Viewer,\n): MessageSQLResult {\nconst userInfos = {}, rowsByID = new Map();\nfor (let row of rows) {\n@@ -169,7 +170,7 @@ function parseMessageSQLResult(\nconst messages = [];\nfor (let messageRows of rowsByID.values()) {\n- const rawMessageInfo = rawMessageInfoFromRows(messageRows);\n+ const rawMessageInfo = rawMessageInfoFromRows(messageRows, viewer);\nif (rawMessageInfo) {\nmessages.push({ rawMessageInfo, rows: messageRows });\n}\n@@ -203,7 +204,7 @@ function mostRecentRowType(\nfunction rawMessageInfoFromRows(\nrows: $ReadOnlyArray<Object>,\n- viewer?: Viewer,\n+ viewer?: ?Viewer,\n): ?RawMessageInfo {\nconst type = mostRecentRowType(rows);\nif (type === messageTypes.TEXT) {\n@@ -447,7 +448,7 @@ async function fetchMessageInfos(\n`);\nconst [ result ] = await dbQuery(query);\n- const { userInfos, messages } = parseMessageSQLResult(result);\n+ const { userInfos, messages } = parseMessageSQLResult(result, viewer);\nconst rawMessageInfos = [];\nconst threadToMessageCount = new Map();\n@@ -609,7 +610,7 @@ async function fetchMessageInfosSince(\nconst {\nuserInfos: allCreatorUserInfos,\nmessages,\n- } = parseMessageSQLResult(result);\n+ } = parseMessageSQLResult(result, viewer);\nconst rawMessageInfos = [];\nconst userInfos = {};\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[server] Include localID whenever possible when returning messages
129,187
10.07.2019 12:51:57
14,400
62146e129deab79e5dae8c19275e8f60f5ba6a85
[lib] Merge RawMultimediaMessageInfos with same localID
[ { "change_type": "MODIFY", "old_path": "lib/reducers/message-reducer.js", "new_path": "lib/reducers/message-reducer.js", "diff": "@@ -161,7 +161,10 @@ function mergeNewMessages(\nconst { id: inputID } = messageInfo;\ninvariant(inputID, \"new messageInfos should have serverID\");\nconst currentMessageInfo = oldMessageStore.messages[inputID];\n- if (messageInfo.type === messageTypes.TEXT) {\n+ if (\n+ messageInfo.type === messageTypes.TEXT ||\n+ messageInfo.type === messageTypes.MULTIMEDIA\n+ ) {\nconst { localID: inputLocalID } = messageInfo;\nconst currentLocalMessageInfo = inputLocalID\n? oldMessageStore.messages[inputLocalID]\n@@ -171,10 +174,18 @@ function mergeNewMessages(\n// any localID associated with the existing one. This is because we\n// use localIDs as React keys and changing React keys leads to loss of\n// component state.\n+ if (messageInfo.type === messageTypes.TEXT) {\n+ messageInfo = {\n+ ...messageInfo,\n+ localID: currentMessageInfo.localID,\n+ };\n+ } else {\n+ // This conditional is for Flow\nmessageInfo = {\n...messageInfo,\nlocalID: currentMessageInfo.localID,\n};\n+ }\n} else if (currentLocalMessageInfo && currentLocalMessageInfo.localID) {\n// If the client has a RawMessageInfo with this localID, but not with\n// the serverID, that means the message creation succeeded but the\n@@ -183,16 +194,27 @@ function mergeNewMessages(\n// MessageStore too.\ninvariant(inputLocalID, \"should be set\");\nlocalIDsToServerIDs.set(inputLocalID, inputID);\n+ if (messageInfo.type === messageTypes.TEXT) {\n+ messageInfo = {\n+ ...messageInfo,\n+ localID: currentLocalMessageInfo.localID,\n+ };\n+ } else {\nmessageInfo = {\n...messageInfo,\nlocalID: currentLocalMessageInfo.localID,\n};\n+ }\n} else {\n// If neither the serverID nor the localID from the delivered\n// RawMessageInfo exists in the client store, then this message is\n// brand new to us. Ignore any localID provided by the server.\nconst { localID, ...rest } = messageInfo;\n+ if (rest.type === messageTypes.TEXT) {\nmessageInfo = { ...rest };\n+ } else {\n+ messageInfo = { ...rest };\n+ }\n}\n}\nreturn _isEqual(messageInfo)(currentMessageInfo)\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[lib] Merge RawMultimediaMessageInfos with same localID
129,187
10.07.2019 17:48:23
14,400
ff3b5afde95b17b0da194437b5783ff897109bfc
Update time on MultimediaMessage whenever retrying it
[ { "change_type": "MODIFY", "old_path": "native/chat/chat-input-state-container.react.js", "new_path": "native/chat/chat-input-state-container.react.js", "diff": "@@ -454,12 +454,12 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\nrawMessageInfo && rawMessageInfo.type === messageTypes.MULTIMEDIA,\n\"messageStore should contain entry for message being retried\",\n);\n+ const newRawMessageInfo = { ...rawMessageInfo, time: Date.now() };\nconst incompleteMedia = rawMessageInfo.media.filter(\n({ id }) => id.startsWith('localUpload'),\n);\nif (incompleteMedia.length === 0) {\n- const newRawMessageInfo = { ...rawMessageInfo, time: Date.now() };\nthis.dispatchMultimediaMessageAction(newRawMessageInfo);\nthis.setState(prevState => ({\npendingUploads: {\n@@ -483,6 +483,13 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\nreturn;\n}\n+ // We're not actually starting the send here,\n+ // we just use this action to update the message's timestamp in Redux\n+ this.props.dispatchActionPayload(\n+ sendMultimediaMessageActionTypes.started,\n+ newRawMessageInfo,\n+ );\n+\nconst imageGalleryImages = retryMedia.map(\n({ dimensions, uri }) => ({ ...dimensions, uri }),\n);\n" }, { "change_type": "MODIFY", "old_path": "web/chat/chat-input-state-container.react.js", "new_path": "web/chat/chat-input-state-container.react.js", "diff": "@@ -693,10 +693,11 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\nlocalMessageID: string,\npendingUploads: ?$ReadOnlyArray<PendingMultimediaUpload>,\n) {\n- const completed = ChatInputStateContainer.completedMessageIDs(this.state);\n- if (completed.has(localMessageID)) {\nconst rawMessageInfo = this.getRawMultimediaMessageInfo(localMessageID);\nconst newRawMessageInfo = { ...rawMessageInfo, time: Date.now() };\n+\n+ const completed = ChatInputStateContainer.completedMessageIDs(this.state);\n+ if (completed.has(localMessageID)) {\nthis.sendMultimediaMessage(newRawMessageInfo);\nreturn;\n}\n@@ -705,6 +706,13 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\nreturn;\n}\n+ // We're not actually starting the send here,\n+ // we just use this action to update the message's timestamp in Redux\n+ this.props.dispatchActionPayload(\n+ sendMultimediaMessageActionTypes.started,\n+ newRawMessageInfo,\n+ );\n+\nconst uploadIDsToRetry = new Set();\nconst uploadsToRetry = [];\nfor (let pendingUpload of pendingUploads) {\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Update time on MultimediaMessage whenever retrying it
129,187
10.07.2019 19:55:06
14,400
760086ee7681b775a54dabd2d0701d3cf94bc31c
[native] Fix Multimedia layout measuring on Android
[ { "change_type": "MODIFY", "old_path": "native/chat/multimedia-message-multimedia.react.js", "new_path": "native/chat/multimedia-message-multimedia.react.js", "diff": "@@ -111,7 +111,7 @@ class MultimediaMessageMultimedia extends React.PureComponent<Props, State> {\nconst { mediaInfo, pendingUpload, style, postInProgress } = this.props;\nreturn (\n<Animated.View style={wrapperStyles}>\n- <View style={styles.expand} ref={this.viewRef}>\n+ <View style={styles.expand} onLayout={this.onLayout} ref={this.viewRef}>\n<InlineMultimedia\nmediaInfo={this.props.mediaInfo}\nstyle={this.props.style}\n@@ -125,6 +125,8 @@ class MultimediaMessageMultimedia extends React.PureComponent<Props, State> {\n);\n}\n+ onLayout = () => {}\n+\nviewRef = (view: ?View) => {\nthis.view = view;\n}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Fix Multimedia layout measuring on Android
129,187
10.07.2019 20:00:00
14,400
4db968ed1893f89f1ee269f44a5077e3e2dc9b0d
[native] Avoid including padding in Multimedia layout measuring
[ { "change_type": "MODIFY", "old_path": "native/chat/inline-multimedia.react.js", "new_path": "native/chat/inline-multimedia.react.js", "diff": "@@ -17,7 +17,6 @@ import Multimedia from '../media/multimedia.react';\ntype Props = {|\nmediaInfo: MediaInfo,\n- style: ImageStyle,\nonPress: () => void,\nonLongPress: () => void,\npostInProgress: bool,\n@@ -34,7 +33,7 @@ class InlineMultimedia extends React.PureComponent<Props> {\n};\nrender() {\n- const { mediaInfo, pendingUpload, style, postInProgress } = this.props;\n+ const { mediaInfo, pendingUpload, postInProgress } = this.props;\nlet failed = mediaInfo.id.startsWith('localUpload') && !postInProgress;\nlet progressPercent = 1;\n@@ -79,7 +78,7 @@ class InlineMultimedia extends React.PureComponent<Props> {\nonLongPress={this.props.onLongPress}\nstyle={styles.expand}\n>\n- <View style={[ styles.multimediaContainer, style ]}>\n+ <View style={styles.expand}>\n<Multimedia mediaInfo={mediaInfo} />\n{progressIndicator}\n</View>\n@@ -93,10 +92,6 @@ const styles = StyleSheet.create({\nexpand: {\nflex: 1,\n},\n- multimediaContainer: {\n- flex: 1,\n- overflow: 'hidden',\n- },\ncenterContainer: {\nposition: 'absolute',\ntop: 0,\n" }, { "change_type": "MODIFY", "old_path": "native/chat/multimedia-message-multimedia.react.js", "new_path": "native/chat/multimedia-message-multimedia.react.js", "diff": "@@ -103,10 +103,11 @@ class MultimediaMessageMultimedia extends React.PureComponent<Props, State> {\n}\nrender() {\n- const wrapperStyles = [ styles.expand ];\n+ const wrapperStyles = [ styles.container ];\nif (this.state.hidden && this.state.opacity) {\nwrapperStyles.push({ opacity: this.state.opacity });\n}\n+ wrapperStyles.push(this.props.style);\nconst { mediaInfo, pendingUpload, style, postInProgress } = this.props;\nreturn (\n@@ -114,7 +115,6 @@ class MultimediaMessageMultimedia extends React.PureComponent<Props, State> {\n<View style={styles.expand} onLayout={this.onLayout} ref={this.viewRef}>\n<InlineMultimedia\nmediaInfo={this.props.mediaInfo}\n- style={this.props.style}\nonPress={this.onPress}\nonLongPress={this.onLongPress}\npostInProgress={this.props.postInProgress}\n@@ -191,6 +191,10 @@ class MultimediaMessageMultimedia extends React.PureComponent<Props, State> {\n}\nconst styles = StyleSheet.create({\n+ container: {\n+ flex: 1,\n+ overflow: 'hidden',\n+ },\nexpand: {\nflex: 1,\n},\n" }, { "change_type": "MODIFY", "old_path": "native/chat/multimedia-tooltip-button.react.js", "new_path": "native/chat/multimedia-tooltip-button.react.js", "diff": "@@ -21,7 +21,7 @@ import type { AppState } from '../redux/redux-setup';\nimport * as React from 'react';\nimport PropTypes from 'prop-types';\n-import { View } from 'react-native';\n+import { View, StyleSheet } from 'react-native';\nimport { connect } from 'lib/utils/redux-utils';\n@@ -113,14 +113,15 @@ class MultimediaTooltipButton extends React.PureComponent<Props> {\nreturn (\n<React.Fragment>\n{timestamp}\n+ <View style={[ styles.media, roundedStyle ]}>\n<InlineMultimedia\nmediaInfo={mediaInfo}\n- style={roundedStyle}\nonPress={this.onPress}\nonLongPress={this.onPress}\npostInProgress={postInProgress}\npendingUpload={pendingUpload}\n/>\n+ </View>\n</React.Fragment>\n);\n}\n@@ -131,6 +132,14 @@ class MultimediaTooltipButton extends React.PureComponent<Props> {\n}\n+\n+const styles = StyleSheet.create({\n+ media: {\n+ flex: 1,\n+ overflow: 'hidden',\n+ },\n+});\n+\nexport default connect(\n(state: AppState, ownProps: { navigation: NavProp }) => {\nconst { messageID } = ownProps.navigation.state.params.mediaInfo;\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Avoid including padding in Multimedia layout measuring
129,187
11.07.2019 00:55:42
14,400
bcf147e395fb10b0039cc45a41c73537a10202ba
[native] Render actual tooltip menu for new Tooltip
[ { "change_type": "MODIFY", "old_path": "native/chat/multimedia-message-multimedia.react.js", "new_path": "native/chat/multimedia-message-multimedia.react.js", "diff": "@@ -183,6 +183,7 @@ class MultimediaMessageMultimedia extends React.PureComponent<Props, State> {\ninitialCoordinates: coordinates,\nverticalOffset,\nverticalBounds,\n+ location: 'above',\n},\n});\n});\n" }, { "change_type": "MODIFY", "old_path": "native/chat/multimedia-tooltip-button.react.js", "new_path": "native/chat/multimedia-tooltip-button.react.js", "diff": "@@ -39,9 +39,12 @@ import { dimensionsSelector } from '../selectors/dimension-selectors';\ntype NavProp = NavigationScreenProp<{|\n...NavigationLeafRoute,\nparams: {\n- mediaInfo: MediaInfo,\n+ // Tooltip props\ninitialCoordinates: LayoutCoordinates,\nverticalBounds: VerticalBounds,\n+ location: 'above' | 'below',\n+ // Custom props\n+ mediaInfo: MediaInfo,\nverticalOffset: number,\n},\n|}>;\n@@ -60,9 +63,10 @@ class MultimediaTooltipButton extends React.PureComponent<Props> {\nnavigation: PropTypes.shape({\nstate: PropTypes.shape({\nparams: PropTypes.shape({\n- mediaInfo: mediaInfoPropType.isRequired,\ninitialCoordinates: layoutCoordinatesPropType.isRequired,\nverticalBounds: verticalBoundsPropType.isRequired,\n+ location: PropTypes.oneOf([ 'above', 'below' ]).isRequired,\n+ mediaInfo: mediaInfoPropType.isRequired,\nverticalOffset: PropTypes.number.isRequired,\n}).isRequired,\n}).isRequired,\n" }, { "change_type": "MODIFY", "old_path": "native/chat/multimedia-tooltip-modal.react.js", "new_path": "native/chat/multimedia-tooltip-modal.react.js", "diff": "// @flow\n+import { StyleSheet } from 'react-native';\n+\nimport type { MediaInfo } from 'lib/types/media-types';\nimport { createTooltip } from '../components/tooltip2.react';\n@@ -16,11 +18,21 @@ function onPressSave(props: CustomProps) {\nreturn saveImage(props.mediaInfo);\n}\n+const styles = StyleSheet.create({\n+ popoverLabelStyle: {\n+ textAlign: 'center',\n+ color: '#444',\n+ },\n+});\n+\nconst MultimediaTooltipModal = createTooltip(\nMultimediaTooltipButton,\n- [\n- { text: \"Save\", onPress: onPressSave }\n+ {\n+ entries: [\n+ { text: \"Save\", onPress: onPressSave },\n],\n+ labelStyle: styles.popoverLabelStyle,\n+ },\n);\nexport default MultimediaTooltipModal;\n" }, { "change_type": "ADD", "old_path": null, "new_path": "native/components/tooltip2-item.react.js", "diff": "+// @flow\n+\n+import type { ViewStyle, TextStyle } from '../types/styles';\n+\n+import * as React from 'react';\n+import {\n+ View,\n+ TouchableOpacity,\n+ StyleSheet,\n+ Text,\n+ ViewPropTypes,\n+} from 'react-native';\n+import PropTypes from 'prop-types';\n+\n+export type TooltipEntry<CustomProps> = {|\n+ text: string,\n+ onPress: (props: CustomProps) => mixed,\n+|};\n+\n+type Props<CustomProps: {}> = {\n+ spec: TooltipEntry<CustomProps>,\n+ onPress: (entry: TooltipEntry<CustomProps>) => void,\n+ containerStyle?: ViewStyle,\n+ labelStyle?: TextStyle,\n+};\n+class TooltipItem<CP: {}> extends React.PureComponent<Props<CP>> {\n+\n+ static propTypes = {\n+ spec: PropTypes.shape({\n+ text: PropTypes.string.isRequired,\n+ onPress: PropTypes.func.isRequired,\n+ }).isRequired,\n+ onPress: PropTypes.func.isRequired,\n+ containerStyle: ViewPropTypes.style,\n+ labelStyle: Text.propTypes.style,\n+ };\n+\n+ render() {\n+ return (\n+ <View style={[styles.itemContainer, this.props.containerStyle]}>\n+ <TouchableOpacity onPress={this.onPress}>\n+ <Text style={this.props.labelStyle} numberOfLines={1}>\n+ {this.props.spec.text}\n+ </Text>\n+ </TouchableOpacity>\n+ </View>\n+ );\n+ }\n+\n+ onPress = () => {\n+ this.props.onPress(this.props.spec);\n+ }\n+\n+}\n+\n+const styles = StyleSheet.create({\n+ itemContainer: {\n+ padding: 10,\n+ },\n+});\n+\n+export default TooltipItem;\n" }, { "change_type": "MODIFY", "old_path": "native/components/tooltip2.react.js", "new_path": "native/components/tooltip2.react.js", "diff": "@@ -14,6 +14,8 @@ import {\n} from '../types/lightbox-types';\nimport type { AppState } from '../redux/redux-setup';\nimport { type Dimensions, dimensionsPropType } from 'lib/types/media-types';\n+import type { ViewStyle } from '../types/styles';\n+import type { TooltipEntry } from './tooltip2-item.react';\nimport * as React from 'react';\nimport Animated, { Easing } from 'react-native-reanimated';\n@@ -26,18 +28,19 @@ import {\ncontentBottomOffset,\ndimensionsSelector,\n} from '../selectors/dimension-selectors';\n+import TooltipItem from './tooltip2-item.react';\nconst {\nValue,\nExtrapolate,\ninterpolate,\n+ multiply,\n} = Animated;\n-type TooltipEntry<CustomProps> = {|\n- text: string,\n- onPress: (props: CustomProps) => mixed,\n+type TooltipSpec<CustomProps> = {|\n+ entries: $ReadOnlyArray<TooltipEntry<CustomProps>>,\n+ labelStyle?: ViewStyle,\n|};\n-type TooltipSpec<CustomProps> = $ReadOnlyArray<TooltipEntry<CustomProps>>;\ntype NavProp<CustomProps> = NavigationScreenProp<{|\n...NavigationLeafRoute,\n@@ -45,6 +48,7 @@ type NavProp<CustomProps> = NavigationScreenProp<{|\n...CustomProps,\ninitialCoordinates: LayoutCoordinates,\nverticalBounds: VerticalBounds,\n+ location: 'above' | 'below',\n},\n|}>;\n@@ -86,14 +90,16 @@ function createTooltip<\nposition: PropTypes.instanceOf(Value).isRequired,\nscreenDimensions: dimensionsPropType.isRequired,\n};\n- tooltipOpacity: Value;\n+ tooltipProgress: Value;\n+ tooltipVerticalAbove: Value;\n+ tooltipVerticalBelow: Value;\nconstructor(props: TooltipPropsType) {\nsuper(props);\nconst { position } = props;\nconst { index } = props.scene;\n- this.tooltipOpacity = interpolate(\n+ this.tooltipProgress = interpolate(\nposition,\n{\ninputRange: [ index - 1, index ],\n@@ -101,12 +107,29 @@ function createTooltip<\nextrapolate: Extrapolate.CLAMP,\n},\n);\n+\n+ const { initialCoordinates } = props.navigation.state.params;\n+ const { y, height } = initialCoordinates;\n+ const entryCount = tooltipSpec.entries.length;\n+ const tooltipHeight = 9 + entryCount * 38;\n+ this.tooltipVerticalAbove = interpolate(\n+ this.tooltipProgress,\n+ {\n+ inputRange: [ 0, 1 ],\n+ outputRange: [ 20 + tooltipHeight / 2, 0 ],\n+ extrapolate: Extrapolate.CLAMP,\n+ },\n+ );\n+ this.tooltipVerticalBelow = multiply(\n+ this.tooltipVerticalAbove,\n+ -1,\n+ );\n}\nget opacityStyle() {\nreturn {\nflex: 1,\n- opacity: this.tooltipOpacity,\n+ opacity: this.tooltipProgress,\n};\n}\n@@ -133,10 +156,70 @@ function createTooltip<\n};\n}\n+ get tooltipContainerStyle() {\n+ const { screenDimensions, navigation } = this.props;\n+ const {\n+ initialCoordinates,\n+ verticalBounds,\n+ location,\n+ } = navigation.state.params;\n+ const { x, y, width, height } = initialCoordinates;\n+\n+ const style: ViewStyle = {\n+ position: 'absolute',\n+ left: x,\n+ width: width,\n+ alignItems: 'center',\n+ transform: [],\n+ };\n+ if (location === 'below') {\n+ style.top = Math.min(\n+ y + height,\n+ verticalBounds.y + verticalBounds.height,\n+ ) + 20;\n+ style.transform.push({ translateY: this.tooltipVerticalBelow });\n+ } else {\n+ const fullScreenHeight = screenDimensions.height + contentBottomOffset;\n+ style.bottom = fullScreenHeight - Math.max(y, verticalBounds.y) + 20;\n+ style.transform.push({ translateY: this.tooltipVerticalAbove });\n+ }\n+ style.transform.push({ scale: this.tooltipProgress });\n+ return style;\n+ }\n+\nrender() {\nconst { navigation } = this.props;\n+\n+ const entries = tooltipSpec.entries.map((entry, index) => {\n+ const style = index !== tooltipSpec.entries.length - 1\n+ ? styles.itemMargin\n+ : null;\nreturn (\n- <TouchableWithoutFeedback onPress={this.onPressBackdrop}>\n+ <TooltipItem\n+ key={index}\n+ spec={entry}\n+ onPress={this.onPressEntry}\n+ containerStyle={style}\n+ labelStyle={[ styles.label, tooltipSpec.labelStyle ]}\n+ />\n+ );\n+ });\n+\n+ let triangleDown = null;\n+ let triangleUp = null;\n+ const { location } = navigation.state.params;\n+ if (location === 'above') {\n+ triangleDown = (\n+ <View style={styles.triangleDown} />\n+ );\n+ } else {\n+ triangleUp = (\n+ <View style={styles.triangleUp} />\n+ );\n+ }\n+\n+ return (\n+ <TouchableWithoutFeedback onPress={this.props.navigation.goBack}>\n<Animated.View style={this.opacityStyle}>\n<View style={styles.backdrop}>\n<View style={this.contentContainerStyle}>\n@@ -145,12 +228,28 @@ function createTooltip<\n</View>\n</View>\n</View>\n+ <Animated.View style={this.tooltipContainerStyle}>\n+ <View>\n+ {triangleUp}\n+ <View style={styles.entries}>\n+ {entries}\n+ </View>\n+ {triangleDown}\n+ </View>\n+ </Animated.View>\n</Animated.View>\n</TouchableWithoutFeedback>\n);\n}\n- onPressBackdrop = () => {\n+ onPressEntry = (entry: TooltipEntry<CustomProps>) => {\n+ const {\n+ initialCoordinates,\n+ verticalBounds,\n+ location,\n+ ...customProps\n+ } = this.props.navigation.state.params;\n+ entry.onPress(customProps);\nthis.props.navigation.goBack();\n}\n@@ -172,6 +271,50 @@ const styles = StyleSheet.create({\nflex: 1,\noverflow: \"hidden\",\n},\n+ entries: {\n+ borderRadius: 5,\n+ backgroundColor: 'white',\n+ alignSelf: 'stretch',\n+ overflow: 'hidden',\n+ },\n+ itemMargin: {\n+ borderBottomWidth: 1,\n+ borderBottomColor: \"#E1E1E1\",\n+ },\n+ triangleDown: {\n+ alignSelf: 'center',\n+ width: 10,\n+ height: 10,\n+ backgroundColor: 'transparent',\n+ borderStyle: 'solid',\n+ borderTopWidth: 10,\n+ borderRightWidth: 10,\n+ borderBottomWidth: 0,\n+ borderLeftWidth: 10,\n+ borderTopColor: 'white',\n+ borderRightColor: 'transparent',\n+ borderBottomColor: 'transparent',\n+ borderLeftColor: 'transparent',\n+ },\n+ triangleUp: {\n+ alignSelf: 'center',\n+ width: 10,\n+ height: 10,\n+ backgroundColor: 'transparent',\n+ borderStyle: 'solid',\n+ borderTopWidth: 0,\n+ borderRightWidth: 10,\n+ borderBottomWidth: 10,\n+ borderLeftWidth: 10,\n+ borderBottomColor: 'white',\n+ borderTopColor: 'transparent',\n+ borderRightColor: 'transparent',\n+ borderLeftColor: 'transparent',\n+ },\n+ label: {\n+ fontSize: 14,\n+ lineHeight: 17,\n+ },\n});\nexport {\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Render actual tooltip menu for new Tooltip
129,187
11.07.2019 14:32:31
14,400
e1e7e495792f62b95cd1b808bc68e934f61b5b6b
[native] Trigger Android media scanner on image after saving
[ { "change_type": "MODIFY", "old_path": "native/media/save-image.js", "new_path": "native/media/save-image.js", "diff": "@@ -21,6 +21,8 @@ function saveImage(mediaInfo: MediaInfo) {\n}\n}\n+// On Android, we save the image to our own SquadCal folder in the\n+// Pictures directory, and then trigger the media scanner to pick it up\nasync function saveImageAndroid(mediaInfo: MediaInfo) {\nconst hasPermission = await getAndroidPermissions();\nif (!hasPermission) {\n@@ -28,7 +30,8 @@ async function saveImageAndroid(mediaInfo: MediaInfo) {\n}\nconst saveFolder = `${filesystem.PicturesDirectoryPath}/SquadCal`;\nawait filesystem.mkdir(saveFolder);\n- await saveToDisk(mediaInfo.uri, saveFolder);\n+ const filePath = await saveToDisk(mediaInfo.uri, saveFolder);\n+ await filesystem.scanFile(filePath);\n}\nasync function getAndroidPermissions() {\n@@ -49,6 +52,7 @@ async function getAndroidPermissions() {\n}\n}\n+// On iOS, we save the image to the camera roll\nasync function saveImageIOS(mediaInfo: MediaInfo) {\nconst { uri, type } = mediaInfo;\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Trigger Android media scanner on image after saving
129,187
11.07.2019 15:17:06
14,400
5f9d83a7c80623a6cc83c1bb0d08e91f6a07b524
[native] Fix new Tooltip backdrop opacity
[ { "change_type": "MODIFY", "old_path": "native/components/tooltip2.react.js", "new_path": "native/components/tooltip2.react.js", "diff": "@@ -90,7 +90,8 @@ function createTooltip<\nposition: PropTypes.instanceOf(Value).isRequired,\nscreenDimensions: dimensionsPropType.isRequired,\n};\n- tooltipProgress: Value;\n+ progress: Value;\n+ backdropOpacity: Value;\ntooltipVerticalAbove: Value;\ntooltipVerticalBelow: Value;\n@@ -99,7 +100,7 @@ function createTooltip<\nconst { position } = props;\nconst { index } = props.scene;\n- this.tooltipProgress = interpolate(\n+ this.progress = interpolate(\nposition,\n{\ninputRange: [ index - 1, index ],\n@@ -107,13 +108,21 @@ function createTooltip<\nextrapolate: Extrapolate.CLAMP,\n},\n);\n+ this.backdropOpacity = interpolate(\n+ this.progress,\n+ {\n+ inputRange: [ 0, 1 ],\n+ outputRange: [ 0, 0.7 ],\n+ extrapolate: Extrapolate.CLAMP,\n+ },\n+ );\nconst { initialCoordinates } = props.navigation.state.params;\nconst { y, height } = initialCoordinates;\nconst entryCount = tooltipSpec.entries.length;\nconst tooltipHeight = 9 + entryCount * 38;\nthis.tooltipVerticalAbove = interpolate(\n- this.tooltipProgress,\n+ this.progress,\n{\ninputRange: [ 0, 1 ],\noutputRange: [ 20 + tooltipHeight / 2, 0 ],\n@@ -128,8 +137,8 @@ function createTooltip<\nget opacityStyle() {\nreturn {\n- flex: 1,\n- opacity: this.tooltipProgress,\n+ ...styles.backdrop,\n+ opacity: this.backdropOpacity,\n};\n}\n@@ -138,10 +147,12 @@ function createTooltip<\nconst fullScreenHeight = this.props.screenDimensions.height\n+ contentBottomOffset;\nconst top = verticalBounds.y;\n- const bottom = fullScreenHeight\n- - verticalBounds.y - verticalBounds.height;\n- const verticalStyle = { marginTop: top, marginBottom: bottom };\n- return [ styles.contentContainer, verticalStyle ];\n+ const bottom = fullScreenHeight - verticalBounds.y - verticalBounds.height;\n+ return {\n+ ...styles.contentContainer,\n+ marginTop: top,\n+ marginBottom: bottom,\n+ };\n}\nget buttonStyle() {\n@@ -183,7 +194,7 @@ function createTooltip<\nstyle.bottom = fullScreenHeight - Math.max(y, verticalBounds.y) + 20;\nstyle.transform.push({ translateY: this.tooltipVerticalAbove });\n}\n- style.transform.push({ scale: this.tooltipProgress });\n+ style.transform.push({ scale: this.progress });\nreturn style;\n}\n@@ -219,15 +230,14 @@ function createTooltip<\n}\nreturn (\n- <TouchableWithoutFeedback onPress={this.props.navigation.goBack}>\n- <Animated.View style={this.opacityStyle}>\n- <View style={styles.backdrop}>\n+ <TouchableWithoutFeedback onPress={this.onPressBackdrop}>\n+ <View style={styles.container}>\n+ <Animated.View style={this.opacityStyle} />\n<View style={this.contentContainerStyle}>\n<View style={this.buttonStyle}>\n<ButtonComponent navigation={navigation} />\n</View>\n</View>\n- </View>\n<Animated.View style={this.tooltipContainerStyle}>\n<View>\n{triangleUp}\n@@ -237,11 +247,15 @@ function createTooltip<\n{triangleDown}\n</View>\n</Animated.View>\n- </Animated.View>\n+ </View>\n</TouchableWithoutFeedback>\n);\n}\n+ onPressBackdrop = () => {\n+ this.props.navigation.goBack();\n+ }\n+\nonPressEntry = (entry: TooltipEntry<CustomProps>) => {\nconst {\ninitialCoordinates,\n@@ -262,10 +276,16 @@ function createTooltip<\n}\nconst styles = StyleSheet.create({\n- backdrop: {\n+ container: {\nflex: 1,\n- opacity: 0.7,\n- backgroundColor: 'black',\n+ },\n+ backdrop: {\n+ position: \"absolute\",\n+ top: 0,\n+ bottom: 0,\n+ left: 0,\n+ right: 0,\n+ backgroundColor: \"black\",\n},\ncontentContainer: {\nflex: 1,\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Fix new Tooltip backdrop opacity
129,187
12.07.2019 14:07:04
14,400
1e43ca66448172aecd6026cba04f2254a2a2883e
[native] Fix Tooltip2 down triangle alignment on Android
[ { "change_type": "MODIFY", "old_path": "native/components/tooltip2.react.js", "new_path": "native/components/tooltip2.react.js", "diff": "@@ -19,7 +19,12 @@ import type { TooltipEntry } from './tooltip2-item.react';\nimport * as React from 'react';\nimport Animated, { Easing } from 'react-native-reanimated';\n-import { View, StyleSheet, TouchableWithoutFeedback } from 'react-native';\n+import {\n+ View,\n+ StyleSheet,\n+ TouchableWithoutFeedback,\n+ Platform,\n+} from 'react-native';\nimport PropTypes from 'prop-types';\nimport { connect } from 'lib/utils/redux-utils';\n@@ -315,6 +320,7 @@ const styles = StyleSheet.create({\nborderRightColor: 'transparent',\nborderBottomColor: 'transparent',\nborderLeftColor: 'transparent',\n+ top: Platform.OS === \"android\" ? -1 : 0,\n},\ntriangleUp: {\nalignSelf: 'center',\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Fix Tooltip2 down triangle alignment on Android
129,187
12.07.2019 14:07:46
14,400
cd0ce62ca7c18f84c4afc42f6dfbcd1d1700cbba
[native] Avoid extra View layer in Tooltip2
[ { "change_type": "MODIFY", "old_path": "native/components/tooltip2.react.js", "new_path": "native/components/tooltip2.react.js", "diff": "@@ -244,13 +244,11 @@ function createTooltip<\n</View>\n</View>\n<Animated.View style={this.tooltipContainerStyle}>\n- <View>\n{triangleUp}\n<View style={styles.entries}>\n{entries}\n</View>\n{triangleDown}\n- </View>\n</Animated.View>\n</View>\n</TouchableWithoutFeedback>\n@@ -299,7 +297,6 @@ const styles = StyleSheet.create({\nentries: {\nborderRadius: 5,\nbackgroundColor: 'white',\n- alignSelf: 'stretch',\noverflow: 'hidden',\n},\nitemMargin: {\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Avoid extra View layer in Tooltip2
129,187
12.07.2019 14:19:12
14,400
a97fe94b97454cbb8f026cce1f5e834a915b3d7e
[native] Animate Tooltip2 "button" opacity
[ { "change_type": "MODIFY", "old_path": "native/components/tooltip2.react.js", "new_path": "native/components/tooltip2.react.js", "diff": "@@ -157,6 +157,7 @@ function createTooltip<\n...styles.contentContainer,\nmarginTop: top,\nmarginBottom: bottom,\n+ opacity: this.progress,\n};\n}\n@@ -238,11 +239,11 @@ function createTooltip<\n<TouchableWithoutFeedback onPress={this.onPressBackdrop}>\n<View style={styles.container}>\n<Animated.View style={this.opacityStyle} />\n- <View style={this.contentContainerStyle}>\n+ <Animated.View style={this.contentContainerStyle}>\n<View style={this.buttonStyle}>\n<ButtonComponent navigation={navigation} />\n</View>\n- </View>\n+ </Animated.View>\n<Animated.View style={this.tooltipContainerStyle}>\n{triangleUp}\n<View style={styles.entries}>\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Animate Tooltip2 "button" opacity
129,187
12.07.2019 14:53:02
14,400
d57d2462c2dba07c803c9eedf84ab1b0ff2b9c21
[native] Decide between above and below for MultimediaTooltipModal
[ { "change_type": "MODIFY", "old_path": "native/chat/multimedia-message-multimedia.react.js", "new_path": "native/chat/multimedia-message-multimedia.react.js", "diff": "@@ -24,7 +24,7 @@ import { KeyboardUtils } from 'react-native-keyboard-input';\nimport invariant from 'invariant';\nimport InlineMultimedia from './inline-multimedia.react';\n-import { saveImage } from '../media/save-image';\n+import { multimediaTooltipHeight } from './multimedia-tooltip-modal.react';\ntype Props = {|\nmediaInfo: MediaInfo,\n@@ -175,6 +175,21 @@ class MultimediaMessageMultimedia extends React.PureComponent<Props, State> {\nview.measure((x, y, width, height, pageX, pageY) => {\nconst coordinates = { x: pageX, y: pageY, width, height };\n+\n+ const multimediaTop = pageY;\n+ const multimediaBottom = pageY + height;\n+ const boundsTop = verticalBounds.y;\n+ const boundsBottom = verticalBounds.y + verticalBounds.height;\n+ const multimediaTooltipVerticalSpace = multimediaTooltipHeight + 20;\n+\n+ let location = 'below';\n+ if (\n+ multimediaBottom + multimediaTooltipVerticalSpace > boundsBottom &&\n+ multimediaTop - multimediaTooltipVerticalSpace > boundsTop\n+ ) {\n+ location = 'above';\n+ }\n+\nconst { mediaInfo, navigate } = this.props;\nnavigate({\nrouteName: MultimediaTooltipModalRouteName,\n@@ -183,7 +198,7 @@ class MultimediaMessageMultimedia extends React.PureComponent<Props, State> {\ninitialCoordinates: coordinates,\nverticalOffset,\nverticalBounds,\n- location: 'above',\n+ location,\n},\n});\n});\n" }, { "change_type": "MODIFY", "old_path": "native/chat/multimedia-tooltip-modal.react.js", "new_path": "native/chat/multimedia-tooltip-modal.react.js", "diff": "@@ -4,7 +4,7 @@ import { StyleSheet } from 'react-native';\nimport type { MediaInfo } from 'lib/types/media-types';\n-import { createTooltip } from '../components/tooltip2.react';\n+import { createTooltip, tooltipHeight } from '../components/tooltip2.react';\nimport MultimediaTooltipButton from './multimedia-tooltip-button.react';\nimport { saveImage } from '../media/save-image';\n@@ -25,14 +25,18 @@ const styles = StyleSheet.create({\n},\n});\n-const MultimediaTooltipModal = createTooltip(\n- MultimediaTooltipButton,\n- {\n+const spec = {\nentries: [\n{ text: \"Save\", onPress: onPressSave },\n],\nlabelStyle: styles.popoverLabelStyle,\n- },\n-);\n+};\n+\n+const MultimediaTooltipModal = createTooltip(MultimediaTooltipButton, spec);\n-export default MultimediaTooltipModal;\n+const multimediaTooltipHeight = tooltipHeight(spec.entries.length);\n+\n+export {\n+ MultimediaTooltipModal,\n+ multimediaTooltipHeight,\n+};\n" }, { "change_type": "MODIFY", "old_path": "native/components/tooltip2.react.js", "new_path": "native/components/tooltip2.react.js", "diff": "@@ -125,12 +125,11 @@ function createTooltip<\nconst { initialCoordinates } = props.navigation.state.params;\nconst { y, height } = initialCoordinates;\nconst entryCount = tooltipSpec.entries.length;\n- const tooltipHeight = 9 + entryCount * 38;\nthis.tooltipVerticalAbove = interpolate(\nthis.progress,\n{\ninputRange: [ 0, 1 ],\n- outputRange: [ 20 + tooltipHeight / 2, 0 ],\n+ outputRange: [ 20 + tooltipHeight(entryCount) / 2, 0 ],\nextrapolate: Extrapolate.CLAMP,\n},\n);\n@@ -341,6 +340,12 @@ const styles = StyleSheet.create({\n},\n});\n+function tooltipHeight(numEntries: number) {\n+ // 10 (triangle) + 37 * numEntries (entries) + numEntries - 1 (padding)\n+ return 9 + 38 * numEntries;\n+}\n+\nexport {\ncreateTooltip,\n+ tooltipHeight,\n};\n" }, { "change_type": "MODIFY", "old_path": "native/navigation/navigation-setup.js", "new_path": "native/navigation/navigation-setup.js", "diff": "@@ -102,7 +102,7 @@ import ColorPickerModal from '../chat/settings/color-picker-modal.react';\nimport ComposeSubthreadModal from '../chat/settings/compose-subthread-modal.react';\nimport { createLightboxNavigator } from '../media/lightbox-navigator.react';\nimport MultimediaModal from '../media/multimedia-modal.react';\n-import MultimediaTooltipModal from '../chat/multimedia-tooltip-modal.react';\n+import { MultimediaTooltipModal } from '../chat/multimedia-tooltip-modal.react';\nimport ChatInputStateContainer from '../chat/chat-input-state-container.react';\nuseScreens();\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Decide between above and below for MultimediaTooltipModal
129,187
12.07.2019 14:57:12
14,400
0187975f1ca4e5eb3b3c6b04de9d8899327f3636
[native] Default Tooltip2 to appearing below content Easier for user to reach
[ { "change_type": "MODIFY", "old_path": "native/chat/multimedia-tooltip-button.react.js", "new_path": "native/chat/multimedia-tooltip-button.react.js", "diff": "@@ -42,7 +42,7 @@ type NavProp = NavigationScreenProp<{|\n// Tooltip props\ninitialCoordinates: LayoutCoordinates,\nverticalBounds: VerticalBounds,\n- location: 'above' | 'below',\n+ location?: 'above' | 'below',\n// Custom props\nmediaInfo: MediaInfo,\nverticalOffset: number,\n@@ -65,7 +65,7 @@ class MultimediaTooltipButton extends React.PureComponent<Props> {\nparams: PropTypes.shape({\ninitialCoordinates: layoutCoordinatesPropType.isRequired,\nverticalBounds: verticalBoundsPropType.isRequired,\n- location: PropTypes.oneOf([ 'above', 'below' ]).isRequired,\n+ location: PropTypes.oneOf([ 'above', 'below' ]),\nmediaInfo: mediaInfoPropType.isRequired,\nverticalOffset: PropTypes.number.isRequired,\n}).isRequired,\n" }, { "change_type": "MODIFY", "old_path": "native/components/tooltip2.react.js", "new_path": "native/components/tooltip2.react.js", "diff": "@@ -53,7 +53,7 @@ type NavProp<CustomProps> = NavigationScreenProp<{|\n...CustomProps,\ninitialCoordinates: LayoutCoordinates,\nverticalBounds: VerticalBounds,\n- location: 'above' | 'below',\n+ location?: 'above' | 'below',\n},\n|}>;\n@@ -188,16 +188,16 @@ function createTooltip<\nalignItems: 'center',\ntransform: [],\n};\n- if (location === 'below') {\n+ if (location === 'above') {\n+ const fullScreenHeight = screenDimensions.height + contentBottomOffset;\n+ style.bottom = fullScreenHeight - Math.max(y, verticalBounds.y) + 20;\n+ style.transform.push({ translateY: this.tooltipVerticalAbove });\n+ } else {\nstyle.top = Math.min(\ny + height,\nverticalBounds.y + verticalBounds.height,\n) + 20;\nstyle.transform.push({ translateY: this.tooltipVerticalBelow });\n- } else {\n- const fullScreenHeight = screenDimensions.height + contentBottomOffset;\n- style.bottom = fullScreenHeight - Math.max(y, verticalBounds.y) + 20;\n- style.transform.push({ translateY: this.tooltipVerticalAbove });\n}\nstyle.transform.push({ scale: this.progress });\nreturn style;\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Default Tooltip2 to appearing below content Easier for user to reach
129,187
12.07.2019 15:45:19
14,400
fc0fc10c9703477c780f0944dbec4d514d90e2c9
[native] Customize MultimediaTooltipModal margin to avoid timestamp
[ { "change_type": "MODIFY", "old_path": "native/chat/multimedia-message-multimedia.react.js", "new_path": "native/chat/multimedia-message-multimedia.react.js", "diff": "@@ -180,14 +180,19 @@ class MultimediaMessageMultimedia extends React.PureComponent<Props, State> {\nconst multimediaBottom = pageY + height;\nconst boundsTop = verticalBounds.y;\nconst boundsBottom = verticalBounds.y + verticalBounds.height;\n- const multimediaTooltipVerticalSpace = multimediaTooltipHeight + 20;\n- let location = 'below';\n+ const belowMargin = 20;\n+ const belowSpace = multimediaTooltipHeight + belowMargin;\n+ const aboveMargin = verticalOffset === 0 ? 30 : 20;\n+ const aboveSpace = multimediaTooltipHeight + aboveMargin;\n+\n+ let location = 'below', margin = belowMargin;\nif (\n- multimediaBottom + multimediaTooltipVerticalSpace > boundsBottom &&\n- multimediaTop - multimediaTooltipVerticalSpace > boundsTop\n+ multimediaBottom + belowSpace > boundsBottom &&\n+ multimediaTop - aboveSpace > boundsTop\n) {\nlocation = 'above';\n+ margin = aboveMargin;\n}\nconst { mediaInfo, navigate } = this.props;\n@@ -199,6 +204,7 @@ class MultimediaMessageMultimedia extends React.PureComponent<Props, State> {\nverticalOffset,\nverticalBounds,\nlocation,\n+ margin,\n},\n});\n});\n" }, { "change_type": "MODIFY", "old_path": "native/chat/multimedia-tooltip-button.react.js", "new_path": "native/chat/multimedia-tooltip-button.react.js", "diff": "@@ -43,6 +43,7 @@ type NavProp = NavigationScreenProp<{|\ninitialCoordinates: LayoutCoordinates,\nverticalBounds: VerticalBounds,\nlocation?: 'above' | 'below',\n+ margin?: number,\n// Custom props\nmediaInfo: MediaInfo,\nverticalOffset: number,\n@@ -66,6 +67,7 @@ class MultimediaTooltipButton extends React.PureComponent<Props> {\ninitialCoordinates: layoutCoordinatesPropType.isRequired,\nverticalBounds: verticalBoundsPropType.isRequired,\nlocation: PropTypes.oneOf([ 'above', 'below' ]),\n+ margin: PropTypes.number,\nmediaInfo: mediaInfoPropType.isRequired,\nverticalOffset: PropTypes.number.isRequired,\n}).isRequired,\n" }, { "change_type": "MODIFY", "old_path": "native/components/tooltip2.react.js", "new_path": "native/components/tooltip2.react.js", "diff": "@@ -50,10 +50,11 @@ type TooltipSpec<CustomProps> = {|\ntype NavProp<CustomProps> = NavigationScreenProp<{|\n...NavigationLeafRoute,\nparams: {\n- ...CustomProps,\n+ ...$Exact<CustomProps>,\ninitialCoordinates: LayoutCoordinates,\nverticalBounds: VerticalBounds,\nlocation?: 'above' | 'below',\n+ margin?: number,\n},\n|}>;\n@@ -178,8 +179,12 @@ function createTooltip<\ninitialCoordinates,\nverticalBounds,\nlocation,\n+ margin: customMargin,\n} = navigation.state.params;\nconst { x, y, width, height } = initialCoordinates;\n+ const margin = customMargin !== null && customMargin !== undefined\n+ ? customMargin\n+ : 20;\nconst style: ViewStyle = {\nposition: 'absolute',\n@@ -190,13 +195,15 @@ function createTooltip<\n};\nif (location === 'above') {\nconst fullScreenHeight = screenDimensions.height + contentBottomOffset;\n- style.bottom = fullScreenHeight - Math.max(y, verticalBounds.y) + 20;\n+ style.bottom = fullScreenHeight -\n+ Math.max(y, verticalBounds.y) +\n+ margin;\nstyle.transform.push({ translateY: this.tooltipVerticalAbove });\n} else {\nstyle.top = Math.min(\ny + height,\nverticalBounds.y + verticalBounds.height,\n- ) + 20;\n+ ) + margin;\nstyle.transform.push({ translateY: this.tooltipVerticalBelow });\n}\nstyle.transform.push({ scale: this.progress });\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Customize MultimediaTooltipModal margin to avoid timestamp
129,187
16.07.2019 14:38:33
14,400
2ce5fe0ddfe2091765be943b8742f5a8393c9bfe
[native] Allow Tooltip2 to be wider than content (But never so wide that it goes off screen)
[ { "change_type": "MODIFY", "old_path": "native/components/tooltip2.react.js", "new_path": "native/components/tooltip2.react.js", "diff": "@@ -186,10 +186,16 @@ function createTooltip<\n? customMargin\n: 20;\n+ const extraLeftSpace = x;\n+ const extraRightSpace = screenDimensions.width - width - x;\n+ const extraSpace = Math.min(extraLeftSpace, extraRightSpace);\n+ const left = x - extraSpace;\n+ const containerWidth = width + 2 * extraSpace;\n+\nconst style: ViewStyle = {\nposition: 'absolute',\n- left: x,\n- width: width,\n+ left,\n+ width: containerWidth,\nalignItems: 'center',\ntransform: [],\n};\n@@ -311,10 +317,8 @@ const styles = StyleSheet.create({\nborderBottomColor: \"#E1E1E1\",\n},\ntriangleDown: {\n- alignSelf: 'center',\nwidth: 10,\nheight: 10,\n- backgroundColor: 'transparent',\nborderStyle: 'solid',\nborderTopWidth: 10,\nborderRightWidth: 10,\n@@ -327,10 +331,8 @@ const styles = StyleSheet.create({\ntop: Platform.OS === \"android\" ? -1 : 0,\n},\ntriangleUp: {\n- alignSelf: 'center',\nwidth: 10,\nheight: 10,\n- backgroundColor: 'transparent',\nborderStyle: 'solid',\nborderTopWidth: 0,\nborderRightWidth: 10,\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Allow Tooltip2 to be wider than content (But never so wide that it goes off screen)
129,187
16.07.2019 15:52:30
14,400
f718aff273763d28a998fa15e8a7bae801778378
[native] Hack around dispatch type mismatch Sadly using an `any`-cast here. We define our `Dispatch` differently than the Redux libdef, partially because of our use of `redux-thunk`.
[ { "change_type": "MODIFY", "old_path": "native/app.react.js", "new_path": "native/app.react.js", "diff": "@@ -509,7 +509,6 @@ class AppWithNavigationState extends React.PureComponent<Props> {\nsaveMessageInfos(messageInfosString: string) {\nsaveMessageInfos(\n- this.props.dispatch,\nmessageInfosString,\nthis.props.updatesCurrentAsOf,\n);\n@@ -591,7 +590,6 @@ class AppWithNavigationState extends React.PureComponent<Props> {\n}\nhandleAndroidMessage(\nmessage,\n- this.props.dispatch,\nthis.props.updatesCurrentAsOf,\nthis.handleAndroidNotificationIfActive,\n);\n" }, { "change_type": "MODIFY", "old_path": "native/push/android.js", "new_path": "native/push/android.js", "diff": "@@ -12,7 +12,7 @@ import {\nimport { getFirebase } from './firebase';\nimport { saveMessageInfos } from './utils';\n-import { store } from '../redux/redux-setup';\n+import { store, dispatch } from '../redux/redux-setup';\nconst androidNotificationChannelID = 'default';\nconst vibrationSpec = [ 500, 500 ];\n@@ -24,7 +24,6 @@ type Texts = {|\n|};\nfunction handleAndroidMessage(\nmessage: RemoteMessage,\n- dispatch: Dispatch,\nupdatesCurrentAsOf: number,\nhandleIfActive?: (\nthreadID: string,\n@@ -46,7 +45,7 @@ function handleAndroidMessage(\nmessageInfos = customNotification.messageInfos;\n}\nif (messageInfos) {\n- saveMessageInfos(dispatch, messageInfos, updatesCurrentAsOf);\n+ saveMessageInfos(messageInfos, updatesCurrentAsOf);\n}\nlet { rescind, rescindID } = data;\n@@ -110,9 +109,8 @@ function handleAndroidMessage(\n}\nasync function androidBackgroundMessageTask(message: RemoteMessage) {\n- const { dispatch } = store;\nconst { updatesCurrentAsOf } = store.getState();\n- handleAndroidMessage(message, dispatch, updatesCurrentAsOf);\n+ handleAndroidMessage(message, updatesCurrentAsOf);\n}\nexport {\n" }, { "change_type": "MODIFY", "old_path": "native/push/utils.js", "new_path": "native/push/utils.js", "diff": "@@ -5,8 +5,9 @@ import type { RawMessageInfo } from 'lib/types/message-types';\nimport { saveMessagesActionType } from 'lib/actions/message-actions';\n+import { dispatch } from '../redux/redux-setup';\n+\nfunction saveMessageInfos(\n- dispatch: Dispatch,\nmessageInfosString: string,\nupdatesCurrentAsOf: number,\n) {\n" }, { "change_type": "MODIFY", "old_path": "native/redux/redux-setup.js", "new_path": "native/redux/redux-setup.js", "diff": "@@ -29,6 +29,7 @@ import {\ntype ConnectivityInfo,\ndefaultConnectivityInfo,\n} from '../types/connectivity';\n+import type { Dispatch } from 'lib/types/redux-types';\nimport React from 'react';\nimport invariant from 'invariant';\n@@ -419,7 +420,11 @@ const store: Store<AppState, *> = createStore(\nconst persistor = persistStore(store);\nsetPersistor(persistor);\n+const unsafeDispatch: any = store.dispatch;\n+const dispatch: Dispatch = unsafeDispatch;\n+\nexport {\nstore,\n+ dispatch,\nappBecameInactive,\n};\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Hack around dispatch type mismatch Sadly using an `any`-cast here. We define our `Dispatch` differently than the Redux libdef, partially because of our use of `redux-thunk`.
129,187
16.07.2019 16:04:05
14,400
68583856791f3a12104fa593c0eb7bd426a5cc5f
[native] Show message after multimedia save
[ { "change_type": "ADD", "old_path": null, "new_path": "native/media/multimedia-saved-modal.react.js", "diff": "+// @flow\n+\n+import type {\n+ NavigationScreenProp,\n+ NavigationLeafRoute,\n+ NavigationScene,\n+} from 'react-navigation';\n+\n+import * as React from 'react';\n+import { View, Text, StyleSheet } from 'react-native';\n+import PropTypes from 'prop-types';\n+import Animated from 'react-native-reanimated';\n+\n+import { contentBottomOffset } from '../selectors/dimension-selectors';\n+\n+const {\n+ Value,\n+ Extrapolate,\n+ interpolate,\n+} = Animated;\n+\n+type NavProp = NavigationScreenProp<{|\n+ ...NavigationLeafRoute,\n+ params: {|\n+ message: string,\n+ |},\n+|}>;\n+\n+type Props = {|\n+ navigation: NavProp,\n+ scene: NavigationScene,\n+ position: Value,\n+|};\n+class MultimediaSavedModal extends React.PureComponent<Props> {\n+\n+ static propTypes = {\n+ navigation: PropTypes.shape({\n+ state: PropTypes.shape({\n+ params: PropTypes.shape({\n+ message: PropTypes.string.isRequired,\n+ }).isRequired,\n+ }).isRequired,\n+ goBack: PropTypes.func.isRequired,\n+ }).isRequired,\n+ scene: PropTypes.object.isRequired,\n+ position: PropTypes.instanceOf(Value).isRequired,\n+ };\n+ progress: Value;\n+\n+ constructor(props: Props) {\n+ super(props);\n+\n+ const { position } = props;\n+ const { index } = props.scene;\n+ this.progress = interpolate(\n+ position,\n+ {\n+ inputRange: [ index - 1, index ],\n+ outputRange: [ 0, 1 ],\n+ extrapolate: Extrapolate.CLAMP,\n+ },\n+ );\n+ }\n+\n+ componentDidMount() {\n+ setTimeout(this.goBack, 2000);\n+ }\n+\n+ goBack = () => {\n+ this.props.navigation.goBack();\n+ }\n+\n+ get containerStyle() {\n+ return {\n+ ...styles.container,\n+ opacity: this.progress,\n+ };\n+ }\n+\n+ render() {\n+ const { message } = this.props.navigation.state.params;\n+ return (\n+ <Animated.View style={this.containerStyle}>\n+ <View style={styles.message}>\n+ <View style={styles.backdrop} />\n+ <Text style={styles.text}>{message}</Text>\n+ </View>\n+ </Animated.View>\n+ );\n+ }\n+\n+}\n+\n+const styles = StyleSheet.create({\n+ container: {\n+ flex: 1,\n+ justifyContent: 'flex-end',\n+ alignItems: 'center',\n+ paddingBottom: contentBottomOffset + 100,\n+ },\n+ message: {\n+ borderRadius: 10,\n+ padding: 10,\n+ overflow: 'hidden',\n+ },\n+ backdrop: {\n+ backgroundColor: 'black',\n+ opacity: 0.7,\n+ position: 'absolute',\n+ top: 0,\n+ bottom: 0,\n+ left: 0,\n+ right: 0,\n+ },\n+ text: {\n+ fontSize: 20,\n+ color: 'white',\n+ },\n+});\n+\n+export default MultimediaSavedModal;\n" }, { "change_type": "MODIFY", "old_path": "native/media/save-image.js", "new_path": "native/media/save-image.js", "diff": "@@ -6,19 +6,37 @@ import { Platform, PermissionsAndroid } from 'react-native';\nimport filesystem from 'react-native-fs';\nimport CameraRoll from '@react-native-community/cameraroll';\nimport invariant from 'invariant';\n+import { NavigationActions } from 'react-navigation';\nimport { fileInfoFromData } from 'lib/utils/file-utils';\nimport { blobToDataURI, dataURIToIntArray } from '../utils/media-utils';\n+import { dispatch } from '../redux/redux-setup';\n+import { MultimediaSavedModalRouteName } from '../navigation/route-names';\n-function saveImage(mediaInfo: MediaInfo) {\n+async function saveImage(mediaInfo: MediaInfo) {\n+ let result, message;\nif (Platform.OS === \"android\") {\n- return saveImageAndroid(mediaInfo);\n+ result = await saveImageAndroid(mediaInfo);\n} else if (Platform.OS === \"ios\") {\n- return saveImageIOS(mediaInfo);\n+ result = await saveImageIOS(mediaInfo);\n} else {\n- invariant(false, `saveImage unsupported on ${Platform.OS}`);\n+ message = `saving images is unsupported on ${Platform.OS}`;\n}\n+\n+ if (result) {\n+ message = \"saved!\";\n+ } else if (!message) {\n+ message = \"don't have permission :(\";\n+ }\n+\n+ dispatch({\n+ // We do this for Flow\n+ ...NavigationActions.navigate({\n+ routeName: MultimediaSavedModalRouteName,\n+ params: { message },\n+ }),\n+ });\n}\n// On Android, we save the image to our own SquadCal folder in the\n@@ -26,12 +44,13 @@ function saveImage(mediaInfo: MediaInfo) {\nasync function saveImageAndroid(mediaInfo: MediaInfo) {\nconst hasPermission = await getAndroidPermissions();\nif (!hasPermission) {\n- return;\n+ return false;\n}\nconst saveFolder = `${filesystem.PicturesDirectoryPath}/SquadCal`;\nawait filesystem.mkdir(saveFolder);\nconst filePath = await saveToDisk(mediaInfo.uri, saveFolder);\nawait filesystem.scanFile(filePath);\n+ return true;\n}\nasync function getAndroidPermissions() {\n@@ -67,6 +86,7 @@ async function saveImageIOS(mediaInfo: MediaInfo) {\nif (tempFile) {\nawait filesystem.unlink(tempFile);\n}\n+ return true;\n}\nasync function saveToDisk(uri: string, directory: string) {\n" }, { "change_type": "MODIFY", "old_path": "native/navigation/navigation-setup.js", "new_path": "native/navigation/navigation-setup.js", "diff": "@@ -89,6 +89,7 @@ import {\nComposeSubthreadModalRouteName,\nMultimediaModalRouteName,\nMultimediaTooltipModalRouteName,\n+ MultimediaSavedModalRouteName,\naccountModals,\n} from './route-names';\nimport {\n@@ -104,6 +105,7 @@ import { createLightboxNavigator } from '../media/lightbox-navigator.react';\nimport MultimediaModal from '../media/multimedia-modal.react';\nimport { MultimediaTooltipModal } from '../chat/multimedia-tooltip-modal.react';\nimport ChatInputStateContainer from '../chat/chat-input-state-container.react';\n+import MultimediaSavedModal from '../media/multimedia-saved-modal.react';\nuseScreens();\n@@ -166,6 +168,7 @@ const AppNavigator = createLightboxNavigator(\n[TabNavigatorRouteName]: TabNavigator,\n[MultimediaModalRouteName]: MultimediaModal,\n[MultimediaTooltipModalRouteName]: MultimediaTooltipModal,\n+ [MultimediaSavedModalRouteName]: MultimediaSavedModal,\n},\n);\n" }, { "change_type": "MODIFY", "old_path": "native/navigation/route-names.js", "new_path": "native/navigation/route-names.js", "diff": "@@ -37,6 +37,7 @@ export const ColorPickerModalRouteName = 'ColorPickerModal';\nexport const ComposeSubthreadModalRouteName = 'ComposeSubthreadModal';\nexport const MultimediaModalRouteName = 'MultimediaModal';\nexport const MultimediaTooltipModalRouteName = 'MultimediaTooltipModal';\n+export const MultimediaSavedModalRouteName = 'MultimediaSavedModal';\nexport const accountModals = [\nLoggedOutModalRouteName,\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Show message after multimedia save
129,187
17.07.2019 10:18:26
14,400
938bf95b2627871a526426c719a0edcb898f9346
[native] Fix scroll disabling behavior to ignore MultimediaSavedModal
[ { "change_type": "MODIFY", "old_path": "native/chat/message-list.react.js", "new_path": "native/chat/message-list.react.js", "diff": "@@ -46,7 +46,10 @@ import {\naddKeyboardDismissListener,\nremoveKeyboardListener,\n} from '../keyboard';\n-import { modalsClosedSelector } from '../selectors/nav-selectors';\n+import {\n+ multimediaModalsClosedSelector,\n+ lightboxTransitioningSelector,\n+} from '../selectors/nav-selectors';\ntype Props = {|\nthreadInfo: ThreadInfo,\n@@ -56,7 +59,8 @@ type Props = {|\n// Redux state\nviewerID: ?string,\nstartReached: bool,\n- modalsClosed: bool,\n+ multimediaModalsClosed: bool,\n+ lightboxIsTransitioning: bool,\n// Redux dispatch functions\ndispatchActionPromise: DispatchActionPromise,\n// async functions that hit server APIs\n@@ -80,7 +84,7 @@ type PropsAndState = {|\n...State,\n|};\ntype FlatListExtraData = {|\n- modalsClosed: bool,\n+ multimediaModalsClosed: bool,\nkeyboardShowing: bool,\nmessageListVerticalBounds: ?VerticalBounds,\nfocusedMessageKey: ?string,\n@@ -94,7 +98,8 @@ class MessageList extends React.PureComponent<Props, State> {\nimageGalleryOpen: PropTypes.bool.isRequired,\nviewerID: PropTypes.string,\nstartReached: PropTypes.bool.isRequired,\n- modalsClosed: PropTypes.bool.isRequired,\n+ multimediaModalsClosed: PropTypes.bool.isRequired,\n+ lightboxIsTransitioning: PropTypes.bool.isRequired,\ndispatchActionPromise: PropTypes.func.isRequired,\nfetchMessagesBeforeCursor: PropTypes.func.isRequired,\nfetchMostRecentMessages: PropTypes.func.isRequired,\n@@ -112,7 +117,7 @@ class MessageList extends React.PureComponent<Props, State> {\nmessageListVerticalBounds: null,\nkeyboardShowing: false,\nflatListExtraData: {\n- modalsClosed: props.modalsClosed,\n+ multimediaModalsClosed: props.multimediaModalsClosed,\nkeyboardShowing: props.imageGalleryOpen,\nmessageListVerticalBounds: null,\nfocusedMessageKey: null,\n@@ -121,19 +126,19 @@ class MessageList extends React.PureComponent<Props, State> {\n}\nstatic flatListExtraDataSelector = createSelector(\n- (propsAndState: PropsAndState) => propsAndState.modalsClosed,\n+ (propsAndState: PropsAndState) => propsAndState.multimediaModalsClosed,\n(propsAndState: PropsAndState) => propsAndState.keyboardShowing,\n(propsAndState: PropsAndState) => propsAndState.messageListVerticalBounds,\n(propsAndState: PropsAndState) => propsAndState.imageGalleryOpen,\n(propsAndState: PropsAndState) => propsAndState.focusedMessageKey,\n(\n- modalsClosed: bool,\n+ multimediaModalsClosed: bool,\nkeyboardShowing: bool,\nmessageListVerticalBounds: ?VerticalBounds,\nimageGalleryOpen: bool,\nfocusedMessageKey: ?string,\n) => ({\n- modalsClosed,\n+ multimediaModalsClosed,\nkeyboardShowing: keyboardShowing || imageGalleryOpen,\nmessageListVerticalBounds,\nfocusedMessageKey,\n@@ -215,9 +220,16 @@ class MessageList extends React.PureComponent<Props, State> {\nthis.loadingFromScroll = false;\n}\n- if (this.props.modalsClosed && !prevProps.modalsClosed) {\n+ if (\n+ this.state.scrollDisabled &&\n+ this.props.multimediaModalsClosed &&\n+ !this.props.lightboxIsTransitioning\n+ ) {\nthis.setState({ scrollDisabled: false });\n- } else if (!this.props.modalsClosed && prevProps.modalsClosed) {\n+ } else if (\n+ !this.state.scrollDisabled &&\n+ !this.props.multimediaModalsClosed\n+ ) {\nthis.setState({ scrollDisabled: true });\n}\n}\n@@ -234,7 +246,7 @@ class MessageList extends React.PureComponent<Props, State> {\n}\nconst messageInfoItem: ChatMessageInfoItemWithHeight = row.item;\nconst {\n- modalsClosed,\n+ multimediaModalsClosed,\nkeyboardShowing,\nmessageListVerticalBounds,\nfocusedMessageKey,\n@@ -250,7 +262,7 @@ class MessageList extends React.PureComponent<Props, State> {\nsetScrollDisabled={this.setScrollDisabled}\nverticalBounds={messageListVerticalBounds}\nkeyboardShowing={keyboardShowing}\n- modalsClosed={modalsClosed}\n+ multimediaModalsClosed={multimediaModalsClosed}\n/>\n);\n}\n@@ -422,7 +434,8 @@ export default connect(\nviewerID: state.currentUserInfo && state.currentUserInfo.id,\nstartReached: !!(state.messageStore.threads[threadID] &&\nstate.messageStore.threads[threadID].startReached),\n- modalsClosed: modalsClosedSelector(state),\n+ multimediaModalsClosed: multimediaModalsClosedSelector(state),\n+ lightboxIsTransitioning: lightboxTransitioningSelector(state),\n};\n},\n{ fetchMessagesBeforeCursor, fetchMostRecentMessages },\n" }, { "change_type": "MODIFY", "old_path": "native/chat/message.react.js", "new_path": "native/chat/message.react.js", "diff": "@@ -68,7 +68,7 @@ type Props = {|\nsetScrollDisabled: (scrollDisabled: bool) => void,\nverticalBounds: ?VerticalBounds,\nkeyboardShowing: bool,\n- modalsClosed: bool,\n+ multimediaModalsClosed: bool,\n|};\nclass Message extends React.PureComponent<Props> {\n@@ -80,7 +80,7 @@ class Message extends React.PureComponent<Props> {\nsetScrollDisabled: PropTypes.func.isRequired,\nverticalBounds: verticalBoundsPropType,\nkeyboardShowing: PropTypes.bool.isRequired,\n- modalsClosed: PropTypes.bool.isRequired,\n+ multimediaModalsClosed: PropTypes.bool.isRequired,\n};\ncomponentDidUpdate(prevProps: Props) {\n@@ -119,7 +119,7 @@ class Message extends React.PureComponent<Props> {\ntoggleFocus={this.props.toggleFocus}\nverticalBounds={this.props.verticalBounds}\nkeyboardShowing={this.props.keyboardShowing}\n- modalsClosed={this.props.modalsClosed}\n+ modalsClosed={this.props.multimediaModalsClosed}\n/>\n);\n} else {\n" }, { "change_type": "MODIFY", "old_path": "native/navigation/route-names.js", "new_path": "native/navigation/route-names.js", "diff": "@@ -43,3 +43,9 @@ export const accountModals = [\nLoggedOutModalRouteName,\nVerificationModalRouteName,\n];\n+\n+// Only includes the modals that block scroll\n+export const multimediaModals = [\n+ MultimediaModalRouteName,\n+ MultimediaTooltipModalRouteName,\n+];\n" }, { "change_type": "MODIFY", "old_path": "native/selectors/nav-selectors.js", "new_path": "native/selectors/nav-selectors.js", "diff": "@@ -23,6 +23,7 @@ import {\nCalendarRouteName,\nThreadPickerModalRouteName,\naccountModals,\n+ multimediaModals,\n} from '../navigation/route-names';\nimport {\nassertNavigationRouteNotLeafNode,\n@@ -71,17 +72,30 @@ const createActiveTabSelector: (\nrouteName: string,\n) => (state: AppState) => bool = _memoize(baseCreateActiveTabSelector);\n-const modalsClosedSelector: (state: AppState) => bool = createSelector(\n+const multimediaModalsClosedSelector: (\n+ state: AppState,\n+) => bool = createSelector(\n(state: AppState) => state.navInfo.navigationState,\n(navigationState: NavigationState) => {\nconst currentRootSubroute = navigationState.routes[navigationState.index];\nif (currentRootSubroute.routeName !== AppRouteName) {\n- return false;\n+ return true;\n}\nconst appRoute = assertNavigationRouteNotLeafNode(currentRootSubroute);\nconst currentAppSubroute = appRoute.routes[appRoute.index];\n- return !appRoute.isTransitioning &&\n- currentAppSubroute.routeName === TabNavigatorRouteName;\n+ return !multimediaModals.includes(currentAppSubroute.routeName);\n+ },\n+);\n+\n+const lightboxTransitioningSelector: (state: AppState) => bool = createSelector(\n+ (state: AppState) => state.navInfo.navigationState,\n+ (navigationState: NavigationState) => {\n+ const currentRootSubroute = navigationState.routes[navigationState.index];\n+ if (currentRootSubroute.routeName !== AppRouteName) {\n+ return false;\n+ }\n+ const appRoute = assertNavigationRouteNotLeafNode(currentRootSubroute);\n+ return !!appRoute.isTransitioning;\n},\n);\n@@ -182,7 +196,8 @@ export {\nappLoggedInSelector,\nforegroundKeySelector,\ncreateActiveTabSelector,\n- modalsClosedSelector,\n+ multimediaModalsClosedSelector,\n+ lightboxTransitioningSelector,\nactiveThreadSelector,\nappCanRespondToBackButtonSelector,\ncalendarActiveSelector,\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Fix scroll disabling behavior to ignore MultimediaSavedModal
129,187
17.07.2019 10:23:55
14,400
a73020695c0adbbbff811da07780b7e8014fa31d
[native] Use scrollDisabled to determine when Multimedia modals cloesd Was using `multimediaModalsClosed`, but that doesn't consider the time it takes to complete the transition.
[ { "change_type": "MODIFY", "old_path": "native/chat/message-list.react.js", "new_path": "native/chat/message-list.react.js", "diff": "@@ -84,7 +84,7 @@ type PropsAndState = {|\n...State,\n|};\ntype FlatListExtraData = {|\n- multimediaModalsClosed: bool,\n+ scrollDisabled: bool,\nkeyboardShowing: bool,\nmessageListVerticalBounds: ?VerticalBounds,\nfocusedMessageKey: ?string,\n@@ -111,13 +111,14 @@ class MessageList extends React.PureComponent<Props, State> {\nconstructor(props: Props) {\nsuper(props);\n+ const scrollDisabled = !props.multimediaModalsClosed;\nthis.state = {\nfocusedMessageKey: null,\n- scrollDisabled: false,\n+ scrollDisabled,\nmessageListVerticalBounds: null,\nkeyboardShowing: false,\nflatListExtraData: {\n- multimediaModalsClosed: props.multimediaModalsClosed,\n+ scrollDisabled,\nkeyboardShowing: props.imageGalleryOpen,\nmessageListVerticalBounds: null,\nfocusedMessageKey: null,\n@@ -126,19 +127,19 @@ class MessageList extends React.PureComponent<Props, State> {\n}\nstatic flatListExtraDataSelector = createSelector(\n- (propsAndState: PropsAndState) => propsAndState.multimediaModalsClosed,\n+ (propsAndState: PropsAndState) => propsAndState.scrollDisabled,\n(propsAndState: PropsAndState) => propsAndState.keyboardShowing,\n(propsAndState: PropsAndState) => propsAndState.messageListVerticalBounds,\n(propsAndState: PropsAndState) => propsAndState.imageGalleryOpen,\n(propsAndState: PropsAndState) => propsAndState.focusedMessageKey,\n(\n- multimediaModalsClosed: bool,\n+ scrollDisabled: bool,\nkeyboardShowing: bool,\nmessageListVerticalBounds: ?VerticalBounds,\nimageGalleryOpen: bool,\nfocusedMessageKey: ?string,\n) => ({\n- multimediaModalsClosed,\n+ scrollDisabled,\nkeyboardShowing: keyboardShowing || imageGalleryOpen,\nmessageListVerticalBounds,\nfocusedMessageKey,\n@@ -246,7 +247,7 @@ class MessageList extends React.PureComponent<Props, State> {\n}\nconst messageInfoItem: ChatMessageInfoItemWithHeight = row.item;\nconst {\n- multimediaModalsClosed,\n+ scrollDisabled,\nkeyboardShowing,\nmessageListVerticalBounds,\nfocusedMessageKey,\n@@ -262,7 +263,7 @@ class MessageList extends React.PureComponent<Props, State> {\nsetScrollDisabled={this.setScrollDisabled}\nverticalBounds={messageListVerticalBounds}\nkeyboardShowing={keyboardShowing}\n- multimediaModalsClosed={multimediaModalsClosed}\n+ scrollDisabled={scrollDisabled}\n/>\n);\n}\n" }, { "change_type": "MODIFY", "old_path": "native/chat/message.react.js", "new_path": "native/chat/message.react.js", "diff": "@@ -68,7 +68,7 @@ type Props = {|\nsetScrollDisabled: (scrollDisabled: bool) => void,\nverticalBounds: ?VerticalBounds,\nkeyboardShowing: bool,\n- multimediaModalsClosed: bool,\n+ scrollDisabled: bool,\n|};\nclass Message extends React.PureComponent<Props> {\n@@ -80,7 +80,7 @@ class Message extends React.PureComponent<Props> {\nsetScrollDisabled: PropTypes.func.isRequired,\nverticalBounds: verticalBoundsPropType,\nkeyboardShowing: PropTypes.bool.isRequired,\n- multimediaModalsClosed: PropTypes.bool.isRequired,\n+ scrollDisabled: PropTypes.bool.isRequired,\n};\ncomponentDidUpdate(prevProps: Props) {\n@@ -119,7 +119,7 @@ class Message extends React.PureComponent<Props> {\ntoggleFocus={this.props.toggleFocus}\nverticalBounds={this.props.verticalBounds}\nkeyboardShowing={this.props.keyboardShowing}\n- modalsClosed={this.props.multimediaModalsClosed}\n+ scrollDisabled={this.props.scrollDisabled}\n/>\n);\n} else {\n" }, { "change_type": "MODIFY", "old_path": "native/chat/multimedia-message-multimedia.react.js", "new_path": "native/chat/multimedia-message-multimedia.react.js", "diff": "@@ -32,7 +32,7 @@ type Props = {|\nverticalBounds: ?VerticalBounds,\nverticalOffset: number,\nstyle: ImageStyle,\n- modalsClosed: bool,\n+ scrollDisabled: bool,\nlightboxPosition: ?Animated.Value,\npostInProgress: bool,\npendingUpload: ?PendingMultimediaUpload,\n@@ -51,7 +51,7 @@ class MultimediaMessageMultimedia extends React.PureComponent<Props, State> {\nnavigate: PropTypes.func.isRequired,\nverticalBounds: verticalBoundsPropType,\nverticalOffset: PropTypes.number.isRequired,\n- modalsClosed: PropTypes.bool.isRequired,\n+ scrollDisabled: PropTypes.bool.isRequired,\nlightboxPosition: PropTypes.instanceOf(Animated.Value),\npostInProgress: PropTypes.bool.isRequired,\npendingUpload: pendingMultimediaUploadPropType,\n@@ -71,7 +71,7 @@ class MultimediaMessageMultimedia extends React.PureComponent<Props, State> {\n}\nstatic getDerivedStateFromProps(props: Props, state: State) {\n- if (props.modalsClosed && state.hidden) {\n+ if (!props.scrollDisabled && state.hidden) {\nreturn { hidden: false };\n}\nreturn null;\n@@ -97,7 +97,7 @@ class MultimediaMessageMultimedia extends React.PureComponent<Props, State> {\nthis.setState({ opacity: this.getOpacity() });\n}\n- if (this.props.modalsClosed && !prevProps.modalsClosed) {\n+ if (!this.props.scrollDisabled && prevProps.scrollDisabled) {\nthis.clickable = true;\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "native/chat/multimedia-message.react.js", "new_path": "native/chat/multimedia-message.react.js", "diff": "@@ -152,7 +152,7 @@ type Props = {|\ntoggleFocus: (messageKey: string) => void,\nverticalBounds: ?VerticalBounds,\nkeyboardShowing: bool,\n- modalsClosed: bool,\n+ scrollDisabled: bool,\n// withLightboxPositionContext\nlightboxPosition: ?Animated.Value,\n|};\n@@ -165,14 +165,14 @@ class MultimediaMessage extends React.PureComponent<Props> {\ntoggleFocus: PropTypes.func.isRequired,\nverticalBounds: verticalBoundsPropType,\nkeyboardShowing: PropTypes.bool.isRequired,\n- modalsClosed: PropTypes.bool.isRequired,\n+ scrollDisabled: PropTypes.bool.isRequired,\nlightboxPosition: PropTypes.instanceOf(Animated.Value),\n};\ncomponentDidUpdate(prevProps: Props) {\nif (\n- this.props.modalsClosed &&\n- !prevProps.modalsClosed &&\n+ !this.props.scrollDisabled &&\n+ prevProps.scrollDisabled &&\nthis.props.focused\n) {\nthis.props.toggleFocus(messageKey(this.props.item.messageInfo));\n@@ -292,7 +292,7 @@ class MultimediaMessage extends React.PureComponent<Props> {\nverticalBounds={this.props.verticalBounds}\nverticalOffset={verticalOffset}\nstyle={[ style, roundedStyle ]}\n- modalsClosed={this.props.modalsClosed}\n+ scrollDisabled={this.props.scrollDisabled}\nlightboxPosition={this.props.lightboxPosition}\npostInProgress={!!pendingUploads}\npendingUpload={pendingUpload}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Use scrollDisabled to determine when Multimedia modals cloesd Was using `multimediaModalsClosed`, but that doesn't consider the time it takes to complete the transition.
129,187
17.07.2019 10:38:20
14,400
b73e0db360ef86f3a7087b3b4fcfa528c7a2d88e
[native] multimediaModals -> scrollBlockingChatModals
[ { "change_type": "MODIFY", "old_path": "native/chat/message-list.react.js", "new_path": "native/chat/message-list.react.js", "diff": "@@ -47,7 +47,7 @@ import {\nremoveKeyboardListener,\n} from '../keyboard';\nimport {\n- multimediaModalsClosedSelector,\n+ scrollBlockingChatModalsClosedSelector,\nlightboxTransitioningSelector,\n} from '../selectors/nav-selectors';\n@@ -59,7 +59,7 @@ type Props = {|\n// Redux state\nviewerID: ?string,\nstartReached: bool,\n- multimediaModalsClosed: bool,\n+ scrollBlockingModalsClosed: bool,\nlightboxIsTransitioning: bool,\n// Redux dispatch functions\ndispatchActionPromise: DispatchActionPromise,\n@@ -98,7 +98,7 @@ class MessageList extends React.PureComponent<Props, State> {\nimageGalleryOpen: PropTypes.bool.isRequired,\nviewerID: PropTypes.string,\nstartReached: PropTypes.bool.isRequired,\n- multimediaModalsClosed: PropTypes.bool.isRequired,\n+ scrollBlockingModalsClosed: PropTypes.bool.isRequired,\nlightboxIsTransitioning: PropTypes.bool.isRequired,\ndispatchActionPromise: PropTypes.func.isRequired,\nfetchMessagesBeforeCursor: PropTypes.func.isRequired,\n@@ -111,7 +111,7 @@ class MessageList extends React.PureComponent<Props, State> {\nconstructor(props: Props) {\nsuper(props);\n- const scrollDisabled = !props.multimediaModalsClosed;\n+ const scrollDisabled = !props.scrollBlockingModalsClosed;\nthis.state = {\nfocusedMessageKey: null,\nscrollDisabled,\n@@ -223,13 +223,13 @@ class MessageList extends React.PureComponent<Props, State> {\nif (\nthis.state.scrollDisabled &&\n- this.props.multimediaModalsClosed &&\n+ this.props.scrollBlockingModalsClosed &&\n!this.props.lightboxIsTransitioning\n) {\nthis.setState({ scrollDisabled: false });\n} else if (\n!this.state.scrollDisabled &&\n- !this.props.multimediaModalsClosed\n+ !this.props.scrollBlockingModalsClosed\n) {\nthis.setState({ scrollDisabled: true });\n}\n@@ -435,7 +435,7 @@ export default connect(\nviewerID: state.currentUserInfo && state.currentUserInfo.id,\nstartReached: !!(state.messageStore.threads[threadID] &&\nstate.messageStore.threads[threadID].startReached),\n- multimediaModalsClosed: multimediaModalsClosedSelector(state),\n+ scrollBlockingModalsClosed: scrollBlockingChatModalsClosedSelector(state),\nlightboxIsTransitioning: lightboxTransitioningSelector(state),\n};\n},\n" }, { "change_type": "MODIFY", "old_path": "native/navigation/route-names.js", "new_path": "native/navigation/route-names.js", "diff": "@@ -44,8 +44,7 @@ export const accountModals = [\nVerificationModalRouteName,\n];\n-// Only includes the modals that block scroll\n-export const multimediaModals = [\n+export const scrollBlockingChatModals = [\nMultimediaModalRouteName,\nMultimediaTooltipModalRouteName,\n];\n" }, { "change_type": "MODIFY", "old_path": "native/selectors/nav-selectors.js", "new_path": "native/selectors/nav-selectors.js", "diff": "@@ -23,7 +23,7 @@ import {\nCalendarRouteName,\nThreadPickerModalRouteName,\naccountModals,\n- multimediaModals,\n+ scrollBlockingChatModals,\n} from '../navigation/route-names';\nimport {\nassertNavigationRouteNotLeafNode,\n@@ -72,7 +72,7 @@ const createActiveTabSelector: (\nrouteName: string,\n) => (state: AppState) => bool = _memoize(baseCreateActiveTabSelector);\n-const multimediaModalsClosedSelector: (\n+const scrollBlockingChatModalsClosedSelector: (\nstate: AppState,\n) => bool = createSelector(\n(state: AppState) => state.navInfo.navigationState,\n@@ -83,7 +83,7 @@ const multimediaModalsClosedSelector: (\n}\nconst appRoute = assertNavigationRouteNotLeafNode(currentRootSubroute);\nconst currentAppSubroute = appRoute.routes[appRoute.index];\n- return !multimediaModals.includes(currentAppSubroute.routeName);\n+ return !scrollBlockingChatModals.includes(currentAppSubroute.routeName);\n},\n);\n@@ -196,7 +196,7 @@ export {\nappLoggedInSelector,\nforegroundKeySelector,\ncreateActiveTabSelector,\n- multimediaModalsClosedSelector,\n+ scrollBlockingChatModalsClosedSelector,\nlightboxTransitioningSelector,\nactiveThreadSelector,\nappCanRespondToBackButtonSelector,\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] multimediaModals -> scrollBlockingChatModals
129,187
17.07.2019 16:08:59
14,400
f764e6e665028813b182ee64cedb5178660edb66
[native] Some MultimediaTooltipModal cleanup
[ { "change_type": "MODIFY", "old_path": "native/chat/multimedia-message-multimedia.react.js", "new_path": "native/chat/multimedia-message-multimedia.react.js", "diff": "@@ -132,6 +132,11 @@ class MultimediaMessageMultimedia extends React.PureComponent<Props, State> {\n}\nonPress = () => {\n+ if (this.props.keyboardShowing) {\n+ KeyboardUtils.dismiss();\n+ return;\n+ }\n+\nconst { view, props: { verticalBounds } } = this;\nif (!view || !verticalBounds) {\nreturn;\n" }, { "change_type": "MODIFY", "old_path": "native/chat/multimedia-tooltip-button.react.js", "new_path": "native/chat/multimedia-tooltip-button.react.js", "diff": "@@ -80,7 +80,10 @@ class MultimediaTooltipButton extends React.PureComponent<Props> {\n};\nget timestampStyle() {\n- const { initialCoordinates, verticalOffset } = this.props.navigation.state.params;\n+ const {\n+ initialCoordinates,\n+ verticalOffset,\n+ } = this.props.navigation.state.params;\nconst top = -26 - verticalOffset;\nreturn {\nposition: 'absolute',\n@@ -138,7 +141,6 @@ class MultimediaTooltipButton extends React.PureComponent<Props> {\n}\n-\nconst styles = StyleSheet.create({\nmedia: {\nflex: 1,\n" }, { "change_type": "MODIFY", "old_path": "native/chat/multimedia-tooltip-modal.react.js", "new_path": "native/chat/multimedia-tooltip-modal.react.js", "diff": "// @flow\n-import { StyleSheet } from 'react-native';\n-\nimport type { MediaInfo } from 'lib/types/media-types';\n-import { createTooltip, tooltipHeight } from '../components/tooltip2.react';\n+import { StyleSheet } from 'react-native';\n+import { createTooltip, tooltipHeight } from '../components/tooltip2.react';\nimport MultimediaTooltipButton from './multimedia-tooltip-button.react';\nimport { saveImage } from '../media/save-image';\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Some MultimediaTooltipModal cleanup
129,187
17.07.2019 16:22:24
14,400
b8e7f2587902cda18c50e6df8410518031691dc4
[native] Freeze scroll before navigating to MultimediaTooltipModal Freezes it before the `measure` call to make sure we get coordinates that don't change.
[ { "change_type": "MODIFY", "old_path": "native/chat/message.react.js", "new_path": "native/chat/message.react.js", "diff": "@@ -117,6 +117,7 @@ class Message extends React.PureComponent<Props> {\nnavigate={this.props.navigate}\nfocused={this.props.focused}\ntoggleFocus={this.props.toggleFocus}\n+ setScrollDisabled={this.props.setScrollDisabled}\nverticalBounds={this.props.verticalBounds}\nkeyboardShowing={this.props.keyboardShowing}\nscrollDisabled={this.props.scrollDisabled}\n" }, { "change_type": "MODIFY", "old_path": "native/chat/multimedia-message-multimedia.react.js", "new_path": "native/chat/multimedia-message-multimedia.react.js", "diff": "@@ -39,6 +39,7 @@ type Props = {|\nkeyboardShowing: bool,\nmessageFocused: bool,\ntoggleMessageFocus: (messageKey: string) => void,\n+ setScrollDisabled: (scrollDisabled: bool) => void,\n|};\ntype State = {|\nhidden: bool,\n@@ -58,6 +59,7 @@ class MultimediaMessageMultimedia extends React.PureComponent<Props, State> {\nkeyboardShowing: PropTypes.bool.isRequired,\nmessageFocused: PropTypes.bool.isRequired,\ntoggleMessageFocus: PropTypes.func.isRequired,\n+ setScrollDisabled: PropTypes.func.isRequired,\n};\nview: ?View;\nclickable = true;\n@@ -147,10 +149,12 @@ class MultimediaMessageMultimedia extends React.PureComponent<Props, State> {\n}\nthis.clickable = false;\n+ const { setScrollDisabled, mediaInfo } = this.props;\n+ setScrollDisabled(true);\n+\nview.measure((x, y, width, height, pageX, pageY) => {\nconst coordinates = { x: pageX, y: pageY, width, height };\n- const { mediaInfo, navigate } = this.props;\n- navigate({\n+ this.props.navigate({\nrouteName: MultimediaModalRouteName,\nparams: { mediaInfo, initialCoordinates: coordinates, verticalBounds },\n});\n@@ -164,7 +168,7 @@ class MultimediaMessageMultimedia extends React.PureComponent<Props, State> {\nreturn;\n}\n- const { view, props: { verticalBounds, verticalOffset } } = this;\n+ const { view, props: { verticalBounds } } = this;\nif (!view || !verticalBounds) {\nreturn;\n}\n@@ -174,9 +178,17 @@ class MultimediaMessageMultimedia extends React.PureComponent<Props, State> {\n}\nthis.clickable = false;\n- if (!this.props.messageFocused) {\n- this.props.toggleMessageFocus(this.props.mediaInfo.messageKey);\n+ const {\n+ messageFocused,\n+ toggleMessageFocus,\n+ setScrollDisabled,\n+ mediaInfo,\n+ verticalOffset,\n+ } = this.props;\n+ if (!messageFocused) {\n+ toggleMessageFocus(mediaInfo.messageKey);\n}\n+ setScrollDisabled(true);\nview.measure((x, y, width, height, pageX, pageY) => {\nconst coordinates = { x: pageX, y: pageY, width, height };\n@@ -200,8 +212,7 @@ class MultimediaMessageMultimedia extends React.PureComponent<Props, State> {\nmargin = aboveMargin;\n}\n- const { mediaInfo, navigate } = this.props;\n- navigate({\n+ this.props.navigate({\nrouteName: MultimediaTooltipModalRouteName,\nparams: {\nmediaInfo,\n" }, { "change_type": "MODIFY", "old_path": "native/chat/multimedia-message.react.js", "new_path": "native/chat/multimedia-message.react.js", "diff": "@@ -150,6 +150,7 @@ type Props = {|\nnavigate: Navigate,\nfocused: bool,\ntoggleFocus: (messageKey: string) => void,\n+ setScrollDisabled: (scrollDisabled: bool) => void,\nverticalBounds: ?VerticalBounds,\nkeyboardShowing: bool,\nscrollDisabled: bool,\n@@ -163,6 +164,7 @@ class MultimediaMessage extends React.PureComponent<Props> {\nnavigate: PropTypes.func.isRequired,\nfocused: PropTypes.bool.isRequired,\ntoggleFocus: PropTypes.func.isRequired,\n+ setScrollDisabled: PropTypes.func.isRequired,\nverticalBounds: verticalBoundsPropType,\nkeyboardShowing: PropTypes.bool.isRequired,\nscrollDisabled: PropTypes.bool.isRequired,\n@@ -299,6 +301,7 @@ class MultimediaMessage extends React.PureComponent<Props> {\nkeyboardShowing={this.props.keyboardShowing}\nmessageFocused={this.props.focused}\ntoggleMessageFocus={this.props.toggleFocus}\n+ setScrollDisabled={this.props.setScrollDisabled}\nkey={index}\n/>\n);\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Freeze scroll before navigating to MultimediaTooltipModal Freezes it before the `measure` call to make sure we get coordinates that don't change.
129,187
17.07.2019 18:27:27
14,400
ebd62f4d9d62e3b3b95241634f021caf47f88e8a
[native] TextMessageTooltipModal
[ { "change_type": "ADD", "old_path": null, "new_path": "native/chat/inner-text-message.react.js", "diff": "+// @flow\n+\n+import { chatMessageItemPropType } from 'lib/selectors/chat-selectors';\n+import type { ChatTextMessageInfoItemWithHeight } from './text-message.react';\n+\n+import * as React from 'react';\n+import { View, Text, StyleSheet } from 'react-native';\n+import PropTypes from 'prop-types';\n+import Color from 'color';\n+import Hyperlink from 'react-native-hyperlink';\n+\n+import { colorIsDark } from 'lib/shared/thread-utils';\n+import { onlyEmojiRegex } from 'lib/shared/emojis';\n+\n+import { RoundedMessageContainer } from './rounded-message-container.react';\n+\n+type Props = {|\n+ item: ChatTextMessageInfoItemWithHeight,\n+ focused: bool,\n+ onPress: () => void,\n+ messageRef?: (message: ?View) => void,\n+|};\n+class InnerTextMessage extends React.PureComponent<Props> {\n+\n+ static propTypes = {\n+ item: chatMessageItemPropType.isRequired,\n+ focused: PropTypes.bool.isRequired,\n+ onPress: PropTypes.func.isRequired,\n+ messageRef: PropTypes.func,\n+ };\n+\n+ render() {\n+ const { item } = this.props;\n+ const { text, id, creator } = item.messageInfo;\n+ const { isViewer } = creator;\n+\n+ let messageStyle = {}, textCustomStyle = {}, darkColor = false;\n+ if (isViewer) {\n+ const threadColor = item.threadInfo.color;\n+ messageStyle.backgroundColor = `#${threadColor}`;\n+ darkColor = colorIsDark(threadColor);\n+ textCustomStyle.color = darkColor ? 'white' : 'black';\n+ } else {\n+ messageStyle.backgroundColor = \"#DDDDDDBB\";\n+ textCustomStyle.color = 'black';\n+ }\n+ if (this.props.focused) {\n+ messageStyle.backgroundColor =\n+ Color(messageStyle.backgroundColor).darken(0.15).hex();\n+ }\n+ textCustomStyle.height = item.contentHeight;\n+\n+ const linkStyle = darkColor ? styles.lightLinkText : styles.darkLinkText;\n+ const textStyle = onlyEmojiRegex.test(text)\n+ ? styles.emojiOnlyText\n+ : styles.text;\n+\n+ const message = (\n+ <RoundedMessageContainer item={item}>\n+ <Hyperlink\n+ linkDefault={true}\n+ style={[styles.message, messageStyle]}\n+ linkStyle={linkStyle}\n+ >\n+ <Text\n+ onPress={this.props.onPress}\n+ onLongPress={this.props.onPress}\n+ style={[textStyle, textCustomStyle]}\n+ >{text}</Text>\n+ </Hyperlink>\n+ </RoundedMessageContainer>\n+ );\n+\n+ const { messageRef } = this.props;\n+ if (!messageRef) {\n+ return message;\n+ }\n+\n+ return (\n+ <View onLayout={this.onLayout} ref={messageRef}>\n+ {message}\n+ </View>\n+ );\n+ }\n+\n+ onLayout = () => {}\n+\n+}\n+\n+const styles = StyleSheet.create({\n+ text: {\n+ fontSize: 18,\n+ fontFamily: 'Arial',\n+ },\n+ emojiOnlyText: {\n+ fontSize: 36,\n+ fontFamily: 'Arial',\n+ },\n+ message: {\n+ paddingVertical: 6,\n+ paddingHorizontal: 12,\n+ },\n+ darkLinkText: {\n+ color: \"#036AFF\",\n+ textDecorationLine: \"underline\",\n+ },\n+ lightLinkText: {\n+ color: \"#129AFF\",\n+ textDecorationLine: \"underline\",\n+ },\n+ popoverLabelStyle: {\n+ textAlign: 'center',\n+ color: '#444',\n+ },\n+});\n+\n+export default InnerTextMessage;\n" }, { "change_type": "MODIFY", "old_path": "native/chat/message.react.js", "new_path": "native/chat/message.react.js", "diff": "@@ -104,10 +104,13 @@ class Message extends React.PureComponent<Props> {\nmessage = (\n<TextMessage\nitem={this.props.item}\n+ navigate={this.props.navigate}\nfocused={this.props.focused}\ntoggleFocus={this.props.toggleFocus}\nsetScrollDisabled={this.props.setScrollDisabled}\n+ verticalBounds={this.props.verticalBounds}\nkeyboardShowing={this.props.keyboardShowing}\n+ scrollDisabled={this.props.scrollDisabled}\n/>\n);\n} else if (this.props.item.messageShapeType === \"multimedia\") {\n" }, { "change_type": "MODIFY", "old_path": "native/chat/rounded-message-container.react.js", "new_path": "native/chat/rounded-message-container.react.js", "diff": "@@ -78,6 +78,7 @@ class RoundedMessageContainer extends React.PureComponent<Props> {\nconst styles = StyleSheet.create({\nmessage: {\n+ backgroundColor: 'white',\noverflow: 'hidden',\n},\n});\n" }, { "change_type": "ADD", "old_path": null, "new_path": "native/chat/text-message-tooltip-button.react.js", "diff": "+// @flow\n+\n+import type { ChatTextMessageInfoItemWithHeight } from './text-message.react';\n+import {\n+ type VerticalBounds,\n+ verticalBoundsPropType,\n+ type LayoutCoordinates,\n+ layoutCoordinatesPropType,\n+} from '../types/lightbox-types';\n+import type {\n+ NavigationScreenProp,\n+ NavigationLeafRoute,\n+} from 'react-navigation';\n+import { type Dimensions, dimensionsPropType } from 'lib/types/media-types';\n+import { chatMessageItemPropType } from 'lib/selectors/chat-selectors';\n+import type { AppState } from '../redux/redux-setup';\n+\n+import * as React from 'react';\n+import { View } from 'react-native';\n+import PropTypes from 'prop-types';\n+\n+import { connect } from 'lib/utils/redux-utils';\n+\n+import { dimensionsSelector } from '../selectors/dimension-selectors';\n+import Timestamp from './timestamp.react';\n+import InnerTextMessage from './inner-text-message.react';\n+\n+type NavProp = NavigationScreenProp<{|\n+ ...NavigationLeafRoute,\n+ params: {\n+ // Tooltip props\n+ initialCoordinates: LayoutCoordinates,\n+ verticalBounds: VerticalBounds,\n+ location?: 'above' | 'below',\n+ margin?: number,\n+ // Custom props\n+ item: ChatTextMessageInfoItemWithHeight,\n+ },\n+|}>;\n+\n+type Props = {\n+ navigation: NavProp,\n+ // Redux state\n+ screenDimensions: Dimensions,\n+};\n+class TextMessageTooltipButton extends React.PureComponent<Props> {\n+\n+ static propTypes = {\n+ navigation: PropTypes.shape({\n+ state: PropTypes.shape({\n+ params: PropTypes.shape({\n+ initialCoordinates: layoutCoordinatesPropType.isRequired,\n+ verticalBounds: verticalBoundsPropType.isRequired,\n+ location: PropTypes.oneOf([ 'above', 'below' ]),\n+ margin: PropTypes.number,\n+ item: chatMessageItemPropType.isRequired,\n+ }).isRequired,\n+ }).isRequired,\n+ goBack: PropTypes.func.isRequired,\n+ }).isRequired,\n+ screenDimensions: dimensionsPropType.isRequired,\n+ };\n+\n+ get timestampStyle() {\n+ const { initialCoordinates } = this.props.navigation.state.params;\n+ return {\n+ position: 'absolute',\n+ left: -initialCoordinates.x,\n+ width: this.props.screenDimensions.width,\n+ top: -26,\n+ };\n+ }\n+\n+ get messageStyle() {\n+ const { item } = this.props.navigation.state.params;\n+ return {\n+ position: 'absolute',\n+ height: item.contentHeight,\n+ width: this.props.screenDimensions.width,\n+ left: 0,\n+ top: 0,\n+ };\n+ }\n+\n+ render() {\n+ const { item } = this.props.navigation.state.params;\n+ const { time } = item.messageInfo;\n+ return (\n+ <React.Fragment>\n+ <View style={this.timestampStyle}>\n+ <Timestamp time={time} color=\"light\" />\n+ </View>\n+ <InnerTextMessage\n+ item={item}\n+ focused={true}\n+ onPress={this.onPress}\n+ />\n+ </React.Fragment>\n+ );\n+ }\n+\n+ onPress = () => {\n+ this.props.navigation.goBack();\n+ }\n+\n+}\n+\n+export default connect((state: AppState) => ({\n+ screenDimensions: dimensionsSelector(state),\n+}))(TextMessageTooltipButton);\n" }, { "change_type": "ADD", "old_path": null, "new_path": "native/chat/text-message-tooltip-modal.react.js", "diff": "+// @flow\n+\n+import type { ChatTextMessageInfoItemWithHeight } from './text-message.react';\n+\n+import { Clipboard, StyleSheet } from 'react-native';\n+\n+import { createTooltip, tooltipHeight } from '../components/tooltip2.react';\n+import TextMessageTooltipButton from './text-message-tooltip-button.react';\n+\n+type CustomProps = {\n+ item: ChatTextMessageInfoItemWithHeight,\n+};\n+\n+function onPressCopy(props: CustomProps) {\n+ Clipboard.setString(props.item.messageInfo.text);\n+}\n+\n+const styles = StyleSheet.create({\n+ popoverLabelStyle: {\n+ textAlign: 'center',\n+ color: '#444',\n+ },\n+});\n+\n+const spec = {\n+ entries: [\n+ { text: \"Copy\", onPress: onPressCopy },\n+ ],\n+ labelStyle: styles.popoverLabelStyle,\n+};\n+\n+const TextMessageTooltipModal = createTooltip(TextMessageTooltipButton, spec);\n+\n+const textMessageTooltipHeight = tooltipHeight(spec.entries.length);\n+\n+export {\n+ TextMessageTooltipModal,\n+ textMessageTooltipHeight,\n+};\n" }, { "change_type": "MODIFY", "old_path": "native/chat/text-message.react.js", "new_path": "native/chat/text-message.react.js", "diff": "// @flow\nimport { chatMessageItemPropType } from 'lib/selectors/chat-selectors';\n-import type { TooltipItemData } from '../components/tooltip.react';\nimport type {\nTextMessageInfo,\nLocalMessageInfo,\n} from 'lib/types/message-types';\nimport type { ThreadInfo } from 'lib/types/thread-types';\n+import {\n+ type VerticalBounds,\n+ verticalBoundsPropType,\n+} from '../types/lightbox-types';\n+import type { Navigate } from '../navigation/route-names';\nimport * as React from 'react';\n-import { Text, StyleSheet, Clipboard } from 'react-native';\n-import invariant from 'invariant';\n+import { View } from 'react-native';\nimport PropTypes from 'prop-types';\n-import Color from 'color';\n-import Hyperlink from 'react-native-hyperlink';\nimport { KeyboardUtils } from 'react-native-keyboard-input';\n-import { colorIsDark } from 'lib/shared/thread-utils';\nimport { messageKey } from 'lib/shared/message-utils';\n-import { onlyEmojiRegex } from 'lib/shared/emojis';\n-import Tooltip from '../components/tooltip.react';\n+import InnerTextMessage from './inner-text-message.react';\n+import { textMessageTooltipHeight } from './text-message-tooltip-modal.react';\n+import { TextMessageTooltipModalRouteName } from '../navigation/route-names';\nimport ComposedMessage from './composed-message.react';\n-import { RoundedMessageContainer } from './rounded-message-container.react';\nexport type ChatTextMessageInfoItemWithHeight = {|\nitemType: \"message\",\n@@ -63,71 +63,42 @@ function textMessageItemHeight(\ntype Props = {|\nitem: ChatTextMessageInfoItemWithHeight,\n+ navigate: Navigate,\nfocused: bool,\ntoggleFocus: (messageKey: string) => void,\nsetScrollDisabled: (scrollDisabled: bool) => void,\n+ verticalBounds: ?VerticalBounds,\nkeyboardShowing: bool,\n+ scrollDisabled: bool,\n|};\nclass TextMessage extends React.PureComponent<Props> {\nstatic propTypes = {\nitem: chatMessageItemPropType.isRequired,\n+ navigate: PropTypes.func.isRequired,\nfocused: PropTypes.bool.isRequired,\ntoggleFocus: PropTypes.func.isRequired,\nsetScrollDisabled: PropTypes.func.isRequired,\n+ verticalBounds: verticalBoundsPropType,\nkeyboardShowing: PropTypes.bool.isRequired,\n+ scrollDisabled: PropTypes.bool.isRequired,\n};\n- tooltipConfig: $ReadOnlyArray<TooltipItemData>;\n- tooltip: ?Tooltip;\n-\n- constructor(props: Props) {\n- super(props);\n- this.tooltipConfig = [\n- { label: \"Copy\", onPress: this.onPressCopy },\n- ];\n+ message: ?View;\n+\n+ componentDidUpdate(prevProps: Props) {\n+ if (\n+ !this.props.scrollDisabled &&\n+ prevProps.scrollDisabled &&\n+ this.props.focused\n+ ) {\n+ this.props.toggleFocus(messageKey(this.props.item.messageInfo));\n+ }\n}\nrender() {\nconst { item } = this.props;\n- const { text, id, creator } = item.messageInfo;\n+ const { id, creator } = item.messageInfo;\nconst { isViewer } = creator;\n-\n- let messageStyle = {}, textCustomStyle = {}, darkColor = false;\n- if (isViewer) {\n- const threadColor = item.threadInfo.color;\n- messageStyle.backgroundColor = `#${threadColor}`;\n- darkColor = colorIsDark(threadColor);\n- textCustomStyle.color = darkColor ? 'white' : 'black';\n- } else {\n- messageStyle.backgroundColor = \"#DDDDDDBB\";\n- textCustomStyle.color = 'black';\n- }\n- if (this.props.focused) {\n- messageStyle.backgroundColor =\n- Color(messageStyle.backgroundColor).darken(0.15).hex();\n- }\n- textCustomStyle.height = item.contentHeight;\n-\n- const linkStyle = darkColor ? styles.lightLinkText : styles.darkLinkText;\n- const textStyle = onlyEmojiRegex.test(text)\n- ? styles.emojiOnlyText\n- : styles.text;\n- const messageBlob = (\n- <RoundedMessageContainer item={item}>\n- <Hyperlink\n- linkDefault={true}\n- style={[styles.message, messageStyle]}\n- linkStyle={linkStyle}\n- >\n- <Text\n- onPress={this.onPress}\n- onLongPress={this.onPress}\n- style={[textStyle, textCustomStyle]}\n- >{text}</Text>\n- </Hyperlink>\n- </RoundedMessageContainer>\n- );\n-\nconst sendFailed =\nisViewer &&\n(id === null || id === undefined) &&\n@@ -136,42 +107,21 @@ class TextMessage extends React.PureComponent<Props> {\nreturn (\n<ComposedMessage\n- item={item}\n+ item={this.props.item}\nsendFailed={!!sendFailed}\n>\n- <Tooltip\n- buttonComponent={messageBlob}\n- items={this.tooltipConfig}\n- labelStyle={styles.popoverLabelStyle}\n- onOpenTooltipMenu={this.onFocus}\n- onCloseTooltipMenu={this.onBlur}\n- onPressOverride={this.onPress}\n- innerRef={this.tooltipRef}\n+ <InnerTextMessage\n+ item={this.props.item}\n+ focused={this.props.focused}\n+ onPress={this.onPress}\n+ messageRef={this.messageRef}\n/>\n</ComposedMessage>\n);\n}\n- tooltipRef = (tooltip: ?Tooltip) => {\n- this.tooltip = tooltip;\n- }\n-\n- onFocus = () => {\n- this.props.setScrollDisabled(true);\n- if (!this.props.focused) {\n- this.props.toggleFocus(messageKey(this.props.item.messageInfo));\n- }\n- }\n-\n- onBlur = () => {\n- this.props.setScrollDisabled(false);\n- if (this.props.focused) {\n- this.props.toggleFocus(messageKey(this.props.item.messageInfo));\n- }\n- }\n-\n- onPressCopy = () => {\n- Clipboard.setString(this.props.item.messageInfo.text);\n+ messageRef = (message: ?View) => {\n+ this.message = message;\n}\nonPress = () => {\n@@ -179,43 +129,54 @@ class TextMessage extends React.PureComponent<Props> {\nKeyboardUtils.dismiss();\nreturn;\n}\n- const tooltip = this.tooltip;\n- invariant(tooltip, \"tooltip should be set\");\n- if (this.props.focused) {\n- tooltip.hideModal();\n- } else {\n- tooltip.openModal();\n- }\n+\n+ const { message, props: { verticalBounds } } = this;\n+ if (!message || !verticalBounds) {\n+ return;\n}\n+ const { focused, toggleFocus, item, setScrollDisabled } = this.props;\n+ if (!focused) {\n+ toggleFocus(messageKey(item.messageInfo));\n}\n+ setScrollDisabled(true);\n-const styles = StyleSheet.create({\n- text: {\n- fontSize: 18,\n- fontFamily: 'Arial',\n- },\n- emojiOnlyText: {\n- fontSize: 36,\n- fontFamily: 'Arial',\n- },\n- message: {\n- paddingVertical: 6,\n- paddingHorizontal: 12,\n- },\n- darkLinkText: {\n- color: \"#036AFF\",\n- textDecorationLine: \"underline\",\n- },\n- lightLinkText: {\n- color: \"#129AFF\",\n- textDecorationLine: \"underline\",\n- },\n- popoverLabelStyle: {\n- textAlign: 'center',\n- color: '#444',\n+ message.measure((x, y, width, height, pageX, pageY) => {\n+ const coordinates = { x: pageX, y: pageY, width, height };\n+\n+ const messageTop = pageY;\n+ const messageBottom = pageY + height;\n+ const boundsTop = verticalBounds.y;\n+ const boundsBottom = verticalBounds.y + verticalBounds.height;\n+\n+ const belowMargin = 20;\n+ const belowSpace = textMessageTooltipHeight + belowMargin;\n+ const aboveMargin = 30;\n+ const aboveSpace = textMessageTooltipHeight + aboveMargin;\n+\n+ let location = 'below', margin = belowMargin;\n+ if (\n+ messageBottom + belowSpace > boundsBottom &&\n+ messageTop - aboveSpace > boundsTop\n+ ) {\n+ location = 'above';\n+ margin = aboveMargin;\n+ }\n+\n+ this.props.navigate({\n+ routeName: TextMessageTooltipModalRouteName,\n+ params: {\n+ initialCoordinates: coordinates,\n+ verticalBounds,\n+ location,\n+ margin,\n+ item,\n},\n});\n+ });\n+ }\n+\n+}\nexport {\nTextMessage,\n" }, { "change_type": "MODIFY", "old_path": "native/navigation/navigation-setup.js", "new_path": "native/navigation/navigation-setup.js", "diff": "@@ -90,6 +90,7 @@ import {\nMultimediaModalRouteName,\nMultimediaTooltipModalRouteName,\nMultimediaSavedModalRouteName,\n+ TextMessageTooltipModalRouteName,\naccountModals,\n} from './route-names';\nimport {\n@@ -100,12 +101,16 @@ import ThreadPickerModal from '../calendar/thread-picker-modal.react';\nimport AddUsersModal from '../chat/settings/add-users-modal.react';\nimport CustomServerModal from '../more/custom-server-modal.react';\nimport ColorPickerModal from '../chat/settings/color-picker-modal.react';\n-import ComposeSubthreadModal from '../chat/settings/compose-subthread-modal.react';\n+import ComposeSubthreadModal\n+ from '../chat/settings/compose-subthread-modal.react';\nimport { createLightboxNavigator } from '../media/lightbox-navigator.react';\nimport MultimediaModal from '../media/multimedia-modal.react';\nimport { MultimediaTooltipModal } from '../chat/multimedia-tooltip-modal.react';\nimport ChatInputStateContainer from '../chat/chat-input-state-container.react';\nimport MultimediaSavedModal from '../media/multimedia-saved-modal.react';\n+import {\n+ TextMessageTooltipModal,\n+} from '../chat/text-message-tooltip-modal.react';\nuseScreens();\n@@ -169,6 +174,7 @@ const AppNavigator = createLightboxNavigator(\n[MultimediaModalRouteName]: MultimediaModal,\n[MultimediaTooltipModalRouteName]: MultimediaTooltipModal,\n[MultimediaSavedModalRouteName]: MultimediaSavedModal,\n+ [TextMessageTooltipModalRouteName]: TextMessageTooltipModal,\n},\n);\n" }, { "change_type": "MODIFY", "old_path": "native/navigation/route-names.js", "new_path": "native/navigation/route-names.js", "diff": "@@ -38,6 +38,7 @@ export const ComposeSubthreadModalRouteName = 'ComposeSubthreadModal';\nexport const MultimediaModalRouteName = 'MultimediaModal';\nexport const MultimediaTooltipModalRouteName = 'MultimediaTooltipModal';\nexport const MultimediaSavedModalRouteName = 'MultimediaSavedModal';\n+export const TextMessageTooltipModalRouteName = 'TextMessageTooltipModal';\nexport const accountModals = [\nLoggedOutModalRouteName,\n@@ -47,4 +48,5 @@ export const accountModals = [\nexport const scrollBlockingChatModals = [\nMultimediaModalRouteName,\nMultimediaTooltipModalRouteName,\n+ TextMessageTooltipModalRouteName,\n];\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] TextMessageTooltipModal
129,187
17.07.2019 18:35:34
14,400
3d14766810e81f89046daf896fc37ae64de173c7
[native] Let tooltip button decide how to apply opacity
[ { "change_type": "MODIFY", "old_path": "native/chat/multimedia-tooltip-button.react.js", "new_path": "native/chat/multimedia-tooltip-button.react.js", "diff": "@@ -20,6 +20,7 @@ import type { RawMessageInfo } from 'lib/types/message-types';\nimport type { AppState } from '../redux/redux-setup';\nimport * as React from 'react';\n+import Animated from 'react-native-reanimated';\nimport PropTypes from 'prop-types';\nimport { View, StyleSheet } from 'react-native';\n@@ -36,6 +37,8 @@ import { getRoundedContainerStyle } from './rounded-message-container.react';\nimport Timestamp from './timestamp.react';\nimport { dimensionsSelector } from '../selectors/dimension-selectors';\n+const { Value } = Animated;\n+\ntype NavProp = NavigationScreenProp<{|\n...NavigationLeafRoute,\nparams: {\n@@ -52,6 +55,7 @@ type NavProp = NavigationScreenProp<{|\ntype Props = {\nnavigation: NavProp,\n+ progress: Value,\n// Redux state\nrawMessageInfo: ?RawMessageInfo,\nscreenDimensions: Dimensions,\n@@ -74,6 +78,7 @@ class MultimediaTooltipButton extends React.PureComponent<Props> {\n}).isRequired,\ngoBack: PropTypes.func.isRequired,\n}).isRequired,\n+ progress: PropTypes.object.isRequired,\nrawMessageInfo: PropTypes.object,\nscreenDimensions: dimensionsPropType.isRequired,\nchatInputState: chatInputStatePropType,\n@@ -86,6 +91,7 @@ class MultimediaTooltipButton extends React.PureComponent<Props> {\n} = this.props.navigation.state.params;\nconst top = -26 - verticalOffset;\nreturn {\n+ opacity: this.props.progress,\nposition: 'absolute',\nleft: -initialCoordinates.x,\nwidth: this.props.screenDimensions.width,\n@@ -113,9 +119,9 @@ class MultimediaTooltipButton extends React.PureComponent<Props> {\nif (this.props.rawMessageInfo) {\nconst { time } = this.props.rawMessageInfo;\ntimestamp = (\n- <View style={this.timestampStyle}>\n+ <Animated.View style={this.timestampStyle}>\n<Timestamp time={time} color=\"light\" />\n- </View>\n+ </Animated.View>\n);\n}\n" }, { "change_type": "MODIFY", "old_path": "native/chat/text-message-tooltip-button.react.js", "new_path": "native/chat/text-message-tooltip-button.react.js", "diff": "@@ -16,6 +16,7 @@ import { chatMessageItemPropType } from 'lib/selectors/chat-selectors';\nimport type { AppState } from '../redux/redux-setup';\nimport * as React from 'react';\n+import Animated from 'react-native-reanimated';\nimport { View } from 'react-native';\nimport PropTypes from 'prop-types';\n@@ -25,6 +26,8 @@ import { dimensionsSelector } from '../selectors/dimension-selectors';\nimport Timestamp from './timestamp.react';\nimport InnerTextMessage from './inner-text-message.react';\n+const { Value } = Animated;\n+\ntype NavProp = NavigationScreenProp<{|\n...NavigationLeafRoute,\nparams: {\n@@ -40,6 +43,7 @@ type NavProp = NavigationScreenProp<{|\ntype Props = {\nnavigation: NavProp,\n+ progress: Value,\n// Redux state\nscreenDimensions: Dimensions,\n};\n@@ -58,12 +62,14 @@ class TextMessageTooltipButton extends React.PureComponent<Props> {\n}).isRequired,\ngoBack: PropTypes.func.isRequired,\n}).isRequired,\n+ progress: PropTypes.object.isRequired,\nscreenDimensions: dimensionsPropType.isRequired,\n};\nget timestampStyle() {\nconst { initialCoordinates } = this.props.navigation.state.params;\nreturn {\n+ opacity: this.props.progress,\nposition: 'absolute',\nleft: -initialCoordinates.x,\nwidth: this.props.screenDimensions.width,\n@@ -87,9 +93,9 @@ class TextMessageTooltipButton extends React.PureComponent<Props> {\nconst { time } = item.messageInfo;\nreturn (\n<React.Fragment>\n- <View style={this.timestampStyle}>\n+ <Animated.View style={this.timestampStyle}>\n<Timestamp time={time} color=\"light\" />\n- </View>\n+ </Animated.View>\n<InnerTextMessage\nitem={item}\nfocused={true}\n" }, { "change_type": "MODIFY", "old_path": "native/components/tooltip2.react.js", "new_path": "native/components/tooltip2.react.js", "diff": "@@ -18,7 +18,7 @@ import type { ViewStyle } from '../types/styles';\nimport type { TooltipEntry } from './tooltip2-item.react';\nimport * as React from 'react';\n-import Animated, { Easing } from 'react-native-reanimated';\n+import Animated from 'react-native-reanimated';\nimport {\nView,\nStyleSheet,\n@@ -60,6 +60,7 @@ type NavProp<CustomProps> = NavigationScreenProp<{|\ntype ButtonProps<Navigation> = {\nnavigation: Navigation,\n+ progress: Value,\n};\ntype TooltipProps<Navigation> = {\n@@ -157,7 +158,6 @@ function createTooltip<\n...styles.contentContainer,\nmarginTop: top,\nmarginBottom: bottom,\n- opacity: this.progress,\n};\n}\n@@ -251,11 +251,14 @@ function createTooltip<\n<TouchableWithoutFeedback onPress={this.onPressBackdrop}>\n<View style={styles.container}>\n<Animated.View style={this.opacityStyle} />\n- <Animated.View style={this.contentContainerStyle}>\n+ <View style={this.contentContainerStyle}>\n<View style={this.buttonStyle}>\n- <ButtonComponent navigation={navigation} />\n+ <ButtonComponent\n+ navigation={navigation}\n+ progress={this.progress}\n+ />\n+ </View>\n</View>\n- </Animated.View>\n<Animated.View style={this.tooltipContainerStyle}>\n{triangleUp}\n<View style={styles.entries}>\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Let tooltip button decide how to apply opacity
129,187
17.07.2019 18:38:39
14,400
3f35cefecc8e84a2cfa4707bb5bd1958f0e05063
[native] Stop changing color of chat bubble when selected We are darkening the background instead
[ { "change_type": "MODIFY", "old_path": "native/chat/inner-text-message.react.js", "new_path": "native/chat/inner-text-message.react.js", "diff": "@@ -6,7 +6,6 @@ import type { ChatTextMessageInfoItemWithHeight } from './text-message.react';\nimport * as React from 'react';\nimport { View, Text, StyleSheet } from 'react-native';\nimport PropTypes from 'prop-types';\n-import Color from 'color';\nimport Hyperlink from 'react-native-hyperlink';\nimport { colorIsDark } from 'lib/shared/thread-utils';\n@@ -16,7 +15,6 @@ import { RoundedMessageContainer } from './rounded-message-container.react';\ntype Props = {|\nitem: ChatTextMessageInfoItemWithHeight,\n- focused: bool,\nonPress: () => void,\nmessageRef?: (message: ?View) => void,\n|};\n@@ -24,7 +22,6 @@ class InnerTextMessage extends React.PureComponent<Props> {\nstatic propTypes = {\nitem: chatMessageItemPropType.isRequired,\n- focused: PropTypes.bool.isRequired,\nonPress: PropTypes.func.isRequired,\nmessageRef: PropTypes.func,\n};\n@@ -44,10 +41,6 @@ class InnerTextMessage extends React.PureComponent<Props> {\nmessageStyle.backgroundColor = \"#DDDDDDBB\";\ntextCustomStyle.color = 'black';\n}\n- if (this.props.focused) {\n- messageStyle.backgroundColor =\n- Color(messageStyle.backgroundColor).darken(0.15).hex();\n- }\ntextCustomStyle.height = item.contentHeight;\nconst linkStyle = darkColor ? styles.lightLinkText : styles.darkLinkText;\n" }, { "change_type": "MODIFY", "old_path": "native/chat/text-message-tooltip-button.react.js", "new_path": "native/chat/text-message-tooltip-button.react.js", "diff": "@@ -98,7 +98,6 @@ class TextMessageTooltipButton extends React.PureComponent<Props> {\n</Animated.View>\n<InnerTextMessage\nitem={item}\n- focused={true}\nonPress={this.onPress}\n/>\n</React.Fragment>\n" }, { "change_type": "MODIFY", "old_path": "native/chat/text-message.react.js", "new_path": "native/chat/text-message.react.js", "diff": "@@ -112,7 +112,6 @@ class TextMessage extends React.PureComponent<Props> {\n>\n<InnerTextMessage\nitem={this.props.item}\n- focused={this.props.focused}\nonPress={this.onPress}\nmessageRef={this.messageRef}\n/>\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Stop changing color of chat bubble when selected We are darkening the background instead