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
05.11.2019 11:39:49
18,000
31e10f1e8e2f7facb184c46523f5e0f6e7c44815
[server] Update debug Android fingerprint in assetlinks.json
[ { "change_type": "MODIFY", "old_path": "server/.well-known/assetlinks.json", "new_path": "server/.well-known/assetlinks.json", "diff": "\"namespace\": \"android_app\",\n\"package_name\": \"org.squadcal\",\n\"sha256_cert_fingerprints\": [\n- \"A8:81:32:91:5C:9A:D9:9E:14:68:1B:10:EA:5D:4E:D0:62:D0:BF:13:15:77:AA:BF:1D:C9:E6:67:ED:AD:E7:6F\",\n+ \"72:30:5F:18:19:A7:3A:93:97:9B:76:14:4C:88:8D:38:A2:5D:77:F1:7D:B5:C8:0A:B6:4C:F7:7E:68:DC:C3:6E\",\n\"78:8A:30:DF:7E:1F:AB:0E:F6:2B:69:8B:98:21:00:FE:97:E7:EB:34:AD:21:45:50:7D:A1:EE:CF:74:C8:FD:0D\"\n]\n}\n\"namespace\": \"android_app\",\n\"package_name\": \"org.squadcal\",\n\"sha256_cert_fingerprints\": [\n- \"A8:81:32:91:5C:9A:D9:9E:14:68:1B:10:EA:5D:4E:D0:62:D0:BF:13:15:77:AA:BF:1D:C9:E6:67:ED:AD:E7:6F\",\n+ \"72:30:5F:18:19:A7:3A:93:97:9B:76:14:4C:88:8D:38:A2:5D:77:F1:7D:B5:C8:0A:B6:4C:F7:7E:68:DC:C3:6E\",\n\"78:8A:30:DF:7E:1F:AB:0E:F6:2B:69:8B:98:21:00:FE:97:E7:EB:34:AD:21:45:50:7D:A1:EE:CF:74:C8:FD:0D\"\n]\n}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[server] Update debug Android fingerprint in assetlinks.json
129,187
05.11.2019 13:16:36
18,000
a614ccdd887ac258fb1eb09ee4b4a15f61d9e6dd
[native] Store DeviceCameraInfo in Redux
[ { "change_type": "MODIFY", "old_path": "native/media/camera-modal.react.js", "new_path": "native/media/camera-modal.react.js", "diff": "@@ -8,6 +8,12 @@ import type {\n} from 'react-navigation-stack';\nimport type { AppState } from '../redux/redux-setup';\nimport { type Dimensions, dimensionsPropType } from 'lib/types/media-types';\n+import type { DispatchActionPayload } from 'lib/utils/action-utils';\n+import { updateDeviceCameraInfoActionType } from '../redux/action-types';\n+import {\n+ type DeviceCameraInfo,\n+ deviceCameraInfoPropType,\n+} from '../types/camera';\nimport * as React from 'react';\nimport {\n@@ -70,10 +76,8 @@ const permissionRationale = {\ntitle: \"Access Your Camera\",\nmessage: \"Requesting access to your device camera\",\n};\n-let hasCamerasOnBothSides = true;\n-let defaultUseFrontCamera = false;\n-type Props = {|\n+type Props = {\nnavigation: NavigationStackProp<NavigationLeafRoute>,\nscene: NavigationStackScene,\ntransitionProps: NavigationStackTransitionProps,\n@@ -81,7 +85,10 @@ type Props = {|\n// Redux state\nscreenDimensions: Dimensions,\ncontentVerticalOffset: number,\n-|};\n+ deviceCameraInfo: DeviceCameraInfo,\n+ // Redux dispatch functions\n+ dispatchActionPayload: DispatchActionPayload,\n+};\ntype State = {|\nzoom: number,\nuseFrontCamera: bool,\n@@ -98,11 +105,8 @@ class CameraModal extends React.PureComponent<Props, State> {\nposition: PropTypes.instanceOf(Value).isRequired,\nscreenDimensions: dimensionsPropType.isRequired,\ncontentVerticalOffset: PropTypes.number.isRequired,\n- };\n- state = {\n- zoom: 0,\n- useFrontCamera: defaultUseFrontCamera,\n- hasCamerasOnBothSides,\n+ deviceCameraInfo: deviceCameraInfoPropType.isRequired,\n+ dispatchActionPayload: PropTypes.func.isRequired,\n};\ncamera: ?RNCamera;\n@@ -132,6 +136,12 @@ class CameraModal extends React.PureComponent<Props, State> {\nconstructor(props: Props) {\nsuper(props);\n+ this.state = {\n+ zoom: 0,\n+ useFrontCamera: props.deviceCameraInfo.defaultUseFrontCamera,\n+ hasCamerasOnBothSides: props.deviceCameraInfo.hasCamerasOnBothSides,\n+ };\n+\nconst { position } = props;\nconst { index } = props.scene;\nthis.progress = interpolate(\n@@ -381,11 +391,24 @@ class CameraModal extends React.PureComponent<Props, State> {\ni++;\n}\n- hasCamerasOnBothSides = hasFront && hasBack;\n- defaultUseFrontCamera = !hasBack && hasFront;\n+ const hasCamerasOnBothSides = hasFront && hasBack;\n+ const defaultUseFrontCamera = !hasBack && hasFront;\nif (hasCamerasOnBothSides !== this.state.hasCamerasOnBothSides) {\nthis.setState({ hasCamerasOnBothSides });\n}\n+ const {\n+ hasCamerasOnBothSides: oldHasCamerasOnBothSides,\n+ defaultUseFrontCamera: oldDefaultUseFrontCamera,\n+ } = this.props.deviceCameraInfo;\n+ if (\n+ hasCamerasOnBothSides !== oldHasCamerasOnBothSides ||\n+ defaultUseFrontCamera !== oldDefaultUseFrontCamera\n+ ) {\n+ this.props.dispatchActionPayload(\n+ updateDeviceCameraInfoActionType,\n+ { hasCamerasOnBothSides, defaultUseFrontCamera },\n+ );\n+ }\n}\n}\n@@ -453,5 +476,8 @@ export default connect(\n(state: AppState) => ({\nscreenDimensions: dimensionsSelector(state),\ncontentVerticalOffset: contentVerticalOffsetSelector(state),\n+ deviceCameraInfo: state.deviceCameraInfo,\n}),\n+ null,\n+ true,\n)(CameraModal);\n" }, { "change_type": "MODIFY", "old_path": "native/redux/action-types.js", "new_path": "native/redux/action-types.js", "diff": "@@ -14,3 +14,4 @@ export const rescindAndroidNotificationActionType =\nexport const updateDimensionsActiveType = \"UPDATE_DIMENSIONS\";\nexport const updateConnectivityActiveType = \"UPDATE_CONNECTIVITY\";\nexport const updateThemeInfoActionType = \"UPDATE_THEME_INFO\";\n+export const updateDeviceCameraInfoActionType = \"UPDATE_DEVICE_CAMERA_INFO\";\n" }, { "change_type": "MODIFY", "old_path": "native/redux/persist.js", "new_path": "native/redux/persist.js", "diff": "@@ -5,6 +5,7 @@ import { defaultCalendarFilters } from 'lib/types/filter-types';\nimport { defaultConnectionInfo } from 'lib/types/socket-types';\nimport { messageTypes } from 'lib/types/message-types';\nimport { defaultGlobalThemeInfo } from '../types/themes';\n+import { defaultDeviceCameraInfo } from '../types/camera';\nimport { createMigrate } from 'redux-persist';\nimport invariant from 'invariant';\n@@ -136,6 +137,10 @@ const migrations = {\n...state,\nglobalThemeInfo: defaultGlobalThemeInfo,\n}),\n+ [13]: (state: AppState) => ({\n+ ...state,\n+ deviceCameraInfo: defaultDeviceCameraInfo,\n+ }),\n};\nconst persistConfig = {\n@@ -143,7 +148,7 @@ const persistConfig = {\nstorage: AsyncStorage,\nblacklist,\ndebug: __DEV__,\n- version: 12,\n+ version: 13,\nmigrate: createMigrate(migrations, { debug: __DEV__ }),\ntimeout: __DEV__ ? 0 : undefined,\n};\n" }, { "change_type": "MODIFY", "old_path": "native/redux/redux-setup.js", "new_path": "native/redux/redux-setup.js", "diff": "@@ -34,6 +34,10 @@ import {\ntype GlobalThemeInfo,\ndefaultGlobalThemeInfo,\n} from '../types/themes';\n+import {\n+ type DeviceCameraInfo,\n+ defaultDeviceCameraInfo,\n+} from '../types/camera';\nimport React from 'react';\nimport invariant from 'invariant';\n@@ -73,6 +77,7 @@ import {\nupdateDimensionsActiveType,\nupdateConnectivityActiveType,\nupdateThemeInfoActionType,\n+ updateDeviceCameraInfoActionType,\n} from './action-types';\nimport {\ndefaultNavInfo,\n@@ -124,6 +129,7 @@ export type AppState = {|\ndimensions: Dimensions,\nconnectivity: ConnectivityInfo,\nglobalThemeInfo: GlobalThemeInfo,\n+ deviceCameraInfo: DeviceCameraInfo,\n|};\nconst { height, width } = NativeDimensions.get('window');\n@@ -166,6 +172,7 @@ const defaultState = ({\ndimensions: { height, width },\nconnectivity: defaultConnectivityInfo,\nglobalThemeInfo: defaultGlobalThemeInfo,\n+ deviceCameraInfo: defaultDeviceCameraInfo,\n}: AppState);\nfunction chatRouteFromNavInfo(navInfo: NavInfo): NavigationStateRoute {\n@@ -232,6 +239,14 @@ function reducer(state: AppState = defaultState, action: *) {\n...action.payload,\n},\n};\n+ } else if (action.type === updateDeviceCameraInfoActionType) {\n+ return {\n+ ...state,\n+ deviceCameraInfo: {\n+ ...state.deviceCameraInfo,\n+ ...action.payload,\n+ },\n+ };\n}\nconst oldState = state;\n" }, { "change_type": "ADD", "old_path": null, "new_path": "native/types/camera.js", "diff": "+// @flow\n+\n+import PropTypes from 'prop-types';\n+\n+export type DeviceCameraInfo = {|\n+ hasCamerasOnBothSides: bool,\n+ defaultUseFrontCamera: bool,\n+|};\n+\n+export const deviceCameraInfoPropType = PropTypes.shape({\n+ hasCamerasOnBothSides: PropTypes.bool.isRequired,\n+ defaultUseFrontCamera: PropTypes.bool.isRequired,\n+});\n+\n+export const defaultDeviceCameraInfo = {\n+ hasCamerasOnBothSides: true,\n+ defaultUseFrontCamera: false,\n+};\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Store DeviceCameraInfo in Redux
129,187
05.11.2019 15:40:26
18,000
bc8ce2307de34f0b2e40adb8d310c18dfa77a61d
[native] Fix up camera switch icon in CameraModal
[ { "change_type": "MODIFY", "old_path": "native/media/camera-modal.react.js", "new_path": "native/media/camera-modal.react.js", "diff": "@@ -246,7 +246,7 @@ class CameraModal extends React.PureComponent<Props, State> {\n? <ConnectedStatusBar hidden />\n: null;\nconst closeButtonStyle = {\n- top: Math.max(this.props.contentVerticalOffset - 2, 4),\n+ top: Math.max(this.props.contentVerticalOffset, 6),\n};\nconst type = this.state.useFrontCamera\n? RNCamera.Constants.Type.front\n@@ -423,13 +423,9 @@ const styles = StyleSheet.create({\n},\ncloseButtonContainer: {\nposition: \"absolute\",\n- left: 4,\n+ left: 24,\n},\ncloseButton: {\n- paddingTop: 2,\n- paddingBottom: 2,\n- paddingLeft: 8,\n- paddingRight: 8,\nfontSize: 36,\ncolor: \"white\",\ntextShadowColor: \"#000\",\n@@ -443,6 +439,7 @@ const styles = StyleSheet.create({\nbottom: contentBottomOffset + 20,\nflexDirection: 'row',\njustifyContent: 'center',\n+ alignItems: 'center',\n},\nsaveButton: {\nheight: 75,\n@@ -462,13 +459,15 @@ const styles = StyleSheet.create({\nswitchCameraButton: {\nposition: 'absolute',\nright: 24,\n- top: 0,\n- bottom: 2,\njustifyContent: 'center',\n},\nswitchCameraIcon: {\ncolor: 'white',\nfontSize: 36,\n+ paddingBottom: 2,\n+ textShadowColor: \"#000\",\n+ textShadowOffset: { width: 0, height: 1 },\n+ textShadowRadius: 1,\n},\n});\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Fix up camera switch icon in CameraModal
129,187
05.11.2019 17:24:07
18,000
2a52fbb548a0263eead2b51c17b86d6cab52e5e6
[native] Use RNCamera FaCC render methodology
[ { "change_type": "MODIFY", "old_path": "native/media/camera-modal.react.js", "new_path": "native/media/camera-modal.react.js", "diff": "@@ -110,9 +110,6 @@ class CameraModal extends React.PureComponent<Props, State> {\ndeviceCameraInfo: deviceCameraInfoPropType.isRequired,\ndispatchActionPayload: PropTypes.func.isRequired,\n};\n- camera: ?RNCamera;\n-\n- progress: Value;\ncloseButton: ?TouchableOpacity;\ncloseButtonX = new Value(0);\n@@ -139,7 +136,9 @@ class CameraModal extends React.PureComponent<Props, State> {\nflashButtonHeight = new Value(0);\npinchEvent;\n+ navigationProgress: Value;\nanimationCode: Value;\n+ cameraIDsFetched = false;\nconstructor(props: Props) {\nsuper(props);\n@@ -153,7 +152,7 @@ class CameraModal extends React.PureComponent<Props, State> {\nconst { position } = props;\nconst { index } = props.scene;\n- this.progress = interpolate(\n+ this.navigationProgress = interpolate(\nposition,\n{\ninputRange: [ index - 1, index ],\n@@ -229,11 +228,15 @@ class CameraModal extends React.PureComponent<Props, State> {\nget containerStyle() {\nreturn {\n...styles.container,\n- opacity: this.progress,\n+ opacity: this.navigationProgress,\n};\n}\n- render() {\n+ renderCamera = ({ camera, status }) => {\n+ if (camera && camera._cameraHandle) {\n+ this.fetchCameraIDs(camera);\n+ }\n+\nlet switchCameraButton = null;\nif (this.state.hasCamerasOnBothSides) {\nswitchCameraButton = (\n@@ -251,11 +254,6 @@ class CameraModal extends React.PureComponent<Props, State> {\n);\n}\n- const topButtonStyle = {\n- top: Math.max(this.props.contentVerticalOffset, 6),\n- };\n-\n- let flashIconName, flashButtonStyle = topButtonStyle;\nlet flashIcon;\nif (this.state.flashMode === RNCamera.Constants.FlashMode.on) {\nflashIcon = <IonIcon name=\"ios-flash\" style={styles.flashIcon} />;\n@@ -270,30 +268,11 @@ class CameraModal extends React.PureComponent<Props, State> {\n);\n}\n- const statusBar = CameraModal.isActive(this.props)\n- ? <ConnectedStatusBar hidden />\n- : null;\n- const type = this.state.useFrontCamera\n- ? RNCamera.Constants.Type.front\n- : RNCamera.Constants.Type.back;\n+ const topButtonStyle = {\n+ top: Math.max(this.props.contentVerticalOffset, 6),\n+ };\nreturn (\n- <PinchGestureHandler\n- onGestureEvent={this.pinchEvent}\n- onHandlerStateChange={this.pinchEvent}\n- >\n- <Animated.View style={this.containerStyle}>\n- {statusBar}\n- <Animated.Code exec={this.animationCode} />\n- <RNCamera\n- type={type}\n- captureAudio={false}\n- maxZoom={maxZoom}\n- zoom={this.state.zoom}\n- flashMode={this.state.flashMode}\n- style={styles.fill}\n- androidCameraPermissionOptions={permissionRationale}\n- ref={this.cameraRef}\n- />\n+ <>\n<TouchableOpacity\nonPress={this.close}\nonLayout={this.onCloseButtonLayout}\n@@ -305,7 +284,7 @@ class CameraModal extends React.PureComponent<Props, State> {\n<TouchableOpacity\nonPress={this.changeFlashMode}\nonLayout={this.onFlashButtonLayout}\n- style={[ styles.flashButton, flashButtonStyle ]}\n+ style={[ styles.flashButton, topButtonStyle ]}\nref={this.flashButtonRef}\n>\n{flashIcon}\n@@ -321,16 +300,39 @@ class CameraModal extends React.PureComponent<Props, State> {\n</TouchableOpacity>\n{switchCameraButton}\n</View>\n- </Animated.View>\n- </PinchGestureHandler>\n+ </>\n);\n}\n- cameraRef = (camera: ?RNCamera) => {\n- this.camera = camera;\n- if (camera) {\n- this.fetchCameraIDs();\n- }\n+ render() {\n+ const statusBar = CameraModal.isActive(this.props)\n+ ? <ConnectedStatusBar hidden />\n+ : null;\n+ const type = this.state.useFrontCamera\n+ ? RNCamera.Constants.Type.front\n+ : RNCamera.Constants.Type.back;\n+ return (\n+ <PinchGestureHandler\n+ onGestureEvent={this.pinchEvent}\n+ onHandlerStateChange={this.pinchEvent}\n+ >\n+ <Animated.View style={this.containerStyle}>\n+ {statusBar}\n+ <Animated.Code exec={this.animationCode} />\n+ <RNCamera\n+ type={type}\n+ captureAudio={false}\n+ maxZoom={maxZoom}\n+ zoom={this.state.zoom}\n+ flashMode={this.state.flashMode}\n+ style={styles.fill}\n+ androidCameraPermissionOptions={permissionRationale}\n+ >\n+ {this.renderCamera}\n+ </RNCamera>\n+ </Animated.View>\n+ </PinchGestureHandler>\n+ );\n}\ncloseButtonRef = (closeButton: ?TouchableOpacity) => {\n@@ -428,15 +430,12 @@ class CameraModal extends React.PureComponent<Props, State> {\n}\n}\n- fetchCameraIDs = async () => {\n- const { camera } = this;\n- if (!camera) {\n- return;\n- }\n- if (!camera._cameraHandle) {\n- setTimeout(this.fetchCameraIDs, 50);\n+ fetchCameraIDs = async (camera: RNCamera) => {\n+ if (this.cameraIDsFetched) {\nreturn;\n}\n+ this.cameraIDsFetched = true;\n+\nconst deviceCameras = await camera.getCameraIdsAsync();\nlet hasFront = false, hasBack = false, i = 0;\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Use RNCamera FaCC render methodology
129,187
05.11.2019 17:39:37
18,000
9249d7ef837fe4d9a0e8a050ffb439a72bb5e345
[native] ContentLoading
[ { "change_type": "MODIFY", "old_path": "native/calendar/calendar.react.js", "new_path": "native/calendar/calendar.react.js", "diff": "@@ -41,7 +41,6 @@ import {\nFlatList,\nAppState as NativeAppState,\nPlatform,\n- ActivityIndicator,\nKeyboard,\nLayoutAnimation,\nTouchableWithoutFeedback,\n@@ -98,6 +97,7 @@ import {\nimport DisconnectedBar from '../navigation/disconnected-bar.react';\nimport SafeAreaView from '../components/safe-area-view.react';\nimport { colorsSelector, styleSelector } from '../themes/colors';\n+import ContentLoading from '../components/content-loading.react';\nexport type EntryInfoWithHeight = {|\n...EntryInfo,\n@@ -743,8 +743,6 @@ class Calendar extends React.PureComponent<Props, State> {\n}\nrender() {\n- const { listSeparatorLabel } = this.props.colors;\n-\nconst listDataWithHeights = this.state.listDataWithHeights;\nlet flatList = null;\nif (listDataWithHeights) {\n@@ -773,13 +771,10 @@ class Calendar extends React.PureComponent<Props, State> {\nlet loadingIndicator = null;\nif (!listDataWithHeights || !this.state.readyToShowList) {\nloadingIndicator = (\n- <View style={this.props.styles.loadingIndicatorContainer}>\n- <ActivityIndicator\n- color={listSeparatorLabel}\n- size=\"large\"\n- style={this.props.styles.loadingIndicator}\n+ <ContentLoading\n+ fillType=\"absolute\"\n+ colors={this.props.colors}\n/>\n- </View>\n);\n}\nreturn (\n@@ -1165,16 +1160,6 @@ const styles = {\nfontWeight: 'bold',\ncolor: 'listSeparatorLabel',\n},\n- loadingIndicator: {\n- flex: 1,\n- },\n- loadingIndicatorContainer: {\n- position: 'absolute',\n- top: 0,\n- bottom: 0,\n- left: 0,\n- right: 0,\n- },\nkeyboardAvoidingView: {\nflex: 1,\n},\n" }, { "change_type": "MODIFY", "old_path": "native/chat/message-list-container.react.js", "new_path": "native/chat/message-list-container.react.js", "diff": "@@ -21,7 +21,7 @@ import type { Styles } from '../types/styles';\nimport * as React from 'react';\nimport PropTypes from 'prop-types';\n-import { View, Platform, ActivityIndicator } from 'react-native';\n+import { View, Platform } from 'react-native';\nimport _differenceWith from 'lodash/fp/differenceWith';\nimport invariant from 'invariant';\nimport hoistNonReactStatics from 'hoist-non-react-statics';\n@@ -53,6 +53,7 @@ import {\nwithChatInputState,\n} from './chat-input-state';\nimport { colorsSelector, styleSelector } from '../themes/colors';\n+import ContentLoading from '../components/content-loading.react';\nexport type ChatMessageItemWithHeight =\n{| itemType: \"loader\" |} |\n@@ -217,13 +218,10 @@ class MessageListContainer extends React.PureComponent<Props, State> {\n);\n} else {\nmessageList = (\n- <View style={this.props.styles.loadingIndicatorContainer}>\n- <ActivityIndicator\n- color={this.props.colors.listSeparatorLabel}\n- size=\"large\"\n- style={this.props.styles.loadingIndicator}\n+ <ContentLoading\n+ fillType=\"flex\"\n+ colors={this.props.colors}\n/>\n- </View>\n);\n}\n@@ -341,12 +339,6 @@ const styles = {\nflex: 1,\nbackgroundColor: 'listSeparator',\n},\n- loadingIndicator: {\n- flex: 1,\n- },\n- loadingIndicatorContainer: {\n- flex: 1,\n- },\ntext: {\nfontSize: 18,\nfontFamily: 'Arial',\n" }, { "change_type": "ADD", "old_path": null, "new_path": "native/components/content-loading.react.js", "diff": "+// @flow\n+\n+import type { Colors } from '../themes/colors';\n+\n+import * as React from 'react';\n+import { View, ActivityIndicator, StyleSheet } from 'react-native';\n+\n+type Props = {|\n+ fillType: 'flex' | 'absolute',\n+ colors: Colors,\n+|};\n+function ContentLoading(props: Props) {\n+ const viewStyle = props.fillType === 'flex'\n+ ? styles.fullFlex\n+ : styles.absoluteContainer;\n+ return (\n+ <View style={viewStyle}>\n+ <ActivityIndicator\n+ color={props.colors.listSeparatorLabel}\n+ size=\"large\"\n+ style={styles.fullFlex}\n+ />\n+ </View>\n+ );\n+}\n+\n+const styles = StyleSheet.create({\n+ fullFlex: {\n+ flex: 1,\n+ },\n+ absoluteContainer: {\n+ position: 'absolute',\n+ top: 0,\n+ bottom: 0,\n+ left: 0,\n+ right: 0,\n+ },\n+});\n+\n+export default ContentLoading;\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] ContentLoading
129,187
05.11.2019 18:03:49
18,000
83fc88c427ea04e1798c76d2beb05b2af83db5d8
[native] Show loading and error screens in CameraModal
[ { "change_type": "MODIFY", "old_path": "native/media/image-gallery-keyboard.react.js", "new_path": "native/media/image-gallery-keyboard.react.js", "diff": "@@ -295,7 +295,7 @@ class ImageGalleryKeyboard extends React.PureComponent<Props, State> {\n}\nthis.androidPermissionsGranted = true;\n} catch (err) {\n- this.guardedSetState({ error: \"don't have permissions :(\" });\n+ this.guardedSetState({ error: \"don't have permission :(\" });\nthis.androidPermissionsGranted = false;\n}\nreturn this.androidPermissionsGranted;\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Show loading and error screens in CameraModal
129,187
06.11.2019 11:52:26
18,000
d9995f64e67aa44134fc8c3f96f9e76978efbddf
[native] TapGestureHandler for CameraModal
[ { "change_type": "MODIFY", "old_path": "native/media/camera-modal.react.js", "new_path": "native/media/camera-modal.react.js", "diff": "@@ -28,10 +28,12 @@ import Animated from 'react-native-reanimated';\nimport { RNCamera } from 'react-native-camera';\nimport {\nPinchGestureHandler,\n+ TapGestureHandler,\nState as GestureState,\n} from 'react-native-gesture-handler';\nimport Icon from 'react-native-vector-icons/Ionicons';\nimport IonIcon from 'react-native-vector-icons/Ionicons';\n+import Orientation from 'react-native-orientation-locker';\nimport { connect } from 'lib/utils/redux-utils';\n@@ -53,9 +55,12 @@ const {\nset,\ncall,\ncond,\n+ and,\nor,\neq,\ngreaterThan,\n+ lessThan,\n+ add,\nsub,\nmultiply,\ndivide,\n@@ -113,33 +118,37 @@ class CameraModal extends React.PureComponent<Props, State> {\ndispatchActionPayload: PropTypes.func.isRequired,\n};\n+ pinchEvent;\n+ pinchHandler = React.createRef();\n+ tapEvent;\n+ tapHandler = React.createRef();\n+ navigationProgress: Value;\n+ animationCode: Value;\n+\ncloseButton: ?TouchableOpacity;\n- closeButtonX = new Value(0);\n- closeButtonY = new Value(0);\n+ closeButtonX = new Value(-1);\n+ closeButtonY = new Value(-1);\ncloseButtonWidth = new Value(0);\ncloseButtonHeight = new Value(0);\nphotoButton: ?TouchableOpacity;\n- photoButtonX = new Value(0);\n- photoButtonY = new Value(0);\n+ photoButtonX = new Value(-1);\n+ photoButtonY = new Value(-1);\nphotoButtonWidth = new Value(0);\nphotoButtonHeight = new Value(0);\nswitchCameraButton: ?TouchableOpacity;\n- switchCameraButtonX = new Value(0);\n- switchCameraButtonY = new Value(0);\n+ switchCameraButtonX = new Value(-1);\n+ switchCameraButtonY = new Value(-1);\nswitchCameraButtonWidth = new Value(0);\nswitchCameraButtonHeight = new Value(0);\nflashButton: ?TouchableOpacity;\n- flashButtonX = new Value(0);\n- flashButtonY = new Value(0);\n+ flashButtonX = new Value(-1);\n+ flashButtonY = new Value(-1);\nflashButtonWidth = new Value(0);\nflashButtonHeight = new Value(0);\n- pinchEvent;\n- navigationProgress: Value;\n- animationCode: Value;\ncameraIDsFetched = false;\nconstructor(props: Props) {\n@@ -172,9 +181,28 @@ class CameraModal extends React.PureComponent<Props, State> {\n},\n}]);\n+ const tapState = new Value(-1);\n+ const tapX = new Value(0);\n+ const tapY = new Value(0);\n+ this.tapEvent = event([{\n+ nativeEvent: {\n+ state: tapState,\n+ x: tapX,\n+ y: tapY,\n+ },\n+ }]);\n+\n+ this.animationCode = block([\n+ this.zoomAnimationCode(pinchState, pinchScale),\n+ this.focusAnimationCode(tapState, tapX, tapY),\n+ ]);\n+ }\n+\n+ zoomAnimationCode(pinchState: Value, pinchScale: Value): Value {\n+ const pinchJustEnded = gestureJustEnded(pinchState);\n+\nconst zoomBase = new Value(1);\nconst zoomReported = new Value(1);\n- const pinchJustEnded = gestureJustEnded(pinchState);\nconst currentZoom = interpolate(\nmultiply(zoomBase, pinchScale),\n@@ -198,7 +226,7 @@ class CameraModal extends React.PureComponent<Props, State> {\nzoomBase,\n);\n- this.animationCode = block([\n+ return [\ncond(\npinchJustEnded,\nset(zoomBase, currentZoom),\n@@ -219,7 +247,74 @@ class CameraModal extends React.PureComponent<Props, State> {\n),\n],\n),\n- ]);\n+ ];\n+ }\n+\n+ focusAnimationCode(tapState: Value, tapX: Value, tapY: Value): Value {\n+ const lastTapX = new Value(0);\n+ const lastTapY = new Value(0);\n+ const tapJustEnded = and(\n+ gestureJustEnded(tapState),\n+ this.outsideButtons(lastTapX, lastTapY),\n+ );\n+ return [\n+ cond(\n+ tapJustEnded,\n+ call(\n+ [ tapX, tapY ],\n+ this.focusOnPoint,\n+ ),\n+ ),\n+ set(lastTapX, tapX),\n+ set(lastTapY, tapY),\n+ ];\n+ }\n+\n+ outsideButtons(x: Value, y: Value) {\n+ const {\n+ closeButtonX,\n+ closeButtonY,\n+ closeButtonWidth,\n+ closeButtonHeight,\n+ photoButtonX,\n+ photoButtonY,\n+ photoButtonWidth,\n+ photoButtonHeight,\n+ switchCameraButtonX,\n+ switchCameraButtonY,\n+ switchCameraButtonWidth,\n+ switchCameraButtonHeight,\n+ flashButtonX,\n+ flashButtonY,\n+ flashButtonWidth,\n+ flashButtonHeight,\n+ } = this;\n+ return and(\n+ or(\n+ lessThan(x, closeButtonX),\n+ greaterThan(x, add(closeButtonX, closeButtonWidth)),\n+ lessThan(y, closeButtonY),\n+ greaterThan(y, add(closeButtonY, closeButtonHeight)),\n+ ),\n+ or(\n+ lessThan(x, photoButtonX),\n+ greaterThan(x, add(photoButtonX, photoButtonWidth)),\n+ lessThan(y, photoButtonY),\n+ greaterThan(y, add(photoButtonY, photoButtonHeight)),\n+ ),\n+ or(\n+ lessThan(x, switchCameraButtonX),\n+ greaterThan(x, add(switchCameraButtonX, switchCameraButtonWidth)),\n+ lessThan(y, switchCameraButtonY),\n+ greaterThan(y, add(switchCameraButtonY, switchCameraButtonHeight)),\n+ ),\n+ or(\n+ lessThan(x, flashButtonX),\n+ greaterThan(x, add(flashButtonX, flashButtonWidth)),\n+ lessThan(y, flashButtonY),\n+ greaterThan(y, add(flashButtonY, flashButtonHeight)),\n+ ),\n+ );\n}\nstatic isActive(props) {\n@@ -227,6 +322,35 @@ class CameraModal extends React.PureComponent<Props, State> {\nreturn index === props.transitionProps.index;\n}\n+ componentDidMount() {\n+ if (CameraModal.isActive(this.props)) {\n+ Orientation.unlockAllOrientations();\n+ }\n+ }\n+\n+ componentWillUnmount() {\n+ if (CameraModal.isActive(this.props)) {\n+ Orientation.lockToPortrait();\n+ }\n+ }\n+\n+ componentDidUpdate(prevProps: Props, prevState: State) {\n+ const isActive = CameraModal.isActive(this.props);\n+ const wasActive = CameraModal.isActive(prevProps);\n+ if (isActive && !wasActive) {\n+ Orientation.unlockAllOrientations();\n+ } else if (!isActive && wasActive) {\n+ Orientation.lockToPortrait();\n+ }\n+\n+ if (!this.state.hasCamerasOnBothSides && prevState.hasCamerasOnBothSides) {\n+ this.switchCameraButtonX.setValue(-1);\n+ this.switchCameraButtonY.setValue(-1);\n+ this.switchCameraButtonWidth.setValue(0);\n+ this.switchCameraButtonHeight.setValue(0);\n+ }\n+ }\n+\nget containerStyle() {\nreturn {\n...styles.container,\n@@ -339,10 +463,19 @@ class CameraModal extends React.PureComponent<Props, State> {\n<PinchGestureHandler\nonGestureEvent={this.pinchEvent}\nonHandlerStateChange={this.pinchEvent}\n+ simultaneousHandlers={this.tapHandler}\n+ ref={this.pinchHandler}\n>\n<Animated.View style={this.containerStyle}>\n{statusBar}\n<Animated.Code exec={this.animationCode} />\n+ <TapGestureHandler\n+ onHandlerStateChange={this.tapEvent}\n+ simultaneousHandlers={this.pinchHandler}\n+ waitFor={this.pinchHandler}\n+ ref={this.tapHandler}\n+ >\n+ <Animated.View style={styles.fill}>\n<RNCamera\ntype={type}\ncaptureAudio={false}\n@@ -355,6 +488,8 @@ class CameraModal extends React.PureComponent<Props, State> {\n{this.renderCamera}\n</RNCamera>\n</Animated.View>\n+ </TapGestureHandler>\n+ </Animated.View>\n</PinchGestureHandler>\n);\n}\n@@ -454,6 +589,15 @@ class CameraModal extends React.PureComponent<Props, State> {\n}\n}\n+ focusOnPoint = ([ x, y ]: [ number, number ]) => {\n+ const screenWidth = this.props.screenDimensions.width;\n+ const screenHeight =\n+ this.props.screenDimensions.height + contentBottomOffset;\n+ const relativeX = x / screenWidth;\n+ const relativeY = y / screenHeight;\n+ console.log(`tap occurred at ${x}, ${y}. aka ${relativeX}, ${relativeY}`);\n+ }\n+\nfetchCameraIDs = async (camera: RNCamera) => {\nif (this.cameraIDsFetched) {\nreturn;\n@@ -504,18 +648,18 @@ const styles = StyleSheet.create({\nflex: 1,\n},\ncloseButton: {\n- position: \"absolute\",\n+ position: 'absolute',\nleft: 24,\n},\ncloseIcon: {\nfontSize: 36,\n- color: \"white\",\n- textShadowColor: \"#000\",\n+ color: 'white',\n+ textShadowColor: 'black',\ntextShadowOffset: { width: 0, height: 1 },\ntextShadowRadius: 1,\n},\nbottomButtonsContainer: {\n- position: \"absolute\",\n+ position: 'absolute',\nleft: 0,\nright: 0,\nbottom: contentBottomOffset + 20,\n@@ -547,30 +691,30 @@ const styles = StyleSheet.create({\ncolor: 'white',\nfontSize: 36,\npaddingBottom: 2,\n- textShadowColor: \"#000\",\n+ textShadowColor: 'black',\ntextShadowOffset: { width: 0, height: 1 },\ntextShadowRadius: 1,\n},\nflashButton: {\n- position: \"absolute\",\n+ position: 'absolute',\nmarginTop: Platform.select({ android: 15, default: 13 }),\nright: 25,\n},\nflashIcon: {\nfontSize: 24,\n- color: \"white\",\n- textShadowColor: \"#000\",\n+ color: 'white',\n+ textShadowColor: 'black',\ntextShadowOffset: { width: 0, height: 1 },\ntextShadowRadius: 1,\n},\nflashIconAutoText: {\n- position: \"absolute\",\n+ position: 'absolute',\ntop: -3,\nright: -5,\nfontSize: 10,\nfontWeight: 'bold',\ncolor: \"white\",\n- textShadowColor: \"#000\",\n+ textShadowColor: 'black',\ntextShadowOffset: { width: 0, height: 1 },\ntextShadowRadius: 1,\n},\n" }, { "change_type": "MODIFY", "old_path": "native/media/multimedia-modal.react.js", "new_path": "native/media/multimedia-modal.react.js", "diff": "@@ -234,13 +234,13 @@ class MultimediaModal extends React.PureComponent<Props, State> {\ncloseButton: ?TouchableOpacity;\nsaveButton: ?TouchableOpacity;\n- closeButtonX = new Value(0);\n- closeButtonY = new Value(0);\n+ closeButtonX = new Value(-1);\n+ closeButtonY = new Value(-1);\ncloseButtonWidth = new Value(0);\ncloseButtonHeight = new Value(0);\ncloseButtonLastState = new Value(1);\n- saveButtonX = new Value(0);\n- saveButtonY = new Value(0);\n+ saveButtonX = new Value(-1);\n+ saveButtonY = new Value(-1);\nsaveButtonWidth = new Value(0);\nsaveButtonHeight = new Value(0);\nactionLinksLastState = new Value(1);\n@@ -1035,6 +1035,12 @@ class MultimediaModal extends React.PureComponent<Props, State> {\n}\n}\n+ componentWillUnmount() {\n+ if (MultimediaModal.isActive(this.props)) {\n+ Orientation.lockToPortrait();\n+ }\n+ }\n+\ncomponentDidUpdate(prevProps: Props) {\nif (\nthis.props.screenDimensions !== prevProps.screenDimensions ||\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] TapGestureHandler for CameraModal
129,187
06.11.2019 12:08:26
18,000
7ea5a18afb03c8a164a949b50f1f27e6b2feb170
[native] Orientation info in Redux
[ { "change_type": "MODIFY", "old_path": "native/app.react.js", "new_path": "native/app.react.js", "diff": "@@ -42,6 +42,7 @@ import DimensionsUpdater from './redux/dimensions-updater.react';\nimport ConnectivityUpdater from './redux/connectivity-updater.react';\nimport PushHandler from './push/push-handler.react';\nimport ThemeHandler from './themes/theme-handler.react';\n+import OrientationHandler from './navigation/orientation-handler.react';\nimport Socket from './socket.react';\nif (Platform.OS === \"android\") {\n@@ -149,6 +150,7 @@ class AppWithNavigationState extends React.PureComponent<Props, State> {\ndetectUnsupervisedBackground={detectUnsupervisedBackground}\n/>\n<ThemeHandler />\n+ <OrientationHandler />\n</View>\n);\n}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "native/navigation/orientation-handler.react.js", "diff": "+// @flow\n+\n+import type { AppState } from '../redux/redux-setup';\n+import type { Orientations } from 'react-native-orientation-locker';\n+import type { DispatchActionPayload } from 'lib/utils/action-utils';\n+import { updateDeviceOrientationActionType } from '../redux/action-types';\n+\n+import * as React from 'react';\n+import PropTypes from 'prop-types';\n+import Orientation from 'react-native-orientation-locker';\n+\n+import { connect } from 'lib/utils/redux-utils';\n+\n+type Props = {\n+ // Redux dispatch functions\n+ dispatchActionPayload: DispatchActionPayload,\n+};\n+class OrientationHandler extends React.PureComponent<Props> {\n+\n+ static propTypes = {\n+ dispatchActionPayload: PropTypes.func.isRequired,\n+ };\n+\n+ componentDidMount() {\n+ Orientation.addOrientationListener(this.updateOrientation);\n+ }\n+\n+ componentWillUnmount() {\n+ Orientation.removeOrientationListener(this.updateOrientation);\n+ }\n+\n+ updateOrientation = orientation => {\n+ this.props.dispatchActionPayload(\n+ updateDeviceOrientationActionType,\n+ orientation,\n+ );\n+ }\n+\n+ render() {\n+ return null;\n+ }\n+\n+}\n+\n+export default connect(\n+ null,\n+ null,\n+ true,\n+)(OrientationHandler);\n" }, { "change_type": "MODIFY", "old_path": "native/redux/action-types.js", "new_path": "native/redux/action-types.js", "diff": "@@ -15,3 +15,4 @@ export const updateDimensionsActiveType = \"UPDATE_DIMENSIONS\";\nexport const updateConnectivityActiveType = \"UPDATE_CONNECTIVITY\";\nexport const updateThemeInfoActionType = \"UPDATE_THEME_INFO\";\nexport const updateDeviceCameraInfoActionType = \"UPDATE_DEVICE_CAMERA_INFO\";\n+export const updateDeviceOrientationActionType = \"UPDATE_DEVICE_ORIENTATION\";\n" }, { "change_type": "MODIFY", "old_path": "native/redux/persist.js", "new_path": "native/redux/persist.js", "diff": "@@ -11,6 +11,7 @@ import { createMigrate } from 'redux-persist';\nimport invariant from 'invariant';\nimport { Platform } from 'react-native';\nimport AsyncStorage from '@react-native-community/async-storage';\n+import Orientation from 'react-native-orientation-locker';\nimport { highestLocalIDSelector } from 'lib/selectors/local-id-selectors';\nimport { unshimMessageStore } from 'lib/shared/unshim-utils';\n@@ -24,6 +25,7 @@ const baseBlacklist = [\n'messageSentFromRoute',\n'dimensions',\n'connectivity',\n+ 'deviceOrientation',\n];\nconst blacklist = __DEV__\n? baseBlacklist\n@@ -140,6 +142,7 @@ const migrations = {\n[13]: (state: AppState) => ({\n...state,\ndeviceCameraInfo: defaultDeviceCameraInfo,\n+ deviceOrientation: Orientation.getInitialOrientation(),\n}),\n};\n" }, { "change_type": "MODIFY", "old_path": "native/redux/redux-setup.js", "new_path": "native/redux/redux-setup.js", "diff": "@@ -38,6 +38,7 @@ import {\ntype DeviceCameraInfo,\ndefaultDeviceCameraInfo,\n} from '../types/camera';\n+import type { Orientations } from 'react-native-orientation-locker';\nimport React from 'react';\nimport invariant from 'invariant';\n@@ -58,6 +59,7 @@ import {\nPlatform,\nDimensions as NativeDimensions,\n} from 'react-native';\n+import Orientation from 'react-native-orientation-locker';\nimport baseReducer from 'lib/reducers/master-reducer';\nimport {\n@@ -78,6 +80,7 @@ import {\nupdateConnectivityActiveType,\nupdateThemeInfoActionType,\nupdateDeviceCameraInfoActionType,\n+ updateDeviceOrientationActionType,\n} from './action-types';\nimport {\ndefaultNavInfo,\n@@ -130,6 +133,7 @@ export type AppState = {|\nconnectivity: ConnectivityInfo,\nglobalThemeInfo: GlobalThemeInfo,\ndeviceCameraInfo: DeviceCameraInfo,\n+ deviceOrientation: Orientations,\n|};\nconst { height, width } = NativeDimensions.get('window');\n@@ -173,6 +177,7 @@ const defaultState = ({\nconnectivity: defaultConnectivityInfo,\nglobalThemeInfo: defaultGlobalThemeInfo,\ndeviceCameraInfo: defaultDeviceCameraInfo,\n+ deviceOrientation: Orientation.getInitialOrientation(),\n}: AppState);\nfunction chatRouteFromNavInfo(navInfo: NavInfo): NavigationStateRoute {\n@@ -247,6 +252,11 @@ function reducer(state: AppState = defaultState, action: *) {\n...action.payload,\n},\n};\n+ } else if (action.type === updateDeviceOrientationActionType) {\n+ return {\n+ ...state,\n+ deviceOrientation: action.payload,\n+ };\n}\nconst oldState = state;\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Orientation info in Redux
129,187
06.11.2019 12:24:24
18,000
6418a00a32707579fa95c10276e9fb71c33340b9
[native] autoFocusPointOfInterest for CameraModal
[ { "change_type": "MODIFY", "old_path": "native/media/camera-modal.react.js", "new_path": "native/media/camera-modal.react.js", "diff": "@@ -14,6 +14,7 @@ import {\ntype DeviceCameraInfo,\ndeviceCameraInfoPropType,\n} from '../types/camera';\n+import type { Orientations } from 'react-native-orientation-locker';\nimport * as React from 'react';\nimport {\n@@ -34,6 +35,7 @@ import {\nimport Icon from 'react-native-vector-icons/Ionicons';\nimport IonIcon from 'react-native-vector-icons/Ionicons';\nimport Orientation from 'react-native-orientation-locker';\n+import invariant from 'invariant';\nimport { connect } from 'lib/utils/redux-utils';\n@@ -94,6 +96,7 @@ type Props = {\nscreenDimensions: Dimensions,\ncontentVerticalOffset: number,\ndeviceCameraInfo: DeviceCameraInfo,\n+ deviceOrientation: Orientations,\n// Redux dispatch functions\ndispatchActionPayload: DispatchActionPayload,\n};\n@@ -102,6 +105,7 @@ type State = {|\nuseFrontCamera: bool,\nhasCamerasOnBothSides: bool,\nflashMode: number,\n+ autoFocusPointOfInterest: ?{| x: number, y: number, autoExposure?: bool |},\n|};\nclass CameraModal extends React.PureComponent<Props, State> {\n@@ -115,6 +119,7 @@ class CameraModal extends React.PureComponent<Props, State> {\nscreenDimensions: dimensionsPropType.isRequired,\ncontentVerticalOffset: PropTypes.number.isRequired,\ndeviceCameraInfo: deviceCameraInfoPropType.isRequired,\n+ deviceOrientation: PropTypes.string.isRequired,\ndispatchActionPayload: PropTypes.func.isRequired,\n};\n@@ -159,6 +164,7 @@ class CameraModal extends React.PureComponent<Props, State> {\nuseFrontCamera: props.deviceCameraInfo.defaultUseFrontCamera,\nhasCamerasOnBothSides: props.deviceCameraInfo.hasCamerasOnBothSides,\nflashMode: RNCamera.Constants.FlashMode.off,\n+ autoFocusPointOfInterest: undefined,\n};\nconst { position } = props;\n@@ -482,6 +488,7 @@ class CameraModal extends React.PureComponent<Props, State> {\nmaxZoom={maxZoom}\nzoom={this.state.zoom}\nflashMode={this.state.flashMode}\n+ autoFocusPointOfInterest={this.state.autoFocusPointOfInterest}\nstyle={styles.fill}\nandroidCameraPermissionOptions={permissionRationale}\n>\n@@ -589,13 +596,39 @@ class CameraModal extends React.PureComponent<Props, State> {\n}\n}\n- focusOnPoint = ([ x, y ]: [ number, number ]) => {\n+ focusOnPoint = ([ inputX, inputY ]: [ number, number ]) => {\nconst screenWidth = this.props.screenDimensions.width;\nconst screenHeight =\nthis.props.screenDimensions.height + contentBottomOffset;\n- const relativeX = x / screenWidth;\n- const relativeY = y / screenHeight;\n- console.log(`tap occurred at ${x}, ${y}. aka ${relativeX}, ${relativeY}`);\n+ const relativeX = inputX / screenWidth;\n+ const relativeY = inputY / screenHeight;\n+\n+ // react-native-camera's autoFocusPointOfInterest prop is based on a\n+ // LANDSCAPE-LEFT orientation, so we need to map to that\n+ let x, y;\n+ if (this.props.deviceOrientation === 'LANDSCAPE-LEFT') {\n+ x = relativeX;\n+ y = relativeY;\n+ } else if (this.props.deviceOrientation === 'LANDSCAPE-RIGHT') {\n+ x = 1 - relativeX;\n+ y = 1 - relativeY;\n+ } else if (this.props.deviceOrientation === 'PORTRAIT') {\n+ x = relativeY;\n+ y = 1 - relativeX;\n+ } else if (this.props.deviceOrientation === 'PORTRAIT-UPSIDEDOWN') {\n+ x = 1 - relativeY;\n+ y = relativeX;\n+ } else {\n+ invariant(\n+ false,\n+ `unexpected device orientation ${this.props.deviceOrientation}`,\n+ );\n+ }\n+\n+ const autoFocusPointOfInterest = Platform.OS === \"ios\"\n+ ? { x, y, autoExposure: true }\n+ : { x, y };\n+ this.setState({ autoFocusPointOfInterest });\n}\nfetchCameraIDs = async (camera: RNCamera) => {\n@@ -735,6 +768,7 @@ export default connect(\nscreenDimensions: dimensionsSelector(state),\ncontentVerticalOffset: contentVerticalOffsetSelector(state),\ndeviceCameraInfo: state.deviceCameraInfo,\n+ deviceOrientation: state.deviceOrientation,\n}),\nnull,\ntrue,\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] autoFocusPointOfInterest for CameraModal
129,187
06.11.2019 17:32:39
18,000
1c402b53890df3a86ccabfa52cacbb4daa38a8b3
[native] CameraModal focus indicator
[ { "change_type": "MODIFY", "old_path": "native/media/camera-modal.react.js", "new_path": "native/media/camera-modal.react.js", "diff": "@@ -25,7 +25,7 @@ import {\nPlatform,\n} from 'react-native';\nimport PropTypes from 'prop-types';\n-import Animated from 'react-native-reanimated';\n+import Animated, { Easing } from 'react-native-reanimated';\nimport { RNCamera } from 'react-native-camera';\nimport {\nPinchGestureHandler,\n@@ -45,18 +45,20 @@ import {\ncontentVerticalOffsetSelector,\n} from '../selectors/dimension-selectors';\nimport ConnectedStatusBar from '../connected-status-bar.react';\n-import { gestureJustEnded } from '../utils/animation-utils';\n+import { clamp, gestureJustEnded } from '../utils/animation-utils';\nimport ContentLoading from '../components/content-loading.react';\nimport { colors } from '../themes/colors';\nconst {\nValue,\n+ Clock,\nevent,\nExtrapolate,\nblock,\nset,\ncall,\ncond,\n+ not,\nand,\nor,\neq,\n@@ -68,6 +70,12 @@ const {\ndivide,\nabs,\ninterpolate,\n+ startClock,\n+ stopClock,\n+ clockRunning,\n+ timing,\n+ spring,\n+ SpringUtils,\n} = Animated;\nconst maxZoom = 8;\nconst zoomUpdateFactor = (() => {\n@@ -87,6 +95,130 @@ const permissionRationale = {\nmessage: \"Requesting access to your device camera\",\n};\n+const indicatorSpringConfig = {\n+ ...SpringUtils.makeDefaultConfig(),\n+ damping: 0,\n+ mass: 0.6,\n+ toValue: 1,\n+};\n+const indicatorTimingConfig = {\n+ duration: 500,\n+ easing: Easing.out(Easing.ease),\n+ toValue: 0,\n+};\n+function runIndicatorAnimation(\n+ // Inputs\n+ springClock: Clock,\n+ delayClock: Clock,\n+ timingClock: Clock,\n+ animationRunning: Value,\n+ // Outputs\n+ scale: Value,\n+ opacity: Value,\n+): Value {\n+ const delayStart = new Value(0);\n+\n+ const springScale = new Value(0.75);\n+ const delayScale = new Value(0);\n+ const timingScale = new Value(0.75);\n+\n+ const animatedScale = cond(\n+ clockRunning(springClock),\n+ springScale,\n+ cond(\n+ clockRunning(delayClock),\n+ delayScale,\n+ timingScale,\n+ ),\n+ );\n+ const lastAnimatedScale = new Value(0.75);\n+ const numScaleLoops = new Value(0);\n+\n+ const springState = {\n+ finished: new Value(1),\n+ velocity: new Value(0),\n+ time: new Value(0),\n+ position: springScale,\n+ };\n+ const timingState = {\n+ finished: new Value(1),\n+ frameTime: new Value(0),\n+ time: new Value(0),\n+ position: timingScale,\n+ };\n+\n+ return block([\n+ cond(\n+ not(animationRunning),\n+ [\n+ set(springState.finished, 0),\n+ set(springState.velocity, 0),\n+ set(springState.time, 0),\n+ set(springScale, 0.75),\n+ set(lastAnimatedScale, 0.75),\n+ set(numScaleLoops, 0),\n+ set(opacity, 1),\n+ startClock(springClock),\n+ ],\n+ ),\n+ [\n+ cond(\n+ clockRunning(springClock),\n+ spring(springClock, springState, indicatorSpringConfig),\n+ ),\n+ timing(timingClock, timingState, indicatorTimingConfig),\n+ ],\n+ [\n+ cond(\n+ and(\n+ greaterThan(animatedScale, 1.2),\n+ not(greaterThan(lastAnimatedScale, 1.2)),\n+ ),\n+ [\n+ set(numScaleLoops, add(numScaleLoops, 1)),\n+ cond(\n+ greaterThan(numScaleLoops, 1),\n+ [\n+ set(springState.finished, 1),\n+ stopClock(springClock),\n+ set(delayScale, springScale),\n+ set(delayStart, delayClock),\n+ startClock(delayClock),\n+ ],\n+ ),\n+ ],\n+ ),\n+ set(lastAnimatedScale, animatedScale),\n+ ],\n+ cond(\n+ and(\n+ clockRunning(delayClock),\n+ greaterThan(delayClock, add(delayStart, 400)),\n+ ),\n+ [\n+ stopClock(delayClock),\n+ set(timingState.finished, 0),\n+ set(timingState.frameTime, 0),\n+ set(timingState.time, 0),\n+ set(timingScale, delayScale),\n+ startClock(timingClock),\n+ ],\n+ ),\n+ cond(\n+ and(springState.finished, timingState.finished),\n+ stopClock(timingClock),\n+ ),\n+ set(scale, animatedScale),\n+ cond(\n+ clockRunning(timingClock),\n+ set(\n+ opacity,\n+ clamp(animatedScale, 0, 1),\n+ ),\n+ ),\n+ ]);\n+}\n+\ntype Props = {\nnavigation: NavigationStackProp<NavigationLeafRoute>,\nscene: NavigationStackScene,\n@@ -154,6 +286,11 @@ class CameraModal extends React.PureComponent<Props, State> {\nflashButtonWidth = new Value(0);\nflashButtonHeight = new Value(0);\n+ focusIndicatorX = new Value(-1);\n+ focusIndicatorY = new Value(-1);\n+ focusIndicatorScale = new Value(0);\n+ focusIndicatorOpacity = new Value(0);\n+\ncameraIDsFetched = false;\nconstructor(props: Props) {\n@@ -259,17 +396,45 @@ class CameraModal extends React.PureComponent<Props, State> {\nfocusAnimationCode(tapState: Value, tapX: Value, tapY: Value): Value {\nconst lastTapX = new Value(0);\nconst lastTapY = new Value(0);\n- const tapJustEnded = and(\n+ const fingerJustReleased = and(\ngestureJustEnded(tapState),\nthis.outsideButtons(lastTapX, lastTapY),\n);\n+\n+ const indicatorSpringClock = new Clock();\n+ const indicatorDelayClock = new Clock();\n+ const indicatorTimingClock = new Clock();\n+ const indicatorAnimationRunning = or(\n+ clockRunning(indicatorSpringClock),\n+ clockRunning(indicatorDelayClock),\n+ clockRunning(indicatorTimingClock),\n+ );\n+\nreturn [\ncond(\n- tapJustEnded,\n+ fingerJustReleased,\n+ [\ncall(\n[ tapX, tapY ],\nthis.focusOnPoint,\n),\n+ set(this.focusIndicatorX, tapX),\n+ set(this.focusIndicatorY, tapY),\n+ stopClock(indicatorSpringClock),\n+ stopClock(indicatorDelayClock),\n+ stopClock(indicatorTimingClock),\n+ ],\n+ ),\n+ cond(\n+ or(fingerJustReleased, indicatorAnimationRunning),\n+ runIndicatorAnimation(\n+ indicatorSpringClock,\n+ indicatorDelayClock,\n+ indicatorTimingClock,\n+ indicatorAnimationRunning,\n+ this.focusIndicatorScale,\n+ this.focusIndicatorOpacity,\n+ ),\n),\nset(lastTapX, tapX),\nset(lastTapY, tapY),\n@@ -364,6 +529,18 @@ class CameraModal extends React.PureComponent<Props, State> {\n};\n}\n+ get focusIndicatorStyle() {\n+ return {\n+ ...styles.focusIndicator,\n+ opacity: this.focusIndicatorOpacity,\n+ transform: [\n+ { translateX: this.focusIndicatorX },\n+ { translateY: this.focusIndicatorY },\n+ { scale: this.focusIndicatorScale },\n+ ],\n+ };\n+ }\n+\nrenderCamera = ({ camera, status }) => {\nif (camera && camera._cameraHandle) {\nthis.fetchCameraIDs(camera);\n@@ -435,6 +612,7 @@ class CameraModal extends React.PureComponent<Props, State> {\n};\nreturn (\n<>\n+ <Animated.View style={this.focusIndicatorStyle} />\n<TouchableOpacity\nonPress={this.changeFlashMode}\nonLayout={this.onFlashButtonLayout}\n@@ -761,6 +939,16 @@ const styles = StyleSheet.create({\nfontSize: 28,\ntextAlign: 'center',\n},\n+ focusIndicator: {\n+ position: 'absolute',\n+ left: -12,\n+ top: -12,\n+ height: 24,\n+ width: 24,\n+ borderRadius: 24,\n+ borderWidth: 1,\n+ borderColor: 'white',\n+ },\n});\nexport default connect(\n" }, { "change_type": "MODIFY", "old_path": "native/media/multimedia-modal.react.js", "new_path": "native/media/multimedia-modal.react.js", "diff": "@@ -673,7 +673,7 @@ class MultimediaModal extends React.PureComponent<Props, State> {\n): Value {\nconst lastTapX = new Value(0);\nconst lastTapY = new Value(0);\n- const tapJustEnded = and(\n+ const fingerJustReleased = and(\ngestureJustEnded(singleTapState),\nthis.outsideButtons(lastTapX, lastTapY),\n);\n@@ -684,7 +684,7 @@ class MultimediaModal extends React.PureComponent<Props, State> {\nconst closeButtonState = cond(\nor(\n- tapJustEnded,\n+ fingerJustReleased,\nand(becameUnzoomed, eq(this.closeButtonLastState, 0)),\n),\nsub(1, this.closeButtonLastState),\n@@ -695,7 +695,7 @@ class MultimediaModal extends React.PureComponent<Props, State> {\nisZoomed,\n0,\ncond(\n- or(tapJustEnded, becameUnzoomed),\n+ or(fingerJustReleased, becameUnzoomed),\nsub(1, this.actionLinksLastState),\nthis.actionLinksLastState,\n),\n@@ -706,7 +706,7 @@ class MultimediaModal extends React.PureComponent<Props, State> {\nconst actionLinksAppearClock = new Clock();\nconst actionLinksDisappearClock = new Clock();\nreturn [\n- tapJustEnded,\n+ fingerJustReleased,\nset(\ncurCloseButtonOpacity,\ncond(\n@@ -803,16 +803,16 @@ class MultimediaModal extends React.PureComponent<Props, State> {\nconst deltaX = panDelta(zoomX, zoomActive);\nconst deltaY = panDelta(zoomY, zoomActive);\n- const tapJustEnded = and(\n+ const fingerJustReleased = and(\ngestureJustEnded(doubleTapState),\nthis.outsideButtons(doubleTapX, doubleTapY),\n);\nreturn cond(\n- [ tapJustEnded, deltaX, deltaY, deltaScale, gestureActive ],\n+ [ fingerJustReleased, deltaX, deltaY, deltaScale, gestureActive ],\nstopClock(zoomClock),\ncond(\n- or(zoomClockRunning, tapJustEnded),\n+ or(zoomClockRunning, fingerJustReleased ),\n[\nzoomX,\nzoomY,\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] CameraModal focus indicator
129,187
06.11.2019 17:40:52
18,000
44cbef6795671c673e0a0c49556f10bab4a3eb83
[native] Wipe focus points on device orientation changes in CameraModal
[ { "change_type": "MODIFY", "old_path": "native/media/camera-modal.react.js", "new_path": "native/media/camera-modal.react.js", "diff": "@@ -291,6 +291,8 @@ class CameraModal extends React.PureComponent<Props, State> {\nfocusIndicatorScale = new Value(0);\nfocusIndicatorOpacity = new Value(0);\n+ cancelIndicatorAnimation = new Value(0);\n+\ncameraIDsFetched = false;\nconstructor(props: Props) {\n@@ -425,6 +427,16 @@ class CameraModal extends React.PureComponent<Props, State> {\nstopClock(indicatorTimingClock),\n],\n),\n+ cond(\n+ this.cancelIndicatorAnimation,\n+ [\n+ set(this.cancelIndicatorAnimation, 0),\n+ stopClock(indicatorSpringClock),\n+ stopClock(indicatorDelayClock),\n+ stopClock(indicatorTimingClock),\n+ set(this.focusIndicatorOpacity, 0),\n+ ],\n+ ),\ncond(\nor(fingerJustReleased, indicatorAnimationRunning),\nrunIndicatorAnimation(\n@@ -520,6 +532,11 @@ class CameraModal extends React.PureComponent<Props, State> {\nthis.switchCameraButtonWidth.setValue(0);\nthis.switchCameraButtonHeight.setValue(0);\n}\n+\n+ if (this.props.deviceOrientation !== prevProps.deviceOrientation) {\n+ this.setState({ autoFocusPointOfInterest: null });\n+ this.cancelIndicatorAnimation.setValue(1);\n+ }\n}\nget containerStyle() {\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Wipe focus points on device orientation changes in CameraModal
129,187
06.11.2019 21:23:31
18,000
c6ea540834ae6893fbe320b46779b0062a52199d
[native] Factor out getAndroidPermission Since Android restarts any application after its permissions change, we can safely persist granted state.
[ { "change_type": "MODIFY", "old_path": "native/media/image-gallery-keyboard.react.js", "new_path": "native/media/image-gallery-keyboard.react.js", "diff": "@@ -35,6 +35,7 @@ import {\nimport ImageGalleryImage from './image-gallery-image.react';\nimport Animated, { Easing } from 'react-native-reanimated';\nimport { colorsSelector, styleSelector } from '../themes/colors';\n+import { getAndroidPermission } from '../utils/android-permissions';\nconst animationSpec = {\nduration: 400,\n@@ -73,7 +74,6 @@ class ImageGalleryKeyboard extends React.PureComponent<Props, State> {\nqueueModeProgress = new Animated.Value(0);\nsendButtonStyle: ViewStyle;\nimagesSelected = false;\n- androidPermissionsGranted: bool | void;\nconstructor(props: Props) {\nsuper(props);\n@@ -279,26 +279,17 @@ class ImageGalleryKeyboard extends React.PureComponent<Props, State> {\n}\nasync getAndroidPermissions(): Promise<bool> {\n- if (this.androidPermissionsGranted !== undefined) {\n- return this.androidPermissionsGranted;\n- }\n- try {\n- const granted = await PermissionsAndroid.request(\n+ const granted = await getAndroidPermission(\nPermissionsAndroid.PERMISSIONS.READ_EXTERNAL_STORAGE,\n{\ntitle: \"Access Your Photos\",\nmessage: \"Requesting access to your external storage\",\n},\n)\n- if (granted !== PermissionsAndroid.RESULTS.GRANTED) {\n- throw new Error('android_permissions');\n- }\n- this.androidPermissionsGranted = true;\n- } catch (err) {\n+ if (!granted) {\nthis.guardedSetState({ error: \"don't have permission :(\" });\n- this.androidPermissionsGranted = false;\n}\n- return this.androidPermissionsGranted;\n+ return granted;\n}\nget queueModeActive() {\n" }, { "change_type": "MODIFY", "old_path": "native/media/save-image.js", "new_path": "native/media/save-image.js", "diff": "@@ -11,6 +11,7 @@ import { fileInfoFromData } from 'lib/utils/file-utils';\nimport { blobToDataURI, dataURIToIntArray } from '../utils/media-utils';\nimport { displayActionResultModal } from '../navigation/action-result-modal';\n+import { getAndroidPermission } from '../utils/android-permissions';\nasync function saveImage(mediaInfo: MediaInfo) {\nlet result, message;\n@@ -34,7 +35,13 @@ async function saveImage(mediaInfo: MediaInfo) {\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) {\n- const hasPermission = await getAndroidPermissions();\n+ const hasPermission = await getAndroidPermission(\n+ PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE,\n+ {\n+ title: \"Save Photo\",\n+ message: \"Requesting access to your external storage\",\n+ },\n+ );\nif (!hasPermission) {\nreturn false;\n}\n@@ -45,24 +52,6 @@ async function saveImageAndroid(mediaInfo: MediaInfo) {\nreturn true;\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// On iOS, we save the image to the camera roll\nasync function saveImageIOS(mediaInfo: MediaInfo) {\nconst { uri, type } = mediaInfo;\n" }, { "change_type": "ADD", "old_path": null, "new_path": "native/utils/android-permissions.js", "diff": "+// @flow\n+\n+import { PermissionsAndroid, type Rationale } from 'react-native';\n+\n+const granted = new Set();\n+\n+async function getAndroidPermission(\n+ permission: string,\n+ rationale?: Rationale,\n+) {\n+ if (granted.has(permission)) {\n+ return true;\n+ }\n+ try {\n+ const result = await PermissionsAndroid.request(permission, rationale);\n+ const gotPermission = result === PermissionsAndroid.RESULTS.GRANTED;\n+ if (gotPermission) {\n+ granted.add(permission);\n+ }\n+ return gotPermission;\n+ } catch (err) {\n+ return false;\n+ }\n+}\n+\n+export {\n+ getAndroidPermission,\n+};\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Factor out getAndroidPermission Since Android restarts any application after its permissions change, we can safely persist granted state.
129,187
06.11.2019 21:24:02
18,000
570c0d4b617d7b1ed47051a6d51c7a4f5d044233
[native] Recheck Android permissions on foreground in CameraModal
[ { "change_type": "MODIFY", "old_path": "native/media/camera-modal.react.js", "new_path": "native/media/camera-modal.react.js", "diff": "@@ -229,6 +229,7 @@ type Props = {\ncontentVerticalOffset: number,\ndeviceCameraInfo: DeviceCameraInfo,\ndeviceOrientation: Orientations,\n+ foreground: bool,\n// Redux dispatch functions\ndispatchActionPayload: DispatchActionPayload,\n};\n@@ -252,8 +253,10 @@ class CameraModal extends React.PureComponent<Props, State> {\ncontentVerticalOffset: PropTypes.number.isRequired,\ndeviceCameraInfo: deviceCameraInfoPropType.isRequired,\ndeviceOrientation: PropTypes.string.isRequired,\n+ foreground: PropTypes.bool.isRequired,\ndispatchActionPayload: PropTypes.func.isRequired,\n};\n+ camera: ?RNCamera;\npinchEvent;\npinchHandler = React.createRef();\n@@ -537,6 +540,10 @@ class CameraModal extends React.PureComponent<Props, State> {\nthis.setState({ autoFocusPointOfInterest: null });\nthis.cancelIndicatorAnimation.setValue(1);\n}\n+\n+ if (this.props.foreground && !prevProps.foreground && this.camera) {\n+ this.camera.refreshAuthorizationStatus();\n+ }\n}\nget containerStyle() {\n@@ -686,6 +693,7 @@ class CameraModal extends React.PureComponent<Props, State> {\nautoFocusPointOfInterest={this.state.autoFocusPointOfInterest}\nstyle={styles.fill}\nandroidCameraPermissionOptions={permissionRationale}\n+ ref={this.cameraRef}\n>\n{this.renderCamera}\n</RNCamera>\n@@ -696,6 +704,10 @@ class CameraModal extends React.PureComponent<Props, State> {\n);\n}\n+ cameraRef = (camera: ?RNCamera) => {\n+ this.camera = camera;\n+ }\n+\ncloseButtonRef = (closeButton: ?TouchableOpacity) => {\nthis.closeButton = closeButton;\n}\n@@ -974,6 +986,7 @@ export default connect(\ncontentVerticalOffset: contentVerticalOffsetSelector(state),\ndeviceCameraInfo: state.deviceCameraInfo,\ndeviceOrientation: state.deviceOrientation,\n+ foreground: state.foreground,\n}),\nnull,\ntrue,\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Recheck Android permissions on foreground in CameraModal
129,187
06.11.2019 21:53:03
18,000
ab789c48ec6cf9f33b28bd4d8330c4a4bcd31978
[native] Actually send photo in CameraModal
[ { "change_type": "MODIFY", "old_path": "native/chat/chat-input-bar.react.js", "new_path": "native/chat/chat-input-bar.react.js", "diff": "@@ -537,7 +537,10 @@ class ChatInputBar extends React.PureComponent<Props, State> {\n}\nopenCamera = () => {\n- this.props.navigation.navigate({ routeName: CameraModalRouteName });\n+ this.props.navigation.navigate({\n+ routeName: CameraModalRouteName,\n+ params: { threadID: this.props.threadInfo.id },\n+ });\n}\nopenImageGallery = () => {\n" }, { "change_type": "MODIFY", "old_path": "native/media/camera-modal.react.js", "new_path": "native/media/camera-modal.react.js", "diff": "@@ -15,6 +15,11 @@ import {\ndeviceCameraInfoPropType,\n} from '../types/camera';\nimport type { Orientations } from 'react-native-orientation-locker';\n+import {\n+ type ChatInputState,\n+ chatInputStatePropType,\n+ withChatInputState,\n+} from '../chat/chat-input-state';\nimport * as React from 'react';\nimport {\n@@ -219,8 +224,15 @@ function runIndicatorAnimation(\n]);\n}\n+type NavProp = NavigationStackProp<{|\n+ ...NavigationLeafRoute,\n+ params: {|\n+ threadID: string,\n+ |},\n+|}>;\n+\ntype Props = {\n- navigation: NavigationStackProp<NavigationLeafRoute>,\n+ navigation: NavProp,\nscene: NavigationStackScene,\ntransitionProps: NavigationStackTransitionProps,\nposition: Value,\n@@ -230,6 +242,8 @@ type Props = {\ndeviceCameraInfo: DeviceCameraInfo,\ndeviceOrientation: Orientations,\nforeground: bool,\n+ // withChatInputState\n+ chatInputState: ?ChatInputState,\n// Redux dispatch functions\ndispatchActionPayload: DispatchActionPayload,\n};\n@@ -244,6 +258,11 @@ class CameraModal extends React.PureComponent<Props, State> {\nstatic propTypes = {\nnavigation: PropTypes.shape({\n+ state: PropTypes.shape({\n+ params: PropTypes.shape({\n+ threadID: PropTypes.string.isRequired,\n+ }).isRequired,\n+ }).isRequired,\ngoBack: PropTypes.func.isRequired,\n}).isRequired,\nscene: PropTypes.object.isRequired,\n@@ -254,6 +273,7 @@ class CameraModal extends React.PureComponent<Props, State> {\ndeviceCameraInfo: deviceCameraInfoPropType.isRequired,\ndeviceOrientation: PropTypes.string.isRequired,\nforeground: PropTypes.bool.isRequired,\n+ chatInputState: chatInputStatePropType,\ndispatchActionPayload: PropTypes.func.isRequired,\n};\ncamera: ?RNCamera;\n@@ -780,7 +800,19 @@ class CameraModal extends React.PureComponent<Props, State> {\nthis.props.navigation.goBack();\n}\n- takePhoto = () => {\n+ takePhoto = async () => {\n+ const { camera } = this;\n+ invariant(camera, \"camera ref should be set\");\n+ const { uri, width, height } = await camera.takePictureAsync({\n+ pauseAfterCapture: true,\n+ });\n+ const imageInfos = [ { uri, width, height } ];\n+ const { chatInputState } = this.props;\n+ invariant(chatInputState, \"chatInputState should be set\");\n+ await chatInputState.sendMultimediaMessage(\n+ this.props.navigation.state.params.threadID,\n+ imageInfos,\n+ );\n}\nswitchCamera = () => {\n@@ -990,4 +1022,4 @@ export default connect(\n}),\nnull,\ntrue,\n-)(CameraModal);\n+)(withChatInputState(CameraModal));\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Actually send photo in CameraModal
129,187
06.11.2019 22:31:47
18,000
faa547e9d9203c97b6b660fb759ce02a177da86e
[native] saveImage -> intentionalSaveImage
[ { "change_type": "MODIFY", "old_path": "native/chat/multimedia-tooltip-modal.react.js", "new_path": "native/chat/multimedia-tooltip-modal.react.js", "diff": "@@ -7,7 +7,7 @@ import type {\nimport { createTooltip, tooltipHeight } from '../navigation/tooltip.react';\nimport MultimediaTooltipButton from './multimedia-tooltip-button.react';\n-import { saveImage } from '../media/save-image';\n+import { intentionalSaveImage } from '../media/save-image';\ntype CustomProps = {\nitem: ChatMultimediaMessageInfoItem,\n@@ -16,7 +16,7 @@ type CustomProps = {\n};\nfunction onPressSave(props: CustomProps) {\n- return saveImage(props.mediaInfo);\n+ return intentionalSaveImage(props.mediaInfo);\n}\nconst spec = {\n" }, { "change_type": "MODIFY", "old_path": "native/media/multimedia-modal.react.js", "new_path": "native/media/multimedia-modal.react.js", "diff": "@@ -53,7 +53,7 @@ import {\ngestureJustStarted,\ngestureJustEnded,\n} from '../utils/animation-utils';\n-import { saveImage } from './save-image';\n+import { intentionalSaveImage } from './save-image';\nconst {\nValue,\n@@ -1238,7 +1238,7 @@ class MultimediaModal extends React.PureComponent<Props, State> {\n}\nsave = async () => {\n- await saveImage(this.props.navigation.state.params.mediaInfo);\n+ await intentionalSaveImage(this.props.navigation.state.params.mediaInfo);\n}\nsetCloseButtonEnabled = ([ enabledNum ]: [ number ]) => {\n" }, { "change_type": "MODIFY", "old_path": "native/media/save-image.js", "new_path": "native/media/save-image.js", "diff": "// @flow\n-import type { MediaInfo } from 'lib/types/media-types';\n+import type { MediaType } from 'lib/types/media-types';\nimport { Platform, PermissionsAndroid } from 'react-native';\nimport filesystem from 'react-native-fs';\n@@ -13,10 +13,16 @@ import { blobToDataURI, dataURIToIntArray } from '../utils/media-utils';\nimport { displayActionResultModal } from '../navigation/action-result-modal';\nimport { getAndroidPermission } from '../utils/android-permissions';\n-async function saveImage(mediaInfo: MediaInfo) {\n+type SaveImageInfo = {\n+ uri: string,\n+ type: MediaType,\n+ ...\n+};\n+\n+async function intentionalSaveImage(mediaInfo: SaveImageInfo) {\nlet result, message;\nif (Platform.OS === \"android\") {\n- result = await saveImageAndroid(mediaInfo);\n+ result = await saveImageAndroid(mediaInfo, \"request\");\n} else if (Platform.OS === \"ios\") {\nresult = await saveImageIOS(mediaInfo);\n} else {\n@@ -34,17 +40,28 @@ async function saveImage(mediaInfo: MediaInfo) {\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\n-async function saveImageAndroid(mediaInfo: MediaInfo) {\n- const hasPermission = await getAndroidPermission(\n+async function saveImageAndroid(\n+ mediaInfo: SaveImageInfo,\n+ permissions: \"check\" | \"request\",\n+) {\n+ let hasPermission;\n+ if (permissions === \"check\") {\n+ hasPermission = await getAndroidPermission(\nPermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE,\n{\ntitle: \"Save Photo\",\nmessage: \"Requesting access to your external storage\",\n},\n);\n+ } else {\n+ hasPermission = await PermissionsAndroid.check(\n+ PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE,\n+ );\n+ }\nif (!hasPermission) {\nreturn false;\n}\n+\nconst saveFolder = `${filesystem.PicturesDirectoryPath}/SquadCal`;\nawait filesystem.mkdir(saveFolder);\nconst filePath = await saveToDisk(mediaInfo.uri, saveFolder);\n@@ -53,7 +70,7 @@ async function saveImageAndroid(mediaInfo: MediaInfo) {\n}\n// On iOS, we save the image to the camera roll\n-async function saveImageIOS(mediaInfo: MediaInfo) {\n+async function saveImageIOS(mediaInfo: SaveImageInfo) {\nconst { uri, type } = mediaInfo;\nlet tempFile;\n@@ -90,5 +107,5 @@ async function saveToDisk(uri: string, directory: string) {\n}\nexport {\n- saveImage,\n+ intentionalSaveImage,\n};\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] saveImage -> intentionalSaveImage
129,187
06.11.2019 22:33:08
18,000
bb3930bd3fadeda19fe3dca2cbf1d167ebdd6030
[native] Save captured images in CameraModal
[ { "change_type": "MODIFY", "old_path": "native/media/camera-modal.react.js", "new_path": "native/media/camera-modal.react.js", "diff": "@@ -53,6 +53,7 @@ import ConnectedStatusBar from '../connected-status-bar.react';\nimport { clamp, gestureJustEnded } from '../utils/animation-utils';\nimport ContentLoading from '../components/content-loading.react';\nimport { colors } from '../themes/colors';\n+import { saveImage } from './save-image';\nconst {\nValue,\n@@ -809,10 +810,13 @@ class CameraModal extends React.PureComponent<Props, State> {\nconst imageInfos = [ { uri, width, height } ];\nconst { chatInputState } = this.props;\ninvariant(chatInputState, \"chatInputState should be set\");\n- await chatInputState.sendMultimediaMessage(\n+ await Promise.all([\n+ chatInputState.sendMultimediaMessage(\nthis.props.navigation.state.params.threadID,\nimageInfos,\n- );\n+ ),\n+ saveImage({ uri, type: \"photo\" }),\n+ ]);\n}\nswitchCamera = () => {\n" }, { "change_type": "MODIFY", "old_path": "native/media/save-image.js", "new_path": "native/media/save-image.js", "diff": "@@ -38,6 +38,14 @@ async function intentionalSaveImage(mediaInfo: SaveImageInfo) {\ndisplayActionResultModal(message);\n}\n+async function saveImage(mediaInfo: SaveImageInfo) {\n+ if (Platform.OS === \"android\") {\n+ await saveImageAndroid(mediaInfo, \"check\");\n+ } else if (Platform.OS === \"ios\") {\n+ await saveImageIOS(mediaInfo);\n+ }\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(\n@@ -108,4 +116,5 @@ async function saveToDisk(uri: string, directory: string) {\nexport {\nintentionalSaveImage,\n+ saveImage,\n};\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Save captured images in CameraModal
129,187
06.11.2019 22:35:03
18,000
13b7c6b3bfb3205d70fecb1d74c890a991b7bdfb
[native] Remove temp image files from camera after sending
[ { "change_type": "MODIFY", "old_path": "native/chat/chat-input-state-container.react.js", "new_path": "native/chat/chat-input-state-container.react.js", "diff": "// @flow\n-import type { PendingMultimediaUploads } from './chat-input-state';\n-import type { GalleryImageInfo } from '../media/image-gallery-image.react';\n+import type {\n+ PendingMultimediaUploads,\n+ ClientImageInfo,\n+} from './chat-input-state';\nimport type { AppState } from '../redux/redux-setup';\nimport type {\nDispatchActionPayload,\n@@ -82,6 +84,7 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\nstate = {\npendingUploads: {},\n};\n+ pendingUnlinkURIs = new Set();\nstatic getCompletedUploads(props: Props, state: State): CompletedUploads {\nconst completedUploads = {};\n@@ -239,13 +242,20 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\nsendMultimediaMessage: this.sendMultimediaMessage,\nmessageHasUploadFailure: this.messageHasUploadFailure,\nretryMultimediaMessage: this.retryMultimediaMessage,\n+ clearURI: this.clearURI,\n}),\n);\nsendMultimediaMessage = async (\nthreadID: string,\n- inputImageInfos: $ReadOnlyArray<GalleryImageInfo>,\n+ inputImageInfos: $ReadOnlyArray<ClientImageInfo>,\n) => {\n+ const urisToUnlink = new Set(\n+ inputImageInfos.filter(\n+ inputImageInfo => !!inputImageInfo.unlinkURIAfterRemoving,\n+ ).map(inputImageInfo => inputImageInfo.uri),\n+ );\n+\nconst validationResults = await Promise.all(\ninputImageInfos.map(validateMedia),\n);\n@@ -265,11 +275,14 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\n}\nconst pendingUploads = {};\n- for (let { localID } of imageInfos) {\n+ for (let { localID, uri } of imageInfos) {\npendingUploads[localID] = {\nfailed: null,\nprogressPercent: 0,\n};\n+ if (urisToUnlink.has(uri)) {\n+ this.pendingUnlinkURIs.add(uri);\n+ }\n}\nthis.setState(\n@@ -534,6 +547,24 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\nawait this.uploadFiles(localMessageID, imageInfos);\n}\n+ clearURI = async (uri: string) => {\n+ if (!this.pendingUnlinkURIs.has(uri)) {\n+ return;\n+ }\n+ this.pendingUnlinkURIs.delete(uri);\n+ const matches = uri.match(/^file:\\/\\/(.*)$/);\n+ if (!matches) {\n+ return;\n+ }\n+ const path = matches[1];\n+ if (!path) {\n+ return;\n+ }\n+ try {\n+ await filesystem.unlink(path);\n+ } catch (e) { }\n+ }\n+\nrender() {\nconst chatInputState = this.chatInputStateSelector(this.state);\nreturn (\n" }, { "change_type": "MODIFY", "old_path": "native/chat/chat-input-state.js", "new_path": "native/chat/chat-input-state.js", "diff": "@@ -11,6 +11,11 @@ export type PendingMultimediaUpload = {|\nprogressPercent: number,\n|};\n+export type ClientImageInfo = {|\n+ ...GalleryImageInfo,\n+ unlinkURIAfterRemoving?: bool,\n+|};\n+\nconst pendingMultimediaUploadPropType = PropTypes.shape({\nfailed: PropTypes.string,\nprogressPercent: PropTypes.number.isRequired,\n@@ -36,10 +41,11 @@ export type ChatInputState = {|\npendingUploads: PendingMultimediaUploads,\nsendMultimediaMessage: (\nthreadID: string,\n- imageInfos: $ReadOnlyArray<GalleryImageInfo>,\n+ imageInfos: $ReadOnlyArray<ClientImageInfo>,\n) => Promise<void>,\nmessageHasUploadFailure: (localMessageID: string) => bool,\nretryMultimediaMessage: (localMessageID: string) => Promise<void>,\n+ clearURI: (uri: string) => Promise<void>,\n|};\nconst chatInputStatePropType = PropTypes.shape({\n@@ -47,6 +53,7 @@ const chatInputStatePropType = PropTypes.shape({\nsendMultimediaMessage: PropTypes.func.isRequired,\nmessageHasUploadFailure: PropTypes.func.isRequired,\nretryMultimediaMessage: PropTypes.func.isRequired,\n+ clearURI: PropTypes.func.isRequired,\n});\nconst ChatInputStateContext = React.createContext<?ChatInputState>(null);\n" }, { "change_type": "MODIFY", "old_path": "native/media/camera-modal.react.js", "new_path": "native/media/camera-modal.react.js", "diff": "@@ -807,7 +807,12 @@ class CameraModal extends React.PureComponent<Props, State> {\nconst { uri, width, height } = await camera.takePictureAsync({\npauseAfterCapture: true,\n});\n- const imageInfos = [ { uri, width, height } ];\n+ const imageInfos = [ {\n+ uri,\n+ width,\n+ height,\n+ unlinkURIAfterRemoving: true,\n+ } ];\nconst { chatInputState } = this.props;\ninvariant(chatInputState, \"chatInputState should be set\");\nawait Promise.all([\n" }, { "change_type": "MODIFY", "old_path": "native/media/multimedia.react.js", "new_path": "native/media/multimedia.react.js", "diff": "// @flow\nimport { type MediaInfo, mediaInfoPropType } from 'lib/types/media-types';\n+import {\n+ type ChatInputState,\n+ chatInputStatePropType,\n+ withChatInputState,\n+} from '../chat/chat-input-state';\nimport * as React from 'react';\nimport PropTypes from 'prop-types';\n@@ -11,6 +16,8 @@ import RemoteImage from './remote-image.react';\ntype Props = {|\nmediaInfo: MediaInfo,\nspinnerColor: string,\n+ // withChatInputState\n+ chatInputState: ?ChatInputState,\n|};\ntype State = {|\ncurrentURI: string,\n@@ -21,6 +28,7 @@ class Multimedia extends React.PureComponent<Props, State> {\nstatic propTypes = {\nmediaInfo: mediaInfoPropType.isRequired,\nspinnerColor: PropTypes.string.isRequired,\n+ chatInputState: chatInputStatePropType,\n};\nstatic defaultProps = {\nspinnerColor: \"black\",\n@@ -65,7 +73,7 @@ class Multimedia extends React.PureComponent<Props, State> {\nreturn (\n<RemoteImage\nuri={uri}\n- onLoad={this.onRemoteImageLoad}\n+ onLoad={this.onLoad}\nspinnerColor={this.props.spinnerColor}\nstyle={styles.image}\ninvisibleLoad={invisibleLoad}\n@@ -85,15 +93,14 @@ class Multimedia extends React.PureComponent<Props, State> {\n}\n}\n- onRemoteImageLoad = (uri: string) => {\n- if (this.state.departingURI) {\n- this.setState({ departingURI: null });\n- }\n- }\n-\nonLoad = () => {\n- if (this.state.departingURI) {\n+ const { departingURI } = this.state;\n+ if (!departingURI) {\n+ return;\n+ }\nthis.setState({ departingURI: null });\n+ if (this.props.chatInputState) {\n+ this.props.chatInputState.clearURI(departingURI);\n}\n}\n@@ -112,4 +119,4 @@ const styles = StyleSheet.create({\n},\n});\n-export default Multimedia;\n+export default withChatInputState(Multimedia);\n" }, { "change_type": "MODIFY", "old_path": "native/utils/media-utils.js", "new_path": "native/utils/media-utils.js", "diff": "@@ -21,10 +21,17 @@ export type MediaValidationResult = {\nmediaType: MediaType,\nblob: ReactNativeBlob,\n};\n+type ValidateMediaInput = {\n+ uri: string,\n+ height: number,\n+ width: number,\n+ ...\n+};\nasync function validateMedia(\n- imageInfo: GalleryImageInfo,\n+ imageInfo: ValidateMediaInput,\n): Promise<?MediaValidationResult> {\n- const { uri, ...dimensions } = imageInfo;\n+ const { uri, height, width } = imageInfo;\n+ const dimensions = { height, width };\nconst response = await fetch(uri);\nconst blob = await response.blob();\nconst reportedMIME = blob.type;\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Remove temp image files from camera after sending
129,187
06.11.2019 22:40:10
18,000
f464037524d0558de1eb4c4c11cf1df60f554f03
[native] CameraModal.sendPhoto
[ { "change_type": "MODIFY", "old_path": "native/media/camera-modal.react.js", "new_path": "native/media/camera-modal.react.js", "diff": "@@ -19,6 +19,7 @@ import {\ntype ChatInputState,\nchatInputStatePropType,\nwithChatInputState,\n+ type ClientImageInfo,\n} from '../chat/chat-input-state';\nimport * as React from 'react';\n@@ -254,6 +255,7 @@ type State = {|\nhasCamerasOnBothSides: bool,\nflashMode: number,\nautoFocusPointOfInterest: ?{| x: number, y: number, autoExposure?: bool |},\n+ pendingImageInfo: ?ClientImageInfo,\n|};\nclass CameraModal extends React.PureComponent<Props, State> {\n@@ -328,6 +330,7 @@ class CameraModal extends React.PureComponent<Props, State> {\nhasCamerasOnBothSides: props.deviceCameraInfo.hasCamerasOnBothSides,\nflashMode: RNCamera.Constants.FlashMode.off,\nautoFocusPointOfInterest: undefined,\n+ pendingImageInfo: undefined,\n};\nconst { position } = props;\n@@ -807,21 +810,29 @@ class CameraModal extends React.PureComponent<Props, State> {\nconst { uri, width, height } = await camera.takePictureAsync({\npauseAfterCapture: true,\n});\n- const imageInfos = [ {\n+ const pendingImageInfo = {\nuri,\nwidth,\nheight,\nunlinkURIAfterRemoving: true,\n- } ];\n+ };\n+ this.setState({ pendingImageInfo });\n+ await this.sendPhoto();\n+ }\n+\n+ async sendPhoto() {\n+ const { pendingImageInfo } = this.state;\n+ invariant(pendingImageInfo, \"pendingImageInfo should be set\");\nconst { chatInputState } = this.props;\ninvariant(chatInputState, \"chatInputState should be set\");\nawait Promise.all([\nchatInputState.sendMultimediaMessage(\nthis.props.navigation.state.params.threadID,\n- imageInfos,\n+ [ pendingImageInfo ],\n),\n- saveImage({ uri, type: \"photo\" }),\n+ saveImage({ uri: pendingImageInfo.uri, type: \"photo\" }),\n]);\n+ this.close();\n}\nswitchCamera = () => {\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] CameraModal.sendPhoto
129,187
07.11.2019 14:34:20
18,000
47008f8484945cd319a82294aff0841763e07302
[native] Increase CameraModal tap target size
[ { "change_type": "MODIFY", "old_path": "native/media/camera-modal.react.js", "new_path": "native/media/camera-modal.react.js", "diff": "@@ -656,7 +656,7 @@ class CameraModal extends React.PureComponent<Props, State> {\n}\nconst topButtonStyle = {\n- top: Math.max(this.props.contentVerticalOffset, 6),\n+ top: Math.max(this.props.contentVerticalOffset - 3, 3),\n};\nreturn (\n<>\n@@ -941,7 +941,9 @@ const styles = StyleSheet.create({\n},\ncloseButton: {\nposition: 'absolute',\n- left: 24,\n+ left: 16,\n+ paddingBottom: 2,\n+ paddingHorizontal: 8,\n},\ncloseIcon: {\nfontSize: 36,\n@@ -976,21 +978,24 @@ const styles = StyleSheet.create({\n},\nswitchCameraButton: {\nposition: 'absolute',\n- right: 26,\n+ right: 18,\n+ paddingVertical: 2,\n+ paddingHorizontal: 8,\njustifyContent: 'center',\n},\nswitchCameraIcon: {\ncolor: 'white',\nfontSize: 36,\n- paddingBottom: 2,\ntextShadowColor: 'black',\ntextShadowOffset: { width: 0, height: 1 },\ntextShadowRadius: 1,\n},\nflashButton: {\nposition: 'absolute',\n+ right: 15,\nmarginTop: Platform.select({ android: 15, default: 13 }),\n- right: 25,\n+ paddingVertical: 3,\n+ paddingHorizontal: 10,\n},\nflashIcon: {\nfontSize: 24,\n@@ -1001,8 +1006,8 @@ const styles = StyleSheet.create({\n},\nflashIconAutoText: {\nposition: 'absolute',\n- top: -3,\n- right: -5,\n+ top: 0,\n+ right: 5,\nfontSize: 10,\nfontWeight: 'bold',\ncolor: \"white\",\n" }, { "change_type": "MODIFY", "old_path": "native/media/multimedia-modal.react.js", "new_path": "native/media/multimedia-modal.react.js", "diff": "@@ -1312,10 +1312,8 @@ const styles = StyleSheet.create({\nright: 4,\n},\ncloseButton: {\n- paddingTop: 2,\n- paddingBottom: 2,\n- paddingLeft: 8,\n- paddingRight: 8,\n+ paddingVertical: 2,\n+ paddingHorizontal: 8,\nfontSize: 36,\ncolor: \"white\",\ntextShadowColor: \"#000\",\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Increase CameraModal tap target size
129,187
07.11.2019 14:44:18
18,000
c3c4161de8127dfaea3e1c5bb33c35bc57799e7b
[native] Don't use GestureHandlers in CameraModal unless camera active
[ { "change_type": "MODIFY", "old_path": "native/media/camera-modal.react.js", "new_path": "native/media/camera-modal.react.js", "diff": "@@ -659,7 +659,20 @@ class CameraModal extends React.PureComponent<Props, State> {\ntop: Math.max(this.props.contentVerticalOffset - 3, 3),\n};\nreturn (\n- <>\n+ <PinchGestureHandler\n+ onGestureEvent={this.pinchEvent}\n+ onHandlerStateChange={this.pinchEvent}\n+ simultaneousHandlers={this.tapHandler}\n+ ref={this.pinchHandler}\n+ >\n+ <Animated.View style={styles.fill}>\n+ <TapGestureHandler\n+ onHandlerStateChange={this.tapEvent}\n+ simultaneousHandlers={this.pinchHandler}\n+ waitFor={this.pinchHandler}\n+ ref={this.tapHandler}\n+ >\n+ <Animated.View style={styles.fill}>\n<Animated.View style={this.focusIndicatorStyle} />\n<TouchableOpacity\nonPress={this.changeFlashMode}\n@@ -680,7 +693,10 @@ class CameraModal extends React.PureComponent<Props, State> {\n</TouchableOpacity>\n{switchCameraButton}\n</View>\n- </>\n+ </Animated.View>\n+ </TapGestureHandler>\n+ </Animated.View>\n+ </PinchGestureHandler>\n);\n}\n@@ -692,22 +708,9 @@ class CameraModal extends React.PureComponent<Props, State> {\n? RNCamera.Constants.Type.front\n: RNCamera.Constants.Type.back;\nreturn (\n- <PinchGestureHandler\n- onGestureEvent={this.pinchEvent}\n- onHandlerStateChange={this.pinchEvent}\n- simultaneousHandlers={this.tapHandler}\n- ref={this.pinchHandler}\n- >\n<Animated.View style={this.containerStyle}>\n{statusBar}\n<Animated.Code exec={this.animationCode} />\n- <TapGestureHandler\n- onHandlerStateChange={this.tapEvent}\n- simultaneousHandlers={this.pinchHandler}\n- waitFor={this.pinchHandler}\n- ref={this.tapHandler}\n- >\n- <Animated.View style={styles.fill}>\n<RNCamera\ntype={type}\ncaptureAudio={false}\n@@ -722,9 +725,6 @@ class CameraModal extends React.PureComponent<Props, State> {\n{this.renderCamera}\n</RNCamera>\n</Animated.View>\n- </TapGestureHandler>\n- </Animated.View>\n- </PinchGestureHandler>\n);\n}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Don't use GestureHandlers in CameraModal unless camera active
129,187
07.11.2019 17:32:09
18,000
2bf61354570cc642e26a223ba87fbd4dd392c864
[native] SendMediaButton
[ { "change_type": "MODIFY", "old_path": "native/media/image-gallery-keyboard.react.js", "new_path": "native/media/image-gallery-keyboard.react.js", "diff": "@@ -15,13 +15,11 @@ import {\nPermissionsAndroid,\nFlatList,\nActivityIndicator,\n- TouchableOpacity,\n} from 'react-native';\nimport { KeyboardRegistry } from 'react-native-keyboard-input';\nimport invariant from 'invariant';\nimport { Provider } from 'react-redux';\nimport CameraRoll from '@react-native-community/cameraroll';\n-import Icon from 'react-native-vector-icons/FontAwesome';\nimport PropTypes from 'prop-types';\nimport { connect } from 'lib/utils/redux-utils';\n@@ -36,6 +34,7 @@ import ImageGalleryImage from './image-gallery-image.react';\nimport Animated, { Easing } from 'react-native-reanimated';\nimport { colorsSelector, styleSelector } from '../themes/colors';\nimport { getAndroidPermission } from '../utils/android-permissions';\n+import SendMediaButton from './send-media-button.react';\nconst animationSpec = {\nduration: 400,\n@@ -85,7 +84,6 @@ class ImageGalleryKeyboard extends React.PureComponent<Props, State> {\n},\n);\nthis.sendButtonStyle = {\n- ...props.styles.sendButton,\nopacity: this.queueModeProgress,\ntransform: [\n{ scale: sendButtonScale },\n@@ -374,20 +372,12 @@ class ImageGalleryKeyboard extends React.PureComponent<Props, State> {\nonLayout={this.onContainerLayout}\n>\n{content}\n- <TouchableOpacity\n+ <SendMediaButton\nonPress={this.sendQueuedImages}\n- activeOpacity={0.6}\n- style={this.props.styles.sendButtonContainer}\n- >\n- <Animated.View style={this.sendButtonStyle}>\n- <Icon name=\"send\" style={this.props.styles.sendIcon} />\n- <View style={this.props.styles.queueCountBubble}>\n- <Text style={this.props.styles.queueCountText}>\n- {queueCount}\n- </Text>\n- </View>\n- </Animated.View>\n- </TouchableOpacity>\n+ queueCount={queueCount}\n+ containerStyle={this.props.styles.sendButtonContainer}\n+ style={this.sendButtonStyle}\n+ />\n</View>\n);\n}\n@@ -519,37 +509,6 @@ const styles = {\nbottom: 30,\nright: 30,\n},\n- sendButton: {\n- backgroundColor: '#7ED321',\n- borderRadius: 30,\n- paddingLeft: 14,\n- paddingRight: 16,\n- paddingTop: 14,\n- paddingBottom: 16,\n- borderWidth: 4,\n- borderColor: 'white',\n- },\n- sendIcon: {\n- color: 'white',\n- fontSize: 22,\n- },\n- queueCountBubble: {\n- backgroundColor: '#222222',\n- position: 'absolute',\n- top: -8,\n- right: -8,\n- width: 25,\n- height: 25,\n- paddingLeft: 1,\n- paddingBottom: Platform.OS === \"android\" ? 2 : 0,\n- borderRadius: 25,\n- alignItems: 'center',\n- justifyContent: 'center',\n- },\n- queueCountText: {\n- textAlign: 'center',\n- color: 'white',\n- },\n};\nconst stylesSelector = styleSelector(styles);\n" }, { "change_type": "ADD", "old_path": null, "new_path": "native/media/send-media-button.react.js", "diff": "+// @flow\n+\n+import type { ViewStyle } from '../types/styles';\n+\n+import * as React from 'react';\n+import {\n+ TouchableOpacity,\n+ View,\n+ Text,\n+ StyleSheet,\n+ Platform,\n+} from 'react-native';\n+import Icon from 'react-native-vector-icons/FontAwesome';\n+import Animated from 'react-native-reanimated';\n+\n+type Props = {|\n+ onPress: () => mixed,\n+ queueCount?: number,\n+ containerStyle?: ViewStyle,\n+ style?: ViewStyle,\n+|};\n+function SendMediaButton(props: Props) {\n+ let queueCount = null;\n+ if (props.queueCount !== undefined && props.queueCount !== null) {\n+ queueCount = (\n+ <View style={styles.queueCountBubble}>\n+ <Text style={styles.queueCountText}>\n+ {props.queueCount}\n+ </Text>\n+ </View>\n+ );\n+ }\n+ return (\n+ <TouchableOpacity\n+ onPress={props.onPress}\n+ activeOpacity={0.6}\n+ style={props.containerStyle}\n+ >\n+ <Animated.View style={[ styles.sendButton, props.style ]}>\n+ <Icon name=\"send\" style={styles.sendIcon} />\n+ {queueCount}\n+ </Animated.View>\n+ </TouchableOpacity>\n+ );\n+}\n+\n+const styles = StyleSheet.create({\n+ sendButton: {\n+ backgroundColor: '#7ED321',\n+ borderRadius: 30,\n+ paddingLeft: 14,\n+ paddingRight: 16,\n+ paddingTop: 14,\n+ paddingBottom: 16,\n+ borderWidth: 4,\n+ borderColor: 'white',\n+ },\n+ sendIcon: {\n+ color: 'white',\n+ fontSize: 22,\n+ },\n+ queueCountBubble: {\n+ backgroundColor: '#222222',\n+ position: 'absolute',\n+ top: -8,\n+ right: -8,\n+ width: 25,\n+ height: 25,\n+ paddingLeft: 1,\n+ paddingBottom: Platform.OS === \"android\" ? 2 : 0,\n+ borderRadius: 25,\n+ alignItems: 'center',\n+ justifyContent: 'center',\n+ },\n+ queueCountText: {\n+ textAlign: 'center',\n+ color: 'white',\n+ },\n+});\n+\n+export default SendMediaButton;\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] SendMediaButton
129,187
07.11.2019 18:35:11
18,000
3eb73caad241c04af047a7810d7d5642cf3dadeb
[native] Staging mode for CameraModal
[ { "change_type": "MODIFY", "old_path": "native/media/camera-modal.react.js", "new_path": "native/media/camera-modal.react.js", "diff": "@@ -21,6 +21,7 @@ import {\nwithChatInputState,\ntype ClientImageInfo,\n} from '../chat/chat-input-state';\n+import type { ViewStyle } from '../types/styles';\nimport * as React from 'react';\nimport {\n@@ -29,6 +30,7 @@ import {\nStyleSheet,\nTouchableOpacity,\nPlatform,\n+ Image,\n} from 'react-native';\nimport PropTypes from 'prop-types';\nimport Animated, { Easing } from 'react-native-reanimated';\n@@ -39,7 +41,6 @@ import {\nState as GestureState,\n} from 'react-native-gesture-handler';\nimport Icon from 'react-native-vector-icons/Ionicons';\n-import IonIcon from 'react-native-vector-icons/Ionicons';\nimport Orientation from 'react-native-orientation-locker';\nimport invariant from 'invariant';\n@@ -55,6 +56,7 @@ import { clamp, gestureJustEnded } from '../utils/animation-utils';\nimport ContentLoading from '../components/content-loading.react';\nimport { colors } from '../themes/colors';\nimport { saveImage } from './save-image';\n+import SendMediaButton from './send-media-button.react';\nconst {\nValue,\n@@ -102,6 +104,11 @@ const permissionRationale = {\nmessage: \"Requesting access to your device camera\",\n};\n+const stagingModeAnimationConfig = {\n+ duration: 150,\n+ easing: Easing.inOut(Easing.ease),\n+};\n+\nconst indicatorSpringConfig = {\n...SpringUtils.makeDefaultConfig(),\ndamping: 0,\n@@ -255,6 +262,7 @@ type State = {|\nhasCamerasOnBothSides: bool,\nflashMode: number,\nautoFocusPointOfInterest: ?{| x: number, y: number, autoExposure?: bool |},\n+ stagingMode: bool,\npendingImageInfo: ?ClientImageInfo,\n|};\nclass CameraModal extends React.PureComponent<Props, State> {\n@@ -321,6 +329,11 @@ class CameraModal extends React.PureComponent<Props, State> {\ncameraIDsFetched = false;\n+ stagingModeProgress = new Value(0);\n+ sendButtonProgress = new Value(0);\n+ sendButtonStyle: ViewStyle;\n+ overlayStyle: ViewStyle;\n+\nconstructor(props: Props) {\nsuper(props);\n@@ -330,6 +343,7 @@ class CameraModal extends React.PureComponent<Props, State> {\nhasCamerasOnBothSides: props.deviceCameraInfo.hasCamerasOnBothSides,\nflashMode: RNCamera.Constants.FlashMode.off,\nautoFocusPointOfInterest: undefined,\n+ stagingMode: false,\npendingImageInfo: undefined,\n};\n@@ -344,6 +358,33 @@ class CameraModal extends React.PureComponent<Props, State> {\n},\n);\n+ const sendButtonScale = interpolate(\n+ this.sendButtonProgress,\n+ {\n+ inputRange: [ 0, 1 ],\n+ outputRange: [ 1.1, 1 ],\n+ },\n+ );\n+ this.sendButtonStyle = {\n+ opacity: this.sendButtonProgress,\n+ transform: [\n+ { scale: sendButtonScale },\n+ ],\n+ };\n+\n+ const overlayOpacity = interpolate(\n+ this.stagingModeProgress,\n+ {\n+ inputRange: [ 0, 0.01, 1 ],\n+ outputRange: [ 0, 0.5, 0 ],\n+ extrapolate: Extrapolate.CLAMP,\n+ },\n+ );\n+ this.overlayStyle = {\n+ ...styles.overlay,\n+ opacity: overlayOpacity,\n+ };\n+\nconst pinchState = new Value(-1);\nconst pinchScale = new Value(1);\nthis.pinchEvent = event([{\n@@ -568,6 +609,26 @@ class CameraModal extends React.PureComponent<Props, State> {\nif (this.props.foreground && !prevProps.foreground && this.camera) {\nthis.camera.refreshAuthorizationStatus();\n}\n+\n+ if (this.state.stagingMode && !prevState.stagingMode) {\n+ this.cancelIndicatorAnimation.setValue(1);\n+ this.focusIndicatorOpacity.setValue(0);\n+ timing(\n+ this.stagingModeProgress,\n+ { ...stagingModeAnimationConfig, toValue: 1 },\n+ ).start();\n+ } else if (!this.state.stagingMode && prevState.stagingMode) {\n+ this.stagingModeProgress.setValue(0);\n+ }\n+\n+ if (this.state.pendingImageInfo && !prevState.pendingImageInfo) {\n+ timing(\n+ this.sendButtonProgress,\n+ { ...stagingModeAnimationConfig, toValue: 1 },\n+ ).start();\n+ } else if (!this.state.pendingImageInfo && prevState.pendingImageInfo) {\n+ this.sendButtonProgress.setValue(0);\n+ }\n}\nget containerStyle() {\n@@ -593,6 +654,9 @@ class CameraModal extends React.PureComponent<Props, State> {\nif (camera && camera._cameraHandle) {\nthis.fetchCameraIDs(camera);\n}\n+ if (this.state.stagingMode) {\n+ return this.renderStagingView();\n+ }\nconst topButtonStyle = {\ntop: Math.max(this.props.contentVerticalOffset, 6),\n};\n@@ -611,6 +675,36 @@ class CameraModal extends React.PureComponent<Props, State> {\n);\n}\n+ renderStagingView() {\n+ let image = null;\n+ if (this.state.pendingImageInfo) {\n+ const imageSource = { uri: this.state.pendingImageInfo.uri };\n+ image = <Image source={imageSource} style={styles.stagingImage} />;\n+ } else {\n+ image = <ContentLoading fillType=\"flex\" colors={colors.dark} />;\n+ }\n+\n+ const topButtonStyle = {\n+ top: Math.max(this.props.contentVerticalOffset - 3, 3),\n+ };\n+ return (\n+ <>\n+ {image}\n+ <TouchableOpacity\n+ onPress={this.clearPendingImage}\n+ style={[ styles.retakeButton, topButtonStyle ]}\n+ >\n+ <Icon name=\"ios-arrow-back\" style={styles.retakeIcon} />\n+ </TouchableOpacity>\n+ <SendMediaButton\n+ onPress={this.sendPhoto}\n+ containerStyle={styles.sendButtonContainer}\n+ style={this.sendButtonStyle}\n+ />\n+ </>\n+ );\n+ }\n+\nrenderCameraContent(status) {\nif (status === 'PENDING_AUTHORIZATION') {\nreturn <ContentLoading fillType=\"flex\" colors={colors.dark} />;\n@@ -643,13 +737,13 @@ class CameraModal extends React.PureComponent<Props, State> {\nlet flashIcon;\nif (this.state.flashMode === RNCamera.Constants.FlashMode.on) {\n- flashIcon = <IonIcon name=\"ios-flash\" style={styles.flashIcon} />;\n+ flashIcon = <Icon name=\"ios-flash\" style={styles.flashIcon} />;\n} else if (this.state.flashMode === RNCamera.Constants.FlashMode.off) {\n- flashIcon = <IonIcon name=\"ios-flash-off\" style={styles.flashIcon} />;\n+ flashIcon = <Icon name=\"ios-flash-off\" style={styles.flashIcon} />;\n} else {\nflashIcon = (\n<>\n- <IonIcon name=\"ios-flash\" style={styles.flashIcon} />\n+ <Icon name=\"ios-flash\" style={styles.flashIcon} />\n<Text style={styles.flashIconAutoText}>A</Text>\n</>\n);\n@@ -724,6 +818,10 @@ class CameraModal extends React.PureComponent<Props, State> {\n>\n{this.renderCamera}\n</RNCamera>\n+ <Animated.View\n+ style={this.overlayStyle}\n+ pointerEvents=\"none\"\n+ />\n</Animated.View>\n);\n}\n@@ -807,32 +905,51 @@ class CameraModal extends React.PureComponent<Props, State> {\ntakePhoto = async () => {\nconst { camera } = this;\ninvariant(camera, \"camera ref should be set\");\n- const { uri, width, height } = await camera.takePictureAsync({\n- pauseAfterCapture: true,\n+ this.setState({ stagingMode: true });\n+\n+ const photoPromise = camera.takePictureAsync({\n+ pauseAfterCapture: Platform.OS === \"android\",\n});\n+ if (Platform.OS === \"ios\") {\n+ camera.pausePreview();\n+ }\n+\n+ const { uri, width, height } = await photoPromise;\nconst pendingImageInfo = {\nuri,\nwidth,\nheight,\nunlinkURIAfterRemoving: true,\n};\n- this.setState({ pendingImageInfo });\n- await this.sendPhoto();\n+ this.setState({\n+ pendingImageInfo,\n+ zoom: 0,\n+ autoFocusPointOfInterest: undefined,\n+ });\n}\n- async sendPhoto() {\n+ sendPhoto = async () => {\nconst { pendingImageInfo } = this.state;\n- invariant(pendingImageInfo, \"pendingImageInfo should be set\");\n+ if (!pendingImageInfo) {\n+ return;\n+ }\nconst { chatInputState } = this.props;\ninvariant(chatInputState, \"chatInputState should be set\");\n- await Promise.all([\n+ this.close();\nchatInputState.sendMultimediaMessage(\nthis.props.navigation.state.params.threadID,\n[ pendingImageInfo ],\n- ),\n- saveImage({ uri: pendingImageInfo.uri, type: \"photo\" }),\n- ]);\n- this.close();\n+ );\n+ saveImage({ uri: pendingImageInfo.uri, type: \"photo\" });\n+ }\n+\n+ clearPendingImage = () => {\n+ invariant(this.camera, \"camera ref should be set\");\n+ this.camera.resumePreview();\n+ this.setState({\n+ stagingMode: false,\n+ pendingImageInfo: undefined,\n+ });\n}\nswitchCamera = () => {\n@@ -871,17 +988,12 @@ class CameraModal extends React.PureComponent<Props, State> {\n} else if (this.props.deviceOrientation === 'LANDSCAPE-RIGHT') {\nx = 1 - relativeX;\ny = 1 - relativeY;\n- } else if (this.props.deviceOrientation === 'PORTRAIT') {\n- x = relativeY;\n- y = 1 - relativeX;\n} else if (this.props.deviceOrientation === 'PORTRAIT-UPSIDEDOWN') {\nx = 1 - relativeY;\ny = relativeX;\n} else {\n- invariant(\n- false,\n- `unexpected device orientation ${this.props.deviceOrientation}`,\n- );\n+ x = relativeY;\n+ y = 1 - relativeX;\n}\nconst autoFocusPointOfInterest = Platform.OS === \"ios\"\n@@ -1015,6 +1127,20 @@ const styles = StyleSheet.create({\ntextShadowOffset: { width: 0, height: 1 },\ntextShadowRadius: 1,\n},\n+ retakeButton: {\n+ position: 'absolute',\n+ left: 20,\n+ marginTop: Platform.select({ android: 15, default: 15 }),\n+ paddingBottom: 3,\n+ paddingHorizontal: 10,\n+ },\n+ retakeIcon: {\n+ fontSize: 24,\n+ color: 'white',\n+ textShadowColor: 'black',\n+ textShadowOffset: { width: 0, height: 1 },\n+ textShadowRadius: 1,\n+ },\nauthorizationDeniedContainer: {\nflex: 1,\nalignItems: 'center',\n@@ -1035,6 +1161,24 @@ const styles = StyleSheet.create({\nborderWidth: 1,\nborderColor: 'white',\n},\n+ sendButtonContainer: {\n+ position: 'absolute',\n+ right: 32,\n+ bottom: contentBottomOffset + 22,\n+ },\n+ overlay: {\n+ position: 'absolute',\n+ top: 0,\n+ bottom: 0,\n+ left: 0,\n+ right: 0,\n+ backgroundColor: 'white',\n+ },\n+ stagingImage: {\n+ flex: 1,\n+ backgroundColor: 'black',\n+ resizeMode: \"contain\",\n+ },\n});\nexport default connect(\n" }, { "change_type": "MODIFY", "old_path": "native/media/save-image.js", "new_path": "native/media/save-image.js", "diff": "@@ -54,6 +54,10 @@ async function saveImageAndroid(\n) {\nlet hasPermission;\nif (permissions === \"check\") {\n+ hasPermission = await PermissionsAndroid.check(\n+ PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE,\n+ );\n+ } else {\nhasPermission = await getAndroidPermission(\nPermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE,\n{\n@@ -61,10 +65,6 @@ async function saveImageAndroid(\nmessage: \"Requesting access to your external storage\",\n},\n);\n- } else {\n- hasPermission = await PermissionsAndroid.check(\n- PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE,\n- );\n}\nif (!hasPermission) {\nreturn false;\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Staging mode for CameraModal
129,187
08.11.2019 12:40:20
18,000
490ca9925ab0ede33687c0b08b54823690825f6c
[native] Roll back react-native-progress
[ { "change_type": "MODIFY", "old_path": "native/ios/Podfile", "new_path": "native/ios/Podfile", "diff": "@@ -16,6 +16,7 @@ target 'SquadCal' do\npod 'React-RCTText', :path => '../../node_modules/react-native/Libraries/Text'\npod 'React-RCTVibration', :path => '../../node_modules/react-native/Libraries/Vibration'\npod 'React-RCTWebSocket', :path => '../../node_modules/react-native/Libraries/WebSocket'\n+ pod 'React-ART', :path => '../../node_modules/react-native/Libraries/ART'\npod 'React-cxxreact', :path => '../../node_modules/react-native/ReactCommon/cxxreact'\npod 'React-jsi', :path => '../../node_modules/react-native/ReactCommon/jsi'\n" }, { "change_type": "MODIFY", "old_path": "native/ios/Podfile.lock", "new_path": "native/ios/Podfile.lock", "diff": "@@ -38,6 +38,8 @@ PODS:\n- React-RCTText (= 0.60.6)\n- React-RCTVibration (= 0.60.6)\n- React-RCTWebSocket (= 0.60.6)\n+ - React-ART (0.60.6):\n+ - React-Core (= 0.60.6)\n- React-Core (0.60.6):\n- Folly (= 2018.10.22.00)\n- React-cxxreact (= 0.60.6)\n@@ -123,8 +125,6 @@ PODS:\n- React-Core (= 0.60.6)\n- React-RCTWebSocket (0.60.6):\n- React-Core (= 0.60.6)\n- - ReactNativeART (1.0.2):\n- - React\n- ReactNativeDarkMode (0.2.0-rc.1):\n- React\n- RNCAsyncStorage (1.6.2):\n@@ -162,6 +162,7 @@ DEPENDENCIES:\n- lottie-ios (from `../../node_modules/lottie-ios`)\n- lottie-react-native (from `../../node_modules/lottie-react-native`)\n- React (from `../../node_modules/react-native/`)\n+ - React-ART (from `../../node_modules/react-native/Libraries/ART`)\n- React-Core (from `../../node_modules/react-native/React`)\n- React-cxxreact (from `../../node_modules/react-native/ReactCommon/cxxreact`)\n- React-DevSupport (from `../../node_modules/react-native/React`)\n@@ -189,7 +190,6 @@ DEPENDENCIES:\n- React-RCTText (from `../../node_modules/react-native/Libraries/Text`)\n- React-RCTVibration (from `../../node_modules/react-native/Libraries/Vibration`)\n- React-RCTWebSocket (from `../../node_modules/react-native/Libraries/WebSocket`)\n- - \"ReactNativeART (from `../../node_modules/@react-native-community/art`)\"\n- ReactNativeDarkMode (from `../../node_modules/react-native-dark-mode`)\n- \"RNCAsyncStorage (from `../../node_modules/@react-native-community/async-storage`)\"\n- RNExitApp (from `../../node_modules/react-native-exit-app`)\n@@ -223,6 +223,8 @@ EXTERNAL SOURCES:\n:path: \"../../node_modules/lottie-react-native\"\nReact:\n:path: \"../../node_modules/react-native/\"\n+ React-ART:\n+ :path: \"../../node_modules/react-native/Libraries/ART\"\nReact-Core:\n:path: \"../../node_modules/react-native/React\"\nReact-cxxreact:\n@@ -277,8 +279,6 @@ EXTERNAL SOURCES:\n:path: \"../../node_modules/react-native/Libraries/Vibration\"\nReact-RCTWebSocket:\n:path: \"../../node_modules/react-native/Libraries/WebSocket\"\n- ReactNativeART:\n- :path: \"../../node_modules/@react-native-community/art\"\nReactNativeDarkMode:\n:path: \"../../node_modules/react-native-dark-mode\"\nRNCAsyncStorage:\n@@ -312,6 +312,7 @@ SPEC CHECKSUMS:\nlottie-ios: 496ac5cea1bbf1a7bd1f1f472f3232eb1b8d744b\nlottie-react-native: b123a79529cc732201091f585c62c89bb4747252\nReact: 68e7f8dfc27729eade18423072a143120f2f32ab\n+ React-ART: b5b51652ddd2096f23c3c045ce4f4309b2aafcf6\nReact-Core: fc9dace551f6c8c1007dd2d3cb1bc10c90a01d3e\nReact-cxxreact: abe59014fce932d41a08bf1aa5dcad9ca8f0a2c5\nReact-DevSupport: b0da2fd9ad4ffb25561bf2a328ab84f78f871bdd\n@@ -339,7 +340,6 @@ SPEC CHECKSUMS:\nReact-RCTText: d91537e29e38dc69cf09cbca0875cf5dc7402da6\nReact-RCTVibration: 7655d72dfb919dd6d8e135ca108a5a2bd9fcd7b4\nReact-RCTWebSocket: 7cd2c8d0f8ddd680dc76404defba7ab1f56b83af\n- ReactNativeART: 103929e284be663b5a2f921ed912821f04120a70\nReactNativeDarkMode: 88317ff05ba95fd063dd347ad32f8c4cefd3166c\nRNCAsyncStorage: 60a80e72d95bf02a01cace55d3697d9724f0d77f\nRNExitApp: c4e052df2568b43bec8a37c7cd61194d4cfee2c3\n@@ -354,6 +354,6 @@ SPEC CHECKSUMS:\nSDWebImageWebPCoder: cc72085bb20368b2f8dbb21b7e355c667e1309b7\nyoga: 5079887aa3e4c62142d6bcee493022643ee4d730\n-PODFILE CHECKSUM: e26aea06ce400ed298a228b8276f9af7174eef68\n+PODFILE CHECKSUM: 7292900a639369e9530fcdd5b003e1b768d4dd0e\nCOCOAPODS: 1.7.5\n" }, { "change_type": "MODIFY", "old_path": "native/package.json", "new_path": "native/package.json", "diff": "\"react-test-renderer\": \"16.8.6\"\n},\n\"dependencies\": {\n- \"@react-native-community/art\": \"^1.0.2\",\n\"@react-native-community/async-storage\": \"^1.6.1\",\n\"@react-native-community/cameraroll\": \"^1.2.1\",\n\"@react-native-community/netinfo\": \"^4.4.0\",\n\"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.6\",\n- \"react-native-progress\": \"^4.0.1\",\n+ \"react-native-progress\": \"git+https://git@github.com/oblador/react-native-progress.git#984c9f2232d5c1a3f9c5481633d34ed6bc6ca476\",\n\"react-native-reanimated\": \"^1.3.0\",\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": "resolved \"https://registry.yarnpkg.com/@protobufjs/utf8/-/utf8-1.1.0.tgz#a777360b5b39a1a2e5106f8e858f2fd2d060c570\"\nintegrity sha1-p3c2C1s5oaLlEG+OhY8v0tBgxXA=\n-\"@react-native-community/art@^1.0.1\", \"@react-native-community/art@^1.0.2\":\n- version \"1.0.2\"\n- resolved \"https://registry.yarnpkg.com/@react-native-community/art/-/art-1.0.2.tgz#38671edcf4eb3d820d62dc5ba3a151d75352f847\"\n- integrity sha512-GFqRy5DfHmD0LF+cIn1TPeNienFNTuLsv3SNq1vsg2J04l51ESSAUq7dY35cCE/g6Hfi9t8zx+A9sEMplRKZ0g==\n- dependencies:\n- art \"^0.10.3\"\n- invariant \"^2.2.4\"\n- prop-types \"^15.7.2\"\n-\n\"@react-native-community/async-storage@^1.6.1\":\nversion \"1.6.2\"\nresolved \"https://registry.yarnpkg.com/@react-native-community/async-storage/-/async-storage-1.6.2.tgz#a19ca7149c4dfe8216f2330e6b1ebfe2d075ef92\"\n@@ -2083,17 +2074,6 @@ anymatch@^3.0.1:\nnormalize-path \"^3.0.0\"\npicomatch \"^2.0.4\"\n-apn@^2.2.0:\n- version \"2.2.0\"\n- resolved \"https://registry.yarnpkg.com/apn/-/apn-2.2.0.tgz#211ae4adf31b115a033342376b7ce23a5d18c393\"\n- integrity sha512-YIypYzPVJA9wzNBLKZ/mq2l1IZX/2FadPvwmSv4ZeR0VH7xdNITQ6Pucgh0Uw6ZZKC+XwheaJ57DFZAhJ0FvPg==\n- dependencies:\n- debug \"^3.1.0\"\n- http2 \"https://github.com/node-apn/node-http2/archive/apn-2.1.4.tar.gz\"\n- jsonwebtoken \"^8.1.0\"\n- node-forge \"^0.7.1\"\n- verror \"^1.10.0\"\n-\n\"apn@git+https://github.com/node-apn/node-apn.git#3.0.0\":\nversion \"3.0.0\"\nresolved \"git+https://github.com/node-apn/node-apn.git#38a357ed0c153aad09c2857e48a710527e685bfc\"\n@@ -2222,7 +2202,7 @@ arrify@^2.0.0:\nresolved \"https://registry.yarnpkg.com/arrify/-/arrify-2.0.1.tgz#c9655e9331e0abcd588d2a7cad7e9956f66701fa\"\nintegrity sha512-3duEwti880xqi4eAMN8AyR4a0ByT90zoYdLlevfrvU43vb0YZwZVfxOgxWrLXXXpyugL0hNZc9G6BiB5B3nUug==\n-art@^0.10.0, art@^0.10.3:\n+art@^0.10.0:\nversion \"0.10.3\"\nresolved \"https://registry.yarnpkg.com/art/-/art-0.10.3.tgz#b01d84a968ccce6208df55a733838c96caeeaea2\"\nintegrity sha512-HXwbdofRTiJT6qZX/FnchtldzJjS3vkLJxQilc3Xj+ma2MXjY4UAyQ0ls1XZYVnDvVIBiFZbC6QsvtW86TD6tQ==\n@@ -10168,12 +10148,10 @@ react-native-orientation-locker@^1.1.6:\nresolved \"https://registry.yarnpkg.com/react-native-orientation-locker/-/react-native-orientation-locker-1.1.6.tgz#7d66a62cdbf4dd1548522efe69a4e04af5daf929\"\nintegrity sha512-yXTC8KmKfhuEAh+gCOcehx0v4IjYapV0lJ6W1muafoISvxMsT+Cizzy+Iz78hQywVZTJNB/Xusl7WMXev7OxDQ==\n-react-native-progress@^4.0.1:\n- version \"4.0.1\"\n- resolved \"https://registry.yarnpkg.com/react-native-progress/-/react-native-progress-4.0.1.tgz#9d61adb997d3d767365e7b68c96a188f2f3ed983\"\n- integrity sha512-libLQjUm8MJyAbW0drxDBUNyDB3C/pmv8rxR2EjdsdBAMsnDTPrL6ljN+vXWi2zfKOcbn+TFU5llnl/vcGPoaA==\n+\"react-native-progress@git+https://git@github.com/oblador/react-native-progress.git#984c9f2232d5c1a3f9c5481633d34ed6bc6ca476\":\n+ version \"3.6.0\"\n+ resolved \"git+https://git@github.com/oblador/react-native-progress.git#984c9f2232d5c1a3f9c5481633d34ed6bc6ca476\"\ndependencies:\n- \"@react-native-community/art\" \"^1.0.1\"\nprop-types \"^15.7.2\"\nreact-native-reanimated@^1.3.0:\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Roll back react-native-progress https://github.com/oblador/react-native-progress/issues/173
129,187
08.11.2019 19:04:23
18,000
d87c038ff7c1c0bd3166ef1c6b5b66492dfcf5f8
[native] Mirror resultant image when using front camera on CameraModal
[ { "change_type": "MODIFY", "old_path": "native/ios/SquadCal.xcodeproj/xcshareddata/xcschemes/SquadCal.xcscheme", "new_path": "native/ios/SquadCal.xcodeproj/xcshareddata/xcschemes/SquadCal.xcscheme", "diff": "</Testables>\n</TestAction>\n<LaunchAction\n- buildConfiguration = \"Debug\"\n+ buildConfiguration = \"Release\"\nselectedDebuggerIdentifier = \"Xcode.DebuggerFoundation.Debugger.LLDB\"\nselectedLauncherIdentifier = \"Xcode.DebuggerFoundation.Launcher.LLDB\"\nlaunchStyle = \"0\"\n" }, { "change_type": "MODIFY", "old_path": "native/media/camera-modal.react.js", "new_path": "native/media/camera-modal.react.js", "diff": "@@ -907,8 +907,19 @@ class CameraModal extends React.PureComponent<Props, State> {\ninvariant(camera, \"camera ref should be set\");\nthis.setState({ stagingMode: true });\n+ const {\n+ hasCamerasOnBothSides,\n+ defaultUseFrontCamera,\n+ } = this.props.deviceCameraInfo;\n+ // We avoid flipping this.state.useFrontCamera if we discover we don't\n+ // actually have a back camera since it causes a bit of lag, but this\n+ // means there are cases where it is false but we are actually using the\n+ // front camera\n+ const usingFrontCamera = this.state.useFrontCamera ||\n+ (!hasCamerasOnBothSides && defaultUseFrontCamera);\nconst photoPromise = camera.takePictureAsync({\npauseAfterCapture: Platform.OS === \"android\",\n+ mirrorImage: usingFrontCamera,\n});\nif (Platform.OS === \"ios\") {\ncamera.pausePreview();\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Mirror resultant image when using front camera on CameraModal
129,187
08.11.2019 19:12:23
18,000
5d89c81035a9cf7b2951c87e7151dd2b9acd8417
[native] Clean up discarded pendingImageInfo
[ { "change_type": "MODIFY", "old_path": "native/chat/chat-input-state-container.react.js", "new_path": "native/chat/chat-input-state-container.react.js", "diff": "@@ -36,7 +36,7 @@ import {\n} from 'lib/actions/message-actions';\nimport { ChatInputStateContext } from './chat-input-state';\n-import { validateMedia, convertMedia } from '../utils/media-utils';\n+import { validateMedia, convertMedia, pathFromURI } from '../utils/media-utils';\nlet nextLocalUploadID = 0;\ntype ImageInfo = {|\n@@ -552,11 +552,7 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\nreturn;\n}\nthis.pendingUnlinkURIs.delete(uri);\n- const matches = uri.match(/^file:\\/\\/(.*)$/);\n- if (!matches) {\n- return;\n- }\n- const path = matches[1];\n+ const path = pathFromURI(uri);\nif (!path) {\nreturn;\n}\n" }, { "change_type": "MODIFY", "old_path": "native/media/camera-modal.react.js", "new_path": "native/media/camera-modal.react.js", "diff": "@@ -43,6 +43,7 @@ import {\nimport Icon from 'react-native-vector-icons/Ionicons';\nimport Orientation from 'react-native-orientation-locker';\nimport invariant from 'invariant';\n+import filesystem from 'react-native-fs';\nimport { connect } from 'lib/utils/redux-utils';\n@@ -57,6 +58,7 @@ import ContentLoading from '../components/content-loading.react';\nimport { colors } from '../themes/colors';\nimport { saveImage } from './save-image';\nimport SendMediaButton from './send-media-button.react';\n+import { pathFromURI } from '../utils/media-utils';\nconst {\nValue,\n@@ -627,10 +629,24 @@ class CameraModal extends React.PureComponent<Props, State> {\n{ ...stagingModeAnimationConfig, toValue: 1 },\n).start();\n} else if (!this.state.pendingImageInfo && prevState.pendingImageInfo) {\n+ CameraModal.cleanUpPendingImageInfo(prevState.pendingImageInfo);\nthis.sendButtonProgress.setValue(0);\n}\n}\n+ static async cleanUpPendingImageInfo(pendingImageInfo: ClientImageInfo) {\n+ if (!pendingImageInfo.unlinkURIAfterRemoving) {\n+ return;\n+ }\n+ const path = pathFromURI(pendingImageInfo.uri);\n+ if (!path) {\n+ return;\n+ }\n+ try {\n+ await filesystem.unlink(path);\n+ } catch (e) { }\n+ }\n+\nget containerStyle() {\nreturn {\n...styles.container,\n" }, { "change_type": "MODIFY", "old_path": "native/utils/media-utils.js", "new_path": "native/utils/media-utils.js", "diff": "@@ -156,9 +156,22 @@ async function convertMedia(\n};\n}\n+function pathFromURI(uri: string): ?string {\n+ const matches = uri.match(/^file:\\/\\/(.*)$/);\n+ if (!matches) {\n+ return null;\n+ }\n+ const path = matches[1];\n+ if (!path) {\n+ return null;\n+ }\n+ return path;\n+}\n+\nexport {\nvalidateMedia,\nblobToDataURI,\ndataURIToIntArray,\nconvertMedia,\n+ pathFromURI,\n};\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Clean up discarded pendingImageInfo
129,187
08.11.2019 19:15:49
18,000
4f82ce0716262f6850e768f6328eb3bd7b605ab1
[native] fixOrientation in CameraModal for Android
[ { "change_type": "MODIFY", "old_path": "native/media/camera-modal.react.js", "new_path": "native/media/camera-modal.react.js", "diff": "@@ -923,24 +923,26 @@ class CameraModal extends React.PureComponent<Props, State> {\ninvariant(camera, \"camera ref should be set\");\nthis.setState({ stagingMode: true });\n- const {\n- hasCamerasOnBothSides,\n- defaultUseFrontCamera,\n- } = this.props.deviceCameraInfo;\n// We avoid flipping this.state.useFrontCamera if we discover we don't\n// actually have a back camera since it causes a bit of lag, but this\n// means there are cases where it is false but we are actually using the\n// front camera\n+ const {\n+ hasCamerasOnBothSides,\n+ defaultUseFrontCamera,\n+ } = this.props.deviceCameraInfo;\nconst usingFrontCamera = this.state.useFrontCamera ||\n(!hasCamerasOnBothSides && defaultUseFrontCamera);\n+\nconst photoPromise = camera.takePictureAsync({\npauseAfterCapture: Platform.OS === \"android\",\nmirrorImage: usingFrontCamera,\n+ fixOrientation: true,\n});\n+\nif (Platform.OS === \"ios\") {\ncamera.pausePreview();\n}\n-\nconst { uri, width, height } = await photoPromise;\nconst pendingImageInfo = {\nuri,\n@@ -948,6 +950,7 @@ class CameraModal extends React.PureComponent<Props, State> {\nheight,\nunlinkURIAfterRemoving: true,\n};\n+\nthis.setState({\npendingImageInfo,\nzoom: 0,\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] fixOrientation in CameraModal for Android
129,187
08.11.2019 19:25:03
18,000
a3c34c5d0ce5129fae4b144c94958c6c19166c90
[native] Make camera icon slightly larger
[ { "change_type": "MODIFY", "old_path": "native/chat/chat-input-bar.react.js", "new_path": "native/chat/chat-input-bar.react.js", "diff": "@@ -147,7 +147,7 @@ class ChatInputBar extends React.PureComponent<Props, State> {\nthis.expandoButtonsOpacity,\n{\ninputRange: [ 0, 1 ],\n- outputRange: [ 22, 58 ],\n+ outputRange: [ 22, 60 ],\n},\n);\n}\n@@ -338,7 +338,7 @@ class ChatInputBar extends React.PureComponent<Props, State> {\n<Animated.View style={this.cameraIconStyle}>\n<FAIcon\nname=\"camera\"\n- size={19}\n+ size={20}\ncolor={this.props.colors.listInputButton}\n/>\n</Animated.View>\n@@ -619,12 +619,12 @@ const styles = {\npaddingBottom: Platform.OS === \"ios\" ? 10 : 12,\n},\ncameraRollIcon: {\n- paddingRight: 7,\n+ paddingRight: 8,\npaddingBottom: Platform.OS === \"ios\" ? 5 : 8,\n},\ncameraIcon: {\npaddingRight: 3,\n- paddingBottom: Platform.OS === \"ios\" ? 10 : 11,\n+ paddingBottom: 10,\n},\nexplanation: {\ncolor: 'listBackgroundSecondaryLabel',\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Make camera icon slightly larger
129,187
08.11.2019 19:25:16
18,000
b71c9aa83405684719d8f1ae4c227828bfd2fb85
[native] codeVersion -> 40
[ { "change_type": "MODIFY", "old_path": "native/android/app/build.gradle", "new_path": "native/android/app/build.gradle", "diff": "@@ -131,8 +131,8 @@ android {\napplicationId \"org.squadcal\"\nminSdkVersion rootProject.ext.minSdkVersion\ntargetSdkVersion rootProject.ext.targetSdkVersion\n- versionCode 39\n- versionName \"0.0.39\"\n+ versionCode 40\n+ versionName \"0.0.40\"\nmissingDimensionStrategy 'react-native-camera', 'general'\nmultiDexEnabled true\n}\n" }, { "change_type": "MODIFY", "old_path": "native/ios/SquadCal/Info.debug.plist", "new_path": "native/ios/SquadCal/Info.debug.plist", "diff": "<key>CFBundlePackageType</key>\n<string>APPL</string>\n<key>CFBundleShortVersionString</key>\n- <string>0.0.39</string>\n+ <string>0.0.40</string>\n<key>CFBundleSignature</key>\n<string>????</string>\n<key>CFBundleVersion</key>\n- <string>39</string>\n+ <string>40</string>\n<key>LSApplicationQueriesSchemes</key>\n<array>\n<string>org-appextension-feature-password-management</string>\n" }, { "change_type": "MODIFY", "old_path": "native/ios/SquadCal/Info.release.plist", "new_path": "native/ios/SquadCal/Info.release.plist", "diff": "<key>CFBundlePackageType</key>\n<string>APPL</string>\n<key>CFBundleShortVersionString</key>\n- <string>0.0.39</string>\n+ <string>0.0.40</string>\n<key>CFBundleSignature</key>\n<string>????</string>\n<key>CFBundleVersion</key>\n- <string>39</string>\n+ <string>40</string>\n<key>LSApplicationQueriesSchemes</key>\n<array>\n<string>org-appextension-feature-password-management</string>\n" }, { "change_type": "MODIFY", "old_path": "native/redux/persist.js", "new_path": "native/redux/persist.js", "diff": "@@ -156,7 +156,7 @@ const persistConfig = {\ntimeout: __DEV__ ? 0 : undefined,\n};\n-const codeVersion = 39;\n+const codeVersion = 40;\n// This local exists to avoid a circular dependency where redux-setup needs to\n// import all the navigation and screen stuff, but some of those screens want to\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] codeVersion -> 40
129,187
09.11.2019 01:36:30
18,000
10b5c1e346313224167389d148e192c7e36b6506
[server] Android privacy policy
[ { "change_type": "MODIFY", "old_path": "server/src/server.js", "new_path": "server/src/server.js", "diff": "@@ -41,6 +41,7 @@ if (cluster.isMaster) {\nconst router = express.Router();\nrouter.use('/images', express.static('images'));\nrouter.use('/fonts', express.static('fonts'));\n+ router.use('/misc', express.static('misc'));\nrouter.use(\n'/.well-known',\nexpress.static(\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[server] Android privacy policy
129,187
11.11.2019 14:04:13
18,000
ebfeb78a9efd25e79994f1d3751f3bb192862e5e
[native] ImageGallery -> MediaGallery
[ { "change_type": "MODIFY", "old_path": "native/chat/chat-input-bar.react.js", "new_path": "native/chat/chat-input-bar.react.js", "diff": "@@ -21,7 +21,7 @@ import type { LoadingStatus } from 'lib/types/loading-types';\nimport { loadingStatusPropType } from 'lib/types/loading-types';\nimport type { CalendarQuery } from 'lib/types/entry-types';\nimport type { KeyboardEvent } from '../keyboard';\n-import type { GalleryImageInfo } from '../media/image-gallery-image.react';\n+import type { GalleryMediaInfo } from '../media/media-gallery-image.react';\nimport {\ntype KeyboardState,\nkeyboardStatePropType,\n@@ -72,8 +72,8 @@ import Button from '../components/button.react';\nimport { nonThreadCalendarQuery } from '../selectors/nav-selectors';\nimport { getKeyboardHeight } from '../keyboard';\nimport {\n- imageGalleryKeyboardName,\n-} from '../media/image-gallery-keyboard.react';\n+ mediaGalleryKeyboardName,\n+} from '../media/media-gallery-keyboard.react';\nimport { ChatInputStateContext } from './chat-input-state';\nimport { colorsSelector, styleSelector } from '../themes/colors';\nimport { CameraModalRouteName } from '../navigation/route-names';\n@@ -152,9 +152,9 @@ class ChatInputBar extends React.PureComponent<Props, State> {\n);\n}\n- static imageGalleryOpen(props: Props) {\n+ static mediaGalleryOpen(props: Props) {\nconst { keyboardState } = props;\n- return !!(keyboardState && keyboardState.imageGalleryOpen);\n+ return !!(keyboardState && keyboardState.mediaGalleryOpen);\n}\nstatic systemKeyboardShowing(props: Props) {\n@@ -186,8 +186,8 @@ class ChatInputBar extends React.PureComponent<Props, State> {\nthis.expandButtons();\n}\n- const imageGalleryIsOpen = ChatInputBar.imageGalleryOpen(this.props);\n- const imageGalleryWasOpen = ChatInputBar.imageGalleryOpen(prevProps);\n+ const imageGalleryIsOpen = ChatInputBar.mediaGalleryOpen(this.props);\n+ const imageGalleryWasOpen = ChatInputBar.mediaGalleryOpen(prevProps);\nif (!imageGalleryIsOpen && imageGalleryWasOpen) {\nthis.hideButtons();\n} else if (imageGalleryIsOpen && !imageGalleryWasOpen) {\n@@ -318,7 +318,7 @@ class ChatInputBar extends React.PureComponent<Props, State> {\n<View style={this.props.styles.innerExpandoButtons}>\n{this.state.buttonsExpanded ? expandoButton : null}\n<TouchableOpacity\n- onPress={this.openImageGallery}\n+ onPress={this.openMediaGallery}\nactiveOpacity={0.4}\n>\n<Animated.View style={this.cameraRollIconStyle}>\n@@ -395,16 +395,16 @@ class ChatInputBar extends React.PureComponent<Props, State> {\n}\nlet keyboardAccessoryView = null;\n- const imageGalleryIsOpen = ChatInputBar.imageGalleryOpen(this.props);\n+ const imageGalleryIsOpen = ChatInputBar.mediaGalleryOpen(this.props);\nif (Platform.OS !== \"android\" || imageGalleryIsOpen) {\n- const kbComponent = imageGalleryIsOpen ? imageGalleryKeyboardName : null;\n+ const kbComponent = imageGalleryIsOpen ? mediaGalleryKeyboardName : null;\nkeyboardAccessoryView = (\n<KeyboardAccessoryView\nkbInputRef={this.textInput}\nkbComponent={kbComponent}\nkbInitialProps={this.props.styles.kbInitialProps}\n- onItemSelected={this.onImageGalleryItemSelected}\n- onKeyboardResigned={this.hideImageGallery}\n+ onItemSelected={this.onMediaGalleryItemSelected}\n+ onKeyboardResigned={this.hideMediaGallery}\nmanageScrollView={false}\n/>\n);\n@@ -523,7 +523,7 @@ class ChatInputBar extends React.PureComponent<Props, State> {\nhideButtons() {\nif (\n- ChatInputBar.imageGalleryOpen(this.props) ||\n+ ChatInputBar.mediaGalleryOpen(this.props) ||\n!this.systemKeyboardShowing ||\n!this.state.buttonsExpanded\n) {\n@@ -543,17 +543,17 @@ class ChatInputBar extends React.PureComponent<Props, State> {\n});\n}\n- openImageGallery = () => {\n- this.setImageGalleryOpen(true);\n+ openMediaGallery = () => {\n+ this.setMediaGalleryOpen(true);\n}\n- hideImageGallery = () => {\n- this.setImageGalleryOpen(false);\n+ hideMediaGallery = () => {\n+ this.setMediaGalleryOpen(false);\n}\n- onImageGalleryItemSelected = (\n+ onMediaGalleryItemSelected = (\nkeyboardName: string,\n- imageInfos: $ReadOnlyArray<GalleryImageInfo>,\n+ imageInfos: $ReadOnlyArray<GalleryMediaInfo>,\n) => {\nthis.dismissKeyboard();\nconst chatInputState = this.context;\n@@ -561,10 +561,10 @@ class ChatInputBar extends React.PureComponent<Props, State> {\nchatInputState.sendMultimediaMessage(this.props.threadInfo.id, imageInfos);\n}\n- setImageGalleryOpen(imageGalleryOpen: bool) {\n+ setMediaGalleryOpen(mediaGalleryOpen: bool) {\nconst { keyboardState } = this.props;\ninvariant(keyboardState, \"keyboardState should be initialized\");\n- keyboardState.setImageGalleryOpen(imageGalleryOpen);\n+ keyboardState.setMediaGalleryOpen(mediaGalleryOpen);\n}\ndismissKeyboard = () => {\n" }, { "change_type": "MODIFY", "old_path": "native/chat/chat-input-state.js", "new_path": "native/chat/chat-input-state.js", "diff": "// @flow\nimport type { Dimensions } from 'lib/types/media-types';\n-import type { GalleryImageInfo } from '../media/image-gallery-image.react';\n+import type { GalleryMediaInfo } from '../media/media-gallery-image.react';\nimport * as React from 'react';\nimport PropTypes from 'prop-types';\n@@ -12,7 +12,7 @@ export type PendingMultimediaUpload = {|\n|};\nexport type ClientImageInfo = {|\n- ...GalleryImageInfo,\n+ ...GalleryMediaInfo,\nunlinkURIAfterRemoving?: bool,\n|};\n" }, { "change_type": "RENAME", "old_path": "native/media/image-gallery-image.react.js", "new_path": "native/media/media-gallery-image.react.js", "diff": "@@ -27,7 +27,7 @@ import\nfrom 'react-native-reanimated';\nimport invariant from 'invariant';\n-export type GalleryImageInfo = {|\n+export type GalleryMediaInfo = {|\n...Dimensions,\nuri: string,\n|};\n@@ -43,14 +43,14 @@ const reanimatedSpec = {\nconst isAndroid44 = Platform.OS === \"android\" && Platform.Version < 21;\ntype Props = {|\n- imageInfo: GalleryImageInfo,\n+ imageInfo: GalleryMediaInfo,\ncontainerHeight: number,\nqueueModeActive: bool,\nisQueued: bool,\n- setImageQueued: (image: GalleryImageInfo, isQueued: bool) => void,\n- sendImage: (image: GalleryImageInfo) => void,\n+ setImageQueued: (image: GalleryMediaInfo, isQueued: bool) => void,\n+ sendImage: (image: GalleryMediaInfo) => void,\nisFocused: bool,\n- setFocus: (image: GalleryImageInfo, isFocused: bool) => void,\n+ setFocus: (image: GalleryMediaInfo, isFocused: bool) => void,\nscreenWidth: number,\n|};\nclass ImageGalleryImage extends React.PureComponent<Props> {\n" }, { "change_type": "RENAME", "old_path": "native/media/image-gallery-keyboard.react.js", "new_path": "native/media/media-gallery-keyboard.react.js", "diff": "// @flow\n-import type { GalleryImageInfo } from './image-gallery-image.react';\n+import type { GalleryMediaInfo } from './media-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@@ -30,7 +30,7 @@ import {\ndimensionsSelector,\ncontentBottomOffset,\n} from '../selectors/dimension-selectors';\n-import ImageGalleryImage from './image-gallery-image.react';\n+import MediaGalleryImage from './media-gallery-image.react';\nimport Animated, { Easing } from 'react-native-reanimated';\nimport { colorsSelector, styleSelector } from '../themes/colors';\nimport { getAndroidPermission } from '../utils/android-permissions';\n@@ -49,16 +49,16 @@ type Props = {|\nstyles: Styles,\n|};\ntype State = {|\n- imageInfos: ?$ReadOnlyArray<GalleryImageInfo>,\n+ mediaInfos: ?$ReadOnlyArray<GalleryMediaInfo>,\nerror: ?string,\ncontainerHeight: ?number,\n// null means end reached; undefined means no fetch yet\ncursor: ?string,\n- queuedImageURIs: ?Set<string>,\n- focusedImageURI: ?string,\n+ queuedMediaURIs: ?Set<string>,\n+ focusedMediaURI: ?string,\nscreenWidth: number,\n|};\n-class ImageGalleryKeyboard extends React.PureComponent<Props, State> {\n+class MediaGalleryKeyboard extends React.PureComponent<Props, State> {\nstatic propTypes = {\nscreenDimensions: dimensionsPropType.isRequired,\n@@ -72,7 +72,7 @@ class ImageGalleryKeyboard extends React.PureComponent<Props, State> {\nviewableIndices: number[] = [];\nqueueModeProgress = new Animated.Value(0);\nsendButtonStyle: ViewStyle;\n- imagesSelected = false;\n+ mediaSelected = false;\nconstructor(props: Props) {\nsuper(props);\n@@ -90,12 +90,12 @@ class ImageGalleryKeyboard extends React.PureComponent<Props, State> {\n],\n};\nthis.state = {\n- imageInfos: null,\n+ mediaInfos: null,\nerror: null,\ncontainerHeight: null,\ncursor: undefined,\n- queuedImageURIs: null,\n- focusedImageURI: null,\n+ queuedMediaURIs: null,\n+ focusedMediaURI: null,\nscreenWidth: props.screenDimensions.width,\n};\n}\n@@ -117,14 +117,14 @@ class ImageGalleryKeyboard extends React.PureComponent<Props, State> {\nthis.setState({ screenWidth: width });\n}\n- const { queuedImageURIs } = this.state;\n- const prevQueuedImageURIs = prevState.queuedImageURIs;\n- if (queuedImageURIs && !prevQueuedImageURIs) {\n+ const { queuedMediaURIs } = this.state;\n+ const prevQueuedMediaURIs = prevState.queuedMediaURIs;\n+ if (queuedMediaURIs && !prevQueuedMediaURIs) {\nAnimated.timing(\nthis.queueModeProgress,\n{ ...animationSpec, toValue: 1 },\n).start();\n- } else if (!queuedImageURIs && prevQueuedImageURIs) {\n+ } else if (!queuedMediaURIs && prevQueuedMediaURIs) {\nAnimated.timing(\nthis.queueModeProgress,\n{ ...animationSpec, toValue: 0 },\n@@ -132,28 +132,28 @@ class ImageGalleryKeyboard extends React.PureComponent<Props, State> {\n}\nconst { flatList, viewableIndices } = this;\n- const { imageInfos, focusedImageURI } = this.state;\n+ const { mediaInfos, focusedMediaURI } = this.state;\nlet scrollingSomewhere = false;\n- if (flatList && imageInfos) {\n+ if (flatList && mediaInfos) {\nlet newURI;\n- if (focusedImageURI && focusedImageURI !== prevState.focusedImageURI) {\n- newURI = focusedImageURI;\n+ if (focusedMediaURI && focusedMediaURI !== prevState.focusedMediaURI) {\n+ newURI = focusedMediaURI;\n} else if (\n- queuedImageURIs &&\n- (!prevQueuedImageURIs ||\n- queuedImageURIs.size > prevQueuedImageURIs.size)\n+ queuedMediaURIs &&\n+ (!prevQueuedMediaURIs ||\n+ queuedMediaURIs.size > prevQueuedMediaURIs.size)\n) {\n- for (let queuedImageURI of queuedImageURIs) {\n- if (prevQueuedImageURIs && prevQueuedImageURIs.has(queuedImageURI)) {\n+ for (let queuedMediaURI of queuedMediaURIs) {\n+ if (prevQueuedMediaURIs && prevQueuedMediaURIs.has(queuedMediaURI)) {\ncontinue;\n}\n- newURI = queuedImageURI;\n+ newURI = queuedMediaURI;\nbreak;\n}\n}\nlet index;\nif (newURI !== null && newURI !== undefined) {\n- index = imageInfos.findIndex(({ uri }) => uri === newURI);\n+ index = mediaInfos.findIndex(({ uri }) => uri === newURI);\n}\nif (index !== null && index !== undefined) {\nif (index === viewableIndices[0]) {\n@@ -173,11 +173,11 @@ class ImageGalleryKeyboard extends React.PureComponent<Props, State> {\nif (\n!scrollingSomewhere &&\nthis.flatList &&\n- this.state.imageInfos &&\n- prevState.imageInfos &&\n- this.state.imageInfos.length > 0 &&\n- prevState.imageInfos.length > 0 &&\n- this.state.imageInfos[0].uri !== prevState.imageInfos[0].uri\n+ this.state.mediaInfos &&\n+ prevState.mediaInfos &&\n+ this.state.mediaInfos.length > 0 &&\n+ prevState.mediaInfos.length > 0 &&\n+ this.state.mediaInfos[0].uri !== prevState.mediaInfos[0].uri\n) {\nthis.flatList.scrollToIndex({ index: 0 });\n}\n@@ -216,17 +216,17 @@ class ImageGalleryKeyboard extends React.PureComponent<Props, State> {\n}\n}\nconst { edges, page_info } = await CameraRoll.getPhotos(\n- ImageGalleryKeyboard.getPhotosQuery(after),\n+ MediaGalleryKeyboard.getPhotosQuery(after),\n);\nlet firstRemoved = false, lastRemoved = false;\n- const imageURIs = this.state.imageInfos\n- ? this.state.imageInfos.map(({ uri }) => uri)\n+ const mediaURIs = this.state.mediaInfos\n+ ? this.state.mediaInfos.map(({ uri }) => uri)\n: [];\n- const existingURIs = new Set(imageURIs);\n+ const existingURIs = new Set(mediaURIs);\nlet first = true;\n- const imageInfos = edges.map(\n+ const mediaInfos = edges.map(\n({ node }) => {\nconst { uri, height, width } = node.image;\nif (existingURIs.has(uri)) {\n@@ -251,17 +251,17 @@ class ImageGalleryKeyboard extends React.PureComponent<Props, State> {\nappendOrPrepend = \"prepend\";\n}\n- let newImageInfos = imageInfos;\n- if (this.state.imageInfos) {\n+ let newMediaInfos = mediaInfos;\n+ if (this.state.mediaInfos) {\nif (appendOrPrepend === \"prepend\") {\n- newImageInfos = [ ...newImageInfos, ...this.state.imageInfos ];\n+ newMediaInfos = [ ...newMediaInfos, ...this.state.mediaInfos ];\n} else {\n- newImageInfos = [ ...this.state.imageInfos, ...newImageInfos ];\n+ newMediaInfos = [ ...this.state.mediaInfos, ...newMediaInfos ];\n}\n}\nthis.guardedSetState({\n- imageInfos: newImageInfos,\n+ mediaInfos: newMediaInfos,\nerror: null,\ncursor: page_info.has_next_page\n? page_info.end_cursor\n@@ -269,7 +269,7 @@ class ImageGalleryKeyboard extends React.PureComponent<Props, State> {\n});\n} catch (e) {\nthis.guardedSetState({\n- imageInfos: null,\n+ mediaInfos: null,\nerror: \"something went wrong :(\",\n});\n}\n@@ -293,25 +293,25 @@ class ImageGalleryKeyboard extends React.PureComponent<Props, State> {\nget queueModeActive() {\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+ return !!this.state.queuedMediaURIs ||\n(Platform.OS === \"android\" && Platform.Version < 21);\n}\n- renderItem = (row: { item: GalleryImageInfo }) => {\n- const { containerHeight, queuedImageURIs } = this.state;\n+ renderItem = (row: { item: GalleryMediaInfo }) => {\n+ const { containerHeight, queuedMediaURIs } = this.state;\ninvariant(containerHeight, \"should be set\");\nconst { uri } = row.item;\n- const isQueued = !!(queuedImageURIs && queuedImageURIs.has(uri));\n+ const isQueued = !!(queuedMediaURIs && queuedMediaURIs.has(uri));\nconst { queueModeActive } = this;\nreturn (\n- <ImageGalleryImage\n+ <MediaGalleryImage\nimageInfo={row.item}\ncontainerHeight={containerHeight}\nqueueModeActive={queueModeActive}\nisQueued={isQueued}\n- setImageQueued={this.setImageQueued}\n- sendImage={this.sendImage}\n- isFocused={this.state.focusedImageURI === uri}\n+ setImageQueued={this.setMediaQueued}\n+ sendImage={this.sendSingleMedia}\n+ isFocused={this.state.focusedMediaURI === uri}\nsetFocus={this.setFocus}\nscreenWidth={this.state.screenWidth}\n/>\n@@ -322,21 +322,21 @@ class ImageGalleryKeyboard extends React.PureComponent<Props, State> {\nreturn <View style={this.props.styles.separator} />;\n}\n- static keyExtractor(item: GalleryImageInfo) {\n+ static keyExtractor(item: GalleryMediaInfo) {\nreturn item.uri;\n}\nrender() {\nlet content;\n- const { imageInfos, error, containerHeight } = this.state;\n- if (imageInfos && imageInfos.length > 0 && containerHeight) {\n+ const { mediaInfos, error, containerHeight } = this.state;\n+ if (mediaInfos && mediaInfos.length > 0 && containerHeight) {\ncontent = (\n<FlatList\nhorizontal={true}\n- data={imageInfos}\n+ data={mediaInfos}\nrenderItem={this.renderItem}\nItemSeparatorComponent={this.ItemSeparator}\n- keyExtractor={ImageGalleryKeyboard.keyExtractor}\n+ keyExtractor={MediaGalleryKeyboard.keyExtractor}\nscrollsToTop={false}\nshowsHorizontalScrollIndicator={false}\nonEndReached={this.onEndReached}\n@@ -346,7 +346,7 @@ class ImageGalleryKeyboard extends React.PureComponent<Props, State> {\nref={this.flatListRef}\n/>\n);\n- } else if (imageInfos && containerHeight) {\n+ } else if (mediaInfos && containerHeight) {\ncontent = (\n<Text style={this.props.styles.error}>\nno media was found!\n@@ -364,8 +364,8 @@ class ImageGalleryKeyboard extends React.PureComponent<Props, State> {\n);\n}\n- const { queuedImageURIs } = this.state;\n- const queueCount = queuedImageURIs ? queuedImageURIs.size : 0;\n+ const { queuedMediaURIs } = this.state;\n+ const queueCount = queuedMediaURIs ? queuedMediaURIs.size : 0;\nreturn (\n<View\nstyle={this.props.styles.container}\n@@ -373,7 +373,7 @@ class ImageGalleryKeyboard extends React.PureComponent<Props, State> {\n>\n{content}\n<SendMediaButton\n- onPress={this.sendQueuedImages}\n+ onPress={this.sendQueuedMedia}\nqueueCount={queueCount}\ncontainerStyle={this.props.styles.sendButtonContainer}\nstyle={this.sendButtonStyle}\n@@ -412,72 +412,72 @@ class ImageGalleryKeyboard extends React.PureComponent<Props, State> {\nthis.viewableIndices = viewableIndices;\n}\n- setImageQueued = (imageInfo: GalleryImageInfo, isQueued: bool) => {\n+ setMediaQueued = (mediaInfo: GalleryMediaInfo, isQueued: bool) => {\nthis.setState((prevState: State) => {\n- const prevQueuedImageURIs = prevState.queuedImageURIs\n- ? [ ...prevState.queuedImageURIs ]\n+ const prevQueuedMediaURIs = prevState.queuedMediaURIs\n+ ? [ ...prevState.queuedMediaURIs ]\n: [];\nif (isQueued) {\nreturn {\n- queuedImageURIs: new Set([\n- ...prevQueuedImageURIs,\n- imageInfo.uri,\n+ queuedMediaURIs: new Set([\n+ ...prevQueuedMediaURIs,\n+ mediaInfo.uri,\n]),\n- focusedImageURI: null,\n+ focusedMediaURI: null,\n};\n}\n- const queuedImageURIs = prevQueuedImageURIs.filter(\n- uri => uri !== imageInfo.uri,\n+ const queuedMediaURIs = prevQueuedMediaURIs.filter(\n+ uri => uri !== mediaInfo.uri,\n);\n- if (queuedImageURIs.length < prevQueuedImageURIs.length) {\n+ if (queuedMediaURIs.length < prevQueuedMediaURIs.length) {\nreturn {\n- queuedImageURIs: new Set(queuedImageURIs),\n- focusedImageURI: null,\n+ queuedMediaURIs: new Set(queuedMediaURIs),\n+ focusedMediaURI: null,\n};\n}\nreturn null;\n});\n}\n- setFocus = (imageInfo: GalleryImageInfo, isFocused: bool) => {\n- const { uri } = imageInfo;\n+ setFocus = (mediaInfo: GalleryMediaInfo, isFocused: bool) => {\n+ const { uri } = mediaInfo;\nif (isFocused) {\n- this.setState({ focusedImageURI: uri });\n- } else if (this.state.focusedImageURI === uri) {\n- this.setState({ focusedImageURI: null });\n+ this.setState({ focusedMediaURI: uri });\n+ } else if (this.state.focusedMediaURI === uri) {\n+ this.setState({ focusedMediaURI: null });\n}\n}\n- sendImage = (imageInfo: GalleryImageInfo) => {\n- this.sendImages([ imageInfo ]);\n+ sendSingleMedia = (mediaInfo: GalleryMediaInfo) => {\n+ this.sendMedia([ mediaInfo ]);\n}\n- sendQueuedImages = () => {\n- const { imageInfos, queuedImageURIs } = this.state;\n- invariant(imageInfos && queuedImageURIs, \"should be set\");\n- const queuedImageInfos = [];\n- for (let uri of queuedImageURIs) {\n- for (let imageInfo of imageInfos) {\n- if (imageInfo.uri === uri) {\n- queuedImageInfos.push(imageInfo);\n+ sendQueuedMedia = () => {\n+ const { mediaInfos, queuedMediaURIs } = this.state;\n+ invariant(mediaInfos && queuedMediaURIs, \"should be set\");\n+ const queuedMediaInfos = [];\n+ for (let uri of queuedMediaURIs) {\n+ for (let mediaInfo of mediaInfos) {\n+ if (mediaInfo.uri === uri) {\n+ queuedMediaInfos.push(mediaInfo);\nbreak;\n}\n}\n}\n- this.sendImages(queuedImageInfos);\n+ this.sendMedia(queuedMediaInfos);\n}\n- sendImages(imageInfos: $ReadOnlyArray<GalleryImageInfo>) {\n- if (this.imagesSelected) {\n+ sendMedia(mediaInfos: $ReadOnlyArray<GalleryMediaInfo>) {\n+ if (this.mediaSelected) {\nreturn;\n}\n- this.imagesSelected = true;\n- KeyboardRegistry.onItemSelected(imageGalleryKeyboardName, imageInfos);\n+ this.mediaSelected = true;\n+ KeyboardRegistry.onItemSelected(mediaGalleryKeyboardName, mediaInfos);\n}\n}\n-const imageGalleryKeyboardName = 'ImageGalleryKeyboard';\n+const mediaGalleryKeyboardName = 'MediaGalleryKeyboard';\nconst styles = {\ncontainer: {\n@@ -512,28 +512,28 @@ const styles = {\n};\nconst stylesSelector = styleSelector(styles);\n-const ReduxConnectedImageGalleryKeyboard = connect(\n+const ReduxConnectedMediaGalleryKeyboard = connect(\n(state: AppState) => ({\nscreenDimensions: dimensionsSelector(state),\nforeground: state.foreground,\ncolors: colorsSelector(state),\nstyles: stylesSelector(state),\n}),\n-)(ImageGalleryKeyboard);\n+)(MediaGalleryKeyboard);\n-function ReduxImageGalleryKeyboard(props: {||}) {\n+function ReduxMediaGalleryKeyboard(props: {||}) {\nreturn (\n<Provider store={store}>\n- <ReduxConnectedImageGalleryKeyboard />\n+ <ReduxConnectedMediaGalleryKeyboard />\n</Provider>\n);\n}\nKeyboardRegistry.registerKeyboard(\n- imageGalleryKeyboardName,\n- () => ReduxImageGalleryKeyboard,\n+ mediaGalleryKeyboardName,\n+ () => ReduxMediaGalleryKeyboard,\n);\nexport {\n- imageGalleryKeyboardName,\n+ mediaGalleryKeyboardName,\n};\n" }, { "change_type": "MODIFY", "old_path": "native/navigation/keyboard-state-container.react.js", "new_path": "native/navigation/keyboard-state-container.react.js", "diff": "@@ -16,7 +16,7 @@ type Props = {|\n|};\ntype State = {|\nsystemKeyboardShowing: bool,\n- imageGalleryOpen: bool,\n+ mediaGalleryOpen: bool,\n|};\nclass KeyboardStateContainer extends React.PureComponent<Props, State> {\n@@ -25,7 +25,7 @@ class KeyboardStateContainer extends React.PureComponent<Props, State> {\n};\nstate = {\nsystemKeyboardShowing: false,\n- imageGalleryOpen: false,\n+ mediaGalleryOpen: false,\n};\nkeyboardShowListener: ?Object;\nkeyboardDismissListener: ?Object;\n@@ -69,29 +69,29 @@ class KeyboardStateContainer extends React.PureComponent<Props, State> {\n}\nget keyboardShowing() {\n- const { systemKeyboardShowing, imageGalleryOpen } = this.state;\n- return systemKeyboardShowing || imageGalleryOpen;\n+ const { systemKeyboardShowing, mediaGalleryOpen } = this.state;\n+ return systemKeyboardShowing || mediaGalleryOpen;\n}\n- setImageGalleryOpen = (imageGalleryOpen: bool) => {\n- this.setState({ imageGalleryOpen });\n+ setMediaGalleryOpen = (mediaGalleryOpen: bool) => {\n+ this.setState({ mediaGalleryOpen });\n}\nrender() {\n- const { systemKeyboardShowing, imageGalleryOpen } = this.state;\n+ const { systemKeyboardShowing, mediaGalleryOpen } = this.state;\nconst {\nkeyboardShowing,\ndismissKeyboard,\ndismissKeyboardIfShowing,\n- setImageGalleryOpen,\n+ setMediaGalleryOpen,\n} = this;\nconst keyboardState = {\nkeyboardShowing,\ndismissKeyboard,\ndismissKeyboardIfShowing,\nsystemKeyboardShowing,\n- imageGalleryOpen,\n- setImageGalleryOpen,\n+ mediaGalleryOpen,\n+ setMediaGalleryOpen,\n};\nreturn (\n<KeyboardContext.Provider value={keyboardState}>\n" }, { "change_type": "MODIFY", "old_path": "native/navigation/keyboard-state.js", "new_path": "native/navigation/keyboard-state.js", "diff": "@@ -8,8 +8,8 @@ export type KeyboardState = {|\ndismissKeyboard: () => void,\ndismissKeyboardIfShowing: () => bool,\nsystemKeyboardShowing: bool,\n- imageGalleryOpen: bool,\n- setImageGalleryOpen: (imageGalleryOpen: bool) => void,\n+ mediaGalleryOpen: bool,\n+ setMediaGalleryOpen: (mediaGalleryOpen: bool) => void,\n|};\nconst keyboardStatePropType = PropTypes.shape({\n@@ -17,8 +17,8 @@ const keyboardStatePropType = PropTypes.shape({\ndismissKeyboard: PropTypes.func.isRequired,\ndismissKeyboardIfShowing: PropTypes.func.isRequired,\nsystemKeyboardShowing: PropTypes.bool.isRequired,\n- imageGalleryOpen: PropTypes.bool.isRequired,\n- setImageGalleryOpen: PropTypes.func.isRequired,\n+ mediaGalleryOpen: PropTypes.bool.isRequired,\n+ setMediaGalleryOpen: PropTypes.func.isRequired,\n});\nconst KeyboardContext = React.createContext<?KeyboardState>(null);\n" }, { "change_type": "MODIFY", "old_path": "native/utils/media-utils.js", "new_path": "native/utils/media-utils.js", "diff": "// @flow\nimport type { Dimensions, MediaType } from 'lib/types/media-types';\n-import type { GalleryImageInfo } from '../media/image-gallery-image.react';\nimport { Platform, Image } from 'react-native';\nimport base64 from 'base-64';\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] ImageGallery -> MediaGallery
129,187
11.11.2019 14:05:44
18,000
c7b5226b4b1e69e16e0c8f32179a363d778aaeaa
[native] Don't crash MediaGalleryKeyboard on SendMediaButton press
[ { "change_type": "MODIFY", "old_path": "native/media/media-gallery-keyboard.react.js", "new_path": "native/media/media-gallery-keyboard.react.js", "diff": "@@ -454,7 +454,9 @@ class MediaGalleryKeyboard extends React.PureComponent<Props, State> {\nsendQueuedMedia = () => {\nconst { mediaInfos, queuedMediaURIs } = this.state;\n- invariant(mediaInfos && queuedMediaURIs, \"should be set\");\n+ if (!mediaInfos || !queuedMediaURIs) {\n+ return;\n+ }\nconst queuedMediaInfos = [];\nfor (let uri of queuedMediaURIs) {\nfor (let mediaInfo of mediaInfos) {\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Don't crash MediaGalleryKeyboard on SendMediaButton press
129,187
11.11.2019 15:10:55
18,000
9fa0d34b61f9caf85f8167c2ccf673b2d17aedfa
[web] Avoid using same localID for simultaneously sent messages Text and media messages can be sent at the same time. Make sure to give them distinct `localID`s
[ { "change_type": "MODIFY", "old_path": "web/chat/chat-input-bar.react.js", "new_path": "web/chat/chat-input-bar.react.js", "diff": "@@ -277,20 +277,23 @@ class ChatInputBar extends React.PureComponent<Props> {\n}\nsend() {\n+ let { nextLocalID } = this.props;\n+\nconst text = this.props.chatInputState.draft.trim();\nif (text) {\n// TODO we should make the send button appear dynamically\n// iff trimmed text is nonempty, just like native\n- this.dispatchTextMessageAction(text);\n+ this.dispatchTextMessageAction(text, nextLocalID);\n+ nextLocalID++;\n}\n- this.props.chatInputState.createMultimediaMessage();\n+ this.props.chatInputState.createMultimediaMessage(nextLocalID);\n}\n- dispatchTextMessageAction(text: string) {\n+ dispatchTextMessageAction(text: string, nextLocalID: number) {\nthis.props.chatInputState.setDraft(\"\");\n- const localID = `local${this.props.nextLocalID}`;\n+ const localID = `local${nextLocalID}`;\nconst creatorID = this.props.viewerID;\ninvariant(creatorID, \"should have viewer ID in order to send a message\");\nconst messageInfo = ({\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": "@@ -303,8 +303,8 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\nthis.appendFiles(threadID, files),\ncancelPendingUpload: (localUploadID: string) =>\nthis.cancelPendingUpload(threadID, localUploadID),\n- createMultimediaMessage: () =>\n- this.createMultimediaMessage(threadID),\n+ createMultimediaMessage: (localID?: number) =>\n+ this.createMultimediaMessage(threadID, localID),\nsetDraft: (draft: string) => this.setDraft(threadID, draft),\nmessageHasUploadFailure: (localMessageID: string) =>\nthis.messageHasUploadFailure(threadAssignedUploads[localMessageID]),\n@@ -606,8 +606,11 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\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}`;\n+ createMultimediaMessage(threadID: string, localID: ?number) {\n+ const nextLocalID = (localID !== null && localID !== undefined)\n+ ? localID\n+ : this.props.nextLocalID;\n+ const localMessageID = `local${nextLocalID}`;\nthis.setState(prevState => {\nconst currentPendingUploads = prevState.pendingUploads[threadID];\nif (!currentPendingUploads) {\n" }, { "change_type": "MODIFY", "old_path": "web/chat/chat-input-state.js", "new_path": "web/chat/chat-input-state.js", "diff": "@@ -51,7 +51,7 @@ export type ChatInputState = {|\ndraft: string,\nappendFiles: (files: $ReadOnlyArray<File>) => Promise<void>,\ncancelPendingUpload: (localUploadID: string) => void,\n- createMultimediaMessage: () => void,\n+ createMultimediaMessage: (localID?: number) => void,\nsetDraft: (draft: string) => void,\nmessageHasUploadFailure: (localMessageID: string) => bool,\nretryMultimediaMessage: (localMessageID: string) => void,\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[web] Avoid using same localID for simultaneously sent messages Text and media messages can be sent at the same time. Make sure to give them distinct `localID`s
129,187
11.11.2019 15:20:04
18,000
7f73a10ec9c083341cada85ad86f69a6195757f1
[server] Retry on MySQL deadlock
[ { "change_type": "MODIFY", "old_path": "server/src/database.js", "new_path": "server/src/database.js", "diff": "@@ -65,7 +65,7 @@ function FakeSQLResult() {\nFakeSQLResult.prototype = Array.prototype;\nconst fakeResult: any = new FakeSQLResult();\n-async function dbQuery(statement: SQLStatement) {\n+async function dbQuery(statement: SQLStatement, triesLeft?: number = 2) {\ntry {\nconst sql = statement.sql.trim();\nif (\n@@ -79,6 +79,10 @@ async function dbQuery(statement: SQLStatement) {\n}\nreturn await pool.query(statement);\n} catch (e) {\n+ if (e.errno === 1213 && triesLeft > 0) {\n+ console.log('deadlock occurred, trying again', e);\n+ return await dbQuery(statement, triesLeft - 1);\n+ }\ne.query = statement.sql;\nthrow e;\n}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[server] Retry on MySQL deadlock
129,187
11.11.2019 15:42:40
18,000
5d68e2a5868b2ceb07734d34d434013057582cc4
[native] codeVersion -> 41
[ { "change_type": "MODIFY", "old_path": "native/android/app/build.gradle", "new_path": "native/android/app/build.gradle", "diff": "@@ -131,8 +131,8 @@ android {\napplicationId \"org.squadcal\"\nminSdkVersion rootProject.ext.minSdkVersion\ntargetSdkVersion rootProject.ext.targetSdkVersion\n- versionCode 40\n- versionName \"0.0.40\"\n+ versionCode 41\n+ versionName \"0.0.41\"\nmissingDimensionStrategy 'react-native-camera', 'general'\nmultiDexEnabled true\n}\n" }, { "change_type": "MODIFY", "old_path": "native/ios/SquadCal/Info.debug.plist", "new_path": "native/ios/SquadCal/Info.debug.plist", "diff": "<key>CFBundlePackageType</key>\n<string>APPL</string>\n<key>CFBundleShortVersionString</key>\n- <string>0.0.40</string>\n+ <string>0.0.41</string>\n<key>CFBundleSignature</key>\n<string>????</string>\n<key>CFBundleVersion</key>\n- <string>40</string>\n+ <string>41</string>\n<key>LSApplicationQueriesSchemes</key>\n<array>\n<string>org-appextension-feature-password-management</string>\n" }, { "change_type": "MODIFY", "old_path": "native/ios/SquadCal/Info.release.plist", "new_path": "native/ios/SquadCal/Info.release.plist", "diff": "<key>CFBundlePackageType</key>\n<string>APPL</string>\n<key>CFBundleShortVersionString</key>\n- <string>0.0.40</string>\n+ <string>0.0.41</string>\n<key>CFBundleSignature</key>\n<string>????</string>\n<key>CFBundleVersion</key>\n- <string>40</string>\n+ <string>41</string>\n<key>LSApplicationQueriesSchemes</key>\n<array>\n<string>org-appextension-feature-password-management</string>\n" }, { "change_type": "MODIFY", "old_path": "native/redux/persist.js", "new_path": "native/redux/persist.js", "diff": "@@ -156,7 +156,7 @@ const persistConfig = {\ntimeout: __DEV__ ? 0 : undefined,\n};\n-const codeVersion = 40;\n+const codeVersion = 41;\n// This local exists to avoid a circular dependency where redux-setup needs to\n// import all the navigation and screen stuff, but some of those screens want to\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] codeVersion -> 41
129,187
11.11.2019 16:57:28
18,000
31d03be14f63c9236b76795c9c2a21ed2fef7f8d
[server] Avoid calling createUpdates twice in activityUpdater
[ { "change_type": "MODIFY", "old_path": "server/src/updaters/activity-updaters.js", "new_path": "server/src/updaters/activity-updaters.js", "diff": "@@ -129,19 +129,21 @@ async function activityUpdater(\nconst memberSetToUnread = setToUnread.filter(filterFunc);\nconst time = Date.now();\n- const makeUpdates = (\n+ const updateDatas = [];\n+ const appendUpdateDatas = (\nthreadIDs: $ReadOnlyArray<string>,\nunread: bool,\n- ) => createUpdates(\n- threadIDs.map(threadID => ({\n+ ) => {\n+ for (let threadID of threadIDs) {\n+ updateDatas.push({\ntype: updateTypes.UPDATE_THREAD_READ_STATUS,\nuserID: viewer.userID,\ntime,\nthreadID,\nunread,\n- })),\n- { viewer, updatesForCurrentSession: \"ignore\" },\n- );\n+ });\n+ }\n+ }\nconst promises = [ focusUpdatePromise ];\nif (memberSetToRead.length > 0) {\n@@ -151,7 +153,7 @@ async function activityUpdater(\nWHERE thread IN (${memberSetToRead})\nAND user = ${viewer.userID}\n`));\n- promises.push(makeUpdates(memberSetToRead, false));\n+ appendUpdateDatas(memberSetToRead, false);\n}\nif (memberSetToUnread.length > 0) {\npromises.push(dbQuery(SQL`\n@@ -160,8 +162,12 @@ async function activityUpdater(\nWHERE thread IN (${memberSetToUnread})\nAND user = ${viewer.userID}\n`));\n- promises.push(makeUpdates(memberSetToUnread, true));\n+ appendUpdateDatas(memberSetToUnread, true);\n}\n+ promises.push(createUpdates(\n+ updateDatas,\n+ { viewer, updatesForCurrentSession: \"ignore\" },\n+ ));\nawait Promise.all(promises);\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[server] Avoid calling createUpdates twice in activityUpdater
129,187
11.11.2019 18:40:44
18,000
8b0b387e4bae80a04a0312e166e633e69dc74e49
[server] Require session ID for web POST
[ { "change_type": "MODIFY", "old_path": "server/src/session/cookies.js", "new_path": "server/src/session/cookies.js", "diff": "@@ -281,20 +281,21 @@ async function fetchViewerFromCookieData(\nreq: $Request,\nsessionParameterInfo: SessionParameterInfo,\n): Promise<FetchViewerResult> {\n+ let viewerResult;\nconst { user, anonymous } = req.cookies;\nif (user) {\n- return await fetchUserViewer(\n+ viewerResult = await fetchUserViewer(\nuser,\ncookieSources.HEADER,\nsessionParameterInfo,\n);\n} else if (anonymous) {\n- return await fetchAnonymousViewer(\n+ viewerResult = await fetchAnonymousViewer(\nanonymous,\ncookieSources.HEADER,\nsessionParameterInfo,\n);\n- }\n+ } else {\nreturn {\ntype: \"nonexistant\",\ncookieName: null,\n@@ -303,6 +304,21 @@ async function fetchViewerFromCookieData(\n};\n}\n+ // We protect against CSRF attacks by making sure that on web,\n+ // non-GET requests cannot use a bare cookie for session identification\n+ if (viewerResult.type === \"valid\") {\n+ const { viewer } = viewerResult;\n+ invariant(\n+ req.method === \"GET\" ||\n+ viewer.sessionIdentifierType !== sessionIdentifierTypes.COOKIE_ID ||\n+ viewer.platform !== \"web\",\n+ \"non-GET request from web using sessionIdentifierTypes.COOKIE_ID\",\n+ );\n+ }\n+\n+ return viewerResult;\n+}\n+\nasync function fetchViewerFromRequestBody(\nbody: mixed,\nsessionParameterInfo: SessionParameterInfo,\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[server] Require session ID for web POST
129,187
12.11.2019 14:11:59
18,000
0400a5ef21069f3f18432df286f5b8f37c92728f
[native] Disable pointerEvents on SendMediaButton when not visible
[ { "change_type": "MODIFY", "old_path": "native/ios/SquadCal.xcodeproj/xcshareddata/xcschemes/SquadCal.xcscheme", "new_path": "native/ios/SquadCal.xcodeproj/xcshareddata/xcschemes/SquadCal.xcscheme", "diff": "</Testables>\n</TestAction>\n<LaunchAction\n- buildConfiguration = \"Release\"\n+ buildConfiguration = \"Debug\"\nselectedDebuggerIdentifier = \"Xcode.DebuggerFoundation.Debugger.LLDB\"\nselectedLauncherIdentifier = \"Xcode.DebuggerFoundation.Launcher.LLDB\"\nlaunchStyle = \"0\"\n" }, { "change_type": "MODIFY", "old_path": "native/media/camera-modal.react.js", "new_path": "native/media/camera-modal.react.js", "diff": "@@ -693,8 +693,9 @@ class CameraModal extends React.PureComponent<Props, State> {\nrenderStagingView() {\nlet image = null;\n- if (this.state.pendingImageInfo) {\n- const imageSource = { uri: this.state.pendingImageInfo.uri };\n+ const { pendingImageInfo } = this.state;\n+ if (pendingImageInfo) {\n+ const imageSource = { uri: pendingImageInfo.uri };\nimage = <Image source={imageSource} style={styles.stagingImage} />;\n} else {\nimage = <ContentLoading fillType=\"flex\" colors={colors.dark} />;\n@@ -714,6 +715,7 @@ class CameraModal extends React.PureComponent<Props, State> {\n</TouchableOpacity>\n<SendMediaButton\nonPress={this.sendPhoto}\n+ pointerEvents={pendingImageInfo ? 'auto' : 'none'}\ncontainerStyle={styles.sendButtonContainer}\nstyle={this.sendButtonStyle}\n/>\n" }, { "change_type": "MODIFY", "old_path": "native/media/media-gallery-keyboard.react.js", "new_path": "native/media/media-gallery-keyboard.react.js", "diff": "@@ -375,6 +375,7 @@ class MediaGalleryKeyboard extends React.PureComponent<Props, State> {\n<SendMediaButton\nonPress={this.sendQueuedMedia}\nqueueCount={queueCount}\n+ pointerEvents={queuedMediaURIs ? 'auto' : 'none'}\ncontainerStyle={this.props.styles.sendButtonContainer}\nstyle={this.sendButtonStyle}\n/>\n" }, { "change_type": "MODIFY", "old_path": "native/media/send-media-button.react.js", "new_path": "native/media/send-media-button.react.js", "diff": "@@ -18,29 +18,37 @@ type Props = {|\nqueueCount?: number,\ncontainerStyle?: ViewStyle,\nstyle?: ViewStyle,\n+ ...$Shape<React.ElementProps<typeof View>>,\n|};\nfunction SendMediaButton(props: Props) {\n- let queueCount = null;\n- if (props.queueCount !== undefined && props.queueCount !== null) {\n- queueCount = (\n+ const {\n+ onPress,\n+ queueCount,\n+ containerStyle,\n+ style,\n+ ...containerProps\n+ } = props;\n+\n+ let queueCountText = null;\n+ if (queueCount !== undefined && queueCount !== null) {\n+ queueCountText = (\n<View style={styles.queueCountBubble}>\n<Text style={styles.queueCountText}>\n- {props.queueCount}\n+ {queueCount}\n</Text>\n</View>\n);\n}\n+\nreturn (\n- <TouchableOpacity\n- onPress={props.onPress}\n- activeOpacity={0.6}\n- style={props.containerStyle}\n- >\n- <Animated.View style={[ styles.sendButton, props.style ]}>\n+ <View {...containerProps} style={containerStyle}>\n+ <TouchableOpacity onPress={onPress} activeOpacity={0.6}>\n+ <Animated.View style={[ styles.sendButton, style ]}>\n<Icon name=\"send\" style={styles.sendIcon} />\n- {queueCount}\n+ {queueCountText}\n</Animated.View>\n</TouchableOpacity>\n+ </View>\n);\n}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Disable pointerEvents on SendMediaButton when not visible
129,187
12.11.2019 15:24:25
18,000
6b771764be4fca72ec946e1ba7563fb9efad9577
[native] MediaGalleryImage -> MediaGalleryMedia
[ { "change_type": "MODIFY", "old_path": "native/chat/chat-input-bar.react.js", "new_path": "native/chat/chat-input-bar.react.js", "diff": "@@ -21,7 +21,7 @@ import type { LoadingStatus } from 'lib/types/loading-types';\nimport { loadingStatusPropType } from 'lib/types/loading-types';\nimport type { CalendarQuery } from 'lib/types/entry-types';\nimport type { KeyboardEvent } from '../keyboard';\n-import type { GalleryMediaInfo } from '../media/media-gallery-image.react';\n+import type { GalleryMediaInfo } from '../media/media-gallery-media.react';\nimport {\ntype KeyboardState,\nkeyboardStatePropType,\n" }, { "change_type": "MODIFY", "old_path": "native/chat/chat-input-state.js", "new_path": "native/chat/chat-input-state.js", "diff": "// @flow\nimport type { Dimensions } from 'lib/types/media-types';\n-import type { GalleryMediaInfo } from '../media/media-gallery-image.react';\n+import type { GalleryMediaInfo } from '../media/media-gallery-media.react';\nimport * as React from 'react';\nimport PropTypes from 'prop-types';\n" }, { "change_type": "MODIFY", "old_path": "native/media/media-gallery-keyboard.react.js", "new_path": "native/media/media-gallery-keyboard.react.js", "diff": "// @flow\n-import type { GalleryMediaInfo } from './media-gallery-image.react';\n+import type { GalleryMediaInfo } from './media-gallery-media.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@@ -30,7 +30,7 @@ import {\ndimensionsSelector,\ncontentBottomOffset,\n} from '../selectors/dimension-selectors';\n-import MediaGalleryImage from './media-gallery-image.react';\n+import MediaGalleryMedia from './media-gallery-media.react';\nimport Animated, { Easing } from 'react-native-reanimated';\nimport { colorsSelector, styleSelector } from '../themes/colors';\nimport { getAndroidPermission } from '../utils/android-permissions';\n@@ -304,13 +304,13 @@ class MediaGalleryKeyboard extends React.PureComponent<Props, State> {\nconst isQueued = !!(queuedMediaURIs && queuedMediaURIs.has(uri));\nconst { queueModeActive } = this;\nreturn (\n- <MediaGalleryImage\n- imageInfo={row.item}\n+ <MediaGalleryMedia\n+ mediaInfo={row.item}\ncontainerHeight={containerHeight}\nqueueModeActive={queueModeActive}\nisQueued={isQueued}\n- setImageQueued={this.setMediaQueued}\n- sendImage={this.sendSingleMedia}\n+ setMediaQueued={this.setMediaQueued}\n+ sendMedia={this.sendSingleMedia}\nisFocused={this.state.focusedMediaURI === uri}\nsetFocus={this.setFocus}\nscreenWidth={this.state.screenWidth}\n" }, { "change_type": "RENAME", "old_path": "native/media/media-gallery-image.react.js", "new_path": "native/media/media-gallery-media.react.js", "diff": "@@ -43,20 +43,20 @@ const reanimatedSpec = {\nconst isAndroid44 = Platform.OS === \"android\" && Platform.Version < 21;\ntype Props = {|\n- imageInfo: GalleryMediaInfo,\n+ mediaInfo: GalleryMediaInfo,\ncontainerHeight: number,\nqueueModeActive: bool,\nisQueued: bool,\n- setImageQueued: (image: GalleryMediaInfo, isQueued: bool) => void,\n- sendImage: (image: GalleryMediaInfo) => void,\n+ setMediaQueued: (media: GalleryMediaInfo, isQueued: bool) => void,\n+ sendMedia: (media: GalleryMediaInfo) => void,\nisFocused: bool,\n- setFocus: (image: GalleryMediaInfo, isFocused: bool) => void,\n+ setFocus: (media: GalleryMediaInfo, isFocused: bool) => void,\nscreenWidth: number,\n|};\n-class ImageGalleryImage extends React.PureComponent<Props> {\n+class MediaGalleryMedia extends React.PureComponent<Props> {\nstatic propTypes = {\n- imageInfo: PropTypes.shape({\n+ mediaInfo: PropTypes.shape({\nheight: PropTypes.number.isRequired,\nwidth: PropTypes.number.isRequired,\nuri: PropTypes.string.isRequired,\n@@ -64,8 +64,8 @@ class ImageGalleryImage extends React.PureComponent<Props> {\ncontainerHeight: PropTypes.number.isRequired,\nqueueModeActive: PropTypes.bool.isRequired,\nisQueued: PropTypes.bool.isRequired,\n- setImageQueued: PropTypes.func.isRequired,\n- sendImage: PropTypes.func.isRequired,\n+ setMediaQueued: PropTypes.func.isRequired,\n+ sendMedia: PropTypes.func.isRequired,\nisFocused: PropTypes.bool.isRequired,\nsetFocus: PropTypes.func.isRequired,\nscreenWidth: PropTypes.number.isRequired,\n@@ -134,8 +134,8 @@ class ImageGalleryImage extends React.PureComponent<Props> {\ncomponentDidUpdate(prevProps: Props) {\nconst animations = [];\n- const isActive = ImageGalleryImage.isActive(this.props);\n- const wasActive = ImageGalleryImage.isActive(prevProps);\n+ const isActive = MediaGalleryMedia.isActive(this.props);\n+ const wasActive = MediaGalleryMedia.isActive(prevProps);\nconst { backdrop, backdropProgress } = this;\nif (isActive && !wasActive) {\nif (backdropProgress) {\n@@ -186,10 +186,9 @@ class ImageGalleryImage extends React.PureComponent<Props> {\n}\nrender() {\n- const { imageInfo, containerHeight } = this.props;\n- const { uri, width, height } = imageInfo;\n- const source = { uri };\n- const active = ImageGalleryImage.isActive(this.props);\n+ const { mediaInfo, containerHeight } = this.props;\n+ const { uri, width, height } = mediaInfo;\n+ const active = MediaGalleryMedia.isActive(this.props);\nconst dimensionsStyle = {\nheight: containerHeight,\nwidth: Math.max(\n@@ -232,6 +231,7 @@ class ImageGalleryImage extends React.PureComponent<Props> {\n);\n}\n+ const source = { uri };\nconst image = (\n<Reanimated.Image\nsource={source}\n@@ -295,16 +295,16 @@ class ImageGalleryImage extends React.PureComponent<Props> {\nonPressBackdrop = () => {\nif (this.props.isQueued) {\n- this.props.setImageQueued(this.props.imageInfo, false);\n+ this.props.setMediaQueued(this.props.mediaInfo, false);\n} else if (this.props.queueModeActive) {\n- this.props.setImageQueued(this.props.imageInfo, true);\n+ this.props.setMediaQueued(this.props.mediaInfo, true);\n} else {\n- this.props.setFocus(this.props.imageInfo, !this.props.isFocused);\n+ this.props.setFocus(this.props.mediaInfo, !this.props.isFocused);\n}\n}\nonBackdropStateChange = (from: number, to: number) => {\n- if (ImageGalleryImage.isActive(this.props)) {\n+ if (MediaGalleryMedia.isActive(this.props)) {\nreturn;\n}\nconst { backdropProgress } = this;\n@@ -325,11 +325,11 @@ class ImageGalleryImage extends React.PureComponent<Props> {\n}\nonPressSend = () => {\n- this.props.sendImage(this.props.imageInfo);\n+ this.props.sendMedia(this.props.mediaInfo);\n}\nonPressEnqueue = () => {\n- this.props.setImageQueued(this.props.imageInfo, true);\n+ this.props.setMediaQueued(this.props.mediaInfo, true);\n}\nonAnimatingBackdropToZeroCompletion = ({ finished }: { finished: bool }) => {\n@@ -388,4 +388,4 @@ const styles = StyleSheet.create({\n},\n});\n-export default ImageGalleryImage;\n+export default MediaGalleryMedia;\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] MediaGalleryImage -> MediaGalleryMedia
129,187
13.11.2019 16:13:45
18,000
f500aabc799e82f2b4af956730199218022d183c
[native] Use react-native-video in MediaGallery
[ { "change_type": "MODIFY", "old_path": "lib/utils/file-utils.js", "new_path": "lib/utils/file-utils.js", "diff": "@@ -33,6 +33,8 @@ const mimeTypesToMediaTypes = {\n\"image/jpeg\": \"photo\",\n\"image/gif\": \"photo\",\n\"image/heic\": \"photo\",\n+ \"video/mp4\": \"video\",\n+ \"video/quicktime\": \"video\",\n};\nexport {\n" }, { "change_type": "MODIFY", "old_path": "native/ios/Podfile.lock", "new_path": "native/ios/Podfile.lock", "diff": "@@ -80,7 +80,7 @@ PODS:\n- React\n- react-native-camera/RN (3.8.0):\n- React\n- - react-native-cameraroll (1.2.1):\n+ - react-native-cameraroll (1.3.0):\n- React\n- react-native-image-resizer (1.0.1):\n- React\n@@ -102,6 +102,11 @@ PODS:\n- React\n- react-native-splash-screen (3.2.0):\n- React\n+ - react-native-video (5.0.2):\n+ - React\n+ - react-native-video/Video (= 5.0.2)\n+ - react-native-video/Video (5.0.2):\n+ - React\n- React-RCTActionSheet (0.60.6):\n- React-Core (= 0.60.6)\n- React-RCTAnimation (0.60.6):\n@@ -180,6 +185,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-native-video (from `../../node_modules/react-native-video`)\n- React-RCTActionSheet (from `../../node_modules/react-native/Libraries/ActionSheetIOS`)\n- React-RCTAnimation (from `../../node_modules/react-native/Libraries/NativeAnimation`)\n- React-RCTBlob (from `../../node_modules/react-native/Libraries/Blob`)\n@@ -259,6 +265,8 @@ EXTERNAL SOURCES:\n:path: \"../../node_modules/react-native-orientation-locker\"\nreact-native-splash-screen:\n:path: \"../../node_modules/react-native-splash-screen\"\n+ react-native-video:\n+ :path: \"../../node_modules/react-native-video\"\nReact-RCTActionSheet:\n:path: \"../../node_modules/react-native/Libraries/ActionSheetIOS\"\nReact-RCTAnimation:\n@@ -320,7 +328,7 @@ SPEC CHECKSUMS:\nReact-jsiexecutor: 2279e559b921d02dfc6253ebef3dcb3a9dc6c07e\nReact-jsinspector: a58b86545a0185f69768e78ac96ca9fe43fa3694\nreact-native-camera: 21cf4ed26cf432ceb1fae959aa6924943fd6f714\n- react-native-cameraroll: 3e5e34d36d93548ae7770ee8ab7b2ae9e778f571\n+ react-native-cameraroll: 463aff54e37cff27ea76eb792e6f1fa43b876320\nreact-native-image-resizer: 48eb06a18a6d0a632ffa162a51ca61a68fb5322f\nreact-native-in-app-message: f91de5009620af01456531118264c93e249b83ec\nreact-native-keyboard-input: 83520632cab76a827bdf1db0aa1c87a047f7c18b\n@@ -330,6 +338,7 @@ SPEC CHECKSUMS:\nreact-native-onepassword: 5b2b7f425f9db40932703e65d350b78cbc598047\nreact-native-orientation-locker: 23918c400376a7043e752c639c122fcf6bce8f1c\nreact-native-splash-screen: 200d11d188e2e78cea3ad319964f6142b6384865\n+ react-native-video: d01ed7ff1e38fa7dcc6c15c94cf505e661b7bfd0\nReact-RCTActionSheet: 49f6a67a7efa6688f637296383d453b97ef13645\nReact-RCTAnimation: e8047438b2927ebbe630bbf600c7309374075df3\nReact-RCTBlob: 2c4b28daca5b3e6e356706d8e0c7436a0e8ef492\n" }, { "change_type": "MODIFY", "old_path": "native/media/media-gallery-keyboard.react.js", "new_path": "native/media/media-gallery-keyboard.react.js", "diff": "@@ -192,7 +192,7 @@ class MediaGalleryKeyboard extends React.PureComponent<Props, State> {\nstatic getPhotosQuery(after: ?string) {\nconst base = {};\nbase.first = 20;\n- base.assetType = \"Photos\";\n+ base.assetType = \"All\";\nif (Platform.OS !== \"android\") {\nbase.groupTypes = \"All\";\n}\n@@ -228,7 +228,7 @@ class MediaGalleryKeyboard extends React.PureComponent<Props, State> {\nlet first = true;\nconst mediaInfos = edges.map(\n({ node }) => {\n- const { uri, height, width } = node.image;\n+ const { uri, height, width, playableDuration } = node.image;\nif (existingURIs.has(uri)) {\nif (first) {\nfirstRemoved = true;\n@@ -240,7 +240,17 @@ class MediaGalleryKeyboard extends React.PureComponent<Props, State> {\nfirst = false;\nlastRemoved = false;\nexistingURIs.add(uri);\n- return { uri, height, width };\n+\n+ const isVideo =\n+ (Platform.OS === \"android\" &&\n+ playableDuration !== null && playableDuration !== undefined) ||\n+ (Platform.OS === \"ios\" && node.type === \"video\");\n+ return {\n+ height,\n+ width,\n+ type: isVideo ? \"video\" : \"photo\",\n+ uri,\n+ };\n},\n).filter(Boolean);\n@@ -314,6 +324,7 @@ class MediaGalleryKeyboard extends React.PureComponent<Props, State> {\nisFocused={this.state.focusedMediaURI === uri}\nsetFocus={this.setFocus}\nscreenWidth={this.state.screenWidth}\n+ colors={this.props.colors}\n/>\n);\n}\n" }, { "change_type": "MODIFY", "old_path": "native/media/media-gallery-media.react.js", "new_path": "native/media/media-gallery-media.react.js", "diff": "// @flow\n-import type { Dimensions } from 'lib/types/media-types';\n+import {\n+ type Dimensions,\n+ type MediaType,\n+ mediaTypePropType,\n+} from 'lib/types/media-types';\nimport type { ViewStyle, ImageStyle } from '../types/styles';\n+import { type Colors, colorsPropType } from '../themes/colors';\nimport * as React from 'react';\nimport PropTypes from 'prop-types';\n@@ -26,9 +31,11 @@ import\n{ Easing as ReanimatedEasing }\nfrom 'react-native-reanimated';\nimport invariant from 'invariant';\n+import Video from 'react-native-video';\nexport type GalleryMediaInfo = {|\n...Dimensions,\n+ type: MediaType,\nuri: string,\n|};\nconst animatedSpec = {\n@@ -52,6 +59,7 @@ type Props = {|\nisFocused: bool,\nsetFocus: (media: GalleryMediaInfo, isFocused: bool) => void,\nscreenWidth: number,\n+ colors: Colors,\n|};\nclass MediaGalleryMedia extends React.PureComponent<Props> {\n@@ -59,6 +67,7 @@ class MediaGalleryMedia extends React.PureComponent<Props> {\nmediaInfo: PropTypes.shape({\nheight: PropTypes.number.isRequired,\nwidth: PropTypes.number.isRequired,\n+ type: mediaTypePropType.isRequired,\nuri: PropTypes.string.isRequired,\n}).isRequired,\ncontainerHeight: PropTypes.number.isRequired,\n@@ -69,6 +78,7 @@ class MediaGalleryMedia extends React.PureComponent<Props> {\nisFocused: PropTypes.bool.isRequired,\nsetFocus: PropTypes.func.isRequired,\nscreenWidth: PropTypes.number.isRequired,\n+ colors: colorsPropType.isRequired,\n};\nbackdrop: ?TouchableOpacity;\nfocusProgress = new Reanimated.Value(0);\n@@ -76,6 +86,8 @@ class MediaGalleryMedia extends React.PureComponent<Props> {\nbackdropProgress: ?Reanimated.Value;\nanimatingBackdropToZero = false;\nimageStyle: ImageStyle;\n+ videoContainerStyle: ViewStyle;\n+ videoOverlayStyle: ViewStyle;\ncheckProgress = new Animated.Value(0);\nconstructor(props: Props) {\n@@ -96,7 +108,7 @@ class MediaGalleryMedia extends React.PureComponent<Props> {\n],\n};\n- const imageScale = Reanimated.interpolate(\n+ const mediaScale = Reanimated.interpolate(\nthis.focusProgress,\n{\ninputRange: [ 0, 1 ],\n@@ -106,9 +118,10 @@ class MediaGalleryMedia extends React.PureComponent<Props> {\nif (isAndroid44) {\nthis.imageStyle = {\ntransform: [\n- { scale: imageScale },\n+ { scale: mediaScale },\n],\n};\n+ this.videoOverlayStyle = {};\n} else {\nthis.backdropProgress = new Reanimated.Value(0);\nconst backdropOpacity = Reanimated.interpolate(\n@@ -121,10 +134,27 @@ class MediaGalleryMedia extends React.PureComponent<Props> {\nthis.imageStyle = {\nopacity: backdropOpacity,\ntransform: [\n- { scale: imageScale },\n+ { scale: mediaScale },\n],\n};\n+ const overlayOpacity = Reanimated.interpolate(\n+ this.backdropProgress,\n+ {\n+ inputRange: [ 0, 1 ],\n+ outputRange: [ 0, 0.8 ],\n+ },\n+ );\n+ this.videoOverlayStyle = {\n+ ...styles.videoOverlay,\n+ opacity: overlayOpacity,\n+ backgroundColor: props.colors.listBackground,\n+ };\n}\n+ this.videoContainerStyle = {\n+ transform: [\n+ { scale: mediaScale },\n+ ],\n+ };\n}\nstatic isActive(props: Props) {\n@@ -187,7 +217,7 @@ class MediaGalleryMedia extends React.PureComponent<Props> {\nrender() {\nconst { mediaInfo, containerHeight } = this.props;\n- const { uri, width, height } = mediaInfo;\n+ const { uri, width, height, type } = mediaInfo;\nconst active = MediaGalleryMedia.isActive(this.props);\nconst dimensionsStyle = {\nheight: containerHeight,\n@@ -232,12 +262,27 @@ class MediaGalleryMedia extends React.PureComponent<Props> {\n}\nconst source = { uri };\n- const image = (\n+ let media;\n+ if (type === \"video\") {\n+ media = (\n+ <Reanimated.View style={this.videoContainerStyle}>\n+ <Video\n+ source={source}\n+ repeat={true}\n+ style={dimensionsStyle}\n+ />\n+ <Reanimated.View style={this.videoOverlayStyle} />\n+ </Reanimated.View>\n+ );\n+ } else {\n+ media = (\n<Reanimated.Image\nsource={source}\nstyle={[ this.imageStyle, dimensionsStyle ]}\n/>\n);\n+ }\n+\nconst checkAnimation = (\n<LottieView\nsource={require('../animations/check.json')}\n@@ -258,7 +303,7 @@ class MediaGalleryMedia extends React.PureComponent<Props> {\nstyle={backdropStyle}\nref={this.backdropRef}\n>\n- {image}\n+ {media}\n</TouchableOpacity>\n<Reanimated.View style={this.buttonsStyle} pointerEvents=\"none\">\n{checkAnimation}\n@@ -274,7 +319,7 @@ class MediaGalleryMedia extends React.PureComponent<Props> {\nonStateChange={this.onBackdropStateChange}\ndelayPressOut={1}\n>\n- {image}\n+ {media}\n<Reanimated.View style={this.buttonsStyle}>\n{checkAnimation}\n</Reanimated.View>\n@@ -386,6 +431,13 @@ const styles = StyleSheet.create({\nposition: 'absolute',\nwidth: 128,\n},\n+ videoOverlay: {\n+ position: 'absolute',\n+ top: 0,\n+ bottom: 0,\n+ left: 0,\n+ right: 0,\n+ },\n});\nexport default MediaGalleryMedia;\n" }, { "change_type": "MODIFY", "old_path": "native/package.json", "new_path": "native/package.json", "diff": "},\n\"dependencies\": {\n\"@react-native-community/async-storage\": \"^1.6.1\",\n- \"@react-native-community/cameraroll\": \"^1.2.1\",\n+ \"@react-native-community/cameraroll\": \"^1.3.0\",\n\"@react-native-community/netinfo\": \"^4.4.0\",\n\"base-64\": \"^0.1.0\",\n\"find-root\": \"^1.1.0\",\n\"react-native-segmented-control-tab\": \"^3.2.1\",\n\"react-native-splash-screen\": \"^3.2.0\",\n\"react-native-vector-icons\": \"^6.6.0\",\n+ \"react-native-video\": \"^5.0.2\",\n\"react-navigation\": \"^4.0.6\",\n\"react-navigation-redux-helpers\": \"^4.0.0\",\n\"react-navigation-stack\": \"^1.10.2\",\n" }, { "change_type": "MODIFY", "old_path": "yarn.lock", "new_path": "yarn.lock", "diff": "resolved \"https://registry.yarnpkg.com/@react-native-community/async-storage/-/async-storage-1.6.2.tgz#a19ca7149c4dfe8216f2330e6b1ebfe2d075ef92\"\nintegrity sha512-EJGsbrHubK1mGxPjWB74AaHAd5m9I+Gg2RRPZzMK6org7QOU9WOBnIMFqoeVto3hKOaEPlk8NV74H6G34/2pZQ==\n-\"@react-native-community/cameraroll@^1.2.1\":\n- version \"1.2.1\"\n- resolved \"https://registry.yarnpkg.com/@react-native-community/cameraroll/-/cameraroll-1.2.1.tgz#68ae3a1de07dd5db8ce9d898057f30c1585c7f1d\"\n- integrity sha512-dMvzCano5/ltQYbF4AOEHe0vaW3Owt05S4y+gJ6PlBp2/YfQAVv7XNgvsvF2CKz4oPKuZAOchENDV/J+nbMbWg==\n+\"@react-native-community/cameraroll@^1.3.0\":\n+ version \"1.3.0\"\n+ resolved \"https://registry.yarnpkg.com/@react-native-community/cameraroll/-/cameraroll-1.3.0.tgz#a340334440f4d08280da839130ef51c931b07483\"\n+ integrity sha512-QJl9N34euvGU7s/Gn6jhsqi70O4SmxFxuy+yBnW7ehE8qtPYO91gyLLrtiWdTfYvuVCUNvX/G0LKJQLm8SojAA==\n\"@react-native-community/cli-platform-android@^2.6.0\", \"@react-native-community/cli-platform-android@^2.9.0\":\nversion \"2.9.0\"\n@@ -7188,6 +7188,11 @@ jws@^3.1.4, jws@^3.1.5, jws@^3.2.2:\njwa \"^1.4.1\"\nsafe-buffer \"^5.0.1\"\n+keymirror@^0.1.1:\n+ version \"0.1.1\"\n+ resolved \"https://registry.yarnpkg.com/keymirror/-/keymirror-0.1.1.tgz#918889ea13f8d0a42e7c557250eee713adc95c35\"\n+ integrity sha1-kYiJ6hP40KQufFVyUO7nE63JXDU=\n+\nkeyv@3.0.0:\nversion \"3.0.0\"\nresolved \"https://registry.yarnpkg.com/keyv/-/keyv-3.0.0.tgz#44923ba39e68b12a7cec7df6c3268c031f2ef373\"\n@@ -10209,6 +10214,15 @@ react-native-vector-icons@^6.6.0:\nprop-types \"^15.6.2\"\nyargs \"^13.2.2\"\n+react-native-video@^5.0.2:\n+ version \"5.0.2\"\n+ resolved \"https://registry.yarnpkg.com/react-native-video/-/react-native-video-5.0.2.tgz#8f07da0cd85a1d4b316d115f3786409efc9e39fb\"\n+ integrity sha512-zbItbMH0uZYkK7xFKa41+950QjoTrIl60bY1vAP7gxTn20HGHvHZRw28h9A5npK5T0QuWMAkn8twaGzqcDkTug==\n+ dependencies:\n+ keymirror \"^0.1.1\"\n+ prop-types \"^15.5.10\"\n+ shaka-player \"^2.4.4\"\n+\nreact-native@0.60.6:\nversion \"0.60.6\"\nresolved \"https://registry.yarnpkg.com/react-native/-/react-native-0.60.6.tgz#8a13dece1c3f6e01db0833db14d2b01b2d8ccba5\"\n@@ -11103,6 +11117,11 @@ sha.js@^2.4.0, sha.js@^2.4.8:\ninherits \"^2.0.1\"\nsafe-buffer \"^5.0.1\"\n+shaka-player@^2.4.4:\n+ version \"2.5.6\"\n+ resolved \"https://registry.yarnpkg.com/shaka-player/-/shaka-player-2.5.6.tgz#1397ffdee9d60fa50c13cda6d584da5228b4607f\"\n+ integrity sha512-z1BM/kpg5OVk57w5gXYBGk78Le04gfCHBOpT106Nz7h4VU7im7o8ZldUKxC9+FlSL4sPvdU8lY6OxL7L3hw5Fw==\n+\nshallowequal@^1.0.2, shallowequal@^1.1.0:\nversion \"1.1.0\"\nresolved \"https://registry.yarnpkg.com/shallowequal/-/shallowequal-1.1.0.tgz#188d521de95b9087404fd4dcb68b13df0ae4e7f8\"\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Use react-native-video in MediaGallery
129,187
13.11.2019 15:06:05
18,000
2031883f53f173b0c1d9484bf0a1740c3ab65434
[native] Use ph-upload scheme for fetching media blob on iOS
[ { "change_type": "MODIFY", "old_path": "native/chat/chat-input-state-container.react.js", "new_path": "native/chat/chat-input-state-container.react.js", "diff": "@@ -504,7 +504,7 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\n);\nconst imageGalleryImages = retryMedia.map(\n- ({ dimensions, uri }) => ({ ...dimensions, uri }),\n+ ({ dimensions, uri, type }) => ({ ...dimensions, uri, type }),\n);\nconst validationResults = await Promise.all(\nimageGalleryImages.map(validateMedia),\n" }, { "change_type": "MODIFY", "old_path": "native/media/camera-modal.react.js", "new_path": "native/media/camera-modal.react.js", "diff": "@@ -950,6 +950,7 @@ class CameraModal extends React.PureComponent<Props, State> {\nuri,\nwidth,\nheight,\n+ type: \"photo\",\nunlinkURIAfterRemoving: true,\n};\n" }, { "change_type": "MODIFY", "old_path": "native/utils/media-utils.js", "new_path": "native/utils/media-utils.js", "diff": "@@ -24,16 +24,29 @@ type ValidateMediaInput = {\nuri: string,\nheight: number,\nwidth: number,\n+ type: MediaType,\n...\n};\nasync function validateMedia(\nimageInfo: ValidateMediaInput,\n): Promise<?MediaValidationResult> {\n- const { uri, height, width } = imageInfo;\n+ // React Native always resolves FBMediaKit's ph:// scheme as an image so that\n+ // the Image component can render thumbnails of videos. In order to force\n+ // fetch() to return a blob of the video, we need to use the ph-upload://\n+ // scheme. https://git.io/Jerlh\n+ const fbMediaKitURL = imageInfo.uri.startsWith('ph://');\n+ const uri = (fbMediaKitURL && imageInfo.type === \"video\")\n+ ? imageInfo.uri.replace(/^ph:/, 'ph-upload:')\n+ : imageInfo.uri;\n+ const { height, width } = imageInfo;\n+\nconst dimensions = { height, width };\nconst response = await fetch(uri);\nconst blob = await response.blob();\n- const reportedMIME = blob.type;\n+ const reportedMIME = (fbMediaKitURL && blob.type === \"application/octet-stream\")\n+ ? \"video/quicktime\"\n+ : blob.type;\n+\nconst mediaType = mimeTypesToMediaTypes[reportedMIME];\nif (!mediaType) {\nreturn null;\n@@ -128,7 +141,7 @@ async function convertMedia(\nuploadURI: resizedURI,\nshouldDisposePath: path,\nname,\n- mime: \"image/jpeg\",\n+ mime: reportedMIME === \"image/png\" ? \"image/png\" : \"image/jpeg\",\nmediaType: \"photo\",\ndimensions: resizedDimensions,\n};\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Use ph-upload scheme for fetching media blob on iOS
129,187
13.11.2019 16:22:45
18,000
5302d25a53c366a0ed4bf8d10929d58f1eb4e623
[native] Avoid passing ph:// URIs to react-native-video on iOS
[ { "change_type": "MODIFY", "old_path": "lib/utils/file-utils.js", "new_path": "lib/utils/file-utils.js", "diff": "@@ -37,7 +37,21 @@ const mimeTypesToMediaTypes = {\n\"video/quicktime\": \"video\",\n};\n+const extRegex = /\\.[0-9a-z]+$/i;\n+function extensionFromFilename(filename: string): ?string {\n+ const matches = filename.match(extRegex);\n+ if (!matches) {\n+ return null;\n+ }\n+ const match = matches[0];\n+ if (!match) {\n+ return null;\n+ }\n+ return match;\n+}\n+\nexport {\nfileInfoFromData,\nmimeTypesToMediaTypes,\n+ extensionFromFilename,\n};\n" }, { "change_type": "MODIFY", "old_path": "native/media/media-gallery-keyboard.react.js", "new_path": "native/media/media-gallery-keyboard.react.js", "diff": "@@ -23,7 +23,10 @@ import CameraRoll from '@react-native-community/cameraroll';\nimport PropTypes from 'prop-types';\nimport { connect } from 'lib/utils/redux-utils';\n-import { mimeTypesToMediaTypes } from 'lib/utils/file-utils';\n+import {\n+ mimeTypesToMediaTypes,\n+ extensionFromFilename,\n+} from 'lib/utils/file-utils';\nimport { store } from '../redux/redux-setup';\nimport {\n@@ -35,6 +38,7 @@ import Animated, { Easing } from 'react-native-reanimated';\nimport { colorsSelector, styleSelector } from '../themes/colors';\nimport { getAndroidPermission } from '../utils/android-permissions';\nimport SendMediaButton from './send-media-button.react';\n+import { getCompatibleMediaURI } from '../utils/media-utils';\nconst animationSpec = {\nduration: 400,\n@@ -228,7 +232,7 @@ class MediaGalleryKeyboard extends React.PureComponent<Props, State> {\nlet first = true;\nconst mediaInfos = edges.map(\n({ node }) => {\n- const { uri, height, width, playableDuration } = node.image;\n+ const { uri, height, width, filename, playableDuration } = node.image;\nif (existingURIs.has(uri)) {\nif (first) {\nfirstRemoved = true;\n@@ -245,12 +249,17 @@ class MediaGalleryKeyboard extends React.PureComponent<Props, State> {\n(Platform.OS === \"android\" &&\nplayableDuration !== null && playableDuration !== undefined) ||\n(Platform.OS === \"ios\" && node.type === \"video\");\n- return {\n+ const mediaInfo: GalleryMediaInfo = {\nheight,\nwidth,\ntype: isVideo ? \"video\" : \"photo\",\nuri,\n};\n+ const extension = extensionFromFilename(filename);\n+ if (extension) {\n+ mediaInfo.compatibleURI = getCompatibleMediaURI(uri, extension);\n+ }\n+ return mediaInfo;\n},\n).filter(Boolean);\n" }, { "change_type": "MODIFY", "old_path": "native/media/media-gallery-media.react.js", "new_path": "native/media/media-gallery-media.react.js", "diff": "@@ -37,6 +37,7 @@ export type GalleryMediaInfo = {|\n...Dimensions,\ntype: MediaType,\nuri: string,\n+ compatibleURI?: string,\n|};\nconst animatedSpec = {\nduration: 400,\n@@ -69,6 +70,7 @@ class MediaGalleryMedia extends React.PureComponent<Props> {\nwidth: PropTypes.number.isRequired,\ntype: mediaTypePropType.isRequired,\nuri: PropTypes.string.isRequired,\n+ compatibleURI: PropTypes.string,\n}).isRequired,\ncontainerHeight: PropTypes.number.isRequired,\nqueueModeActive: PropTypes.bool.isRequired,\n@@ -217,7 +219,7 @@ class MediaGalleryMedia extends React.PureComponent<Props> {\nrender() {\nconst { mediaInfo, containerHeight } = this.props;\n- const { uri, width, height, type } = mediaInfo;\n+ const { uri, width, height, compatibleURI, type } = mediaInfo;\nconst active = MediaGalleryMedia.isActive(this.props);\nconst dimensionsStyle = {\nheight: containerHeight,\n@@ -261,9 +263,9 @@ class MediaGalleryMedia extends React.PureComponent<Props> {\n);\n}\n- const source = { uri };\nlet media;\nif (type === \"video\") {\n+ const source = { uri: compatibleURI ? compatibleURI : uri };\nmedia = (\n<Reanimated.View style={this.videoContainerStyle}>\n<Video\n@@ -275,6 +277,7 @@ class MediaGalleryMedia extends React.PureComponent<Props> {\n</Reanimated.View>\n);\n} else {\n+ const source = { uri };\nmedia = (\n<Reanimated.Image\nsource={source}\n" }, { "change_type": "MODIFY", "old_path": "native/utils/media-utils.js", "new_path": "native/utils/media-utils.js", "diff": "@@ -180,10 +180,27 @@ function pathFromURI(uri: string): ?string {\nreturn path;\n}\n+function getCompatibleMediaURI(uri: string, ext: string): string {\n+ if (!uri.startsWith('ph://')) {\n+ return uri;\n+ }\n+ const photoKitLocalIdentifier = uri.split('/')[2];\n+ if (!photoKitLocalIdentifier) {\n+ return uri;\n+ }\n+ // While the ph:// scheme is a Facebook hack used by FBMediaKit, the\n+ // assets-library:// scheme is a legacy Apple identifier. Certain components\n+ // and libraries (namely react-native-video) don't know how to handle the\n+ // ph:// scheme yet, so we have to map to the legacy assets-library:// scheme\n+ return `assets-library://asset/asset.${ext}` +\n+ `?id=${photoKitLocalIdentifier}&ext=${ext}`;\n+}\n+\nexport {\nvalidateMedia,\nblobToDataURI,\ndataURIToIntArray,\nconvertMedia,\npathFromURI,\n+ getCompatibleMediaURI,\n};\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Avoid passing ph:// URIs to react-native-video on iOS
129,187
14.11.2019 16:54:10
18,000
9ae6b53df09d7be5dcedb47753ad49d18f2a96dd
pathFromURI -> lib
[ { "change_type": "MODIFY", "old_path": "lib/utils/file-utils.js", "new_path": "lib/utils/file-utils.js", "diff": "@@ -50,8 +50,21 @@ function extensionFromFilename(filename: string): ?string {\nreturn match;\n}\n+function pathFromURI(uri: string): ?string {\n+ const matches = uri.match(/^file:\\/\\/(.*)$/);\n+ if (!matches) {\n+ return null;\n+ }\n+ const path = matches[1];\n+ if (!path) {\n+ return null;\n+ }\n+ return path;\n+}\n+\nexport {\nfileInfoFromData,\nmimeTypesToMediaTypes,\nextensionFromFilename,\n+ pathFromURI,\n};\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": "@@ -34,9 +34,10 @@ import {\nsendMultimediaMessageActionTypes,\nsendMultimediaMessage,\n} from 'lib/actions/message-actions';\n+import { pathFromURI } from 'lib/utils/file-utils';\nimport { ChatInputStateContext } from './chat-input-state';\n-import { validateMedia, convertMedia, pathFromURI } from '../utils/media-utils';\n+import { validateMedia, convertMedia } from '../utils/media-utils';\nlet nextLocalUploadID = 0;\ntype ImageInfo = {|\n" }, { "change_type": "MODIFY", "old_path": "native/media/camera-modal.react.js", "new_path": "native/media/camera-modal.react.js", "diff": "@@ -46,6 +46,7 @@ import invariant from 'invariant';\nimport filesystem from 'react-native-fs';\nimport { connect } from 'lib/utils/redux-utils';\n+import { pathFromURI } from 'lib/utils/file-utils';\nimport {\ncontentBottomOffset,\n@@ -58,7 +59,6 @@ import ContentLoading from '../components/content-loading.react';\nimport { colors } from '../themes/colors';\nimport { saveImage } from './save-image';\nimport SendMediaButton from './send-media-button.react';\n-import { pathFromURI } from '../utils/media-utils';\nconst {\nValue,\n" }, { "change_type": "MODIFY", "old_path": "native/utils/media-utils.js", "new_path": "native/utils/media-utils.js", "diff": "@@ -168,18 +168,6 @@ async function convertMedia(\n};\n}\n-function pathFromURI(uri: string): ?string {\n- const matches = uri.match(/^file:\\/\\/(.*)$/);\n- if (!matches) {\n- return null;\n- }\n- const path = matches[1];\n- if (!path) {\n- return null;\n- }\n- return path;\n-}\n-\nfunction getCompatibleMediaURI(uri: string, ext: string): string {\nif (!uri.startsWith('ph://')) {\nreturn uri;\n@@ -201,6 +189,5 @@ export {\nblobToDataURI,\ndataURIToIntArray,\nconvertMedia,\n- pathFromURI,\ngetCompatibleMediaURI,\n};\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
pathFromURI -> lib
129,187
15.11.2019 18:46:03
18,000
72a02c77982405d0057de90f3e946ede1ff4d606
[lib] filenameFromPathOrURI
[ { "change_type": "MODIFY", "old_path": "lib/utils/file-utils.js", "new_path": "lib/utils/file-utils.js", "diff": "@@ -37,29 +37,35 @@ const mimeTypesToMediaTypes = {\n\"video/quicktime\": \"video\",\n};\n-const extRegex = /\\.[0-9a-z]+$/i;\n+const extRegex = /\\.([0-9a-z]+)$/i;\nfunction extensionFromFilename(filename: string): ?string {\nconst matches = filename.match(extRegex);\nif (!matches) {\nreturn null;\n}\n- const match = matches[0];\n+ const match = matches[1];\nif (!match) {\nreturn null;\n}\n- return match;\n+ return match.toLowerCase();\n}\n+const pathRegex = /^file:\\/\\/(.*)$/;\nfunction pathFromURI(uri: string): ?string {\n- const matches = uri.match(/^file:\\/\\/(.*)$/);\n+ const matches = uri.match(pathRegex);\nif (!matches) {\nreturn null;\n}\n- const path = matches[1];\n- if (!path) {\n+ return matches[1] ? matches[1] : null;\n+}\n+\n+const filenameRegex = /[^/]+$/;\n+function filenameFromPathOrURI(pathOrURI: string): ?string {\n+ const matches = pathOrURI.match(filenameRegex);\n+ if (!matches) {\nreturn null;\n}\n- return path;\n+ return matches[0] ? matches[0] : null;\n}\nexport {\n@@ -67,4 +73,5 @@ export {\nmimeTypesToMediaTypes,\nextensionFromFilename,\npathFromURI,\n+ filenameFromPathOrURI,\n};\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[lib] filenameFromPathOrURI
129,187
15.11.2019 18:36:34
18,000
a4c7725d1ebd79e6373c2678e05f30c384816b00
[native] Include filename in video info
[ { "change_type": "MODIFY", "old_path": "native/media/camera-modal.react.js", "new_path": "native/media/camera-modal.react.js", "diff": "@@ -46,7 +46,7 @@ import invariant from 'invariant';\nimport filesystem from 'react-native-fs';\nimport { connect } from 'lib/utils/redux-utils';\n-import { pathFromURI } from 'lib/utils/file-utils';\n+import { pathFromURI, filenameFromPathOrURI } from 'lib/utils/file-utils';\nimport {\ncontentBottomOffset,\n@@ -946,8 +946,15 @@ class CameraModal extends React.PureComponent<Props, State> {\ncamera.pausePreview();\n}\nconst { uri, width, height } = await photoPromise;\n+ const filename = filenameFromPathOrURI(uri);\n+ invariant(\n+ filename,\n+ `unable to parse filename out of react-native-camera URI ${uri}`,\n+ );\n+\nconst pendingImageInfo = {\nuri,\n+ filename,\nwidth,\nheight,\ntype: \"photo\",\n" }, { "change_type": "MODIFY", "old_path": "native/media/media-gallery-keyboard.react.js", "new_path": "native/media/media-gallery-keyboard.react.js", "diff": "@@ -23,10 +23,7 @@ import CameraRoll from '@react-native-community/cameraroll';\nimport PropTypes from 'prop-types';\nimport { connect } from 'lib/utils/redux-utils';\n-import {\n- mimeTypesToMediaTypes,\n- extensionFromFilename,\n-} from 'lib/utils/file-utils';\n+import { mimeTypesToMediaTypes } from 'lib/utils/file-utils';\nimport { store } from '../redux/redux-setup';\nimport {\n@@ -38,7 +35,6 @@ import Animated, { Easing } from 'react-native-reanimated';\nimport { colorsSelector, styleSelector } from '../themes/colors';\nimport { getAndroidPermission } from '../utils/android-permissions';\nimport SendMediaButton from './send-media-button.react';\n-import { getCompatibleMediaURI } from '../utils/media-utils';\nconst animationSpec = {\nduration: 400,\n@@ -249,17 +245,13 @@ class MediaGalleryKeyboard extends React.PureComponent<Props, State> {\n(Platform.OS === \"android\" &&\nplayableDuration !== null && playableDuration !== undefined) ||\n(Platform.OS === \"ios\" && node.type === \"video\");\n- const mediaInfo: GalleryMediaInfo = {\n+ return {\nheight,\nwidth,\ntype: isVideo ? \"video\" : \"photo\",\nuri,\n+ filename,\n};\n- const extension = extensionFromFilename(filename);\n- if (extension) {\n- mediaInfo.compatibleURI = getCompatibleMediaURI(uri, extension);\n- }\n- return mediaInfo;\n},\n).filter(Boolean);\n" }, { "change_type": "MODIFY", "old_path": "native/media/media-gallery-media.react.js", "new_path": "native/media/media-gallery-media.react.js", "diff": "@@ -33,11 +33,15 @@ from 'react-native-reanimated';\nimport invariant from 'invariant';\nimport Video from 'react-native-video';\n+import { extensionFromFilename } from 'lib/utils/file-utils';\n+\n+import { getCompatibleMediaURI } from '../utils/media-utils';\n+\nexport type GalleryMediaInfo = {|\n...Dimensions,\ntype: MediaType,\nuri: string,\n- compatibleURI?: string,\n+ filename: string,\n|};\nconst animatedSpec = {\nduration: 400,\n@@ -70,7 +74,7 @@ class MediaGalleryMedia extends React.PureComponent<Props> {\nwidth: PropTypes.number.isRequired,\ntype: mediaTypePropType.isRequired,\nuri: PropTypes.string.isRequired,\n- compatibleURI: PropTypes.string,\n+ filename: PropTypes.string.isRequired,\n}).isRequired,\ncontainerHeight: PropTypes.number.isRequired,\nqueueModeActive: PropTypes.bool.isRequired,\n@@ -217,9 +221,18 @@ class MediaGalleryMedia extends React.PureComponent<Props> {\n}\n}\n+ get compatibleURI() {\n+ const { uri, filename } = this.props.mediaInfo;\n+ const extension = extensionFromFilename(filename);\n+ if (!extension) {\n+ return uri;\n+ }\n+ return getCompatibleMediaURI(uri, extension);\n+ }\n+\nrender() {\nconst { mediaInfo, containerHeight } = this.props;\n- const { uri, width, height, compatibleURI, type } = mediaInfo;\n+ const { uri, width, height, type } = mediaInfo;\nconst active = MediaGalleryMedia.isActive(this.props);\nconst dimensionsStyle = {\nheight: containerHeight,\n@@ -265,7 +278,7 @@ class MediaGalleryMedia extends React.PureComponent<Props> {\nlet media;\nif (type === \"video\") {\n- const source = { uri: compatibleURI ? compatibleURI : uri };\n+ const source = { uri: this.compatibleURI };\nmedia = (\n<Reanimated.View style={this.videoContainerStyle}>\n<Video\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Include filename in video info
129,187
15.11.2019 18:56:29
18,000
0f65bef64edd6ed9bb128dfe5d965dd7880d79ae
[lib] stripExtension
[ { "change_type": "MODIFY", "old_path": "lib/utils/file-utils.js", "new_path": "lib/utils/file-utils.js", "diff": "@@ -50,6 +50,15 @@ function extensionFromFilename(filename: string): ?string {\nreturn match.toLowerCase();\n}\n+const stripExtensionRegex = /(.*)\\.[^.]+$/;\n+function stripExtension(filename: string): string {\n+ const matches = filename.match(stripExtensionRegex);\n+ if (!matches) {\n+ return filename;\n+ }\n+ return matches[1] ? matches[1] : filename;\n+}\n+\nconst pathRegex = /^file:\\/\\/(.*)$/;\nfunction pathFromURI(uri: string): ?string {\nconst matches = uri.match(pathRegex);\n@@ -72,6 +81,7 @@ export {\nfileInfoFromData,\nmimeTypesToMediaTypes,\nextensionFromFilename,\n+ stripExtension,\npathFromURI,\nfilenameFromPathOrURI,\n};\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[lib] stripExtension
129,187
20.11.2019 14:57:24
18,000
ab0c954325b6934c4815d80d76584fc3c0f9fd50
[native] Add native modules for video transcode
[ { "change_type": "MODIFY", "old_path": "native/android/build.gradle", "new_path": "native/android/build.gradle", "diff": "@@ -21,6 +21,10 @@ buildscript {\n}\n}\n+ext {\n+ reactNativeFFmpegPackage = \"min-lts\"\n+}\n+\nallprojects {\nrepositories {\nmavenLocal()\n" }, { "change_type": "MODIFY", "old_path": "native/ios/Podfile", "new_path": "native/ios/Podfile", "diff": "-platform :ios, '9.0'\n+platform :ios, '9.3'\nrequire_relative '../../node_modules/@react-native-community/cli-platform-ios/native_modules'\ntarget 'SquadCal' do\n@@ -30,6 +30,7 @@ target 'SquadCal' do\npod 'react-native-keyboard-tracking-view', :path => '../../node_modules/react-native-keyboard-tracking-view'\npod 'react-native-keyboard-input', :path => '../../node_modules/react-native-keyboard-input'\n+ pod 'react-native-ffmpeg/min-lts', :podspec => '../../node_modules/react-native-ffmpeg/ios/react-native-ffmpeg.podspec'\nuse_native_modules!(\"..\")\nend\n" }, { "change_type": "MODIFY", "old_path": "native/ios/Podfile.lock", "new_path": "native/ios/Podfile.lock", "diff": "@@ -25,6 +25,7 @@ PODS:\n- lottie-react-native (3.2.1):\n- lottie-ios (~> 3.1.3)\n- React\n+ - mobile-ffmpeg-min (4.2.2.LTS)\n- React (0.60.6):\n- React-Core (= 0.60.6)\n- React-DevSupport (= 0.60.6)\n@@ -82,6 +83,9 @@ PODS:\n- React\n- react-native-cameraroll (1.3.0):\n- React\n+ - react-native-ffmpeg/min-lts (0.4.0):\n+ - mobile-ffmpeg-min (= 4.2.2.LTS)\n+ - React\n- react-native-image-resizer (1.0.1):\n- React\n- react-native-in-app-message (1.0.2):\n@@ -91,6 +95,8 @@ PODS:\n- react-native-keyboard-tracking-view\n- react-native-keyboard-tracking-view (5.5.0):\n- React\n+ - react-native-mov-to-mp4 (0.2.2):\n+ - React\n- react-native-netinfo (4.4.0):\n- React\n- react-native-notifications (1.1.19):\n@@ -140,7 +146,7 @@ PODS:\n- React\n- SDWebImage (~> 5.0)\n- SDWebImageWebPCoder (~> 0.2.3)\n- - RNFS (2.14.1):\n+ - RNFS (2.15.2):\n- React\n- RNGestureHandler (1.4.1):\n- React\n@@ -176,10 +182,12 @@ DEPENDENCIES:\n- React-jsinspector (from `../../node_modules/react-native/ReactCommon/jsinspector`)\n- react-native-camera (from `../../node_modules/react-native-camera`)\n- \"react-native-cameraroll (from `../../node_modules/@react-native-community/cameraroll`)\"\n+ - react-native-ffmpeg/min-lts (from `../../node_modules/react-native-ffmpeg/ios/react-native-ffmpeg.podspec`)\n- react-native-image-resizer (from `../../node_modules/react-native-image-resizer`)\n- react-native-in-app-message (from `../../node_modules/react-native-in-app-message`)\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-mov-to-mp4 (from `../../node_modules/react-native-mov-to-mp4`)\n- \"react-native-netinfo (from `../../node_modules/@react-native-community/netinfo`)\"\n- react-native-notifications (from `../../node_modules/react-native-notifications`)\n- react-native-onepassword (from `../../node_modules/react-native-onepassword`)\n@@ -213,6 +221,7 @@ SPEC REPOS:\n- 1PasswordExtension\n- boost-for-react-native\n- libwebp\n+ - mobile-ffmpeg-min\n- SDWebImage\n- SDWebImageWebPCoder\n@@ -247,6 +256,8 @@ EXTERNAL SOURCES:\n:path: \"../../node_modules/react-native-camera\"\nreact-native-cameraroll:\n:path: \"../../node_modules/@react-native-community/cameraroll\"\n+ react-native-ffmpeg:\n+ :podspec: \"../../node_modules/react-native-ffmpeg/ios/react-native-ffmpeg.podspec\"\nreact-native-image-resizer:\n:path: \"../../node_modules/react-native-image-resizer\"\nreact-native-in-app-message:\n@@ -255,6 +266,8 @@ EXTERNAL SOURCES:\n:path: \"../../node_modules/react-native-keyboard-input\"\nreact-native-keyboard-tracking-view:\n:path: \"../../node_modules/react-native-keyboard-tracking-view\"\n+ react-native-mov-to-mp4:\n+ :path: \"../../node_modules/react-native-mov-to-mp4\"\nreact-native-netinfo:\n:path: \"../../node_modules/@react-native-community/netinfo\"\nreact-native-notifications:\n@@ -319,6 +332,7 @@ SPEC CHECKSUMS:\nlibwebp: 057912d6d0abfb6357d8bb05c0ea470301f5d61e\nlottie-ios: 496ac5cea1bbf1a7bd1f1f472f3232eb1b8d744b\nlottie-react-native: b123a79529cc732201091f585c62c89bb4747252\n+ mobile-ffmpeg-min: 05ebe3998721155274ae50466b5223d3637a92ab\nReact: 68e7f8dfc27729eade18423072a143120f2f32ab\nReact-ART: b5b51652ddd2096f23c3c045ce4f4309b2aafcf6\nReact-Core: fc9dace551f6c8c1007dd2d3cb1bc10c90a01d3e\n@@ -329,10 +343,12 @@ SPEC CHECKSUMS:\nReact-jsinspector: a58b86545a0185f69768e78ac96ca9fe43fa3694\nreact-native-camera: 21cf4ed26cf432ceb1fae959aa6924943fd6f714\nreact-native-cameraroll: 463aff54e37cff27ea76eb792e6f1fa43b876320\n+ react-native-ffmpeg: 35e303059e3c958cb74e271a45f9391d044f915a\nreact-native-image-resizer: 48eb06a18a6d0a632ffa162a51ca61a68fb5322f\nreact-native-in-app-message: f91de5009620af01456531118264c93e249b83ec\nreact-native-keyboard-input: 83520632cab76a827bdf1db0aa1c87a047f7c18b\nreact-native-keyboard-tracking-view: bf1f758a529e1e87f8a76044414b168251d59d37\n+ react-native-mov-to-mp4: bfdafbd4ec9bd9290c779360810d1edae1f29310\nreact-native-netinfo: 6bb847e64f45a2d69c6173741111cfd95c669301\nreact-native-notifications: bb042206ac7eab9323d528c780b3d6fe796c1f5e\nreact-native-onepassword: 5b2b7f425f9db40932703e65d350b78cbc598047\n@@ -353,7 +369,7 @@ SPEC CHECKSUMS:\nRNCAsyncStorage: 60a80e72d95bf02a01cace55d3697d9724f0d77f\nRNExitApp: c4e052df2568b43bec8a37c7cd61194d4cfee2c3\nRNFastImage: 9b0c22643872bb7494c8d87bbbb66cc4c0d9e7a2\n- RNFS: a8fbe7060fa49157d819466404794ad9c58e58cf\n+ RNFS: 54da03c2b7d862c42ea3ca8c7f86f892760a535a\nRNGestureHandler: 4cb47a93019c1a201df2644413a0a1569a51c8aa\nRNKeychain: 45dbd50d1ac4bd42c3740f76ffb135abf05746d0\nRNReanimated: 6abbbae2e5e72609d85aabd92a982a94566885f1\n@@ -363,6 +379,6 @@ SPEC CHECKSUMS:\nSDWebImageWebPCoder: cc72085bb20368b2f8dbb21b7e355c667e1309b7\nyoga: 5079887aa3e4c62142d6bcee493022643ee4d730\n-PODFILE CHECKSUM: 7292900a639369e9530fcdd5b003e1b768d4dd0e\n+PODFILE CHECKSUM: f56c0719050ff0232b07034c3977cf1d83b78082\nCOCOAPODS: 1.7.5\n" }, { "change_type": "MODIFY", "old_path": "native/package.json", "new_path": "native/package.json", "diff": "\"react-native-dark-mode\": \"^0.2.0-rc.1\",\n\"react-native-exit-app\": \"^1.1.0\",\n\"react-native-fast-image\": \"^7.0.2\",\n+ \"react-native-ffmpeg\": \"^0.4.0\",\n\"react-native-firebase\": \"^5.5.6\",\n\"react-native-floating-action\": \"^1.19.1\",\n- \"react-native-fs\": \"^2.14.1\",\n+ \"react-native-fs\": \"2.15.2\",\n\"react-native-gesture-handler\": \"^1.4.1\",\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-message\": \"^1.0.2\",\n\"react-native-keyboard-input\": \"^5.3.1\",\n\"react-native-keychain\": \"^4.0.0\",\n+ \"react-native-mov-to-mp4\": \"git+https://git@github.com/taltultc/react-native-mov-to-mp4.git#d040c5aad736dd7a4bf1836836a1d62d6ab0d030\",\n\"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.6\",\n" }, { "change_type": "MODIFY", "old_path": "yarn.lock", "new_path": "yarn.lock", "diff": "@@ -10069,6 +10069,11 @@ react-native-fast-image@^7.0.2:\nresolved \"https://registry.yarnpkg.com/react-native-fast-image/-/react-native-fast-image-7.0.2.tgz#e06b21f42f4a9786eaa86f3db35d919070fb8403\"\nintegrity sha512-MfuzJbC0RjYobR2gFCdqe1I7jvNOCfDkjQ7VGOHXniqjohhULMkcWNBE9Umovi9Dx93lJ6t5utcE2wf/09zvlg==\n+react-native-ffmpeg@^0.4.0:\n+ version \"0.4.0\"\n+ resolved \"https://registry.yarnpkg.com/react-native-ffmpeg/-/react-native-ffmpeg-0.4.0.tgz#75bf061a189467c622aacc3b3e0669a2bc373f47\"\n+ integrity sha512-DRDXI5IkcPr7eZIpxwbCCuWPVmIHsO3k3yHSs9vojqFS1QRWokwRrQrkT49ZGQgo/PuUJOAlcZHhozA3i5D7nQ==\n+\nreact-native-firebase@^5.5.6:\nversion \"5.5.6\"\nresolved \"https://registry.yarnpkg.com/react-native-firebase/-/react-native-firebase-5.5.6.tgz#17b34ec0d5dc39afaaf0e159fd160f6339e0f707\"\n@@ -10082,13 +10087,13 @@ react-native-floating-action@^1.19.1:\nresolved \"https://registry.yarnpkg.com/react-native-floating-action/-/react-native-floating-action-1.19.1.tgz#fc3dcd0441ecbaf2d870b71f6db27f2db0f811b3\"\nintegrity sha512-6zgiCJyV63TOxpDKK+OxzhghMcBSn1Qhjb8p8TrfrUGAkzh7gQcmNN4ahq1CVbrN0ZpKhWET68WeifisYnQWyg==\n-react-native-fs@^2.14.1:\n- version \"2.14.1\"\n- resolved \"https://registry.yarnpkg.com/react-native-fs/-/react-native-fs-2.14.1.tgz#61c70a865b5b5bcb020dd4e4befd60a2c20c836f\"\n- integrity sha512-ZcfiwNP+FBgvv2eRk0B62/NI58mbjszjjYvQlP352HLkUqVsK4Ld6X8fdBO1lZAz6SgitUk8WEc9NEciRIt31g==\n+react-native-fs@2.15.2:\n+ version \"2.15.2\"\n+ resolved \"https://registry.yarnpkg.com/react-native-fs/-/react-native-fs-2.15.2.tgz#0bb8ff3c9c4778910677f36551b3494c661453f1\"\n+ integrity sha512-xZ0WS5nN1IfpPKO8LpbkRPnKzZrhx7us1B2ufDnt0k40pTIJsnoQno76y/2pYQbzhXmbi3330aI4km5+akxssg==\ndependencies:\nbase-64 \"^0.1.0\"\n- utf8 \"^2.1.1\"\n+ utf8 \"^3.0.0\"\nreact-native-gesture-handler@^1.4.1:\nversion \"1.4.1\"\n@@ -10135,6 +10140,10 @@ react-native-keychain@^4.0.0:\nresolved \"https://registry.yarnpkg.com/react-native-keychain/-/react-native-keychain-4.0.1.tgz#c332f5d9aaf597255ae6ea4ca7d5c84a24684a1d\"\nintegrity sha512-AqQp4Hib9y5DP5es5umEAhxKG7L0bA8cHNFhvlqs6oUcbUoKtXmhLDo3wzvnCF+bm8DXpGhvkU6P0LkfO0AgPQ==\n+\"react-native-mov-to-mp4@git+https://git@github.com/taltultc/react-native-mov-to-mp4.git#d040c5aad736dd7a4bf1836836a1d62d6ab0d030\":\n+ version \"0.2.2\"\n+ resolved \"git+https://git@github.com/taltultc/react-native-mov-to-mp4.git#d040c5aad736dd7a4bf1836836a1d62d6ab0d030\"\n+\n\"react-native-notifications@git+https://git@github.com/ashoat/react-native-notifications.git\":\nversion \"1.1.19\"\nresolved \"git+https://git@github.com/ashoat/react-native-notifications.git#6f741c582bcf19fd4151f2b18d48d55d3da157e9\"\n@@ -12430,10 +12439,10 @@ utf-8-validate@^5.0.2:\ndependencies:\nnode-gyp-build \"~3.7.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+utf8@^3.0.0:\n+ version \"3.0.0\"\n+ resolved \"https://registry.yarnpkg.com/utf8/-/utf8-3.0.0.tgz#f052eed1364d696e769ef058b183df88c87f69d1\"\n+ integrity sha512-E8VjFIQ/TyQgp+TZfS6l8yp/xWppSAHzidGiRrqe4bK4XP9pTRyKFgGJpO3SN7zdX4DeomTrwaseCHovfpFcqQ==\nutil-deprecate@^1.0.1, util-deprecate@~1.0.1:\nversion \"1.0.2\"\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Add native modules for video transcode
129,187
20.11.2019 15:20:54
18,000
2d1f79a3365b75aa66183249556926dcd45e6f9b
[native] Logic to transcode videos
[ { "change_type": "MODIFY", "old_path": "native/chat/chat-input-state-container.react.js", "new_path": "native/chat/chat-input-state-container.react.js", "diff": "@@ -40,8 +40,8 @@ import { ChatInputStateContext } from './chat-input-state';\nimport { validateMedia, convertMedia } from '../utils/media-utils';\nlet nextLocalUploadID = 0;\n-type ImageInfo = {|\n- ...$Exact<MediaValidationResult>,\n+type MediaInfo = {|\n+ validationResult: MediaValidationResult,\nlocalID: string,\n|};\ntype CompletedUploads = { [localMessageID: string]: ?Set<string> };\n@@ -260,23 +260,25 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\nconst validationResults = await Promise.all(\ninputImageInfos.map(validateMedia),\n);\n- const imageInfos = validationResults.filter(Boolean).map(imageInfo => ({\n- ...imageInfo,\n+ const mediaInfos = validationResults.filter(Boolean).map(\n+ validationResult => ({\n+ validationResult,\nlocalID: `localUpload${nextLocalUploadID++}`,\n- }));\n+ }),\n+ );\nconst localMessageID = `local${this.props.nextLocalID}`;\n- if (imageInfos.length < validationResults.length) {\n+ if (mediaInfos.length < validationResults.length) {\n// Since we filter our MIME types in our calls to CameraRoll,\n// this should never be triggered\nconsole.log('unexpected MIME type found');\n}\n- if (imageInfos.length === 0) {\n+ if (mediaInfos.length === 0) {\nreturn;\n}\nconst pendingUploads = {};\n- for (let { localID, uri } of imageInfos) {\n+ for (let { localID, validationResult: { uri } } of mediaInfos) {\npendingUploads[localID] = {\nfailed: null,\nprogressPercent: 0,\n@@ -304,8 +306,8 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\nthreadID,\ncreatorID,\ntime: Date.now(),\n- media: imageInfos.map(\n- ({ localID, uri, dimensions }) => ({\n+ media: mediaInfos.map(\n+ ({ localID, validationResult: { uri, dimensions } }) => ({\nid: localID,\nuri,\ntype: \"photo\",\n@@ -320,21 +322,21 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\n},\n);\n- await this.uploadFiles(localMessageID, imageInfos);\n+ await this.uploadFiles(localMessageID, mediaInfos);\n}\nuploadFiles(\nlocalMessageID: string,\n- imageInfos: $ReadOnlyArray<ImageInfo>,\n+ mediaInfos: $ReadOnlyArray<MediaInfo>,\n) {\nreturn Promise.all(\n- imageInfos.map(imageInfo => this.uploadFile(localMessageID, imageInfo)),\n+ mediaInfos.map(mediaInfo => this.uploadFile(localMessageID, mediaInfo)),\n);\n}\n- async uploadFile(localMessageID: string, imageInfo: ImageInfo) {\n- const { localID } = imageInfo;\n- const conversionResult = await convertMedia(imageInfo);\n+ async uploadFile(localMessageID: string, mediaInfo: MediaInfo) {\n+ const { localID, validationResult } = mediaInfo;\n+ const conversionResult = await convertMedia(validationResult);\nif (!conversionResult) {\nthis.handleUploadFailure(\nlocalMessageID,\n@@ -511,28 +513,28 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\nimageGalleryImages.map(validateMedia),\n);\n- const imageInfos = [];\n+ const mediaInfos = [];\nfor (let i = 0; i < validationResults.length; i++) {\nconst result = validationResults[i];\nif (!result) {\ncontinue;\n}\nconst { id } = retryMedia[i];\n- imageInfos.push({\n- ...result,\n+ mediaInfos.push({\n+ validationResult: result,\nlocalID: id,\n});\n}\n- if (imageInfos.length < validationResults.length) {\n+ if (mediaInfos.length < validationResults.length) {\n// Since we filter our MIME types in our calls to CameraRoll,\n// this should never be triggered\nconsole.log('unexpected MIME type found');\n}\n- if (imageInfos.length === 0) {\n+ if (mediaInfos.length === 0) {\nreturn;\n}\n- for (let { localID } of imageInfos) {\n+ for (let { localID } of mediaInfos) {\npendingUploads[localID] = {\nfailed: null,\nprogressPercent: 0,\n@@ -545,7 +547,7 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\n},\n}));\n- await this.uploadFiles(localMessageID, imageInfos);\n+ await this.uploadFiles(localMessageID, mediaInfos);\n}\nclearURI = async (uri: string) => {\n" }, { "change_type": "MODIFY", "old_path": "native/media/media-gallery-keyboard.react.js", "new_path": "native/media/media-gallery-keyboard.react.js", "diff": "@@ -23,7 +23,10 @@ import CameraRoll from '@react-native-community/cameraroll';\nimport PropTypes from 'prop-types';\nimport { connect } from 'lib/utils/redux-utils';\n-import { mimeTypesToMediaTypes } from 'lib/utils/file-utils';\n+import {\n+ mimeTypesToMediaTypes,\n+ extensionFromFilename,\n+} from 'lib/utils/file-utils';\nimport { store } from '../redux/redux-setup';\nimport {\n@@ -35,6 +38,7 @@ import Animated, { Easing } from 'react-native-reanimated';\nimport { colorsSelector, styleSelector } from '../themes/colors';\nimport { getAndroidPermission } from '../utils/android-permissions';\nimport SendMediaButton from './send-media-button.react';\n+import { getCompatibleMediaURI } from '../utils/media-utils';\nconst animationSpec = {\nduration: 400,\n@@ -203,6 +207,14 @@ class MediaGalleryKeyboard extends React.PureComponent<Props, State> {\nreturn base;\n}\n+ static compatibleURI(uri: string, filename: string) {\n+ const extension = extensionFromFilename(filename);\n+ if (!extension) {\n+ return uri;\n+ }\n+ return getCompatibleMediaURI(uri, extension);\n+ }\n+\nasync fetchPhotos(after?: ?string) {\nif (this.fetchingPhotos) {\nreturn;\n@@ -245,11 +257,14 @@ class MediaGalleryKeyboard extends React.PureComponent<Props, State> {\n(Platform.OS === \"android\" &&\nplayableDuration !== null && playableDuration !== undefined) ||\n(Platform.OS === \"ios\" && node.type === \"video\");\n+ const compatibleURI = isVideo\n+ ? MediaGalleryKeyboard.compatibleURI(uri, filename)\n+ : uri;\nreturn {\nheight,\nwidth,\ntype: isVideo ? \"video\" : \"photo\",\n- uri,\n+ uri: compatibleURI,\nfilename,\n};\n},\n" }, { "change_type": "MODIFY", "old_path": "native/media/media-gallery-media.react.js", "new_path": "native/media/media-gallery-media.react.js", "diff": "@@ -33,10 +33,6 @@ from 'react-native-reanimated';\nimport invariant from 'invariant';\nimport Video from 'react-native-video';\n-import { extensionFromFilename } from 'lib/utils/file-utils';\n-\n-import { getCompatibleMediaURI } from '../utils/media-utils';\n-\nexport type GalleryMediaInfo = {|\n...Dimensions,\ntype: MediaType,\n@@ -221,15 +217,6 @@ class MediaGalleryMedia extends React.PureComponent<Props> {\n}\n}\n- get compatibleURI() {\n- const { uri, filename } = this.props.mediaInfo;\n- const extension = extensionFromFilename(filename);\n- if (!extension) {\n- return uri;\n- }\n- return getCompatibleMediaURI(uri, extension);\n- }\n-\nrender() {\nconst { mediaInfo, containerHeight } = this.props;\nconst { uri, width, height, type } = mediaInfo;\n@@ -277,8 +264,8 @@ class MediaGalleryMedia extends React.PureComponent<Props> {\n}\nlet media;\n+ const source = { uri };\nif (type === \"video\") {\n- const source = { uri: this.compatibleURI };\nmedia = (\n<Reanimated.View style={this.videoContainerStyle}>\n<Video\n@@ -290,7 +277,6 @@ class MediaGalleryMedia extends React.PureComponent<Props> {\n</Reanimated.View>\n);\n} else {\n- const source = { uri };\nmedia = (\n<Reanimated.Image\nsource={source}\n" }, { "change_type": "MODIFY", "old_path": "native/utils/media-utils.js", "new_path": "native/utils/media-utils.js", "diff": "@@ -11,36 +11,50 @@ import {\nmimeTypesToMediaTypes,\n} from 'lib/utils/file-utils';\n+import { transcodeVideo } from './video-utils';\n+\ntype ReactNativeBlob =\n& Blob\n& { data: { type: string, name: string, size: number } };\n-export type MediaValidationResult = {\n+export type MediaValidationResult =\n+ | {|\n+ mediaType: \"photo\",\nuri: string,\ndimensions: Dimensions,\n- mediaType: MediaType,\nblob: ReactNativeBlob,\n-};\n+ |}\n+ | {|\n+ mediaType: \"video\",\n+ uri: string,\n+ dimensions: Dimensions,\n+ filename: string,\n+ |};\ntype ValidateMediaInput = {\nuri: string,\nheight: number,\nwidth: number,\ntype: MediaType,\n+ filename: string,\n...\n};\nasync function validateMedia(\n- imageInfo: ValidateMediaInput,\n+ mediaInfo: ValidateMediaInput,\n): Promise<?MediaValidationResult> {\n+ const { height, width, filename } = mediaInfo;\n+ const dimensions = { height, width };\n+ if (mediaInfo.type === \"video\") {\n+ return { mediaType: \"video\", uri: mediaInfo.uri, dimensions, filename };\n+ }\n+\n// React Native always resolves FBMediaKit's ph:// scheme as an image so that\n// the Image component can render thumbnails of videos. In order to force\n// fetch() to return a blob of the video, we need to use the ph-upload://\n// scheme. https://git.io/Jerlh\n- const fbMediaKitURL = imageInfo.uri.startsWith('ph://');\n- const uri = (fbMediaKitURL && imageInfo.type === \"video\")\n- ? imageInfo.uri.replace(/^ph:/, 'ph-upload:')\n- : imageInfo.uri;\n- const { height, width } = imageInfo;\n+ const fbMediaKitURL = mediaInfo.uri.startsWith('ph://');\n+ const uri = (fbMediaKitURL && mediaInfo.type === \"video\")\n+ ? mediaInfo.uri.replace(/^ph:/, 'ph-upload:')\n+ : mediaInfo.uri;\n- const dimensions = { height, width };\nconst response = await fetch(uri);\nconst blob = await response.blob();\nconst reportedMIME = (fbMediaKitURL && blob.type === \"application/octet-stream\")\n@@ -48,10 +62,10 @@ async function validateMedia(\n: blob.type;\nconst mediaType = mimeTypesToMediaTypes[reportedMIME];\n- if (!mediaType) {\n+ if (mediaType !== \"photo\") {\nreturn null;\n}\n- return { uri, dimensions, mediaType, blob };\n+ return { mediaType: \"photo\", uri, dimensions, blob };\n}\nfunction blobToDataURI(blob: Blob): Promise<string> {\n@@ -105,7 +119,7 @@ function getDimensions(uri: string): Promise<Dimensions> {\n});\n}\n-type MediaConversionResult = {|\n+export type MediaConversionResult = {|\nuploadURI: string,\nshouldDisposePath: ?string,\nname: string,\n@@ -117,6 +131,23 @@ async function convertMedia(\nvalidationResult: MediaValidationResult,\n): Promise<?MediaConversionResult> {\nconst { uri, dimensions } = validationResult;\n+ if (validationResult.mediaType === \"video\") {\n+ const result = await transcodeVideo(validationResult);\n+ if (!result) {\n+ return null;\n+ }\n+ const { uri: uploadURI, filename } = result.videoInfo;\n+ const shouldDisposePath = uri !== uploadURI ? uploadURI : null;\n+ return {\n+ uploadURI,\n+ shouldDisposePath,\n+ name: filename,\n+ mime: \"video/mp4\",\n+ mediaType: \"video\",\n+ dimensions,\n+ };\n+ }\n+\nlet { blob } = validationResult;\nconst { type: reportedMIME, size } = blob;\n@@ -158,18 +189,21 @@ async function convertMedia(\n}\nconst { name, mime, mediaType } = fileInfo;\n+ if (mediaType !== \"photo\") {\n+ return null;\n+ }\nreturn {\nuploadURI: Platform.OS === \"ios\" ? dataURI : uri,\nshouldDisposePath: null,\nname,\nmime,\n- mediaType,\n+ mediaType: \"photo\",\ndimensions,\n};\n}\nfunction getCompatibleMediaURI(uri: string, ext: string): string {\n- if (!uri.startsWith('ph://')) {\n+ if (!uri.startsWith('ph://') && !uri.startsWith('ph-upload://')) {\nreturn uri;\n}\nconst photoKitLocalIdentifier = uri.split('/')[2];\n" }, { "change_type": "ADD", "old_path": null, "new_path": "native/utils/video-utils.js", "diff": "+// @flow\n+\n+import filesystem from 'react-native-fs';\n+import { RNFFmpeg } from 'react-native-ffmpeg';\n+import { NativeModules, Platform } from 'react-native';\n+import invariant from 'invariant';\n+\n+import {\n+ pathFromURI,\n+ stripExtension,\n+ extensionFromFilename,\n+} from 'lib/utils/file-utils';\n+\n+const MovToMp4 = NativeModules.movToMp4;\n+\n+if (!__DEV__) {\n+ RNFFmpeg.disableLogs();\n+ RNFFmpeg.disableStatistics();\n+}\n+\n+type TranscodeVideoInfo = {\n+ uri: string,\n+ filename: string,\n+ ...\n+};\n+type TranscodeResult = $Shape<{|\n+ iosCopy: {| time: number |},\n+ initialProbe: {| time: number |},\n+ iosNativeTranscode: {| time: number, success: bool |},\n+ ffmpegTranscode: {| time: number, success: bool |},\n+|}>;\n+async function transcodeVideo<InputInfo: TranscodeVideoInfo>(\n+ input: InputInfo,\n+): Promise<?{| videoInfo: InputInfo, transcodeResult: TranscodeResult |}> {\n+ const transcodeResult: TranscodeResult = {}, createdPaths = [];\n+ let path = pathFromURI(input.uri), filename = input.filename;\n+ const finish = () => {\n+ for (let createdPath of createdPaths) {\n+ if (createdPath !== path) {\n+ filesystem.unlink(createdPath);\n+ }\n+ }\n+ if (!path) {\n+ return null;\n+ }\n+ return {\n+ videoInfo: { ...input, uri: `file://${path}`, filename },\n+ transcodeResult,\n+ };\n+ };\n+\n+ if (extensionFromFilename(filename) === 'mov') {\n+ // iOS uses the proprietary QuickTime container format (.mov),\n+ // which is generally compatible with .mp4\n+ filename = `${stripExtension(filename)}.mp4`;\n+ }\n+ if (Platform.OS === \"ios\" && !path) {\n+ // iOS uses custom URI schemes like ph, assets-library, and ph-upload\n+ // We need a filesystem path before we can continue\n+ const iosCopyPath =\n+ `${filesystem.TemporaryDirectoryPath}copy.${Date.now()}.${filename}`;\n+ const copyStart = Date.now();\n+ try {\n+ await filesystem.copyAssetsVideoIOS(input.uri, iosCopyPath);\n+ createdPaths.push(iosCopyPath);\n+ path = iosCopyPath;\n+ } catch (e) { }\n+ transcodeResult.iosCopy = { time: Date.now() - copyStart };\n+ }\n+ if (!path) {\n+ console.log(`could not extract path from ${input.uri}`);\n+ return finish();\n+ }\n+\n+ // Let's decide if we even need to do a transcoding step\n+ const {\n+ success: initialCheck,\n+ timing: initialCheckTiming,\n+ } = await checkVideoCodec(path);\n+ transcodeResult.initialProbe = { time: initialCheckTiming };\n+ if (initialCheck) {\n+ return finish();\n+ }\n+\n+ // Next, if we're on iOS we'll try using native libraries to transcode\n+ // We special-case iOS because Android doesn't usually need to transcode\n+ // iOS defaults to HEVC since iOS 11\n+ if (Platform.OS === \"ios\") {\n+ const iosNativeTranscodeStart = Date.now();\n+ let iosNativeTranscodeSuccess = false;\n+ try {\n+ const [ iosNativeTranscodedURI ] = await MovToMp4.convertMovToMp4(\n+ path,\n+ `iostranscode.${Date.now()}.${filename}`,\n+ );\n+ const iosNativeTranscodedPath = pathFromURI(iosNativeTranscodedURI);\n+ invariant(\n+ iosNativeTranscodedPath,\n+ \"react-native-mov-to-mp4 should return a file:/// uri, not \" +\n+ iosNativeTranscodedURI,\n+ );\n+ createdPaths.push(iosNativeTranscodedPath);\n+ const { success: iosCheck } = await checkVideoCodec(\n+ iosNativeTranscodedPath,\n+ );\n+ if (iosCheck) {\n+ path = iosNativeTranscodedPath;\n+ iosNativeTranscodeSuccess = true;\n+ }\n+ } catch (e) { }\n+ transcodeResult.iosNativeTranscode = {\n+ time: Date.now() - iosNativeTranscodeStart,\n+ success: iosNativeTranscodeSuccess,\n+ };\n+ if (iosNativeTranscodeSuccess) {\n+ return finish();\n+ }\n+ }\n+\n+ // This tells ffmpeg to use the hardware-accelerated encoders. Since we're\n+ // using the min-lts builds of react-native-ffmpeg we actually don't need\n+ // to specify this, but we would if we were using any build that provides\n+ // alternate encoders (for instance, min-gpl-lts)\n+ const codec = Platform.select({\n+ ios: 'h264_videotoolbox',\n+ android: 'h264_mediacodec',\n+ default: 'h264',\n+ });\n+ const ffmpegTranscodeStart = Date.now();\n+ let ffmpegTranscodeSuccess = false;\n+ const ffmpegTranscodedPath =\n+ `${filesystem.TemporaryDirectoryPath}transcode.${Date.now()}.${filename}`;\n+ try {\n+ const { rc } = await RNFFmpeg.execute(\n+ `-i ${path} -c:v ${codec} ${ffmpegTranscodedPath}`,\n+ );\n+ if (rc === 0) {\n+ createdPaths.push(ffmpegTranscodedPath);\n+ const { success: transcodeCheck } = await checkVideoCodec(\n+ ffmpegTranscodedPath,\n+ );\n+ if (transcodeCheck) {\n+ path = ffmpegTranscodedPath;\n+ ffmpegTranscodeSuccess = true;\n+ }\n+ }\n+ } catch (e) { }\n+ transcodeResult.ffmpegTranscode = {\n+ time: Date.now() - ffmpegTranscodeStart,\n+ success: ffmpegTranscodeSuccess,\n+ };\n+\n+ if (!ffmpegTranscodeSuccess) {\n+ console.log(\n+ `failed to transcode ${input.uri}, ` +\n+ `result: ${JSON.stringify(transcodeResult)}`,\n+ );\n+ path = null;\n+ }\n+\n+ return finish();\n+}\n+\n+type CheckCodecResult = {|\n+ success: bool,\n+ timing: number,\n+|};\n+async function checkVideoCodec(path: string) {\n+ const probeStart = Date.now();\n+ const ext = extensionFromFilename(path);\n+ let success = ext === \"mp4\" || ext === \"mov\";\n+ if (success) {\n+ const videoInfo = await RNFFmpeg.getMediaInformation(path);\n+ success = getVideoCodec(videoInfo) === \"h264\";\n+ }\n+ return { success, timing: Date.now() - probeStart };\n+}\n+\n+function getVideoCodec(info): ?string {\n+ if (!info.streams) {\n+ return null;\n+ }\n+ for (let stream of info.streams) {\n+ if (stream.type === \"video\") {\n+ return stream.codec;\n+ }\n+ }\n+ return null;\n+}\n+\n+export {\n+ transcodeVideo,\n+};\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Logic to transcode videos
129,187
20.11.2019 15:57:32
18,000
26dce5704b20ead3de3e9e2e73dd9af2abed6af3
createLocalMultimediaMessageActionType -> createLocalMessageActionType
[ { "change_type": "MODIFY", "old_path": "lib/actions/message-actions.js", "new_path": "lib/actions/message-actions.js", "diff": "@@ -76,8 +76,7 @@ async function sendTextMessage(\n};\n}\n-const createLocalMultimediaMessageActionType =\n- \"CREATE_LOCAL_MULTIMEDIA_MESSAGE\";\n+const createLocalMessageActionType = \"CREATE_LOCAL_MESSAGE\";\nconst sendMultimediaMessageActionTypes = Object.freeze({\nstarted: \"SEND_MULTIMEDIA_MESSAGE_STARTED\",\n@@ -111,7 +110,7 @@ export {\nfetchMostRecentMessages,\nsendTextMessageActionTypes,\nsendTextMessage,\n- createLocalMultimediaMessageActionType,\n+ createLocalMessageActionType,\nsendMultimediaMessageActionTypes,\nsendMultimediaMessage,\nsaveMessagesActionType,\n" }, { "change_type": "MODIFY", "old_path": "lib/reducers/local-id-reducer.js", "new_path": "lib/reducers/local-id-reducer.js", "diff": "@@ -12,7 +12,7 @@ import { rehydrateActionType } from '../types/redux-types';\nimport {\nsendTextMessageActionTypes,\nsendMultimediaMessageActionTypes,\n- createLocalMultimediaMessageActionType,\n+ createLocalMessageActionType,\n} from '../actions/message-actions';\nimport { createLocalEntryActionType } from '../actions/entry-actions';\n@@ -31,7 +31,7 @@ export default function reduceNextLocalID(state: number, action: BaseAction) {\naction.type === sendTextMessageActionTypes.started ||\naction.type === sendMultimediaMessageActionTypes.started ||\naction.type === createLocalEntryActionType ||\n- action.type === createLocalMultimediaMessageActionType\n+ action.type === createLocalMessageActionType\n) {\nconst { localID } = action.payload;\ninvariant(localID, \"should be set\");\n" }, { "change_type": "MODIFY", "old_path": "lib/reducers/message-reducer.js", "new_path": "lib/reducers/message-reducer.js", "diff": "@@ -73,7 +73,7 @@ import {\nsaveMessagesActionType,\nprocessMessagesActionType,\nmessageStorePruneActionType,\n- createLocalMultimediaMessageActionType,\n+ createLocalMessageActionType,\n} from '../actions/message-actions';\nimport threadWatcher from '../shared/thread-watcher';\nimport {\n@@ -811,7 +811,7 @@ function reduceMessageStore(\n},\n},\n};\n- } else if (action.type === createLocalMultimediaMessageActionType) {\n+ } else if (action.type === createLocalMessageActionType) {\nconst messageInfo = action.payload;\nreturn {\n...messageStore,\n" }, { "change_type": "MODIFY", "old_path": "lib/types/message-types.js", "new_path": "lib/types/message-types.js", "diff": "@@ -285,6 +285,12 @@ export type RawMessageInfo =\n| RawComposableMessageInfo\n| RawRobotextMessageInfo;\n+export type LocallyComposedMessageInfo = {\n+ localID: string,\n+ threadID: string,\n+ ...\n+};\n+\nexport type TextMessageInfo = {|\ntype: 0,\nid?: string, // null if local copy without ID yet\n" }, { "change_type": "MODIFY", "old_path": "lib/types/redux-types.js", "new_path": "lib/types/redux-types.js", "diff": "@@ -43,6 +43,7 @@ import type {\nSaveMessagesPayload,\nMessagesResultWithUserInfos,\nMessageStorePrunePayload,\n+ LocallyComposedMessageInfo,\n} from './message-types';\nimport type { SetSessionPayload } from './session-types';\nimport type {\n@@ -638,8 +639,8 @@ export type BaseAction =\ntype: \"UPDATE_MULTIMEDIA_MESSAGE_MEDIA\",\npayload: UpdateMultimediaMessageMediaPayload,\n|} | {|\n- type: \"CREATE_LOCAL_MULTIMEDIA_MESSAGE\",\n- payload: RawMultimediaMessageInfo,\n+ type: \"CREATE_LOCAL_MESSAGE\",\n+ payload: LocallyComposedMessageInfo,\n|};\nexport type ActionPayload\n" }, { "change_type": "MODIFY", "old_path": "native/chat/chat-input-bar.react.js", "new_path": "native/chat/chat-input-bar.react.js", "diff": "@@ -8,6 +8,7 @@ import type {\nimport {\ntype RawTextMessageInfo,\ntype SendMessageResult,\n+ type SendMessagePayload,\nmessageTypes,\n} from 'lib/types/message-types';\nimport {\n@@ -463,7 +464,9 @@ class ChatInputBar extends React.PureComponent<Props, State> {\n);\n}\n- async sendTextMessageAction(messageInfo: RawTextMessageInfo) {\n+ async sendTextMessageAction(\n+ messageInfo: RawTextMessageInfo,\n+ ): Promise<SendMessagePayload> {\ntry {\nconst { localID } = messageInfo;\ninvariant(\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": "@@ -15,6 +15,7 @@ import {\ntype RawMessageInfo,\ntype RawMultimediaMessageInfo,\ntype SendMessageResult,\n+ type SendMessagePayload,\n} from 'lib/types/message-types';\nimport type { MediaValidationResult } from '../utils/media-utils';\n@@ -30,7 +31,7 @@ import {\nupdateMultimediaMessageMediaActionType,\n} from 'lib/actions/upload-actions';\nimport {\n- createLocalMultimediaMessageActionType,\n+ createLocalMessageActionType,\nsendMultimediaMessageActionTypes,\nsendMultimediaMessage,\n} from 'lib/actions/message-actions';\n@@ -211,7 +212,9 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\n);\n}\n- async sendMultimediaMessageAction(messageInfo: RawMultimediaMessageInfo) {\n+ async sendMultimediaMessageAction(\n+ messageInfo: RawMultimediaMessageInfo,\n+ ): Promise<SendMessagePayload> {\nconst { localID, threadID, media } = messageInfo;\ninvariant(\nlocalID !== null && localID !== undefined,\n@@ -316,7 +319,7 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\n),\n}: RawMultimediaMessageInfo);\nthis.props.dispatchActionPayload(\n- createLocalMultimediaMessageActionType,\n+ createLocalMessageActionType,\nmessageInfo,\n);\n},\n" }, { "change_type": "MODIFY", "old_path": "native/chat/failed-send.react.js", "new_path": "native/chat/failed-send.react.js", "diff": "@@ -5,6 +5,7 @@ import { chatMessageItemPropType } from 'lib/selectors/chat-selectors';\nimport {\nmessageTypes,\ntype SendMessageResult,\n+ type SendMessagePayload,\ntype RawTextMessageInfo,\ntype RawMessageInfo,\n} from 'lib/types/message-types';\n@@ -107,7 +108,9 @@ class FailedSend extends React.PureComponent<Props> {\n}\n}\n- async sendTextMessageAction(messageInfo: RawTextMessageInfo) {\n+ async sendTextMessageAction(\n+ messageInfo: RawTextMessageInfo,\n+ ): Promise<SendMessagePayload> {\ntry {\nconst { localID } = messageInfo;\ninvariant(\n" }, { "change_type": "MODIFY", "old_path": "web/chat/chat-input-bar.react.js", "new_path": "web/chat/chat-input-bar.react.js", "diff": "@@ -18,6 +18,7 @@ import {\nimport {\ntype RawTextMessageInfo,\ntype SendMessageResult,\n+ type SendMessagePayload,\nmessageTypes,\n} from 'lib/types/message-types';\nimport {\n@@ -312,7 +313,9 @@ class ChatInputBar extends React.PureComponent<Props> {\n);\n}\n- async sendTextMessageAction(messageInfo: RawTextMessageInfo) {\n+ async sendTextMessageAction(\n+ messageInfo: RawTextMessageInfo,\n+ ): Promise<SendMessagePayload> {\ntry {\nconst { localID } = messageInfo;\ninvariant(\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": "@@ -12,6 +12,7 @@ import {\ntype RawMessageInfo,\ntype RawMultimediaMessageInfo,\ntype SendMessageResult,\n+ type SendMessagePayload,\n} from 'lib/types/message-types';\nimport * as React from 'react';\n@@ -33,7 +34,7 @@ import {\ndeleteUpload,\n} from 'lib/actions/upload-actions';\nimport {\n- createLocalMultimediaMessageActionType,\n+ createLocalMessageActionType,\nsendMultimediaMessageActionTypes,\nsendMultimediaMessage,\n} from 'lib/actions/message-actions';\n@@ -200,7 +201,7 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\nfor (let [ messageID, messageInfo ] of newMessageInfos) {\nthis.props.dispatchActionPayload(\n- createLocalMultimediaMessageActionType,\n+ createLocalMessageActionType,\nmessageInfo,\n);\n}\n@@ -230,7 +231,9 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\n);\n}\n- async sendMultimediaMessageAction(messageInfo: RawMultimediaMessageInfo) {\n+ async sendMultimediaMessageAction(\n+ messageInfo: RawMultimediaMessageInfo,\n+ ): Promise<SendMessagePayload> {\nconst { localID, threadID, media } = messageInfo;\ninvariant(\nlocalID !== null && localID !== undefined,\n" }, { "change_type": "MODIFY", "old_path": "web/chat/failed-send.react.js", "new_path": "web/chat/failed-send.react.js", "diff": "@@ -7,6 +7,7 @@ import {\nimport {\nmessageTypes,\ntype SendMessageResult,\n+ type SendMessagePayload,\ntype RawComposableMessageInfo,\ntype RawTextMessageInfo,\nassertComposableMessageType,\n@@ -96,7 +97,9 @@ class FailedSend extends React.PureComponent<Props> {\n}\n}\n- async sendTextMessageAction(messageInfo: RawTextMessageInfo) {\n+ async sendTextMessageAction(\n+ messageInfo: RawTextMessageInfo,\n+ ): Promise<SendMessagePayload> {\ntry {\nconst { localID } = messageInfo;\ninvariant(\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
createLocalMultimediaMessageActionType -> createLocalMessageActionType
129,187
20.11.2019 20:43:10
18,000
eb17a6a4a7d94239a998be152107ec573f4c99c5
[lib] Use "images" instead of "photos" in robotext
[ { "change_type": "MODIFY", "old_path": "lib/shared/media-utils.js", "new_path": "lib/shared/media-utils.js", "diff": "@@ -35,6 +35,9 @@ function contentStringForMediaArray(media: $ReadOnlyArray<Media>): string {\n}\n}\ninvariant(firstType, \"there should be some media\");\n+ if (firstType === \"photo\") {\n+ firstType = \"image\";\n+ }\nreturn `some ${firstType}s`;\n}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[lib] Use "images" instead of "photos" in robotext
129,187
20.11.2019 21:04:09
18,000
d19c04adb49e9676477d4a9433cdf84a90805670
MultimediaMessage -> ImagesMessage
[ { "change_type": "MODIFY", "old_path": "lib/types/message-types.js", "new_path": "lib/types/message-types.js", "diff": "@@ -216,7 +216,7 @@ type RestoreEntryMessageData = {|\ndate: string,\ntext: string,\n|};\n-export type MultimediaMessageData = {|\n+export type ImagesMessageData = {|\ntype: 14,\nlocalID?: string, // for optimistic creations. included by new clients\nthreadID: string,\n@@ -238,16 +238,21 @@ export type MessageData =\n| EditEntryMessageData\n| DeleteEntryMessageData\n| RestoreEntryMessageData\n- | MultimediaMessageData;\n+ | ImagesMessageData;\n+\n+export type MultimediaMessageData =\n+ | ImagesMessageData;\nexport type RawTextMessageInfo = {|\n...TextMessageData,\nid?: string, // null if local copy without ID yet\n|};\n-export type RawMultimediaMessageInfo = {|\n- ...MultimediaMessageData,\n+export type RawImagesMessageInfo = {|\n+ ...ImagesMessageData,\nid?: string, // null if local copy without ID yet\n|};\n+export type RawMultimediaMessageInfo =\n+ | RawImagesMessageInfo;\nexport type RawComposableMessageInfo =\n| RawTextMessageInfo\n| RawMultimediaMessageInfo;\n@@ -316,7 +321,7 @@ export type TextMessageInfo = {|\ntime: number, // millisecond timestamp\ntext: string,\n|};\n-export type MultimediaMessageInfo = {|\n+export type ImagesMessageInfo = {|\ntype: 14,\nid?: string, // null if local copy without ID yet\nlocalID?: string, // for optimistic creations\n@@ -325,6 +330,8 @@ export type MultimediaMessageInfo = {|\ntime: number, // millisecond timestamp\nmedia: $ReadOnlyArray<Media>,\n|};\n+export type MultimediaMessageInfo =\n+ | ImagesMessageInfo;\nexport type ComposableMessageInfo =\n| TextMessageInfo\n| MultimediaMessageInfo;\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
MultimediaMessage -> ImagesMessage
129,187
21.11.2019 16:54:49
18,000
c6578737656856ef7fc9f7c14e33cf4423241665
Introduce new MultimediaMessage types
[ { "change_type": "MODIFY", "old_path": "lib/reducers/message-reducer.js", "new_path": "lib/reducers/message-reducer.js", "diff": "@@ -7,6 +7,7 @@ import {\ntype MessageStore,\ntype MessageTruncationStatus,\ntype MessagesResponse,\n+ type RawImagesMessageInfo,\nmessageTruncationStatus,\nmessageTypes,\ndefaultNumberPerThread,\n@@ -173,25 +174,29 @@ function mergeNewMessages(\n// If the client already has a RawMessageInfo with this serverID, keep\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+ // component state. (The conditional below is for Flow)\nif (messageInfo.type === messageTypes.TEXT) {\nmessageInfo = {\n...messageInfo,\nlocalID: currentMessageInfo.localID,\n};\n- } else {\n- // This conditional is for Flow\n+ } else if (messageInfo.type === messageTypes.MULTIMEDIA) {\nmessageInfo = {\n...messageInfo,\nlocalID: currentMessageInfo.localID,\n};\n+ } else {\n+ messageInfo = ({\n+ ...messageInfo,\n+ localID: currentMessageInfo.localID,\n+ }: RawImagesMessageInfo);\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// success action never got processed. We set a key in\n// localIDsToServerIDs here to fix the messageIDs for the rest of the\n- // MessageStore too.\n+ // MessageStore too. (The conditional below is for Flow)\ninvariant(inputLocalID, \"should be set\");\nlocalIDsToServerIDs.set(inputLocalID, inputID);\nif (messageInfo.type === messageTypes.TEXT) {\n@@ -199,21 +204,29 @@ function mergeNewMessages(\n...messageInfo,\nlocalID: currentLocalMessageInfo.localID,\n};\n- } else {\n+ } else if (messageInfo.type === messageTypes.MULTIMEDIA) {\nmessageInfo = {\n...messageInfo,\nlocalID: currentLocalMessageInfo.localID,\n};\n+ } else {\n+ messageInfo = ({\n+ ...messageInfo,\n+ localID: currentLocalMessageInfo.localID,\n+ }: RawImagesMessageInfo);\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.\n+ // (The conditional below is for Flow)\nconst { localID, ...rest } = messageInfo;\nif (rest.type === messageTypes.TEXT) {\nmessageInfo = { ...rest };\n- } else {\n+ } else if (rest.type === messageTypes.MULTIMEDIA) {\nmessageInfo = { ...rest };\n+ } else {\n+ messageInfo = ({ ...rest }: RawImagesMessageInfo);\n}\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "lib/selectors/chat-selectors.js", "new_path": "lib/selectors/chat-selectors.js", "diff": "@@ -202,7 +202,8 @@ function createChatMessageItems(\n// be the source of truth\ninvariant(\nmessageInfo.type === messageTypes.TEXT ||\n- messageInfo.type === messageTypes.IMAGES,\n+ messageInfo.type === messageTypes.IMAGES ||\n+ messageInfo.type === messageTypes.MULTIMEDIA,\n\"Flow doesn't understand isComposableMessageType above\",\n);\nconst localMessageInfo = messageStore.local[messageKey(messageInfo)];\n@@ -217,7 +218,8 @@ function createChatMessageItems(\n} else {\ninvariant(\nmessageInfo.type !== messageTypes.TEXT &&\n- messageInfo.type !== messageTypes.IMAGES,\n+ messageInfo.type !== messageTypes.IMAGES &&\n+ messageInfo.type !== messageTypes.MULTIMEDIA,\n\"Flow doesn't understand isComposableMessageType above\",\n);\nconst robotext = robotextForMessageInfo(\n" }, { "change_type": "MODIFY", "old_path": "lib/shared/message-utils.js", "new_path": "lib/shared/message-utils.js", "diff": "@@ -6,11 +6,15 @@ import {\ntype RobotextMessageInfo,\ntype PreviewableMessageInfo,\ntype TextMessageInfo,\n- type MultimediaMessageInfo,\n+ type MediaMessageInfo,\n+ type ImagesMessageInfo,\ntype RawMultimediaMessageInfo,\ntype MessageData,\ntype MessageType,\ntype MessageTruncationStatus,\n+ type RawImagesMessageInfo,\n+ type RawMediaMessageInfo,\n+ type MultimediaMessageData,\nmessageTypes,\nmessageTruncationStatus,\n} from '../types/message-types';\n@@ -18,6 +22,7 @@ import type { RelativeUserInfo } from '../types/user-types';\nimport type { UserInfo } from '../types/user-types';\nimport type { ThreadInfo } from '../types/thread-types';\nimport type { PlatformDetails } from '../types/device-types';\n+import type { Media } from '../types/media-types';\nimport invariant from 'invariant';\nimport _maxBy from 'lodash/fp/maxBy';\n@@ -415,7 +420,7 @@ function createMessageInfo(\nunsupportedMessageInfo: rawMessageInfo.unsupportedMessageInfo,\n};\n} else if (rawMessageInfo.type === messageTypes.IMAGES) {\n- const messageInfo: MultimediaMessageInfo = {\n+ const messageInfo: ImagesMessageInfo = {\ntype: messageTypes.IMAGES,\nthreadID: rawMessageInfo.threadID,\ncreator: {\n@@ -433,6 +438,25 @@ function createMessageInfo(\nmessageInfo.localID = rawMessageInfo.localID;\n}\nreturn messageInfo;\n+ } else if (rawMessageInfo.type === messageTypes.MULTIMEDIA) {\n+ const messageInfo: MediaMessageInfo = {\n+ type: messageTypes.MULTIMEDIA,\n+ threadID: rawMessageInfo.threadID,\n+ creator: {\n+ id: rawMessageInfo.creatorID,\n+ username: creatorInfo.username,\n+ isViewer: rawMessageInfo.creatorID === viewerID,\n+ },\n+ time: rawMessageInfo.time,\n+ media: rawMessageInfo.media,\n+ };\n+ if (rawMessageInfo.id) {\n+ messageInfo.id = rawMessageInfo.id;\n+ }\n+ if (rawMessageInfo.localID) {\n+ messageInfo.localID = rawMessageInfo.localID;\n+ }\n+ return messageInfo;\n}\ninvariant(false, `we're not aware of messageType ${rawMessageInfo.type}`);\n}\n@@ -522,7 +546,9 @@ function rawMessageInfoFromMessageData(\ntext: messageData.text,\n};\n} else if (messageData.type === messageTypes.IMAGES) {\n- return { ...messageData, id };\n+ return ({ ...messageData, id }: RawImagesMessageInfo);\n+ } else if (messageData.type === messageTypes.MULTIMEDIA) {\n+ return ({ ...messageData, id }: RawMediaMessageInfo);\n} else {\ninvariant(false, `we're not aware of messageType ${messageData.type}`);\n}\n@@ -628,7 +654,10 @@ function messagePreviewText(\nmessageInfo: PreviewableMessageInfo,\nthreadInfo: ThreadInfo,\n): string {\n- if (messageInfo.type === messageTypes.IMAGES) {\n+ if (\n+ messageInfo.type === messageTypes.IMAGES ||\n+ messageInfo.type === messageTypes.MULTIMEDIA\n+ ) {\nconst creator = stringForUser(messageInfo.creator);\nconst preview = multimediaMessagePreview(messageInfo);\nreturn `${creator} ${preview}`;\n@@ -636,6 +665,68 @@ function messagePreviewText(\nreturn robotextToRawString(robotextForMessageInfo(messageInfo, threadInfo));\n}\n+type MultimediaMessageCreationInput = $ReadOnly<{\n+ localID: string,\n+ threadID: string,\n+ creatorID: string,\n+ media: $ReadOnlyArray<Media>,\n+ ...\n+}>;\n+function createMediaMessageData(\n+ { localID, threadID, creatorID, media }: MultimediaMessageCreationInput,\n+): MultimediaMessageData {\n+ let allMediaArePhotos = true;\n+ const photoMedia = [];\n+ for (let singleMedia of media) {\n+ if (singleMedia.type === \"video\") {\n+ allMediaArePhotos = false;\n+ break;\n+ } else {\n+ photoMedia.push(singleMedia);\n+ }\n+ }\n+\n+ if (allMediaArePhotos) {\n+ return {\n+ type: messageTypes.IMAGES,\n+ localID,\n+ threadID,\n+ creatorID,\n+ time: Date.now(),\n+ media: photoMedia,\n+ };\n+ } else {\n+ return {\n+ type: messageTypes.MULTIMEDIA,\n+ localID,\n+ threadID,\n+ creatorID,\n+ time: Date.now(),\n+ media,\n+ };\n+ }\n+}\n+\n+function createMediaMessageInfo(\n+ input: MultimediaMessageCreationInput,\n+): RawMultimediaMessageInfo {\n+ const messageData = createMediaMessageData(input);\n+ // This conditional is for Flow\n+ if (messageData.type === messageTypes.IMAGES) {\n+ return ({\n+ ...messageData,\n+ type: messageTypes.IMAGES,\n+ id: undefined,\n+ }: RawImagesMessageInfo);\n+ } else {\n+ return ({\n+ ...messageData,\n+ type: messageTypes.MULTIMEDIA,\n+ id: undefined,\n+ }: RawMediaMessageInfo);\n+ }\n+}\n+\nexport {\nmessageKey,\nmessageID,\n@@ -652,4 +743,6 @@ export {\ncombineTruncationStatuses,\nshimUnsupportedRawMessageInfos,\nmessagePreviewText,\n+ createMediaMessageData,\n+ createMediaMessageInfo,\n};\n" }, { "change_type": "MODIFY", "old_path": "lib/types/media-types.js", "new_path": "lib/types/media-types.js", "diff": "@@ -14,13 +14,24 @@ export const dimensionsPropType = PropTypes.shape({\nexport type MediaType = \"photo\" | \"video\";\n-export type Media = {|\n+export type Image = {|\nid: string,\nuri: string,\n- type: MediaType,\n+ type: \"photo\",\ndimensions: Dimensions,\n|};\n+export type Video = {|\n+ id: string,\n+ uri: string,\n+ type: \"video\",\n+ dimensions: Dimensions,\n+|};\n+\n+export type Media =\n+ | Image\n+ | Video;\n+\nexport type Corners = $Shape<{|\ntopLeft: bool,\ntopRight: bool,\n@@ -28,8 +39,14 @@ export type Corners = $Shape<{|\nbottomRight: bool,\n|}>;\n-export type MediaInfo = {|\n- ...Media,\n+export type MediaInfo =\n+ | {|\n+ ...Image,\n+ corners: Corners,\n+ index: number,\n+ |}\n+ | {|\n+ ...Video,\ncorners: Corners,\nindex: number,\n|};\n" }, { "change_type": "MODIFY", "old_path": "lib/types/message-types.js", "new_path": "lib/types/message-types.js", "diff": "@@ -12,7 +12,7 @@ import {\ntype UserInfo,\ntype UserInfos,\n} from './user-types';\n-import { type Media, mediaPropType } from './media-types';\n+import { type Media, type Image, mediaPropType } from './media-types';\nimport invariant from 'invariant';\nimport PropTypes from 'prop-types';\n@@ -38,6 +38,7 @@ export const messageTypes = Object.freeze({\n// converting these MessageInfos when the client is upgraded.\nUNSUPPORTED: 13,\nIMAGES: 14,\n+ MULTIMEDIA: 15,\n});\nexport type MessageType = $Values<typeof messageTypes>;\nexport function assertMessageType(\n@@ -58,7 +59,8 @@ export function assertMessageType(\nourMessageType === 11 ||\nourMessageType === 12 ||\nourMessageType === 13 ||\n- ourMessageType === 14,\n+ ourMessageType === 14 ||\n+ ourMessageType === 15,\n\"number is not MessageType enum\",\n);\nreturn ourMessageType;\n@@ -67,6 +69,7 @@ export function assertMessageType(\nconst composableMessageTypes = new Set([\nmessageTypes.TEXT,\nmessageTypes.IMAGES,\n+ messageTypes.MULTIMEDIA,\n]);\nexport function isComposableMessageType(ourMessageType: MessageType): bool {\nreturn composableMessageTypes.has(ourMessageType);\n@@ -83,7 +86,8 @@ export function assertComposableMessageType(\nexport function messageDataLocalID(messageData: MessageData) {\nif (\nmessageData.type !== messageTypes.TEXT &&\n- messageData.type !== messageTypes.IMAGES\n+ messageData.type !== messageTypes.IMAGES &&\n+ messageData.type !== messageTypes.MULTIMEDIA\n) {\nreturn null;\n}\n@@ -92,6 +96,7 @@ export function messageDataLocalID(messageData: MessageData) {\nconst mediaMessageTypes = new Set([\nmessageTypes.IMAGES,\n+ messageTypes.MULTIMEDIA,\n]);\nexport function isMediaMessageType(ourMessageType: MessageType): bool {\nreturn mediaMessageTypes.has(ourMessageType);\n@@ -222,6 +227,14 @@ export type ImagesMessageData = {|\nthreadID: string,\ncreatorID: string,\ntime: number,\n+ media: $ReadOnlyArray<Image>,\n+|};\n+export type MediaMessageData = {|\n+ type: 15,\n+ localID?: string, // for optimistic creations. included by new clients\n+ threadID: string,\n+ creatorID: string,\n+ time: number,\nmedia: $ReadOnlyArray<Media>,\n|};\nexport type MessageData =\n@@ -238,10 +251,12 @@ export type MessageData =\n| EditEntryMessageData\n| DeleteEntryMessageData\n| RestoreEntryMessageData\n- | ImagesMessageData;\n+ | ImagesMessageData\n+ | MediaMessageData;\nexport type MultimediaMessageData =\n- | ImagesMessageData;\n+ | ImagesMessageData\n+ | MediaMessageData;\nexport type RawTextMessageInfo = {|\n...TextMessageData,\n@@ -251,8 +266,13 @@ export type RawImagesMessageInfo = {|\n...ImagesMessageData,\nid?: string, // null if local copy without ID yet\n|};\n+export type RawMediaMessageInfo = {|\n+ ...MediaMessageData,\n+ id?: string, // null if local copy without ID yet\n+|};\nexport type RawMultimediaMessageInfo =\n- | RawImagesMessageInfo;\n+ | RawImagesMessageInfo\n+ | RawMediaMessageInfo;\nexport type RawComposableMessageInfo =\n| RawTextMessageInfo\n| RawMultimediaMessageInfo;\n@@ -328,10 +348,20 @@ export type ImagesMessageInfo = {|\nthreadID: string,\ncreator: RelativeUserInfo,\ntime: number, // millisecond timestamp\n+ media: $ReadOnlyArray<Image>,\n+|};\n+export type MediaMessageInfo = {|\n+ type: 15,\n+ id?: string, // null if local copy without ID yet\n+ localID?: string, // for optimistic creations\n+ threadID: string,\n+ creator: RelativeUserInfo,\n+ time: number, // millisecond timestamp\nmedia: $ReadOnlyArray<Media>,\n|};\nexport type MultimediaMessageInfo =\n- | ImagesMessageInfo;\n+ | ImagesMessageInfo\n+ | MediaMessageInfo;\nexport type ComposableMessageInfo =\n| TextMessageInfo\n| MultimediaMessageInfo;\n@@ -592,6 +622,15 @@ export const messageInfoPropType = PropTypes.oneOfType([\ntime: PropTypes.number.isRequired,\nmedia: PropTypes.arrayOf(mediaPropType).isRequired,\n}),\n+ PropTypes.shape({\n+ type: PropTypes.oneOf([ messageTypes.MULTIMEDIA ]).isRequired,\n+ id: PropTypes.string,\n+ localID: PropTypes.string,\n+ threadID: PropTypes.string.isRequired,\n+ creator: relativeUserInfoPropType.isRequired,\n+ time: PropTypes.number.isRequired,\n+ media: PropTypes.arrayOf(mediaPropType).isRequired,\n+ }),\n]);\nexport type ThreadMessageInfo = {|\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": "@@ -16,6 +16,8 @@ import {\ntype RawMultimediaMessageInfo,\ntype SendMessageResult,\ntype SendMessagePayload,\n+ type RawImagesMessageInfo,\n+ type RawMediaMessageInfo,\n} from 'lib/types/message-types';\nimport type { MediaValidationResult } from '../utils/media-utils';\n@@ -36,6 +38,7 @@ import {\nsendMultimediaMessage,\n} from 'lib/actions/message-actions';\nimport { pathFromURI } from 'lib/utils/file-utils';\n+import { createMediaMessageInfo } from 'lib/shared/message-utils';\nimport { ChatInputStateContext } from './chat-input-state';\nimport { validateMedia, convertMedia } from '../utils/media-utils';\n@@ -215,16 +218,20 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\nasync sendMultimediaMessageAction(\nmessageInfo: RawMultimediaMessageInfo,\n): Promise<SendMessagePayload> {\n- const { localID, threadID, media } = messageInfo;\n+ const { localID, threadID } = messageInfo;\ninvariant(\nlocalID !== null && localID !== undefined,\n\"localID should be set\",\n);\n+ const mediaIDs = [];\n+ for (let { id } of messageInfo.media) {\n+ mediaIDs.push(id);\n+ }\ntry {\nconst result = await this.props.sendMultimediaMessage(\nthreadID,\nlocalID,\n- media.map(({ id }) => id),\n+ mediaIDs,\n);\nreturn {\nlocalID,\n@@ -303,21 +310,32 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\n() => {\nconst creatorID = this.props.viewerID;\ninvariant(creatorID, \"need viewer ID in order to send a message\");\n- const messageInfo = ({\n- type: messageTypes.IMAGES,\n- localID: localMessageID,\n- threadID,\n- creatorID,\n- time: Date.now(),\n- media: mediaInfos.map(\n- ({ localID, validationResult: { uri, dimensions } }) => ({\n+ const media = mediaInfos.map(\n+ ({ localID, validationResult: { uri, dimensions, mediaType } }) => {\n+ // This conditional is for Flow\n+ if (mediaType === \"photo\") {\n+ return {\nid: localID,\nuri,\ntype: \"photo\",\ndimensions,\n- }),\n- ),\n- }: RawMultimediaMessageInfo);\n+ };\n+ } else {\n+ return {\n+ id: localID,\n+ uri,\n+ type: \"video\",\n+ dimensions,\n+ };\n+ }\n+ },\n+ );\n+ const messageInfo = createMediaMessageInfo({\n+ localID: localMessageID,\n+ threadID,\n+ creatorID,\n+ media,\n+ });\nthis.props.dispatchActionPayload(\ncreateLocalMessageActionType,\nmessageInfo,\n@@ -470,14 +488,34 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\nretryMultimediaMessage = async (localMessageID: string) => {\nconst rawMessageInfo = this.props.messageStoreMessages[localMessageID];\ninvariant(\n- rawMessageInfo && rawMessageInfo.type === messageTypes.IMAGES,\n- \"messageStore should contain entry for message being retried\",\n+ rawMessageInfo,\n+ `rawMessageInfo ${localMessageID} should exist`,\n);\n- const newRawMessageInfo = { ...rawMessageInfo, time: Date.now() };\n-\n- const incompleteMedia = rawMessageInfo.media.filter(\n- ({ id }) => id.startsWith('localUpload'),\n+ let newRawMessageInfo;\n+ // This conditional is for Flow\n+ if (rawMessageInfo.type === messageTypes.MULTIMEDIA) {\n+ newRawMessageInfo = ({\n+ ...rawMessageInfo,\n+ time: Date.now(),\n+ }: RawMediaMessageInfo);\n+ } else if (rawMessageInfo.type === messageTypes.IMAGES) {\n+ newRawMessageInfo = ({\n+ ...rawMessageInfo,\n+ time: Date.now(),\n+ }: RawImagesMessageInfo);\n+ } else {\n+ invariant(\n+ false,\n+ `rawMessageInfo ${localMessageID} should be multimedia`,\n);\n+ }\n+\n+ const incompleteMedia = [];\n+ for (let singleMedia of newRawMessageInfo.media) {\n+ if (singleMedia.id.startsWith('localUpload')) {\n+ incompleteMedia.push(singleMedia);\n+ }\n+ }\nif (incompleteMedia.length === 0) {\nthis.dispatchMultimediaMessageAction(newRawMessageInfo);\nthis.setState(prevState => ({\n" }, { "change_type": "MODIFY", "old_path": "native/chat/message-list-container.react.js", "new_path": "native/chat/message-list-container.react.js", "diff": "@@ -263,7 +263,10 @@ class MessageListContainer extends React.PureComponent<Props, State> {\n}\nconst { messageInfo } = item;\nconst key = messageKey(messageInfo);\n- if (messageInfo.type === messageTypes.IMAGES) {\n+ if (\n+ messageInfo.type === messageTypes.IMAGES ||\n+ messageInfo.type === messageTypes.MULTIMEDIA\n+ ) {\n// Conditional due to Flow...\nconst localMessageInfo = item.localMessageInfo\n? item.localMessageInfo\n" }, { "change_type": "MODIFY", "old_path": "native/media/save-image.js", "new_path": "native/media/save-image.js", "diff": "@@ -13,9 +13,15 @@ import { blobToDataURI, dataURIToIntArray } from '../utils/media-utils';\nimport { displayActionResultModal } from '../navigation/action-result-modal';\nimport { getAndroidPermission } from '../utils/android-permissions';\n-type SaveImageInfo = {\n+type SaveImageInfo =\n+ | {\n+ type: \"photo\",\n+ uri: string,\n+ ...\n+ }\n+ | {\n+ type: \"video\",\nuri: string,\n- type: MediaType,\n...\n};\n" }, { "change_type": "MODIFY", "old_path": "server/src/responders/message-responders.js", "new_path": "server/src/responders/message-responders.js", "diff": "@@ -18,6 +18,7 @@ import invariant from 'invariant';\nimport { ServerError } from 'lib/utils/errors';\nimport { threadPermissions } from 'lib/types/thread-types';\n+import { createMediaMessageData } from 'lib/shared/message-utils';\nimport createMessages from '../creators/message-creator';\nimport { validateInput, tShape } from '../utils/validation-utils';\n@@ -121,14 +122,12 @@ async function multimediaMessageCreationResponder(\nthrow new ServerError('invalid_parameters');\n}\n- const messageData = {\n- type: messageTypes.IMAGES,\n+ const messageData = createMediaMessageData({\nlocalID,\nthreadID,\ncreatorID: viewer.id,\n- time: Date.now(),\nmedia,\n- };\n+ });\nconst [ newMessageInfo ] = await createMessages(viewer, [messageData]);\nconst { id } = newMessageInfo;\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": "@@ -10,6 +10,8 @@ import type { PendingMultimediaUpload } from './chat-input-state';\nimport {\nmessageTypes,\ntype RawMessageInfo,\n+ type RawImagesMessageInfo,\n+ type RawMediaMessageInfo,\ntype RawMultimediaMessageInfo,\ntype SendMessageResult,\ntype SendMessagePayload,\n@@ -38,6 +40,7 @@ import {\nsendMultimediaMessageActionTypes,\nsendMultimediaMessage,\n} from 'lib/actions/message-actions';\n+import { createMediaMessageInfo } from 'lib/shared/message-utils';\nimport ChatMessageList from './chat-message-list.react';\nimport { validateFile, preloadImage } from '../utils/media-utils';\n@@ -164,21 +167,32 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\nconst { uploads, threadID } = assignedUploads;\nconst creatorID = this.props.viewerID;\ninvariant(creatorID, \"need viewer ID in order to send a message\");\n- const messageInfo = ({\n- type: messageTypes.IMAGES,\n- localID: messageID,\n- threadID,\n- creatorID,\n- time: Date.now(),\n- media: uploads.map(\n- ({ localID, serverID, uri, mediaType, dimensions }) => ({\n+ const media = uploads.map(\n+ ({ localID, serverID, uri, mediaType, dimensions }) => {\n+ // This conditional is for Flow\n+ if (mediaType === \"photo\") {\n+ return {\nid: serverID ? serverID : localID,\nuri,\n- type: mediaType,\n+ type: \"photo\",\ndimensions,\n- }),\n- ),\n- }: RawMultimediaMessageInfo);\n+ };\n+ } else {\n+ return {\n+ id: serverID ? serverID : localID,\n+ uri,\n+ type: \"video\",\n+ dimensions,\n+ };\n+ }\n+ },\n+ );\n+ const messageInfo = createMediaMessageInfo({\n+ localID: messageID,\n+ threadID,\n+ creatorID,\n+ media,\n+ });\nnewMessageInfos.set(messageID, messageInfo);\n}\n@@ -216,8 +230,9 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\n`rawMessageInfo ${localMessageID} should exist`,\n);\ninvariant(\n- rawMessageInfo.type === messageTypes.IMAGES,\n- `rawMessageInfo ${localMessageID} should be messageTypes.IMAGES`,\n+ rawMessageInfo.type === messageTypes.IMAGES ||\n+ rawMessageInfo.type === messageTypes.MULTIMEDIA,\n+ `rawMessageInfo ${localMessageID} should be multimedia`,\n);\nreturn rawMessageInfo;\n}\n@@ -234,16 +249,20 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\nasync sendMultimediaMessageAction(\nmessageInfo: RawMultimediaMessageInfo,\n): Promise<SendMessagePayload> {\n- const { localID, threadID, media } = messageInfo;\n+ const { localID, threadID } = messageInfo;\ninvariant(\nlocalID !== null && localID !== undefined,\n\"localID should be set\",\n);\n+ const mediaIDs = [];\n+ for (let { id } of messageInfo.media) {\n+ mediaIDs.push(id);\n+ }\ntry {\nconst result = await this.props.sendMultimediaMessage(\nthreadID,\nlocalID,\n- media.map(({ id }) => id),\n+ mediaIDs,\n);\nthis.setState(prevState => {\nconst prevUploads = prevState.pendingUploads[threadID];\n@@ -700,7 +719,19 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\npendingUploads: ?$ReadOnlyArray<PendingMultimediaUpload>,\n) {\nconst rawMessageInfo = this.getRawMultimediaMessageInfo(localMessageID);\n- const newRawMessageInfo = { ...rawMessageInfo, time: Date.now() };\n+ let newRawMessageInfo;\n+ // This conditional is for Flow\n+ if (rawMessageInfo.type === messageTypes.MULTIMEDIA) {\n+ newRawMessageInfo = ({\n+ ...rawMessageInfo,\n+ time: Date.now(),\n+ }: RawMediaMessageInfo);\n+ } else {\n+ newRawMessageInfo = ({\n+ ...rawMessageInfo,\n+ time: Date.now(),\n+ }: RawImagesMessageInfo);\n+ }\nconst completed = ChatInputStateContainer.completedMessageIDs(this.state);\nif (completed.has(localMessageID)) {\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Introduce new MultimediaMessage types
129,187
21.11.2019 17:32:20
18,000
8c0d6ef87fdb6df01059f7156c9f8c4ac98a5b15
Store video filename in MessageStore on native for retries
[ { "change_type": "MODIFY", "old_path": "lib/types/media-types.js", "new_path": "lib/types/media-types.js", "diff": "@@ -26,6 +26,8 @@ export type Video = {|\nuri: string,\ntype: \"video\",\ndimensions: Dimensions,\n+ // stored on native only during creation in case retry needed after state lost\n+ filename?: string,\n|};\nexport type Media =\n@@ -58,6 +60,7 @@ const mediaPropTypes = {\nuri: PropTypes.string.isRequired,\ntype: mediaTypePropType.isRequired,\ndimensions: dimensionsPropType.isRequired,\n+ filename: PropTypes.string,\n};\nexport const mediaPropType = PropTypes.shape(mediaPropTypes);\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": "@@ -311,9 +311,10 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\nconst creatorID = this.props.viewerID;\ninvariant(creatorID, \"need viewer ID in order to send a message\");\nconst media = mediaInfos.map(\n- ({ localID, validationResult: { uri, dimensions, mediaType } }) => {\n+ ({ localID, validationResult }) => {\n// This conditional is for Flow\n- if (mediaType === \"photo\") {\n+ if (validationResult.mediaType === \"photo\") {\n+ const { uri, dimensions, mediaType } = validationResult;\nreturn {\nid: localID,\nuri,\n@@ -321,11 +322,13 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\ndimensions,\n};\n} else {\n+ const { uri, dimensions, mediaType, filename } = validationResult;\nreturn {\nid: localID,\nuri,\ntype: \"video\",\ndimensions,\n+ filename,\n};\n}\n},\n@@ -398,6 +401,7 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\nuri: result.uri,\ntype: mediaType,\ndimensions: conversionResult.dimensions,\n+ filename: undefined,\n},\n},\n);\n@@ -547,9 +551,15 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\nnewRawMessageInfo,\n);\n- const imageGalleryImages = retryMedia.map(\n- ({ dimensions, uri, type }) => ({ ...dimensions, uri, type }),\n- );\n+ const imageGalleryImages = retryMedia.map(singleMedia => {\n+ if (singleMedia.type === \"photo\") {\n+ const { dimensions, uri } = singleMedia;\n+ return { type: \"photo\", ...dimensions, uri };\n+ } else {\n+ const { dimensions, uri, filename } = singleMedia;\n+ return { type: \"video\", ...dimensions, uri, filename };\n+ }\n+ });\nconst validationResults = await Promise.all(\nimageGalleryImages.map(validateMedia),\n);\n" }, { "change_type": "MODIFY", "old_path": "native/media/camera-modal.react.js", "new_path": "native/media/camera-modal.react.js", "diff": "@@ -954,7 +954,6 @@ class CameraModal extends React.PureComponent<Props, State> {\nconst pendingImageInfo = {\nuri,\n- filename,\nwidth,\nheight,\ntype: \"photo\",\n" }, { "change_type": "MODIFY", "old_path": "native/media/media-gallery-keyboard.react.js", "new_path": "native/media/media-gallery-keyboard.react.js", "diff": "@@ -260,13 +260,22 @@ class MediaGalleryKeyboard extends React.PureComponent<Props, State> {\nconst compatibleURI = isVideo\n? MediaGalleryKeyboard.compatibleURI(uri, filename)\n: uri;\n+ if (isVideo) {\nreturn {\n+ type: \"video\",\nheight,\nwidth,\n- type: isVideo ? \"video\" : \"photo\",\nuri: compatibleURI,\nfilename,\n};\n+ } else {\n+ return {\n+ type: \"photo\",\n+ height,\n+ width,\n+ uri: compatibleURI,\n+ };\n+ }\n},\n).filter(Boolean);\n" }, { "change_type": "MODIFY", "old_path": "native/media/media-gallery-media.react.js", "new_path": "native/media/media-gallery-media.react.js", "diff": "@@ -33,10 +33,18 @@ from 'react-native-reanimated';\nimport invariant from 'invariant';\nimport Video from 'react-native-video';\n-export type GalleryMediaInfo = {|\n- ...Dimensions,\n- type: MediaType,\n+export type GalleryMediaInfo =\n+ | {|\n+ type: \"photo\",\nuri: string,\n+ height: number,\n+ width: number,\n+ |}\n+ | {|\n+ type: \"video\",\n+ uri: string,\n+ height: number,\n+ width: number,\nfilename: string,\n|};\nconst animatedSpec = {\n" }, { "change_type": "MODIFY", "old_path": "native/utils/media-utils.js", "new_path": "native/utils/media-utils.js", "diff": "@@ -5,6 +5,7 @@ import type { Dimensions, MediaType } from 'lib/types/media-types';\nimport { Platform, Image } from 'react-native';\nimport base64 from 'base-64';\nimport ImageResizer from 'react-native-image-resizer';\n+import invariant from 'invariant';\nimport {\nfileInfoFromData,\n@@ -29,20 +30,29 @@ export type MediaValidationResult =\ndimensions: Dimensions,\nfilename: string,\n|};\n-type ValidateMediaInput = {\n+type ValidateMediaInput =\n+ | {\n+ type: \"photo\",\n+ uri: string,\n+ height: number,\n+ width: number,\n+ ...\n+ }\n+ | {\n+ type: \"video\",\nuri: string,\nheight: number,\nwidth: number,\n- type: MediaType,\nfilename: string,\n...\n};\nasync function validateMedia(\nmediaInfo: ValidateMediaInput,\n): Promise<?MediaValidationResult> {\n- const { height, width, filename } = mediaInfo;\n+ const { height, width } = mediaInfo;\nconst dimensions = { height, width };\nif (mediaInfo.type === \"video\") {\n+ const { filename } = mediaInfo;\nreturn { mediaType: \"video\", uri: mediaInfo.uri, dimensions, filename };\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": "@@ -440,6 +440,7 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\ncurrentMediaID: upload.localID,\nmediaUpdate: {\nid: result.id,\n+ filename: undefined,\n},\n},\n);\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Store video filename in MessageStore on native for retries
129,187
22.11.2019 19:10:34
18,000
6ad865270ba30f5b0d46aeb046e676ae4933fbb7
Add server support for new messageTypes.MULTIMEDIA
[ { "change_type": "MODIFY", "old_path": "lib/shared/message-utils.js", "new_path": "lib/shared/message-utils.js", "diff": "@@ -15,6 +15,8 @@ import {\ntype RawImagesMessageInfo,\ntype RawMediaMessageInfo,\ntype MultimediaMessageData,\n+ type MediaMessageData,\n+ type ImagesMessageData,\nmessageTypes,\nmessageTruncationStatus,\n} from '../types/message-types';\n@@ -665,19 +667,20 @@ function messagePreviewText(\nreturn robotextToRawString(robotextForMessageInfo(messageInfo, threadInfo));\n}\n-type MultimediaMessageCreationInput = $ReadOnly<{\n- localID: string,\n+type MediaMessageDataCreationInput = $ReadOnly<{\nthreadID: string,\ncreatorID: string,\nmedia: $ReadOnlyArray<Media>,\n+ localID?: ?string,\n+ time?: ?number,\n...\n}>;\nfunction createMediaMessageData(\n- { localID, threadID, creatorID, media }: MultimediaMessageCreationInput,\n+ input: MediaMessageDataCreationInput,\n): MultimediaMessageData {\nlet allMediaArePhotos = true;\nconst photoMedia = [];\n- for (let singleMedia of media) {\n+ for (let singleMedia of input.media) {\nif (singleMedia.type === \"video\") {\nallMediaArePhotos = false;\nbreak;\n@@ -686,45 +689,57 @@ function createMediaMessageData(\n}\n}\n+ const { localID, threadID, creatorID } = input;\n+ const time = input.time ? input.time : Date.now();\n+ let messageData;\nif (allMediaArePhotos) {\n- return {\n+ messageData = ({\ntype: messageTypes.IMAGES,\n- localID,\nthreadID,\ncreatorID,\n- time: Date.now(),\n+ time,\nmedia: photoMedia,\n- };\n+ }: ImagesMessageData);\n} else {\n- return {\n+ messageData = ({\ntype: messageTypes.MULTIMEDIA,\n- localID,\nthreadID,\ncreatorID,\n- time: Date.now(),\n- media,\n- };\n+ time,\n+ media: input.media,\n+ }: MediaMessageData);\n}\n+ if (localID) {\n+ messageData.localID = localID;\n+ }\n+ return messageData;\n}\n+type MediaMessageInfoCreationInput = $ReadOnly<{\n+ ...$Exact<MediaMessageDataCreationInput>,\n+ id?: ?string,\n+}>;\nfunction createMediaMessageInfo(\n- input: MultimediaMessageCreationInput,\n+ input: MediaMessageInfoCreationInput,\n): RawMultimediaMessageInfo {\nconst messageData = createMediaMessageData(input);\n// This conditional is for Flow\n+ let rawMessageInfo;\nif (messageData.type === messageTypes.IMAGES) {\n- return ({\n+ rawMessageInfo = ({\n...messageData,\ntype: messageTypes.IMAGES,\n- id: undefined,\n}: RawImagesMessageInfo);\n} else {\n- return ({\n+ rawMessageInfo = ({\n...messageData,\ntype: messageTypes.MULTIMEDIA,\n- id: undefined,\n}: RawMediaMessageInfo);\n}\n+ if (input.id) {\n+ rawMessageInfo.id = input.id;\n+ }\n+ return rawMessageInfo;\n}\nexport {\n" }, { "change_type": "MODIFY", "old_path": "server/src/creators/message-creator.js", "new_path": "server/src/creators/message-creator.js", "diff": "@@ -122,10 +122,15 @@ async function createMessages(\ndate: messageData.date,\ntext: messageData.text,\n});\n- } else if (messageData.type === messageTypes.IMAGES) {\n- content = JSON.stringify(messageData.media.map(\n- ({ id }) => parseInt(id, 10),\n- ));\n+ } else if (\n+ messageData.type === messageTypes.IMAGES ||\n+ messageData.type === messageTypes.MULTIMEDIA\n+ ) {\n+ const mediaIDs = [];\n+ for (let { id } of messageData.media) {\n+ mediaIDs.push(parseInt(id, 10));\n+ }\n+ content = JSON.stringify(mediaIDs);\n}\nconst creation = messageData.localID && viewer.hasSessionInfo\n" }, { "change_type": "MODIFY", "old_path": "server/src/fetchers/message-fetchers.js", "new_path": "server/src/fetchers/message-fetchers.js", "diff": "@@ -13,7 +13,6 @@ 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@@ -24,6 +23,7 @@ import { notifCollapseKeyForRawMessageInfo } from 'lib/shared/notif-utils';\nimport {\nsortMessageInfoList,\nshimUnsupportedRawMessageInfos,\n+ createMediaMessageInfo,\n} from 'lib/shared/message-utils';\nimport { permissionLookup } from 'lib/permissions/thread-permissions';\nimport { ServerError } from 'lib/utils/errors';\n@@ -103,7 +103,7 @@ async function fetchCollapsableNotifs(\nFROM notifications n\nLEFT JOIN messages m ON m.id = n.message\nLEFT JOIN uploads up\n- ON m.type = ${messageTypes.IMAGES}\n+ ON m.type IN (${[ messageTypes.IMAGES, messageTypes.MULTIMEDIA ]})\nAND JSON_CONTAINS(m.content, CAST(up.id as JSON), '$')\nLEFT JOIN memberships mm ON mm.thread = m.thread AND mm.user = n.user\nLEFT JOIN memberships stm\n@@ -367,34 +367,41 @@ function rawMessageInfoFromRows(\ndate: content.date,\ntext: content.text,\n};\n- } else if (type === messageTypes.IMAGES) {\n+ } else if (\n+ type === messageTypes.IMAGES ||\n+ type === messageTypes.MULTIMEDIA\n+ ) {\nconst media = [];\nfor (let row of rows) {\nif (!row.uploadID) {\ncontinue;\n}\nconst uploadID = row.uploadID.toString();\n+ if (row.uploadType === \"photo\") {\nmedia.push({\nid: uploadID,\nuri: getUploadURL(uploadID, row.uploadSecret),\n- type: row.uploadType,\n+ type: \"photo\",\ndimensions: row.uploadExtra,\n});\n+ } else {\n+ media.push({\n+ id: uploadID,\n+ uri: getUploadURL(uploadID, row.uploadSecret),\n+ type: \"video\",\n+ dimensions: row.uploadExtra,\n+ });\n+ }\n}\nconst [ row ] = rows;\n- const rawMultimediaMessageInfo: RawMultimediaMessageInfo = {\n- type: messageTypes.IMAGES,\n- id: row.id.toString(),\n+ return createMediaMessageInfo({\nthreadID: row.threadID.toString(),\n- time: row.time,\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+ id: row.id.toString(),\n+ localID: localIDFromCreationString(viewer, row.creation),\n+ time: row.time,\n+ });\n} else {\ninvariant(false, `unrecognized messageType ${type}`);\n}\n@@ -430,7 +437,8 @@ async function fetchMessageInfos(\nup.id AS uploadID, up.type AS uploadType, up.secret AS uploadSecret,\nup.extra AS uploadExtra\nFROM messages m\n- LEFT JOIN uploads up ON m.type = ${messageTypes.IMAGES}\n+ LEFT JOIN uploads up\n+ ON m.type IN (${[ messageTypes.IMAGES, messageTypes.MULTIMEDIA ]})\nAND JSON_CONTAINS(m.content, CAST(up.id as JSON), '$')\nLEFT JOIN memberships mm\nON mm.thread = m.thread AND mm.user = ${viewerID}\n@@ -592,7 +600,8 @@ async function fetchMessageInfosSince(\nup.id AS uploadID, up.type AS uploadType, up.secret AS uploadSecret,\nup.extra AS uploadExtra\nFROM messages m\n- LEFT JOIN uploads up ON m.type = ${messageTypes.IMAGES}\n+ LEFT JOIN uploads up\n+ ON m.type IN (${[ messageTypes.IMAGES, messageTypes.MULTIMEDIA ]})\nAND JSON_CONTAINS(m.content, CAST(up.id as JSON), '$')\nLEFT JOIN memberships mm ON mm.thread = m.thread AND mm.user = ${viewerID}\nLEFT JOIN memberships stm ON m.type = ${messageTypes.CREATE_SUB_THREAD}\n@@ -691,7 +700,8 @@ async function fetchMessageInfoForLocalID(\nup.id AS uploadID, up.type AS uploadType, up.secret AS uploadSecret,\nup.extra AS uploadExtra\nFROM messages m\n- LEFT JOIN uploads up ON m.type = ${messageTypes.IMAGES}\n+ LEFT JOIN uploads up\n+ ON m.type IN (${[ messageTypes.IMAGES, messageTypes.MULTIMEDIA ]})\nAND JSON_CONTAINS(m.content, CAST(up.id as JSON), '$')\nLEFT JOIN memberships mm ON mm.thread = m.thread AND mm.user = ${viewerID}\nLEFT JOIN memberships stm ON m.type = ${messageTypes.CREATE_SUB_THREAD}\n@@ -720,7 +730,8 @@ async function fetchMessageInfoForEntryAction(\nm.user AS creatorID, up.id AS uploadID, up.type AS uploadType,\nup.secret AS uploadSecret, up.extra AS uploadExtra\nFROM messages m\n- LEFT JOIN uploads up ON m.type = ${messageTypes.IMAGES}\n+ LEFT JOIN uploads up\n+ ON m.type IN (${[ messageTypes.IMAGES, messageTypes.MULTIMEDIA ]})\nAND JSON_CONTAINS(m.content, CAST(up.id as JSON), '$')\nLEFT JOIN memberships mm ON mm.thread = m.thread AND mm.user = ${viewerID}\nWHERE m.user = ${viewerID} AND m.thread = ${threadID} AND\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Add server support for new messageTypes.MULTIMEDIA
129,187
22.11.2019 19:41:57
18,000
27e7be93d91dfde4fd49f7ea3011a521ae2ab588
Finish client support for new messageTypes.MULTIMEDIA
[ { "change_type": "MODIFY", "old_path": "lib/reducers/message-reducer.js", "new_path": "lib/reducers/message-reducer.js", "diff": "@@ -7,6 +7,7 @@ import {\ntype MessageStore,\ntype MessageTruncationStatus,\ntype MessagesResponse,\n+ type RawMediaMessageInfo,\ntype RawImagesMessageInfo,\nmessageTruncationStatus,\nmessageTypes,\n@@ -164,7 +165,8 @@ function mergeNewMessages(\nconst currentMessageInfo = oldMessageStore.messages[inputID];\nif (\nmessageInfo.type === messageTypes.TEXT ||\n- messageInfo.type === messageTypes.IMAGES\n+ messageInfo.type === messageTypes.IMAGES ||\n+ messageInfo.type === messageTypes.MULTIMEDIA\n) {\nconst { localID: inputLocalID } = messageInfo;\nconst currentLocalMessageInfo = inputLocalID\n@@ -181,10 +183,10 @@ function mergeNewMessages(\nlocalID: currentMessageInfo.localID,\n};\n} else if (messageInfo.type === messageTypes.MULTIMEDIA) {\n- messageInfo = {\n+ messageInfo = ({\n...messageInfo,\nlocalID: currentMessageInfo.localID,\n- };\n+ }: RawMediaMessageInfo);\n} else {\nmessageInfo = ({\n...messageInfo,\n@@ -205,10 +207,10 @@ function mergeNewMessages(\nlocalID: currentLocalMessageInfo.localID,\n};\n} else if (messageInfo.type === messageTypes.MULTIMEDIA) {\n- messageInfo = {\n+ messageInfo = ({\n...messageInfo,\nlocalID: currentLocalMessageInfo.localID,\n- };\n+ }: RawMediaMessageInfo);\n} else {\nmessageInfo = ({\n...messageInfo,\n@@ -224,7 +226,7 @@ function mergeNewMessages(\nif (rest.type === messageTypes.TEXT) {\nmessageInfo = { ...rest };\n} else if (rest.type === messageTypes.MULTIMEDIA) {\n- messageInfo = { ...rest };\n+ messageInfo = ({ ...rest }: RawMediaMessageInfo);\n} else {\nmessageInfo = ({ ...rest }: RawImagesMessageInfo);\n}\n@@ -794,26 +796,29 @@ function reduceMessageStore(\nconst message = messageStore.messages[messageID];\ninvariant(message, `message with ID ${messageID} could not be found`);\ninvariant(\n- message.type === messageTypes.IMAGES,\n- `message with ID ${messageID} is not messageTypes.IMAGES`,\n+ message.type === messageTypes.IMAGES ||\n+ message.type === messageTypes.MULTIMEDIA,\n+ `message with ID ${messageID} is not multimedia`,\n);\n+\nlet replaced = false;\n- const media = message.media.map(\n- singleMedia => {\n+ const media = [];\n+ for (let singleMedia of message.media) {\nif (singleMedia.id !== currentMediaID) {\n- return singleMedia;\n- }\n+ media.push(singleMedia);\n+ } else {\nreplaced = true;\n- return {\n+ media.push({\n...singleMedia,\n...mediaUpdate,\n- };\n- },\n- );\n+ });\n+ }\n+ }\ninvariant(\nreplaced,\n`message ${messageID} did not contain media with ID ${currentMediaID}`,\n);\n+\nreturn {\n...messageStore,\nmessages: {\n@@ -852,7 +857,11 @@ function reduceMessageStore(\nlet newThreads = threads, newLocal = local;\nfor (let messageID in messages) {\nconst message = messages[messageID];\n- if (message.type !== messageTypes.IMAGES || message.id) {\n+ if (\n+ (message.type !== messageTypes.IMAGES &&\n+ message.type !== messageTypes.MULTIMEDIA) ||\n+ message.id\n+ ) {\nnewMessages[messageID] = message;\ncontinue;\n}\n" }, { "change_type": "MODIFY", "old_path": "lib/shared/notif-utils.js", "new_path": "lib/shared/notif-utils.js", "diff": "@@ -395,12 +395,16 @@ function fullNotifTextsForMessageInfo(\ntitle: threadInfo.uiName,\nbody,\n};\n- } else if (mostRecentType === messageTypes.IMAGES) {\n+ } else if (\n+ mostRecentType === messageTypes.IMAGES ||\n+ mostRecentType === messageTypes.MULTIMEDIA\n+ ) {\nconst media = [];\nfor (let messageInfo of messageInfos) {\ninvariant(\n- messageInfo.type === messageTypes.IMAGES,\n- \"messageInfo should be messageTypes.IMAGES!\",\n+ messageInfo.type === messageTypes.IMAGES ||\n+ messageInfo.type === messageTypes.MULTIMEDIA,\n+ \"messageInfo should be multimedia type!\",\n);\nfor (let singleMedia of messageInfo.media) {\nmedia.push(singleMedia);\n@@ -450,14 +454,23 @@ function notifCollapseKeyForRawMessageInfo(\n): ?string {\nif (\nrawMessageInfo.type === messageTypes.ADD_MEMBERS ||\n- rawMessageInfo.type === messageTypes.REMOVE_MEMBERS ||\n- rawMessageInfo.type === messageTypes.IMAGES\n+ rawMessageInfo.type === messageTypes.REMOVE_MEMBERS\n) {\nreturn joinResult(\nrawMessageInfo.type,\nrawMessageInfo.threadID,\nrawMessageInfo.creatorID,\n);\n+ } else if (\n+ rawMessageInfo.type === messageTypes.IMAGES ||\n+ rawMessageInfo.type === messageTypes.MULTIMEDIA\n+ ) {\n+ // We use the legacy constant here to collapse both types into one\n+ return joinResult(\n+ messageTypes.IMAGES,\n+ rawMessageInfo.threadID,\n+ rawMessageInfo.creatorID,\n+ );\n} else if (rawMessageInfo.type === messageTypes.CHANGE_SETTINGS) {\nreturn joinResult(\nrawMessageInfo.type,\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": "@@ -100,16 +100,21 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\ncontinue;\n}\ninvariant(\n- rawMessageInfo.type === messageTypes.IMAGES,\n- `${localMessageID} should be messageTypes.IMAGES`,\n+ rawMessageInfo.type === messageTypes.IMAGES ||\n+ rawMessageInfo.type === messageTypes.MULTIMEDIA,\n+ `rawMessageInfo ${localMessageID} should be multimedia`,\n);\nconst completed = [];\nlet allUploadsComplete = true;\nfor (let localUploadID in messagePendingUploads) {\n- const media = rawMessageInfo.media.find(\n- media => media.id === localUploadID,\n- );\n+ let media;\n+ for (let singleMedia of rawMessageInfo.media) {\n+ if (singleMedia.id === localUploadID) {\n+ media = singleMedia;\n+ break;\n+ }\n+ }\nif (media) {\nallUploadsComplete = false;\n} else {\n@@ -199,8 +204,9 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\ncontinue;\n}\ninvariant(\n- rawMessageInfo.type === messageTypes.IMAGES,\n- `${localMessageID} should be messageTypes.IMAGES`,\n+ rawMessageInfo.type === messageTypes.IMAGES ||\n+ rawMessageInfo.type === messageTypes.MULTIMEDIA,\n+ `rawMessageInfo ${localMessageID} should be multimedia`,\n);\nthis.dispatchMultimediaMessageAction(rawMessageInfo);\n}\n" }, { "change_type": "MODIFY", "old_path": "native/chat/failed-send.react.js", "new_path": "native/chat/failed-send.react.js", "diff": "@@ -96,7 +96,10 @@ class FailedSend extends React.PureComponent<Props> {\nundefined,\nnewRawMessageInfo,\n);\n- } else if (rawMessageInfo.type === messageTypes.IMAGES) {\n+ } else if (\n+ rawMessageInfo.type === messageTypes.IMAGES ||\n+ rawMessageInfo.type === messageTypes.MULTIMEDIA\n+ ) {\nconst { localID } = rawMessageInfo;\ninvariant(localID, \"failed RawMessageInfo should have localID\");\nconst { chatInputState } = this.props;\n" }, { "change_type": "MODIFY", "old_path": "web/chat/failed-send.react.js", "new_path": "web/chat/failed-send.react.js", "diff": "@@ -47,11 +47,6 @@ type Props = {|\nlocalID: string,\ntext: string,\n) => Promise<SendMessageResult>,\n- sendMultimediaMessage: (\n- threadID: string,\n- localID: string,\n- mediaIDs: $ReadOnlyArray<string>,\n- ) => Promise<SendMessageResult>,\n|};\nclass FailedSend extends React.PureComponent<Props> {\n@@ -62,7 +57,6 @@ class FailedSend extends React.PureComponent<Props> {\nrawMessageInfo: PropTypes.object.isRequired,\ndispatchActionPromise: PropTypes.func.isRequired,\nsendTextMessage: PropTypes.func.isRequired,\n- sendMultimediaMessage: PropTypes.func.isRequired,\n};\nrender() {\n@@ -90,7 +84,10 @@ class FailedSend extends React.PureComponent<Props> {\nundefined,\nnewRawMessageInfo,\n);\n- } else if (rawMessageInfo.type === messageTypes.IMAGES) {\n+ } else if (\n+ rawMessageInfo.type === messageTypes.IMAGES ||\n+ rawMessageInfo.type === messageTypes.MULTIMEDIA\n+ ) {\nconst { localID } = rawMessageInfo;\ninvariant(localID, \"failed RawMessageInfo should have localID\");\nthis.props.chatInputState.retryMultimediaMessage(localID);\n@@ -135,7 +132,8 @@ export default connect(\nassertComposableMessageType(rawMessageInfo.type);\ninvariant(\nrawMessageInfo.type === messageTypes.TEXT ||\n- rawMessageInfo.type === messageTypes.IMAGES,\n+ rawMessageInfo.type === messageTypes.IMAGES ||\n+ rawMessageInfo.type === messageTypes.MULTIMEDIA,\n\"FailedSend should only be used for composable message types\",\n);\nreturn { rawMessageInfo };\n" }, { "change_type": "MODIFY", "old_path": "web/chat/message.react.js", "new_path": "web/chat/message.react.js", "diff": "@@ -80,7 +80,10 @@ class Message extends React.PureComponent<Props> {\nchatInputState={this.props.chatInputState}\n/>\n);\n- } else if (item.messageInfo.type === messageTypes.IMAGES) {\n+ } else if (\n+ item.messageInfo.type === messageTypes.IMAGES ||\n+ item.messageInfo.type === messageTypes.MULTIMEDIA\n+ ) {\nmessage = (\n<MultimediaMessage\nitem={item}\n" }, { "change_type": "MODIFY", "old_path": "web/chat/multimedia-message.react.js", "new_path": "web/chat/multimedia-message.react.js", "diff": "@@ -41,10 +41,11 @@ class MultimediaMessage extends React.PureComponent<Props> {\nstatic multimediaUploadFailed(props: Props) {\nconst { messageInfo } = props.item;\ninvariant(\n- messageInfo.type === messageTypes.IMAGES,\n- \"MultimediaMessage should only be used for messageTypes.IMAGES\",\n+ messageInfo.type === messageTypes.IMAGES ||\n+ messageInfo.type === messageTypes.MULTIMEDIA,\n+ \"MultimediaMessage should only be used for multimedia messages\",\n);\n- const { id, localID, media } = messageInfo;\n+ const { id, localID } = messageInfo;\nif (id) {\nreturn false;\n}\n@@ -55,8 +56,9 @@ class MultimediaMessage extends React.PureComponent<Props> {\nrender() {\nconst { item, setModal } = this.props;\ninvariant(\n- item.messageInfo.type === messageTypes.IMAGES,\n- \"MultimediaMessage should only be used for messageTypes.IMAGES\",\n+ item.messageInfo.type === messageTypes.IMAGES ||\n+ item.messageInfo.type === messageTypes.MULTIMEDIA,\n+ \"MultimediaMessage should only be used for multimedia messages\",\n);\nconst { id, localID, media } = item.messageInfo;\nconst { isViewer } = item.messageInfo.creator;\n@@ -70,11 +72,12 @@ class MultimediaMessage extends React.PureComponent<Props> {\nconst pendingUploads = localID\n? this.props.chatInputState.assignedUploads[localID]\n: null;\n- const multimedia = media.map(singleMedia => {\n+ const multimedia = [];\n+ for (let singleMedia of media) {\nconst pendingUpload = pendingUploads\n? pendingUploads.find(upload => upload.localID === singleMedia.id)\n: null;\n- return (\n+ multimedia.push(\n<Multimedia\nuri={singleMedia.uri}\npendingUpload={pendingUpload}\n@@ -82,7 +85,7 @@ class MultimediaMessage extends React.PureComponent<Props> {\nkey={singleMedia.id}\n/>\n);\n- });\n+ }\ninvariant(\nmultimedia.length > 0,\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Finish client support for new messageTypes.MULTIMEDIA
129,187
22.11.2019 20:01:28
18,000
678bb3147da0e9de6b702081175658f0b126bc9b
Don't shim messageTypes.IMAGES for codeVersion >= 30
[ { "change_type": "MODIFY", "old_path": "lib/shared/message-utils.js", "new_path": "lib/shared/message-utils.js", "diff": "@@ -627,8 +627,15 @@ function shimUnsupportedRawMessageInfos(\nif (platformDetails && platformDetails.platform === \"web\") {\nreturn [ ...rawMessageInfos ];\n}\n+ const codeVersion =\n+ (platformDetails &&\n+ platformDetails.codeVersion !== null &&\n+ platformDetails.codeVersion !== undefined)\n+ ? platformDetails.codeVersion\n+ : null;\nreturn rawMessageInfos.map(rawMessageInfo => {\n- if (rawMessageInfo.type !== messageTypes.IMAGES) {\n+ if (rawMessageInfo.type === messageTypes.IMAGES) {\n+ if (codeVersion && codeVersion > 29) {\nreturn rawMessageInfo;\n}\nconst { id } = rawMessageInfo;\n@@ -649,6 +656,8 @@ function shimUnsupportedRawMessageInfos(\nrobotext: multimediaMessagePreview(rawMessageInfo),\nunsupportedMessageInfo,\n};\n+ }\n+ return rawMessageInfo;\n});\n}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Don't shim messageTypes.IMAGES for codeVersion >= 30
129,187
22.11.2019 20:05:41
18,000
facd118a81dab59f63ab9c8fc90242904df06f84
Support for shimming and unshimming new messageTypes.MULTIMEDIA
[ { "change_type": "MODIFY", "old_path": "lib/shared/message-utils.js", "new_path": "lib/shared/message-utils.js", "diff": "@@ -656,6 +656,29 @@ function shimUnsupportedRawMessageInfos(\nrobotext: multimediaMessagePreview(rawMessageInfo),\nunsupportedMessageInfo,\n};\n+ } else if (rawMessageInfo.type === messageTypes.MULTIMEDIA) {\n+ // TODO figure out first native codeVersion supporting video playback\n+ if (codeVersion && codeVersion > 41) {\n+ return rawMessageInfo;\n+ }\n+ const { id } = rawMessageInfo;\n+ invariant(id !== null && id !== undefined, \"id should be set on server\");\n+ const unsupportedMessageInfo = {\n+ ...rawMessageInfo,\n+ media: rawMessageInfo.media.map(media => ({\n+ ...media,\n+ uri: shimUploadURI(media.uri, platformDetails),\n+ })),\n+ };\n+ return {\n+ type: messageTypes.UNSUPPORTED,\n+ id,\n+ threadID: rawMessageInfo.threadID,\n+ creatorID: rawMessageInfo.creatorID,\n+ time: rawMessageInfo.time,\n+ robotext: multimediaMessagePreview(rawMessageInfo),\n+ unsupportedMessageInfo,\n+ };\n}\nreturn rawMessageInfo;\n});\n" }, { "change_type": "MODIFY", "old_path": "lib/shared/unshim-utils.js", "new_path": "lib/shared/unshim-utils.js", "diff": "@@ -47,6 +47,13 @@ function unshimFunc(\n}),\n};\n}\n+ if (unwrapped.type === messageTypes.MULTIMEDIA) {\n+ for (let { type } of unwrapped.media) {\n+ if (type !== \"photo\" && type !== \"video\") {\n+ return messageInfo;\n+ }\n+ }\n+ }\nreturn unwrapped;\n}\n@@ -63,6 +70,7 @@ function unshimMessageStore(\nconst localUnshimTypes = new Set([\nmessageTypes.IMAGES,\n+ messageTypes.MULTIMEDIA,\n]);\nfunction unshimMessageInfos(\nmessageInfos: $ReadOnlyArray<RawMessageInfo>,\n" }, { "change_type": "MODIFY", "old_path": "native/redux/persist.js", "new_path": "native/redux/persist.js", "diff": "@@ -144,6 +144,13 @@ const migrations = {\ndeviceCameraInfo: defaultDeviceCameraInfo,\ndeviceOrientation: Orientation.getInitialOrientation(),\n}),\n+ [14]: (state: AppState) => ({\n+ ...state,\n+ messageStore: unshimMessageStore(\n+ state.messageStore,\n+ [ messageTypes.MULTIMEDIA ],\n+ ),\n+ }),\n};\nconst persistConfig = {\n@@ -151,7 +158,7 @@ const persistConfig = {\nstorage: AsyncStorage,\nblacklist,\ndebug: __DEV__,\n- version: 13,\n+ version: 14,\nmigrate: createMigrate(migrations, { debug: __DEV__ }),\ntimeout: __DEV__ ? 0 : undefined,\n};\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Support for shimming and unshimming new messageTypes.MULTIMEDIA
129,187
25.11.2019 20:38:56
18,000
1a4680bccfc58e42df75681a391102e21fdd1f9a
[native] Fix batch inomplete crash in TextHeightMeasurer `this.leftInBatch` isn't set (and doesn't need to be set) in the case where nothing is passed in
[ { "change_type": "MODIFY", "old_path": "native/text-height-measurer.react.js", "new_path": "native/text-height-measurer.react.js", "diff": "@@ -119,7 +119,6 @@ class TextHeightMeasurer extends React.PureComponent<Props, State> {\ndone(textToMeasure: TextToMeasure[]) {\ninvariant(this.leftToMeasure.size === 0, \"should be 0 left to measure\");\n- invariant(this.leftInBatch === 0, \"batch should be complete\");\ninvariant(this.nextTextToHeight, \"nextTextToHeight should be set\");\nthis.currentTextToHeight = this.nextTextToHeight;\nthis.nextTextToHeight = null;\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Fix batch inomplete crash in TextHeightMeasurer `this.leftInBatch` isn't set (and doesn't need to be set) in the case where nothing is passed in
129,187
25.11.2019 22:16:19
18,000
c810911976b1109e0905635ad478ba93f9e8030b
[native] Don't allow attempting retry multiple times for same message
[ { "change_type": "MODIFY", "old_path": "native/chat/failed-send.react.js", "new_path": "native/chat/failed-send.react.js", "diff": "@@ -12,6 +12,11 @@ import {\nimport type { AppState } from '../redux/redux-setup';\nimport type { DispatchActionPromise } from 'lib/utils/action-utils';\nimport type { Styles } from '../types/styles';\n+import {\n+ type ChatInputState,\n+ chatInputStatePropType,\n+ withChatInputState,\n+} from './chat-input-state';\nimport * as React from 'react';\nimport { Text, View } from 'react-native';\n@@ -24,14 +29,10 @@ 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';\nimport { styleSelector } from '../themes/colors';\n+import multimediaMessageSendFailed from './multimedia-message-send-failed';\nconst failedSendHeight = 22;\n@@ -61,6 +62,28 @@ class FailedSend extends React.PureComponent<Props> {\nsendTextMessage: PropTypes.func.isRequired,\nchatInputState: chatInputStatePropType,\n};\n+ retryingText = false;\n+ retryingMedia = false;\n+\n+ componentDidUpdate(prevProps: Props) {\n+ const newItem = this.props.item;\n+ if (newItem.messageShapeType !== \"multimedia\") {\n+ return;\n+ }\n+ const prevItem = prevProps.item;\n+ if (prevItem.messageShapeType !== \"multimedia\") {\n+ return;\n+ }\n+ const isFailed = multimediaMessageSendFailed(newItem);\n+ const wasFailed = multimediaMessageSendFailed(prevItem);\n+ const isDone = newItem.messageInfo.id !== null &&\n+ newItem.messageInfo.id !== undefined;\n+ const wasDone = prevItem.messageInfo.id !== null &&\n+ prevItem.messageInfo.id !== undefined;\n+ if ((isFailed && !wasFailed) || (isDone && !wasDone)) {\n+ this.retryingMedia = false;\n+ }\n+ }\nrender() {\nif (!this.props.rawMessageInfo) {\n@@ -73,7 +96,7 @@ class FailedSend extends React.PureComponent<Props> {\n</Text>\n<Button onPress={this.retrySend}>\n<Text style={this.props.styles.retrySend} numberOfLines={1}>\n- RETRY?\n+ {\"RETRY?\"}\n</Text>\n</Button>\n</View>\n@@ -86,6 +109,9 @@ class FailedSend extends React.PureComponent<Props> {\nreturn;\n}\nif (rawMessageInfo.type === messageTypes.TEXT) {\n+ if (this.retryingText) {\n+ return;\n+ }\nconst newRawMessageInfo = {\n...rawMessageInfo,\ntime: Date.now(),\n@@ -107,6 +133,10 @@ class FailedSend extends React.PureComponent<Props> {\nchatInputState,\n`chatInputState should be initialized before user can hit retry`,\n);\n+ if (this.retryingMedia) {\n+ return;\n+ }\n+ this.retryingMedia = true;\nchatInputState.retryMultimediaMessage(localID);\n}\n}\n@@ -114,6 +144,7 @@ class FailedSend extends React.PureComponent<Props> {\nasync sendTextMessageAction(\nmessageInfo: RawTextMessageInfo,\n): Promise<SendMessagePayload> {\n+ this.retryingText = true;\ntry {\nconst { localID } = messageInfo;\ninvariant(\n@@ -135,6 +166,8 @@ class FailedSend extends React.PureComponent<Props> {\ne.localID = messageInfo.localID;\ne.threadID = messageInfo.threadID;\nthrow e;\n+ } finally {\n+ this.retryingText = false;\n}\n}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "native/chat/multimedia-message-send-failed.js", "diff": "+// @flow\n+\n+import type { ChatMultimediaMessageInfoItem } from './multimedia-message.react';\n+\n+export default function multimediaMessageSendFailed(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" }, { "change_type": "MODIFY", "old_path": "native/chat/multimedia-message.react.js", "new_path": "native/chat/multimedia-message.react.js", "diff": "@@ -36,6 +36,7 @@ import {\n} from './rounded-message-container.react';\nimport { authorNameHeight } from './message-header.react';\nimport { failedSendHeight } from './failed-send.react';\n+import sendFailed from './multimedia-message-send-failed';\ntype ContentHeights = {|\nimageHeight: number,\n@@ -100,32 +101,6 @@ function multimediaMessageContentHeights(\nreturn { imageHeight, contentHeight };\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-\n// Called by Message\n// Given a ChatMultimediaMessageInfoItem, determines exact height of row\nfunction multimediaMessageItemHeight(\n@@ -338,4 +313,5 @@ export {\nWrappedMultimediaMessage as MultimediaMessage,\nmultimediaMessageContentHeights,\nmultimediaMessageItemHeight,\n+ sendFailed as multimediaMessageSendFailed,\n};\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Don't allow attempting retry multiple times for same message
129,187
25.11.2019 22:33:23
18,000
df896d022c80325afac70746b8164369259864ea
[web] Don't allow attempting retry multiple times for same message
[ { "change_type": "MODIFY", "old_path": "web/chat/failed-send.react.js", "new_path": "web/chat/failed-send.react.js", "diff": "@@ -32,6 +32,7 @@ import {\n} from 'lib/actions/message-actions';\nimport css from './chat-message-list.css';\n+import multimediaMessageSendFailed from './multimedia-message-send-failed';\ntype Props = {|\nitem: ChatMessageInfoItem,\n@@ -58,6 +59,28 @@ class FailedSend extends React.PureComponent<Props> {\ndispatchActionPromise: PropTypes.func.isRequired,\nsendTextMessage: PropTypes.func.isRequired,\n};\n+ retryingText = false;\n+ retryingMedia = false;\n+\n+ componentDidUpdate(prevProps: Props) {\n+ const newItem = this.props.item;\n+ const prevItem = prevProps.item;\n+ const isFailed = multimediaMessageSendFailed(\n+ this.props.item,\n+ this.props.chatInputState,\n+ );\n+ const wasFailed = multimediaMessageSendFailed(\n+ prevProps.item,\n+ prevProps.chatInputState,\n+ );\n+ const isDone = this.props.item.messageInfo.id !== null &&\n+ this.props.item.messageInfo.id !== undefined;\n+ const wasDone = prevProps.item.messageInfo.id !== null &&\n+ prevProps.item.messageInfo.id !== undefined;\n+ if ((isFailed && !wasFailed) || (isDone && !wasDone)) {\n+ this.retryingMedia = false;\n+ }\n+ }\nrender() {\nreturn (\n@@ -77,6 +100,9 @@ class FailedSend extends React.PureComponent<Props> {\nconst { rawMessageInfo } = this.props;\nif (rawMessageInfo.type === messageTypes.TEXT) {\n+ if (this.retryingText) {\n+ return;\n+ }\nconst newRawMessageInfo = { ...rawMessageInfo, time: Date.now() };\nthis.props.dispatchActionPromise(\nsendTextMessageActionTypes,\n@@ -90,6 +116,10 @@ class FailedSend extends React.PureComponent<Props> {\n) {\nconst { localID } = rawMessageInfo;\ninvariant(localID, \"failed RawMessageInfo should have localID\");\n+ if (this.retryingMedia) {\n+ return;\n+ }\n+ this.retryingMedia = true;\nthis.props.chatInputState.retryMultimediaMessage(localID);\n}\n}\n@@ -97,6 +127,7 @@ class FailedSend extends React.PureComponent<Props> {\nasync sendTextMessageAction(\nmessageInfo: RawTextMessageInfo,\n): Promise<SendMessagePayload> {\n+ this.retryingText = true;\ntry {\nconst { localID } = messageInfo;\ninvariant(\n@@ -118,6 +149,8 @@ class FailedSend extends React.PureComponent<Props> {\ne.localID = messageInfo.localID;\ne.threadID = messageInfo.threadID;\nthrow e;\n+ } finally {\n+ this.retryingText = false;\n}\n}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "web/chat/multimedia-message-send-failed.js", "diff": "+// @flow\n+\n+import type { ChatMessageInfoItem } from 'lib/selectors/chat-selectors';\n+import { messageTypes } from 'lib/types/message-types';\n+import type { ChatInputState } from './chat-input-state';\n+\n+import invariant from 'invariant';\n+\n+export default function multimediaMessageSendFailed(\n+ item: ChatMessageInfoItem,\n+ chatInputState: ChatInputState,\n+) {\n+ const { messageInfo } = item;\n+ if (\n+ !messageInfo.creator.isViewer ||\n+ (messageInfo.type !== messageTypes.MULTIMEDIA &&\n+ messageInfo.type !== messageTypes.IMAGES)\n+ ) {\n+ return false;\n+ }\n+ const { id, localID } = messageInfo;\n+ if (id !== null && id !== undefined) {\n+ return false;\n+ }\n+ invariant(localID, \"localID should be set if serverID is not\");\n+ return !!(\n+ chatInputState.messageHasUploadFailure(localID) ||\n+ (item.localMessageInfo && item.localMessageInfo.sendFailed)\n+ );\n+}\n" }, { "change_type": "MODIFY", "old_path": "web/chat/multimedia-message.react.js", "new_path": "web/chat/multimedia-message.react.js", "diff": "@@ -20,6 +20,7 @@ import classNames from 'classnames';\nimport css from './chat-message-list.css';\nimport Multimedia from './multimedia.react';\nimport ComposedMessage from './composed-message.react';\n+import sendFailed from './multimedia-message-send-failed';\ntype Props = {|\nitem: ChatMessageInfoItem,\n@@ -38,21 +39,6 @@ class MultimediaMessage extends React.PureComponent<Props> {\nsetModal: PropTypes.func.isRequired,\n};\n- static multimediaUploadFailed(props: Props) {\n- const { messageInfo } = props.item;\n- invariant(\n- messageInfo.type === messageTypes.IMAGES ||\n- messageInfo.type === messageTypes.MULTIMEDIA,\n- \"MultimediaMessage should only be used for multimedia messages\",\n- );\n- const { id, localID } = messageInfo;\n- if (id) {\n- return false;\n- }\n- invariant(localID, \"localID should be set if serverID is not\");\n- return props.chatInputState.messageHasUploadFailure(localID);\n- }\n-\nrender() {\nconst { item, setModal } = this.props;\ninvariant(\n@@ -63,12 +49,6 @@ class MultimediaMessage extends React.PureComponent<Props> {\nconst { id, localID, media } = item.messageInfo;\nconst { isViewer } = item.messageInfo.creator;\n- const sendFailed =\n- isViewer &&\n- (id === null || id === undefined) &&\n- (MultimediaMessage.multimediaUploadFailed(this.props) ||\n- (item.localMessageInfo && item.localMessageInfo.sendFailed));\n-\nconst pendingUploads = localID\n? this.props.chatInputState.assignedUploads[localID]\n: null;\n@@ -100,7 +80,7 @@ class MultimediaMessage extends React.PureComponent<Props> {\n<ComposedMessage\nitem={item}\nthreadInfo={this.props.threadInfo}\n- sendFailed={!!sendFailed}\n+ sendFailed={sendFailed(this.props.item, this.props.chatInputState)}\nsetMouseOver={this.props.setMouseOver}\nclassName={className}\nborderRadius={16}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[web] Don't allow attempting retry multiple times for same message
129,187
25.11.2019 22:33:35
18,000
31365f9c2c838e1e17720cb4431aa4ef24990238
[native] Floor instead of round when reporting media upload progress
[ { "change_type": "MODIFY", "old_path": "native/chat/inline-multimedia.react.js", "new_path": "native/chat/inline-multimedia.react.js", "diff": "@@ -68,6 +68,7 @@ class InlineMultimedia extends React.PureComponent<Props> {\nthickness={15}\nshowsText={true}\ntextStyle={styles.progressIndicatorText}\n+ formatText={this.formatProgressText}\n/>\n</View>\n);\n@@ -91,6 +92,8 @@ class InlineMultimedia extends React.PureComponent<Props> {\n);\n}\n+ formatProgressText = (progress: number) => `${Math.floor(progress * 100)}%`\n+\n}\nconst styles = StyleSheet.create({\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Floor instead of round when reporting media upload progress
129,187
25.11.2019 23:38:25
18,000
72f90474a983ddfe1768352210fc87615274cedc
[native] Don't change chatInputState if progressPercent is similar We only care about two sig figs
[ { "change_type": "MODIFY", "old_path": "native/chat/chat-input-state-container.react.js", "new_path": "native/chat/chat-input-state-container.react.js", "diff": "@@ -434,6 +434,11 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\nif (!pendingUpload) {\nreturn {};\n}\n+ const newOutOfHundred = Math.floor(progressPercent * 100);\n+ const oldOutOfHundred = Math.floor(pendingUpload.progressPercent * 100);\n+ if (newOutOfHundred === oldOutOfHundred) {\n+ return {};\n+ }\nconst newPendingUploads = {\n...pendingUploads,\n[localUploadID]: {\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Don't change chatInputState if progressPercent is similar We only care about two sig figs
129,187
25.11.2019 23:55:14
18,000
86ab70fdcb168206dd018b556c191cb997349b26
Fix places I should've used throttle instead of debounce
[ { "change_type": "MODIFY", "old_path": "lib/socket/socket.react.js", "new_path": "lib/socket/socket.react.js", "diff": "@@ -42,7 +42,7 @@ import type { CalendarQuery } from '../types/entry-types';\nimport * as React from 'react';\nimport PropTypes from 'prop-types';\nimport invariant from 'invariant';\n-import _debounce from 'lodash/debounce';\n+import _throttle from 'lodash/throttle';\nimport { getConfig } from '../utils/config';\nimport {\n@@ -259,10 +259,9 @@ class Socket extends React.PureComponent<Props, State> {\n}\n}\n- reconnect = _debounce(\n+ reconnect = _throttle(\n() => this.openSocket(\"reconnecting\"),\n2000,\n- { leading: true, trailing: true },\n)\ncomponentDidMount() {\n" }, { "change_type": "MODIFY", "old_path": "native/calendar/calendar.react.js", "new_path": "native/calendar/calendar.react.js", "diff": "@@ -57,7 +57,7 @@ import _filter from 'lodash/fp/filter';\nimport _sum from 'lodash/fp/sum';\nimport _pickBy from 'lodash/fp/pickBy';\nimport _size from 'lodash/fp/size';\n-import _debounce from 'lodash/debounce';\n+import _throttle from 'lodash/throttle';\nimport { entryKey } from 'lib/shared/entry-utils';\nimport { dateString, prettyDate, dateFromString } from 'lib/utils/date-utils';\n@@ -1067,7 +1067,7 @@ class Calendar extends React.PureComponent<Props, State> {\n);\n}\n- loadMoreAbove = _debounce(\n+ loadMoreAbove = _throttle(\n() => {\nif (\nthis.topLoadingFromScroll &&\n@@ -1078,10 +1078,9 @@ class Calendar extends React.PureComponent<Props, State> {\n}\n},\n1000,\n- { leading: true, trailing: true },\n)\n- loadMoreBelow = _debounce(\n+ loadMoreBelow = _throttle(\n() => {\nif (\nthis.bottomLoadingFromScroll &&\n@@ -1092,7 +1091,6 @@ class Calendar extends React.PureComponent<Props, State> {\n}\n},\n1000,\n- { leading: true, trailing: true },\n)\nonScroll = (event: { nativeEvent: { contentOffset: { y: number } } }) => {\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Fix places I should've used throttle instead of debounce
129,187
26.11.2019 00:01:25
18,000
27f6e3065ff8df57b8e11876d55a4376710d4ea4
[native] Throttle text draft saving
[ { "change_type": "MODIFY", "old_path": "native/chat/chat-input-bar.react.js", "new_path": "native/chat/chat-input-bar.react.js", "diff": "@@ -55,6 +55,7 @@ import {\nKeyboardAccessoryView,\nTextInputKeyboardMangerIOS,\n} from 'react-native-keyboard-input';\n+import _throttle from 'lodash/throttle';\nimport { connect } from 'lib/utils/redux-utils';\nimport {\n@@ -426,11 +427,18 @@ class ChatInputBar extends React.PureComponent<Props, State> {\nupdateText = (text: string) => {\nthis.setState({ text });\n+ this.saveDraft(text);\n+ }\n+\n+ saveDraft = _throttle(\n+ (text: string) => {\nthis.props.dispatchActionPayload(\nsaveDraftActionType,\n{ key: draftKeyFromThreadID(this.props.threadInfo.id), draft: text },\n);\n- }\n+ },\n+ 400,\n+ );\nonContentSizeChange = (event) => {\nlet height = event.nativeEvent.contentSize.height;\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Throttle text draft saving
129,187
26.11.2019 15:05:46
18,000
f830658e64b24f95cafb7e0bfbfcae7bb17bc73f
Strip localIDs from messages before sending to other clients These should be stripped before being passed to Redis and push notif code.
[ { "change_type": "MODIFY", "old_path": "lib/shared/message-utils.js", "new_path": "lib/shared/message-utils.js", "diff": "@@ -774,6 +774,42 @@ function createMediaMessageInfo(\nreturn rawMessageInfo;\n}\n+function stripLocalIDs(\n+ input: $ReadOnlyArray<RawMessageInfo>,\n+): RawMessageInfo[] {\n+ const output = [];\n+ for (let rawMessageInfo of input) {\n+ if (\n+ rawMessageInfo.localID === null ||\n+ rawMessageInfo.localID === undefined\n+ ) {\n+ output.push(rawMessageInfo);\n+ continue;\n+ }\n+ invariant(\n+ rawMessageInfo.id,\n+ \"serverID should be set if localID is being stripped\",\n+ );\n+ if (rawMessageInfo.type === messageTypes.TEXT) {\n+ const { localID, ...rest } = rawMessageInfo;\n+ output.push({ ...rest });\n+ } else if (rawMessageInfo.type === messageTypes.IMAGES) {\n+ const { localID, ...rest } = rawMessageInfo;\n+ output.push(({ ...rest }: RawImagesMessageInfo));\n+ } else if (rawMessageInfo.type === messageTypes.MULTIMEDIA) {\n+ const { localID, ...rest } = rawMessageInfo;\n+ output.push(({ ...rest }: RawMediaMessageInfo));\n+ } else {\n+ invariant(\n+ false,\n+ `message ${rawMessageInfo.id} of type ${rawMessageInfo.type} ` +\n+ `unexpectedly has localID`,\n+ );\n+ }\n+ }\n+ return output;\n+}\n+\nexport {\nmessageKey,\nmessageID,\n@@ -792,4 +828,5 @@ export {\nmessagePreviewText,\ncreateMediaMessageData,\ncreateMediaMessageInfo,\n+ stripLocalIDs,\n};\n" }, { "change_type": "MODIFY", "old_path": "server/src/creators/message-creator.js", "new_path": "server/src/creators/message-creator.js", "diff": "@@ -17,6 +17,7 @@ import {\nrawMessageInfoFromMessageData,\nmessageTypeGeneratesNotifs,\nshimUnsupportedRawMessageInfos,\n+ stripLocalIDs,\n} from 'lib/shared/message-utils';\nimport { permissionLookup } from 'lib/permissions/thread-permissions';\n@@ -153,7 +154,7 @@ async function createMessages(\nviewer,\nthreadsToMessageIndices,\nsubthreadPermissionsToCheck,\n- messageInfos,\n+ stripLocalIDs(messageInfos),\n));\nconst messageInsertQuery = SQL`\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Strip localIDs from messages before sending to other clients These should be stripped before being passed to Redis and push notif code.
129,187
26.11.2019 15:29:44
18,000
5094f9250d92342232d3f922cc4c2b7a20bae027
[server] Include platformDetails in report column
[ { "change_type": "ADD", "old_path": null, "new_path": "server/flow-typed/npm/@fortawesome/react-fontawesome_vx.x.x.js", "diff": "+// flow-typed signature: 945b871ffc274e5f02d50d5a92d1b945\n+// flow-typed version: <<STUB>>/@fortawesome/react-fontawesome_v^0.0.18/flow_v0.98.0\n+\n+/**\n+ * This is an autogenerated libdef stub for:\n+ *\n+ * '@fortawesome/react-fontawesome'\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 '@fortawesome/react-fontawesome' {\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 '@fortawesome/react-fontawesome/index.es' {\n+ declare module.exports: any;\n+}\n+\n+// Filename aliases\n+declare module '@fortawesome/react-fontawesome/index.es.js' {\n+ declare module.exports: $Exports<'@fortawesome/react-fontawesome/index.es'>;\n+}\n+declare module '@fortawesome/react-fontawesome/index' {\n+ declare module.exports: $Exports<'@fortawesome/react-fontawesome'>;\n+}\n+declare module '@fortawesome/react-fontawesome/index.js' {\n+ declare module.exports: $Exports<'@fortawesome/react-fontawesome'>;\n+}\n" }, { "change_type": "MODIFY", "old_path": "server/src/creators/report-creator.js", "new_path": "server/src/creators/report-creator.js", "diff": "@@ -40,14 +40,14 @@ async function createReport(\nreturn null;\n}\nconst [ id ] = await createIDs(\"reports\", 1);\n- let type, platformDetails, report, time;\n+ let type, report, time;\nif (request.type === reportTypes.THREAD_INCONSISTENCY) {\n- ({ type, platformDetails, time, ...report } = request);\n+ ({ type, time, ...report } = request);\ntime = time ? time : Date.now();\n} else if (request.type === reportTypes.ENTRY_INCONSISTENCY) {\n- ({ type, platformDetails, time, ...report } = request);\n+ ({ type, time, ...report } = request);\n} else {\n- ({ type, platformDetails, ...report } = request);\n+ ({ type, ...report } = request);\ntime = Date.now();\nreport = {\n...report,\n@@ -60,7 +60,7 @@ async function createReport(\nid,\nviewer.id,\ntype,\n- platformDetails.platform,\n+ request.platformDetails.platform,\nJSON.stringify(report),\ntime,\n];\n" }, { "change_type": "MODIFY", "old_path": "server/src/fetchers/report-fetchers.js", "new_path": "server/src/fetchers/report-fetchers.js", "diff": "@@ -36,14 +36,18 @@ async function fetchErrorReportInfos(\nconst userInfos = {};\nfor (let row of result) {\nconst viewerID = row.user.toString();\n- reports.push({\n- id: row.id.toString(),\n- viewerID,\n- platformDetails: {\n+ let { platformDetails } = row.report;\n+ if (!platformDetails) {\n+ platformDetails = {\nplatform: row.platform,\ncodeVersion: row.report.codeVersion,\nstateVersion: row.report.stateVersion,\n- },\n+ };\n+ }\n+ reports.push({\n+ id: row.id.toString(),\n+ viewerID,\n+ platformDetails,\ncreationTime: row.creation_time,\n});\nif (row.username) {\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[server] Include platformDetails in report column
129,187
26.11.2019 16:07:03
18,000
6b780f27d1a6dc9848724cdafa097bd843ec1841
[native] Show media upload retry beginning before validateMedia More responsive
[ { "change_type": "MODIFY", "old_path": "native/chat/chat-input-state-container.react.js", "new_path": "native/chat/chat-input-state-container.react.js", "diff": "@@ -562,6 +562,21 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\nnewRawMessageInfo,\n);\n+ // We clear out the failed status on individual media here,\n+ // which makes the UI show pending status instead of error messages\n+ for (let { id } of retryMedia) {\n+ pendingUploads[id] = {\n+ failed: null,\n+ progressPercent: 0,\n+ };\n+ }\n+ this.setState(prevState => ({\n+ pendingUploads: {\n+ ...prevState.pendingUploads,\n+ [localMessageID]: pendingUploads,\n+ },\n+ }));\n+\nconst imageGalleryImages = retryMedia.map(singleMedia => {\nif (singleMedia.type === \"photo\") {\nconst { dimensions, uri } = singleMedia;\n@@ -576,12 +591,17 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\n);\nconst mediaInfos = [];\n+ const newPendingUploads = {};\nfor (let i = 0; i < validationResults.length; i++) {\nconst result = validationResults[i];\n+ const { id } = retryMedia[i];\nif (!result) {\n+ newPendingUploads[id] = {\n+ failed: \"validation\",\n+ progressPercent: 0,\n+ };\ncontinue;\n}\n- const { id } = retryMedia[i];\nmediaInfos.push({\nvalidationResult: result,\nlocalID: id,\n@@ -592,25 +612,22 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\n// this should never be triggered\nconsole.log('unexpected MIME type found');\n}\n- if (mediaInfos.length === 0) {\n- return;\n- }\n-\n- for (let { localID } of mediaInfos) {\n- pendingUploads[localID] = {\n- failed: null,\n- progressPercent: 0,\n- };\n- }\n+ if (Object.keys(newPendingUploads).length > 0) {\nthis.setState(prevState => ({\npendingUploads: {\n...prevState.pendingUploads,\n- [localMessageID]: pendingUploads,\n+ [localMessageID]: {\n+ ...prevState.pendingUploads[localMessageID],\n+ ...newPendingUploads,\n+ },\n},\n}));\n+ }\n+ if (mediaInfos.length > 0) {\nawait this.uploadFiles(localMessageID, mediaInfos);\n}\n+ }\nclearURI = async (uri: string) => {\nif (!this.pendingUnlinkURIs.has(uri)) {\n" }, { "change_type": "MODIFY", "old_path": "native/media/media-gallery-media.react.js", "new_path": "native/media/media-gallery-media.react.js", "diff": "@@ -78,7 +78,7 @@ class MediaGalleryMedia extends React.PureComponent<Props> {\nwidth: PropTypes.number.isRequired,\ntype: mediaTypePropType.isRequired,\nuri: PropTypes.string.isRequired,\n- filename: PropTypes.string.isRequired,\n+ filename: PropTypes.string,\n}).isRequired,\ncontainerHeight: PropTypes.number.isRequired,\nqueueModeActive: PropTypes.bool.isRequired,\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Show media upload retry beginning before validateMedia More responsive
129,187
26.11.2019 22:35:08
18,000
11ad3311694e0d8e5d41d87a667cba1667cbff0b
[native] Don't crash if Calendar.scrollToToday called while transitioning
[ { "change_type": "MODIFY", "old_path": "native/calendar/calendar.react.js", "new_path": "native/calendar/calendar.react.js", "diff": "@@ -625,7 +625,9 @@ class Calendar extends React.PureComponent<Props, State> {\nanimated = this.props.calendarActive;\n}\nconst ldwh = this.state.listDataWithHeights;\n- invariant(ldwh, \"scrollToToday called, but listDataWithHeights isn't set\");\n+ if (!ldwh) {\n+ return;\n+ }\nconst todayIndex = _findIndex(['dateString', dateString(new Date())])(ldwh);\ninvariant(this.flatList, \"scrollToToday called, but flatList isn't set\");\nthis.flatList.scrollToIndex({\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Don't crash if Calendar.scrollToToday called while transitioning
129,187
26.11.2019 23:10:35
18,000
a41ac372e01f97502bfe1098ecad704d4d1dae15
[lib] Fix redux-persist filtering logic in ReduxLogger
[ { "change_type": "MODIFY", "old_path": "lib/utils/redux-logger.js", "new_path": "lib/utils/redux-logger.js", "diff": "@@ -59,7 +59,7 @@ class ReduxLogger {\nconst stateWithTime = { state, time };\nif (\nthis.lastNActions.length > 0 &&\n- this.lastNActions[this.lastNActions.length - 1].type\n+ this.lastNActions[this.lastNActions.length - 1].action.type\n=== rehydrateActionType\n) {\n// redux-persist can't handle replaying REHYDRATE\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[lib] Fix redux-persist filtering logic in ReduxLogger
129,187
26.11.2019 23:20:56
18,000
e5bbc558c1efd8224f23aa3acdb22871630f7892
[native] Make sure rehydrateConcluded is bool
[ { "change_type": "MODIFY", "old_path": "native/account/logged-out-modal.react.js", "new_path": "native/account/logged-out-modal.react.js", "diff": "@@ -839,7 +839,7 @@ const isForegroundSelector =\ncreateIsForegroundSelector(LoggedOutModalRouteName);\nexport default connect(\n(state: AppState) => ({\n- rehydrateConcluded: state._persist && state._persist.rehydrated,\n+ rehydrateConcluded: !!(state._persist && state._persist.rehydrated),\ncookie: state.cookie,\nurlPrefix: state.urlPrefix,\nloggedIn: !!(state.currentUserInfo &&\n" }, { "change_type": "MODIFY", "old_path": "native/push/push-handler.react.js", "new_path": "native/push/push-handler.react.js", "diff": "@@ -594,7 +594,7 @@ AppRegistry.registerHeadlessTask(\nexport default connect(\n(state: AppState) => ({\n- rehydrateConcluded: state._persist && state._persist.rehydrated,\n+ rehydrateConcluded: !!(state._persist && state._persist.rehydrated),\nunreadCount: unreadCount(state),\nactiveThread: activeThreadSelector(state),\nappLoggedIn: appLoggedInSelector(state),\n" }, { "change_type": "MODIFY", "old_path": "native/themes/theme-handler.react.js", "new_path": "native/themes/theme-handler.react.js", "diff": "@@ -85,7 +85,7 @@ class ThemeHandler extends React.PureComponent<Props> {\nexport default connect(\n(state: AppState) => ({\nglobalThemeInfo: state.globalThemeInfo,\n- rehydrateConcluded: state._persist && state._persist.rehydrated,\n+ rehydrateConcluded: !!(state._persist && state._persist.rehydrated),\n}),\nnull,\ntrue,\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Make sure rehydrateConcluded is bool
129,187
27.11.2019 00:27:09
18,000
02ba08466e458e15267be81186333ec103633ab0
Error report download now avoids persisting in Redux
[ { "change_type": "MODIFY", "old_path": "native/redux/persist.js", "new_path": "native/redux/persist.js", "diff": "@@ -26,6 +26,7 @@ const baseBlacklist = [\n'dimensions',\n'connectivity',\n'deviceOrientation',\n+ 'frozen',\n];\nconst blacklist = __DEV__\n? baseBlacklist\n" }, { "change_type": "MODIFY", "old_path": "native/redux/redux-setup.js", "new_path": "native/redux/redux-setup.js", "diff": "@@ -134,6 +134,7 @@ export type AppState = {|\nglobalThemeInfo: GlobalThemeInfo,\ndeviceCameraInfo: DeviceCameraInfo,\ndeviceOrientation: Orientations,\n+ frozen: bool,\n|};\nconst { height, width } = NativeDimensions.get('window');\n@@ -178,6 +179,7 @@ const defaultState = ({\nglobalThemeInfo: defaultGlobalThemeInfo,\ndeviceCameraInfo: defaultDeviceCameraInfo,\ndeviceOrientation: Orientation.getInitialOrientation(),\n+ frozen: false,\n}: AppState);\nfunction chatRouteFromNavInfo(navInfo: NavInfo): NavigationStateRoute {\n" }, { "change_type": "MODIFY", "old_path": "server/src/fetchers/report-fetchers.js", "new_path": "server/src/fetchers/report-fetchers.js", "diff": "@@ -80,8 +80,19 @@ async function fetchReduxToolsImport(\n}\nconst row = result[0];\n+ const _persist = row.report.preloadedState._persist\n+ ? row.report.preloadedState._persist\n+ : {};\nreturn {\n- preloadedState: row.report.preloadedState,\n+ preloadedState: {\n+ ...row.report.preloadedState,\n+ _persist: {\n+ ..._persist,\n+ // Setting this to false disables redux-persist\n+ rehydrated: false,\n+ },\n+ frozen: true,\n+ },\npayload: row.report.actions,\n};\n}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Error report download now avoids persisting in Redux
129,187
27.11.2019 14:31:31
18,000
1036ad245c1689add4faa066ac8e9ff42e0dba41
[native] Fix dimensions and orientation after loading a frozen app state
[ { "change_type": "MODIFY", "old_path": "native/navigation/orientation-handler.react.js", "new_path": "native/navigation/orientation-handler.react.js", "diff": "@@ -12,12 +12,15 @@ import Orientation from 'react-native-orientation-locker';\nimport { connect } from 'lib/utils/redux-utils';\ntype Props = {\n+ // Redux state\n+ deviceOrientation: Orientations,\n// Redux dispatch functions\ndispatchActionPayload: DispatchActionPayload,\n};\nclass OrientationHandler extends React.PureComponent<Props> {\nstatic propTypes = {\n+ deviceOrientation: PropTypes.string.isRequired,\ndispatchActionPayload: PropTypes.func.isRequired,\n};\n@@ -29,6 +32,19 @@ class OrientationHandler extends React.PureComponent<Props> {\nOrientation.removeOrientationListener(this.updateOrientation);\n}\n+ componentDidUpdate(prevProps: Props) {\n+ if (this.props.deviceOrientation !== prevProps.deviceOrientation) {\n+ Orientation.getOrientation(orientation => {\n+ if (orientation !== this.props.deviceOrientation) {\n+ // If the orientation in Redux changes, but it doesn't match what's\n+ // being reported by native, then update Redux. This should only\n+ // happen when importing a frozen app state via React Native Debugger\n+ this.updateOrientation(orientation);\n+ }\n+ });\n+ }\n+ }\n+\nupdateOrientation = orientation => {\nthis.props.dispatchActionPayload(\nupdateDeviceOrientationActionType,\n@@ -43,7 +59,9 @@ class OrientationHandler extends React.PureComponent<Props> {\n}\nexport default connect(\n- null,\n+ (state: AppState) => ({\n+ deviceOrientation: state.deviceOrientation,\n+ }),\nnull,\ntrue,\n)(OrientationHandler);\n" }, { "change_type": "MODIFY", "old_path": "native/redux/dimensions-updater.react.js", "new_path": "native/redux/dimensions-updater.react.js", "diff": "// @flow\n-import type { Dimensions } from 'lib/types/media-types';\n+import { type Dimensions, dimensionsPropType } from 'lib/types/media-types';\nimport type { DispatchActionPayload } from 'lib/utils/action-utils';\n+import type { AppState } from '../redux/redux-setup';\nimport * as React from 'react';\nimport PropTypes from 'prop-types';\n@@ -11,13 +12,16 @@ import { connect } from 'lib/utils/redux-utils';\nimport { updateDimensionsActiveType } from './action-types';\n-type Props = {|\n+type Props = {\n+ // Redux state\n+ dimensions: Dimensions,\n// Redux dispatch functions\ndispatchActionPayload: DispatchActionPayload,\n-|};\n+};\nclass DimensionsUpdater extends React.PureComponent<Props> {\nstatic propTypes = {\n+ dimensions: dimensionsPropType.isRequired,\ndispatchActionPayload: PropTypes.func.isRequired,\n};\n@@ -29,6 +33,24 @@ class DimensionsUpdater extends React.PureComponent<Props> {\nNativeDimensions.removeEventListener('change', this.onDimensionsChange);\n}\n+ componentDidUpdate(prevProps: Props) {\n+ const { height, width } = NativeDimensions.get('window');\n+ if (\n+ (this.props.dimensions.height !== prevProps.dimensions.height ||\n+ this.props.dimensions.width !== prevProps.dimensions.width) &&\n+ (this.props.dimensions.height !== height ||\n+ this.props.dimensions.width !== width)\n+ ) {\n+ // If the dimensions in Redux change, but they don't match what's being\n+ // reported by React Native, then update Redux. This should only happen\n+ // when importing a frozen app state via React Native Debugger\n+ this.props.dispatchActionPayload(\n+ updateDimensionsActiveType,\n+ { height, width },\n+ );\n+ }\n+ }\n+\nonDimensionsChange = (allDimensions: { window: Dimensions }) => {\nconst dimensions = allDimensions.window;\nthis.props.dispatchActionPayload(\n@@ -43,4 +65,10 @@ class DimensionsUpdater extends React.PureComponent<Props> {\n}\n-export default connect(null, null, true)(DimensionsUpdater);\n+export default connect(\n+ (state: AppState) => ({\n+ dimensions: state.dimensions,\n+ }),\n+ null,\n+ true,\n+)(DimensionsUpdater);\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Fix dimensions and orientation after loading a frozen app state
129,187
27.11.2019 15:56:29
18,000
aded38770cfefbfc8dedb5145c6d4551d6e6fd8d
Turn off most handlers when loading a frozen app state
[ { "change_type": "MODIFY", "old_path": "lib/socket/activity-handler.react.js", "new_path": "lib/socket/activity-handler.react.js", "diff": "@@ -26,6 +26,7 @@ import {\ntype Props = {|\nactiveThread: ?string,\n+ frozen: bool,\n// Redux state\nconnection: ConnectionInfo,\nactiveThreadLatestMessage: ?string,\n@@ -41,6 +42,7 @@ class ActivityHandler extends React.PureComponent<Props> {\nstatic propTypes = {\nactiveThread: PropTypes.string,\n+ frozen: PropTypes.bool.isRequired,\nconnection: connectionInfoPropType.isRequired,\nactiveThreadLatestMessage: PropTypes.string,\ndispatchActionPayload: PropTypes.func.isRequired,\n@@ -48,6 +50,11 @@ class ActivityHandler extends React.PureComponent<Props> {\nupdateActivity: PropTypes.func.isRequired,\n};\n+ static canSend(props: Props) {\n+ const { connection: { status }, frozen } = props;\n+ return status === \"connected\" && !frozen;\n+ }\n+\ncomponentDidUpdate(prevProps: Props) {\nconst activityUpdates = [];\nif (this.props.activeThread !== prevProps.activeThread) {\n@@ -69,6 +76,7 @@ class ActivityHandler extends React.PureComponent<Props> {\nconst { status } = this.props.connection;\nconst prevStatus = prevProps.connection.status;\nif (\n+ !this.props.frozen &&\nstatus !== \"connected\" &&\nprevStatus === \"connected\" &&\nthis.props.activeThread\n@@ -90,11 +98,11 @@ class ActivityHandler extends React.PureComponent<Props> {\n);\n}\n- if (status !== \"connected\") {\n+ if (!ActivityHandler.canSend(this.props)) {\nreturn;\n}\n- if (prevStatus !== \"connected\") {\n+ if (!ActivityHandler.canSend(prevProps)) {\nconst { queuedActivityUpdates } = this.props.connection;\nthis.sendActivityUpdates(\n[ ...queuedActivityUpdates, ...activityUpdates ],\n" }, { "change_type": "MODIFY", "old_path": "lib/socket/calendar-query-handler.react.js", "new_path": "lib/socket/calendar-query-handler.react.js", "diff": "@@ -27,6 +27,7 @@ import { getConfig } from '../utils/config';\ntype Props = {|\ncurrentCalendarQuery: () => CalendarQuery,\n+ frozen: bool,\n// Redux state\nconnection: ConnectionInfo,\nlastUserInteractionCalendar: number,\n@@ -42,8 +43,9 @@ type Props = {|\nclass CalendarQueryHandler extends React.PureComponent<Props> {\nstatic propTypes = {\n- connection: connectionInfoPropType.isRequired,\ncurrentCalendarQuery: PropTypes.func.isRequired,\n+ frozen: PropTypes.bool.isRequired,\n+ connection: connectionInfoPropType.isRequired,\nlastUserInteractionCalendar: PropTypes.number.isRequired,\nforeground: PropTypes.bool.isRequired,\ndispatchActionPromise: PropTypes.func.isRequired,\n@@ -103,7 +105,7 @@ class CalendarQueryHandler extends React.PureComponent<Props> {\n}\nget shouldUpdateCalendarQuery() {\n- if (this.props.connection.status !== \"connected\") {\n+ if (this.props.connection.status !== \"connected\" || this.props.frozen) {\nreturn false;\n}\nconst calendarQuery = this.props.currentCalendarQuery();\n" }, { "change_type": "MODIFY", "old_path": "lib/socket/inconsistency-report-handler.react.js", "new_path": "lib/socket/inconsistency-report-handler.react.js", "diff": "@@ -24,6 +24,7 @@ import { ServerError } from '../utils/errors';\ntype Props = {|\nhasWiFi: bool,\n+ frozen: bool,\n// Redux state\nqueuedInconsistencyReports: $ReadOnlyArray<ClientInconsistencyResponse>,\n// Redux dispatch functions\n@@ -37,6 +38,7 @@ class InconsistencyReportHandler extends React.PureComponent<Props> {\nstatic propTypes = {\nhasWiFi: PropTypes.bool.isRequired,\n+ frozen: PropTypes.bool.isRequired,\nqueuedInconsistencyReports: PropTypes.arrayOf(\nclientResponsePropType,\n).isRequired,\n@@ -44,23 +46,26 @@ class InconsistencyReportHandler extends React.PureComponent<Props> {\nsendReport: PropTypes.func.isRequired,\n};\n- componentDidMount() {\n- const { queuedInconsistencyReports, hasWiFi } = this.props;\n- if (queuedInconsistencyReports.length === 0 || !hasWiFi) {\n- return;\n+ static canSend(props: Props) {\n+ const { frozen, hasWiFi } = props;\n+ return !frozen && hasWiFi;\n}\n- this.sendResponses(queuedInconsistencyReports);\n+ componentDidMount() {\n+ if (InconsistencyReportHandler.canSend(this.props)) {\n+ this.sendResponses(this.props.queuedInconsistencyReports);\n+ }\n}\ncomponentDidUpdate(prevProps: Props) {\n- const { queuedInconsistencyReports, hasWiFi } = this.props;\n- if (queuedInconsistencyReports.length === 0 || !hasWiFi) {\n+ const canSend = InconsistencyReportHandler.canSend(this.props);\n+ if (!canSend) {\nreturn;\n}\n- const hadWiFi = prevProps.hasWiFi;\n- if (!hadWiFi) {\n+ const couldSend = InconsistencyReportHandler.canSend(prevProps);\n+ const { queuedInconsistencyReports } = this.props;\n+ if (!couldSend) {\nthis.sendResponses(queuedInconsistencyReports);\nreturn;\n}\n" }, { "change_type": "MODIFY", "old_path": "lib/socket/socket.react.js", "new_path": "lib/socket/socket.react.js", "diff": "@@ -88,6 +88,7 @@ type Props = {|\nconnection: ConnectionInfo,\ncurrentCalendarQuery: () => CalendarQuery,\nhasWiFi: bool,\n+ frozen: bool,\n// Redux dispatch functions\ndispatch: Dispatch,\ndispatchActionPayload: DispatchActionPayload,\n@@ -113,6 +114,7 @@ class Socket extends React.PureComponent<Props, State> {\nconnection: connectionInfoPropType.isRequired,\ncurrentCalendarQuery: PropTypes.func.isRequired,\nhasWiFi: PropTypes.bool.isRequired,\n+ frozen: PropTypes.bool.isRequired,\ndispatch: PropTypes.func.isRequired,\ndispatchActionPayload: PropTypes.func.isRequired,\ndispatchActionPromise: PropTypes.func.isRequired,\n@@ -138,6 +140,9 @@ class Socket extends React.PureComponent<Props, State> {\n}\nopenSocket(newStatus: ConnectionStatus) {\n+ if (this.props.frozen) {\n+ return;\n+ }\nif (this.socket) {\nconst { status } = this.props.connection;\nif (status === \"forcedDisconnecting\") {\n@@ -310,7 +315,10 @@ class Socket extends React.PureComponent<Props, State> {\ninflightRequests={this.state.inflightRequests}\nsendMessage={this.sendMessageWithoutID}\n/>\n- <ActivityHandler activeThread={this.props.activeThread} />\n+ <ActivityHandler\n+ activeThread={this.props.activeThread}\n+ frozen={this.props.frozen}\n+ />\n<RequestResponseHandler\ninflightRequests={this.state.inflightRequests}\nsendMessage={this.sendMessageWithoutID}\n@@ -330,8 +338,12 @@ class Socket extends React.PureComponent<Props, State> {\n/>\n<CalendarQueryHandler\ncurrentCalendarQuery={this.props.currentCalendarQuery}\n+ frozen={this.props.frozen}\n+ />\n+ <InconsistencyReportHandler\n+ hasWiFi={this.props.hasWiFi}\n+ frozen={this.props.frozen}\n/>\n- <InconsistencyReportHandler hasWiFi={this.props.hasWiFi} />\n</React.Fragment>\n);\n}\n" }, { "change_type": "MODIFY", "old_path": "native/chat/message-store-pruner.react.js", "new_path": "native/chat/message-store-pruner.react.js", "diff": "@@ -19,6 +19,7 @@ type Props = {|\nnextMessagePruneTime: ?number,\npruneThreadIDs: () => $ReadOnlyArray<string>,\nforeground: bool,\n+ frozen: bool,\n// Redux dispatch functions\ndispatchActionPayload: DispatchActionPayload,\n|};\n@@ -28,10 +29,14 @@ class MessageStorePruner extends React.PureComponent<Props> {\nnextMessagePruneTime: PropTypes.number,\npruneThreadIDs: PropTypes.func.isRequired,\nforeground: PropTypes.bool.isRequired,\n+ frozen: PropTypes.bool.isRequired,\ndispatchActionPayload: PropTypes.func.isRequired,\n};\ncomponentDidUpdate(prevProps: Props) {\n+ if (this.props.frozen) {\n+ return;\n+ }\nconst { nextMessagePruneTime } = this.props;\nif (nextMessagePruneTime === null || nextMessagePruneTime === undefined) {\nreturn;\n@@ -62,6 +67,7 @@ export default connect(\npruneThreadIDs: pruneThreadIDsSelector(state),\n// We include this so that componentDidUpdate will be called on foreground\nforeground: state.foreground,\n+ frozen: state.frozen,\n}),\nnull,\ntrue,\n" }, { "change_type": "MODIFY", "old_path": "native/socket.react.js", "new_path": "native/socket.react.js", "diff": "@@ -36,6 +36,7 @@ export default connect(\nconnection: state.connection,\ncurrentCalendarQuery: nativeCalendarQuery(state),\nhasWiFi: state.connectivity.hasWiFi,\n+ frozen: state.frozen,\n};\n},\n{ logOut },\n" }, { "change_type": "MODIFY", "old_path": "web/socket.react.js", "new_path": "web/socket.react.js", "diff": "@@ -35,6 +35,7 @@ export default connect(\nconnection: state.connection,\ncurrentCalendarQuery: webCalendarQuery(state),\nhasWiFi: true,\n+ frozen: false,\n};\n},\n{ logOut },\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Turn off most handlers when loading a frozen app state
129,187
27.11.2019 16:14:47
18,000
f4845c7196d2ecd2fb6295eb31f84771ef0a5c9f
[native] Include threadInfo in CalendarItem To avoid weird inconsistencies between Redux state and selector state
[ { "change_type": "MODIFY", "old_path": "native/calendar/calendar.react.js", "new_path": "native/calendar/calendar.react.js", "diff": "@@ -33,6 +33,7 @@ import {\n} from 'lib/types/socket-types';\nimport type { Styles } from '../types/styles';\nimport { type Colors, colorsPropType } from '../themes/colors';\n+import { type ThreadInfo, threadInfoPropType } from 'lib/types/thread-types';\nimport * as React from 'react';\nimport {\n@@ -110,6 +111,7 @@ type CalendarItemWithHeight =\n| {|\nitemType: \"entryInfo\",\nentryInfo: EntryInfoWithHeight,\n+ threadInfo: ThreadInfo,\n|};\ntype ExtraData = $ReadOnly<{|\nactiveEntries: {[key: string]: bool},\n@@ -173,6 +175,7 @@ class Calendar extends React.PureComponent<Props, State> {\nPropTypes.shape({\nitemType: PropTypes.oneOf([\"entryInfo\"]),\nentryInfo: entryInfoPropType.isRequired,\n+ threadInfo: threadInfoPropType.isRequired,\n}),\nPropTypes.shape({\nitemType: PropTypes.oneOf([\"footer\"]),\n@@ -604,6 +607,7 @@ class Calendar extends React.PureComponent<Props, State> {\nitem.entryInfo,\ntextHeight,\n),\n+ threadInfo: item.threadInfo,\n};\n})(listData);\nif (\n@@ -649,6 +653,7 @@ class Calendar extends React.PureComponent<Props, State> {\n<Entry\nnavigation={this.props.navigation}\nentryInfo={item.entryInfo}\n+ threadInfo={item.threadInfo}\nactive={!!this.state.extraData.activeEntries[key]}\nvisible={!!this.state.extraData.visibleEntries[key]}\nmakeActive={this.makeActive}\n" }, { "change_type": "MODIFY", "old_path": "native/calendar/entry.react.js", "new_path": "native/calendar/entry.react.js", "diff": "@@ -61,7 +61,6 @@ import { connect } from 'lib/utils/redux-utils';\nimport { ServerError } from 'lib/utils/errors';\nimport { entryKey } from 'lib/shared/entry-utils';\nimport { registerFetchKey } from 'lib/reducers/loading-reducer';\n-import { threadInfoSelector } from 'lib/selectors/thread-selectors';\nimport { dateString } from 'lib/utils/date-utils';\nimport Button from '../components/button.react';\n@@ -88,6 +87,7 @@ function hueDistance(firstColor: string, secondColor: string): number {\ntype Props = {|\nnavigation: NavigationScreenProp<NavigationRoute>,\nentryInfo: EntryInfoWithHeight,\n+ threadInfo: ThreadInfo,\nvisible: bool,\nactive: bool,\nmakeActive: (entryKey: string, active: bool) => void,\n@@ -95,7 +95,6 @@ type Props = {|\nonPressWhitespace: () => void,\nentryRef: (entryKey: string, entry: ?InternalEntry) => void,\n// Redux state\n- threadInfo: ThreadInfo,\ncalendarQuery: () => CalendarQuery,\nthreadPickerActive: bool,\nforegroundKey: string,\n@@ -114,7 +113,6 @@ type State = {|\ntext: string,\nloadingStatus: LoadingStatus,\nheight: number,\n- threadInfo: ThreadInfo,\n|};\nclass InternalEntry extends React.Component<Props, State> {\n@@ -124,13 +122,13 @@ class InternalEntry extends React.Component<Props, State> {\ngoBack: PropTypes.func.isRequired,\n}).isRequired,\nentryInfo: entryInfoPropType.isRequired,\n+ threadInfo: threadInfoPropType.isRequired,\nvisible: PropTypes.bool.isRequired,\nactive: PropTypes.bool.isRequired,\nmakeActive: PropTypes.func.isRequired,\nonEnterEditMode: PropTypes.func.isRequired,\nonPressWhitespace: PropTypes.func.isRequired,\nentryRef: PropTypes.func.isRequired,\n- threadInfo: threadInfoPropType.isRequired,\ncalendarQuery: PropTypes.func.isRequired,\nthreadPickerActive: PropTypes.bool.isRequired,\nforegroundKey: PropTypes.string.isRequired,\n@@ -153,17 +151,11 @@ class InternalEntry extends React.Component<Props, State> {\nconstructor(props: Props) {\nsuper(props);\n- invariant(props.threadInfo, \"should be set\");\nthis.state = {\nediting: false,\ntext: props.entryInfo.text,\nloadingStatus: \"inactive\",\nheight: props.entryInfo.textHeight,\n- // On log out, it's possible for the thread to be deauthorized before\n- // the log out animation completes. To avoid having rendering issues in\n- // that case, we cache the threadInfo in state and don't reset it when the\n- // threadInfo is undefined.\n- threadInfo: props.threadInfo,\n};\nthis.state.editing = InternalEntry.isActive(props, this.state);\n}\n@@ -199,13 +191,6 @@ class InternalEntry extends React.Component<Props, State> {\nthis.currentlySaving = null;\n}\n- if (\n- this.props.threadInfo &&\n- !_isEqual(this.props.threadInfo)(this.state.threadInfo)\n- ) {\n- this.guardedSetState({ threadInfo: this.props.threadInfo });\n- }\n-\n// Our parent will set the active prop to false if something else gets\n// pressed or if the Entry is scrolled out of view. In either of those cases\n// we should complete the edit process.\n@@ -253,9 +238,9 @@ class InternalEntry extends React.Component<Props, State> {\nrender() {\nconst active = InternalEntry.isActive(this.props, this.state);\nconst { editing } = this.state;\n- const threadColor = `#${this.state.threadInfo.color}`;\n+ const threadColor = `#${this.props.threadInfo.color}`;\n- const darkColor = colorIsDark(this.state.threadInfo.color);\n+ const darkColor = colorIsDark(this.props.threadInfo.color);\nlet actionLinks = null;\nif (active) {\nconst actionLinksColor = darkColor ? '#D3D3D3' : '#404040';\n@@ -356,7 +341,7 @@ class InternalEntry extends React.Component<Props, State> {\n]}\nnumberOfLines={1}\n>\n- {this.state.threadInfo.uiName}\n+ {this.props.threadInfo.uiName}\n</Text>\n</Button>\n</View>\n@@ -665,7 +650,7 @@ class InternalEntry extends React.Component<Props, State> {\nonPressThreadName = () => {\nKeyboard.dismiss();\n- const threadInfo = this.props.threadInfo;\n+ const { threadInfo } = this.props;\nthis.props.navigation.navigate({\nrouteName: ChatRouteName,\nparams: {},\n@@ -767,8 +752,7 @@ const activeThreadPickerSelector =\ncreateIsForegroundSelector(ThreadPickerModalRouteName);\nconst Entry = connect(\n- (state: AppState, ownProps: { entryInfo: EntryInfoWithHeight }) => ({\n- threadInfo: threadInfoSelector(state)[ownProps.entryInfo.threadID],\n+ (state: AppState) => ({\ncalendarQuery: nonThreadCalendarQuery(state),\nthreadPickerActive: activeThreadPickerSelector(state),\nforegroundKey: foregroundKeySelector(state),\n" }, { "change_type": "MODIFY", "old_path": "native/selectors/calendar-selectors.js", "new_path": "native/selectors/calendar-selectors.js", "diff": "import type { EntryInfo } from 'lib/types/entry-types';\nimport type { AppState } from '../redux/redux-setup';\n+import type { ThreadInfo } from 'lib/types/thread-types';\nimport { createSelector } from 'reselect';\nimport _map from 'lodash/fp/map';\nconst _mapWithKeys = _map.convert({ cap: false });\nimport invariant from 'invariant';\n-import { currentDaysToEntries } from 'lib/selectors/thread-selectors';\n+import {\n+ currentDaysToEntries,\n+ threadInfoSelector,\n+} from 'lib/selectors/thread-selectors';\nimport { dateString } from 'lib/utils/date-utils';\nexport type SectionHeaderItem = {|\n@@ -30,15 +34,18 @@ export type CalendarItem =\n| {|\nitemType: \"entryInfo\",\nentryInfo: EntryInfo,\n+ threadInfo: ThreadInfo,\n|};\nconst calendarListData: (state: AppState) => ?CalendarItem[] = createSelector(\n(state: AppState) => !!(state.currentUserInfo &&\n!state.currentUserInfo.anonymous && true),\ncurrentDaysToEntries,\n+ threadInfoSelector,\n(\nloggedIn: bool,\ndaysToEntries: { [dayString: string]: EntryInfo[] },\n+ threadInfos: { [id: string]: ThreadInfo },\n) => {\nif (!loggedIn || daysToEntries[dateString(new Date())] === undefined) {\nreturn null;\n@@ -47,7 +54,10 @@ const calendarListData: (state: AppState) => ?CalendarItem[] = createSelector(\nfor (let dayString in daysToEntries) {\nitems.push({ itemType: \"header\", dateString: dayString });\nfor (let entryInfo of daysToEntries[dayString]) {\n- items.push({ itemType: \"entryInfo\", entryInfo });\n+ const threadInfo = threadInfos[entryInfo.threadID];\n+ if (threadInfo) {\n+ items.push({ itemType: \"entryInfo\", entryInfo, threadInfo });\n+ }\n}\nitems.push({ itemType: \"footer\", dateString: dayString });\n}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Include threadInfo in CalendarItem To avoid weird inconsistencies between Redux state and selector state
129,187
29.11.2019 12:16:14
28,800
01d9601eb24e34259913f52906c5a38462b7b704
[native] Order CameraRoll results on iOS by modification date
[ { "change_type": "ADD", "old_path": null, "new_path": "patches/@react-native-community+cameraroll+1.3.0.patch", "diff": "+diff --git a/node_modules/@react-native-community/cameraroll/ios/.RNCCameraRollManager.m.swp b/node_modules/@react-native-community/cameraroll/ios/.RNCCameraRollManager.m.swp\n+new file mode 100644\n+index 0000000..5f05a91\n+Binary files /dev/null and b/node_modules/@react-native-community/cameraroll/ios/.RNCCameraRollManager.m.swp differ\n+diff --git a/node_modules/@react-native-community/cameraroll/ios/RNCCameraRollManager.m b/node_modules/@react-native-community/cameraroll/ios/RNCCameraRollManager.m\n+index 566d8fc..862aa42 100644\n+--- a/node_modules/@react-native-community/cameraroll/ios/RNCCameraRollManager.m\n++++ b/node_modules/@react-native-community/cameraroll/ios/RNCCameraRollManager.m\n+@@ -236,7 +236,7 @@ static void RCTResolvePromise(RCTPromiseResolveBlock resolve,\n+\n+ // Predicate for fetching assets within a collection\n+ PHFetchOptions *const assetFetchOptions = [RCTConvert PHFetchOptionsFromMediaType:mediaType];\n+- assetFetchOptions.sortDescriptors = @[[NSSortDescriptor sortDescriptorWithKey:@\"creationDate\" ascending:NO]];\n++ assetFetchOptions.sortDescriptors = @[[NSSortDescriptor sortDescriptorWithKey:@\"modificationDate\" ascending:NO]];\n+\n+ BOOL __block foundAfter = NO;\n+ BOOL __block hasNextPage = NO;\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Order CameraRoll results on iOS by modification date
129,187
29.11.2019 12:42:30
28,800
e5fb82c613b1eb36c2dc81a2eaa036717451bc89
[native] Compare compatible URIs for videos in MediaGalleryKeyboard
[ { "change_type": "MODIFY", "old_path": "native/media/media-gallery-keyboard.react.js", "new_path": "native/media/media-gallery-keyboard.react.js", "diff": "@@ -240,7 +240,15 @@ class MediaGalleryKeyboard extends React.PureComponent<Props, State> {\nlet first = true;\nconst mediaInfos = edges.map(\n({ node }) => {\n- const { uri, height, width, filename, playableDuration } = node.image;\n+ const { height, width, filename, playableDuration } = node.image;\n+ const isVideo =\n+ (Platform.OS === \"android\" &&\n+ playableDuration !== null && playableDuration !== undefined) ||\n+ (Platform.OS === \"ios\" && node.type === \"video\");\n+ const uri = isVideo\n+ ? MediaGalleryKeyboard.compatibleURI(node.image.uri, filename)\n+ : node.image.uri;\n+\nif (existingURIs.has(uri)) {\nif (first) {\nfirstRemoved = true;\n@@ -253,19 +261,12 @@ class MediaGalleryKeyboard extends React.PureComponent<Props, State> {\nlastRemoved = false;\nexistingURIs.add(uri);\n- const isVideo =\n- (Platform.OS === \"android\" &&\n- playableDuration !== null && playableDuration !== undefined) ||\n- (Platform.OS === \"ios\" && node.type === \"video\");\n- const compatibleURI = isVideo\n- ? MediaGalleryKeyboard.compatibleURI(uri, filename)\n- : uri;\nif (isVideo) {\nreturn {\ntype: \"video\",\nheight,\nwidth,\n- uri: compatibleURI,\n+ uri,\nfilename,\n};\n} else {\n@@ -273,7 +274,7 @@ class MediaGalleryKeyboard extends React.PureComponent<Props, State> {\ntype: \"photo\",\nheight,\nwidth,\n- uri: compatibleURI,\n+ uri,\n};\n}\n},\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Compare compatible URIs for videos in MediaGalleryKeyboard
129,187
29.11.2019 15:31:17
28,800
5aecadab75cc0a8f7887ebec044aa76b2167c056
[native] getBlobFromURI
[ { "change_type": "MODIFY", "old_path": "native/utils/media-utils.js", "new_path": "native/utils/media-utils.js", "diff": "@@ -14,6 +14,23 @@ import {\nimport { transcodeVideo } from './video-utils';\n+async function getBlobFromURI(\n+ uri: string,\n+ type: MediaType,\n+): Promise<ReactNativeBlob> {\n+ // React Native always resolves FBMediaKit's ph:// scheme as an image so that\n+ // the Image component can render thumbnails of videos. In order to force\n+ // fetch() to return a blob of the video, we need to use the ph-upload://\n+ // scheme. https://git.io/Jerlh\n+ const fbMediaKitURL = uri.startsWith('ph://');\n+ const fixedURI = (fbMediaKitURL && type === \"video\")\n+ ? uri.replace(/^ph:/, 'ph-upload:')\n+ : uri;\n+ const start = Date.now();\n+ const response = await fetch(fixedURI);\n+ return await response.blob();\n+}\n+\ntype ReactNativeBlob =\n& Blob\n& { data: { type: string, name: string, size: number } };\n@@ -51,23 +68,15 @@ async function validateMedia(\n): Promise<?MediaValidationResult> {\nconst { height, width } = mediaInfo;\nconst dimensions = { height, width };\n+ const { uri, type } = mediaInfo;\nif (mediaInfo.type === \"video\") {\nconst { filename } = mediaInfo;\n- return { mediaType: \"video\", uri: mediaInfo.uri, dimensions, filename };\n+ return { mediaType: \"video\", uri, dimensions, filename };\n}\n- // React Native always resolves FBMediaKit's ph:// scheme as an image so that\n- // the Image component can render thumbnails of videos. In order to force\n- // fetch() to return a blob of the video, we need to use the ph-upload://\n- // scheme. https://git.io/Jerlh\n- const fbMediaKitURL = mediaInfo.uri.startsWith('ph://');\n- const uri = (fbMediaKitURL && mediaInfo.type === \"video\")\n- ? mediaInfo.uri.replace(/^ph:/, 'ph-upload:')\n- : mediaInfo.uri;\n-\n- const response = await fetch(uri);\n- const blob = await response.blob();\n- const reportedMIME = (fbMediaKitURL && blob.type === \"application/octet-stream\")\n+ const blob = await getBlobFromURI(uri, type);\n+ const reportedMIME =\n+ (uri.startsWith('ph://') && blob.type === \"application/octet-stream\")\n? \"video/quicktime\"\n: blob.type;\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] getBlobFromURI
129,187
29.11.2019 15:31:27
28,800
d8229ff94244e9704984eddff9d7f10944006c84
[native] Ensure filename set when retrying Video upload
[ { "change_type": "MODIFY", "old_path": "native/chat/chat-input-state-container.react.js", "new_path": "native/chat/chat-input-state-container.react.js", "diff": "@@ -9,7 +9,7 @@ import type {\nDispatchActionPayload,\nDispatchActionPromise,\n} from 'lib/utils/action-utils';\n-import type { UploadMultimediaResult } from 'lib/types/media-types';\n+import type { UploadMultimediaResult, Media } from 'lib/types/media-types';\nimport {\nmessageTypes,\ntype RawMessageInfo,\n@@ -20,6 +20,7 @@ import {\ntype RawMediaMessageInfo,\n} from 'lib/types/message-types';\nimport type { MediaValidationResult } from '../utils/media-utils';\n+import type { GalleryMediaInfo } from '../media/media-gallery-media.react';\nimport * as React from 'react';\nimport PropTypes from 'prop-types';\n@@ -525,7 +526,7 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\n);\n}\n- const incompleteMedia = [];\n+ const incompleteMedia: Media[] = [];\nfor (let singleMedia of newRawMessageInfo.media) {\nif (singleMedia.id.startsWith('localUpload')) {\nincompleteMedia.push(singleMedia);\n@@ -577,17 +578,22 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\n},\n}));\n- const imageGalleryImages = retryMedia.map(singleMedia => {\n+ const galleryMediaInfos: GalleryMediaInfo[] =\n+ retryMedia.map(singleMedia => {\nif (singleMedia.type === \"photo\") {\nconst { dimensions, uri } = singleMedia;\nreturn { type: \"photo\", ...dimensions, uri };\n} else {\nconst { dimensions, uri, filename } = singleMedia;\n+ invariant(\n+ filename,\n+ \"filename should be set on locally created Video\",\n+ );\nreturn { type: \"video\", ...dimensions, uri, filename };\n}\n});\nconst validationResults = await Promise.all(\n- imageGalleryImages.map(validateMedia),\n+ galleryMediaInfos.map(validateMedia),\n);\nconst mediaInfos = [];\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Ensure filename set when retrying Video upload
129,187
02.12.2019 11:19:39
28,800
e9b4b8977222a00cd868656238e20e370e011638
[native] Only dispatch UPDATE_DEVICE_ORIENTATION on changes
[ { "change_type": "MODIFY", "old_path": "native/navigation/orientation-handler.react.js", "new_path": "native/navigation/orientation-handler.react.js", "diff": "@@ -34,23 +34,22 @@ class OrientationHandler extends React.PureComponent<Props> {\ncomponentDidUpdate(prevProps: Props) {\nif (this.props.deviceOrientation !== prevProps.deviceOrientation) {\n- Orientation.getOrientation(orientation => {\n- if (orientation !== this.props.deviceOrientation) {\n- // If the orientation in Redux changes, but it doesn't match what's\n- // being reported by native, then update Redux. This should only\n- // happen when importing a frozen app state via React Native Debugger\n- this.updateOrientation(orientation);\n- }\n- });\n+ // Most of the time, this is triggered as a result of an action dispatched\n+ // by the handler attached above, so the updateOrientation call should be\n+ // a no-op. This conditional is here to correct Redux state when it is\n+ // imported from another device context.\n+ Orientation.getOrientation(this.updateOrientation);\n}\n}\nupdateOrientation = orientation => {\n+ if (orientation !== this.props.deviceOrientation) {\nthis.props.dispatchActionPayload(\nupdateDeviceOrientationActionType,\norientation,\n);\n}\n+ }\nrender() {\nreturn null;\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Only dispatch UPDATE_DEVICE_ORIENTATION on changes
129,187
02.12.2019 12:03:06
28,800
39751d0e95065619bad63e20ca1f0c304579ab28
[native] Only dispatch UPDATE_DIMENSIONS on changes
[ { "change_type": "MODIFY", "old_path": "native/redux/dimensions-updater.react.js", "new_path": "native/redux/dimensions-updater.react.js", "diff": "@@ -34,30 +34,28 @@ class DimensionsUpdater extends React.PureComponent<Props> {\n}\ncomponentDidUpdate(prevProps: Props) {\n- const { height, width } = NativeDimensions.get('window');\nif (\n- (this.props.dimensions.height !== prevProps.dimensions.height ||\n- this.props.dimensions.width !== prevProps.dimensions.width) &&\n- (this.props.dimensions.height !== height ||\n- this.props.dimensions.width !== width)\n+ this.props.dimensions.height !== prevProps.dimensions.height ||\n+ this.props.dimensions.width !== prevProps.dimensions.width\n) {\n- // If the dimensions in Redux change, but they don't match what's being\n- // reported by React Native, then update Redux. This should only happen\n- // when importing a frozen app state via React Native Debugger\n- this.props.dispatchActionPayload(\n- updateDimensionsActiveType,\n- { height, width },\n- );\n+ // Most of the time, this is triggered as a result of an action dispatched\n+ // by the handler attached above, so the onDimensionsChnage call should be\n+ // a no-op. This conditional is here to correct Redux state when it is\n+ // imported from another device context.\n+ this.onDimensionsChange({ window: NativeDimensions.get('window') });\n}\n}\nonDimensionsChange = (allDimensions: { window: Dimensions }) => {\n- const dimensions = allDimensions.window;\n+ const { height: newHeight, width: newWidth } = allDimensions.window;\n+ const { height: oldHeight, width: oldWidth } = this.props.dimensions;\n+ if (newHeight !== oldHeight || newWidth !== oldWidth) {\nthis.props.dispatchActionPayload(\nupdateDimensionsActiveType,\n- dimensions,\n+ { height: newHeight, width: newWidth },\n);\n}\n+ }\nrender() {\nreturn null;\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Only dispatch UPDATE_DIMENSIONS on changes
129,187
02.12.2019 12:09:12
28,800
52ac4189fd161a0b3fd069c76ef2b9622e1ac2e0
[native] Gate Redux-dependent handlers/updaters behind PersistGate
[ { "change_type": "MODIFY", "old_path": "native/app.react.js", "new_path": "native/app.react.js", "diff": "@@ -24,6 +24,7 @@ import { createReduxContainer } from 'react-navigation-redux-helpers';\nimport PropTypes from 'prop-types';\nimport SplashScreen from 'react-native-splash-screen';\nimport Orientation from 'react-native-orientation-locker';\n+import { PersistGate } from 'redux-persist/integration/react';\nimport { connect } from 'lib/utils/redux-utils';\nimport {\n@@ -44,6 +45,7 @@ import PushHandler from './push/push-handler.react';\nimport ThemeHandler from './themes/theme-handler.react';\nimport OrientationHandler from './navigation/orientation-handler.react';\nimport Socket from './socket.react';\n+import { getPersistor } from './redux/persist';\nif (Platform.OS === \"android\") {\nUIManager.setLayoutAnimationEnabledExperimental &&\n@@ -129,20 +131,15 @@ class AppWithNavigationState extends React.PureComponent<Props, State> {\nrender() {\nconst { detectUnsupervisedBackground } = this.state;\n+ const { detectUnsupervisedBackgroundRef } = this;\nconst reactNavigationTheme = this.props.activeTheme\n? this.props.activeTheme\n: 'no-preference';\n- return (\n- <View style={styles.app}>\n+ const gated: React.Node = (\n+ <>\n<Socket\n- detectUnsupervisedBackgroundRef={this.detectUnsupervisedBackgroundRef}\n+ detectUnsupervisedBackgroundRef={detectUnsupervisedBackgroundRef}\n/>\n- <ReduxifiedRootNavigator\n- state={this.props.navigationState}\n- dispatch={this.props.dispatch}\n- theme={reactNavigationTheme}\n- />\n- <ConnectedStatusBar />\n<DisconnectedBarVisibilityHandler />\n<DimensionsUpdater />\n<ConnectivityUpdater />\n@@ -151,6 +148,19 @@ class AppWithNavigationState extends React.PureComponent<Props, State> {\n/>\n<ThemeHandler />\n<OrientationHandler />\n+ </>\n+ );\n+ return (\n+ <View style={styles.app}>\n+ <PersistGate persistor={getPersistor()}>\n+ {gated}\n+ </PersistGate>\n+ <ReduxifiedRootNavigator\n+ state={this.props.navigationState}\n+ dispatch={this.props.dispatch}\n+ theme={reactNavigationTheme}\n+ />\n+ <ConnectedStatusBar />\n</View>\n);\n}\n" }, { "change_type": "MODIFY", "old_path": "native/push/push-handler.react.js", "new_path": "native/push/push-handler.react.js", "diff": "@@ -83,7 +83,6 @@ const supportsTapticFeedback = Platform.OS === \"ios\" &&\ntype Props = {\ndetectUnsupervisedBackground: ?((alreadyClosed: bool) => bool),\n// Redux state\n- rehydrateConcluded: bool,\nunreadCount: number,\nactiveThread: ?string,\nappLoggedIn: bool,\n@@ -113,7 +112,6 @@ class PushHandler extends React.PureComponent<Props, State> {\nstatic propTypes = {\ndetectUnsupervisedBackground: PropTypes.func,\n- rehydrateConcluded: PropTypes.bool.isRequired,\nunreadCount: PropTypes.number.isRequired,\nactiveThread: PropTypes.string,\nappLoggedIn: PropTypes.bool.isRequired,\n@@ -141,12 +139,6 @@ class PushHandler extends React.PureComponent<Props, State> {\ncomponentDidMount() {\nthis.appStarted = Date.now();\nNativeAppState.addEventListener('change', this.handleAppStateChange);\n- if (this.props.rehydrateConcluded) {\n- this.onReduxRehydrate();\n- }\n- }\n-\n- onReduxRehydrate() {\nthis.onForeground();\nif (Platform.OS === \"ios\") {\nNotificationsIOS.addEventListener(\n@@ -263,9 +255,7 @@ class PushHandler extends React.PureComponent<Props, State> {\n}\n}\n- if (this.props.rehydrateConcluded && !prevProps.rehydrateConcluded) {\n- this.onReduxRehydrate();\n- } else if (\n+ if (\n(this.props.appLoggedIn && !prevProps.appLoggedIn) ||\n(!this.props.deviceToken && prevProps.deviceToken)\n) {\n@@ -594,7 +584,6 @@ AppRegistry.registerHeadlessTask(\nexport default connect(\n(state: AppState) => ({\n- rehydrateConcluded: !!(state._persist && state._persist.rehydrated),\nunreadCount: unreadCount(state),\nactiveThread: activeThreadSelector(state),\nappLoggedIn: appLoggedInSelector(state),\n" }, { "change_type": "MODIFY", "old_path": "native/themes/theme-handler.react.js", "new_path": "native/themes/theme-handler.react.js", "diff": "@@ -22,7 +22,6 @@ import { connect } from 'lib/utils/redux-utils';\ntype Props = {|\n// Redux state\nglobalThemeInfo: GlobalThemeInfo,\n- rehydrateConcluded: bool,\n// Redux dispatch functions\ndispatchActionPayload: DispatchActionPayload,\n|};\n@@ -30,37 +29,28 @@ class ThemeHandler extends React.PureComponent<Props> {\nstatic propTypes = {\nglobalThemeInfo: globalThemeInfoPropType.isRequired,\n- rehydrateConcluded: PropTypes.bool.isRequired,\ndispatchActionPayload: PropTypes.func.isRequired,\n};\ncomponentDidMount() {\n- if (this.props.rehydrateConcluded) {\n- this.startListening();\n- }\n- }\n-\n- componentDidUpdate(prevProps: Props) {\n- if (this.props.rehydrateConcluded && !prevProps.rehydrateConcluded) {\n- this.startListening();\n- }\n+ if (!osCanTheme) {\n+ return;\n}\n-\n- componentWillUnmount() {\n- systemThemeEventEmitter.removeListener(\n+ systemThemeEventEmitter.addListener(\n'currentModeChanged',\nthis.updateSystemTheme,\n);\n+ this.updateSystemTheme(initialSystemTheme);\n}\n- startListening() {\n- if (osCanTheme) {\n- systemThemeEventEmitter.addListener(\n+ componentWillUnmount() {\n+ if (!osCanTheme) {\n+ return;\n+ }\n+ systemThemeEventEmitter.removeListener(\n'currentModeChanged',\nthis.updateSystemTheme,\n);\n- this.updateSystemTheme(initialSystemTheme);\n- }\n}\nupdateSystemTheme = (colorScheme: GlobalTheme) => {\n@@ -85,7 +75,6 @@ class ThemeHandler extends React.PureComponent<Props> {\nexport default connect(\n(state: AppState) => ({\nglobalThemeInfo: state.globalThemeInfo,\n- rehydrateConcluded: !!(state._persist && state._persist.rehydrated),\n}),\nnull,\ntrue,\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Gate Redux-dependent handlers/updaters behind PersistGate
129,187
02.12.2019 11:44:08
28,800
213a90d3db8a9c50e9e31b9b2fdd093959ba5504
[lib] Shim uploadURIs on Android for all codeVersions For dev mode
[ { "change_type": "MODIFY", "old_path": "lib/shared/message-utils.js", "new_path": "lib/shared/message-utils.js", "diff": "@@ -24,7 +24,7 @@ import type { RelativeUserInfo } from '../types/user-types';\nimport type { UserInfo } from '../types/user-types';\nimport type { ThreadInfo } from '../types/thread-types';\nimport type { PlatformDetails } from '../types/device-types';\n-import type { Media } from '../types/media-types';\n+import type { Media, Image, Video } from '../types/media-types';\nimport invariant from 'invariant';\nimport _maxBy from 'lodash/fp/maxBy';\n@@ -635,55 +635,97 @@ function shimUnsupportedRawMessageInfos(\n: null;\nreturn rawMessageInfos.map(rawMessageInfo => {\nif (rawMessageInfo.type === messageTypes.IMAGES) {\n+ const shimmedRawMessageInfo = shimMediaMessageInfo(\n+ rawMessageInfo,\n+ platformDetails,\n+ );\nif (codeVersion && codeVersion > 29) {\n- return rawMessageInfo;\n+ return shimmedRawMessageInfo;\n}\n- const { id } = rawMessageInfo;\n+ const { id } = shimmedRawMessageInfo;\ninvariant(id !== null && id !== undefined, \"id should be set on server\");\n- const unsupportedMessageInfo = {\n- ...rawMessageInfo,\n- media: rawMessageInfo.media.map(media => ({\n- ...media,\n- uri: shimUploadURI(media.uri, platformDetails),\n- })),\n- };\nreturn {\ntype: messageTypes.UNSUPPORTED,\nid,\n- threadID: rawMessageInfo.threadID,\n- creatorID: rawMessageInfo.creatorID,\n- time: rawMessageInfo.time,\n- robotext: multimediaMessagePreview(rawMessageInfo),\n- unsupportedMessageInfo,\n+ threadID: shimmedRawMessageInfo.threadID,\n+ creatorID: shimmedRawMessageInfo.creatorID,\n+ time: shimmedRawMessageInfo.time,\n+ robotext: multimediaMessagePreview(shimmedRawMessageInfo),\n+ unsupportedMessageInfo: shimmedRawMessageInfo,\n};\n} else if (rawMessageInfo.type === messageTypes.MULTIMEDIA) {\n+ const shimmedRawMessageInfo = shimMediaMessageInfo(\n+ rawMessageInfo,\n+ platformDetails,\n+ );\n// TODO figure out first native codeVersion supporting video playback\nif (codeVersion && codeVersion > 41) {\n- return rawMessageInfo;\n+ return shimmedRawMessageInfo;\n}\n- const { id } = rawMessageInfo;\n+ const { id } = shimmedRawMessageInfo;\ninvariant(id !== null && id !== undefined, \"id should be set on server\");\n- const unsupportedMessageInfo = {\n- ...rawMessageInfo,\n- media: rawMessageInfo.media.map(media => ({\n- ...media,\n- uri: shimUploadURI(media.uri, platformDetails),\n- })),\n- };\nreturn {\ntype: messageTypes.UNSUPPORTED,\nid,\n- threadID: rawMessageInfo.threadID,\n- creatorID: rawMessageInfo.creatorID,\n- time: rawMessageInfo.time,\n- robotext: multimediaMessagePreview(rawMessageInfo),\n- unsupportedMessageInfo,\n+ threadID: shimmedRawMessageInfo.threadID,\n+ creatorID: shimmedRawMessageInfo.creatorID,\n+ time: shimmedRawMessageInfo.time,\n+ robotext: multimediaMessagePreview(shimmedRawMessageInfo),\n+ unsupportedMessageInfo: shimmedRawMessageInfo,\n};\n}\nreturn rawMessageInfo;\n});\n}\n+function shimMediaMessageInfo(\n+ rawMessageInfo: RawMultimediaMessageInfo,\n+ platformDetails: ?PlatformDetails,\n+): RawMultimediaMessageInfo {\n+ if (rawMessageInfo.type === messageTypes.IMAGES) {\n+ let uriChanged = false;\n+ const newMedia: Image[] = [];\n+ for (let singleMedia of rawMessageInfo.media) {\n+ const shimmedURI = shimUploadURI(singleMedia.uri, platformDetails);\n+ if (shimmedURI === singleMedia.uri) {\n+ newMedia.push(singleMedia);\n+ } else {\n+ newMedia.push(({ ...singleMedia, uri: shimmedURI }: Image));\n+ uriChanged = true;\n+ }\n+ }\n+ if (!uriChanged) {\n+ return rawMessageInfo;\n+ }\n+ return ({\n+ ...rawMessageInfo,\n+ media: newMedia,\n+ }: RawImagesMessageInfo);\n+ } else {\n+ let uriChanged = false;\n+ const newMedia: Media[] = [];\n+ for (let singleMedia of rawMessageInfo.media) {\n+ const shimmedURI = shimUploadURI(singleMedia.uri, platformDetails);\n+ if (shimmedURI === singleMedia.uri) {\n+ newMedia.push(singleMedia);\n+ } else if (singleMedia.type === \"photo\") {\n+ newMedia.push(({ ...singleMedia, uri: shimmedURI }: Image));\n+ uriChanged = true;\n+ } else {\n+ newMedia.push(({ ...singleMedia, uri: shimmedURI }: Video));\n+ uriChanged = true;\n+ }\n+ }\n+ if (!uriChanged) {\n+ return rawMessageInfo;\n+ }\n+ return ({\n+ ...rawMessageInfo,\n+ media: newMedia,\n+ }: RawMediaMessageInfo);\n+ }\n+}\n+\nfunction messagePreviewText(\nmessageInfo: PreviewableMessageInfo,\nthreadInfo: ThreadInfo,\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[lib] Shim uploadURIs on Android for all codeVersions For dev mode
129,187
02.12.2019 18:55:49
28,800
9d2c18095c95e73348d7cdfdbdac0c9011bd2cac
[native] Use dimensions from react-native-video
[ { "change_type": "MODIFY", "old_path": "native/chat/chat-input-state.js", "new_path": "native/chat/chat-input-state.js", "diff": "// @flow\n-import type { Dimensions } from 'lib/types/media-types';\nimport type { GalleryMediaInfo } from '../media/media-gallery-media.react';\nimport * as React from 'react';\n" }, { "change_type": "MODIFY", "old_path": "native/media/media-gallery-keyboard.react.js", "new_path": "native/media/media-gallery-keyboard.react.js", "diff": "@@ -77,6 +77,7 @@ class MediaGalleryKeyboard extends React.PureComponent<Props, State> {\nqueueModeProgress = new Animated.Value(0);\nsendButtonStyle: ViewStyle;\nmediaSelected = false;\n+ realVideoDimensions = new Map();\nconstructor(props: Props) {\nsuper(props);\n@@ -351,6 +352,7 @@ class MediaGalleryKeyboard extends React.PureComponent<Props, State> {\nsetFocus={this.setFocus}\nscreenWidth={this.state.screenWidth}\ncolors={this.props.colors}\n+ setRealVideoDimensions={this.setRealVideoDimensions}\n/>\n);\n}\n@@ -512,7 +514,18 @@ class MediaGalleryKeyboard extends React.PureComponent<Props, State> {\nreturn;\n}\nthis.mediaSelected = true;\n- KeyboardRegistry.onItemSelected(mediaGalleryKeyboardName, mediaInfos);\n+ const fixedVideoDimensionsMediaInfos = mediaInfos.map(mediaInfo => {\n+ const fixedDimensions = this.realVideoDimensions.get(mediaInfo.uri);\n+ return fixedDimensions ? { ...mediaInfo, ...fixedDimensions } : mediaInfo;\n+ });\n+ KeyboardRegistry.onItemSelected(\n+ mediaGalleryKeyboardName,\n+ fixedVideoDimensionsMediaInfos,\n+ );\n+ }\n+\n+ setRealVideoDimensions = (compatibleURI: string, dimensions: Dimensions) => {\n+ this.realVideoDimensions.set(compatibleURI, dimensions);\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "native/media/media-gallery-media.react.js", "new_path": "native/media/media-gallery-media.react.js", "diff": "// @flow\n-import {\n- type Dimensions,\n- type MediaType,\n- mediaTypePropType,\n-} from 'lib/types/media-types';\n+import { type Dimensions, mediaTypePropType } from 'lib/types/media-types';\nimport type { ViewStyle, ImageStyle } from '../types/styles';\nimport { type Colors, colorsPropType } from '../themes/colors';\n@@ -69,6 +65,10 @@ type Props = {|\nsetFocus: (media: GalleryMediaInfo, isFocused: bool) => void,\nscreenWidth: number,\ncolors: Colors,\n+ setRealVideoDimensions: (\n+ compatibleURI: string,\n+ dimensions: Dimensions,\n+ ) => void,\n|};\nclass MediaGalleryMedia extends React.PureComponent<Props> {\n@@ -89,6 +89,7 @@ class MediaGalleryMedia extends React.PureComponent<Props> {\nsetFocus: PropTypes.func.isRequired,\nscreenWidth: PropTypes.number.isRequired,\ncolors: colorsPropType.isRequired,\n+ setRealVideoDimensions: PropTypes.func.isRequired,\n};\nbackdrop: ?TouchableOpacity;\nfocusProgress = new Reanimated.Value(0);\n@@ -280,6 +281,7 @@ class MediaGalleryMedia extends React.PureComponent<Props> {\nsource={source}\nrepeat={true}\nstyle={dimensionsStyle}\n+ onLoad={this.onVideoLoad}\n/>\n<Reanimated.View style={this.videoOverlayStyle} />\n</Reanimated.View>\n@@ -391,6 +393,15 @@ class MediaGalleryMedia extends React.PureComponent<Props> {\nthis.animatingBackdropToZero = false;\n}\n+ onVideoLoad = (videoLoadProps: {\n+ naturalSize: { height: number, width: number, ... },\n+ ...\n+ }) => {\n+ const { height, width } = videoLoadProps.naturalSize;\n+ const { uri } = this.props.mediaInfo;\n+ this.props.setRealVideoDimensions(uri, { height, width });\n+ }\n+\n}\nconst buttonStyle = {\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Use dimensions from react-native-video
129,187
05.12.2019 22:15:10
18,000
dc2f71ca43ba7e1906b28c46cc61c6458e85e79a
[native] Load App's ConnectedStatusBar first
[ { "change_type": "MODIFY", "old_path": "native/app.react.js", "new_path": "native/app.react.js", "diff": "@@ -152,6 +152,7 @@ class AppWithNavigationState extends React.PureComponent<Props, State> {\n);\nreturn (\n<View style={styles.app}>\n+ <ConnectedStatusBar />\n<PersistGate persistor={getPersistor()}>\n{gated}\n</PersistGate>\n@@ -160,7 +161,6 @@ class AppWithNavigationState extends React.PureComponent<Props, State> {\ndispatch={this.props.dispatch}\ntheme={reactNavigationTheme}\n/>\n- <ConnectedStatusBar />\n</View>\n);\n}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Load App's ConnectedStatusBar first
129,187
06.12.2019 00:18:59
18,000
64a9c675a4a8a860134333a54ba4b91b72a1d0a2
[native] mediaGalleryThreadID in KeyboardStateContainer
[ { "change_type": "MODIFY", "old_path": "native/chat/chat-input-bar.react.js", "new_path": "native/chat/chat-input-bar.react.js", "diff": "@@ -320,7 +320,7 @@ class ChatInputBar extends React.PureComponent<Props, State> {\n<View style={this.props.styles.innerExpandoButtons}>\n{this.state.buttonsExpanded ? expandoButton : null}\n<TouchableOpacity\n- onPress={this.openMediaGallery}\n+ onPress={this.showMediaGallery}\nactiveOpacity={0.4}\n>\n<Animated.View style={this.cameraRollIconStyle}>\n@@ -554,12 +554,16 @@ class ChatInputBar extends React.PureComponent<Props, State> {\n});\n}\n- openMediaGallery = () => {\n- this.setMediaGalleryOpen(true);\n+ showMediaGallery = () => {\n+ const { keyboardState } = this.props;\n+ invariant(keyboardState, \"keyboardState should be initialized\");\n+ keyboardState.showMediaGallery(this.props.threadInfo.id);\n}\nhideMediaGallery = () => {\n- this.setMediaGalleryOpen(false);\n+ const { keyboardState } = this.props;\n+ invariant(keyboardState, \"keyboardState should be initialized\");\n+ keyboardState.hideMediaGallery();\n}\nonMediaGalleryItemSelected = (\n@@ -572,12 +576,6 @@ class ChatInputBar extends React.PureComponent<Props, State> {\nchatInputState.sendMultimediaMessage(this.props.threadInfo.id, imageInfos);\n}\n- setMediaGalleryOpen(mediaGalleryOpen: bool) {\n- const { keyboardState } = this.props;\n- invariant(keyboardState, \"keyboardState should be initialized\");\n- keyboardState.setMediaGalleryOpen(mediaGalleryOpen);\n- }\n-\ndismissKeyboard = () => {\nconst { keyboardState } = this.props;\nkeyboardState && keyboardState.dismissKeyboard();\n" }, { "change_type": "MODIFY", "old_path": "native/keyboard/keyboard-state-container.react.js", "new_path": "native/keyboard/keyboard-state-container.react.js", "diff": "@@ -17,6 +17,7 @@ type Props = {|\ntype State = {|\nsystemKeyboardShowing: bool,\nmediaGalleryOpen: bool,\n+ mediaGalleryThreadID: ?string,\n|};\nclass KeyboardStateContainer extends React.PureComponent<Props, State> {\n@@ -26,6 +27,7 @@ class KeyboardStateContainer extends React.PureComponent<Props, State> {\nstate = {\nsystemKeyboardShowing: false,\nmediaGalleryOpen: false,\n+ mediaGalleryThreadID: null,\n};\nkeyboardShowListener: ?Object;\nkeyboardDismissListener: ?Object;\n@@ -73,8 +75,12 @@ class KeyboardStateContainer extends React.PureComponent<Props, State> {\nreturn systemKeyboardShowing || mediaGalleryOpen;\n}\n- setMediaGalleryOpen = (mediaGalleryOpen: bool) => {\n- this.setState({ mediaGalleryOpen });\n+ showMediaGallery = (threadID: string) => {\n+ this.setState({ mediaGalleryOpen: true, mediaGalleryThreadID: threadID });\n+ }\n+\n+ hideMediaGallery = () => {\n+ this.setState({ mediaGalleryOpen: false });\n}\nrender() {\n@@ -83,7 +89,8 @@ class KeyboardStateContainer extends React.PureComponent<Props, State> {\nkeyboardShowing,\ndismissKeyboard,\ndismissKeyboardIfShowing,\n- setMediaGalleryOpen,\n+ showMediaGallery,\n+ hideMediaGallery,\n} = this;\nconst keyboardState = {\nkeyboardShowing,\n@@ -91,7 +98,8 @@ class KeyboardStateContainer extends React.PureComponent<Props, State> {\ndismissKeyboardIfShowing,\nsystemKeyboardShowing,\nmediaGalleryOpen,\n- setMediaGalleryOpen,\n+ showMediaGallery,\n+ hideMediaGallery,\n};\nreturn (\n<KeyboardContext.Provider value={keyboardState}>\n" }, { "change_type": "MODIFY", "old_path": "native/keyboard/keyboard-state.js", "new_path": "native/keyboard/keyboard-state.js", "diff": "@@ -9,7 +9,8 @@ export type KeyboardState = {|\ndismissKeyboardIfShowing: () => bool,\nsystemKeyboardShowing: bool,\nmediaGalleryOpen: bool,\n- setMediaGalleryOpen: (mediaGalleryOpen: bool) => void,\n+ showMediaGallery: (threadID: string) => void,\n+ hideMediaGallery: () => void,\n|};\nconst keyboardStatePropType = PropTypes.shape({\n@@ -18,7 +19,8 @@ const keyboardStatePropType = PropTypes.shape({\ndismissKeyboardIfShowing: PropTypes.func.isRequired,\nsystemKeyboardShowing: PropTypes.bool.isRequired,\nmediaGalleryOpen: PropTypes.bool.isRequired,\n- setMediaGalleryOpen: PropTypes.func.isRequired,\n+ showMediaGallery: PropTypes.func.isRequired,\n+ hideMediaGallery: PropTypes.func.isRequired,\n});\nconst KeyboardContext = React.createContext<?KeyboardState>(null);\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] mediaGalleryThreadID in KeyboardStateContainer
129,187
06.12.2019 00:52:06
18,000
f1c3654c01218a406f16ba2a29d951dadbb04157
[native] KeyboardInputHost
[ { "change_type": "MODIFY", "old_path": "native/chat/chat-input-bar.react.js", "new_path": "native/chat/chat-input-bar.react.js", "diff": "@@ -22,7 +22,6 @@ import type { LoadingStatus } from 'lib/types/loading-types';\nimport { loadingStatusPropType } from 'lib/types/loading-types';\nimport type { CalendarQuery } from 'lib/types/entry-types';\nimport type { KeyboardEvent } from '../keyboard/keyboard';\n-import type { GalleryMediaInfo } from '../media/media-gallery-media.react';\nimport {\ntype KeyboardState,\nkeyboardStatePropType,\n@@ -51,10 +50,7 @@ import FAIcon from 'react-native-vector-icons/FontAwesome';\nimport PropTypes from 'prop-types';\nimport invariant from 'invariant';\nimport Animated, { Easing } from 'react-native-reanimated';\n-import {\n- KeyboardAccessoryView,\n- TextInputKeyboardMangerIOS,\n-} from 'react-native-keyboard-input';\n+import { TextInputKeyboardMangerIOS } from 'react-native-keyboard-input';\nimport _throttle from 'lodash/throttle';\nimport { connect } from 'lib/utils/redux-utils';\n@@ -73,12 +69,9 @@ import { createLoadingStatusSelector } from 'lib/selectors/loading-selectors';\nimport Button from '../components/button.react';\nimport { nonThreadCalendarQuery } from '../selectors/nav-selectors';\nimport { getKeyboardHeight } from '../keyboard/keyboard';\n-import {\n- mediaGalleryKeyboardName,\n-} from '../media/media-gallery-keyboard.react';\n-import { ChatInputStateContext } from './chat-input-state';\nimport { colorsSelector, styleSelector } from '../themes/colors';\nimport { CameraModalRouteName } from '../navigation/route-names';\n+import KeyboardInputHost from '../keyboard/keyboard-input-host.react';\nconst draftKeyFromThreadID =\n(threadID: string) => `${threadID}/message_composer`;\n@@ -130,7 +123,6 @@ class ChatInputBar extends React.PureComponent<Props, State> {\nsendTextMessage: PropTypes.func.isRequired,\njoinThread: PropTypes.func.isRequired,\n};\n- static contextType = ChatInputStateContext;\ntextInput: ?TextInput;\nexpandOpacity: Animated.Value;\nexpandoButtonsOpacity: Animated.Value;\n@@ -396,27 +388,11 @@ class ChatInputBar extends React.PureComponent<Props, State> {\n}\n}\n- let keyboardAccessoryView = null;\n- const imageGalleryIsOpen = ChatInputBar.mediaGalleryOpen(this.props);\n- if (Platform.OS !== \"android\" || imageGalleryIsOpen) {\n- const kbComponent = imageGalleryIsOpen ? mediaGalleryKeyboardName : null;\n- keyboardAccessoryView = (\n- <KeyboardAccessoryView\n- kbInputRef={this.textInput}\n- kbComponent={kbComponent}\n- kbInitialProps={this.props.styles.kbInitialProps}\n- onItemSelected={this.onMediaGalleryItemSelected}\n- onKeyboardResigned={this.hideMediaGallery}\n- manageScrollView={false}\n- />\n- );\n- }\n-\nreturn (\n<View style={this.props.styles.container}>\n{joinButton}\n{content}\n- {keyboardAccessoryView}\n+ <KeyboardInputHost textInputRef={this.textInput} />\n</View>\n);\n}\n@@ -560,22 +536,6 @@ class ChatInputBar extends React.PureComponent<Props, State> {\nkeyboardState.showMediaGallery(this.props.threadInfo.id);\n}\n- hideMediaGallery = () => {\n- const { keyboardState } = this.props;\n- invariant(keyboardState, \"keyboardState should be initialized\");\n- keyboardState.hideMediaGallery();\n- }\n-\n- onMediaGalleryItemSelected = (\n- keyboardName: string,\n- imageInfos: $ReadOnlyArray<GalleryMediaInfo>,\n- ) => {\n- this.dismissKeyboard();\n- const chatInputState = this.context;\n- invariant(chatInputState, \"chatInputState should be set in ChatInputBar\");\n- chatInputState.sendMultimediaMessage(this.props.threadInfo.id, imageInfos);\n- }\n-\ndismissKeyboard = () => {\nconst { keyboardState } = this.props;\nkeyboardState && keyboardState.dismissKeyboard();\n@@ -663,9 +623,6 @@ const styles = {\njoinThreadLoadingIndicator: {\npaddingVertical: 2,\n},\n- kbInitialProps: {\n- backgroundColor: 'listBackground',\n- },\n};\nconst stylesSelector = styleSelector(styles);\n" }, { "change_type": "ADD", "old_path": null, "new_path": "native/keyboard/keyboard-input-host.react.js", "diff": "+// @flow\n+\n+import type { AppState } from '../redux/redux-setup';\n+import type { Styles } from '../types/styles';\n+import {\n+ type ChatInputState,\n+ chatInputStatePropType,\n+ withChatInputState,\n+} from '../chat/chat-input-state';\n+import {\n+ type KeyboardState,\n+ keyboardStatePropType,\n+ withKeyboardState,\n+} from '../keyboard/keyboard-state';\n+import type { GalleryMediaInfo } from '../media/media-gallery-media.react';\n+\n+import * as React from 'react';\n+import PropTypes from 'prop-types';\n+import { TextInput } from 'react-native';\n+import { KeyboardAccessoryView } from 'react-native-keyboard-input';\n+import invariant from 'invariant';\n+\n+import { connect } from 'lib/utils/redux-utils';\n+\n+import { styleSelector } from '../themes/colors';\n+import {\n+ mediaGalleryKeyboardName,\n+} from '../media/media-gallery-keyboard.react';\n+\n+type Props = {|\n+ textInputRef: ?TextInput,\n+ // Redux state\n+ styles: Styles,\n+ // withKeyboardState\n+ keyboardState: ?KeyboardState,\n+ // withChatInput\n+ chatInputState: ?ChatInputState,\n+|};\n+class KeyboardInputHost extends React.PureComponent<Props> {\n+\n+ static propTypes = {\n+ textInputRef: PropTypes.instanceOf(TextInput),\n+ styles: PropTypes.objectOf(PropTypes.object).isRequired,\n+ keyboardState: keyboardStatePropType,\n+ chatInputState: chatInputStatePropType,\n+ };\n+\n+ static mediaGalleryOpen(props: Props) {\n+ const { keyboardState } = props;\n+ return !!(keyboardState && keyboardState.mediaGalleryOpen);\n+ }\n+\n+ render() {\n+ const imageGalleryIsOpen = KeyboardInputHost.mediaGalleryOpen(this.props);\n+ if (Platform.OS === \"android\" && !imageGalleryIsOpen) {\n+ return null;\n+ }\n+ const kbComponent = imageGalleryIsOpen ? mediaGalleryKeyboardName : null;\n+ return (\n+ <KeyboardAccessoryView\n+ kbInputRef={this.props.textInputRef}\n+ kbComponent={kbComponent}\n+ kbInitialProps={this.props.styles.kbInitialProps}\n+ onItemSelected={this.onMediaGalleryItemSelected}\n+ onKeyboardResigned={this.hideMediaGallery}\n+ manageScrollView={false}\n+ />\n+ );\n+ }\n+\n+ onMediaGalleryItemSelected = (\n+ keyboardName: string,\n+ mediaInfos: $ReadOnlyArray<GalleryMediaInfo>,\n+ ) => {\n+ const { keyboardState } = this.props;\n+ invariant(\n+ keyboardState,\n+ \"keyboardState should be set in onMediaGalleryItemSelected\",\n+ );\n+ keyboardState.dismissKeyboard();\n+ const mediaGalleryThreadID = keyboardState.getMediaGalleryThreadID();\n+ if (mediaGalleryThreadID === null || mediaGalleryThreadID === undefined) {\n+ return;\n+ }\n+\n+ const { chatInputState } = this.props;\n+ invariant(\n+ chatInputState,\n+ \"chatInputState should be set in onMediaGalleryItemSelected\",\n+ );\n+\n+ // We do this for Flow\n+ const mappedMediaInfos = [];\n+ for (let mediaInfo of mediaInfos) {\n+ if (mediaInfo.type === \"photo\") {\n+ mappedMediaInfos.push({ ...mediaInfo });\n+ } else {\n+ mappedMediaInfos.push({ ...mediaInfo });\n+ }\n+ }\n+\n+ chatInputState.sendMultimediaMessage(\n+ mediaGalleryThreadID,\n+ mappedMediaInfos,\n+ );\n+ }\n+\n+ hideMediaGallery = () => {\n+ const { keyboardState } = this.props;\n+ invariant(keyboardState, \"keyboardState should be initialized\");\n+ keyboardState.hideMediaGallery();\n+ }\n+\n+}\n+\n+const styles = {\n+ kbInitialProps: {\n+ backgroundColor: 'listBackground',\n+ },\n+};\n+const stylesSelector = styleSelector(styles);\n+\n+export default connect((state: AppState) => ({\n+ styles: stylesSelector(state),\n+}))(withKeyboardState(withChatInputState(KeyboardInputHost)));\n" }, { "change_type": "MODIFY", "old_path": "native/keyboard/keyboard-state-container.react.js", "new_path": "native/keyboard/keyboard-state-container.react.js", "diff": "// @flow\n+import type { GalleryMediaInfo } from '../media/media-gallery-media.react';\n+\nimport * as React from 'react';\nimport PropTypes from 'prop-types';\nimport { KeyboardUtils } from 'react-native-keyboard-input';\n@@ -80,9 +82,11 @@ class KeyboardStateContainer extends React.PureComponent<Props, State> {\n}\nhideMediaGallery = () => {\n- this.setState({ mediaGalleryOpen: false });\n+ this.setState({ mediaGalleryOpen: false, mediaGalleryThreadID: null });\n}\n+ getMediaGalleryThreadID = () => this.state.mediaGalleryThreadID;\n+\nrender() {\nconst { systemKeyboardShowing, mediaGalleryOpen } = this.state;\nconst {\n@@ -91,6 +95,7 @@ class KeyboardStateContainer extends React.PureComponent<Props, State> {\ndismissKeyboardIfShowing,\nshowMediaGallery,\nhideMediaGallery,\n+ getMediaGalleryThreadID,\n} = this;\nconst keyboardState = {\nkeyboardShowing,\n@@ -100,6 +105,7 @@ class KeyboardStateContainer extends React.PureComponent<Props, State> {\nmediaGalleryOpen,\nshowMediaGallery,\nhideMediaGallery,\n+ getMediaGalleryThreadID,\n};\nreturn (\n<KeyboardContext.Provider value={keyboardState}>\n" }, { "change_type": "MODIFY", "old_path": "native/keyboard/keyboard-state.js", "new_path": "native/keyboard/keyboard-state.js", "diff": "@@ -11,6 +11,7 @@ export type KeyboardState = {|\nmediaGalleryOpen: bool,\nshowMediaGallery: (threadID: string) => void,\nhideMediaGallery: () => void,\n+ getMediaGalleryThreadID: () => ?string,\n|};\nconst keyboardStatePropType = PropTypes.shape({\n@@ -21,6 +22,7 @@ const keyboardStatePropType = PropTypes.shape({\nmediaGalleryOpen: PropTypes.bool.isRequired,\nshowMediaGallery: PropTypes.func.isRequired,\nhideMediaGallery: PropTypes.func.isRequired,\n+ getMediaGalleryThreadID: PropTypes.func.isRequired,\n});\nconst KeyboardContext = React.createContext<?KeyboardState>(null);\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] KeyboardInputHost
129,187
06.12.2019 01:02:57
18,000
b452a914b647b0e2c17baeab442a9593b6e71878
[native] Render KeyboardInputHost higher up the component tree on Android
[ { "change_type": "MODIFY", "old_path": "native/chat/chat-input-bar.react.js", "new_path": "native/chat/chat-input-bar.react.js", "diff": "@@ -388,11 +388,15 @@ class ChatInputBar extends React.PureComponent<Props, State> {\n}\n}\n+ const keyboardInputHost = Platform.OS === \"android\"\n+ ? null\n+ : <KeyboardInputHost textInputRef={this.textInput} />;\n+\nreturn (\n<View style={this.props.styles.container}>\n{joinButton}\n{content}\n- <KeyboardInputHost textInputRef={this.textInput} />\n+ {keyboardInputHost}\n</View>\n);\n}\n" }, { "change_type": "MODIFY", "old_path": "native/keyboard/keyboard-input-host.react.js", "new_path": "native/keyboard/keyboard-input-host.react.js", "diff": "@@ -51,11 +51,9 @@ class KeyboardInputHost extends React.PureComponent<Props> {\n}\nrender() {\n- const imageGalleryIsOpen = KeyboardInputHost.mediaGalleryOpen(this.props);\n- if (Platform.OS === \"android\" && !imageGalleryIsOpen) {\n- return null;\n- }\n- const kbComponent = imageGalleryIsOpen ? mediaGalleryKeyboardName : null;\n+ const kbComponent = KeyboardInputHost.mediaGalleryOpen(this.props)\n+ ? mediaGalleryKeyboardName\n+ : null;\nreturn (\n<KeyboardAccessoryView\nkbInputRef={this.props.textInputRef}\n" }, { "change_type": "MODIFY", "old_path": "native/keyboard/keyboard-state-container.react.js", "new_path": "native/keyboard/keyboard-state-container.react.js", "diff": "@@ -5,6 +5,7 @@ import type { GalleryMediaInfo } from '../media/media-gallery-media.react';\nimport * as React from 'react';\nimport PropTypes from 'prop-types';\nimport { KeyboardUtils } from 'react-native-keyboard-input';\n+import { Platform } from 'react-native';\nimport {\naddKeyboardShowListener,\n@@ -12,6 +13,7 @@ import {\nremoveKeyboardListener,\n} from './keyboard';\nimport { KeyboardContext } from './keyboard-state';\n+import KeyboardInputHost from './keyboard-input-host.react';\ntype Props = {|\nchildren: React.Node,\n@@ -107,9 +109,13 @@ class KeyboardStateContainer extends React.PureComponent<Props, State> {\nhideMediaGallery,\ngetMediaGalleryThreadID,\n};\n+ const keyboardInputHost = (Platform.OS === \"android\" && mediaGalleryOpen)\n+ ? <KeyboardInputHost />\n+ : null;\nreturn (\n<KeyboardContext.Provider value={keyboardState}>\n{this.props.children}\n+ {keyboardInputHost}\n</KeyboardContext.Provider>\n);\n}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Render KeyboardInputHost higher up the component tree on Android
129,187
06.12.2019 01:20:47
18,000
207316298082a2f03a96a44b474a05bd9a3e3161
[native] Undo Android 4 hacks We had hacks in place to avoid StackOverflows during draw, but we fixed this by decreasing draw tree depth by moving `KeyboardInputHost` to a lower level.
[ { "change_type": "MODIFY", "old_path": "native/chat/message.react.js", "new_path": "native/chat/message.react.js", "diff": "@@ -25,12 +25,7 @@ import {\n} from '../keyboard/keyboard-state';\nimport * as React from 'react';\n-import {\n- View,\n- LayoutAnimation,\n- TouchableWithoutFeedback,\n- Platform,\n-} from 'react-native';\n+import { View, LayoutAnimation, TouchableWithoutFeedback } from 'react-native';\nimport PropTypes from 'prop-types';\nimport { TextMessage, textMessageItemHeight } from './text-message.react';\n@@ -127,12 +122,6 @@ class Message extends React.PureComponent<Props> {\n/>\n);\n}\n- if (Platform.OS === \"android\" && Platform.Version < 21) {\n- // On old Android 4.4 devices, we can get a stack overflow during draw\n- // when we use the TouchableWithoutFeedback below. It's just too deep of\n- // a stack for the old hardware to handle\n- return message;\n- }\nreturn (\n<TouchableWithoutFeedback onPress={this.dismissKeyboard}>\n{message}\n" }, { "change_type": "MODIFY", "old_path": "native/media/media-gallery-keyboard.react.js", "new_path": "native/media/media-gallery-keyboard.react.js", "diff": "@@ -328,10 +328,7 @@ class MediaGalleryKeyboard extends React.PureComponent<Props, State> {\n}\nget queueModeActive() {\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.queuedMediaURIs ||\n- (Platform.OS === \"android\" && Platform.Version < 21);\n+ return !!this.state.queuedMediaURIs;\n}\nrenderItem = (row: { item: GalleryMediaInfo }) => {\n" }, { "change_type": "MODIFY", "old_path": "native/media/media-gallery-media.react.js", "new_path": "native/media/media-gallery-media.react.js", "diff": "@@ -52,7 +52,6 @@ const reanimatedSpec = {\nduration: 400,\neasing: ReanimatedEasing.inOut(ReanimatedEasing.ease),\n};\n-const isAndroid44 = Platform.OS === \"android\" && Platform.Version < 21;\ntype Props = {|\nmediaInfo: GalleryMediaInfo,\n@@ -91,10 +90,9 @@ class MediaGalleryMedia extends React.PureComponent<Props> {\ncolors: colorsPropType.isRequired,\nsetRealVideoDimensions: PropTypes.func.isRequired,\n};\n- backdrop: ?TouchableOpacity;\nfocusProgress = new Reanimated.Value(0);\nbuttonsStyle: ViewStyle;\n- backdropProgress: ?Reanimated.Value;\n+ backdropProgress = new Reanimated.Value(0);\nanimatingBackdropToZero = false;\nimageStyle: ImageStyle;\nvideoContainerStyle: ViewStyle;\n@@ -126,15 +124,12 @@ class MediaGalleryMedia extends React.PureComponent<Props> {\noutputRange: [ 1, 1.3 ],\n},\n);\n- if (isAndroid44) {\n- this.imageStyle = {\n+ this.videoContainerStyle = {\ntransform: [\n{ scale: mediaScale },\n],\n};\n- this.videoOverlayStyle = {};\n- } else {\n- this.backdropProgress = new Reanimated.Value(0);\n+\nconst backdropOpacity = Reanimated.interpolate(\nthis.backdropProgress,\n{\n@@ -148,6 +143,7 @@ class MediaGalleryMedia extends React.PureComponent<Props> {\n{ scale: mediaScale },\n],\n};\n+\nconst overlayOpacity = Reanimated.interpolate(\nthis.backdropProgress,\n{\n@@ -161,12 +157,6 @@ class MediaGalleryMedia extends React.PureComponent<Props> {\nbackgroundColor: props.colors.listBackground,\n};\n}\n- this.videoContainerStyle = {\n- transform: [\n- { scale: mediaScale },\n- ],\n- };\n- }\nstatic isActive(props: Props) {\nreturn props.isFocused || props.isQueued;\n@@ -177,7 +167,7 @@ class MediaGalleryMedia extends React.PureComponent<Props> {\nconst isActive = MediaGalleryMedia.isActive(this.props);\nconst wasActive = MediaGalleryMedia.isActive(prevProps);\n- const { backdrop, backdropProgress } = this;\n+ const { backdropProgress } = this;\nif (isActive && !wasActive) {\nif (backdropProgress) {\nReanimated.timing(\n@@ -185,9 +175,6 @@ class MediaGalleryMedia extends React.PureComponent<Props> {\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@@ -200,9 +187,6 @@ class MediaGalleryMedia extends React.PureComponent<Props> {\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@@ -297,35 +281,6 @@ class MediaGalleryMedia extends React.PureComponent<Props> {\n);\n}\n- const checkAnimation = (\n- <LottieView\n- source={require('../animations/check.json')}\n- progress={this.checkProgress}\n- style={styles.checkAnimation}\n- resizeMode=\"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- {media}\n- </TouchableOpacity>\n- <Reanimated.View style={this.buttonsStyle} pointerEvents=\"none\">\n- {checkAnimation}\n- </Reanimated.View>\n- </View>\n- );\n- }\n-\nreturn (\n<View style={[ styles.container, dimensionsStyle ]}>\n<GenericTouchable\n@@ -335,7 +290,12 @@ class MediaGalleryMedia extends React.PureComponent<Props> {\n>\n{media}\n<Reanimated.View style={this.buttonsStyle}>\n- {checkAnimation}\n+ <LottieView\n+ source={require('../animations/check.json')}\n+ progress={this.checkProgress}\n+ style={styles.checkAnimation}\n+ resizeMode=\"cover\"\n+ />\n</Reanimated.View>\n</GenericTouchable>\n<Reanimated.View\n@@ -348,10 +308,6 @@ class MediaGalleryMedia extends React.PureComponent<Props> {\n);\n}\n- backdropRef = (backdrop: ?TouchableOpacity) => {\n- this.backdrop = backdrop;\n- }\n-\nonPressBackdrop = () => {\nif (this.props.isQueued) {\nthis.props.setMediaQueued(this.props.mediaInfo, false);\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Undo Android 4 hacks We had hacks in place to avoid StackOverflows during draw, but we fixed this by decreasing draw tree depth by moving `KeyboardInputHost` to a lower level.
129,187
06.12.2019 01:25:20
18,000
dce8abc7297edc92cb21cf21b517340c6e433c75
[native] Dismiss keyboard before showing CameraModal
[ { "change_type": "MODIFY", "old_path": "native/chat/chat-input-bar.react.js", "new_path": "native/chat/chat-input-bar.react.js", "diff": "@@ -528,6 +528,7 @@ class ChatInputBar extends React.PureComponent<Props, State> {\n}\nopenCamera = () => {\n+ this.dismissKeyboard();\nthis.props.navigation.navigate({\nrouteName: CameraModalRouteName,\nparams: { threadID: this.props.threadInfo.id },\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Dismiss keyboard before showing CameraModal
129,187
06.12.2019 11:44:59
18,000
c5e3b986a13b894e859155d66059b273eb6aef6f
[native] visible -> showDisconnectedBar in DisconnectedBar
[ { "change_type": "MODIFY", "old_path": "native/navigation/disconnected-bar.react.js", "new_path": "native/navigation/disconnected-bar.react.js", "diff": "@@ -9,16 +9,17 @@ import PropTypes from 'prop-types';\nimport { connect } from 'lib/utils/redux-utils';\ntype Props = {|\n- visible: bool,\n+ // Redux state\n+ showDisconnectedBar: bool,\n|};\nclass DisconnectedBar extends React.PureComponent<Props> {\nstatic propTypes = {\n- visible: PropTypes.bool.isRequired,\n+ showDisconnectedBar: PropTypes.bool.isRequired,\n};\ncomponentDidUpdate(prevProps: Props) {\n- if (this.props.visible !== prevProps.visible) {\n+ if (this.props.showDisconnectedBar !== prevProps.showDisconnectedBar) {\nLayoutAnimation.easeInEaseOut();\n}\n}\n@@ -26,7 +27,7 @@ class DisconnectedBar extends React.PureComponent<Props> {\nrender() {\nconst disconnectedBarStyles = [ styles.disconnectedBar ];\nlet text;\n- if (this.props.visible) {\n+ if (this.props.showDisconnectedBar) {\ntext = <Text style={styles.disconnectedText}>DISCONNECTED</Text>;\n} else {\ndisconnectedBarStyles.push(styles.hiddenDisconnectedBar);\n@@ -53,5 +54,5 @@ const styles = StyleSheet.create({\n});\nexport default connect((state: AppState) => ({\n- visible: state.connection.showDisconnectedBar,\n+ showDisconnectedBar: state.connection.showDisconnectedBar,\n}))(DisconnectedBar);\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] visible -> showDisconnectedBar in DisconnectedBar
129,187
06.12.2019 13:17:36
18,000
b55f060868bc1af8d92f1a509f8948a948967b66
[native] Don't animate DisconnectedBar if it isn't visible
[ { "change_type": "MODIFY", "old_path": "native/calendar/calendar.react.js", "new_path": "native/calendar/calendar.react.js", "diff": "@@ -786,7 +786,9 @@ class Calendar extends React.PureComponent<Props, State> {\n}\nreturn (\n<SafeAreaView style={this.props.styles.container}>\n- <DisconnectedBar />\n+ <DisconnectedBar\n+ visible={this.props.calendarActive}\n+ />\n<TextHeightMeasurer\ntextToMeasure={this.state.textToMeasure}\nallHeightsMeasuredCallback={this.allHeightsMeasured}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "native/chat/chat-header.react.js", "diff": "+// @flow\n+\n+import type { AppState } from '../redux/redux-setup';\n+import type { HeaderProps } from 'react-navigation-stack';\n+\n+import * as React from 'react';\n+\n+import { connect } from 'lib/utils/redux-utils';\n+\n+import Header from '../navigation/header.react';\n+import { createActiveTabSelector } from '../selectors/nav-selectors';\n+import { ChatRouteName } from '../navigation/route-names';\n+\n+const activeTabSelector = createActiveTabSelector(ChatRouteName);\n+\n+const ChatHeader = connect((state: AppState) => ({\n+ activeTab: activeTabSelector(state),\n+}))(Header);\n+\n+export default (props: $Exact<HeaderProps>) => (<ChatHeader {...props} />);\n" }, { "change_type": "MODIFY", "old_path": "native/chat/chat-navigator.react.js", "new_path": "native/chat/chat-navigator.react.js", "diff": "@@ -23,8 +23,8 @@ import {\nMessageListRouteName,\nChatThreadListRouteName,\n} from '../navigation/route-names';\n-import Header from '../navigation/header.react';\nimport HeaderBackButton from '../navigation/header-back-button.react';\n+import ChatHeader from './chat-header.react';\nconst ChatNavigator = createStackNavigator(\n{\n@@ -36,7 +36,7 @@ const ChatNavigator = createStackNavigator(\n},\n{\ndefaultNavigationOptions: ({ navigation }) => ({\n- header: Header,\n+ header: ChatHeader,\nheaderLeft: navigation.isFirstRouteInParent()\n? undefined\n: HeaderBackButton,\n" }, { "change_type": "ADD", "old_path": null, "new_path": "native/more/more-header.react.js", "diff": "+// @flow\n+\n+import type { AppState } from '../redux/redux-setup';\n+import type { HeaderProps } from 'react-navigation-stack';\n+\n+import * as React from 'react';\n+\n+import { connect } from 'lib/utils/redux-utils';\n+\n+import Header from '../navigation/header.react';\n+import { createActiveTabSelector } from '../selectors/nav-selectors';\n+import { MoreRouteName } from '../navigation/route-names';\n+\n+const activeTabSelector = createActiveTabSelector(MoreRouteName);\n+\n+const MoreHeader = connect((state: AppState) => ({\n+ activeTab: activeTabSelector(state),\n+}))(Header);\n+\n+export default (props: $Exact<HeaderProps>) => (<MoreHeader {...props} />);\n" }, { "change_type": "MODIFY", "old_path": "native/more/more.react.js", "new_path": "native/more/more.react.js", "diff": "// @flow\n-import React from 'react';\n+import * as React from 'react';\nimport { StyleSheet, Platform } from 'react-native';\nimport Icon from 'react-native-vector-icons/FontAwesome';\nimport { createStackNavigator } from 'react-navigation-stack';\n@@ -21,7 +21,7 @@ import {\nDevToolsRouteName,\nAppearancePreferencesRouteName,\n} from '../navigation/route-names';\n-import Header from '../navigation/header.react';\n+import MoreHeader from './more-header.react';\nimport HeaderBackButton from '../navigation/header-back-button.react';\nconst More = createStackNavigator(\n@@ -36,7 +36,7 @@ const More = createStackNavigator(\n},\n{\ndefaultNavigationOptions: ({ navigation }) => ({\n- header: Header,\n+ header: MoreHeader,\nheaderLeft: navigation.isFirstRouteInParent()\n? undefined\n: HeaderBackButton,\n" }, { "change_type": "MODIFY", "old_path": "native/navigation/disconnected-bar.react.js", "new_path": "native/navigation/disconnected-bar.react.js", "diff": "@@ -9,17 +9,20 @@ import PropTypes from 'prop-types';\nimport { connect } from 'lib/utils/redux-utils';\ntype Props = {|\n+ visible: bool,\n// Redux state\nshowDisconnectedBar: bool,\n|};\nclass DisconnectedBar extends React.PureComponent<Props> {\nstatic propTypes = {\n+ visible: PropTypes.bool.isRequired,\nshowDisconnectedBar: PropTypes.bool.isRequired,\n};\ncomponentDidUpdate(prevProps: Props) {\n- if (this.props.showDisconnectedBar !== prevProps.showDisconnectedBar) {\n+ const { visible, showDisconnectedBar } = this.props;\n+ if (visible && showDisconnectedBar !== prevProps.showDisconnectedBar) {\nLayoutAnimation.easeInEaseOut();\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "native/navigation/header.react.js", "new_path": "native/navigation/header.react.js", "diff": "// @flow\n+import type { HeaderProps } from 'react-navigation-stack';\n+\nimport * as React from 'react';\nimport { Header } from 'react-navigation-stack';\nimport { View } from 'react-native';\nimport DisconnectedBar from './disconnected-bar.react';\n-export default function CustomHeader(props: React.ElementProps<typeof Header>) {\n+type Props = {|\n+ activeTab: bool,\n+ ...$Exact<HeaderProps>,\n+|};\n+export default function CustomHeader(props: Props) {\n+ const { activeTab, ...rest } = props;\nreturn (\n<View>\n- <Header {...props} />\n- <DisconnectedBar />\n+ <Header {...rest} />\n+ <DisconnectedBar visible={activeTab} />\n</View>\n);\n}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Don't animate DisconnectedBar if it isn't visible
129,187
06.12.2019 15:08:16
18,000
fedb66f98ad454ad9f439234779ae8633a5002f6
[native] Customize react-native-video builds 1. On iOS, use the caching functionality 2. On Android, force it to use the older MediaPlayer (currently the default but likely to change)
[ { "change_type": "MODIFY", "old_path": "native/ios/Podfile", "new_path": "native/ios/Podfile", "diff": "@@ -31,6 +31,7 @@ target 'SquadCal' do\npod 'KeyboardTrackingView', :path => '../../node_modules/react-native-keyboard-tracking-view'\npod 'ReactNativeKeyboardInput', :path => '../../node_modules/react-native-keyboard-input'\npod 'react-native-ffmpeg/min-lts', :podspec => '../../node_modules/react-native-ffmpeg/ios/react-native-ffmpeg.podspec'\n+ pod 'react-native-video/VideoCaching', :podspec => '../../node_modules/react-native-video/react-native-video.podspec'\nuse_native_modules!(\"..\")\nend\n" }, { "change_type": "MODIFY", "old_path": "native/ios/Podfile.lock", "new_path": "native/ios/Podfile.lock", "diff": "@@ -2,6 +2,7 @@ PODS:\n- 1PasswordExtension (1.8.5)\n- boost-for-react-native (1.63.0)\n- DoubleConversion (1.1.6)\n+ - DVAssetLoaderDelegate (0.3.3)\n- Folly (2018.10.22.00):\n- boost-for-react-native\n- DoubleConversion\n@@ -105,11 +106,13 @@ PODS:\n- React\n- react-native-splash-screen (3.2.0):\n- React\n- - react-native-video (5.0.2):\n- - React\n- - react-native-video/Video (= 5.0.2)\n- react-native-video/Video (5.0.2):\n- React\n+ - react-native-video/VideoCaching (5.0.2):\n+ - DVAssetLoaderDelegate (~> 0.3.1)\n+ - React\n+ - react-native-video/Video\n+ - SPTPersistentCache (~> 1.1.0)\n- React-RCTActionSheet (0.60.6):\n- React-Core (= 0.60.6)\n- React-RCTAnimation (0.60.6):\n@@ -163,6 +166,7 @@ PODS:\n- SDWebImageWebPCoder (0.2.4):\n- libwebp (~> 1.0)\n- SDWebImage/Core (~> 5.0)\n+ - SPTPersistentCache (1.1.0)\n- yoga (0.60.6.React)\nDEPENDENCIES:\n@@ -191,7 +195,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-native-video (from `../../node_modules/react-native-video`)\n+ - react-native-video/VideoCaching (from `../../node_modules/react-native-video/react-native-video.podspec`)\n- React-RCTActionSheet (from `../../node_modules/react-native/Libraries/ActionSheetIOS`)\n- React-RCTAnimation (from `../../node_modules/react-native/Libraries/NativeAnimation`)\n- React-RCTBlob (from `../../node_modules/react-native/Libraries/Blob`)\n@@ -219,10 +223,12 @@ SPEC REPOS:\nhttps://github.com/cocoapods/specs.git:\n- 1PasswordExtension\n- boost-for-react-native\n+ - DVAssetLoaderDelegate\n- libwebp\n- mobile-ffmpeg-min\n- SDWebImage\n- SDWebImageWebPCoder\n+ - SPTPersistentCache\nEXTERNAL SOURCES:\nDoubleConversion:\n@@ -276,7 +282,7 @@ EXTERNAL SOURCES:\nreact-native-splash-screen:\n:path: \"../../node_modules/react-native-splash-screen\"\nreact-native-video:\n- :path: \"../../node_modules/react-native-video\"\n+ :podspec: \"../../node_modules/react-native-video/react-native-video.podspec\"\nReact-RCTActionSheet:\n:path: \"../../node_modules/react-native/Libraries/ActionSheetIOS\"\nReact-RCTAnimation:\n@@ -326,6 +332,7 @@ SPEC CHECKSUMS:\n1PasswordExtension: 0e95bdea64ec8ff2f4f693be5467a09fac42a83d\nboost-for-react-native: 39c7adb57c4e60d6c5479dd8623128eb5b3f0f2c\nDoubleConversion: 5805e889d232975c086db112ece9ed034df7a0b2\n+ DVAssetLoaderDelegate: 0caec20e4e08b8560b691131539e9180024d4bce\nFolly: 30e7936e1c45c08d884aa59369ed951a8e68cf51\nglog: 1f3da668190260b06b429bb211bfbee5cd790c28\nKeyboardTrackingView: fd40d2a0acc26bcc923f39b8ad65d834ac5af217\n@@ -376,8 +383,9 @@ SPEC CHECKSUMS:\nRNVectorIcons: 0bb4def82230be1333ddaeee9fcba45f0b288ed4\nSDWebImage: 96d7f03415ccb28d299d765f93557ff8a617abd8\nSDWebImageWebPCoder: cc72085bb20368b2f8dbb21b7e355c667e1309b7\n+ SPTPersistentCache: df36ea46762d7cf026502bbb86a8b79d0080dff4\nyoga: 5079887aa3e4c62142d6bcee493022643ee4d730\n-PODFILE CHECKSUM: 639918298b7631941d4e1e0c7a2007f9981bf939\n+PODFILE CHECKSUM: bef973e63f300f7e85c0d1f71f5d64ee8926e9e4\nCOCOAPODS: 1.7.5\n" }, { "change_type": "MODIFY", "old_path": "native/react-native.config.js", "new_path": "native/react-native.config.js", "diff": "@@ -2,5 +2,9 @@ module.exports = {\ndependencies: {\n'react-native-firebase': { platforms: { ios: null } },\n'react-native-notifications': { platforms: { android: null } },\n+ 'react-native-video': { platforms: {\n+ android: { sourceDir: '../node_modules/react-native-video/android' },\n+ ios: null,\n+ } },\n},\n};\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Customize react-native-video builds 1. On iOS, use the caching functionality 2. On Android, force it to use the older MediaPlayer (currently the default but likely to change)
129,187
09.12.2019 15:13:40
18,000
7d83930d3cc835b5b477798278ac93948f6f363c
[web] Address GHSA-h9rv-jmmf-4pgx vulnerability Versions of `serialize-javascript` before 2.1.1 are vulnerable
[ { "change_type": "MODIFY", "old_path": "yarn.lock", "new_path": "yarn.lock", "diff": "@@ -11055,15 +11055,10 @@ serialize-error@^2.1.0:\nresolved \"https://registry.yarnpkg.com/serialize-error/-/serialize-error-2.1.0.tgz#50b679d5635cdf84667bdc8e59af4e5b81d5f60a\"\nintegrity sha1-ULZ51WNc34Rme9yOWa9OW4HV9go=\n-serialize-javascript@^1.7.0:\n- version \"1.9.1\"\n- resolved \"https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-1.9.1.tgz#cfc200aef77b600c47da9bb8149c943e798c2fdb\"\n- integrity sha512-0Vb/54WJ6k5v8sSWN09S0ora+Hnr+cX40r9F170nT+mSkaxltoE/7R3OrIdBSUv1OoiobH1QoWQbCnAO+e8J1A==\n-\n-serialize-javascript@^2.1.0:\n- version \"2.1.0\"\n- resolved \"https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-2.1.0.tgz#9310276819efd0eb128258bb341957f6eb2fc570\"\n- integrity sha512-a/mxFfU00QT88umAJQsNWOnUKckhNCqOl028N48e7wFmo2/EHpTo9Wso+iJJCMrQnmFvcjto5RJdAHEvVhcyUQ==\n+serialize-javascript@^2.1.0, serialize-javascript@^2.1.1:\n+ version \"2.1.2\"\n+ resolved \"https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-2.1.2.tgz#ecec53b0e0317bdc95ef76ab7074b7384785fa61\"\n+ integrity sha512-rs9OggEUF0V4jUSecXazOYsLfu7OGK2qIn3c7IPBiffz32XniEp/TX9Xmc9LQfK2nQ2QKHvZ2oygKUGU0lG4jQ==\nserve-index@^1.9.1:\nversion \"1.9.1\"\n@@ -11870,15 +11865,15 @@ term-size@^1.2.0:\nexeca \"^0.7.0\"\nterser-webpack-plugin@^1.4.1:\n- version \"1.4.1\"\n- resolved \"https://registry.yarnpkg.com/terser-webpack-plugin/-/terser-webpack-plugin-1.4.1.tgz#61b18e40eaee5be97e771cdbb10ed1280888c2b4\"\n- integrity sha512-ZXmmfiwtCLfz8WKZyYUuuHf3dMYEjg8NrjHMb0JqHVHVOSkzp3cW2/XG1fP3tRhqEqSzMwzzRQGtAPbs4Cncxg==\n+ version \"1.4.2\"\n+ resolved \"https://registry.yarnpkg.com/terser-webpack-plugin/-/terser-webpack-plugin-1.4.2.tgz#e23c0d554587d1f473bd0cf68627720e733890a4\"\n+ integrity sha512-fdEb91kR2l+BVgES77N/NTXWZlpX6vX+pYPjnX5grcDYBF2CMnzJiXX4NNlna4l04lvCW39lZ+O/jSvUhHH/ew==\ndependencies:\ncacache \"^12.0.2\"\nfind-cache-dir \"^2.1.0\"\nis-wsl \"^1.1.0\"\nschema-utils \"^1.0.0\"\n- serialize-javascript \"^1.7.0\"\n+ serialize-javascript \"^2.1.1\"\nsource-map \"^0.6.1\"\nterser \"^4.1.2\"\nwebpack-sources \"^1.4.0\"\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[web] Address GHSA-h9rv-jmmf-4pgx vulnerability Versions of `serialize-javascript` before 2.1.1 are vulnerable
129,187
13.12.2019 14:29:27
18,000
cc8dfb4283291a1fcb00e9cb8488c11a69cbd211
[native] Minor typo correction
[ { "change_type": "MODIFY", "old_path": "native/components/button.react.js", "new_path": "native/components/button.react.js", "diff": "@@ -92,7 +92,7 @@ class Button extends React.PureComponent<Props> {\ninvariant(\nunderlayColor,\n\"iosHighlightUnderlayColor should be specified to Button in \" +\n- \"format='higlight'\",\n+ \"format='highlight'\",\n);\nconst child = this.props.children ? this.props.children : <View />;\nreturn (\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Minor typo correction
129,187
17.12.2019 14:00:42
18,000
5fee7252e21a77726c6cd16ba175c9e9bdc5ba68
[native] Don't update activity when displaying chat modals
[ { "change_type": "MODIFY", "old_path": "native/navigation/route-names.js", "new_path": "native/navigation/route-names.js", "diff": "@@ -55,3 +55,9 @@ export const scrollBlockingChatModals = [\nTextMessageTooltipModalRouteName,\nThreadSettingsMemberTooltipModalRouteName,\n];\n+\n+export const chatRootModals = [\n+ AddUsersModalRouteName,\n+ ColorPickerModalRouteName,\n+ ComposeSubthreadModalRouteName,\n+];\n" }, { "change_type": "MODIFY", "old_path": "native/selectors/nav-selectors.js", "new_path": "native/selectors/nav-selectors.js", "diff": "@@ -26,6 +26,7 @@ import {\nActionResultModalRouteName,\naccountModals,\nscrollBlockingChatModals,\n+ chatRootModals,\n} from '../navigation/route-names';\nimport {\nassertNavigationRouteNotLeafNode,\n@@ -127,10 +128,17 @@ const lightboxTransitioningSelector: (state: AppState) => bool = createSelector(\nconst activeThreadSelector: (state: AppState) => ?string = createSelector(\n(state: AppState) => state.navInfo.navigationState,\n(navigationState: NavigationState): ?string => {\n- const currentRootSubroute = navigationState.routes[navigationState.index];\n- if (currentRootSubroute.routeName !== AppRouteName) {\n+ let rootIndex = navigationState.index;\n+ let currentRootSubroute = navigationState.routes[rootIndex];\n+ while (currentRootSubroute.routeName !== AppRouteName) {\n+ if (!chatRootModals.includes(currentRootSubroute.routeName)) {\nreturn null;\n}\n+ if (rootIndex === 0) {\n+ return null;\n+ }\n+ currentRootSubroute = navigationState.routes[--rootIndex];\n+ }\nconst appRoute = assertNavigationRouteNotLeafNode(currentRootSubroute);\nconst [ firstAppSubroute ] = appRoute.routes;\nif (firstAppSubroute.routeName !== TabNavigatorRouteName) {\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Don't update activity when displaying chat modals
129,187
17.12.2019 14:24:58
18,000
e966c88d93e100ba366ad0810309fbbe735e8686
[native] Determine ColorPickerModal height based on screenDimensions
[ { "change_type": "MODIFY", "old_path": "native/chat/settings/color-picker-modal.react.js", "new_path": "native/chat/settings/color-picker-modal.react.js", "diff": "@@ -14,6 +14,7 @@ import {\n} from 'lib/types/thread-types';\nimport type { Styles } from '../../types/styles';\nimport { type Colors, colorsPropType } from '../../themes/colors';\n+import { type Dimensions, dimensionsPropType } from 'lib/types/media-types';\nimport * as React from 'react';\nimport PropTypes from 'prop-types';\n@@ -30,6 +31,7 @@ import { createModal } from '../../components/modal.react';\nimport { AddUsersModalRouteName } from '../../navigation/route-names';\nimport ColorPicker from '../../components/color-picker.react';\nimport { colorsSelector, styleSelector } from '../../themes/colors';\n+import { dimensionsSelector } from '../../selectors/dimension-selectors';\nconst Modal = createModal(AddUsersModalRouteName);\ntype NavProp = NavigationScreenProp<{|\n@@ -46,6 +48,7 @@ type Props = {|\n// Redux state\ncolors: Colors,\nstyles: Styles,\n+ screenDimensions: Dimensions,\n// Redux dispatch functions\ndispatchActionPromise: DispatchActionPromise,\n// async functions that hit server APIs\n@@ -68,16 +71,20 @@ class ColorPickerModal extends React.PureComponent<Props> {\n}).isRequired,\ncolors: colorsPropType.isRequired,\nstyles: PropTypes.objectOf(PropTypes.object).isRequired,\n+ screenDimensions: dimensionsPropType.isRequired,\ndispatchActionPromise: PropTypes.func.isRequired,\nchangeThreadSettings: PropTypes.func.isRequired,\n};\nrender() {\nconst { color, threadInfo } = this.props.navigation.state.params;\n+ // Based on the assumption we are always in portrait,\n+ // and consequently width is the lowest dimensions\n+ const modalStyle = { height: this.props.screenDimensions.width - 5 };\nreturn (\n<Modal\nnavigation={this.props.navigation}\n- modalStyle={this.props.styles.colorPickerContainer}\n+ modalStyle={[ this.props.styles.colorPickerContainer, modalStyle ]}\n>\n<ColorPicker\ndefaultColor={color}\n@@ -145,7 +152,6 @@ class ColorPickerModal extends React.PureComponent<Props> {\nconst styles = {\ncolorPickerContainer: {\nflex: 0,\n- height: 370,\nbackgroundColor: 'modalBackground',\nmarginVertical: 20,\nmarginHorizontal: 15,\n@@ -178,6 +184,7 @@ export default connect(\n(state: AppState) => ({\ncolors: colorsSelector(state),\nstyles: stylesSelector(state),\n+ screenDimensions: dimensionsSelector(state),\n}),\n{ changeThreadSettings },\n)(ColorPickerModal);\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Determine ColorPickerModal height based on screenDimensions
129,187
17.12.2019 17:25:54
18,000
36e62939d0f3ea4c23f44a7832c79ff0712df1d8
[native] Fix media orientation in Android CameraRoll This makes things work on Android 4.4. Who knows what it does to newer Android devices...
[ { "change_type": "MODIFY", "old_path": "patches/@react-native-community+cameraroll+1.3.0.patch", "new_path": "patches/@react-native-community+cameraroll+1.3.0.patch", "diff": "-diff --git a/node_modules/@react-native-community/cameraroll/ios/.RNCCameraRollManager.m.swp b/node_modules/@react-native-community/cameraroll/ios/.RNCCameraRollManager.m.swp\n-new file mode 100644\n-index 0000000..5f05a91\n-Binary files /dev/null and b/node_modules/@react-native-community/cameraroll/ios/.RNCCameraRollManager.m.swp differ\n+diff --git a/node_modules/@react-native-community/cameraroll/android/src/main/java/com/reactnativecommunity/cameraroll/CameraRollModule.java b/node_modules/@react-native-community/cameraroll/android/src/main/java/com/reactnativecommunity/cameraroll/CameraRollModule.java\n+index 1e01f7a..831c46b 100644\n+--- a/node_modules/@react-native-community/cameraroll/android/src/main/java/com/reactnativecommunity/cameraroll/CameraRollModule.java\n++++ b/node_modules/@react-native-community/cameraroll/android/src/main/java/com/reactnativecommunity/cameraroll/CameraRollModule.java\n+@@ -13,6 +13,7 @@ import android.content.Context;\n+ import android.content.res.AssetFileDescriptor;\n+ import android.database.Cursor;\n+ import android.graphics.BitmapFactory;\n++import android.media.ExifInterface;\n+ import android.media.MediaMetadataRetriever;\n+ import android.media.MediaScannerConnection;\n+ import android.net.Uri;\n+@@ -439,13 +440,21 @@ public class CameraRollModule extends ReactContextBaseJavaModule {\n+ retriever.setDataSource(photoDescriptor.getFileDescriptor());\n+\n+ try {\n+- if (width <= 0 || height <= 0) {\n+- width =\n+- Integer.parseInt(\n+- retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_WIDTH));\n+- height =\n+- Integer.parseInt(\n+- retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_HEIGHT));\n++ int videoWidth = Integer.parseInt(\n++ retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_WIDTH)\n++ );\n++ int videoHeight = Integer.parseInt(\n++ retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_HEIGHT)\n++ );\n++ int orientation = Integer.parseInt(\n++ retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_ROTATION)\n++ );\n++ if (Math.abs(orientation) % 180 == 90) {\n++ width = videoHeight;\n++ height = videoWidth;\n++ } else {\n++ width = videoWidth;\n++ height = videoHeight;\n+ }\n+ int timeInMillisec =\n+ Integer.parseInt(\n+@@ -467,6 +476,24 @@ public class CameraRollModule extends ReactContextBaseJavaModule {\n+ FLog.e(ReactConstants.TAG, \"Could not get video metadata for \" + photoUri.toString(), e);\n+ return false;\n+ }\n++ } else {\n++ try {\n++ ExifInterface exif = new ExifInterface(photoUri.toString().substring(7));\n++ int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);\n++ if (\n++ orientation == ExifInterface.ORIENTATION_ROTATE_90 ||\n++ orientation == ExifInterface.ORIENTATION_ROTATE_270 ||\n++ orientation == ExifInterface.ORIENTATION_TRANSPOSE ||\n++ orientation == ExifInterface.ORIENTATION_TRANSVERSE\n++ ) {\n++ float oldHeight = height;\n++ height = width;\n++ width = oldHeight;\n++ }\n++ } catch (IOException e) {\n++ FLog.e(ReactConstants.TAG, \"Could not get EXIF info for \" + photoUri.toString(), e);\n++ return false;\n++ }\n+ }\n+\n+ if (width <= 0 || height <= 0) {\ndiff --git a/node_modules/@react-native-community/cameraroll/ios/RNCCameraRollManager.m b/node_modules/@react-native-community/cameraroll/ios/RNCCameraRollManager.m\nindex 566d8fc..862aa42 100644\n--- a/node_modules/@react-native-community/cameraroll/ios/RNCCameraRollManager.m\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Fix media orientation in Android CameraRoll This makes things work on Android 4.4. Who knows what it does to newer Android devices...
129,187
17.12.2019 18:13:50
18,000
b0fe0ffb0d87a181553bc48cdff45200d04accad
[native] Instantly reflect theme updates in ThreadList and UserList
[ { "change_type": "MODIFY", "old_path": "native/components/thread-list.react.js", "new_path": "native/components/thread-list.react.js", "diff": "@@ -54,13 +54,19 @@ class ThreadList extends React.PureComponent<Props, State> {\n(propsAndState: PropsAndState) => propsAndState.threadInfos,\n(propsAndState: PropsAndState) => propsAndState.searchText,\n(propsAndState: PropsAndState) => propsAndState.searchResults,\n+ (propsAndState: PropsAndState) => propsAndState.itemStyle,\n+ (propsAndState: PropsAndState) => propsAndState.itemTextStyle,\n(\nthreadInfos: $ReadOnlyArray<ThreadInfo>,\ntext: string,\nsearchResults: Set<string>,\n+ itemStyle: ?ViewStyle,\n+ itemTextStyle: ?TextStyle,\n) => text\n? threadInfos.filter(threadInfo => searchResults.has(threadInfo.id))\n- : threadInfos,\n+ // We spread to make sure the result of this selector updates when\n+ // any input param (namely itemStyle or itemTextStyle) changes\n+ : [ ...threadInfos ],\n);\nget listData() {\n" }, { "change_type": "MODIFY", "old_path": "native/components/user-list.react.js", "new_path": "native/components/user-list.react.js", "diff": "@@ -32,6 +32,7 @@ class UserList extends React.PureComponent<Props> {\ngetItemLayout={UserList.getItemLayout}\nkeyboardShouldPersistTaps=\"handled\"\ninitialNumToRender={20}\n+ extraData={this.props.itemTextStyle}\n/>\n);\n}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Instantly reflect theme updates in ThreadList and UserList
129,187
18.12.2019 10:03:52
18,000
ce649cfdb52f2b16c2a42329967fb1385015fa41
[native] Don't use dimensions from react-native-video anymore `CameraRoll` should now return the correct dimensions... we hope...
[ { "change_type": "MODIFY", "old_path": "native/media/media-gallery-keyboard.react.js", "new_path": "native/media/media-gallery-keyboard.react.js", "diff": "@@ -77,7 +77,6 @@ class MediaGalleryKeyboard extends React.PureComponent<Props, State> {\nqueueModeProgress = new Animated.Value(0);\nsendButtonStyle: ViewStyle;\nmediaSelected = false;\n- realVideoDimensions = new Map();\nconstructor(props: Props) {\nsuper(props);\n@@ -349,7 +348,6 @@ class MediaGalleryKeyboard extends React.PureComponent<Props, State> {\nsetFocus={this.setFocus}\nscreenWidth={this.state.screenWidth}\ncolors={this.props.colors}\n- setRealVideoDimensions={this.setRealVideoDimensions}\n/>\n);\n}\n@@ -511,18 +509,7 @@ class MediaGalleryKeyboard extends React.PureComponent<Props, State> {\nreturn;\n}\nthis.mediaSelected = true;\n- const fixedVideoDimensionsMediaInfos = mediaInfos.map(mediaInfo => {\n- const fixedDimensions = this.realVideoDimensions.get(mediaInfo.uri);\n- return fixedDimensions ? { ...mediaInfo, ...fixedDimensions } : mediaInfo;\n- });\n- KeyboardRegistry.onItemSelected(\n- mediaGalleryKeyboardName,\n- fixedVideoDimensionsMediaInfos,\n- );\n- }\n-\n- setRealVideoDimensions = (compatibleURI: string, dimensions: Dimensions) => {\n- this.realVideoDimensions.set(compatibleURI, dimensions);\n+ KeyboardRegistry.onItemSelected(mediaGalleryKeyboardName, mediaInfos);\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "native/media/media-gallery-media.react.js", "new_path": "native/media/media-gallery-media.react.js", "diff": "// @flow\n-import { type Dimensions, mediaTypePropType } from 'lib/types/media-types';\n+import { mediaTypePropType } from 'lib/types/media-types';\nimport type { ViewStyle, ImageStyle } from '../types/styles';\nimport { type Colors, colorsPropType } from '../themes/colors';\n@@ -64,10 +64,6 @@ type Props = {|\nsetFocus: (media: GalleryMediaInfo, isFocused: bool) => void,\nscreenWidth: number,\ncolors: Colors,\n- setRealVideoDimensions: (\n- compatibleURI: string,\n- dimensions: Dimensions,\n- ) => void,\n|};\nclass MediaGalleryMedia extends React.PureComponent<Props> {\n@@ -88,7 +84,6 @@ class MediaGalleryMedia extends React.PureComponent<Props> {\nsetFocus: PropTypes.func.isRequired,\nscreenWidth: PropTypes.number.isRequired,\ncolors: colorsPropType.isRequired,\n- setRealVideoDimensions: PropTypes.func.isRequired,\n};\nfocusProgress = new Reanimated.Value(0);\nbuttonsStyle: ViewStyle;\n@@ -267,7 +262,6 @@ class MediaGalleryMedia extends React.PureComponent<Props> {\nmuted={true}\nresizeMode=\"contain\"\nstyle={dimensionsStyle}\n- onLoad={this.onVideoLoad}\n/>\n<Reanimated.View style={this.videoOverlayStyle} />\n</Reanimated.View>\n@@ -351,15 +345,6 @@ class MediaGalleryMedia extends React.PureComponent<Props> {\nthis.animatingBackdropToZero = false;\n}\n- onVideoLoad = (videoLoadProps: {\n- naturalSize: { height: number, width: number, ... },\n- ...\n- }) => {\n- const { height, width } = videoLoadProps.naturalSize;\n- const { uri } = this.props.mediaInfo;\n- this.props.setRealVideoDimensions(uri, { height, width });\n- }\n-\n}\nconst buttonStyle = {\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Don't use dimensions from react-native-video anymore `CameraRoll` should now return the correct dimensions... we hope...
129,187
18.12.2019 10:37:48
18,000
c86f963f9925d0372d4a9fe188ed239dffa535cc
[native] Consider MultimediaModal active when ActionResultModal appears over it This is to avoid relocking orientation or temporarily showing the status bar
[ { "change_type": "MODIFY", "old_path": "native/media/multimedia-modal.react.js", "new_path": "native/media/multimedia-modal.react.js", "diff": "@@ -1117,8 +1117,9 @@ class MultimediaModal extends React.PureComponent<Props, State> {\n}\nstatic isActive(props) {\n- const { index } = props.scene;\n- return index === props.transitionProps.index;\n+ const ourIndex = props.scene.index;\n+ const curIndex = props.transitionProps.index;\n+ return curIndex >= ourIndex;\n}\nget contentContainerStyle() {\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Consider MultimediaModal active when ActionResultModal appears over it This is to avoid relocking orientation or temporarily showing the status bar
129,187
20.12.2019 16:48:30
18,000
b35f275ad2acd707e640c2e68cd11aacea3cbbac
[native] Don't NAVIGATE_TO_APP after log out in dev mode
[ { "change_type": "MODIFY", "old_path": "native/account/logged-out-modal.react.js", "new_path": "native/account/logged-out-modal.react.js", "diff": "@@ -226,9 +226,6 @@ class LoggedOutModal extends React.PureComponent<Props, State> {\ncomponentDidMount() {\nthis.mounted = true;\n- if (this.props.rehydrateConcluded) {\n- this.onInitialAppLoad();\n- }\nif (this.props.isForeground) {\nthis.onForeground();\n}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Don't NAVIGATE_TO_APP after log out in dev mode