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
13.07.2020 13:27:13
14,400
91bac959029a5f341b8a958b9ae0f069fb05b6b3
[native] Always default to light-content StatusBar We only use the default on the initial load, and since we're showing the splash screen there, `light-content` makes the most sense.
[ { "change_type": "MODIFY", "old_path": "native/connected-status-bar.react.js", "new_path": "native/connected-status-bar.react.js", "diff": "@@ -35,13 +35,15 @@ class ConnectedStatusBar extends React.PureComponent<Props> {\n} = this.props;\nlet barStyle = inBarStyle;\n- const fetchingSomething = this.props.globalLoadingStatus === 'loading';\n- if (!barStyle && this.props.activeTheme === 'light') {\n- barStyle = Platform.OS === 'android' ? 'light-content' : 'dark-content';\n- } else if (!barStyle && this.props.activeTheme === 'dark') {\n+ if (!barStyle) {\n+ if (Platform.OS !== 'android' && this.props.activeTheme === 'light') {\n+ barStyle = 'dark-content';\n+ } else {\nbarStyle = 'light-content';\n}\n+ }\n+ const fetchingSomething = this.props.globalLoadingStatus === 'loading';\nreturn (\n<StatusBar\n{...statusBarProps}\n" }, { "change_type": "MODIFY", "old_path": "native/ios/SplashScreen.storyboard", "new_path": "native/ios/SplashScreen.storyboard", "diff": "<!--View Controller-->\n<scene sceneID=\"EHf-IW-A2E\">\n<objects>\n- <viewController storyboardIdentifier=\"SplashScreenViewController\" automaticallyAdjustsScrollViewInsets=\"NO\" id=\"01J-lp-oVM\" sceneMemberID=\"viewController\">\n+ <viewController storyboardIdentifier=\"SplashScreenViewController\" automaticallyAdjustsScrollViewInsets=\"NO\" interfaceStyle=\"dark\" id=\"01J-lp-oVM\" sceneMemberID=\"viewController\">\n<view key=\"view\" contentMode=\"scaleToFill\" insetsLayoutMarginsFromSafeArea=\"NO\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"nvi-kw-ZOr\">\n<rect key=\"frame\" x=\"0.0\" y=\"0.0\" width=\"414\" height=\"896\"/>\n<subviews>\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Always default to light-content StatusBar We only use the default on the initial load, and since we're showing the splash screen there, `light-content` makes the most sense.
129,187
13.07.2020 14:36:28
14,400
998187094d25e4094cdba529efe1c8428f7c8263
[native] Prevent border/shadow between Chat header and top tabs
[ { "change_type": "MODIFY", "old_path": "native/chat/chat.react.js", "new_path": "native/chat/chat.react.js", "diff": "@@ -56,8 +56,10 @@ const unboundStyles = {\nflex: 1,\nbackgroundColor: 'listBackground',\n},\n- headerStyle: {\n+ threadListHeaderStyle: {\nelevation: 0,\n+ shadowOffset: { width: 0, height: 0 },\n+ borderBottomWidth: 0,\n},\n};\n@@ -149,7 +151,7 @@ const chatThreadListOptions = ({ navigation }) => ({\n? () => <ComposeThreadButton navigate={navigation.navigate} />\n: undefined,\nheaderBackTitle: 'Back',\n- headerStyle: unboundStyles.headerStyle,\n+ headerStyle: unboundStyles.threadListHeaderStyle,\n});\nconst messageListOptions = ({ navigation, route }) => ({\n// This is a render prop, not a component\n" }, { "change_type": "MODIFY", "old_path": "native/themes/colors.js", "new_path": "native/themes/colors.js", "diff": "@@ -145,10 +145,10 @@ for (let theme in colors) {\n}\n}\n-type Styles = { [name: string]: { [field: string]: number | string } };\n+type Styles = { [name: string]: { [field: string]: mixed } };\ntype ReplaceField = (input: any) => any;\n-type ReplaceStyleObject = <Obj: { [key: string]: number | string }>(\n+type ReplaceStyleObject = <Obj: { [key: string]: mixed }>(\nObj,\n) => $ObjMap<Obj, ReplaceField>;\n@@ -164,6 +164,9 @@ function stylesFromColors<IS: Styles>(\nconst filledInStyle = { ...style };\nfor (let styleKey in style) {\nconst styleValue = style[styleKey];\n+ if (typeof styleValue !== 'string') {\n+ continue;\n+ }\nif (magicStrings.has(styleValue)) {\nconst mapped = themeColors[styleValue];\nif (mapped) {\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Prevent border/shadow between Chat header and top tabs
129,187
13.07.2020 14:20:52
14,400
d5c38afee9272fcbeeafca7727a047470b500653
[native] Don't wait for mount to render React Navigation in release builds
[ { "change_type": "MODIFY", "old_path": "native/navigation/app-navigator.react.js", "new_path": "native/navigation/app-navigator.react.js", "diff": "@@ -10,13 +10,6 @@ import { PersistGate } from 'redux-persist/integration/react';\nimport * as SplashScreen from 'expo-splash-screen';\nimport Icon from 'react-native-vector-icons/FontAwesome';\n-let splashScreenHasHidden = false;\n-(async () => {\n- try {\n- await SplashScreen.preventAutoHideAsync();\n- } catch {}\n-})();\n-\nimport {\nCalendarRouteName,\nChatRouteName,\n@@ -50,6 +43,13 @@ import { RootContext } from '../root-context';\nimport { waitForInteractions } from '../utils/interactions';\nimport ChatIcon from '../chat/chat-icon.react';\n+let splashScreenHasHidden = false;\n+(async () => {\n+ try {\n+ await SplashScreen.preventAutoHideAsync();\n+ } catch {}\n+})();\n+\nconst calendarTabOptions = {\ntabBarLabel: 'Calendar',\n// eslint-disable-next-line react/display-name\n" }, { "change_type": "MODIFY", "old_path": "native/root.react.js", "new_path": "native/root.react.js", "diff": "@@ -69,13 +69,16 @@ function Root() {\n};\nsetNavContext(updatedNavContext);\nsetGlobalNavContext(updatedNavContext);\n- }, [navStateRef, navDispatchRef, navStateInitializedRef, setNavContext]);\n+ }, []);\n+\n+ const [initialState, setInitialState] = React.useState(\n+ __DEV__ ? undefined : defaultNavigationState,\n+ );\n- const [initialState, setInitialState] = React.useState(null);\nReact.useEffect(() => {\nOrientation.lockToPortrait();\n(async () => {\n- let loadedState;\n+ let loadedState = initialState;\nif (__DEV__) {\ntry {\nconst navStateString = await AsyncStorage.getItem(\n@@ -92,17 +95,20 @@ function Root() {\nif (!loadedState) {\nloadedState = defaultNavigationState;\n}\n+ if (loadedState !== initialState) {\n+ setInitialState(loadedState);\n+ }\nnavStateRef.current = loadedState;\nupdateNavContext();\nactionLogger.addOtherAction('navState', navInitAction, null, loadedState);\n- setInitialState(loadedState);\n})();\n- }, [navStateRef, updateNavContext, setInitialState]);\n+ // eslint-disable-next-line react-hooks/exhaustive-deps\n+ }, [updateNavContext]);\nconst setNavStateInitialized = React.useCallback(() => {\nnavStateInitializedRef.current = true;\nupdateNavContext();\n- }, [navStateInitializedRef, updateNavContext]);\n+ }, [updateNavContext]);\nconst [rootContext, setRootContext] = React.useState(() => ({\nsetNavStateInitialized,\n@@ -115,7 +121,7 @@ function Root() {\ndetectUnsupervisedBackground,\n}));\n},\n- [setRootContext],\n+ [],\n);\nconst frozen = useSelector(state => state.frozen);\n@@ -151,7 +157,7 @@ function Root() {\n}\n})();\n},\n- [navStateRef, updateNavContext, queuedActionsRef, frozen],\n+ [updateNavContext, frozen],\n);\nconst navContainerRef = React.useRef();\n@@ -163,7 +169,7 @@ function Root() {\nupdateNavContext();\n}\n},\n- [navContainerRef, navDispatchRef, updateNavContext],\n+ [updateNavContext],\n);\nuseReduxDevToolsExtension(navContainerRef);\n@@ -184,7 +190,7 @@ function Root() {\ntype: `NAV/${action.type}`,\n});\n});\n- }, [navContainer, navStateRef, queuedActionsRef]);\n+ }, [navContainer]);\nconst activeTheme = useSelector(state => state.globalThemeInfo.activeTheme);\nconst theme = (() => {\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Don't wait for mount to render React Navigation in release builds
129,187
13.07.2020 15:26:24
14,400
d4e56d5360ae6b11ff9aa824345d7a44425ececf
[native] Convert DimensionsUpdater into hook
[ { "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, dimensionsPropType } from 'lib/types/media-types';\n-import type { DispatchActionPayload } from 'lib/utils/action-utils';\n-import type { AppState } from '../redux/redux-setup';\n+import type { Dimensions } from 'lib/types/media-types';\nimport * as React from 'react';\n-import PropTypes from 'prop-types';\nimport { Dimensions as NativeDimensions } from 'react-native';\n-\n-import { connect } from 'lib/utils/redux-utils';\n+import { useSelector, useDispatch } from 'react-redux';\nimport { updateDimensionsActiveType } from './action-types';\n-type Props = {\n- // Redux state\n- dimensions: Dimensions,\n- // Redux dispatch functions\n- dispatchActionPayload: DispatchActionPayload,\n-};\n-class DimensionsUpdater extends React.PureComponent<Props> {\n- static propTypes = {\n- dimensions: dimensionsPropType.isRequired,\n- dispatchActionPayload: PropTypes.func.isRequired,\n- };\n-\n- componentDidMount() {\n- NativeDimensions.addEventListener('change', this.onDimensionsChange);\n- }\n+export default function DimensionsUpdater() {\n+ const dimensions = useSelector(state => state.dimensions);\n+ const dispatch = useDispatch();\n- componentWillUnmount() {\n- NativeDimensions.removeEventListener('change', this.onDimensionsChange);\n+ const onDimensionsChange = React.useCallback(\n+ (allDimensions: { window: Dimensions }) => {\n+ const { height: newHeight, width: newWidth } = allDimensions.window;\n+ const { height: oldHeight, width: oldWidth } = dimensions;\n+ if (newHeight !== oldHeight || newWidth !== oldWidth) {\n+ dispatch({\n+ type: updateDimensionsActiveType,\n+ payload: {\n+ height: newHeight,\n+ width: newWidth,\n+ },\n+ });\n}\n+ },\n+ [dimensions, dispatch],\n+ );\n+\n+ React.useEffect(() => {\n+ NativeDimensions.addEventListener('change', onDimensionsChange);\n+ return () => {\n+ NativeDimensions.removeEventListener('change', onDimensionsChange);\n+ };\n+ }, [onDimensionsChange]);\n- componentDidUpdate(prevProps: Props) {\n+ const prevDimensionsRef = React.useRef();\n+ React.useEffect(() => {\n+ const prevDimensions = prevDimensionsRef.current;\nif (\n- this.props.dimensions.height !== prevProps.dimensions.height ||\n- this.props.dimensions.width !== prevProps.dimensions.width\n+ prevDimensions &&\n+ (dimensions.height !== prevDimensions.height ||\n+ dimensions.width !== prevDimensions.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 onDimensionsChange 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+ onDimensionsChange({ window: NativeDimensions.get('window') });\n}\n+ prevDimensionsRef.current = dimensions;\n+ }, [dimensions, onDimensionsChange]);\n- onDimensionsChange = (allDimensions: { window: Dimensions }) => {\n- const { height: newHeight, width: newWidth } = allDimensions.window;\n- const { height: oldHeight, width: oldWidth } = this.props.dimensions;\n- if (newHeight !== oldHeight || newWidth !== oldWidth) {\n- this.props.dispatchActionPayload(updateDimensionsActiveType, {\n- height: newHeight,\n- width: newWidth,\n- });\n- }\n- };\n-\n- render() {\nreturn null;\n}\n-}\n-\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] Convert DimensionsUpdater into hook
129,187
13.07.2020 15:58:41
14,400
bc7894016a33ab7cf63ac3d4657f2af770016809
[native] Refactor DimensionsUpdater based on react-native-safe-area-context
[ { "change_type": "MODIFY", "old_path": "native/redux/dimensions-updater.react.js", "new_path": "native/redux/dimensions-updater.react.js", "diff": "import type { Dimensions } from 'lib/types/media-types';\nimport * as React from 'react';\n-import { Dimensions as NativeDimensions } from 'react-native';\nimport { useSelector, useDispatch } from 'react-redux';\n+import {\n+ initialWindowMetrics,\n+ useSafeAreaFrame,\n+ useSafeAreaInsets,\n+} from 'react-native-safe-area-context';\nimport { updateDimensionsActiveType } from './action-types';\n-export default function DimensionsUpdater() {\n- const dimensions = useSelector(state => state.dimensions);\n- const dispatch = useDispatch();\n+export type DimensionsInfo = {|\n+ ...Dimensions,\n+ topInset: number,\n+ bottomInset: number,\n+ tabBarHeight: number,\n+|};\n- const onDimensionsChange = React.useCallback(\n- (allDimensions: { window: Dimensions }) => {\n- const { height: newHeight, width: newWidth } = allDimensions.window;\n- const { height: oldHeight, width: oldWidth } = dimensions;\n- if (newHeight !== oldHeight || newWidth !== oldWidth) {\n- dispatch({\n- type: updateDimensionsActiveType,\n- payload: {\n- height: newHeight,\n- width: newWidth,\n- },\n- });\n+type Metrics = {|\n+ +frame: {| +x: number, +y: number, +width: number, +height: number |},\n+ +insets: {| +top: number, +left: number, +right: number, +bottom: number |},\n+|};\n+function dimensionsUpdateFromMetrics(metrics: Metrics): $Shape<DimensionsInfo> {\n+ return {\n+ height: metrics.frame.height,\n+ width: metrics.frame.width,\n+ topInset: metrics.insets.top,\n+ bottomInset: metrics.insets.bottom,\n+ };\n}\n- },\n- [dimensions, dispatch],\n- );\n- React.useEffect(() => {\n- NativeDimensions.addEventListener('change', onDimensionsChange);\n- return () => {\n- NativeDimensions.removeEventListener('change', onDimensionsChange);\n+const defaultDimensionsInfo = {\n+ ...dimensionsUpdateFromMetrics(initialWindowMetrics),\n+ tabBarHeight: 50,\n};\n- }, [onDimensionsChange]);\n- const prevDimensionsRef = React.useRef();\n+function DimensionsUpdater() {\n+ const dimensions = useSelector(state => state.dimensions);\n+ const dispatch = useDispatch();\n+\n+ const frame = useSafeAreaFrame();\n+ const insets = useSafeAreaInsets();\n+\nReact.useEffect(() => {\n- const prevDimensions = prevDimensionsRef.current;\n- if (\n- prevDimensions &&\n- (dimensions.height !== prevDimensions.height ||\n- dimensions.width !== prevDimensions.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 onDimensionsChange 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- onDimensionsChange({ window: NativeDimensions.get('window') });\n+ const updates = dimensionsUpdateFromMetrics({ frame, insets });\n+ for (let key in updates) {\n+ if (updates[key] === dimensions[key]) {\n+ continue;\n+ }\n+ dispatch({\n+ type: updateDimensionsActiveType,\n+ payload: updates,\n+ });\n+ return;\n}\n- prevDimensionsRef.current = dimensions;\n- }, [dimensions, onDimensionsChange]);\n+ }, [dimensions, dispatch, frame, insets]);\nreturn null;\n}\n+\n+export { defaultDimensionsInfo, DimensionsUpdater };\n" }, { "change_type": "MODIFY", "old_path": "native/redux/redux-setup.js", "new_path": "native/redux/redux-setup.js", "diff": "@@ -39,12 +39,7 @@ import type { SetSessionPayload } from 'lib/types/session-types';\nimport thunk from 'redux-thunk';\nimport { createStore, applyMiddleware, type Store, compose } from 'redux';\nimport { persistStore, persistReducer } from 'redux-persist';\n-import {\n- AppState as NativeAppState,\n- Platform,\n- Dimensions as NativeDimensions,\n- Alert,\n-} from 'react-native';\n+import { AppState as NativeAppState, Platform, Alert } from 'react-native';\nimport Orientation from 'react-native-orientation-locker';\nimport baseReducer from 'lib/reducers/master-reducer';\n@@ -83,9 +78,9 @@ import reactotron from '../reactotron';\nimport reduceDrafts from '../reducers/draft-reducer';\nimport { getGlobalNavContext } from '../navigation/icky-global';\nimport {\n- defaultTabBarHeight,\n+ defaultDimensionsInfo,\ntype DimensionsInfo,\n-} from '../selectors/dimension-selectors';\n+} from './dimensions-updater.react';\nexport type AppState = {|\nnavInfo: NavInfo,\n@@ -120,7 +115,6 @@ export type AppState = {|\nfrozen: boolean,\n|};\n-const { height, width } = NativeDimensions.get('window');\nconst defaultState = ({\nnavInfo: defaultNavInfo,\ncurrentUserInfo: null,\n@@ -158,7 +152,7 @@ const defaultState = ({\nnextLocalID: 0,\nqueuedReports: [],\n_persist: null,\n- dimensions: { height, width, tabBarHeight: defaultTabBarHeight },\n+ dimensions: defaultDimensionsInfo,\nconnectivity: defaultConnectivityInfo,\nglobalThemeInfo: defaultGlobalThemeInfo,\ndeviceCameraInfo: defaultDeviceCameraInfo,\n" }, { "change_type": "MODIFY", "old_path": "native/root.react.js", "new_path": "native/root.react.js", "diff": "@@ -23,7 +23,7 @@ import { store } from './redux/redux-setup';\nimport ConnectedStatusBar from './connected-status-bar.react';\nimport ErrorBoundary from './error-boundary.react';\nimport DisconnectedBarVisibilityHandler from './navigation/disconnected-bar-visibility-handler.react';\n-import DimensionsUpdater from './redux/dimensions-updater.react';\n+import { DimensionsUpdater } from './redux/dimensions-updater.react';\nimport ConnectivityUpdater from './redux/connectivity-updater.react';\nimport ThemeHandler from './themes/theme-handler.react';\nimport OrientationHandler from './navigation/orientation-handler.react';\n" }, { "change_type": "MODIFY", "old_path": "native/selectors/dimension-selectors.js", "new_path": "native/selectors/dimension-selectors.js", "diff": "import type { AppState } from '../redux/redux-setup';\nimport type { Dimensions } from 'lib/types/media-types';\n+import type { DimensionsInfo } from '../redux/dimensions-updater.react';\nimport { Platform, DeviceInfo } from 'react-native';\nimport { createSelector } from 'reselect';\n-export type DimensionsInfo = {|\n- ...Dimensions,\n- tabBarHeight: number,\n-|};\n-\nconst isIPhoneX =\nPlatform.OS === 'ios' && DeviceInfo.getConstants().isIPhoneX_deprecated;\n-\n-let statusBarHeight = 0;\n-if (Platform.OS === 'android') {\n- statusBarHeight = 24;\n-} else if (isIPhoneX) {\n- statusBarHeight = 44;\n-} else if (Platform.OS === 'ios') {\n- statusBarHeight = 20;\n-}\n-\n-// iPhone X home pill\nconst contentBottomOffset = isIPhoneX ? 34 : 0;\nconst androidOpaqueStatus = Platform.OS === 'android' && Platform.Version < 21;\n@@ -32,43 +17,19 @@ const androidOpaqueStatus = Platform.OS === 'android' && Platform.Version < 21;\nconst dimensionsSelector: (state: AppState) => Dimensions = createSelector(\n(state: AppState) => state.dimensions,\n(dimensions: DimensionsInfo): Dimensions => {\n- let { height, width } = dimensions;\n- if (androidOpaqueStatus) {\n- // Android always includes the status bar height,\n- // even if the zero pixel starts below the status bar\n- height -= statusBarHeight;\n- }\n- height -= contentBottomOffset;\n+ const { width, bottomInset } = dimensions;\n+ const height = dimensions.height - bottomInset;\nreturn { height, width };\n},\n);\n-// iOS starts the 0 pixel above the status bar,\n-// so we offset our content by the status bar height\n-const contentVerticalOffsetSelector: (\n- state: AppState,\n-) => number = createSelector(\n- (state: AppState) => state.dimensions,\n- (dimensions: DimensionsInfo): number => {\n- if (androidOpaqueStatus) {\n- return 0;\n- }\n- const { height, width } = dimensions;\n- if (width > height) {\n- // We don't display a status bar at all in landscape mode,\n- // plus there is no notch for the iPhone X\n- return 0;\n+function contentVerticalOffsetSelector(state: AppState) {\n+ return state.dimensions.topInset;\n}\n- return statusBarHeight;\n- },\n-);\n-\n-const defaultTabBarHeight = 50;\nexport {\nandroidOpaqueStatus,\ncontentBottomOffset,\ndimensionsSelector,\ncontentVerticalOffsetSelector,\n- defaultTabBarHeight,\n};\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Refactor DimensionsUpdater based on react-native-safe-area-context
129,187
13.07.2020 16:12:04
14,400
76213d50136b9f710b571f5447138a058ac22648
[native] Get rid of contentVerticalOffset in favor of topInset
[ { "change_type": "MODIFY", "old_path": "native/account/logged-out-modal.react.js", "new_path": "native/account/logged-out-modal.react.js", "diff": "@@ -39,10 +39,7 @@ import {\nimport { connect } from 'lib/utils/redux-utils';\nimport { isLoggedIn } from 'lib/selectors/user-selectors';\n-import {\n- dimensionsSelector,\n- contentVerticalOffsetSelector,\n-} from '../selectors/dimension-selectors';\n+import { dimensionsSelector } from '../selectors/dimension-selectors';\nimport LogInPanelContainer from './log-in-panel-container.react';\nimport RegisterPanel from './register-panel.react';\nimport ConnectedStatusBar from '../connected-status-bar.react';\n@@ -85,7 +82,7 @@ type Props = {\nurlPrefix: string,\nloggedIn: boolean,\ndimensions: Dimensions,\n- contentVerticalOffset: number,\n+ topInset: number,\nsplashStyle: ImageStyle,\n// Redux dispatch functions\ndispatch: Dispatch,\n@@ -112,7 +109,7 @@ class LoggedOutModal extends React.PureComponent<Props, State> {\nurlPrefix: PropTypes.string.isRequired,\nloggedIn: PropTypes.bool.isRequired,\ndimensions: dimensionsPropType.isRequired,\n- contentVerticalOffset: PropTypes.number.isRequired,\n+ topInset: PropTypes.number.isRequired,\ndispatch: PropTypes.func.isRequired,\ndispatchActionPayload: PropTypes.func.isRequired,\n};\n@@ -317,7 +314,7 @@ class LoggedOutModal extends React.PureComponent<Props, State> {\ncalculatePanelPaddingTop(mode: LoggedOutMode, keyboardHeight: number) {\nconst {\ndimensions: { height: windowHeight },\n- contentVerticalOffset,\n+ topInset,\n} = this.props;\nlet containerSize = Platform.OS === 'ios' ? 62.33 : 58.54; // header height\nif (mode === 'log-in') {\n@@ -333,7 +330,7 @@ class LoggedOutModal extends React.PureComponent<Props, State> {\n// and I'm not sure how to get AutoLayout to behave consistently with Yoga\ncontainerSize += DeviceInfo.getConstants().isIPhoneX_deprecated ? 50 : 61;\n}\n- const contentHeight = windowHeight - contentVerticalOffset;\n+ const contentHeight = windowHeight - topInset;\nreturn (contentHeight - containerSize - keyboardHeight) / 2;\n}\n@@ -741,7 +738,7 @@ export default connectNav((context: ?NavContextType) => ({\nurlPrefix: state.urlPrefix,\nloggedIn: isLoggedIn(state),\ndimensions: dimensionsSelector(state),\n- contentVerticalOffset: contentVerticalOffsetSelector(state),\n+ topInset: state.dimensions.topInset,\nsplashStyle: splashStyleSelector(state),\n}),\nnull,\n" }, { "change_type": "MODIFY", "old_path": "native/calendar/calendar.react.js", "new_path": "native/calendar/calendar.react.js", "diff": "@@ -68,10 +68,7 @@ import { connect } from 'lib/utils/redux-utils';\nimport { createLoadingStatusSelector } from 'lib/selectors/loading-selectors';\nimport { Entry, InternalEntry, entryStyles } from './entry.react';\n-import {\n- dimensionsSelector,\n- contentVerticalOffsetSelector,\n-} from '../selectors/dimension-selectors';\n+import { dimensionsSelector } from '../selectors/dimension-selectors';\nimport { calendarListData } from '../selectors/calendar-selectors';\nimport {\ncreateIsForegroundSelector,\n@@ -134,7 +131,7 @@ type Props = {\nendDate: string,\ncalendarFilters: $ReadOnlyArray<CalendarFilter>,\ndimensions: Dimensions,\n- contentVerticalOffset: number,\n+ topInset: number,\nloadingStatus: LoadingStatus,\nconnectionStatus: ConnectionStatus,\ncolors: Colors,\n@@ -192,7 +189,7 @@ class Calendar extends React.PureComponent<Props, State> {\nendDate: PropTypes.string.isRequired,\ncalendarFilters: PropTypes.arrayOf(calendarFilterPropType).isRequired,\ndimensions: dimensionsPropType.isRequired,\n- contentVerticalOffset: PropTypes.number.isRequired,\n+ topInset: PropTypes.number.isRequired,\nloadingStatus: loadingStatusPropType.isRequired,\nconnectionStatus: connectionStatusPropType.isRequired,\ncolors: colorsPropType.isRequired,\n@@ -779,10 +776,10 @@ class Calendar extends React.PureComponent<Props, State> {\nflatListHeight() {\nconst {\ndimensions: { height: windowHeight },\n- contentVerticalOffset,\n+ topInset,\ntabBarHeight,\n} = this.props;\n- return windowHeight - contentVerticalOffset - tabBarHeight;\n+ return windowHeight - topInset - tabBarHeight;\n}\ninitialScrollIndex(data: $ReadOnlyArray<CalendarItemWithHeight>) {\n@@ -1161,7 +1158,7 @@ export default connectNav((context: ?NavContextType) => ({\nendDate: state.navInfo.endDate,\ncalendarFilters: state.calendarFilters,\ndimensions: dimensionsSelector(state),\n- contentVerticalOffset: contentVerticalOffsetSelector(state),\n+ topInset: state.dimensions.topInset,\nloadingStatus: loadingStatusSelector(state),\nconnectionStatus: state.connection.status,\ncolors: colorsSelector(state),\n" }, { "change_type": "MODIFY", "old_path": "native/media/camera-modal.react.js", "new_path": "native/media/camera-modal.react.js", "diff": "@@ -55,7 +55,6 @@ import { pathFromURI, filenameFromPathOrURI } from 'lib/media/file-utils';\nimport {\ncontentBottomOffset,\ndimensionsSelector,\n- contentVerticalOffsetSelector,\n} from '../selectors/dimension-selectors';\nimport ConnectedStatusBar from '../connected-status-bar.react';\nimport { clamp, gestureJustEnded } from '../utils/animation-utils';\n@@ -246,7 +245,7 @@ type Props = {\nroute: NavigationRoute<'CameraModal'>,\n// Redux state\nscreenDimensions: Dimensions,\n- contentVerticalOffset: number,\n+ topInset: number,\ndeviceCameraInfo: DeviceCameraInfo,\ndeviceOrientation: Orientations,\nforeground: boolean,\n@@ -277,7 +276,7 @@ class CameraModal extends React.PureComponent<Props, State> {\n}).isRequired,\n}).isRequired,\nscreenDimensions: dimensionsPropType.isRequired,\n- contentVerticalOffset: PropTypes.number.isRequired,\n+ topInset: PropTypes.number.isRequired,\ndeviceCameraInfo: deviceCameraInfoPropType.isRequired,\ndeviceOrientation: PropTypes.string.isRequired,\nforeground: PropTypes.bool.isRequired,\n@@ -636,7 +635,7 @@ class CameraModal extends React.PureComponent<Props, State> {\nreturn this.renderStagingView();\n}\nconst topButtonStyle = {\n- top: Math.max(this.props.contentVerticalOffset, 6),\n+ top: Math.max(this.props.topInset, 6),\n};\nreturn (\n<>\n@@ -664,7 +663,7 @@ class CameraModal extends React.PureComponent<Props, State> {\n}\nconst topButtonStyle = {\n- top: Math.max(this.props.contentVerticalOffset - 3, 3),\n+ top: Math.max(this.props.topInset - 3, 3),\n};\nreturn (\n<>\n@@ -727,7 +726,7 @@ class CameraModal extends React.PureComponent<Props, State> {\n}\nconst topButtonStyle = {\n- top: Math.max(this.props.contentVerticalOffset - 3, 3),\n+ top: Math.max(this.props.topInset - 3, 3),\n};\nreturn (\n<PinchGestureHandler\n@@ -1201,7 +1200,7 @@ const styles = StyleSheet.create({\nexport default connect(\n(state: AppState) => ({\nscreenDimensions: dimensionsSelector(state),\n- contentVerticalOffset: contentVerticalOffsetSelector(state),\n+ topInset: state.dimensions.topInset,\ndeviceCameraInfo: state.deviceCameraInfo,\ndeviceOrientation: state.deviceOrientation,\nforeground: state.foreground,\n" }, { "change_type": "MODIFY", "old_path": "native/media/multimedia-modal.react.js", "new_path": "native/media/multimedia-modal.react.js", "diff": "@@ -44,7 +44,6 @@ import { connect } from 'lib/utils/redux-utils';\nimport {\ncontentBottomOffset,\ndimensionsSelector,\n- contentVerticalOffsetSelector,\n} from '../selectors/dimension-selectors';\nimport Multimedia from './multimedia.react';\nimport ConnectedStatusBar from '../connected-status-bar.react';\n@@ -199,7 +198,7 @@ type Props = {|\nroute: NavigationRoute<'MultimediaModal'>,\n// Redux state\nscreenDimensions: Dimensions,\n- contentVerticalOffset: number,\n+ topInset: number,\n// withOverlayContext\noverlayContext: ?OverlayContextType,\n|};\n@@ -221,7 +220,7 @@ class MultimediaModal extends React.PureComponent<Props, State> {\n}).isRequired,\n}).isRequired,\nscreenDimensions: dimensionsPropType.isRequired,\n- contentVerticalOffset: PropTypes.number.isRequired,\n+ topInset: PropTypes.number.isRequired,\noverlayContext: overlayContextPropType,\n};\nstate = {\n@@ -946,7 +945,7 @@ class MultimediaModal extends React.PureComponent<Props, State> {\n}\nconst centerX = screenWidth / 2;\n- const centerY = screenHeight / 2 + this.props.contentVerticalOffset;\n+ const centerY = screenHeight / 2 + this.props.topInset;\nif (this.centerX) {\nthis.centerX.setValue(centerX);\n} else {\n@@ -986,7 +985,7 @@ class MultimediaModal extends React.PureComponent<Props, State> {\ncomponentDidUpdate(prevProps: Props) {\nif (\nthis.props.screenDimensions !== prevProps.screenDimensions ||\n- this.props.contentVerticalOffset !== prevProps.contentVerticalOffset\n+ this.props.topInset !== prevProps.topInset\n) {\nthis.updateDimensions();\n}\n@@ -1001,12 +1000,12 @@ class MultimediaModal extends React.PureComponent<Props, State> {\n}\nget screenDimensions(): Dimensions {\n- const { screenDimensions, contentVerticalOffset } = this.props;\n- if (contentVerticalOffset === 0) {\n+ const { screenDimensions, topInset } = this.props;\n+ if (topInset === 0) {\nreturn screenDimensions;\n}\nconst { height, width } = screenDimensions;\n- return { height: height - contentVerticalOffset, width };\n+ return { height: height - topInset, width };\n}\nget imageDimensions(): Dimensions {\n@@ -1041,7 +1040,7 @@ class MultimediaModal extends React.PureComponent<Props, State> {\nget imageContainerStyle() {\nconst { height, width } = this.imageDimensions;\nconst { height: screenHeight, width: screenWidth } = this.screenDimensions;\n- const top = (screenHeight - height) / 2 + this.props.contentVerticalOffset;\n+ const top = (screenHeight - height) / 2 + this.props.topInset;\nconst left = (screenWidth - width) / 2;\nconst { verticalBounds } = this.props.route.params;\nreturn {\n@@ -1067,9 +1066,7 @@ class MultimediaModal extends React.PureComponent<Props, State> {\nget contentContainerStyle() {\nconst { verticalBounds } = this.props.route.params;\nconst fullScreenHeight =\n- this.screenDimensions.height +\n- contentBottomOffset +\n- this.props.contentVerticalOffset;\n+ this.screenDimensions.height + contentBottomOffset + this.props.topInset;\nconst top = verticalBounds.y;\nconst bottom = fullScreenHeight - verticalBounds.y - verticalBounds.height;\n@@ -1088,7 +1085,7 @@ class MultimediaModal extends React.PureComponent<Props, State> {\nconst backdropStyle = { opacity: this.backdropOpacity };\nconst closeButtonStyle = {\nopacity: this.closeButtonOpacity,\n- top: Math.max(this.props.contentVerticalOffset - 2, 4),\n+ top: Math.max(this.props.topInset - 2, 4),\n};\nconst saveButtonStyle = { opacity: this.actionLinksOpacity };\nconst view = (\n@@ -1291,5 +1288,5 @@ const styles = StyleSheet.create({\nexport default connect((state: AppState) => ({\nscreenDimensions: dimensionsSelector(state),\n- contentVerticalOffset: contentVerticalOffsetSelector(state),\n+ topInset: state.dimensions.topInset,\n}))(withOverlayContext(MultimediaModal));\n" }, { "change_type": "MODIFY", "old_path": "native/selectors/dimension-selectors.js", "new_path": "native/selectors/dimension-selectors.js", "diff": "@@ -23,13 +23,4 @@ const dimensionsSelector: (state: AppState) => Dimensions = createSelector(\n},\n);\n-function contentVerticalOffsetSelector(state: AppState) {\n- return state.dimensions.topInset;\n-}\n-\n-export {\n- androidOpaqueStatus,\n- contentBottomOffset,\n- dimensionsSelector,\n- contentVerticalOffsetSelector,\n-};\n+export { androidOpaqueStatus, contentBottomOffset, dimensionsSelector };\n" }, { "change_type": "MODIFY", "old_path": "native/splash.js", "new_path": "native/splash.js", "diff": "@@ -7,15 +7,12 @@ import type { AppState } from './redux/redux-setup';\nimport { Platform, PixelRatio } from 'react-native';\nimport { createSelector } from 'reselect';\n-import {\n- dimensionsSelector,\n- contentVerticalOffsetSelector,\n-} from './selectors/dimension-selectors';\n+import { dimensionsSelector } from './selectors/dimension-selectors';\nconst splashStyleSelector: (state: AppState) => ImageStyle = createSelector(\ndimensionsSelector,\n- contentVerticalOffsetSelector,\n- (dimensions: Dimensions, contentVerticalOffset: number): ImageStyle => {\n+ (state: AppState) => state.dimensions.topInset,\n+ (dimensions: Dimensions, topInset: number): ImageStyle => {\nif (Platform.OS !== 'android') {\nreturn null;\n}\n@@ -47,8 +44,7 @@ const splashStyleSelector: (state: AppState) => ImageStyle = createSelector(\nconst splashHeight =\nwindowWidth <= 480 ? splashWidth * 2.5 : splashWidth * 2;\nconst translateX = (-1 * (splashWidth - windowWidth)) / 2;\n- const translateY =\n- (-1 * (splashHeight - windowHeight)) / 2 + contentVerticalOffset;\n+ const translateY = (-1 * (splashHeight - windowHeight)) / 2 + topInset;\nreturn {\nwidth: splashWidth,\nheight: splashHeight,\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Get rid of contentVerticalOffset in favor of topInset
129,187
13.07.2020 16:25:13
14,400
b609bad754ab19ccfd331d1802834635755b0498
[native] Get rid of contentBottomOffset in favor of bottomInset
[ { "change_type": "MODIFY", "old_path": "native/media/camera-modal.react.js", "new_path": "native/media/camera-modal.react.js", "diff": "@@ -52,10 +52,7 @@ import filesystem from 'react-native-fs';\nimport { connect } from 'lib/utils/redux-utils';\nimport { pathFromURI, filenameFromPathOrURI } from 'lib/media/file-utils';\n-import {\n- contentBottomOffset,\n- dimensionsSelector,\n-} from '../selectors/dimension-selectors';\n+import { dimensionsSelector } from '../selectors/dimension-selectors';\nimport ConnectedStatusBar from '../connected-status-bar.react';\nimport { clamp, gestureJustEnded } from '../utils/animation-utils';\nimport ContentLoading from '../components/content-loading.react';\n@@ -246,6 +243,7 @@ type Props = {\n// Redux state\nscreenDimensions: Dimensions,\ntopInset: number,\n+ bottomInset: number,\ndeviceCameraInfo: DeviceCameraInfo,\ndeviceOrientation: Orientations,\nforeground: boolean,\n@@ -277,6 +275,7 @@ class CameraModal extends React.PureComponent<Props, State> {\n}).isRequired,\nscreenDimensions: dimensionsPropType.isRequired,\ntopInset: PropTypes.number.isRequired,\n+ bottomInset: PropTypes.number.isRequired,\ndeviceCameraInfo: deviceCameraInfoPropType.isRequired,\ndeviceOrientation: PropTypes.string.isRequired,\nforeground: PropTypes.bool.isRequired,\n@@ -665,6 +664,9 @@ class CameraModal extends React.PureComponent<Props, State> {\nconst topButtonStyle = {\ntop: Math.max(this.props.topInset - 3, 3),\n};\n+ const sendButtonContainerStyle = {\n+ bottom: this.props.bottomInset + 22,\n+ };\nreturn (\n<>\n{image}\n@@ -677,7 +679,10 @@ class CameraModal extends React.PureComponent<Props, State> {\n<SendMediaButton\nonPress={this.sendPhoto}\npointerEvents={pendingPhotoCapture ? 'auto' : 'none'}\n- containerStyle={styles.sendButtonContainer}\n+ containerStyle={[\n+ styles.sendButtonContainer,\n+ sendButtonContainerStyle,\n+ ]}\nstyle={this.sendButtonStyle}\n/>\n</>\n@@ -728,6 +733,9 @@ class CameraModal extends React.PureComponent<Props, State> {\nconst topButtonStyle = {\ntop: Math.max(this.props.topInset - 3, 3),\n};\n+ const bottomButtonsContainerStyle = {\n+ bottom: this.props.bottomInset + 20,\n+ };\nreturn (\n<PinchGestureHandler\nonGestureEvent={this.pinchEvent}\n@@ -752,7 +760,12 @@ class CameraModal extends React.PureComponent<Props, State> {\n>\n{flashIcon}\n</TouchableOpacity>\n- <View style={styles.bottomButtonsContainer}>\n+ <View\n+ style={[\n+ styles.bottomButtonsContainer,\n+ bottomButtonsContainerStyle,\n+ ]}\n+ >\n<TouchableOpacity\nonPress={this.takePhoto}\nonLayout={this.onPhotoButtonLayout}\n@@ -991,7 +1004,7 @@ class CameraModal extends React.PureComponent<Props, State> {\nfocusOnPoint = ([inputX, inputY]: [number, number]) => {\nconst screenWidth = this.props.screenDimensions.width;\nconst screenHeight =\n- this.props.screenDimensions.height + contentBottomOffset;\n+ this.props.screenDimensions.height + this.props.bottomInset;\nconst relativeX = inputX / screenWidth;\nconst relativeY = inputY / screenHeight;\n@@ -1072,7 +1085,6 @@ const styles = StyleSheet.create({\n},\nbottomButtonsContainer: {\nalignItems: 'center',\n- bottom: contentBottomOffset + 20,\nflexDirection: 'row',\njustifyContent: 'center',\nleft: 0,\n@@ -1172,7 +1184,6 @@ const styles = StyleSheet.create({\nwidth: 60,\n},\nsendButtonContainer: {\n- bottom: contentBottomOffset + 22,\nposition: 'absolute',\nright: 32,\n},\n@@ -1201,6 +1212,7 @@ export default connect(\n(state: AppState) => ({\nscreenDimensions: dimensionsSelector(state),\ntopInset: state.dimensions.topInset,\n+ bottomInset: state.dimensions.bottomInset,\ndeviceCameraInfo: state.deviceCameraInfo,\ndeviceOrientation: state.deviceOrientation,\nforeground: state.foreground,\n" }, { "change_type": "MODIFY", "old_path": "native/media/media-gallery-keyboard.react.js", "new_path": "native/media/media-gallery-keyboard.react.js", "diff": "@@ -28,10 +28,7 @@ import { connect } from 'lib/utils/redux-utils';\nimport { extensionFromFilename } from 'lib/media/file-utils';\nimport { store } from '../redux/redux-setup';\n-import {\n- dimensionsSelector,\n- contentBottomOffset,\n-} from '../selectors/dimension-selectors';\n+import { dimensionsSelector } from '../selectors/dimension-selectors';\nimport MediaGalleryMedia from './media-gallery-media.react';\nimport {\ntype Colors,\n@@ -51,6 +48,7 @@ const animationSpec = {\ntype Props = {|\n// Redux state\nscreenDimensions: Dimensions,\n+ bottomInset: number,\nforeground: boolean,\ncolors: Colors,\nstyles: typeof styles,\n@@ -68,6 +66,7 @@ type State = {|\nclass MediaGalleryKeyboard extends React.PureComponent<Props, State> {\nstatic propTypes = {\nscreenDimensions: dimensionsPropType.isRequired,\n+ bottomInset: PropTypes.number.isRequired,\nforeground: PropTypes.bool.isRequired,\ncolors: colorsPropType.isRequired,\nstyles: PropTypes.objectOf(PropTypes.object).isRequired,\n@@ -343,6 +342,9 @@ class MediaGalleryKeyboard extends React.PureComponent<Props, State> {\nrender() {\nlet content;\nconst { selections, error, containerHeight } = this.state;\n+ const bottomOffsetStyle = {\n+ marginBottom: this.props.bottomInset,\n+ };\nif (selections && selections.length > 0 && containerHeight) {\ncontent = (\n<FlatList\n@@ -365,22 +367,27 @@ class MediaGalleryKeyboard extends React.PureComponent<Props, State> {\n<Text style={this.props.styles.error}>no media was found!</Text>\n);\n} else if (error) {\n- content = <Text style={this.props.styles.error}>{error}</Text>;\n+ content = (\n+ <Text style={[this.props.styles.error, bottomOffsetStyle]}>\n+ {error}\n+ </Text>\n+ );\n} else {\ncontent = (\n<ActivityIndicator\ncolor={this.props.colors.listSeparatorLabel}\nsize=\"large\"\n- style={this.props.styles.loadingIndicator}\n+ style={[this.props.styles.loadingIndicator, bottomOffsetStyle]}\n/>\n);\n}\nconst { queuedMediaURIs } = this.state;\nconst queueCount = queuedMediaURIs ? queuedMediaURIs.size : 0;\n+ const containerStyle = { bottom: -1 * this.props.bottomInset };\nreturn (\n<View\n- style={this.props.styles.container}\n+ style={[this.props.styles.container, containerStyle]}\nonLayout={this.onContainerLayout}\n>\n{content}\n@@ -506,7 +513,6 @@ const styles = {\ncontainer: {\nalignItems: 'center',\nbackgroundColor: 'listBackground',\n- bottom: -contentBottomOffset,\nflexDirection: 'row',\nleft: 0,\nposition: 'absolute',\n@@ -517,12 +523,10 @@ const styles = {\ncolor: 'listBackgroundLabel',\nflex: 1,\nfontSize: 28,\n- marginBottom: contentBottomOffset,\ntextAlign: 'center',\n},\nloadingIndicator: {\nflex: 1,\n- marginBottom: contentBottomOffset,\n},\nsendButtonContainer: {\nbottom: 30,\n@@ -537,6 +541,7 @@ const stylesSelector = styleSelector(styles);\nconst ReduxConnectedMediaGalleryKeyboard = connect((state: AppState) => ({\nscreenDimensions: dimensionsSelector(state),\n+ bottomInset: state.dimensions.bottomInset,\nforeground: state.foreground,\ncolors: colorsSelector(state),\nstyles: stylesSelector(state),\n" }, { "change_type": "MODIFY", "old_path": "native/media/multimedia-modal.react.js", "new_path": "native/media/multimedia-modal.react.js", "diff": "@@ -41,10 +41,7 @@ import invariant from 'invariant';\nimport { connect } from 'lib/utils/redux-utils';\n-import {\n- contentBottomOffset,\n- dimensionsSelector,\n-} from '../selectors/dimension-selectors';\n+import { dimensionsSelector } from '../selectors/dimension-selectors';\nimport Multimedia from './multimedia.react';\nimport ConnectedStatusBar from '../connected-status-bar.react';\nimport {\n@@ -199,6 +196,7 @@ type Props = {|\n// Redux state\nscreenDimensions: Dimensions,\ntopInset: number,\n+ bottomInset: number,\n// withOverlayContext\noverlayContext: ?OverlayContextType,\n|};\n@@ -221,6 +219,7 @@ class MultimediaModal extends React.PureComponent<Props, State> {\n}).isRequired,\nscreenDimensions: dimensionsPropType.isRequired,\ntopInset: PropTypes.number.isRequired,\n+ bottomInset: PropTypes.number.isRequired,\noverlayContext: overlayContextPropType,\n};\nstate = {\n@@ -1066,7 +1065,9 @@ class MultimediaModal extends React.PureComponent<Props, State> {\nget contentContainerStyle() {\nconst { verticalBounds } = this.props.route.params;\nconst fullScreenHeight =\n- this.screenDimensions.height + contentBottomOffset + this.props.topInset;\n+ this.screenDimensions.height +\n+ this.props.bottomInset +\n+ this.props.topInset;\nconst top = verticalBounds.y;\nconst bottom = fullScreenHeight - verticalBounds.y - verticalBounds.height;\n@@ -1087,7 +1088,10 @@ class MultimediaModal extends React.PureComponent<Props, State> {\nopacity: this.closeButtonOpacity,\ntop: Math.max(this.props.topInset - 2, 4),\n};\n- const saveButtonStyle = { opacity: this.actionLinksOpacity };\n+ const saveButtonStyle = {\n+ opacity: this.actionLinksOpacity,\n+ bottom: this.props.bottomInset + 8,\n+ };\nconst view = (\n<Animated.View style={styles.container}>\n{statusBar}\n@@ -1266,7 +1270,6 @@ const styles = StyleSheet.create({\npaddingTop: 2,\n},\nsaveButtonContainer: {\n- bottom: contentBottomOffset + 8,\nleft: 16,\nposition: 'absolute',\n},\n@@ -1289,4 +1292,5 @@ const styles = StyleSheet.create({\nexport default connect((state: AppState) => ({\nscreenDimensions: dimensionsSelector(state),\ntopInset: state.dimensions.topInset,\n+ bottomInset: state.dimensions.bottomInset,\n}))(withOverlayContext(MultimediaModal));\n" }, { "change_type": "MODIFY", "old_path": "native/navigation/action-result-modal.react.js", "new_path": "native/navigation/action-result-modal.react.js", "diff": "@@ -7,8 +7,8 @@ import * as React from 'react';\nimport { View, Text } from 'react-native';\nimport Animated from 'react-native-reanimated';\nimport invariant from 'invariant';\n+import { useSelector } from 'react-redux';\n-import { contentBottomOffset } from '../selectors/dimension-selectors';\nimport { useOverlayStyles } from '../themes/colors';\nimport { OverlayContext } from './overlay-context';\n@@ -35,9 +35,11 @@ function ActionResultModal(props: Props) {\n}, [message, goBackOnce]);\nconst styles = useOverlayStyles(ourStyles);\n+ const bottomInset = useSelector(state => state.dimensions.bottomInset);\nconst containerStyle = {\n...styles.container,\nopacity: position,\n+ paddingBottom: bottomInset + 100,\n};\nreturn (\n<Animated.View style={containerStyle}>\n@@ -63,7 +65,6 @@ const ourStyles = {\nalignItems: 'center',\nflex: 1,\njustifyContent: 'flex-end',\n- paddingBottom: contentBottomOffset + 100,\n},\nmessage: {\nborderRadius: 10,\n" }, { "change_type": "MODIFY", "old_path": "native/navigation/tooltip.react.js", "new_path": "native/navigation/tooltip.react.js", "diff": "@@ -40,10 +40,7 @@ import {\nimport { connect } from 'lib/utils/redux-utils';\nimport { createBoundServerCallsSelector } from 'lib/utils/action-utils';\n-import {\n- contentBottomOffset,\n- dimensionsSelector,\n-} from '../selectors/dimension-selectors';\n+import { dimensionsSelector } from '../selectors/dimension-selectors';\nimport TooltipItem from './tooltip-item.react';\nimport {\nwithOverlayContext,\n@@ -93,6 +90,7 @@ type TooltipProps<Navigation, Route> = {\nroute: Route,\n// Redux state\nscreenDimensions: Dimensions,\n+ bottomInset: number,\nserverCallState: ServerCallState,\n// Redux dispatch functions\ndispatch: Dispatch,\n@@ -125,6 +123,7 @@ function createTooltip<\n}).isRequired,\n}).isRequired,\nscreenDimensions: dimensionsPropType.isRequired,\n+ bottomInset: PropTypes.number.isRequired,\nserverCallState: serverCallStatePropType.isRequired,\ndispatch: PropTypes.func.isRequired,\ndispatchActionPayload: PropTypes.func.isRequired,\n@@ -224,7 +223,7 @@ function createTooltip<\nget contentContainerStyle() {\nconst { verticalBounds } = this.props.route.params;\nconst fullScreenHeight =\n- this.props.screenDimensions.height + contentBottomOffset;\n+ this.props.screenDimensions.height + this.props.bottomInset;\nconst top = verticalBounds.y;\nconst bottom =\nfullScreenHeight - verticalBounds.y - verticalBounds.height;\n@@ -255,7 +254,7 @@ function createTooltip<\n}\nget tooltipContainerStyle() {\n- const { screenDimensions, route } = this.props;\n+ const { screenDimensions, bottomInset, route } = this.props;\nconst { initialCoordinates, verticalBounds } = route.params;\nconst { x, y, width, height } = initialCoordinates;\nconst { margin, location } = this;\n@@ -277,7 +276,7 @@ function createTooltip<\n}\nif (location === 'above') {\n- const fullScreenHeight = screenDimensions.height + contentBottomOffset;\n+ const fullScreenHeight = screenDimensions.height + bottomInset;\nstyle.bottom =\nfullScreenHeight - Math.max(y, verticalBounds.y) + margin;\nstyle.transform.push({ translateY: this.tooltipVerticalAbove });\n@@ -425,6 +424,7 @@ function createTooltip<\nreturn connect(\n(state: AppState) => ({\nscreenDimensions: dimensionsSelector(state),\n+ bottomInset: state.dimensions.bottomInset,\nserverCallState: serverCallStateSelector(state),\n}),\nnull,\n" }, { "change_type": "MODIFY", "old_path": "native/selectors/dimension-selectors.js", "new_path": "native/selectors/dimension-selectors.js", "diff": "@@ -4,14 +4,10 @@ import type { AppState } from '../redux/redux-setup';\nimport type { Dimensions } from 'lib/types/media-types';\nimport type { DimensionsInfo } from '../redux/dimensions-updater.react';\n-import { Platform, DeviceInfo } from 'react-native';\n+import { Platform } from 'react-native';\nimport { createSelector } from 'reselect';\n-const isIPhoneX =\n- Platform.OS === 'ios' && DeviceInfo.getConstants().isIPhoneX_deprecated;\n-const contentBottomOffset = isIPhoneX ? 34 : 0;\n-\nconst androidOpaqueStatus = Platform.OS === 'android' && Platform.Version < 21;\nconst dimensionsSelector: (state: AppState) => Dimensions = createSelector(\n@@ -23,4 +19,4 @@ const dimensionsSelector: (state: AppState) => Dimensions = createSelector(\n},\n);\n-export { androidOpaqueStatus, contentBottomOffset, dimensionsSelector };\n+export { androidOpaqueStatus, dimensionsSelector };\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Get rid of contentBottomOffset in favor of bottomInset
129,187
13.07.2020 16:39:32
14,400
13fa8e6df3531b9a471196fc641c2fbf7ee08dc8
[native] Fix up inset handling in MediaGalleryKeyboard Was ignoring it in some places because it's so small on iOS. Also, `react-native-keyboard-input` doesn't include it on iOS, but does on Android.
[ { "change_type": "MODIFY", "old_path": "native/media/media-gallery-keyboard.react.js", "new_path": "native/media/media-gallery-keyboard.react.js", "diff": "@@ -17,6 +17,7 @@ import {\nActivityIndicator,\nAnimated,\nEasing,\n+ Platform,\n} from 'react-native';\nimport { KeyboardRegistry } from 'react-native-keyboard-input';\nimport invariant from 'invariant';\n@@ -62,6 +63,7 @@ type State = {|\nqueuedMediaURIs: ?Set<string>,\nfocusedMediaURI: ?string,\nscreenWidth: number,\n+ bottomInset: number,\n|};\nclass MediaGalleryKeyboard extends React.PureComponent<Props, State> {\nstatic propTypes = {\n@@ -97,9 +99,20 @@ class MediaGalleryKeyboard extends React.PureComponent<Props, State> {\nqueuedMediaURIs: null,\nfocusedMediaURI: null,\nscreenWidth: props.screenDimensions.width,\n+ bottomInset: props.bottomInset,\n};\n}\n+ static getDerivedStateFromProps(props: Props) {\n+ // We keep these in this.state since that's what we pass in as\n+ // FlatList's extraData\n+ const {\n+ bottomInset,\n+ screenDimensions: { width },\n+ } = props;\n+ return { bottomInset, screenWidth: width };\n+ }\n+\ncomponentDidMount() {\nthis.mounted = true;\nreturn this.fetchPhotos();\n@@ -110,13 +123,6 @@ class MediaGalleryKeyboard extends React.PureComponent<Props, State> {\n}\ncomponentDidUpdate(prevProps: Props, prevState: State) {\n- const { width } = this.props.screenDimensions;\n- if (width !== prevProps.screenDimensions.width) {\n- // We keep screenWidth in this.state since that's what we pass in as\n- // FlatList's extraData\n- this.setState({ screenWidth: width });\n- }\n-\nconst { queuedMediaURIs } = this.state;\nconst prevQueuedMediaURIs = prevState.queuedMediaURIs;\nif (queuedMediaURIs && !prevQueuedMediaURIs) {\n@@ -327,6 +333,7 @@ class MediaGalleryKeyboard extends React.PureComponent<Props, State> {\nsetFocus={this.setFocus}\nscreenWidth={this.state.screenWidth}\ncolors={this.props.colors}\n+ bottomInset={this.state.bottomInset}\n/>\n);\n};\n@@ -384,7 +391,11 @@ class MediaGalleryKeyboard extends React.PureComponent<Props, State> {\nconst { queuedMediaURIs } = this.state;\nconst queueCount = queuedMediaURIs ? queuedMediaURIs.size : 0;\n- const containerStyle = { bottom: -1 * this.props.bottomInset };\n+ const bottomInset = Platform.select({\n+ ios: -1 * this.props.bottomInset,\n+ default: 0,\n+ });\n+ const containerStyle = { bottom: bottomInset };\nreturn (\n<View\nstyle={[this.props.styles.container, containerStyle]}\n@@ -395,7 +406,10 @@ class MediaGalleryKeyboard extends React.PureComponent<Props, State> {\nonPress={this.sendQueuedMedia}\nqueueCount={queueCount}\npointerEvents={queuedMediaURIs ? 'auto' : 'none'}\n- containerStyle={this.props.styles.sendButtonContainer}\n+ containerStyle={[\n+ this.props.styles.sendButtonContainer,\n+ bottomOffsetStyle,\n+ ]}\nstyle={this.sendButtonStyle}\n/>\n</View>\n@@ -529,7 +543,7 @@ const styles = {\nflex: 1,\n},\nsendButtonContainer: {\n- bottom: 30,\n+ bottom: 20,\nposition: 'absolute',\nright: 30,\n},\n" }, { "change_type": "MODIFY", "old_path": "native/media/media-gallery-media.react.js", "new_path": "native/media/media-gallery-media.react.js", "diff": "@@ -51,6 +51,7 @@ type Props = {|\nsetFocus: (media: MediaLibrarySelection, isFocused: boolean) => void,\nscreenWidth: number,\ncolors: Colors,\n+ bottomInset: number,\n|};\nclass MediaGalleryMedia extends React.PureComponent<Props> {\nstatic propTypes = {\n@@ -64,6 +65,7 @@ class MediaGalleryMedia extends React.PureComponent<Props> {\nsetFocus: PropTypes.func.isRequired,\nscreenWidth: PropTypes.number.isRequired,\ncolors: colorsPropType.isRequired,\n+ bottomInset: PropTypes.number.isRequired,\n};\n// eslint-disable-next-line import/no-named-as-default-member\nfocusProgress = new Reanimated.Value(0);\n@@ -88,6 +90,7 @@ class MediaGalleryMedia extends React.PureComponent<Props> {\n...styles.buttons,\nopacity: this.focusProgress,\ntransform: [{ scale: buttonsScale }],\n+ marginBottom: this.props.bottomInset,\n};\n// eslint-disable-next-line import/no-named-as-default-member\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Fix up inset handling in MediaGalleryKeyboard Was ignoring it in some places because it's so small on iOS. Also, `react-native-keyboard-input` doesn't include it on iOS, but does on Android.
129,187
13.07.2020 16:47:16
14,400
21ade5a79e966ef8a6d9ef66b523720ff6dd4ec7
[native] androidOpaqueStatus -> androidKeyboardResizesFrame
[ { "change_type": "MODIFY", "old_path": "native/components/keyboard-avoiding-view.react.js", "new_path": "native/components/keyboard-avoiding-view.react.js", "diff": "@@ -18,7 +18,7 @@ import {\n} from 'react-native';\nimport invariant from 'invariant';\n-import { androidOpaqueStatus } from '../selectors/dimension-selectors';\n+import { androidKeyboardResizesFrame } from '../keyboard/keyboard';\ntype ViewProps = React.ElementConfig<typeof View>;\ntype Props = {|\n@@ -29,7 +29,7 @@ type Props = {|\nkeyboardState: ?KeyboardState,\n|};\nfunction KeyboardAvoidingView(props: Props) {\n- if (!androidOpaqueStatus) {\n+ if (!androidKeyboardResizesFrame) {\nreturn <InnerKeyboardAvoidingView {...props} />;\n}\n@@ -97,7 +97,7 @@ class InnerKeyboardAvoidingView extends React.PureComponent<Props, State> {\nconst mediaGalleryOpen = keyboardState && keyboardState.mediaGalleryOpen;\nif (\nPlatform.OS === 'android' &&\n- !androidOpaqueStatus &&\n+ !androidKeyboardResizesFrame &&\nmediaGalleryOpen &&\nthis.keyboardFrame.height > 0 &&\nthis.viewFrame\n" }, { "change_type": "MODIFY", "old_path": "native/keyboard/keyboard-state-container.react.js", "new_path": "native/keyboard/keyboard-state-container.react.js", "diff": "@@ -11,11 +11,11 @@ import {\naddKeyboardShowListener,\naddKeyboardDismissListener,\nremoveKeyboardListener,\n+ androidKeyboardResizesFrame,\n} from './keyboard';\nimport { KeyboardContext } from './keyboard-state';\nimport KeyboardInputHost from './keyboard-input-host.react';\nimport { waitForInteractions } from '../utils/interactions';\n-import { androidOpaqueStatus } from '../selectors/dimension-selectors';\nimport { tabBarAnimationDuration } from '../navigation/tab-bar.react';\ntype Props = {|\n@@ -67,7 +67,7 @@ class KeyboardStateContainer extends React.PureComponent<Props, State> {\n}\ncomponentDidUpdate(prevProps: Props, prevState: State) {\n- if (Platform.OS !== 'android' || androidOpaqueStatus) {\n+ if (Platform.OS !== 'android' || androidKeyboardResizesFrame) {\nreturn;\n}\nif (this.state.mediaGalleryOpen && !prevState.mediaGalleryOpen) {\n@@ -102,7 +102,7 @@ class KeyboardStateContainer extends React.PureComponent<Props, State> {\nmediaGalleryOpen: true,\nmediaGalleryThreadID: threadID,\n};\n- if (androidOpaqueStatus) {\n+ if (androidKeyboardResizesFrame) {\nupdates.renderKeyboardInputHost = true;\n}\nthis.setState(updates);\n" }, { "change_type": "MODIFY", "old_path": "native/keyboard/keyboard.js", "new_path": "native/keyboard/keyboard.js", "diff": "@@ -85,10 +85,16 @@ function removeKeyboardListener(listener: EmitterSubscription) {\nlistener.remove();\n}\n+// This happens because we set windowTranslucentStatus and\n+// windowTranslucentNavigation\n+const androidKeyboardResizesFrame =\n+ Platform.OS === 'android' && Platform.Version < 21;\n+\nexport {\ngetKeyboardHeight,\naddKeyboardShowListener,\naddKeyboardDismissListener,\naddKeyboardDidDismissListener,\nremoveKeyboardListener,\n+ androidKeyboardResizesFrame,\n};\n" }, { "change_type": "MODIFY", "old_path": "native/navigation/tab-bar.react.js", "new_path": "native/navigation/tab-bar.react.js", "diff": "@@ -11,7 +11,7 @@ import { useSafeArea } from 'react-native-safe-area-context';\nimport { KeyboardContext } from '../keyboard/keyboard-state';\nimport { updateDimensionsActiveType } from '../redux/action-types';\n-import { androidOpaqueStatus } from '../selectors/dimension-selectors';\n+import { androidKeyboardResizesFrame } from '../keyboard/keyboard';\n/* eslint-disable import/no-named-as-default-member */\nconst { Value, timing, interpolate } = Animated;\n@@ -31,7 +31,7 @@ function TabBar(props: Props) {\nconst shouldHideTabBar =\nkeyboardState &&\n(keyboardState.mediaGalleryOpen ||\n- (keyboardState.keyboardShowing && androidOpaqueStatus));\n+ (keyboardState.keyboardShowing && androidKeyboardResizesFrame));\nconst prevKeyboardStateRef = React.useRef();\nReact.useEffect(() => {\n" }, { "change_type": "MODIFY", "old_path": "native/selectors/dimension-selectors.js", "new_path": "native/selectors/dimension-selectors.js", "diff": "@@ -4,12 +4,8 @@ import type { AppState } from '../redux/redux-setup';\nimport type { Dimensions } from 'lib/types/media-types';\nimport type { DimensionsInfo } from '../redux/dimensions-updater.react';\n-import { Platform } from 'react-native';\n-\nimport { createSelector } from 'reselect';\n-const androidOpaqueStatus = Platform.OS === 'android' && Platform.Version < 21;\n-\nconst dimensionsSelector: (state: AppState) => Dimensions = createSelector(\n(state: AppState) => state.dimensions,\n(dimensions: DimensionsInfo): Dimensions => {\n@@ -19,4 +15,4 @@ const dimensionsSelector: (state: AppState) => Dimensions = createSelector(\n},\n);\n-export { androidOpaqueStatus, dimensionsSelector };\n+export { dimensionsSelector };\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] androidOpaqueStatus -> androidKeyboardResizesFrame
129,187
13.07.2020 23:45:14
14,400
e3303c01e7a3b21679c0f0b0915a47e90b28ba93
[native] Center splash header within Safe Area bounds on iOS
[ { "change_type": "MODIFY", "old_path": "native/account/logged-out-modal.react.js", "new_path": "native/account/logged-out-modal.react.js", "diff": "@@ -25,7 +25,6 @@ import {\nPlatform,\nBackHandler,\nActivityIndicator,\n- DeviceInfo,\n} from 'react-native';\nimport invariant from 'invariant';\nimport Icon from 'react-native-vector-icons/FontAwesome';\n@@ -325,11 +324,7 @@ class LoggedOutModal extends React.PureComponent<Props, State> {\n// We need to make space for the password manager on smaller devices\ncontainerSize += windowHeight < 600 ? 261 : 246;\n} else {\n- // This is arbitrary and artificial... actually centering just looks a bit\n- // weird because the buttons are at the bottom. The reason it's different\n- // for iPhone X is because that's where LaunchScreen.storyboard places it\n- // and I'm not sure how to get AutoLayout to behave consistently with Yoga\n- containerSize += DeviceInfo.getConstants().isIPhoneX_deprecated ? 50 : 61;\n+ containerSize += Platform.OS === 'ios' ? 40 : 61;\n}\nconst contentHeight = windowHeight - bottomInset - topInset;\nreturn (contentHeight - keyboardHeight - containerSize) / 2;\n" }, { "change_type": "MODIFY", "old_path": "native/ios/SplashScreen.storyboard", "new_path": "native/ios/SplashScreen.storyboard", "diff": "<color key=\"tintColor\" red=\"1\" green=\"0.0\" blue=\"0.092869963400000005\" alpha=\"0.0\" colorSpace=\"custom\" customColorSpace=\"sRGB\"/>\n</imageView>\n<imageView clipsSubviews=\"YES\" userInteractionEnabled=\"NO\" contentMode=\"scaleAspectFit\" horizontalHuggingPriority=\"251\" verticalHuggingPriority=\"251\" image=\"Header\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"v97-50-knt\">\n- <rect key=\"frame\" x=\"118.5\" y=\"397\" width=\"177\" height=\"62\"/>\n+ <rect key=\"frame\" x=\"118.5\" y=\"402\" width=\"177\" height=\"62\"/>\n<color key=\"tintColor\" red=\"1\" green=\"0.0\" blue=\"0.092869963400000005\" alpha=\"0.0\" colorSpace=\"custom\" customColorSpace=\"sRGB\"/>\n</imageView>\n</subviews>\n<constraint firstItem=\"XDd-ht-ntp\" firstAttribute=\"leading\" secondItem=\"nvi-kw-ZOr\" secondAttribute=\"leading\" id=\"ZTe-QG-Nli\"/>\n<constraint firstItem=\"XDd-ht-ntp\" firstAttribute=\"centerX\" secondItem=\"nvi-kw-ZOr\" secondAttribute=\"centerX\" id=\"fVU-PV-N6U\"/>\n<constraint firstItem=\"XDd-ht-ntp\" firstAttribute=\"centerY\" secondItem=\"nvi-kw-ZOr\" secondAttribute=\"centerY\" id=\"tbV-Um-ZE2\"/>\n- <constraint firstItem=\"v97-50-knt\" firstAttribute=\"centerY\" secondItem=\"nvi-kw-ZOr\" secondAttribute=\"centerY\" constant=\"-20\" id=\"y4g-id-F9J\"/>\n+ <constraint firstItem=\"v97-50-knt\" firstAttribute=\"centerY\" secondItem=\"LGf-cj-VRq\" secondAttribute=\"centerY\" constant=\"-20\" id=\"y4g-id-F9J\"/>\n</constraints>\n<viewLayoutGuide key=\"safeArea\" id=\"LGf-cj-VRq\"/>\n</view>\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Center splash header within Safe Area bounds on iOS
129,187
13.07.2020 23:46:29
14,400
91fc804830023cfba901ec4c808b4f2f8e656fb2
[native] Standardize positioning of VerificationModal close button
[ { "change_type": "MODIFY", "old_path": "native/account/verification-modal.react.js", "new_path": "native/account/verification-modal.react.js", "diff": "@@ -28,7 +28,6 @@ import {\nKeyboard,\nTouchableHighlight,\nEasing,\n- DeviceInfo,\n} from 'react-native';\nimport Icon from 'react-native-vector-icons/FontAwesome';\nimport invariant from 'invariant';\n@@ -451,9 +450,7 @@ class VerificationModal extends React.PureComponent<Props, State> {\n}\nconst padding = { paddingTop: this.state.paddingTop };\nconst animatedContent = (\n- <Animated.View style={[styles.animationContainer, padding]}>\n- {content}\n- </Animated.View>\n+ <Animated.View style={padding}>{content}</Animated.View>\n);\nreturn (\n<React.Fragment>\n@@ -470,22 +467,14 @@ class VerificationModal extends React.PureComponent<Props, State> {\n}\n}\n-const closeButtonTop =\n- Platform.OS === 'ios'\n- ? DeviceInfo.getConstants().isIPhoneX_deprecated\n- ? 49\n- : 25\n- : 15;\n-\nconst styles = StyleSheet.create({\n- animationContainer: {},\ncloseButton: {\nbackgroundColor: '#D0D0D055',\nborderRadius: 3,\nheight: 36,\nposition: 'absolute',\nright: 15,\n- top: closeButtonTop,\n+ top: 15,\nwidth: 36,\n},\ncloseButtonIcon: {\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Standardize positioning of VerificationModal close button
129,187
13.07.2020 23:53:53
14,400
b1f94749613a3844a148a8d7cfb2ed120bc1441d
[native] Keep Calendar DisconnectedBar within SafeAreaView
[ { "change_type": "MODIFY", "old_path": "native/calendar/calendar.react.js", "new_path": "native/calendar/calendar.react.js", "diff": "@@ -746,13 +746,13 @@ class Calendar extends React.PureComponent<Props, State> {\nconst disableInputBar = this.state.currentlyEditing.length === 0;\nreturn (\n<>\n- <DisconnectedBar visible={this.props.calendarActive} />\n<TextHeightMeasurer\ntextToMeasure={this.state.textToMeasure}\nallHeightsMeasuredCallback={this.allHeightsMeasured}\nstyle={[entryStyles.entry, entryStyles.text]}\n/>\n<SafeAreaView style={this.props.styles.container} edges={safeAreaEdges}>\n+ <DisconnectedBar visible={this.props.calendarActive} />\n{loadingIndicator}\n{flatList}\n</SafeAreaView>\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Keep Calendar DisconnectedBar within SafeAreaView
129,187
14.07.2020 15:02:07
14,400
e77bf0b9488c35ab203a693c844cfbd62fd71034
[native] Dismiss media gallery when ChatList background pressed
[ { "change_type": "MODIFY", "old_path": "native/chat/chat-list.react.js", "new_path": "native/chat/chat-list.react.js", "diff": "@@ -9,6 +9,10 @@ import type { TabNavigationProp } from '../navigation/app-navigator.react';\nimport type { ChatMessageItemWithHeight } from './message-list-container.react';\nimport type { ViewStyle } from '../types/styles';\nimport type { AppState } from '../redux/redux-setup';\n+import {\n+ type KeyboardState,\n+ withKeyboardState,\n+} from '../keyboard/keyboard-state';\nimport * as React from 'react';\nimport {\n@@ -17,6 +21,8 @@ import {\nAnimated,\nEasing,\nStyleSheet,\n+ TouchableWithoutFeedback,\n+ View,\n} from 'react-native';\nimport invariant from 'invariant';\nimport _sum from 'lodash/fp/sum';\n@@ -55,6 +61,8 @@ type Props = {\ndata: $ReadOnlyArray<ChatMessageItemWithHeight>,\n// Redux state\nviewerID: ?string,\n+ // withKeyboardState\n+ keyboardState: ?KeyboardState,\n};\ntype State = {|\nnewMessageCount: number,\n@@ -208,7 +216,8 @@ class ChatList extends React.PureComponent<Props, State> {\nconst { navigation, viewerID, ...rest } = this.props;\nconst { newMessageCount } = this.state;\nreturn (\n- <>\n+ <TouchableWithoutFeedback onPress={this.onPressBackground}>\n+ <View style={styles.container}>\n<FlatList\n{...rest}\nkeyExtractor={chatMessageItemKey}\n@@ -223,7 +232,8 @@ class ChatList extends React.PureComponent<Props, State> {\ncontainerStyle={styles.newMessagesPillContainer}\nstyle={this.newMessagesPillStyle}\n/>\n- </>\n+ </View>\n+ </TouchableWithoutFeedback>\n);\n}\n@@ -284,9 +294,17 @@ class ChatList extends React.PureComponent<Props, State> {\nflatList.scrollToOffset({ offset: 0 });\nthis.toggleNewMessagesPill(false);\n};\n+\n+ onPressBackground = () => {\n+ const { keyboardState } = this.props;\n+ keyboardState && keyboardState.dismissKeyboard();\n+ };\n}\nconst styles = StyleSheet.create({\n+ container: {\n+ flex: 1,\n+ },\nnewMessagesPillContainer: {\nbottom: 30,\nposition: 'absolute',\n@@ -296,4 +314,4 @@ const styles = StyleSheet.create({\nexport default connect((state: AppState) => ({\nviewerID: state.currentUserInfo && state.currentUserInfo.id,\n-}))(ChatList);\n+}))(withKeyboardState(ChatList));\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Dismiss media gallery when ChatList background pressed
129,187
15.07.2020 00:32:56
14,400
9fd32aef2fc2e5468717d6be6b3d79bd165582ee
[native] react-native-safe-area-context@^3.1.1
[ { "change_type": "MODIFY", "old_path": "native/ios/Podfile.lock", "new_path": "native/ios/Podfile.lock", "diff": "@@ -297,7 +297,7 @@ PODS:\n- React\n- react-native-orientation-locker (1.1.6):\n- React\n- - react-native-safe-area-context (3.0.6):\n+ - react-native-safe-area-context (3.1.1):\n- React\n- react-native-video/Video (5.0.2):\n- React\n@@ -739,7 +739,7 @@ SPEC CHECKSUMS:\nreact-native-notifications: bb042206ac7eab9323d528c780b3d6fe796c1f5e\nreact-native-onepassword: 5b2b7f425f9db40932703e65d350b78cbc598047\nreact-native-orientation-locker: 23918c400376a7043e752c639c122fcf6bce8f1c\n- react-native-safe-area-context: e22a8ca00f758273d2408953965cb8db67da7925\n+ react-native-safe-area-context: 344b969c45af3d8464d36e8dea264942992ef033\nreact-native-video: d01ed7ff1e38fa7dcc6c15c94cf505e661b7bfd0\nReact-RCTActionSheet: f41ea8a811aac770e0cc6e0ad6b270c644ea8b7c\nReact-RCTAnimation: 49ab98b1c1ff4445148b72a3d61554138565bad0\n" }, { "change_type": "MODIFY", "old_path": "native/package.json", "new_path": "native/package.json", "diff": "\"react-native-orientation-locker\": \"^1.1.6\",\n\"react-native-progress\": \"^4.0.3\",\n\"react-native-reanimated\": \"^1.9.0\",\n- \"react-native-safe-area-context\": \"^3.0.6\",\n+ \"react-native-safe-area-context\": \"^3.1.1\",\n\"react-native-screens\": \"^2.9.0\",\n\"react-native-tab-view\": \"^2.14.4\",\n\"react-native-unimodules\": \"^0.9.0\",\n" }, { "change_type": "MODIFY", "old_path": "yarn.lock", "new_path": "yarn.lock", "diff": "@@ -12181,10 +12181,10 @@ react-native-reanimated@^1.9.0:\ndependencies:\nfbjs \"^1.0.0\"\n-react-native-safe-area-context@^3.0.6:\n- version \"3.0.6\"\n- resolved \"https://registry.yarnpkg.com/react-native-safe-area-context/-/react-native-safe-area-context-3.0.6.tgz#ee180f53f9f40f8302923b9c09d821cf8ada01eb\"\n- integrity sha512-/McWHgRG3CjXo/1ctlxH3mjW2psjf/QYAt9kWUTEtHu4b6z1y4hfUIGuYEJ02asaS1ixPsYrkqVqwzTv4olUMQ==\n+react-native-safe-area-context@^3.1.1:\n+ version \"3.1.1\"\n+ resolved \"https://registry.yarnpkg.com/react-native-safe-area-context/-/react-native-safe-area-context-3.1.1.tgz#9b04d1154766e6c1132030aca8f4b0336f561ccd\"\n+ integrity sha512-Iqb41OT5+QxFn0tpTbbHgz8+3VU/F9OH2fTeeoU7oZCzojOXQbC6sp6mN7BlsAoTKhngWoJLMcSosL58uRaLWQ==\nreact-native-safe-modules@^1.0.0:\nversion \"1.0.0\"\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] react-native-safe-area-context@^3.1.1
129,187
15.07.2020 00:33:22
14,400
e752603c9663582d810292626daa76604ce244c5
[native] Fix DimensionsUpdater for androidKeyboardResizesFrame
[ { "change_type": "MODIFY", "old_path": "native/redux/dimensions-updater.react.js", "new_path": "native/redux/dimensions-updater.react.js", "diff": "@@ -10,6 +10,12 @@ import {\nuseSafeAreaInsets,\n} from 'react-native-safe-area-context';\nimport PropTypes from 'prop-types';\n+import {\n+ addKeyboardShowListener,\n+ addKeyboardDismissListener,\n+ removeKeyboardListener,\n+ androidKeyboardResizesFrame,\n+} from '../keyboard/keyboard';\nimport { updateDimensionsActiveType } from './action-types';\n@@ -36,8 +42,8 @@ function dimensionsUpdateFromMetrics(metrics: Metrics): $Shape<DimensionsInfo> {\nreturn {\nheight: metrics.frame.height,\nwidth: metrics.frame.width,\n- topInset: metrics.insets.top,\n- bottomInset: metrics.insets.bottom,\n+ topInset: androidKeyboardResizesFrame ? 0 : metrics.insets.top,\n+ bottomInset: androidKeyboardResizesFrame ? 0 : metrics.insets.bottom,\n};\n}\n@@ -53,7 +59,30 @@ function DimensionsUpdater() {\nconst frame = useSafeAreaFrame();\nconst insets = useSafeAreaInsets();\n+ const keyboardShowingRef = React.useRef();\n+ const keyboardShow = React.useCallback(() => {\n+ keyboardShowingRef.current = true;\n+ }, []);\n+ const keyboardDismiss = React.useCallback(() => {\n+ keyboardShowingRef.current = false;\n+ }, []);\n+ React.useEffect(() => {\n+ if (!androidKeyboardResizesFrame) {\n+ return;\n+ }\n+ const showListener = addKeyboardShowListener(keyboardShow);\n+ const dismissListener = addKeyboardDismissListener(keyboardDismiss);\n+ return () => {\n+ removeKeyboardListener(showListener);\n+ removeKeyboardListener(dismissListener);\n+ };\n+ }, [keyboardShow, keyboardDismiss]);\n+ const keyboardShowing = keyboardShowingRef.current;\n+\nReact.useEffect(() => {\n+ if (keyboardShowing) {\n+ return;\n+ }\nconst updates = dimensionsUpdateFromMetrics({ frame, insets });\nfor (let key in updates) {\nif (updates[key] === dimensions[key]) {\n@@ -65,7 +94,7 @@ function DimensionsUpdater() {\n});\nreturn;\n}\n- }, [dimensions, dispatch, frame, insets]);\n+ }, [keyboardShowing, dimensions, dispatch, frame, insets]);\nreturn null;\n}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Fix DimensionsUpdater for androidKeyboardResizesFrame
129,187
15.07.2020 01:09:39
14,400
c1918733bf31fd75a1b5fd71cbe5f56660fe9b91
[native] Block goBack nav actions by returning null instead of lastState This fixes `canGoBack()`, which lets the back button correctly background the app when React Nav can't handle it
[ { "change_type": "MODIFY", "old_path": "native/navigation/root-router.js", "new_path": "native/navigation/root-router.js", "diff": "@@ -193,7 +193,7 @@ function RootRouter(\naccountModals.includes(lastRouteName) &&\n!accountModals.includes(newRouteName)\n) {\n- return lastState;\n+ return null;\n}\nreturn newState;\n}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Block goBack nav actions by returning null instead of lastState This fixes `canGoBack()`, which lets the back button correctly background the app when React Nav can't handle it
129,187
15.07.2020 01:14:09
14,400
508ac9f92a361233f02a2a932e9ba788a30cc794
[native] codeVersion -> 57
[ { "change_type": "MODIFY", "old_path": "native/android/app/build.gradle", "new_path": "native/android/app/build.gradle", "diff": "@@ -133,8 +133,8 @@ android {\napplicationId \"org.squadcal\"\nminSdkVersion rootProject.ext.minSdkVersion\ntargetSdkVersion rootProject.ext.targetSdkVersion\n- versionCode 56\n- versionName \"0.0.56\"\n+ versionCode 57\n+ versionName \"0.0.57\"\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.56</string>\n+ <string>0.0.57</string>\n<key>CFBundleSignature</key>\n<string>????</string>\n<key>CFBundleVersion</key>\n- <string>56</string>\n+ <string>57</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.56</string>\n+ <string>0.0.57</string>\n<key>CFBundleSignature</key>\n<string>????</string>\n<key>CFBundleVersion</key>\n- <string>56</string>\n+ <string>57</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": "@@ -175,7 +175,7 @@ const persistConfig = {\ntimeout: __DEV__ ? 0 : undefined,\n};\n-const codeVersion = 56;\n+const codeVersion = 57;\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 -> 57
129,187
15.07.2020 12:53:02
14,400
7c257ab6b4a08cff02716ddd73d06d85dff3556f
[server] Dedup membership changeset in commitMembershipChangeset
[ { "change_type": "MODIFY", "old_path": "server/src/creators/thread-creator.js", "new_path": "server/src/creators/thread-creator.js", "diff": "@@ -99,12 +99,7 @@ async function createThread(\nconst initialMemberAndCreatorIDs = initialMemberIDs\n? [...initialMemberIDs, viewer.userID]\n: [viewer.userID];\n- const changeset = [\n- ...creatorChangeset,\n- ...recalculatePermissionsChangeset.filter(\n- rowToSave => !initialMemberAndCreatorIDs.includes(rowToSave.userID),\n- ),\n- ];\n+ const changeset = [...creatorChangeset, ...recalculatePermissionsChangeset];\nif (initialMemberIDs && initialMemberIDs.length > 0) {\nif (!initialMembersChangeset) {\nthrow new ServerError('unknown_error');\n" }, { "change_type": "MODIFY", "old_path": "server/src/updaters/thread-permission-updaters.js", "new_path": "server/src/updaters/thread-permission-updaters.js", "diff": "@@ -492,42 +492,47 @@ async function commitMembershipChangeset(\nthrow new ServerError('not_logged_in');\n}\n+ const threadMembershipCreationPairs = new Set();\n+ const threadMembershipDeletionPairs = new Set();\n+ for (let row of changeset) {\n+ const { userID, threadID } = row;\n+ changedThreadIDs.add(threadID);\n+\n+ const pairString = `${userID}|${threadID}`;\n+ if (row.operation === 'join') {\n+ threadMembershipCreationPairs.add(pairString);\n+ } else if (row.operation === 'delete') {\n+ threadMembershipDeletionPairs.add(pairString);\n+ }\n+ }\n+\nconst toJoin = [],\ntoUpdate = [],\ntoDelete = [];\nfor (let row of changeset) {\nif (row.operation === 'join') {\ntoJoin.push(row);\n- } else if (row.operation === 'update') {\n- toUpdate.push(row);\n} else if (row.operation === 'delete') {\ntoDelete.push(row);\n+ } else if (row.operation === 'update') {\n+ const { userID, threadID } = row;\n+ const pairString = `${userID}|${threadID}`;\n+ if (\n+ !threadMembershipCreationPairs.has(pairString) &&\n+ !threadMembershipDeletionPairs.has(pairString)\n+ ) {\n+ toUpdate.push(row);\n+ }\n}\n}\n-\nawait Promise.all([\nsaveMemberships([...toJoin, ...toUpdate]),\ndeleteMemberships(toDelete),\n]);\n- const threadMembershipCreationPairs = new Set();\n- const threadMembershipDeletionPairs = new Set();\n- for (let rowToJoin of toJoin) {\n- const { userID, threadID } = rowToJoin;\n- changedThreadIDs.add(threadID);\n- threadMembershipCreationPairs.add(`${userID}|${threadID}`);\n- }\n- for (let rowToUpdate of toUpdate) {\n- const { threadID } = rowToUpdate;\n- changedThreadIDs.add(threadID);\n- }\n- for (let rowToDelete of toDelete) {\n- const { userID, threadID } = rowToDelete;\n- changedThreadIDs.add(threadID);\n- threadMembershipDeletionPairs.add(`${userID}|${threadID}`);\n- }\n-\n- const serverThreadInfoFetchResult = await fetchServerThreadInfos();\n+ const serverThreadInfoFetchResult = await fetchServerThreadInfos(\n+ SQL`t.id IN (${[...changedThreadIDs]})`,\n+ );\nconst { threadInfos: serverThreadInfos } = serverThreadInfoFetchResult;\nconst time = Date.now();\n" }, { "change_type": "MODIFY", "old_path": "server/src/updaters/thread-updaters.js", "new_path": "server/src/updaters/thread-updaters.js", "diff": "@@ -438,21 +438,12 @@ async function updateThread(\n} = await promiseAll(savePromises);\nconst changeset = [];\n- if (recalculatePermissionsChangeset && newMemberIDs) {\n- changeset.push(\n- ...recalculatePermissionsChangeset.filter(\n- rowToSave => !newMemberIDs.includes(rowToSave.userID),\n- ),\n- );\n- } else if (recalculatePermissionsChangeset) {\n+ if (recalculatePermissionsChangeset) {\nchangeset.push(...recalculatePermissionsChangeset);\n}\nif (addMembersChangeset) {\n- for (let rowToSave of addMembersChangeset) {\n- if (rowToSave.operation === 'delete') {\n- changeset.push(rowToSave);\n- continue;\n- }\n+ changeset.push(\n+ addMembersChangeset.map(rowToSave => {\nif (\nrowToSave.operation === 'join' &&\n(rowToSave.userID !== viewer.userID ||\n@@ -460,8 +451,9 @@ async function updateThread(\n) {\nrowToSave.unread = true;\n}\n- changeset.push(rowToSave);\n- }\n+ return rowToSave;\n+ }),\n+ );\n}\nconst time = Date.now();\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[server] Dedup membership changeset in commitMembershipChangeset
129,187
15.07.2020 15:12:18
14,400
3a2eee3a9c3889207c2b5f32d68622c0099915ff
[server] setJoinsToUnread
[ { "change_type": "MODIFY", "old_path": "server/src/creators/thread-creator.js", "new_path": "server/src/creators/thread-creator.js", "diff": "@@ -21,6 +21,7 @@ import {\nchangeRole,\nrecalculateAllPermissions,\ncommitMembershipChangeset,\n+ setJoinsToUnread,\n} from '../updaters/thread-permission-updaters';\nimport createMessages from './message-creator';\n@@ -106,17 +107,7 @@ async function createThread(\n}\nchangeset.push(...initialMembersChangeset);\n}\n- for (let rowToSave of changeset) {\n- if (rowToSave.operation === 'delete') {\n- continue;\n- }\n- if (\n- rowToSave.operation === 'join' &&\n- (rowToSave.userID !== viewer.userID || rowToSave.threadID !== id)\n- ) {\n- rowToSave.unread = true;\n- }\n- }\n+ setJoinsToUnread(changeset, viewer.userID, id);\nconst messageDatas = [\n{\n" }, { "change_type": "MODIFY", "old_path": "server/src/updaters/thread-permission-updaters.js", "new_path": "server/src/updaters/thread-permission-updaters.js", "diff": "@@ -591,4 +591,24 @@ async function commitMembershipChangeset(\n};\n}\n-export { changeRole, recalculateAllPermissions, commitMembershipChangeset };\n+function setJoinsToUnread(\n+ rows: Row[],\n+ exceptViewerID: string,\n+ exceptThreadID: string,\n+) {\n+ for (let row of rows) {\n+ if (\n+ row.operation === 'join' &&\n+ (row.userID !== exceptViewerID || row.threadID !== exceptThreadID)\n+ ) {\n+ row.unread = true;\n+ }\n+ }\n+}\n+\n+export {\n+ changeRole,\n+ recalculateAllPermissions,\n+ commitMembershipChangeset,\n+ setJoinsToUnread,\n+};\n" }, { "change_type": "MODIFY", "old_path": "server/src/updaters/thread-updaters.js", "new_path": "server/src/updaters/thread-updaters.js", "diff": "@@ -39,6 +39,7 @@ import {\nchangeRole,\nrecalculateAllPermissions,\ncommitMembershipChangeset,\n+ setJoinsToUnread,\n} from './thread-permission-updaters';\nimport createMessages from '../creators/message-creator';\nimport { fetchMessageInfos } from '../fetchers/message-fetchers';\n@@ -442,18 +443,8 @@ async function updateThread(\nchangeset.push(...recalculatePermissionsChangeset);\n}\nif (addMembersChangeset) {\n- changeset.push(\n- addMembersChangeset.map(rowToSave => {\n- if (\n- rowToSave.operation === 'join' &&\n- (rowToSave.userID !== viewer.userID ||\n- rowToSave.threadID !== request.threadID)\n- ) {\n- rowToSave.unread = true;\n- }\n- return rowToSave;\n- }),\n- );\n+ setJoinsToUnread(addMembersChangeset, viewer.userID, request.threadID);\n+ changeset.push(addMembersChangeset);\n}\nconst time = Date.now();\n@@ -538,18 +529,7 @@ async function joinThread(\nif (!changeset) {\nthrow new ServerError('unknown_error');\n}\n- for (let rowToSave of changeset) {\n- if (rowToSave.operation === 'delete') {\n- continue;\n- }\n- if (\n- rowToSave.operation === 'join' &&\n- (rowToSave.userID !== viewer.userID ||\n- rowToSave.threadID !== request.threadID)\n- ) {\n- rowToSave.unread = true;\n- }\n- }\n+ setJoinsToUnread(changeset, viewer.userID, request.threadID);\nconst messageData = {\ntype: messageTypes.JOIN_THREAD,\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[server] setJoinsToUnread
129,187
15.07.2020 17:23:27
14,400
0f8fc31521dac5c7705cf9d5de89e2f03caa4a0e
[server] One update per pairString in commitMembershipChangeset
[ { "change_type": "MODIFY", "old_path": "server/src/updaters/thread-permission-updaters.js", "new_path": "server/src/updaters/thread-permission-updaters.js", "diff": "@@ -492,43 +492,33 @@ async function commitMembershipChangeset(\nthrow new ServerError('not_logged_in');\n}\n- const threadMembershipCreationPairs = new Set();\n- const threadMembershipDeletionPairs = new Set();\n+ const membershipRowMap = new Map();\nfor (let row of changeset) {\nconst { userID, threadID } = row;\nchangedThreadIDs.add(threadID);\nconst pairString = `${userID}|${threadID}`;\n- if (row.operation === 'join') {\n- threadMembershipCreationPairs.add(pairString);\n- } else if (row.operation === 'delete') {\n- threadMembershipDeletionPairs.add(pairString);\n+ const existing = membershipRowMap.get(pairString);\n+ if (\n+ !existing ||\n+ (existing.operation !== 'join' &&\n+ (row.operation === 'join' ||\n+ (row.operation === 'delete' && existing.operation === 'update')))\n+ ) {\n+ membershipRowMap.set(pairString, row);\n}\n}\n- const toJoin = [],\n- toUpdate = [],\n+ const toSave = [],\ntoDelete = [];\n- for (let row of changeset) {\n- if (row.operation === 'join') {\n- toJoin.push(row);\n- } else if (row.operation === 'delete') {\n+ for (let row of membershipRowMap.values()) {\n+ if (row.operation === 'delete') {\ntoDelete.push(row);\n- } else if (row.operation === 'update') {\n- const { userID, threadID } = row;\n- const pairString = `${userID}|${threadID}`;\n- if (\n- !threadMembershipCreationPairs.has(pairString) &&\n- !threadMembershipDeletionPairs.has(pairString)\n- ) {\n- toUpdate.push(row);\n- }\n+ } else {\n+ toSave.push(row);\n}\n}\n- await Promise.all([\n- saveMemberships([...toJoin, ...toUpdate]),\n- deleteMemberships(toDelete),\n- ]);\n+ await Promise.all([saveMemberships(toSave), deleteMemberships(toDelete)]);\nconst serverThreadInfoFetchResult = await fetchServerThreadInfos(\nSQL`t.id IN (${[...changedThreadIDs]})`,\n@@ -541,10 +531,8 @@ async function commitMembershipChangeset(\nconst serverThreadInfo = serverThreadInfos[changedThreadID];\nfor (let memberInfo of serverThreadInfo.members) {\nconst pairString = `${memberInfo.id}|${serverThreadInfo.id}`;\n- if (\n- threadMembershipCreationPairs.has(pairString) ||\n- threadMembershipDeletionPairs.has(pairString)\n- ) {\n+ const membershipRow = membershipRowMap.get(pairString);\n+ if (membershipRow && membershipRow.operation !== 'update') {\ncontinue;\n}\nupdateDatas.push({\n@@ -555,17 +543,16 @@ async function commitMembershipChangeset(\n});\n}\n}\n- for (let pair of threadMembershipCreationPairs) {\n- const [userID, threadID] = pair.split('|');\n+ for (let row of membershipRowMap.values()) {\n+ const { userID, threadID } = row;\n+ if (row.operation === 'join') {\nupdateDatas.push({\ntype: updateTypes.JOIN_THREAD,\nuserID,\ntime,\nthreadID,\n});\n- }\n- for (let pair of threadMembershipDeletionPairs) {\n- const [userID, threadID] = pair.split('|');\n+ } else if (row.operation === 'delete') {\nupdateDatas.push({\ntype: updateTypes.DELETE_THREAD,\nuserID,\n@@ -573,6 +560,7 @@ async function commitMembershipChangeset(\nthreadID,\n});\n}\n+ }\nconst threadInfoFetchResult = rawThreadInfosFromServerThreadInfos(\nviewer,\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[server] One update per pairString in commitMembershipChangeset
129,187
15.07.2020 18:04:26
14,400
42cd4ff8ac055fdcdec02250ab3f415c0a6f71e7
[native] Fix pointerEvents for behavior="position" KeyboardAvoidingView
[ { "change_type": "MODIFY", "old_path": "native/components/keyboard-avoiding-view.react.js", "new_path": "native/components/keyboard-avoiding-view.react.js", "diff": "@@ -171,9 +171,12 @@ class InnerKeyboardAvoidingView extends React.PureComponent<Props, State> {\nconst composedStyle = StyleSheet.compose(contentContainerStyle, {\nbottom,\n});\n+ const { pointerEvents } = props;\nreturn (\n<View style={style} onLayout={this.onLayout} {...props}>\n- <View style={composedStyle}>{children}</View>\n+ <View style={composedStyle} pointerEvents={pointerEvents}>\n+ {children}\n+ </View>\n</View>\n);\n} else if (behavior === 'padding') {\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Fix pointerEvents for behavior="position" KeyboardAvoidingView
129,187
15.07.2020 22:27:54
14,400
654af201bf37baf4e622cae899017f348aa93eca
[native] Fix MultimediaModal frame parameters
[ { "change_type": "MODIFY", "old_path": "native/media/multimedia-modal.react.js", "new_path": "native/media/multimedia-modal.react.js", "diff": "@@ -995,8 +995,8 @@ class MultimediaModal extends React.PureComponent<Props, State> {\n}\nget frame(): Dimensions {\n- const { height, width, topInset, bottomInset } = this.props.dimensions;\n- return { height, width: width - topInset - bottomInset };\n+ const { width, height, topInset, bottomInset } = this.props.dimensions;\n+ return { width, height: height - topInset - bottomInset };\n}\nget imageDimensions(): Dimensions {\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Fix MultimediaModal frame parameters
129,187
15.07.2020 22:32:04
14,400
59b5b2a98ae628944aa65e6a2cb88f82e117987e
[native] codeVersion -> 58
[ { "change_type": "MODIFY", "old_path": "native/android/app/build.gradle", "new_path": "native/android/app/build.gradle", "diff": "@@ -133,8 +133,8 @@ android {\napplicationId \"org.squadcal\"\nminSdkVersion rootProject.ext.minSdkVersion\ntargetSdkVersion rootProject.ext.targetSdkVersion\n- versionCode 57\n- versionName \"0.0.57\"\n+ versionCode 58\n+ versionName \"0.0.58\"\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.57</string>\n+ <string>0.0.58</string>\n<key>CFBundleSignature</key>\n<string>????</string>\n<key>CFBundleVersion</key>\n- <string>57</string>\n+ <string>58</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.57</string>\n+ <string>0.0.58</string>\n<key>CFBundleSignature</key>\n<string>????</string>\n<key>CFBundleVersion</key>\n- <string>57</string>\n+ <string>58</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": "@@ -175,7 +175,7 @@ const persistConfig = {\ntimeout: __DEV__ ? 0 : undefined,\n};\n-const codeVersion = 57;\n+const codeVersion = 58;\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 -> 58
129,187
16.07.2020 13:01:16
14,400
980dc596642f08d239ed4f728c8632176d00914c
[native] Disable android:windowTranslucentNavigation in dev mode Error messages end up drawing below the navigation bar, which makes the buttons hard to press. My PR should fix this. We can revert this commit once we upgrade to a version of React Native that has merged that PR
[ { "change_type": "ADD", "old_path": null, "new_path": "native/android/app/src/debug/res/values-v21/styles.xml", "diff": "+<resources>\n+ <style name=\"AppTheme\" parent=\"AppThemeBase\">\n+ <item name=\"android:windowTranslucentStatus\">true</item>\n+ <item name=\"android:windowTranslucentNavigation\">false</item>\n+ </style>\n+ <style name=\"NoSplashTheme\" parent=\"SplashThemeBase\">\n+ <item name=\"android:windowTranslucentStatus\">true</item>\n+ <item name=\"android:windowTranslucentNavigation\">false</item>\n+ </style>\n+</resources>\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Disable android:windowTranslucentNavigation in dev mode Error messages end up drawing below the navigation bar, which makes the buttons hard to press. My PR https://github.com/facebook/react-native/pull/29399 should fix this. We can revert this commit once we upgrade to a version of React Native that has merged that PR
129,187
16.07.2020 18:21:39
14,400
98341cf203c4e047557193b292b268d8f3558115
Don't add know_of rows in changeRole if membership row already exists
[ { "change_type": "MODIFY", "old_path": "server/src/updaters/thread-permission-updaters.js", "new_path": "server/src/updaters/thread-permission-updaters.js", "diff": "@@ -103,6 +103,7 @@ async function changeRole(\nfor (let userID of userIDs) {\nlet oldPermissionsForChildren = null;\nlet permissionsFromParent = null;\n+ let hadMembershipRow = false;\nconst userRoleInfo = roleInfo.get(userID);\nif (userRoleInfo) {\nconst oldRole = userRoleInfo.oldRole;\n@@ -117,6 +118,7 @@ async function changeRole(\n}\noldPermissionsForChildren = userRoleInfo.oldPermissionsForChildren;\npermissionsFromParent = userRoleInfo.permissionsFromParent;\n+ hadMembershipRow = true;\n}\nconst permissions = makePermissionsBlob(\n@@ -140,8 +142,15 @@ async function changeRole(\npermissionsForChildren,\nrole: roleThreadResult.roleColumnValue,\n});\n- memberIDs.add(userID);\n+ } else {\n+ membershipRows.push({\n+ operation: 'delete',\n+ userID,\n+ threadID,\n+ });\n+ }\n+ if (permissions && !hadMembershipRow) {\nfor (const currentUserID of memberIDs) {\nif (userID !== currentUserID) {\nconst [user1, user2] = sortIDs(userID, currentUserID);\n@@ -152,12 +161,7 @@ async function changeRole(\n});\n}\n}\n- } else {\n- membershipRows.push({\n- operation: 'delete',\n- userID,\n- threadID,\n- });\n+ memberIDs.add(userID);\n}\nif (!_isEqual(permissionsForChildren)(oldPermissionsForChildren)) {\n@@ -293,6 +297,7 @@ async function updateDescendantPermissions(\nconst oldPermissionsForChildren = userInfo\n? userInfo.permissionsForChildren\n: null;\n+\nconst permissions = makePermissionsBlob(\nrolePermissions,\npermissionsFromParent,\n@@ -307,6 +312,7 @@ async function updateDescendantPermissions(\nconst permissionsForChildren = makePermissionsForChildrenBlob(\npermissions,\n);\n+\nif (permissions) {\nmembershipRows.push({\noperation: 'update',\n@@ -316,8 +322,15 @@ async function updateDescendantPermissions(\npermissionsForChildren,\nrole,\n});\n+ } else {\n+ membershipRows.push({\n+ operation: 'delete',\n+ userID,\n+ threadID,\n+ });\n+ }\n- if (!oldPermissions) {\n+ if (permissions && !oldPermissions) {\nfor (const [childUserID] of userInfos) {\nif (childUserID !== userID) {\nconst [user1, user2] = sortIDs(childUserID, userID);\n@@ -326,13 +339,7 @@ async function updateDescendantPermissions(\n}\n}\n}\n- } else {\n- membershipRows.push({\n- operation: 'delete',\n- userID,\n- threadID,\n- });\n- }\n+\nif (!_isEqual(permissionsForChildren)(oldPermissionsForChildren)) {\nusersForNextLayer.set(userID, permissionsForChildren);\n}\n@@ -400,6 +407,7 @@ async function recalculateAllPermissions(\nconst oldPermissionsForChildren = JSON.parse(row.permissions_for_children);\nconst permissionsFromParent = JSON.parse(row.permissions_from_parent);\nconst rolePermissions = JSON.parse(row.role_permissions);\n+\nconst permissions = makePermissionsBlob(\nrolePermissions,\npermissionsFromParent,\n@@ -412,6 +420,7 @@ async function recalculateAllPermissions(\ncontinue;\n}\nconst permissionsForChildren = makePermissionsForChildrenBlob(permissions);\n+\nif (permissions) {\nmembershipRows.push({\noperation: 'update',\n@@ -421,8 +430,15 @@ async function recalculateAllPermissions(\npermissionsForChildren,\nrole,\n});\n+ } else {\n+ membershipRows.push({\n+ operation: 'delete',\n+ userID,\n+ threadID,\n+ });\n+ }\n- if (!oldPermissions) {\n+ if (permissions && !oldPermissions) {\nparentIDs.add(userID);\nfor (const childID of childIDs) {\nconst [user1, user2] = sortIDs(userID, childID);\n@@ -433,13 +449,7 @@ async function recalculateAllPermissions(\n});\n}\n}\n- } else {\n- membershipRows.push({\n- operation: 'delete',\n- userID,\n- threadID,\n- });\n- }\n+\nif (!_isEqual(permissionsForChildren)(oldPermissionsForChildren)) {\ntoUpdateDescendants.set(userID, permissionsForChildren);\n}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Don't add know_of rows in changeRole if membership row already exists
129,187
18.07.2020 06:47:06
14,400
878f88023f3df5887a8ef2651249e3562d686481
[server] Fix accidental duplicate chokidar-cli
[ { "change_type": "MODIFY", "old_path": "server/package.json", "new_path": "server/package.json", "diff": "\"@babel/plugin-syntax-dynamic-import\": \"^7.2.0\",\n\"@babel/preset-flow\": \"^7.0.0\",\n\"@babel/preset-react\": \"^7.0.0\",\n- \"chokidar-cli\": \"^2.0.0\",\n+ \"chokidar-cli\": \"^2.1.0\",\n\"concurrently\": \"^5.0.0\",\n\"flow-bin\": \"^0.113.0\",\n\"flow-typed\": \"^2.2.3\",\n\"@vingle/bmp-js\": \"^0.2.5\",\n\"JSONStream\": \"^1.3.5\",\n\"apn\": \"git+https://github.com/node-apn/node-apn.git#3.0.0\",\n- \"chokidar-cli\": \"^2.1.0\",\n\"common-tags\": \"^1.7.2\",\n\"cookie-parser\": \"^1.4.3\",\n\"dateformat\": \"^3.0.3\",\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[server] Fix accidental duplicate chokidar-cli
129,187
19.07.2020 13:47:46
14,400
d8c86d3a5b11b9483f700e5c51f9070598eafe55
[lib] normalizeURL
[ { "change_type": "MODIFY", "old_path": "lib/package.json", "new_path": "lib/package.json", "diff": "\"string-hash\": \"^1.1.3\",\n\"tinycolor2\": \"^1.4.1\",\n\"tokenize-text\": \"^1.1.3\",\n+ \"url-parse-lax\": \"^3.0.0\",\n\"util-inspect\": \"^0.1.8\"\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "lib/utils/url-utils.js", "new_path": "lib/utils/url-utils.js", "diff": "// @flow\n+import urlParseLax from 'url-parse-lax';\n+\nexport type URLInfo = {\nyear?: number,\nmonth?: number, // 1-indexed\n@@ -48,6 +50,10 @@ function infoFromURL(url: string): URLInfo {\nreturn returnObj;\n}\n+function normalizeURL(url: string) {\n+ return urlParseLax(url).href;\n+}\n+\nconst setURLPrefix = 'SET_URL_PREFIX';\n-export { infoFromURL, setURLPrefix };\n+export { infoFromURL, normalizeURL, setURLPrefix };\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[lib] normalizeURL
129,187
19.07.2020 21:56:22
14,400
b3148f2d70f6ac0d786d45cf71e4a442a9ba74ff
[native] TextHeightMeasurer -> NodeHeightMeasurer Now can handle measuring any node, in preparation for having to measure `<Markdown>`
[ { "change_type": "MODIFY", "old_path": "native/calendar/calendar.react.js", "new_path": "native/calendar/calendar.react.js", "diff": "@@ -16,7 +16,7 @@ import type {\nimport type { ViewToken } from '../types/react-native';\nimport type { DispatchActionPromise } from 'lib/utils/action-utils';\nimport type { KeyboardEvent } from '../keyboard/keyboard';\n-import type { TextToMeasure } from '../text-height-measurer.react';\n+import type { NodeToMeasure } from '../components/node-height-measurer.react';\nimport {\ntype CalendarFilter,\ncalendarFilterPropType,\n@@ -76,7 +76,7 @@ import {\ncreateIsForegroundSelector,\ncreateActiveTabSelector,\n} from '../navigation/nav-selectors';\n-import TextHeightMeasurer from '../text-height-measurer.react';\n+import NodeHeightMeasurer from '../components/node-height-measurer.react';\nimport ListLoadingIndicator from '../components/list-loading-indicator.react';\nimport SectionFooter from './section-footer.react';\nimport CalendarInputBar from './calendar-input-bar.react';\n@@ -146,7 +146,7 @@ type Props = {\n) => Promise<CalendarQueryUpdateResult>,\n};\ntype State = {|\n- textToMeasure: TextToMeasure[],\n+ nodesToMeasure: NodeToMeasure[],\nlistDataWithHeights: ?$ReadOnlyArray<CalendarItemWithHeight>,\nreadyToShowList: boolean,\nextraData: ExtraData,\n@@ -197,7 +197,7 @@ class Calendar extends React.PureComponent<Props, State> {\nupdateCalendarQuery: PropTypes.func.isRequired,\n};\nflatList: ?FlatList<CalendarItemWithHeight> = null;\n- textHeights: ?Map<string, number> = null;\n+ nodeHeights: ?Map<string, number> = null;\ncurrentState: ?string = NativeAppState.currentState;\nlastForegrounded = 0;\nlastCalendarReset = 0;\n@@ -225,15 +225,15 @@ class Calendar extends React.PureComponent<Props, State> {\nconstructor(props: Props) {\nsuper(props);\n- const textToMeasure = props.listData\n- ? Calendar.textToMeasureFromListData(props.listData)\n+ const nodesToMeasure = props.listData\n+ ? Calendar.nodesToMeasureFromListData(props.listData)\n: [];\nthis.latestExtraData = {\nactiveEntries: {},\nvisibleEntries: {},\n};\nthis.state = {\n- textToMeasure,\n+ nodesToMeasure,\nlistDataWithHeights: null,\nreadyToShowList: false,\nextraData: this.latestExtraData,\n@@ -241,18 +241,20 @@ class Calendar extends React.PureComponent<Props, State> {\n};\n}\n- static textToMeasureFromListData(listData: $ReadOnlyArray<CalendarItem>) {\n- const textToMeasure = [];\n+ static nodesToMeasureFromListData(listData: $ReadOnlyArray<CalendarItem>) {\n+ const nodesToMeasure = [];\nfor (let item of listData) {\nif (item.itemType !== 'entryInfo') {\ncontinue;\n}\n- textToMeasure.push({\n+ const text = item.entryInfo.text === '' ? ' ' : item.entryInfo.text;\n+ const node = <Text style={entryStyles.text}>{text}</Text>;\n+ nodesToMeasure.push({\nid: entryKey(item.entryInfo),\n- text: item.entryInfo.text,\n+ node,\n});\n}\n- return textToMeasure;\n+ return nodesToMeasure;\n}\ncomponentDidMount() {\n@@ -308,7 +310,7 @@ class Calendar extends React.PureComponent<Props, State> {\ncomponentDidUpdate(prevProps: Props, prevState: State) {\nif (this.props.listData !== prevProps.listData) {\n- this.handleNewTextToMeasure();\n+ this.handleNewNodesToMeasure();\n}\nconst { loadingStatus, connectionStatus } = this.props;\n@@ -383,7 +385,7 @@ class Calendar extends React.PureComponent<Props, State> {\n}\n}\n- handleNewTextToMeasure() {\n+ handleNewNodesToMeasure() {\nconst { listData } = this.props;\nif (!listData) {\nthis.latestExtraData = {\n@@ -391,7 +393,7 @@ class Calendar extends React.PureComponent<Props, State> {\nvisibleEntries: {},\n};\nthis.setState({\n- textToMeasure: [],\n+ nodesToMeasure: [],\nlistDataWithHeights: null,\nreadyToShowList: false,\nextraData: this.latestExtraData,\n@@ -401,37 +403,37 @@ class Calendar extends React.PureComponent<Props, State> {\nreturn;\n}\n- const newTextToMeasure = Calendar.textToMeasureFromListData(listData);\n- const newText = _differenceWith(_isEqual)(newTextToMeasure)(\n- this.state.textToMeasure,\n+ const newNodesToMeasure = Calendar.nodesToMeasureFromListData(listData);\n+ const newNodes = _differenceWith(_isEqual)(newNodesToMeasure)(\n+ this.state.nodesToMeasure,\n);\n- if (newText.length !== 0) {\n- // We set textHeights to null here since if a future set of text\n- // came in before we completed text measurement that was a subset\n- // of the earlier text, we would end up merging directly there, but\n- // then when the measurement for the middle text came in it would\n- // override the newer text heights.\n- this.textHeights = null;\n- this.setState({ textToMeasure: newTextToMeasure });\n+ if (newNodes.length !== 0) {\n+ // We set nodeHeights to null here since if a future set of nodes\n+ // came in before we completed height measurement that was a subset\n+ // of the earlier nodes, we would end up merging directly there, but\n+ // then when the measurement for the middle nodes came in it would\n+ // override the newer node heights.\n+ this.nodeHeights = null;\n+ this.setState({ nodesToMeasure: newNodesToMeasure });\nreturn;\n}\n- let allTextAlreadyMeasured = false;\n- if (this.textHeights) {\n- allTextAlreadyMeasured = true;\n- for (let textToMeasure of newTextToMeasure) {\n- if (!this.textHeights.has(textToMeasure.id)) {\n- allTextAlreadyMeasured = false;\n+ let allNodesAlreadyMeasured = false;\n+ if (this.nodeHeights) {\n+ allNodesAlreadyMeasured = true;\n+ for (let nodeToMeasure of newNodesToMeasure) {\n+ if (!this.nodeHeights.has(nodeToMeasure.id)) {\n+ allNodesAlreadyMeasured = false;\nbreak;\n}\n}\n}\n- if (allTextAlreadyMeasured) {\n+ if (allNodesAlreadyMeasured) {\nthis.mergeHeightsIntoListData();\n}\n- // If we don't have everything in textHeights, but we do have everything in\n- // textToMeasure, we can conclude that we're just waiting for the\n+ // If we don't have everything in nodeHeights, but we do have everything in\n+ // nodesToMeasure, we can conclude that we're just waiting for the\n// measurement to complete and then we'll be good.\n}\n@@ -557,14 +559,14 @@ class Calendar extends React.PureComponent<Props, State> {\nreturn;\n}\n- const textHeights = this.textHeights;\n- invariant(textHeights, 'textHeights should be set');\n+ const { nodeHeights } = this;\n+ invariant(nodeHeights, 'nodeHeights should be set');\nconst listDataWithHeights = _map((item: CalendarItem) => {\nif (item.itemType !== 'entryInfo') {\nreturn item;\n}\nconst entryInfo = item.entryInfo;\n- const textHeight = textHeights.get(entryKey(entryInfo));\n+ const textHeight = nodeHeights.get(entryKey(entryInfo));\ninvariant(textHeight, `height for ${entryKey(entryInfo)} should be set`);\nreturn {\nitemType: 'entryInfo',\n@@ -746,10 +748,9 @@ class Calendar extends React.PureComponent<Props, State> {\nconst disableInputBar = this.state.currentlyEditing.length === 0;\nreturn (\n<>\n- <TextHeightMeasurer\n- textToMeasure={this.state.textToMeasure}\n+ <NodeHeightMeasurer\n+ nodesToMeasure={this.state.nodesToMeasure}\nallHeightsMeasuredCallback={this.allHeightsMeasured}\n- style={[entryStyles.entry, entryStyles.text]}\n/>\n<SafeAreaView style={this.props.styles.container} edges={safeAreaEdges}>\n<DisconnectedBar visible={this.props.calendarActive} />\n@@ -940,13 +941,13 @@ class Calendar extends React.PureComponent<Props, State> {\n}\nallHeightsMeasured = (\n- textToMeasure: TextToMeasure[],\n- newTextHeights: Map<string, number>,\n+ nodesToMeasure: $ReadOnlyArray<NodeToMeasure>,\n+ newHeights: Map<string, number>,\n) => {\n- if (textToMeasure !== this.state.textToMeasure) {\n+ if (nodesToMeasure !== this.state.nodesToMeasure) {\nreturn;\n}\n- this.textHeights = newTextHeights;\n+ this.nodeHeights = newHeights;\nthis.mergeHeightsIntoListData();\n};\n" }, { "change_type": "MODIFY", "old_path": "native/chat/message-list-container.react.js", "new_path": "native/chat/message-list-container.react.js", "diff": "import type { AppState } from '../redux/redux-setup';\nimport { messageTypes } from 'lib/types/message-types';\nimport { type ThreadInfo, threadInfoPropType } from 'lib/types/thread-types';\n-import type { TextToMeasure } from '../text-height-measurer.react';\n+import type { NodeToMeasure } from '../components/node-height-measurer.react';\nimport type { ChatMessageInfoItemWithHeight } from './message.react';\nimport {\nmessageListRoutePropType,\n@@ -14,7 +14,7 @@ import type { NavigationRoute } from '../navigation/route-names';\nimport * as React from 'react';\nimport PropTypes from 'prop-types';\n-import { View } from 'react-native';\n+import { View, Text } from 'react-native';\nimport invariant from 'invariant';\nimport hoistNonReactStatics from 'hoist-non-react-statics';\n@@ -33,7 +33,7 @@ import {\nimport { onlyEmojiRegex } from 'lib/shared/emojis';\nimport MessageList from './message-list.react';\n-import TextHeightMeasurer from '../text-height-measurer.react';\n+import NodeHeightMeasurer from '../components/node-height-measurer.react';\nimport ChatInputBar from './chat-input-bar.react';\nimport { multimediaMessageContentSizes } from './multimedia-message.react';\nimport {\n@@ -71,7 +71,7 @@ type Props = {|\ninputState: ?InputState,\n|};\ntype State = {|\n- textToMeasure: TextToMeasure[],\n+ nodesToMeasure: NodeToMeasure[],\nlistDataWithHeights: ?$ReadOnlyArray<ChatMessageItemWithHeight>,\n|};\nclass MessageListContainer extends React.PureComponent<Props, State> {\n@@ -89,21 +89,21 @@ class MessageListContainer extends React.PureComponent<Props, State> {\nconstructor(props: Props) {\nsuper(props);\n- const textToMeasure = props.messageListData\n- ? this.textToMeasureFromListData(props.messageListData)\n+ const nodesToMeasure = props.messageListData\n+ ? this.nodesToMeasureFromListData(props.messageListData)\n: [];\nconst listDataWithHeights =\n- props.messageListData && textToMeasure.length === 0\n+ props.messageListData && nodesToMeasure.length === 0\n? this.mergeHeightsIntoListData()\n: null;\nthis.state = {\n- textToMeasure,\n+ nodesToMeasure,\nlistDataWithHeights,\n};\n}\n- textToMeasureFromListData(listData: $ReadOnlyArray<ChatMessageItem>) {\n- const textToMeasure = [];\n+ nodesToMeasureFromListData(listData: $ReadOnlyArray<ChatMessageItem>) {\n+ const nodesToMeasure = [];\nfor (let item of listData) {\nif (item.itemType !== 'message') {\ncontinue;\n@@ -116,20 +116,24 @@ class MessageListContainer extends React.PureComponent<Props, State> {\n: this.props.styles.text,\n{ width: this.props.textMessageMaxWidth },\n];\n- textToMeasure.push({\n+ const node = <Text style={style}>{messageInfo.text}</Text>;\n+ nodesToMeasure.push({\nid: messageKey(messageInfo),\n- text: messageInfo.text,\n- style,\n+ node,\n});\n} else if (item.robotext && typeof item.robotext === 'string') {\n- textToMeasure.push({\n+ const node = (\n+ <Text style={this.props.styles.robotext}>\n+ {robotextToRawString(item.robotext)}\n+ </Text>\n+ );\n+ nodesToMeasure.push({\nid: messageKey(messageInfo),\n- text: robotextToRawString(item.robotext),\n- style: this.props.styles.robotext,\n+ node,\n});\n}\n}\n- return textToMeasure;\n+ return nodesToMeasure;\n}\nstatic getThreadInfo(props: Props): ThreadInfo {\n@@ -147,7 +151,7 @@ class MessageListContainer extends React.PureComponent<Props, State> {\nconst newListData = this.props.messageListData;\nif (!newListData && oldListData) {\nthis.setState({\n- textToMeasure: [],\n+ nodesToMeasure: [],\nlistDataWithHeights: null,\n});\n}\n@@ -167,8 +171,8 @@ class MessageListContainer extends React.PureComponent<Props, State> {\nreturn;\n}\n- const newTextToMeasure = this.textToMeasureFromListData(newListData);\n- this.setState({ textToMeasure: newTextToMeasure });\n+ const newNodesToMeasure = this.nodesToMeasureFromListData(newListData);\n+ this.setState({ nodesToMeasure: newNodesToMeasure });\n}\nrender() {\n@@ -193,8 +197,8 @@ class MessageListContainer extends React.PureComponent<Props, State> {\nreturn (\n<View style={this.props.styles.container}>\n- <TextHeightMeasurer\n- textToMeasure={this.state.textToMeasure}\n+ <NodeHeightMeasurer\n+ nodesToMeasure={this.state.nodesToMeasure}\nallHeightsMeasuredCallback={this.allHeightsMeasured}\n/>\n{messageList}\n@@ -208,20 +212,20 @@ class MessageListContainer extends React.PureComponent<Props, State> {\n}\nallHeightsMeasured = (\n- textToMeasure: TextToMeasure[],\n- newTextHeights: Map<string, number>,\n+ nodesToMeasure: $ReadOnlyArray<NodeToMeasure>,\n+ newHeights: Map<string, number>,\n) => {\n- if (textToMeasure !== this.state.textToMeasure) {\n+ if (nodesToMeasure !== this.state.nodesToMeasure) {\nreturn;\n}\nif (!this.props.messageListData) {\nreturn;\n}\n- const listDataWithHeights = this.mergeHeightsIntoListData(newTextHeights);\n+ const listDataWithHeights = this.mergeHeightsIntoListData(newHeights);\nthis.setState({ listDataWithHeights });\n};\n- mergeHeightsIntoListData(textHeights?: Map<string, number>) {\n+ mergeHeightsIntoListData(nodeHeights?: Map<string, number>) {\nconst { messageListData: listData, inputState } = this.props;\nconst threadInfo = MessageListContainer.getThreadInfo(this.props);\nconst listDataWithHeights = listData.map((item: ChatMessageItem) => {\n@@ -260,10 +264,10 @@ class MessageListContainer extends React.PureComponent<Props, State> {\n...sizes,\n};\n}\n- invariant(textHeights, 'textHeights not set');\n- const textHeight = textHeights.get(key);\n+ invariant(nodeHeights, 'nodeHeights not set');\n+ const contentHeight = nodeHeights.get(key);\ninvariant(\n- textHeight !== null && textHeight !== undefined,\n+ contentHeight !== null && contentHeight !== undefined,\n`height for ${key} should be set`,\n);\nif (messageInfo.type === messageTypes.TEXT) {\n@@ -280,7 +284,7 @@ class MessageListContainer extends React.PureComponent<Props, State> {\nstartsConversation: item.startsConversation,\nstartsCluster: item.startsCluster,\nendsCluster: item.endsCluster,\n- contentHeight: textHeight,\n+ contentHeight,\n};\n} else {\ninvariant(\n@@ -296,7 +300,7 @@ class MessageListContainer extends React.PureComponent<Props, State> {\nstartsCluster: item.startsCluster,\nendsCluster: item.endsCluster,\nrobotext: item.robotext,\n- contentHeight: textHeight,\n+ contentHeight,\n};\n}\n});\n" }, { "change_type": "ADD", "old_path": null, "new_path": "native/components/node-height-measurer.react.js", "diff": "+// @flow\n+\n+import type { LayoutEvent } from '../types/react-native';\n+\n+import * as React from 'react';\n+import PropTypes from 'prop-types';\n+import { View, StyleSheet } from 'react-native';\n+import invariant from 'invariant';\n+import _isEmpty from 'lodash/fp/isEmpty';\n+import _intersectionWith from 'lodash/fp/intersectionWith';\n+import _differenceWith from 'lodash/fp/differenceWith';\n+import _isEqual from 'lodash/fp/isEqual';\n+\n+const measureBatchSize = 50;\n+\n+export type NodeToMeasure = {|\n+ +id: string,\n+ +node: React.Element<any>,\n+|};\n+type NodesToHeight = Map<string, number>;\n+type Props = {|\n+ +nodesToMeasure: NodeToMeasure[],\n+ +allHeightsMeasuredCallback: (\n+ nodesToMeasure: $ReadOnlyArray<NodeToMeasure>,\n+ heights: NodesToHeight,\n+ ) => void,\n+ +minHeight?: number,\n+|};\n+type State = {|\n+ +currentlyMeasuring: ?Set<NodeToMeasure>,\n+|};\n+class NodeHeightMeasurer extends React.PureComponent<Props, State> {\n+ state = {\n+ currentlyMeasuring: null,\n+ };\n+ static propTypes = {\n+ nodesToMeasure: PropTypes.arrayOf(\n+ PropTypes.exact({\n+ id: PropTypes.string.isRequired,\n+ node: PropTypes.element.isRequired,\n+ }),\n+ ).isRequired,\n+ allHeightsMeasuredCallback: PropTypes.func.isRequired,\n+ minHeight: PropTypes.number,\n+ };\n+\n+ currentNodesToHeight: NodesToHeight = new Map();\n+ nextNodesToHeight: ?NodesToHeight = null;\n+ leftToMeasure: Set<NodeToMeasure> = new Set();\n+ leftInBatch = 0;\n+\n+ componentDidMount() {\n+ this.resetInternalState(this.props.nodesToMeasure);\n+ }\n+\n+ componentDidUpdate(prevProps: Props) {\n+ if (this.props.nodesToMeasure !== prevProps.nodesToMeasure) {\n+ this.resetInternalState(prevProps.nodesToMeasure);\n+ }\n+ }\n+\n+ // resets this.leftToMeasure and this.nextNodesToHeight\n+ resetInternalState(prevNodesToMeasure: NodeToMeasure[]) {\n+ this.leftToMeasure = new Set();\n+ const nextNextNodesToHeight = new Map();\n+ const nextNodesToMeasure = this.props.nodesToMeasure;\n+\n+ const newNodesToMeasure = _differenceWith(_isEqual)(nextNodesToMeasure)(\n+ prevNodesToMeasure,\n+ );\n+ for (let nodeToMeasure of newNodesToMeasure) {\n+ this.leftToMeasure.add(nodeToMeasure);\n+ }\n+\n+ const existingNodesToHeight = this.nextNodesToHeight\n+ ? this.nextNodesToHeight\n+ : this.currentNodesToHeight;\n+ const existingNodesToMeasure = _intersectionWith(_isEqual)(\n+ nextNodesToMeasure,\n+ )(prevNodesToMeasure);\n+ for (let nodeToMeasure of existingNodesToMeasure) {\n+ const { id } = nodeToMeasure;\n+ const measuredHeight = existingNodesToHeight.get(id);\n+ if (measuredHeight !== undefined) {\n+ nextNextNodesToHeight.set(id, measuredHeight);\n+ } else {\n+ this.leftToMeasure.add(nodeToMeasure);\n+ }\n+ }\n+\n+ this.nextNodesToHeight = nextNextNodesToHeight;\n+ if (this.leftToMeasure.size === 0) {\n+ this.done(nextNodesToMeasure);\n+ } else {\n+ this.newBatch();\n+ }\n+ }\n+\n+ onLayout(nodeToMeasure: NodeToMeasure, event: LayoutEvent) {\n+ invariant(this.nextNodesToHeight, 'nextNodesToHeight should be set');\n+ this.nextNodesToHeight.set(\n+ nodeToMeasure.id,\n+ this.props.minHeight !== undefined && this.props.minHeight !== null\n+ ? Math.max(event.nativeEvent.layout.height, this.props.minHeight)\n+ : event.nativeEvent.layout.height,\n+ );\n+ this.leftToMeasure.delete(nodeToMeasure);\n+ this.leftInBatch--;\n+ if (this.leftToMeasure.size === 0) {\n+ this.done(this.props.nodesToMeasure);\n+ } else if (this.leftInBatch === 0) {\n+ this.newBatch();\n+ }\n+ }\n+\n+ done(nodesToMeasure: NodeToMeasure[]) {\n+ invariant(this.leftToMeasure.size === 0, 'should be 0 left to measure');\n+ invariant(this.nextNodesToHeight, 'nextNodesToHeight should be set');\n+ this.currentNodesToHeight = this.nextNodesToHeight;\n+ this.nextNodesToHeight = null;\n+ this.props.allHeightsMeasuredCallback(\n+ nodesToMeasure,\n+ this.currentNodesToHeight,\n+ );\n+ this.setState({ currentlyMeasuring: null });\n+ }\n+\n+ newBatch() {\n+ let newBatchSize = Math.min(measureBatchSize, this.leftToMeasure.size);\n+ this.leftInBatch = newBatchSize;\n+ const newCurrentlyMeasuring = new Set();\n+ const leftToMeasureIter = this.leftToMeasure.values();\n+ for (; newBatchSize > 0; newBatchSize--) {\n+ const value = leftToMeasureIter.next().value;\n+ invariant(value !== undefined && value !== null, 'item should exist');\n+ newCurrentlyMeasuring.add(value);\n+ }\n+ this.setState({ currentlyMeasuring: newCurrentlyMeasuring });\n+ }\n+\n+ render() {\n+ const set = this.state.currentlyMeasuring;\n+ if (_isEmpty(set)) {\n+ return null;\n+ }\n+ invariant(set, 'should be set');\n+ const dummies = Array.from(set).map((nodeToMeasure: NodeToMeasure) => {\n+ let { children } = nodeToMeasure.node.props;\n+ if (children === '') {\n+ children = ' ';\n+ }\n+ const style = [nodeToMeasure.node.props.style, styles.text];\n+ const onLayout = event => this.onLayout(nodeToMeasure, event);\n+ const node = React.cloneElement(nodeToMeasure.node, {\n+ style,\n+ onLayout,\n+ children,\n+ });\n+\n+ return <React.Fragment key={nodeToMeasure.id}>{node}</React.Fragment>;\n+ });\n+ return <View>{dummies}</View>;\n+ }\n+}\n+\n+const styles = StyleSheet.create({\n+ text: {\n+ opacity: 0,\n+ position: 'absolute',\n+ },\n+});\n+\n+export default NodeHeightMeasurer;\n" }, { "change_type": "DELETE", "old_path": "native/text-height-measurer.react.js", "new_path": null, "diff": "-// @flow\n-\n-import type { TextStyle } from './types/styles';\n-import type { LayoutEvent } from './types/react-native';\n-\n-import React from 'react';\n-import PropTypes from 'prop-types';\n-import { Text, View, StyleSheet } from 'react-native';\n-import invariant from 'invariant';\n-import _isEmpty from 'lodash/fp/isEmpty';\n-import _intersectionWith from 'lodash/fp/intersectionWith';\n-import _differenceWith from 'lodash/fp/differenceWith';\n-import _isEqual from 'lodash/fp/isEqual';\n-\n-const measureBatchSize = 50;\n-\n-export type TextToMeasure = {|\n- id: string,\n- text: string,\n- style?: TextStyle,\n-|};\n-type TextToHeight = Map<string, number>;\n-type Props = {|\n- textToMeasure: TextToMeasure[],\n- allHeightsMeasuredCallback: (\n- textToMeasure: TextToMeasure[],\n- heights: TextToHeight,\n- ) => void,\n- minHeight?: number,\n- style?: TextStyle,\n-|};\n-type State = {|\n- currentlyMeasuring: ?Set<TextToMeasure>,\n-|};\n-class TextHeightMeasurer extends React.PureComponent<Props, State> {\n- state = {\n- currentlyMeasuring: null,\n- };\n- static propTypes = {\n- textToMeasure: PropTypes.arrayOf(\n- PropTypes.shape({\n- id: PropTypes.string.isRequired,\n- text: PropTypes.string.isRequired,\n- style: Text.propTypes.style,\n- }),\n- ).isRequired,\n- allHeightsMeasuredCallback: PropTypes.func.isRequired,\n- minHeight: PropTypes.number,\n- style: Text.propTypes.style,\n- };\n-\n- currentTextToHeight: TextToHeight = new Map();\n- nextTextToHeight: ?TextToHeight = null;\n- leftToMeasure: Set<TextToMeasure> = new Set();\n- leftInBatch = 0;\n-\n- componentDidMount() {\n- this.resetInternalState(this.props.textToMeasure);\n- }\n-\n- componentDidUpdate(prevProps: Props) {\n- if (this.props.textToMeasure !== prevProps.textToMeasure) {\n- this.resetInternalState(prevProps.textToMeasure);\n- }\n- }\n-\n- // resets this.leftToMeasure and this.nextTextToHeight\n- resetInternalState(prevTextToMeasure: TextToMeasure[]) {\n- this.leftToMeasure = new Set();\n- const nextNextTextToHeight = new Map();\n- const nextTextToMeasure = this.props.textToMeasure;\n-\n- const newTextToMeasure = _differenceWith(_isEqual)(nextTextToMeasure)(\n- prevTextToMeasure,\n- );\n- for (let textToMeasure of newTextToMeasure) {\n- this.leftToMeasure.add(textToMeasure);\n- }\n-\n- const existingTextToHeight = this.nextTextToHeight\n- ? this.nextTextToHeight\n- : this.currentTextToHeight;\n- const existingTextToMeasure = _intersectionWith(_isEqual)(\n- nextTextToMeasure,\n- )(prevTextToMeasure);\n- for (let textToMeasure of existingTextToMeasure) {\n- const { id } = textToMeasure;\n- const measuredHeight = existingTextToHeight.get(id);\n- if (measuredHeight !== undefined) {\n- nextNextTextToHeight.set(id, measuredHeight);\n- } else {\n- this.leftToMeasure.add(textToMeasure);\n- }\n- }\n-\n- this.nextTextToHeight = nextNextTextToHeight;\n- if (this.leftToMeasure.size === 0) {\n- this.done(nextTextToMeasure);\n- } else {\n- this.newBatch();\n- }\n- }\n-\n- onTextLayout(textToMeasure: TextToMeasure, event: LayoutEvent) {\n- invariant(this.nextTextToHeight, 'nextTextToHeight should be set');\n- this.nextTextToHeight.set(\n- textToMeasure.id,\n- this.props.minHeight !== undefined && this.props.minHeight !== null\n- ? Math.max(event.nativeEvent.layout.height, this.props.minHeight)\n- : event.nativeEvent.layout.height,\n- );\n- this.leftToMeasure.delete(textToMeasure);\n- this.leftInBatch--;\n- if (this.leftToMeasure.size === 0) {\n- this.done(this.props.textToMeasure);\n- } else if (this.leftInBatch === 0) {\n- this.newBatch();\n- }\n- }\n-\n- done(textToMeasure: TextToMeasure[]) {\n- invariant(this.leftToMeasure.size === 0, 'should be 0 left to measure');\n- invariant(this.nextTextToHeight, 'nextTextToHeight should be set');\n- this.currentTextToHeight = this.nextTextToHeight;\n- this.nextTextToHeight = null;\n- this.props.allHeightsMeasuredCallback(\n- textToMeasure,\n- this.currentTextToHeight,\n- );\n- this.setState({ currentlyMeasuring: null });\n- }\n-\n- newBatch() {\n- let newBatchSize = Math.min(measureBatchSize, this.leftToMeasure.size);\n- this.leftInBatch = newBatchSize;\n- const newCurrentlyMeasuring = new Set();\n- const leftToMeasureIter = this.leftToMeasure.values();\n- for (; newBatchSize > 0; newBatchSize--) {\n- const value = leftToMeasureIter.next().value;\n- invariant(value !== undefined && value !== null, 'item should exist');\n- newCurrentlyMeasuring.add(value);\n- }\n- this.setState({ currentlyMeasuring: newCurrentlyMeasuring });\n- }\n-\n- render() {\n- const set = this.state.currentlyMeasuring;\n- if (_isEmpty(set)) {\n- return null;\n- }\n- invariant(set, 'should be set');\n- const dummies = Array.from(set).map((textToMeasure: TextToMeasure) => {\n- const style = textToMeasure.style\n- ? textToMeasure.style\n- : this.props.style;\n- invariant(style, 'style should exist for every text being measured!');\n- let text = textToMeasure.text;\n- if (text === '' || text.slice(-1) === '\\n') {\n- text += ' ';\n- }\n- return (\n- <Text\n- style={[styles.text, style]}\n- onLayout={event => this.onTextLayout(textToMeasure, event)}\n- key={textToMeasure.id}\n- >\n- {text}\n- </Text>\n- );\n- });\n- return <View>{dummies}</View>;\n- }\n-}\n-\n-const styles = StyleSheet.create({\n- text: {\n- opacity: 0,\n- position: 'absolute',\n- },\n-});\n-\n-export default TextHeightMeasurer;\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] TextHeightMeasurer -> NodeHeightMeasurer Now can handle measuring any node, in preparation for having to measure `<Markdown>`
129,187
20.07.2020 17:27:41
14,400
9eecf158e27ff5908a529567caffeb4306cdab2d
[server] Script to backup Phabricator
[ { "change_type": "ADD", "old_path": null, "new_path": "server/bash/backup_phabricator.sh", "diff": "+#!/bin/bash\n+\n+# run as: ssh user on root wheel\n+# run from: wherever\n+\n+# The path to Phabricator on our server\n+PHABRICATOR_PATH=/var/www/phabricator/phabricator\n+\n+# The path to the backup directory on our server\n+BACKUP_PATH=/mnt/backup\n+\n+# The user that will be owning the backup files\n+BACKUP_USER=squadcal\n+\n+set -e\n+[[ `whoami` = root ]] || exec sudo su -c \"$0 $1\"\n+\n+cd \"$PHABRICATOR_PATH\"\n+\n+OUTPUT_FILE=\"$BACKUP_PATH/phabricator.$(date +'%Y-%m-%d-%R').sql.gz\"\n+\n+RETRIES=2\n+while [[ $RETRIES -ge 0 ]]; do\n+ if ./bin/storage dump --compress --overwrite --output \"$OUTPUT_FILE\"; then\n+ break\n+ fi\n+ rm -f \"$OUTPUT_FILE\"\n+\n+ # Delete most recent backup file\n+ rm -f $(find \"$BACKUP_PATH\" -maxdepth 1 -name 'phabricator.*.sql.gz' -type f -printf '%T+ %p\\0' | sort -z | head -z -n 1 | cut -d ' ' -f2- | cut -d '' -f1)\n+\n+ ((RETRIES--))\n+done\n+\n+chown \"$BACKUP_USER:$BACKUP_USER\" \"$OUTPUT_FILE\" || true\n" }, { "change_type": "MODIFY", "old_path": "server/src/cron/backups.js", "new_path": "server/src/cron/backups.js", "diff": "@@ -90,7 +90,7 @@ async function deleteOldestBackup() {\nconst files = await readdir(backupConfig.directory);\nlet oldestFile;\nfor (let file of files) {\n- if (!file.endsWith('.sql.gz')) {\n+ if (!file.endsWith('.sql.gz') || !file.startsWith('squadcal.')) {\ncontinue;\n}\nconst stat = await lstat(`${backupConfig.directory}/${file}`);\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[server] Script to backup Phabricator
129,187
20.07.2020 20:19:27
14,400
3d14fbc40ba3de9c47f5604f55999958aedff3af
[server] Delete failed server backup attempts
[ { "change_type": "MODIFY", "old_path": "server/src/cron/backups.js", "new_path": "server/src/cron/backups.js", "diff": "@@ -52,7 +52,11 @@ async function backupDB() {\nconst dateString = dateFormat('yyyy-mm-dd-HH:MM');\nconst filename = `${backupConfig.directory}/squadcal.${dateString}.sql.gz`;\n+ try {\nawait saveBackup(filename, cache);\n+ } catch (e) {\n+ await unlink(filename);\n+ }\n}\nasync function saveBackup(\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[server] Delete failed server backup attempts
129,187
20.07.2020 20:41:48
14,400
ed97628620152dee79334d9a451190864ec36af8
[native] Specify indicatorStyle on all FlatLists
[ { "change_type": "MODIFY", "old_path": "native/calendar/calendar.react.js", "new_path": "native/calendar/calendar.react.js", "diff": "@@ -95,6 +95,9 @@ import {\ncolorsPropType,\ncolorsSelector,\nstyleSelector,\n+ type IndicatorStyle,\n+ indicatorStylePropType,\n+ indicatorStyleSelector,\n} from '../themes/colors';\nimport ContentLoading from '../components/content-loading.react';\nimport {\n@@ -137,6 +140,7 @@ type Props = {\nconnectionStatus: ConnectionStatus,\ncolors: Colors,\nstyles: typeof styles,\n+ indicatorStyle: IndicatorStyle,\n// Redux dispatch functions\ndispatchActionPromise: DispatchActionPromise,\n// async functions that hit server APIs\n@@ -193,6 +197,7 @@ class Calendar extends React.PureComponent<Props, State> {\nconnectionStatus: connectionStatusPropType.isRequired,\ncolors: colorsPropType.isRequired,\nstyles: PropTypes.objectOf(PropTypes.object).isRequired,\n+ indicatorStyle: indicatorStylePropType.isRequired,\ndispatchActionPromise: PropTypes.func.isRequired,\nupdateCalendarQuery: PropTypes.func.isRequired,\n};\n@@ -735,6 +740,7 @@ class Calendar extends React.PureComponent<Props, State> {\nscrollsToTop={false}\nextraData={this.state.extraData}\nstyle={[this.props.styles.flatList, flatListStyle]}\n+ indicatorStyle={this.props.indicatorStyle}\nref={this.flatListRef}\n/>\n);\n@@ -1169,6 +1175,7 @@ export default connectNav((context: ?NavContextType) => ({\nconnectionStatus: state.connection.status,\ncolors: colorsSelector(state),\nstyles: stylesSelector(state),\n+ indicatorStyle: indicatorStyleSelector(state),\n}),\n{ updateCalendarQuery },\n)(Calendar),\n" }, { "change_type": "MODIFY", "old_path": "native/chat/chat-thread-list.react.js", "new_path": "native/chat/chat-thread-list.react.js", "diff": "@@ -34,7 +34,12 @@ import {\nBackgroundChatThreadListRouteName,\ntype NavigationRoute,\n} from '../navigation/route-names';\n-import { styleSelector } from '../themes/colors';\n+import {\n+ styleSelector,\n+ type IndicatorStyle,\n+ indicatorStylePropType,\n+ indicatorStyleSelector,\n+} from '../themes/colors';\nimport Search from '../components/search.react';\nconst floatingActions = [\n@@ -62,6 +67,7 @@ type Props = {|\nviewerID: ?string,\nthreadSearchIndex: SearchIndex,\nstyles: typeof styles,\n+ indicatorStyle: IndicatorStyle,\n|};\ntype State = {|\nsearchText: string,\n@@ -81,6 +87,7 @@ class ChatThreadList extends React.PureComponent<Props, State> {\nviewerID: PropTypes.string,\nthreadSearchIndex: PropTypes.instanceOf(SearchIndex).isRequired,\nstyles: PropTypes.objectOf(PropTypes.object).isRequired,\n+ indicatorStyle: indicatorStylePropType.isRequired,\n};\nstate = {\nsearchText: '',\n@@ -250,6 +257,7 @@ class ChatThreadList extends React.PureComponent<Props, State> {\nkeyboardShouldPersistTaps=\"handled\"\nonScroll={this.onScroll}\nstyle={this.props.styles.flatList}\n+ indicatorStyle={this.props.indicatorStyle}\nref={this.flatListRef}\n/>\n{floatingAction}\n@@ -314,4 +322,5 @@ export default connect((state: AppState) => ({\nviewerID: state.currentUserInfo && state.currentUserInfo.id,\nthreadSearchIndex: threadSearchIndex(state),\nstyles: stylesSelector(state),\n+ indicatorStyle: indicatorStyleSelector(state),\n}))(ChatThreadList);\n" }, { "change_type": "MODIFY", "old_path": "native/chat/message-list.react.js", "new_path": "native/chat/message-list.react.js", "diff": "@@ -36,7 +36,12 @@ import { registerFetchKey } from 'lib/reducers/loading-reducer';\nimport { Message, type ChatMessageInfoItemWithHeight } from './message.react';\nimport ListLoadingIndicator from '../components/list-loading-indicator.react';\n-import { styleSelector } from '../themes/colors';\n+import {\n+ styleSelector,\n+ type IndicatorStyle,\n+ indicatorStylePropType,\n+ indicatorStyleSelector,\n+} from '../themes/colors';\nimport {\nwithOverlayContext,\ntype OverlayContextType,\n@@ -57,6 +62,7 @@ type Props = {|\n// Redux state\nstartReached: boolean,\nstyles: typeof styles,\n+ indicatorStyle: IndicatorStyle,\n// Redux dispatch functions\ndispatchActionPromise: DispatchActionPromise,\n// async functions that hit server APIs\n@@ -95,6 +101,7 @@ class MessageList extends React.PureComponent<Props, State> {\nroute: messageListRoutePropType.isRequired,\nstartReached: PropTypes.bool.isRequired,\nstyles: PropTypes.objectOf(PropTypes.object).isRequired,\n+ indicatorStyle: indicatorStylePropType.isRequired,\ndispatchActionPromise: PropTypes.func.isRequired,\nfetchMessagesBeforeCursor: PropTypes.func.isRequired,\nfetchMostRecentMessages: PropTypes.func.isRequired,\n@@ -266,6 +273,7 @@ class MessageList extends React.PureComponent<Props, State> {\nscrollsToTop={false}\nscrollEnabled={!MessageList.scrollDisabled(this.props)}\nextraData={this.flatListExtraData}\n+ indicatorStyle={this.props.indicatorStyle}\n/>\n</View>\n);\n@@ -368,6 +376,7 @@ export default connect(\nstate.messageStore.threads[threadID].startReached\n),\nstyles: stylesSelector(state),\n+ indicatorStyle: indicatorStyleSelector(state),\n};\n},\n{ fetchMessagesBeforeCursor, fetchMostRecentMessages },\n" }, { "change_type": "MODIFY", "old_path": "native/chat/settings/thread-settings.react.js", "new_path": "native/chat/settings/thread-settings.react.js", "diff": "@@ -65,7 +65,12 @@ import {\nAddUsersModalRouteName,\nComposeSubthreadModalRouteName,\n} from '../../navigation/route-names';\n-import { styleSelector } from '../../themes/colors';\n+import {\n+ styleSelector,\n+ type IndicatorStyle,\n+ indicatorStylePropType,\n+ indicatorStyleSelector,\n+} from '../../themes/colors';\nimport {\nwithOverlayContext,\ntype OverlayContextType,\n@@ -195,6 +200,7 @@ type Props = {|\nchildThreadInfos: ?(ThreadInfo[]),\nsomethingIsSaving: boolean,\nstyles: typeof styles,\n+ indicatorStyle: IndicatorStyle,\n// withOverlayContext\noverlayContext: ?OverlayContextType,\n|};\n@@ -230,6 +236,7 @@ class ThreadSettings extends React.PureComponent<Props, State> {\nchildThreadInfos: PropTypes.arrayOf(threadInfoPropType),\nsomethingIsSaving: PropTypes.bool.isRequired,\nstyles: PropTypes.objectOf(PropTypes.object).isRequired,\n+ indicatorStyle: indicatorStylePropType.isRequired,\noverlayContext: overlayContextPropType,\n};\nflatListContainer: ?React.ElementRef<typeof View>;\n@@ -642,6 +649,7 @@ class ThreadSettings extends React.PureComponent<Props, State> {\ncontentContainerStyle={this.props.styles.flatList}\nrenderItem={this.renderItem}\nscrollEnabled={!ThreadSettings.scrollDisabled(this.props)}\n+ indicatorStyle={this.props.indicatorStyle}\n/>\n</View>\n);\n@@ -900,6 +908,7 @@ const WrappedThreadSettings = connect(\nchildThreadInfos: childThreadInfos(state)[threadID],\nsomethingIsSaving: somethingIsSaving(state, threadMembers),\nstyles: stylesSelector(state),\n+ indicatorStyle: indicatorStyleSelector(state),\n};\n},\n)(withOverlayContext(ThreadSettings));\n" }, { "change_type": "MODIFY", "old_path": "native/components/thread-list.react.js", "new_path": "native/components/thread-list.react.js", "diff": "@@ -14,7 +14,12 @@ import SearchIndex from 'lib/shared/search-index';\nimport { connect } from 'lib/utils/redux-utils';\nimport ThreadListThread from './thread-list-thread.react';\n-import { styleSelector } from '../themes/colors';\n+import {\n+ styleSelector,\n+ type IndicatorStyle,\n+ indicatorStylePropType,\n+ indicatorStyleSelector,\n+} from '../themes/colors';\nimport Search from './search.react';\ntype Props = {|\n@@ -25,6 +30,7 @@ type Props = {|\nsearchIndex?: SearchIndex,\n// Redux state\nstyles: typeof styles,\n+ indicatorStyle: IndicatorStyle,\n|};\ntype State = {|\nsearchText: string,\n@@ -39,6 +45,7 @@ class ThreadList extends React.PureComponent<Props, State> {\nitemTextStyle: Text.propTypes.style,\nsearchIndex: PropTypes.instanceOf(SearchIndex),\nstyles: PropTypes.objectOf(PropTypes.object).isRequired,\n+ indicatorStyle: indicatorStylePropType.isRequired,\n};\nstate = {\nsearchText: '',\n@@ -90,6 +97,7 @@ class ThreadList extends React.PureComponent<Props, State> {\ngetItemLayout={ThreadList.getItemLayout}\nkeyboardShouldPersistTaps=\"handled\"\ninitialNumToRender={20}\n+ indicatorStyle={this.props.indicatorStyle}\n/>\n</React.Fragment>\n);\n@@ -130,4 +138,5 @@ const stylesSelector = styleSelector(styles);\nexport default connect((state: AppState) => ({\nstyles: stylesSelector(state),\n+ indicatorStyle: indicatorStyleSelector(state),\n}))(ThreadList);\n" }, { "change_type": "MODIFY", "old_path": "native/components/user-list.react.js", "new_path": "native/components/user-list.react.js", "diff": "import type { TextStyle } from '../types/styles';\nimport { type UserListItem, userListItemPropType } from 'lib/types/user-types';\n+import type { AppState } from '../redux/redux-setup';\nimport React from 'react';\nimport PropTypes from 'prop-types';\nimport { FlatList, Text } from 'react-native';\nimport _sum from 'lodash/fp/sum';\n+import { connect } from 'lib/utils/redux-utils';\n+\nimport { UserListUser, getUserListItemHeight } from './user-list-user.react';\n+import {\n+ type IndicatorStyle,\n+ indicatorStylePropType,\n+ indicatorStyleSelector,\n+} from '../themes/colors';\ntype Props = {\nuserInfos: $ReadOnlyArray<UserListItem>,\nonSelect: (userID: string) => void,\nitemTextStyle?: TextStyle,\n+ // Redux state\n+ indicatorStyle: IndicatorStyle,\n};\nclass UserList extends React.PureComponent<Props> {\nstatic propTypes = {\nuserInfos: PropTypes.arrayOf(userListItemPropType).isRequired,\nonSelect: PropTypes.func.isRequired,\nitemTextStyle: Text.propTypes.style,\n+ indicatorStyle: indicatorStylePropType.isRequired,\n};\nrender() {\n@@ -32,6 +43,7 @@ class UserList extends React.PureComponent<Props> {\nkeyboardShouldPersistTaps=\"handled\"\ninitialNumToRender={20}\nextraData={this.props.itemTextStyle}\n+ indicatorStyle={this.props.indicatorStyle}\n/>\n);\n}\n@@ -63,4 +75,6 @@ class UserList extends React.PureComponent<Props> {\n}\n}\n-export default UserList;\n+export default connect((state: AppState) => ({\n+ indicatorStyle: indicatorStyleSelector(state),\n+}))(UserList);\n" }, { "change_type": "MODIFY", "old_path": "native/more/relationship-list.react.js", "new_path": "native/more/relationship-list.react.js", "diff": "@@ -12,7 +12,11 @@ import { connect } from 'lib/utils/redux-utils';\nimport { type UserInfo } from 'lib/types/user-types';\nimport { AddFriendsModalRouteName } from '../navigation/route-names';\n-import { styleSelector } from '../themes/colors';\n+import {\n+ styleSelector,\n+ type IndicatorStyle,\n+ indicatorStyleSelector,\n+} from '../themes/colors';\nimport RelationshipListItem from './relationship-list-item.react';\n@@ -50,6 +54,7 @@ type Props = {|\nroute: NavigationRoute<'FriendList' | 'BlockList'>,\n// Redux state\nstyles: typeof styles,\n+ indicatorStyle: IndicatorStyle,\n|};\nclass RelationshipList extends React.PureComponent<Props> {\nrender() {\n@@ -59,6 +64,7 @@ class RelationshipList extends React.PureComponent<Props> {\ncontentContainerStyle={this.props.styles.contentContainer}\ndata={LIST_DATA}\nrenderItem={this.renderItem}\n+ indicatorStyle={this.props.indicatorStyle}\n/>\n</View>\n);\n@@ -120,4 +126,5 @@ const stylesSelector = styleSelector(styles);\nexport default connect((state: AppState) => ({\nstyles: stylesSelector(state),\n+ indicatorStyle: indicatorStyleSelector(state),\n}))(RelationshipList);\n" }, { "change_type": "MODIFY", "old_path": "native/themes/colors.js", "new_path": "native/themes/colors.js", "diff": "@@ -225,6 +225,23 @@ function getStylesForTheme<IS: Styles>(\nreturn stylesFromColors(obj, colors[theme]);\n}\n+export type IndicatorStyle = 'white' | 'black';\n+const indicatorStylePropType = PropTypes.oneOf(['white', 'black']);\n+function useIndicatorStyle(): IndicatorStyle {\n+ const theme = useSelector(\n+ (state: AppState) => state.globalThemeInfo.activeTheme,\n+ );\n+ return theme && theme === 'dark' ? 'white' : 'black';\n+}\n+const indicatorStyleSelector: (\n+ state: AppState,\n+) => IndicatorStyle = createSelector(\n+ (state: AppState) => state.globalThemeInfo.activeTheme,\n+ (theme: ?GlobalTheme) => {\n+ return theme && theme === 'dark' ? 'white' : 'black';\n+ },\n+);\n+\nexport {\ncolorsPropType,\ncolors,\n@@ -233,4 +250,7 @@ export {\nuseStyles,\nuseOverlayStyles,\ngetStylesForTheme,\n+ indicatorStylePropType,\n+ useIndicatorStyle,\n+ indicatorStyleSelector,\n};\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Specify indicatorStyle on all FlatLists
129,187
20.07.2020 21:49:22
14,400
6c03db7a6eba7dc1330f811674dc8ce32ff0a8a5
[native] Complain when NodeHeightMeasurer is wrong
[ { "change_type": "MODIFY", "old_path": "native/calendar/entry.react.js", "new_path": "native/calendar/entry.react.js", "diff": "@@ -195,6 +195,24 @@ class InternalEntry extends React.Component<Props, State> {\nthis.currentlySaving = null;\n}\n+ if (\n+ !this.props.active &&\n+ this.state.text === prevState.text &&\n+ this.state.height !== prevState.height &&\n+ this.state.height !== this.props.entryInfo.textHeight\n+ ) {\n+ const approxMeasuredHeight = Math.round(this.state.height * 1000) / 1000;\n+ const approxExpectedHeight =\n+ Math.round(this.props.entryInfo.textHeight * 1000) / 1000;\n+ console.log(\n+ `Entry height for ${entryKey(this.props.entryInfo)} was expected to ` +\n+ `be ${approxExpectedHeight} but is actually ` +\n+ `${approxMeasuredHeight}. This means Calendar's FlatList isn't ` +\n+ 'getting the right item height for some of its nodes, which is ' +\n+ 'guaranteed to cause glitchy behavior. Please investigate!!',\n+ );\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" }, { "change_type": "MODIFY", "old_path": "native/chat/inner-text-message.react.js", "new_path": "native/chat/inner-text-message.react.js", "diff": "@@ -4,6 +4,7 @@ import { chatMessageItemPropType } from 'lib/selectors/chat-selectors';\nimport type { ChatTextMessageInfoItemWithHeight } from './text-message.react';\nimport { type GlobalTheme, globalThemePropType } from '../types/themes';\nimport type { AppState } from '../redux/redux-setup';\n+import type { LayoutEvent } from '../types/react-native';\nimport * as React from 'react';\nimport { View, Text, StyleSheet, TouchableOpacity } from 'react-native';\n@@ -11,6 +12,7 @@ import PropTypes from 'prop-types';\nimport { colorIsDark } from 'lib/shared/thread-utils';\nimport { connect } from 'lib/utils/redux-utils';\n+import { messageKey } from 'lib/shared/message-utils';\nimport {\nallCorners,\n@@ -67,7 +69,9 @@ class InnerTextMessage extends React.PureComponent<Props> {\nfilterCorners(allCorners, item),\n);\n- const outerTextStyle = { height: item.contentHeight };\n+ const outerTextProps = __DEV__\n+ ? { onLayout: this.onLayoutOuterText }\n+ : { style: { height: item.contentHeight } };\nconst message = (\n<TouchableOpacity\nonPress={this.props.onPress}\n@@ -75,7 +79,7 @@ class InnerTextMessage extends React.PureComponent<Props> {\nactiveOpacity={0.6}\nstyle={[styles.message, messageStyle, cornerStyle]}\n>\n- <Text style={outerTextStyle}>\n+ <Text {...outerTextProps}>\n<Markdown\nstyle={textStyle}\nuseDarkStyle={darkColor}\n@@ -101,6 +105,22 @@ class InnerTextMessage extends React.PureComponent<Props> {\n// We need to set onLayout in order to allow .measure() to be on the ref\nonLayout = () => {};\n+\n+ onLayoutOuterText = (event: LayoutEvent) => {\n+ const approxMeasuredHeight =\n+ Math.round(event.nativeEvent.layout.height * 1000) / 1000;\n+ const approxExpectedHeight =\n+ Math.round(this.props.item.contentHeight * 1000) / 1000;\n+ if (approxMeasuredHeight !== approxExpectedHeight) {\n+ console.log(\n+ `TextMessage height for ${messageKey(this.props.item.messageInfo)} ` +\n+ `was expected to be ${approxExpectedHeight} but is actually ` +\n+ `${approxMeasuredHeight}. This means MessageList's FlatList isn't ` +\n+ 'getting the right item height for some of its nodes, which is ' +\n+ 'guaranteed to cause glitchy behavior. Please investigate!!',\n+ );\n+ }\n+ };\n}\nconst styles = StyleSheet.create({\n" }, { "change_type": "MODIFY", "old_path": "native/chat/robotext-message.react.js", "new_path": "native/chat/robotext-message.react.js", "diff": "@@ -12,6 +12,7 @@ import {\nimport { messageListNavPropType } from './message-list-types';\nimport type { ChatNavigationProp } from './chat.react';\nimport { type GlobalTheme, globalThemePropType } from '../types/themes';\n+import type { LayoutEvent } from '../types/react-native';\nimport * as React from 'react';\nimport { Text, TouchableWithoutFeedback, View } from 'react-native';\n@@ -112,10 +113,11 @@ class RobotextMessage extends React.PureComponent<Props> {\n}\nif (splitPart.charAt(0) !== '<') {\nconst darkColor = this.props.activeTheme === 'dark';\n+ const key = `text${keyIndex++}`;\ntextParts.push(\n<Markdown\nstyle={this.props.styles.robotext}\n- key={`text${keyIndex++}`}\n+ key={key}\nuseDarkStyle={darkColor}\nrules={inlineMarkdownRules}\n>\n@@ -142,13 +144,19 @@ class RobotextMessage extends React.PureComponent<Props> {\ntextParts.push(rawText);\n}\n}\n- const textStyle = [\n- this.props.styles.robotext,\n- { height: item.contentHeight },\n- ];\n+ const textStyle = [this.props.styles.robotext];\n+ let onLayoutOuterText;\n+ if (__DEV__) {\n+ ({ onLayoutOuterText } = this);\n+ } else {\n+ textStyle.push({ height: item.contentHeight });\n+ }\n+\nreturn (\n<View style={this.props.styles.robotextContainer}>\n- <Text style={textStyle}>{textParts}</Text>\n+ <Text onLayout={onLayoutOuterText} style={textStyle}>\n+ {textParts}\n+ </Text>\n</View>\n);\n}\n@@ -161,6 +169,23 @@ class RobotextMessage extends React.PureComponent<Props> {\nthis.props.toggleFocus(messageKey(this.props.item.messageInfo));\n}\n};\n+\n+ onLayoutOuterText = (event: LayoutEvent) => {\n+ const approxMeasuredHeight =\n+ Math.round(event.nativeEvent.layout.height * 1000) / 1000;\n+ const approxExpectedHeight =\n+ Math.round(this.props.item.contentHeight * 1000) / 1000;\n+ if (approxMeasuredHeight !== approxExpectedHeight) {\n+ console.log(\n+ `RobotextMessage height for ` +\n+ `${messageKey(this.props.item.messageInfo)} was expected to be ` +\n+ `${approxExpectedHeight} but is actually ${approxMeasuredHeight}. ` +\n+ \"This means MessageList's FlatList isn't getting the right item \" +\n+ 'height for some of its nodes, which is guaranteed to cause ' +\n+ 'glitchy behavior. Please investigate!!',\n+ );\n+ }\n+ };\n}\nconst WrappedRobotextMessage = connect((state: AppState) => ({\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Complain when NodeHeightMeasurer is wrong
129,187
20.07.2020 22:08:58
14,400
d0d20704ecd6a345dcca986b82df85d49eda0387
[server] Fix server bug that wipes out thread list
[ { "change_type": "MODIFY", "old_path": "server/src/updaters/thread-permission-updaters.js", "new_path": "server/src/updaters/thread-permission-updaters.js", "diff": "@@ -603,9 +603,10 @@ async function commitMembershipChangeset(\nupdateUndirectedRelationships(_uniqWith(_isEqual)(relationshipRows)),\n]);\n- const serverThreadInfoFetchResult = await fetchServerThreadInfos(\n- SQL`t.id IN (${[...changedThreadIDs]})`,\n- );\n+ // We fetch all threads here because clients still expect the full list of\n+ // threads on most thread operations. We're in the process of switching them\n+ // to just need the diff, but until then...\n+ const serverThreadInfoFetchResult = await fetchServerThreadInfos();\nconst { threadInfos: serverThreadInfos } = serverThreadInfoFetchResult;\nconst time = Date.now();\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[server] Fix server bug that wipes out thread list
129,187
20.07.2020 22:30:43
14,400
bb7eae5c5382bb0d31972e46198a81ca47a0e638
[native] Call sendMessage in iOS ClearableTextInput onBlur
[ { "change_type": "MODIFY", "old_path": "native/components/clearable-text-input.react.ios.js", "new_path": "native/components/clearable-text-input.react.ios.js", "diff": "@@ -132,6 +132,14 @@ class ClearableTextInput extends React.PureComponent<\nonBlur = () => {\nthis.focused = false;\n+ if (this.pendingMessage) {\n+ // This is to catch a race condition where somebody hits the send button\n+ // and then blurs the TextInput before the textInputKey increment can\n+ // rerender this component. With this.focused set to false, the new\n+ // TextInput won't focus, and the old TextInput won't blur, which means\n+ // nothing will call sendMessage unless we do it right here.\n+ this.sendMessage();\n+ }\n};\nrender() {\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Call sendMessage in iOS ClearableTextInput onBlur
129,187
21.07.2020 09:44:24
14,400
27a0a6eedac14d4ca5a618aa56a6054fa051eb28
[server] Update backup_phabricator.sh to look at phacility/phabricator directory Instead of `phabricator/phabricator` directory, which feels repetitive
[ { "change_type": "MODIFY", "old_path": "server/bash/backup_phabricator.sh", "new_path": "server/bash/backup_phabricator.sh", "diff": "# run from: wherever\n# The path to Phabricator on our server\n-PHABRICATOR_PATH=/var/www/phabricator/phabricator\n+PHABRICATOR_PATH=/var/www/phacility/phabricator\n# The path to the backup directory on our server\nBACKUP_PATH=/mnt/backup\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[server] Update backup_phabricator.sh to look at phacility/phabricator directory Instead of `phabricator/phabricator` directory, which feels repetitive
129,187
21.07.2020 09:48:20
14,400
ba6a90d7db41a22d93e3c6de1c1fd4ac07a93224
[server] Silence Phabricator backup command
[ { "change_type": "MODIFY", "old_path": "server/bash/backup_phabricator.sh", "new_path": "server/bash/backup_phabricator.sh", "diff": "@@ -21,7 +21,7 @@ OUTPUT_FILE=\"$BACKUP_PATH/phabricator.$(date +'%Y-%m-%d-%R').sql.gz\"\nRETRIES=2\nwhile [[ $RETRIES -ge 0 ]]; do\n- if ./bin/storage dump --compress --overwrite --output \"$OUTPUT_FILE\"; then\n+ if ./bin/storage dump --compress --overwrite --output \"$OUTPUT_FILE\" > /dev/null 2>&1; then\nbreak\nfi\nrm -f \"$OUTPUT_FILE\"\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[server] Silence Phabricator backup command
129,187
22.07.2020 08:27:16
14,400
8403759af5644f442c1ab0446230804a71b5600c
[native] react-native-floating-action@^1.21.0
[ { "change_type": "MODIFY", "old_path": "native/package.json", "new_path": "native/package.json", "diff": "\"react-native-fast-image\": \"^7.0.2\",\n\"react-native-ffmpeg\": \"^0.4.4\",\n\"react-native-firebase\": \"^5.6.0\",\n- \"react-native-floating-action\": \"^1.19.1\",\n+ \"react-native-floating-action\": \"^1.21.0\",\n\"react-native-fs\": \"2.15.2\",\n\"react-native-gesture-handler\": \"^1.6.1\",\n\"react-native-in-app-message\": \"^1.0.2\",\n" }, { "change_type": "MODIFY", "old_path": "yarn.lock", "new_path": "yarn.lock", "diff": "@@ -12095,10 +12095,10 @@ react-native-firebase@^5.6.0:\nopencollective-postinstall \"^2.0.0\"\nprop-types \"^15.7.2\"\n-react-native-floating-action@^1.19.1:\n- version \"1.19.1\"\n- resolved \"https://registry.yarnpkg.com/react-native-floating-action/-/react-native-floating-action-1.19.1.tgz#fc3dcd0441ecbaf2d870b71f6db27f2db0f811b3\"\n- integrity sha512-6zgiCJyV63TOxpDKK+OxzhghMcBSn1Qhjb8p8TrfrUGAkzh7gQcmNN4ahq1CVbrN0ZpKhWET68WeifisYnQWyg==\n+react-native-floating-action@^1.21.0:\n+ version \"1.21.0\"\n+ resolved \"https://registry.yarnpkg.com/react-native-floating-action/-/react-native-floating-action-1.21.0.tgz#cb1e8349fec5b9aed06c8053c07372822c64b22f\"\n+ integrity sha512-ozd/iaJunrEYc4eGUWkP+4UI8yoIL0nQsToI3hnJRste/3LPhBkyu0eG3RTjc6aFY+q++JpRmgO469Ck8jJOwg==\nreact-native-fs@2.15.2:\nversion \"2.15.2\"\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] react-native-floating-action@^1.21.0
129,186
21.07.2020 12:09:42
-7,200
020cf71d97c3bcb0895d7efc6527c321e0b84cfa
Add userInfo state check Reviewers: ashoat
[ { "change_type": "MODIFY", "old_path": "lib/reducers/user-reducer.js", "new_path": "lib/reducers/user-reducer.js", "diff": "@@ -196,19 +196,26 @@ function reduceUserInfos(\nconst checkStateRequest = action.payload.serverRequests.find(\ncandidate => candidate.type === serverRequestTypes.CHECK_STATE,\n);\n- if (\n- checkStateRequest &&\n- checkStateRequest.stateChanges &&\n- checkStateRequest.stateChanges.userInfos\n- ) {\n- const newUserInfos = checkStateRequest.stateChanges.userInfos;\n- const newUserInfoObject = _keyBy(userInfo => userInfo.id)(newUserInfos);\n- // $FlowFixMe should be fixed in flow-bin@0.115 / react-native@0.63\n- const updated = { ...state, ...newUserInfoObject };\n- if (!_isEqual(state)(updated)) {\n- return updated;\n+ if (!checkStateRequest || !checkStateRequest.stateChanges) {\n+ return state;\n+ }\n+ const { userInfos, deleteUserInfoIDs } = checkStateRequest.stateChanges;\n+ if (!userInfos && !deleteUserInfoIDs) {\n+ return state;\n+ }\n+\n+ const newUserInfos = { ...state };\n+ if (userInfos) {\n+ for (const userInfo of userInfos) {\n+ newUserInfos[userInfo.id] = userInfo;\n}\n}\n+ if (deleteUserInfoIDs) {\n+ for (const deleteUserInfoID of deleteUserInfoIDs) {\n+ delete newUserInfos[deleteUserInfoID];\n+ }\n+ }\n+ return newUserInfos;\n}\nreturn state;\n}\n" }, { "change_type": "MODIFY", "old_path": "lib/selectors/socket-selectors.js", "new_path": "lib/selectors/socket-selectors.js", "diff": "@@ -7,7 +7,7 @@ import {\ntype ClientClientResponse,\n} from '../types/request-types';\nimport type { RawEntryInfo, CalendarQuery } from '../types/entry-types';\n-import type { CurrentUserInfo } from '../types/user-types';\n+import type { CurrentUserInfo, UserInfo } from '../types/user-types';\nimport type { RawThreadInfo } from '../types/thread-types';\nimport type { SessionState } from '../types/session-types';\nimport type {\n@@ -53,11 +53,13 @@ const getClientResponsesSelector: (\n) => $ReadOnlyArray<ClientClientResponse> = createSelector(\n(state: AppState) => state.threadStore.threadInfos,\n(state: AppState) => state.entryStore.entryInfos,\n+ (state: AppState) => state.userInfos,\n(state: AppState) => state.currentUserInfo,\ncurrentCalendarQuery,\n(\nthreadInfos: { [id: string]: RawThreadInfo },\nentryInfos: { [id: string]: RawEntryInfo },\n+ userInfos: { [id: string]: UserInfo },\ncurrentUserInfo: ?CurrentUserInfo,\ncalendarQuery: (calendarActive: boolean) => CalendarQuery,\n) => (\n@@ -95,6 +97,8 @@ const getClientResponsesSelector: (\nhashValue = hash(threadInfos);\n} else if (key === 'entryInfos') {\nhashValue = hash(filteredEntryInfos);\n+ } else if (key === 'userInfos') {\n+ hashValue = hash(userInfos);\n} else if (key === 'currentUserInfo') {\nhashValue = hash(currentUserInfo);\n} else if (key.startsWith('threadInfo|')) {\n@@ -107,6 +111,11 @@ const getClientResponsesSelector: (\nrawEntryInfo = serverEntryInfo(rawEntryInfo);\n}\nhashValue = hash(rawEntryInfo);\n+ } else if (key.startsWith('userInfo|')) {\n+ const [, userID] = key.split('|');\n+ hashValue = hash(userInfos[userID]);\n+ } else {\n+ continue;\n}\nhashResults[key] = expectedHashValue === hashValue;\n}\n@@ -130,6 +139,15 @@ const getClientResponsesSelector: (\n}\n}\n}\n+ if (failUnmentioned && failUnmentioned.userInfos) {\n+ for (let userID in userInfos) {\n+ const key = `userInfo|${userID}`;\n+ const hashResult = hashResults[key];\n+ if (hashResult === null || hashResult === undefined) {\n+ hashResults[key] = false;\n+ }\n+ }\n+ }\nclientResponses.push({\ntype: serverRequestTypes.CHECK_STATE,\n" }, { "change_type": "MODIFY", "old_path": "lib/types/request-types.js", "new_path": "lib/types/request-types.js", "diff": "@@ -89,6 +89,7 @@ export type CheckStateServerRequest = {|\nfailUnmentioned?: $Shape<{|\nthreadInfos: boolean,\nentryInfos: boolean,\n+ userInfos: boolean,\n|}>,\nstateChanges?: $Shape<{|\nrawThreadInfos: RawThreadInfo[],\n@@ -97,6 +98,7 @@ export type CheckStateServerRequest = {|\nuserInfos: AccountUserInfo[],\ndeleteThreadIDs: string[],\ndeleteEntryIDs: string[],\n+ deleteUserInfoIDs: string[],\n|}>,\n|};\ntype CheckStateClientResponse = {|\n" }, { "change_type": "MODIFY", "old_path": "server/src/fetchers/user-fetchers.js", "new_path": "server/src/fetchers/user-fetchers.js", "diff": "@@ -41,6 +41,29 @@ async function fetchUserInfos(userIDs: string[]): Promise<UserInfos> {\nreturn userInfos;\n}\n+async function fetchKnownUserInfos(viewer: Viewer) {\n+ if (!viewer.loggedIn) {\n+ throw new ServerError('not_logged_in');\n+ }\n+ const query = SQL`\n+ SELECT DISTINCT u.id, u.username FROM relationships_undirected r\n+ LEFT JOIN users u ON r.user1 = u.id OR r.user2 = u.id\n+ WHERE (r.user1 = ${viewer.userID} OR r.user2 = ${viewer.userID})\n+ `;\n+ const [result] = await dbQuery(query);\n+\n+ const userInfos = {};\n+ for (let row of result) {\n+ const id = row.id.toString();\n+ userInfos[id] = {\n+ id,\n+ username: row.username,\n+ };\n+ }\n+\n+ return userInfos;\n+}\n+\nasync function verifyUserIDs(\nuserIDs: $ReadOnlyArray<string>,\n): Promise<string[]> {\n@@ -118,4 +141,5 @@ export {\nfetchLoggedInUserInfos,\nfetchAllUserIDs,\nfetchUsername,\n+ fetchKnownUserInfos,\n};\n" }, { "change_type": "MODIFY", "old_path": "server/src/responders/ping-responders.js", "new_path": "server/src/responders/ping-responders.js", "diff": "@@ -69,6 +69,7 @@ import {\nimport {\nfetchCurrentUserInfo,\nfetchUserInfos,\n+ fetchKnownUserInfos,\n} from '../fetchers/user-fetchers';\nimport { fetchUpdateInfos } from '../fetchers/update-fetchers';\nimport {\n@@ -542,21 +543,40 @@ async function checkState(\nstatus: StateCheckStatus,\ncalendarQuery: CalendarQuery,\n): Promise<StateCheckResult> {\n+ const { platformDetails } = viewer;\n+ const shouldCheckUserInfos =\n+ (platformDetails && platformDetails.platform === 'web') ||\n+ (platformDetails &&\n+ platformDetails.codeVersion !== null &&\n+ platformDetails.codeVersion !== undefined &&\n+ platformDetails.codeVersion > 58);\n+\nif (status.status === 'state_validated') {\nreturn { sessionUpdate: { lastValidated: Date.now() } };\n} else if (status.status === 'state_check') {\n- const fetchedData = await promiseAll({\n+ const promises = {\nthreadsResult: fetchThreadInfos(viewer),\nentriesResult: fetchEntryInfos(viewer, [calendarQuery]),\ncurrentUserInfo: fetchCurrentUserInfo(viewer),\n- });\n- const hashesToCheck = {\n+ userInfosResult: undefined,\n+ };\n+ if (shouldCheckUserInfos) {\n+ promises.userInfosResult = fetchKnownUserInfos(viewer);\n+ }\n+ const fetchedData = await promiseAll(promises);\n+ let hashesToCheck = {\nthreadInfos: hash(fetchedData.threadsResult.threadInfos),\nentryInfos: hash(\nserverEntryInfosObject(fetchedData.entriesResult.rawEntryInfos),\n),\ncurrentUserInfo: hash(fetchedData.currentUserInfo),\n};\n+ if (shouldCheckUserInfos) {\n+ hashesToCheck = {\n+ ...hashesToCheck,\n+ userInfos: hash(fetchedData.userInfosResult),\n+ };\n+ }\nconst checkStateRequest = {\ntype: serverRequestTypes.CHECK_STATE,\nhashesToCheck,\n@@ -568,14 +588,18 @@ async function checkState(\nlet fetchAllThreads = false,\nfetchAllEntries = false,\n+ fetchAllUserInfos = false,\nfetchUserInfo = false;\nconst threadIDsToFetch = [],\n- entryIDsToFetch = [];\n+ entryIDsToFetch = [],\n+ userIDsToFetch = [];\nfor (let key of invalidKeys) {\nif (key === 'threadInfos') {\nfetchAllThreads = true;\n} else if (key === 'entryInfos') {\nfetchAllEntries = true;\n+ } else if (key === 'userInfos') {\n+ fetchAllUserInfos = true;\n} else if (key === 'currentUserInfo') {\nfetchUserInfo = true;\n} else if (key.startsWith('threadInfo|')) {\n@@ -584,6 +608,9 @@ async function checkState(\n} else if (key.startsWith('entryInfo|')) {\nconst [, entryID] = key.split('|');\nentryIDsToFetch.push(entryID);\n+ } else if (key.startsWith('userInfo|')) {\n+ const [, userID] = key.split('|');\n+ userIDsToFetch.push(userID);\n}\n}\n@@ -601,6 +628,11 @@ async function checkState(\n} else if (entryIDsToFetch.length > 0) {\nfetchPromises.entryInfos = fetchEntryInfosByID(viewer, entryIDsToFetch);\n}\n+ if (fetchAllUserInfos) {\n+ fetchPromises.userInfos = fetchKnownUserInfos(viewer);\n+ } else if (userIDsToFetch.length > 0) {\n+ fetchPromises.userInfos = fetchUserInfos(userIDsToFetch);\n+ }\nif (fetchUserInfo) {\nfetchPromises.currentUserInfo = fetchCurrentUserInfo(viewer);\n}\n@@ -630,6 +662,14 @@ async function checkState(\nhashesToCheck[`entryInfo|${entryID}`] = hash(entryInfo);\n}\nfailUnmentioned.entryInfos = true;\n+ } else if (key === 'userInfos') {\n+ // Instead of returning all userInfos, we want to narrow down and figure\n+ // out which userInfos don't match first\n+ const { userInfos } = fetchedData;\n+ for (let userID in userInfos) {\n+ hashesToCheck[`userInfo|${userID}`] = hash(userInfos[userID]);\n+ }\n+ failUnmentioned.userInfos = true;\n} else if (key === 'currentUserInfo') {\nstateChanges.currentUserInfo = fetchedData.currentUserInfo;\n} else if (key.startsWith('threadInfo|')) {\n@@ -666,9 +706,25 @@ async function checkState(\nstateChanges.rawEntryInfos = [];\n}\nstateChanges.rawEntryInfos.push(entryInfo);\n+ } else if (key.startsWith('userInfo|')) {\n+ const { userInfos: fetchedUserInfos } = fetchedData;\n+ const [, userID] = key.split('|');\n+ const userInfo = fetchedUserInfos[userID];\n+ if (!userInfo || !userInfo.username) {\n+ if (!stateChanges.deleteUserInfoIDs) {\n+ stateChanges.deleteUserInfoIDs = [];\n+ }\n+ stateChanges.deleteUserInfoIDs.push(userID);\n+ continue;\n+ }\n+ if (!stateChanges.userInfos) {\n+ stateChanges.userInfos = [];\n+ }\n+ stateChanges.userInfos.push(userInfo);\n}\n}\n+ if (!shouldCheckUserInfos) {\nconst userIDs = new Set();\nif (stateChanges.rawThreadInfos) {\nfor (let threadInfo of stateChanges.rawThreadInfos) {\n@@ -692,7 +748,7 @@ async function checkState(\nconst allUserInfos = { ...threadUserInfos, ...entryUserInfos };\nconst userInfos = [];\n- const userIDsToFetch = [];\n+ const oldUserIDsToFetch = [];\nfor (let userID of userIDs) {\nconst userInfo = allUserInfos[userID];\nif (userInfo) {\n@@ -702,7 +758,7 @@ async function checkState(\n}\n}\nif (userIDsToFetch.length > 0) {\n- const fetchedUserInfos = await fetchUserInfos(userIDsToFetch);\n+ const fetchedUserInfos = await fetchUserInfos(oldUserIDsToFetch);\nfor (let userID in fetchedUserInfos) {\nconst userInfo = fetchedUserInfos[userID];\nif (userInfo && userInfo.username) {\n@@ -714,7 +770,7 @@ async function checkState(\nif (userInfos.length > 0) {\nstateChanges.userInfos = userInfos;\n}\n-\n+ }\nconst checkStateRequest = {\ntype: serverRequestTypes.CHECK_STATE,\nhashesToCheck,\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Add userInfo state check Reviewers: ashoat Reviewed By: ashoat Differential Revision: https://phabricator.ashoat.com/D2
129,187
23.07.2020 22:33:56
14,400
9bd45e0aeb45c87ffe6e5c2c55a81f2de55391b1
[native] Fix Android crashes in background tasks I introduced these issues in and which both shipped in 57
[ { "change_type": "MODIFY", "old_path": "native/ios/Podfile.lock", "new_path": "native/ios/Podfile.lock", "diff": "@@ -369,7 +369,7 @@ PODS:\n- React\n- ReactNativeDarkMode (0.2.0-rc.1):\n- React\n- - ReactNativeKeyboardInput (6.0.0):\n+ - ReactNativeKeyboardInput (6.0.1):\n- React\n- ReactNativeKeyboardTrackingView (5.7.0):\n- React\n@@ -753,7 +753,7 @@ SPEC CHECKSUMS:\nReactCommon: ed4e11d27609d571e7eee8b65548efc191116eb3\nReactNativeART: c580fba2f7d188d8fa4418ce78db8130654ed10f\nReactNativeDarkMode: 88317ff05ba95fd063dd347ad32f8c4cefd3166c\n- ReactNativeKeyboardInput: c37e26821519869993b3b61844350feb9177ff37\n+ ReactNativeKeyboardInput: 266ba27a2e9921f5bdc0b4cc30289b2a2f46b157\nReactNativeKeyboardTrackingView: 02137fac3b2ebd330d74fa54ead48b14750a2306\nRNCAsyncStorage: 60a80e72d95bf02a01cace55d3697d9724f0d77f\nRNCMaskedView: 5a8ec07677aa885546a0d98da336457e2bea557f\n" }, { "change_type": "MODIFY", "old_path": "native/package.json", "new_path": "native/package.json", "diff": "\"react-native-fs\": \"2.15.2\",\n\"react-native-gesture-handler\": \"^1.6.1\",\n\"react-native-in-app-message\": \"^1.0.2\",\n- \"react-native-keyboard-input\": \"^6.0.0\",\n+ \"react-native-keyboard-input\": \"6.0.1\",\n\"react-native-keychain\": \"^4.0.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" }, { "change_type": "MODIFY", "old_path": "native/redux/dimensions-updater.react.js", "new_path": "native/redux/dimensions-updater.react.js", "diff": "@@ -38,7 +38,13 @@ type Metrics = {|\n+frame: {| +x: number, +y: number, +width: number, +height: number |},\n+insets: {| +top: number, +left: number, +right: number, +bottom: number |},\n|};\n-function dimensionsUpdateFromMetrics(metrics: Metrics): $Shape<DimensionsInfo> {\n+function dimensionsUpdateFromMetrics(\n+ metrics: ?Metrics,\n+): $Shape<DimensionsInfo> {\n+ if (!metrics) {\n+ // This happens when the app gets booted to run a background task\n+ return { height: 0, width: 0, topInset: 0, bottomInset: 0 };\n+ }\nreturn {\nheight: metrics.frame.height,\nwidth: metrics.frame.width,\n" }, { "change_type": "RENAME", "old_path": "patches/react-native-keyboard-input+6.0.0.patch", "new_path": "patches/react-native-keyboard-input+6.0.1.patch", "diff": "@@ -11,7 +11,7 @@ index 46d2207..830c7b5 100644\nmLayout.setShadowNode(this);\n}\ndiff --git a/node_modules/react-native-keyboard-input/lib/android/src/main/java/com/wix/reactnativekeyboardinput/ReactSoftKeyboardMonitor.java b/node_modules/react-native-keyboard-input/lib/android/src/main/java/com/wix/reactnativekeyboardinput/ReactSoftKeyboardMonitor.java\n-index ae5e756..e861f64 100644\n+index 6bd4453..8607b47 100644\n--- a/node_modules/react-native-keyboard-input/lib/android/src/main/java/com/wix/reactnativekeyboardinput/ReactSoftKeyboardMonitor.java\n+++ b/node_modules/react-native-keyboard-input/lib/android/src/main/java/com/wix/reactnativekeyboardinput/ReactSoftKeyboardMonitor.java\n@@ -24,9 +24,9 @@ index ae5e756..e861f64 100644\n+import android.util.TypedValue;\n+import android.view.Display;\nimport android.view.ViewTreeObserver;\n+ import android.view.Window;\n- import androidx.annotation.Nullable;\n-@@ -61,8 +66,28 @@ public class ReactSoftKeyboardMonitor implements ReactScreenMonitor.Listener {\n+@@ -65,8 +70,33 @@ public class ReactSoftKeyboardMonitor implements ReactScreenMonitor.Listener {\nprivate Listener mExternalListener;\nprivate ReactRootView mLastReactRootView;\n@@ -36,6 +36,11 @@ index ae5e756..e861f64 100644\nscreenMonitor.addListener(this);\n+\n+ this.translucentNavBarHeight = 0;\n++\n++ if (getWindow() == null) {\n++ return;\n++ }\n++\n+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {\n+ return;\n+ }\n@@ -55,7 +60,7 @@ index ae5e756..e861f64 100644\n}\n@Override\n-@@ -123,14 +148,14 @@ public class ReactSoftKeyboardMonitor implements ReactScreenMonitor.Listener {\n+@@ -132,21 +162,21 @@ public class ReactSoftKeyboardMonitor implements ReactScreenMonitor.Listener {\nRuntimeUtils.runOnUIThread(new Runnable() {\n@Override\npublic void run() {\n@@ -67,10 +72,20 @@ index ae5e756..e861f64 100644\nreturn;\n}\n-- if (mLocallyVisibleHeight > locallyVisibleHeight) {\n+ if (mLocallyVisibleHeight == null) {\n+- mLocallyVisibleHeight = locallyVisibleHeight;\n++ mLocallyVisibleHeight = viewportVisibleHeight;\n+ mKeyboardHeight = mLocallyVisibleHeight;\n+ Logger.d(TAG, \"mLocallyVisibleHeight WAS NULL, now is: \" + mLocallyVisibleHeight);\n+- } else if (mLocallyVisibleHeight > locallyVisibleHeight) {\n- mKeyboardHeight = mLocallyVisibleHeight - locallyVisibleHeight;\n-+ if (mMaxViewportVisibleHeight > viewportVisibleHeight) {\n++ } else if (mMaxViewportVisibleHeight > viewportVisibleHeight) {\n+ mKeyboardHeight = mMaxViewportVisibleHeight - viewportVisibleHeight + translucentNavBarHeight;\n+ } else {\n+- mKeyboardHeight = locallyVisibleHeight;\n+- Logger.d(TAG, \"mKeyboardHeight = \" + mKeyboardHeight + \" mLocallyVisibleHeight = \" + mLocallyVisibleHeight + \" locallyVisibleHeight = \" + locallyVisibleHeight);\n++ mKeyboardHeight = viewportVisibleHeight;\n++ Logger.d(TAG, \"mKeyboardHeight = \" + mKeyboardHeight + \" mLocallyVisibleHeight = \" + mLocallyVisibleHeight + \" viewportVisibleHeight= \" + viewportVisibleHeight);\n}\n}\n});\n@@ -143,10 +158,10 @@ index b91aa83..f403d38 100644\nrevealKeyboardInteractive={this.props.revealKeyboardInteractive}\nmanageScrollView={this.props.manageScrollView}\ndiff --git a/node_modules/react-native-keyboard-input/src/TextInputKeyboardMangerIOS.js b/node_modules/react-native-keyboard-input/src/TextInputKeyboardMangerIOS.js\n-index 20d61c9..13a6493 100644\n+index 20d61c9..e8369f0 100644\n--- a/node_modules/react-native-keyboard-input/src/TextInputKeyboardMangerIOS.js\n+++ b/node_modules/react-native-keyboard-input/src/TextInputKeyboardMangerIOS.js\n-@@ -41,6 +41,12 @@ export default class TextInputKeyboardManagerIOS {\n+@@ -41,6 +41,11 @@ export default class TextInputKeyboardManagerIOS {\n}\n}\n};\n@@ -155,7 +170,6 @@ index 20d61c9..13a6493 100644\n+ const reactTag = findNodeHandle(textInputRef);\n+ CustomInputController.changeKeyboardHeightForInput(reactTag, keyboardHeight);\n+ }\n-+\n}\nfunction findNodeHandle(ref) {\n" }, { "change_type": "MODIFY", "old_path": "yarn.lock", "new_path": "yarn.lock", "diff": "@@ -12128,10 +12128,10 @@ react-native-iphone-x-helper@^1.2.1:\nresolved \"https://registry.yarnpkg.com/react-native-iphone-x-helper/-/react-native-iphone-x-helper-1.2.1.tgz#645e2ffbbb49e80844bb4cbbe34a126fda1e6772\"\nintegrity sha512-/VbpIEp8tSNNHIvstuA3Swx610whci1Zpc9mqNkqn14DkMbw+ORviln2u0XyHG1kPvvwTNGZY6QpeFwxYaSdbQ==\n-react-native-keyboard-input@^6.0.0:\n- version \"6.0.0\"\n- resolved \"https://registry.yarnpkg.com/react-native-keyboard-input/-/react-native-keyboard-input-6.0.0.tgz#db71ddc8f7c6fdb799b17b9ebdeb783c7ca55c08\"\n- integrity sha512-dpmkLaLk1+hqYfsRFktB5z0UuJHvJSBCQG67o8MhHa9uOq01OSwMIQUujuOwnGwJ/iIzexZs7YaI2Yb6M34g5g==\n+react-native-keyboard-input@6.0.1:\n+ version \"6.0.1\"\n+ resolved \"https://registry.yarnpkg.com/react-native-keyboard-input/-/react-native-keyboard-input-6.0.1.tgz#996a0c00c2232b09e30cdee37dd8c086c688e1f7\"\n+ integrity sha512-tLvyD0D7SBWQvothqrXRdI1Czsj1zPb6TYkjN5KgPBzlm89VxFSxJMAUkTDHR2iY+wl/E5FVgDdSvVKH8T/pew==\ndependencies:\nlodash \"^4.17.4\"\nreact-native-keyboard-tracking-view \"^5.5.0\"\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Fix Android crashes in background tasks I introduced these issues in f4e846975d7a610038fd1f21b79a39305ce293bc and bc7894016a33ab7cf63ac3d4657f2af770016809, which both shipped in 57
129,187
24.07.2020 00:48:24
14,400
9a86944810f9283a1c7d3d940cf01328547ac9a9
[native] Don't disable SplashScreen autohide until Root mounts Otherwise if the app boots from a background task it never shows the `MainActivity` splash screen
[ { "change_type": "MODIFY", "old_path": "native/navigation/app-navigator.react.js", "new_path": "native/navigation/app-navigator.react.js", "diff": "@@ -44,11 +44,6 @@ import { waitForInteractions } from '../utils/interactions';\nimport ChatIcon from '../chat/chat-icon.react';\nlet splashScreenHasHidden = false;\n-(async () => {\n- try {\n- await SplashScreen.preventAutoHideAsync();\n- } catch {}\n-})();\nconst calendarTabOptions = {\ntabBarLabel: 'Calendar',\n" }, { "change_type": "MODIFY", "old_path": "native/root.react.js", "new_path": "native/root.react.js", "diff": "@@ -15,6 +15,7 @@ import {\ninitialWindowMetrics,\n} from 'react-native-safe-area-context';\nimport { useReduxDevToolsExtension } from '@react-navigation/devtools';\n+import * as SplashScreen from 'expo-splash-screen';\nimport { actionLogger } from 'lib/utils/action-logger';\n@@ -54,6 +55,14 @@ function Root() {\nconst navDispatchRef = React.useRef();\nconst navStateInitializedRef = React.useRef(false);\n+ React.useEffect(() => {\n+ (async () => {\n+ try {\n+ await SplashScreen.preventAutoHideAsync();\n+ } catch {}\n+ })();\n+ }, []);\n+\nconst [navContext, setNavContext] = React.useState(null);\nconst updateNavContext = React.useCallback(() => {\nif (\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Don't disable SplashScreen autohide until Root mounts Otherwise if the app boots from a background task it never shows the `MainActivity` splash screen
129,187
24.07.2020 00:58:59
14,400
b9ea65696a21d985a3bdcc26319d9f524413ee1d
[native] Display in-app notifs below top inset
[ { "change_type": "MODIFY", "old_path": "native/push/in-app-notif.react.js", "new_path": "native/push/in-app-notif.react.js", "diff": "@@ -4,6 +4,9 @@ import type { GlobalTheme } from '../types/themes';\nimport * as React from 'react';\nimport { View, Text, StyleSheet, Platform } from 'react-native';\n+import { SafeAreaView } from 'react-native-safe-area-context';\n+\n+const edges = ['top'];\ntype Props = {|\ntitle: ?string,\n@@ -28,14 +31,22 @@ function InAppNotif(props: Props) {\n}\nconst textStyles = [styles.text, useLightStyle ? styles.lightText : null];\n- return (\n- <View style={styles.notif}>\n+ const notificationContent = (\n<Text style={textStyles}>\n{title}\n{props.message}\n</Text>\n- </View>\n);\n+\n+ if (Platform.OS === 'android') {\n+ return (\n+ <SafeAreaView style={styles.notif} edges={edges}>\n+ {notificationContent}\n+ </SafeAreaView>\n+ );\n+ }\n+\n+ return <View style={styles.notif}>{notificationContent}</View>;\n}\nconst styles = StyleSheet.create({\n" }, { "change_type": "MODIFY", "old_path": "native/push/push-handler.react.js", "new_path": "native/push/push-handler.react.js", "diff": "@@ -596,7 +596,12 @@ class PushHandler extends React.PureComponent<Props, State> {\n};\nrender() {\n- return <InAppNotification {...this.state.inAppNotifProps} />;\n+ return (\n+ <InAppNotification\n+ {...this.state.inAppNotifProps}\n+ hideStatusBar={false}\n+ />\n+ );\n}\n}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Display in-app notifs below top inset
129,187
23.07.2020 23:04:45
14,400
de427d2e9e5e4db4e37bc301dae19215b7edc0a2
[native] codeVersion -> 59
[ { "change_type": "MODIFY", "old_path": "native/android/app/build.gradle", "new_path": "native/android/app/build.gradle", "diff": "@@ -133,8 +133,8 @@ android {\napplicationId \"org.squadcal\"\nminSdkVersion rootProject.ext.minSdkVersion\ntargetSdkVersion rootProject.ext.targetSdkVersion\n- versionCode 58\n- versionName \"0.0.58\"\n+ versionCode 59\n+ versionName \"0.0.59\"\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.58</string>\n+ <string>0.0.59</string>\n<key>CFBundleSignature</key>\n<string>????</string>\n<key>CFBundleVersion</key>\n- <string>58</string>\n+ <string>59</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.58</string>\n+ <string>0.0.59</string>\n<key>CFBundleSignature</key>\n<string>????</string>\n<key>CFBundleVersion</key>\n- <string>58</string>\n+ <string>59</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": "@@ -175,7 +175,7 @@ const persistConfig = {\ntimeout: __DEV__ ? 0 : undefined,\n};\n-const codeVersion = 58;\n+const codeVersion = 59;\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 -> 59
129,187
24.07.2020 02:05:33
14,400
d8ce9ac576a790f2db123eefcd35648e1fa49c02
[server] Fix typo in relationships_undirected key ALTER TABLE in create-db.js
[ { "change_type": "MODIFY", "old_path": "server/src/scripts/create-db.js", "new_path": "server/src/scripts/create-db.js", "diff": "@@ -286,7 +286,7 @@ async function createTables() {\nALTER TABLE relationships_undirected\nADD UNIQUE KEY user1_user2 (user1,user2),\n- ADD UNIQUE KEY user2_user1 (user2,user1),\n+ ADD UNIQUE KEY user2_user1 (user2,user1);\nALTER TABLE relationships_directed\nADD UNIQUE KEY user1_user2 (user1,user2);\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[server] Fix typo in relationships_undirected key ALTER TABLE in create-db.js
129,183
20.07.2020 13:10:38
-7,200
02f65383b43581229da59a798a13319dd8999b29
[web] Add more rules for markdown Summary: [web] After review changes Fix fence regex [web] Handle empty line in fence [web] Add useDarkStyle props to markdown Reviewers: ashoat
[ { "change_type": "MODIFY", "old_path": "lib/shared/markdown.js", "new_path": "lib/shared/markdown.js", "diff": "// @flow\nconst urlRegex = /^(https?:\\/\\/[^\\s<]+[^<.,:;\"')\\]\\s])/i;\n+const paragraphRegex = /^((?:[^\\n]*)(?:\\n|$))/;\n+const blockQuoteRegex = /^( *>[^\\n]+(?:\\n[^\\n]+)*)/;\n+const headingRegex = /^ *(#{1,6}) ([^\\n]+?)#* *(?![^\\n])/;\n+const codeBlockRegex = /^(?: {4}[^\\n]*\\n*?)+(?!\\n* {4}[^\\n])(?:\\n|$)/;\n+const fenceRegex = /^(`{3,}|~{3,})[^\\n]*\\n([\\s\\S]*\\n)\\1(?:\\n|$)/;\n-export { urlRegex };\n+export {\n+ urlRegex,\n+ paragraphRegex,\n+ blockQuoteRegex,\n+ headingRegex,\n+ codeBlockRegex,\n+ fenceRegex,\n+};\n" }, { "change_type": "MODIFY", "old_path": "native/markdown/rules.react.js", "new_path": "native/markdown/rules.react.js", "diff": "@@ -7,7 +7,7 @@ import * as React from 'react';\nimport { Text, Linking, Alert } from 'react-native';\nimport * as SimpleMarkdown from 'simple-markdown';\n-import { urlRegex } from 'lib/shared/markdown';\n+import { urlRegex, paragraphRegex } from 'lib/shared/markdown';\nimport { normalizeURL } from 'lib/utils/url-utils';\ntype MarkdownRuleSpec = {|\n@@ -76,7 +76,7 @@ function inlineMarkdownRules(\n...SimpleMarkdown.defaultRules.paragraph,\n// simple-markdown collapses multiple newlines into one, but we want to\n// preserve the newlines\n- match: SimpleMarkdown.blockRegex(/^((?:[^\\n]*)(?:\\n|$))/),\n+ match: SimpleMarkdown.blockRegex(paragraphRegex),\n// eslint-disable-next-line react/display-name\nreact: (\nnode: SimpleMarkdown.SingleASTNode,\n" }, { "change_type": "MODIFY", "old_path": "web/chat/robotext-message.react.js", "new_path": "web/chat/robotext-message.react.js", "diff": "@@ -56,8 +56,9 @@ class RobotextMessage extends React.PureComponent<Props> {\ncontinue;\n}\nif (splitPart.charAt(0) !== '<') {\n+ const key = `text${keyIndex++}`;\ntextParts.push(\n- <Markdown key={`text${keyIndex++}`} rules={linkRules}>\n+ <Markdown key={key} useDarkStyle={false} rules={linkRules}>\n{decodeURI(splitPart)}\n</Markdown>,\n);\n" }, { "change_type": "MODIFY", "old_path": "web/chat/text-message.react.js", "new_path": "web/chat/text-message.react.js", "diff": "@@ -86,7 +86,9 @@ class TextMessage extends React.PureComponent<Props> {\nsetMouseOver={this.props.setMouseOver}\n>\n<div className={messageClassName} style={messageStyle}>\n- <Markdown rules={markdownRules}>{text}</Markdown>\n+ <Markdown useDarkStyle={darkColor} rules={markdownRules}>\n+ {text}\n+ </Markdown>\n</div>\n</ComposedMessage>\n);\n" }, { "change_type": "ADD", "old_path": null, "new_path": "web/markdown/markdown.css", "diff": "+div.markdown {\n+ display: inline;\n+}\n+\n+div.markdown h1,\n+div.markdown h2,\n+div.markdown h3,\n+div.markdown h4,\n+div.markdown h5,\n+div.markdown h6 {\n+ display: inline;\n+}\n+\n+div.markdown blockquote {\n+ display: inline-block;\n+ padding: .5em 10px;\n+ box-sizing: border-box;\n+ width: 100%;\n+}\n+div.darkBackground blockquote {\n+ background: #A9A9A9;\n+ border-left: 5px solid #808080;\n+}\n+div.lightBackground blockquote {\n+ background: #D3D3D3;\n+ border-left: 5px solid #C0C0C0;\n+}\n+\n+div.markdown code {\n+ width: 100%;\n+ display: inline-block;\n+ padding: .5em 10px;\n+ box-sizing: border-box;\n+}\n+div.lightBackground code {\n+ background: #DCDCDC;\n+}\n+div.darkBackground code {\n+ background: #808080;\n+}\n" }, { "change_type": "MODIFY", "old_path": "web/markdown/markdown.react.js", "new_path": "web/markdown/markdown.react.js", "diff": "import type { MarkdownRules } from './rules.react';\nimport * as React from 'react';\n-import PropTypes from 'prop-types';\nimport * as SimpleMarkdown from 'simple-markdown';\n+import classNames from 'classnames';\n+\n+import css from './markdown.css';\ntype Props = {|\nchildren: string,\nrules: MarkdownRules,\n+ useDarkStyle: boolean,\n|};\n-class Markdown extends React.PureComponent<Props> {\n- static propTypes = {\n- children: PropTypes.string.isRequired,\n- rules: PropTypes.func.isRequired,\n- };\n-\n- ast: SimpleMarkdown.Parser;\n- output: SimpleMarkdown.ReactOutput;\n-\n- constructor(props: Props) {\n- super(props);\n-\n- const { simpleMarkdownRules } = this.props.rules();\n- const parser = SimpleMarkdown.parserFor(simpleMarkdownRules);\n- this.ast = parser(this.props.children, { inline: true });\n- this.output = SimpleMarkdown.outputFor(simpleMarkdownRules, 'react');\n- }\n-\n- render() {\n- return this.output(this.ast);\n- }\n+function Markdown(props: Props) {\n+ const { useDarkStyle, children, rules } = props;\n+\n+ const markdownClassName = React.useMemo(\n+ () =>\n+ classNames({\n+ [css.markdown]: true,\n+ [css.darkBackground]: useDarkStyle,\n+ [css.lightBackground]: !useDarkStyle,\n+ }),\n+ [useDarkStyle],\n+ );\n+\n+ const { simpleMarkdownRules } = React.useMemo(() => rules(), [rules]);\n+\n+ const parser = React.useMemo(\n+ () => SimpleMarkdown.parserFor(simpleMarkdownRules),\n+ [simpleMarkdownRules],\n+ );\n+ const ast = React.useMemo(\n+ () => parser(children, { disableAutoBlockNewlines: true }),\n+ [parser, children],\n+ );\n+\n+ const output = React.useMemo(\n+ () => SimpleMarkdown.outputFor(simpleMarkdownRules, 'react'),\n+ [simpleMarkdownRules],\n+ );\n+ const renderedOutput = React.useMemo(() => output(ast), [ast, output]);\n+\n+ return <div className={markdownClassName}>{renderedOutput}</div>;\n}\nexport default Markdown;\n" }, { "change_type": "MODIFY", "old_path": "web/markdown/rules.react.js", "new_path": "web/markdown/rules.react.js", "diff": "import * as SimpleMarkdown from 'simple-markdown';\nimport * as React from 'react';\n-import { urlRegex } from 'lib/shared/markdown';\n+import * as MarkdownRegex from 'lib/shared/markdown';\ntype MarkdownRuleSpec = {|\n+simpleMarkdownRules: SimpleMarkdown.Rules,\n@@ -14,9 +14,9 @@ function linkRules(): MarkdownRuleSpec {\nconst simpleMarkdownRules = {\n// We are using default simple-markdown rules\n// For more details, look at native/markdown/rules.react\n- autolink: SimpleMarkdown.defaultRules.autolink,\nlink: {\n...SimpleMarkdown.defaultRules.link,\n+ match: () => null,\n// eslint-disable-next-line react/display-name\nreact: (\nnode: SimpleMarkdown.SingleASTNode,\n@@ -34,10 +34,24 @@ function linkRules(): MarkdownRuleSpec {\n</a>\n),\n},\n+ paragraph: {\n+ ...SimpleMarkdown.defaultRules.paragraph,\n+ match: SimpleMarkdown.blockRegex(MarkdownRegex.paragraphRegex),\n+ // eslint-disable-next-line react/display-name\n+ react: (\n+ node: SimpleMarkdown.SingleASTNode,\n+ output: SimpleMarkdown.Output<SimpleMarkdown.ReactElement>,\n+ state: SimpleMarkdown.State,\n+ ) => (\n+ <React.Fragment key={state.key}>\n+ {output(node.content, state)}\n+ </React.Fragment>\n+ ),\n+ },\ntext: SimpleMarkdown.defaultRules.text,\nurl: {\n...SimpleMarkdown.defaultRules.url,\n- match: SimpleMarkdown.inlineRegex(urlRegex),\n+ match: SimpleMarkdown.inlineRegex(MarkdownRegex.urlRegex),\n},\n};\nreturn {\n@@ -47,8 +61,59 @@ function linkRules(): MarkdownRuleSpec {\n// function will contain additional rules for message formatting\nfunction markdownRules(): MarkdownRuleSpec {\n+ const linkMarkdownRules = linkRules();\n+\n+ const simpleMarkdownRules = {\n+ ...linkMarkdownRules.simpleMarkdownRules,\n+ autolink: SimpleMarkdown.defaultRules.autolink,\n+ link: {\n+ ...linkMarkdownRules.simpleMarkdownRules.link,\n+ match: SimpleMarkdown.defaultRules.link.match,\n+ },\n+ blockQuote: {\n+ ...SimpleMarkdown.defaultRules.blockQuote,\n+ // match end of blockQuote by either \\n\\n or end of string\n+ match: SimpleMarkdown.blockRegex(MarkdownRegex.blockQuoteRegex),\n+ parse(\n+ capture: SimpleMarkdown.Capture,\n+ parse: SimpleMarkdown.Parser,\n+ state: SimpleMarkdown.State,\n+ ) {\n+ const content = capture[1].replace(/^ *> ?/gm, '');\n+ return {\n+ content: parse(content, state),\n+ };\n+ },\n+ },\n+ inlineCode: SimpleMarkdown.defaultRules.inlineCode,\n+ em: SimpleMarkdown.defaultRules.em,\n+ strong: SimpleMarkdown.defaultRules.strong,\n+ del: SimpleMarkdown.defaultRules.del,\n+ u: SimpleMarkdown.defaultRules.u,\n+ heading: {\n+ ...SimpleMarkdown.defaultRules.heading,\n+ match: SimpleMarkdown.blockRegex(MarkdownRegex.headingRegex),\n+ },\n+ mailto: SimpleMarkdown.defaultRules.mailto,\n+ codeBlock: {\n+ ...SimpleMarkdown.defaultRules.codeBlock,\n+ match: SimpleMarkdown.blockRegex(MarkdownRegex.codeBlockRegex),\n+ parse: (capture: SimpleMarkdown.Capture) => ({\n+ content: capture[0].replace(/^ {4}/gm, ''),\n+ }),\n+ },\n+ fence: {\n+ ...SimpleMarkdown.defaultRules.fence,\n+ match: SimpleMarkdown.blockRegex(MarkdownRegex.fenceRegex),\n+ parse: (capture: SimpleMarkdown.Capture) => ({\n+ type: 'codeBlock',\n+ content: capture[2],\n+ }),\n+ },\n+ };\nreturn {\n- ...linkRules(),\n+ ...linkMarkdownRules,\n+ simpleMarkdownRules,\n};\n}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[web] Add more rules for markdown Summary: [web] After review changes Fix fence regex [web] Handle empty line in fence [web] Add useDarkStyle props to markdown Reviewers: ashoat Reviewed By: ashoat Differential Revision: https://phabricator.ashoat.com/D4
129,187
24.07.2020 11:04:21
14,400
4351fcf2ea6704afb2e8a7c5542d66b525440373
Fix up .arcconfig to make arc land and arc diff easier
[ { "change_type": "MODIFY", "old_path": ".arcconfig", "new_path": ".arcconfig", "diff": "{\n\"phabricator.uri\": \"https://phabricator.ashoat.com/\",\n- \"repository.callsign\": \"SQUADCAL\"\n+ \"repository.callsign\": \"SQUADCAL\",\n+ \"arc.land.onto.default\": \"master\",\n+ \"base\": \"git:merge-base(origin/master)\"\n}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Fix up .arcconfig to make arc land and arc diff easier
129,187
24.07.2020 11:41:14
14,400
7904fac4c08175012efe988a55ba161b4205ffe3
[native] Don't render PushHandler until splash screen is hidden Otherwise `PushHandler` can trigger an `Alert` that prevents the splash screen from hiding for some reason
[ { "change_type": "MODIFY", "old_path": "native/navigation/app-navigator.react.js", "new_path": "native/navigation/app-navigator.react.js", "diff": "@@ -125,8 +125,13 @@ function AppNavigator(props: AppNavigatorProps) {\nsetNavStateInitialized && setNavStateInitialized();\n}, [setNavStateInitialized]);\n+ const [\n+ localSplashScreenHasHidden,\n+ setLocalSplashScreenHasHidden,\n+ ] = React.useState(splashScreenHasHidden);\n+\nReact.useEffect(() => {\n- if (splashScreenHasHidden) {\n+ if (localSplashScreenHasHidden) {\nreturn;\n}\nsplashScreenHasHidden = true;\n@@ -134,9 +139,19 @@ function AppNavigator(props: AppNavigatorProps) {\nawait waitForInteractions();\ntry {\nawait SplashScreen.hideAsync();\n+ setLocalSplashScreenHasHidden(true);\n} catch {}\n})();\n- }, []);\n+ }, [localSplashScreenHasHidden]);\n+\n+ let pushHandler;\n+ if (localSplashScreenHasHidden) {\n+ pushHandler = (\n+ <PersistGate persistor={getPersistor()}>\n+ <PushHandler navigation={navigation} />\n+ </PersistGate>\n+ );\n+ }\nreturn (\n<KeyboardStateContainer>\n@@ -164,9 +179,7 @@ function AppNavigator(props: AppNavigatorProps) {\n/>\n<App.Screen name={CameraModalRouteName} component={CameraModal} />\n</App.Navigator>\n- <PersistGate persistor={getPersistor()}>\n- <PushHandler navigation={navigation} />\n- </PersistGate>\n+ {pushHandler}\n</KeyboardStateContainer>\n);\n}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Don't render PushHandler until splash screen is hidden Otherwise `PushHandler` can trigger an `Alert` that prevents the splash screen from hiding for some reason
129,187
24.07.2020 15:48:40
14,400
4515d05db305f86aada4f8c9ce089b4f2eb79b73
[native] Fix Entry height calculation
[ { "change_type": "MODIFY", "old_path": "native/calendar/calendar.react.js", "new_path": "native/calendar/calendar.react.js", "diff": "@@ -70,7 +70,7 @@ import {\nimport { connect } from 'lib/utils/redux-utils';\nimport { createLoadingStatusSelector } from 'lib/selectors/loading-selectors';\n-import { Entry, InternalEntry, combinedEntryStyle } from './entry.react';\n+import { Entry, InternalEntry, entryStyles } from './entry.react';\nimport { calendarListData } from '../selectors/calendar-selectors';\nimport {\ncreateIsForegroundSelector,\n@@ -253,7 +253,11 @@ class Calendar extends React.PureComponent<Props, State> {\ncontinue;\n}\nconst text = item.entryInfo.text === '' ? ' ' : item.entryInfo.text;\n- const node = <Text style={combinedEntryStyle}>{text}</Text>;\n+ const node = (\n+ <View style={[entryStyles.entry, entryStyles.textContainer]}>\n+ <Text style={entryStyles.text}>{text}</Text>\n+ </View>\n+ );\nnodesToMeasure.push({\nid: entryKey(item.entryInfo),\nnode,\n" }, { "change_type": "MODIFY", "old_path": "native/calendar/entry.react.js", "new_path": "native/calendar/entry.react.js", "diff": "@@ -21,7 +21,6 @@ import type {\nimport type { LoadingStatus } from 'lib/types/loading-types';\nimport type { LayoutEvent } from '../types/react-native';\nimport type { TabNavigationProp } from '../navigation/app-navigator.react';\n-import type { TextStyle as FlattenedTextStyle } from 'react-native/Libraries/StyleSheet/StyleSheet';\nimport * as React from 'react';\nimport {\n@@ -33,7 +32,6 @@ import {\nAlert,\nLayoutAnimation,\nKeyboard,\n- StyleSheet,\n} from 'react-native';\nimport PropTypes from 'prop-types';\nimport invariant from 'invariant';\n@@ -750,11 +748,6 @@ const styles = {\n};\nconst stylesSelector = styleSelector(styles);\n-const combinedEntryStyle: FlattenedTextStyle = (StyleSheet.flatten([\n- styles.textContainer,\n- styles.text,\n-]): any);\n-\nregisterFetchKey(saveEntryActionTypes);\nregisterFetchKey(deleteEntryActionTypes);\nconst activeThreadPickerSelector = createIsForegroundSelector(\n@@ -778,4 +771,4 @@ const Entry = connectNav((context: ?NavContextType) => ({\n)(InternalEntry),\n);\n-export { InternalEntry, Entry, combinedEntryStyle };\n+export { InternalEntry, Entry, styles as entryStyles };\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Fix Entry height calculation
129,187
24.07.2020 16:14:35
14,400
c535ee0620d1c0cc12d28d739f497066bdfeefc0
[native] Delay ThreadList Search autoFocus until KeyboardAvoidingView can mount
[ { "change_type": "MODIFY", "old_path": "native/components/thread-list.react.js", "new_path": "native/components/thread-list.react.js", "diff": "@@ -6,12 +6,13 @@ import type { AppState } from '../redux/redux-setup';\nimport * as React from 'react';\nimport PropTypes from 'prop-types';\n-import { FlatList, ViewPropTypes, Text } from 'react-native';\n+import { FlatList, ViewPropTypes, Text, TextInput } from 'react-native';\nimport invariant from 'invariant';\nimport { createSelector } from 'reselect';\nimport SearchIndex from 'lib/shared/search-index';\nimport { connect } from 'lib/utils/redux-utils';\n+import sleep from 'lib/utils/sleep';\nimport ThreadListThread from './thread-list-thread.react';\nimport {\n@@ -51,6 +52,7 @@ class ThreadList extends React.PureComponent<Props, State> {\nsearchText: '',\nsearchResults: new Set(),\n};\n+ textInput: ?React.ElementRef<typeof TextInput>;\nlistDataSelector = createSelector(\n(propsAndState: PropsAndState) => propsAndState.threadInfos,\n@@ -83,7 +85,7 @@ class ThreadList extends React.PureComponent<Props, State> {\nonChangeText={this.onChangeSearchText}\ncontainerStyle={this.props.styles.search}\nplaceholder=\"Search threads\"\n- autoFocus={true}\n+ ref={this.searchRef}\n/>\n);\n}\n@@ -127,6 +129,17 @@ class ThreadList extends React.PureComponent<Props, State> {\nconst results = this.props.searchIndex.getSearchResults(searchText);\nthis.setState({ searchText, searchResults: new Set(results) });\n};\n+\n+ searchRef = async (textInput: ?React.ElementRef<typeof TextInput>) => {\n+ this.textInput = textInput;\n+ if (!textInput) {\n+ return;\n+ }\n+ await sleep(50);\n+ if (this.textInput) {\n+ this.textInput.focus();\n+ }\n+ };\n}\nconst styles = {\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Delay ThreadList Search autoFocus until KeyboardAvoidingView can mount
129,187
24.07.2020 16:16:02
14,400
7a83fa311020631de079cc8bf5835953289d611a
[server] Don't overwrite friendships in create-relationships.js
[ { "change_type": "MODIFY", "old_path": "server/src/scripts/create-relationships.js", "new_path": "server/src/scripts/create-relationships.js", "diff": "@@ -45,7 +45,7 @@ async function createKnowOfRelationships() {\n})),\n])(result);\n- await updateUndirectedRelationships(changeset, false);\n+ await updateUndirectedRelationships(changeset);\n}\nmain();\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[server] Don't overwrite friendships in create-relationships.js
129,187
24.07.2020 16:53:35
14,400
e1666218af64b15495531a07208d1b6dd5c7bb94
[server] Fix userStore state check deletion of extraneous user
[ { "change_type": "MODIFY", "old_path": "server/src/fetchers/user-fetchers.js", "new_path": "server/src/fetchers/user-fetchers.js", "diff": "@@ -9,7 +9,7 @@ import type { Viewer } from '../session/viewer';\nimport { ServerError } from 'lib/utils/errors';\n-import { dbQuery, SQL } from '../database';\n+import { dbQuery, SQL, SQLStatement } from '../database';\nasync function fetchUserInfos(userIDs: string[]): Promise<UserInfos> {\nif (userIDs.length <= 0) {\n@@ -41,15 +41,17 @@ async function fetchUserInfos(userIDs: string[]): Promise<UserInfos> {\nreturn userInfos;\n}\n-async function fetchKnownUserInfos(viewer: Viewer) {\n+async function fetchKnownUserInfos(viewer: Viewer, condition?: SQLStatement) {\nif (!viewer.loggedIn) {\nthrow new ServerError('not_logged_in');\n}\n+\n+ const whereClause = condition ? SQL`AND `.append(condition) : '';\nconst query = SQL`\nSELECT DISTINCT u.id, u.username FROM relationships_undirected r\nLEFT JOIN users u ON r.user1 = u.id OR r.user2 = u.id\nWHERE (r.user1 = ${viewer.userID} OR r.user2 = ${viewer.userID})\n- `;\n+ `.append(whereClause);\nconst [result] = await dbQuery(query);\nconst userInfos = {};\n" }, { "change_type": "MODIFY", "old_path": "server/src/responders/ping-responders.js", "new_path": "server/src/responders/ping-responders.js", "diff": "@@ -631,7 +631,13 @@ async function checkState(\nif (fetchAllUserInfos) {\nfetchPromises.userInfos = fetchKnownUserInfos(viewer);\n} else if (userIDsToFetch.length > 0) {\n- fetchPromises.userInfos = fetchUserInfos(userIDsToFetch);\n+ fetchPromises.userInfos = fetchKnownUserInfos(\n+ viewer,\n+ SQL`\n+ ((r.user1 = ${viewer.userID} AND r.user2 IN (${userIDsToFetch})) OR\n+ (r.user1 IN (${userIDsToFetch}) AND r.user2 = ${viewer.userID}))\n+ `,\n+ );\n}\nif (fetchUserInfo) {\nfetchPromises.currentUserInfo = fetchCurrentUserInfo(viewer);\n@@ -754,10 +760,10 @@ async function checkState(\nif (userInfo) {\nuserInfos.push(userInfo);\n} else {\n- userIDsToFetch.push(userID);\n+ oldUserIDsToFetch.push(userID);\n}\n}\n- if (userIDsToFetch.length > 0) {\n+ if (oldUserIDsToFetch.length > 0) {\nconst fetchedUserInfos = await fetchUserInfos(oldUserIDsToFetch);\nfor (let userID in fetchedUserInfos) {\nconst userInfo = fetchedUserInfos[userID];\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[server] Fix userStore state check deletion of extraneous user
129,187
24.07.2020 17:17:35
14,400
be378bd287af6e0ccff00ea9e84c62fd36cbb2c4
[native] codeVersion -> 60
[ { "change_type": "MODIFY", "old_path": "native/android/app/build.gradle", "new_path": "native/android/app/build.gradle", "diff": "@@ -133,8 +133,8 @@ android {\napplicationId \"org.squadcal\"\nminSdkVersion rootProject.ext.minSdkVersion\ntargetSdkVersion rootProject.ext.targetSdkVersion\n- versionCode 59\n- versionName \"0.0.59\"\n+ versionCode 60\n+ versionName \"0.0.60\"\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.59</string>\n+ <string>0.0.60</string>\n<key>CFBundleSignature</key>\n<string>????</string>\n<key>CFBundleVersion</key>\n- <string>59</string>\n+ <string>60</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.59</string>\n+ <string>0.0.60</string>\n<key>CFBundleSignature</key>\n<string>????</string>\n<key>CFBundleVersion</key>\n- <string>59</string>\n+ <string>60</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": "@@ -175,7 +175,7 @@ const persistConfig = {\ntimeout: __DEV__ ? 0 : undefined,\n};\n-const codeVersion = 59;\n+const codeVersion = 60;\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 -> 60
129,187
24.07.2020 18:25:05
14,400
c69654252860c7cfffae2023fcd45b9cb6f33fed
[server] Waste less space on Phabricator backups
[ { "change_type": "MODIFY", "old_path": "server/bash/backup_phabricator.sh", "new_path": "server/bash/backup_phabricator.sh", "diff": "@@ -12,13 +12,25 @@ BACKUP_PATH=/mnt/backup\n# The user that will be owning the backup files\nBACKUP_USER=squadcal\n+# The maximum amount of space to spend on Phabricator backups\n+MAX_DISK_USAGE_KB=51200 # 50 MiB\n+\nset -e\n-[[ `whoami` = root ]] || exec sudo su -c \"$0 $1\"\n+[[ `whoami` = root ]] || exec sudo su -c \"$0\"\ncd \"$PHABRICATOR_PATH\"\nOUTPUT_FILE=\"$BACKUP_PATH/phabricator.$(date +'%Y-%m-%d-%R').sql.gz\"\n+function remove_oldest_backup {\n+ OLDEST_BACKUP=$(find \"$BACKUP_PATH\" -maxdepth 1 -name 'phabricator.*.sql.gz' -type f -printf '%T+ %p\\0' | sort -z | head -z -n 1 | cut -d ' ' -f2- | cut -d '' -f1)\n+ if [[ ! \"$OLDEST_BACKUP\" ]]; then\n+ return 1\n+ fi\n+ rm -f \"$OLDEST_BACKUP\"\n+ return 0\n+}\n+\nRETRIES=2\nwhile [[ $RETRIES -ge 0 ]]; do\nif ./bin/storage dump --compress --overwrite --output \"$OUTPUT_FILE\" > /dev/null 2>&1; then\n@@ -26,10 +38,20 @@ while [[ $RETRIES -ge 0 ]]; do\nfi\nrm -f \"$OUTPUT_FILE\"\n- # Delete most recent backup file\n- rm -f $(find \"$BACKUP_PATH\" -maxdepth 1 -name 'phabricator.*.sql.gz' -type f -printf '%T+ %p\\0' | sort -z | head -z -n 1 | cut -d ' ' -f2- | cut -d '' -f1)\n-\n+ remove_oldest_backup || break\n((RETRIES--))\ndone\n-chown \"$BACKUP_USER:$BACKUP_USER\" \"$OUTPUT_FILE\" || true\n+chown $BACKUP_USER:$(id -gn $BACKUP_USER) \"$OUTPUT_FILE\" || true\n+\n+while true; do\n+ TOTAL_USAGE=$(sudo du -cs \"$BACKUP_PATH\"/phabricator.*.sql.gz | grep total | awk '{ print $1 }')\n+ if [[ $TOTAL_USAGE -le $MAX_DISK_USAGE_KB ]]; then\n+ break\n+ fi\n+ BACKUP_COUNT=$(ls -hla \"$BACKUP_PATH\"/phabricator.*.sql.gz | wc -l)\n+ if [[ $BACKUP_COUNT -lt 2 ]]; then\n+ break\n+ fi\n+ remove_oldest_backup || break\n+done\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[server] Waste less space on Phabricator backups
129,187
24.07.2020 19:05:21
14,400
63c61c23f668a860c5844baa050b0a43797c83db
[web] Style changes for code Markdown
[ { "change_type": "MODIFY", "old_path": "web/markdown/markdown.css", "new_path": "web/markdown/markdown.css", "diff": "@@ -27,14 +27,23 @@ div.lightBackground blockquote {\n}\ndiv.markdown code {\n- width: 100%;\n- display: inline-block;\n- padding: .5em 10px;\n- box-sizing: border-box;\n+ padding: 0 4px;\n+ margin: 0 2px;\n+ border-radius: 3px;\n}\ndiv.lightBackground code {\nbackground: #DCDCDC;\n+ color: #222222;\n}\ndiv.darkBackground code {\n- background: #808080;\n+ background: #222222;\n+ color: #F3F3F3;\n+}\n+div.markdown pre > code {\n+ width: 100%;\n+ display: inline-block;\n+ padding: .5em 10px;\n+ margin: 0;\n+ box-sizing: border-box;\n+ border-radius: 5px;\n}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[web] Style changes for code Markdown
129,187
25.07.2020 23:07:27
14,400
d19ad476d6095c35a67ff13e4f8e24eb019e531d
[native] Add react-native-safe-area-view package Need it because
[ { "change_type": "MODIFY", "old_path": "native/package.json", "new_path": "native/package.json", "diff": "\"react-native-progress\": \"^4.0.3\",\n\"react-native-reanimated\": \"^1.9.0\",\n\"react-native-safe-area-context\": \"^3.1.1\",\n+ \"react-native-safe-area-view\": \"^2.0.0\",\n\"react-native-screens\": \"^2.9.0\",\n\"react-native-tab-view\": \"^2.14.4\",\n\"react-native-unimodules\": \"^0.9.0\",\n" }, { "change_type": "MODIFY", "old_path": "yarn.lock", "new_path": "yarn.lock", "diff": "@@ -12184,6 +12184,13 @@ react-native-safe-area-context@^3.1.1:\nresolved \"https://registry.yarnpkg.com/react-native-safe-area-context/-/react-native-safe-area-context-3.1.1.tgz#9b04d1154766e6c1132030aca8f4b0336f561ccd\"\nintegrity sha512-Iqb41OT5+QxFn0tpTbbHgz8+3VU/F9OH2fTeeoU7oZCzojOXQbC6sp6mN7BlsAoTKhngWoJLMcSosL58uRaLWQ==\n+react-native-safe-area-view@^2.0.0:\n+ version \"2.0.0\"\n+ resolved \"https://registry.yarnpkg.com/react-native-safe-area-view/-/react-native-safe-area-view-2.0.0.tgz#98fc9bb1bf3cb8c97ba684efb7dd897765afff3b\"\n+ integrity sha512-tGlGZwRoZpTQ0gEdSSRgbkeyyKC50ZsEv2H/LQKjXhc00IHffbU0BA5chSzTqNwDrs5MFXfTG1ooRQK+0FVTjw==\n+ dependencies:\n+ hoist-non-react-statics \"^2.3.1\"\n+\nreact-native-safe-modules@^1.0.0:\nversion \"1.0.0\"\nresolved \"https://registry.yarnpkg.com/react-native-safe-modules/-/react-native-safe-modules-1.0.0.tgz#10a918adf97da920adb1e33e0c852b1e80123b65\"\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Add react-native-safe-area-view package Need it because https://github.com/th3rdwave/react-native-safe-area-context/issues/114#issuecomment-663928390
129,187
25.07.2020 23:11:37
14,400
8c4ab14082590635e23180bdc24358df1d65c3cd
[native] Truly center Calendar after mount if it's off-screen
[ { "change_type": "MODIFY", "old_path": "native/calendar/calendar.react.js", "new_path": "native/calendar/calendar.react.js", "diff": "@@ -59,7 +59,7 @@ import _sum from 'lodash/fp/sum';\nimport _pickBy from 'lodash/fp/pickBy';\nimport _size from 'lodash/fp/size';\nimport _throttle from 'lodash/throttle';\n-import { SafeAreaView } from 'react-native-safe-area-context';\n+import SafeAreaView from 'react-native-safe-area-view';\nimport { entryKey } from 'lib/shared/entry-utils';\nimport { dateString, prettyDate, dateFromString } from 'lib/utils/date-utils';\n@@ -69,6 +69,7 @@ import {\n} from 'lib/actions/entry-actions';\nimport { connect } from 'lib/utils/redux-utils';\nimport { createLoadingStatusSelector } from 'lib/selectors/loading-selectors';\n+import sleep from 'lib/utils/sleep';\nimport { Entry, InternalEntry, entryStyles } from './entry.react';\nimport { calendarListData } from '../selectors/calendar-selectors';\n@@ -124,7 +125,10 @@ type ExtraData = $ReadOnly<{|\nvisibleEntries: { [key: string]: boolean },\n|}>;\n-const safeAreaEdges = ['top'];\n+const safeAreaViewForceInset = {\n+ top: 'always',\n+ bottom: 'never',\n+};\ntype Props = {\nnavigation: TabNavigationProp<'Calendar'>,\n@@ -337,7 +341,16 @@ class Calendar extends React.PureComponent<Props, State> {\nconst lastLDWH = prevState.listDataWithHeights;\nconst newLDWH = this.state.listDataWithHeights;\n- if (!lastLDWH || !newLDWH) {\n+ if (!newLDWH) {\n+ return;\n+ } else if (!lastLDWH) {\n+ if (!this.props.calendarActive) {\n+ // FlatList has an initialScrollIndex prop, which is usually close to\n+ // centering but can be off when there is a particularly large Entry in\n+ // the list. scrollToToday lets us actually center, but gets overriden\n+ // by initialScrollIndex if we call it after the FlatList mounts\n+ sleep(50).then(() => this.scrollToToday());\n+ }\nreturn;\n}\n@@ -369,7 +382,7 @@ class Calendar extends React.PureComponent<Props, State> {\n// current calendar query gets reset due to inactivity, let's reset the\n// scroll position to the center (today)\nif (!this.props.calendarActive) {\n- setTimeout(() => this.scrollToToday(), 50);\n+ sleep(50).then(() => this.scrollToToday());\n}\nthis.firstScrollUpOnAndroidComplete = false;\n} else if (newStartDate < lastStartDate) {\n@@ -762,7 +775,10 @@ class Calendar extends React.PureComponent<Props, State> {\nnodesToMeasure={this.state.nodesToMeasure}\nallHeightsMeasuredCallback={this.allHeightsMeasured}\n/>\n- <SafeAreaView style={this.props.styles.container} edges={safeAreaEdges}>\n+ <SafeAreaView\n+ style={this.props.styles.container}\n+ forceInset={safeAreaViewForceInset}\n+ >\n<DisconnectedBar visible={this.props.calendarActive} />\n{loadingIndicator}\n{flatList}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Truly center Calendar after mount if it's off-screen
129,187
26.07.2020 00:26:49
14,400
9d6b00d9166420fbd3295d4d4a3f53940fa67766
[native] Define dummyNodeForEntryHeightMeasurement in Entry Instead of defining node inline in `Calendar` based on `entryStyles` exported from `Entry`
[ { "change_type": "MODIFY", "old_path": "native/calendar/calendar.react.js", "new_path": "native/calendar/calendar.react.js", "diff": "@@ -71,7 +71,11 @@ import { connect } from 'lib/utils/redux-utils';\nimport { createLoadingStatusSelector } from 'lib/selectors/loading-selectors';\nimport sleep from 'lib/utils/sleep';\n-import { Entry, InternalEntry, entryStyles } from './entry.react';\n+import {\n+ Entry,\n+ InternalEntry,\n+ dummyNodeForEntryHeightMeasurement,\n+} from './entry.react';\nimport { calendarListData } from '../selectors/calendar-selectors';\nimport {\ncreateIsForegroundSelector,\n@@ -253,20 +257,13 @@ class Calendar extends React.PureComponent<Props, State> {\nstatic nodesToMeasureFromListData(listData: $ReadOnlyArray<CalendarItem>) {\nconst nodesToMeasure = [];\nfor (let item of listData) {\n- if (item.itemType !== 'entryInfo') {\n- continue;\n- }\n- const text = item.entryInfo.text === '' ? ' ' : item.entryInfo.text;\n- const node = (\n- <View style={[entryStyles.entry, entryStyles.textContainer]}>\n- <Text style={entryStyles.text}>{text}</Text>\n- </View>\n- );\n+ if (item.itemType === 'entryInfo') {\nnodesToMeasure.push({\nid: entryKey(item.entryInfo),\n- node,\n+ node: dummyNodeForEntryHeightMeasurement(item.entryInfo.text),\n});\n}\n+ }\nreturn nodesToMeasure;\n}\n" }, { "change_type": "MODIFY", "old_path": "native/calendar/entry.react.js", "new_path": "native/calendar/entry.react.js", "diff": "@@ -85,6 +85,15 @@ function hueDistance(firstColor: string, secondColor: string): number {\n}\nconst omitEntryInfo = _omit(['entryInfo']);\n+function dummyNodeForEntryHeightMeasurement(entryText: string) {\n+ const text = entryText === '' ? ' ' : entryText;\n+ return (\n+ <View style={[styles.entry, styles.textContainer]}>\n+ <Text style={styles.text}>{text}</Text>\n+ </View>\n+ );\n+}\n+\ntype Props = {|\nnavigation: TabNavigationProp<'Calendar'>,\nentryInfo: EntryInfoWithHeight,\n@@ -771,4 +780,4 @@ const Entry = connectNav((context: ?NavContextType) => ({\n)(InternalEntry),\n);\n-export { InternalEntry, Entry, styles as entryStyles };\n+export { InternalEntry, Entry, dummyNodeForEntryHeightMeasurement };\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Define dummyNodeForEntryHeightMeasurement in Entry Instead of defining node inline in `Calendar` based on `entryStyles` exported from `Entry`
129,187
26.07.2020 00:54:12
14,400
2739065ff9445795a6e1df0f4a5e90db3c5fcdd0
[native] Define dummyNodeForRobotextMessageHeightMeasurement in RobotextMessage Now that we have `NodeTextMeasurer` instead of `TextHeightMeasurer`, we don't need to hardcode 17 in `robotextMessageItemHeight`. Instead we can measure the height of the container `View` directly.
[ { "change_type": "MODIFY", "old_path": "native/chat/message-list-container.react.js", "new_path": "native/chat/message-list-container.react.js", "diff": "@@ -14,7 +14,7 @@ import type { NavigationRoute } from '../navigation/route-names';\nimport * as React from 'react';\nimport PropTypes from 'prop-types';\n-import { View, Text } from 'react-native';\n+import { View } from 'react-native';\nimport invariant from 'invariant';\nimport hoistNonReactStatics from 'hoist-non-react-statics';\n@@ -25,11 +25,7 @@ import {\nchatMessageItemPropType,\nmessageListData,\n} from 'lib/selectors/chat-selectors';\n-import {\n- messageKey,\n- messageID,\n- robotextToRawString,\n-} from 'lib/shared/message-utils';\n+import { messageKey, messageID } from 'lib/shared/message-utils';\nimport MessageList from './message-list.react';\nimport NodeHeightMeasurer from '../components/node-height-measurer.react';\n@@ -49,6 +45,7 @@ import {\n} from '../themes/colors';\nimport ContentLoading from '../components/content-loading.react';\nimport { dummyNodeForTextMessageHeightMeasurement } from './inner-text-message.react';\n+import { dummyNodeForRobotextMessageHeightMeasurement } from './robotext-message.react';\nexport type ChatMessageItemWithHeight =\n| {| itemType: 'loader' |}\n@@ -110,14 +107,9 @@ class MessageListContainer extends React.PureComponent<Props, State> {\nnode: dummyNodeForTextMessageHeightMeasurement(messageInfo.text),\n});\n} else if (item.robotext && typeof item.robotext === 'string') {\n- const node = (\n- <Text style={this.props.styles.robotext}>\n- {robotextToRawString(item.robotext)}\n- </Text>\n- );\nnodesToMeasure.push({\nid: messageKey(messageInfo),\n- node,\n+ node: dummyNodeForRobotextMessageHeightMeasurement(item.robotext),\n});\n}\n}\n@@ -301,12 +293,6 @@ const styles = {\nbackgroundColor: 'listBackground',\nflex: 1,\n},\n- robotext: {\n- fontFamily: 'Arial',\n- fontSize: 15,\n- left: 24,\n- right: 24,\n- },\n};\nconst stylesSelector = styleSelector(styles);\n" }, { "change_type": "MODIFY", "old_path": "native/chat/robotext-message.react.js", "new_path": "native/chat/robotext-message.react.js", "diff": "@@ -23,6 +23,7 @@ import {\nmessageKey,\nsplitRobotext,\nparseRobotextEntity,\n+ robotextToRawString,\n} from 'lib/shared/message-utils';\nimport { threadInfoSelector } from 'lib/selectors/thread-selectors';\nimport { connect } from 'lib/utils/redux-utils';\n@@ -48,7 +49,15 @@ export type ChatRobotextMessageInfoItemWithHeight = {|\nfunction robotextMessageItemHeight(\nitem: ChatRobotextMessageInfoItemWithHeight,\n) {\n- return 17 + item.contentHeight; // for padding, margin, and text\n+ return item.contentHeight;\n+}\n+\n+function dummyNodeForRobotextMessageHeightMeasurement(robotext: string) {\n+ return (\n+ <View style={styles.robotextContainer}>\n+ <Text style={styles.dummyRobotext}>{robotextToRawString(robotext)}</Text>\n+ </View>\n+ );\n}\ntype Props = {|\n@@ -144,19 +153,18 @@ class RobotextMessage extends React.PureComponent<Props> {\ntextParts.push(rawText);\n}\n}\n- const textStyle = [this.props.styles.robotext];\n- let onLayoutOuterText;\n+\n+ const viewStyle = [this.props.styles.robotextContainer];\n+ let onLayout;\nif (__DEV__) {\n- ({ onLayoutOuterText } = this);\n+ ({ onLayout } = this);\n} else {\n- textStyle.push({ height: item.contentHeight });\n+ viewStyle.push({ height: item.contentHeight });\n}\nreturn (\n- <View style={this.props.styles.robotextContainer}>\n- <Text onLayout={onLayoutOuterText} style={textStyle}>\n- {textParts}\n- </Text>\n+ <View onLayout={onLayout} style={viewStyle}>\n+ <Text style={this.props.styles.robotext}>{textParts}</Text>\n</View>\n);\n}\n@@ -170,7 +178,7 @@ class RobotextMessage extends React.PureComponent<Props> {\n}\n};\n- onLayoutOuterText = (event: LayoutEvent) => {\n+ onLayout = (event: LayoutEvent) => {\nconst approxMeasuredHeight =\nMath.round(event.nativeEvent.layout.height * 1000) / 1000;\nconst approxExpectedHeight =\n@@ -256,7 +264,16 @@ const styles = {\nfontSize: 15,\ntextAlign: 'center',\n},\n+ dummyRobotext: {\n+ fontFamily: 'Arial',\n+ fontSize: 15,\n+ textAlign: 'center',\n+ },\n};\nconst stylesSelector = styleSelector(styles);\n-export { WrappedRobotextMessage as RobotextMessage, robotextMessageItemHeight };\n+export {\n+ robotextMessageItemHeight,\n+ dummyNodeForRobotextMessageHeightMeasurement,\n+ WrappedRobotextMessage as RobotextMessage,\n+};\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Define dummyNodeForRobotextMessageHeightMeasurement in RobotextMessage Now that we have `NodeTextMeasurer` instead of `TextHeightMeasurer`, we don't need to hardcode 17 in `robotextMessageItemHeight`. Instead we can measure the height of the container `View` directly.
129,187
26.07.2020 13:23:42
14,400
91a0f5ee3e9e5b73a13ad1f7ac45bc776be3581d
[native] Measure and compare full Message height
[ { "change_type": "MODIFY", "old_path": "native/chat/composed-message.react.js", "new_path": "native/chat/composed-message.react.js", "diff": "@@ -20,6 +20,7 @@ import { type Colors, colorsPropType, colorsSelector } from '../themes/colors';\nconst clusterEndHeight = 7;\ntype Props = {|\n+ ...React.ElementConfig<typeof View>,\nitem: ChatMessageInfoItemWithHeight,\nsendFailed: boolean,\nfocused: boolean,\n@@ -27,7 +28,6 @@ type Props = {|\n// Redux state\ncomposedMessageMaxWidth: number,\ncolors: Colors,\n- ...React.ElementProps<typeof View>,\n|};\nclass ComposedMessage extends React.PureComponent<Props> {\nstatic propTypes = {\n" }, { "change_type": "MODIFY", "old_path": "native/chat/inner-text-message.react.js", "new_path": "native/chat/inner-text-message.react.js", "diff": "@@ -4,15 +4,13 @@ import { chatMessageItemPropType } from 'lib/selectors/chat-selectors';\nimport type { ChatTextMessageInfoItemWithHeight } from './text-message.react';\nimport { type GlobalTheme, globalThemePropType } from '../types/themes';\nimport type { AppState } from '../redux/redux-setup';\n-import type { LayoutEvent } from '../types/react-native';\nimport * as React from 'react';\n-import { View, Text, StyleSheet, TouchableOpacity } from 'react-native';\n+import { View, StyleSheet, TouchableOpacity } from 'react-native';\nimport PropTypes from 'prop-types';\nimport { colorIsDark } from 'lib/shared/thread-utils';\nimport { connect } from 'lib/utils/redux-utils';\n-import { messageKey } from 'lib/shared/message-utils';\nimport {\nallCorners,\n@@ -30,7 +28,7 @@ import { fullMarkdownRules } from '../markdown/rules.react';\nfunction dummyNodeForTextMessageHeightMeasurement(text: string) {\nreturn (\n- <Text style={styles.dummyMessage}>\n+ <View style={styles.dummyMessage}>\n<Markdown\nstyle={styles.text}\nuseDarkStyle={false}\n@@ -38,7 +36,7 @@ function dummyNodeForTextMessageHeightMeasurement(text: string) {\n>\n{text}\n</Markdown>\n- </Text>\n+ </View>\n);\n}\n@@ -83,9 +81,12 @@ class InnerTextMessage extends React.PureComponent<Props> {\nfilterCorners(allCorners, item),\n);\n- const outerTextProps = __DEV__\n- ? { onLayout: this.onLayoutOuterText }\n- : { style: { height: item.contentHeight } };\n+ if (!__DEV__) {\n+ // We don't force view height in dev mode because we\n+ // want to measure it in Message to see if it's correct\n+ messageStyle.height = item.contentHeight;\n+ }\n+\nconst message = (\n<TouchableOpacity\nonPress={this.props.onPress}\n@@ -93,7 +94,6 @@ class InnerTextMessage extends React.PureComponent<Props> {\nactiveOpacity={0.6}\nstyle={[styles.message, messageStyle, cornerStyle]}\n>\n- <Text {...outerTextProps}>\n<Markdown\nstyle={textStyle}\nuseDarkStyle={darkColor}\n@@ -101,7 +101,6 @@ class InnerTextMessage extends React.PureComponent<Props> {\n>\n{text}\n</Markdown>\n- </Text>\n</TouchableOpacity>\n);\n@@ -119,28 +118,12 @@ class InnerTextMessage extends React.PureComponent<Props> {\n// We need to set onLayout in order to allow .measure() to be on the ref\nonLayout = () => {};\n-\n- onLayoutOuterText = (event: LayoutEvent) => {\n- const approxMeasuredHeight =\n- Math.round(event.nativeEvent.layout.height * 1000) / 1000;\n- const approxExpectedHeight =\n- Math.round(this.props.item.contentHeight * 1000) / 1000;\n- if (approxMeasuredHeight !== approxExpectedHeight) {\n- console.log(\n- `TextMessage height for ${messageKey(this.props.item.messageInfo)} ` +\n- `was expected to be ${approxExpectedHeight} but is actually ` +\n- `${approxMeasuredHeight}. This means MessageList's FlatList isn't ` +\n- 'getting the right item height for some of its nodes, which is ' +\n- 'guaranteed to cause glitchy behavior. Please investigate!!',\n- );\n- }\n- };\n}\nconst styles = StyleSheet.create({\ndummyMessage: {\n- marginHorizontal: 12,\n- marginVertical: 6,\n+ paddingHorizontal: 12,\n+ paddingVertical: 6,\n},\nmessage: {\noverflow: 'hidden',\n" }, { "change_type": "MODIFY", "old_path": "native/chat/message.react.js", "new_path": "native/chat/message.react.js", "diff": "@@ -19,11 +19,14 @@ import {\n} from '../keyboard/keyboard-state';\nimport type { ChatNavigationProp } from './chat.react';\nimport type { NavigationRoute } from '../navigation/route-names';\n+import type { LayoutEvent } from '../types/react-native';\nimport * as React from 'react';\nimport { LayoutAnimation, TouchableWithoutFeedback } from 'react-native';\nimport PropTypes from 'prop-types';\n+import { messageKey } from 'lib/shared/message-utils';\n+\nimport { TextMessage, textMessageItemHeight } from './text-message.react';\nimport {\nRobotextMessage,\n@@ -119,13 +122,36 @@ class Message extends React.PureComponent<Props> {\n/>\n);\n}\n+\n+ const onLayout = __DEV__ ? this.onLayout : undefined;\nreturn (\n- <TouchableWithoutFeedback onPress={this.dismissKeyboard}>\n+ <TouchableWithoutFeedback\n+ onPress={this.dismissKeyboard}\n+ onLayout={onLayout}\n+ >\n{message}\n</TouchableWithoutFeedback>\n);\n}\n+ onLayout = (event: LayoutEvent) => {\n+ const expectedHeight = messageItemHeight(this.props.item);\n+\n+ const approxMeasuredHeight =\n+ Math.round(event.nativeEvent.layout.height * 1000) / 1000;\n+ const approxExpectedHeight = Math.round(expectedHeight * 1000) / 1000;\n+ if (approxMeasuredHeight !== approxExpectedHeight) {\n+ console.log(\n+ `Message height for ${this.props.item.messageShapeType} ` +\n+ `${messageKey(this.props.item.messageInfo)} was expected to be ` +\n+ `${approxExpectedHeight} but is actually ${approxMeasuredHeight}. ` +\n+ \"This means MessageList's FlatList isn't getting the right item \" +\n+ 'height for some of its nodes, which is guaranteed to cause ' +\n+ 'glitchy behavior. Please investigate!!',\n+ );\n+ }\n+ };\n+\ndismissKeyboard = () => {\nconst { keyboardState } = this.props;\nkeyboardState && keyboardState.dismissKeyboard();\n" }, { "change_type": "MODIFY", "old_path": "native/chat/multimedia-message.react.js", "new_path": "native/chat/multimedia-message.react.js", "diff": "@@ -117,7 +117,7 @@ function multimediaMessageItemHeight(item: ChatMultimediaMessageInfoItem) {\nconst { messageInfo, contentHeight, startsCluster, endsCluster } = item;\nconst { creator } = messageInfo;\nconst { isViewer } = creator;\n- let height = 5 + contentHeight; // for margin and images\n+ let height = 5 + contentHeight; // 5 from marginBottom in ComposedMessage\nif (!isViewer && startsCluster) {\nheight += authorNameHeight;\n}\n@@ -133,13 +133,13 @@ function multimediaMessageItemHeight(item: ChatMultimediaMessageInfoItem) {\nconst borderRadius = 16;\ntype Props = {|\n+ ...React.ElementConfig<typeof View>,\nitem: ChatMultimediaMessageInfoItem,\nnavigation: ChatNavigationProp<'MessageList'>,\nroute: NavigationRoute<'MessageList'>,\nfocused: boolean,\ntoggleFocus: (messageKey: string) => void,\nverticalBounds: ?VerticalBounds,\n- ...React.ElementProps<typeof View>,\n|};\nclass MultimediaMessage extends React.PureComponent<Props> {\nstatic propTypes = {\n" }, { "change_type": "MODIFY", "old_path": "native/chat/robotext-message.react.js", "new_path": "native/chat/robotext-message.react.js", "diff": "@@ -12,7 +12,6 @@ import {\nimport { messageListNavPropType } from './message-list-types';\nimport type { ChatNavigationProp } from './chat.react';\nimport { type GlobalTheme, globalThemePropType } from '../types/themes';\n-import type { LayoutEvent } from '../types/react-native';\nimport * as React from 'react';\nimport { Text, TouchableWithoutFeedback, View } from 'react-native';\n@@ -61,6 +60,7 @@ function dummyNodeForRobotextMessageHeightMeasurement(robotext: string) {\n}\ntype Props = {|\n+ ...React.ElementConfig<typeof View>,\nitem: ChatRobotextMessageInfoItemWithHeight,\nnavigation: ChatNavigationProp<'MessageList'>,\nfocused: boolean,\n@@ -70,7 +70,6 @@ type Props = {|\n// Redux state\nstyles: typeof styles,\nactiveTheme: ?GlobalTheme,\n- ...React.ElementProps<typeof View>,\n|};\nclass RobotextMessage extends React.PureComponent<Props> {\nstatic propTypes = {\n@@ -155,15 +154,14 @@ class RobotextMessage extends React.PureComponent<Props> {\n}\nconst viewStyle = [this.props.styles.robotextContainer];\n- let onLayout;\n- if (__DEV__) {\n- ({ onLayout } = this);\n- } else {\n+ if (!__DEV__) {\n+ // We don't force view height in dev mode because we\n+ // want to measure it in Message to see if it's correct\nviewStyle.push({ height: item.contentHeight });\n}\nreturn (\n- <View onLayout={onLayout} style={viewStyle}>\n+ <View style={viewStyle}>\n<Text style={this.props.styles.robotext}>{textParts}</Text>\n</View>\n);\n@@ -177,23 +175,6 @@ class RobotextMessage extends React.PureComponent<Props> {\nthis.props.toggleFocus(messageKey(this.props.item.messageInfo));\n}\n};\n-\n- onLayout = (event: LayoutEvent) => {\n- const approxMeasuredHeight =\n- Math.round(event.nativeEvent.layout.height * 1000) / 1000;\n- const approxExpectedHeight =\n- Math.round(this.props.item.contentHeight * 1000) / 1000;\n- if (approxMeasuredHeight !== approxExpectedHeight) {\n- console.log(\n- `RobotextMessage height for ` +\n- `${messageKey(this.props.item.messageInfo)} was expected to be ` +\n- `${approxExpectedHeight} but is actually ${approxMeasuredHeight}. ` +\n- \"This means MessageList's FlatList isn't getting the right item \" +\n- 'height for some of its nodes, which is guaranteed to cause ' +\n- 'glitchy behavior. Please investigate!!',\n- );\n- }\n- };\n}\nconst WrappedRobotextMessage = connect((state: AppState) => ({\n@@ -254,9 +235,9 @@ const styles = {\ncolor: 'link',\n},\nrobotextContainer: {\n- marginBottom: 5,\n- marginHorizontal: 24,\n- paddingVertical: 6,\n+ paddingTop: 6,\n+ paddingBottom: 11,\n+ paddingHorizontal: 24,\n},\nrobotext: {\ncolor: 'listForegroundSecondaryLabel',\n" }, { "change_type": "MODIFY", "old_path": "native/chat/text-message.react.js", "new_path": "native/chat/text-message.react.js", "diff": "@@ -57,7 +57,7 @@ export type ChatTextMessageInfoItemWithHeight = {|\nfunction textMessageItemHeight(item: ChatTextMessageInfoItemWithHeight) {\nconst { messageInfo, contentHeight, startsCluster, endsCluster } = item;\nconst { isViewer } = messageInfo.creator;\n- let height = 17 + contentHeight; // for padding, margin, and text\n+ let height = 5 + contentHeight; // 5 from marginBottom in ComposedMessage\nif (!isViewer && startsCluster) {\nheight += authorNameHeight;\n}\n@@ -71,6 +71,7 @@ function textMessageItemHeight(item: ChatTextMessageInfoItemWithHeight) {\n}\ntype Props = {|\n+ ...React.ElementConfig<typeof View>,\nitem: ChatTextMessageInfoItemWithHeight,\nnavigation: ChatNavigationProp<'MessageList'>,\nroute: NavigationRoute<'MessageList'>,\n@@ -81,7 +82,6 @@ type Props = {|\nkeyboardState: ?KeyboardState,\n// withOverlayContext\noverlayContext: ?OverlayContextType,\n- ...React.ElementProps<typeof View>,\n|};\nclass TextMessage extends React.PureComponent<Props> {\nstatic propTypes = {\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Measure and compare full Message height
129,187
26.07.2020 13:47:19
14,400
e867552be57a5f5798eef70b9ca950c31d1a3e3c
[native] Reduce false complaints about Message height
[ { "change_type": "MODIFY", "old_path": "native/chat/message.react.js", "new_path": "native/chat/message.react.js", "diff": "@@ -22,7 +22,11 @@ import type { NavigationRoute } from '../navigation/route-names';\nimport type { LayoutEvent } from '../types/react-native';\nimport * as React from 'react';\n-import { LayoutAnimation, TouchableWithoutFeedback } from 'react-native';\n+import {\n+ LayoutAnimation,\n+ TouchableWithoutFeedback,\n+ PixelRatio,\n+} from 'react-native';\nimport PropTypes from 'prop-types';\nimport { messageKey } from 'lib/shared/message-utils';\n@@ -135,21 +139,29 @@ class Message extends React.PureComponent<Props> {\n}\nonLayout = (event: LayoutEvent) => {\n+ if (this.props.focused) {\n+ return;\n+ }\n+\n+ const measuredHeight = event.nativeEvent.layout.height;\nconst expectedHeight = messageItemHeight(this.props.item);\n- const approxMeasuredHeight =\n- Math.round(event.nativeEvent.layout.height * 1000) / 1000;\n- const approxExpectedHeight = Math.round(expectedHeight * 1000) / 1000;\n- if (approxMeasuredHeight !== approxExpectedHeight) {\n+ const pixelRatio = 1 / PixelRatio.get();\n+ const distance = Math.abs(measuredHeight - expectedHeight);\n+ if (distance < pixelRatio) {\n+ return;\n+ }\n+\n+ const approxMeasuredHeight = Math.round(measuredHeight * 100) / 100;\n+ const approxExpectedHeight = Math.round(expectedHeight * 100) / 100;\nconsole.log(\n`Message height for ${this.props.item.messageShapeType} ` +\n`${messageKey(this.props.item.messageInfo)} was expected to be ` +\n`${approxExpectedHeight} but is actually ${approxMeasuredHeight}. ` +\n\"This means MessageList's FlatList isn't getting the right item \" +\n- 'height for some of its nodes, which is guaranteed to cause ' +\n- 'glitchy behavior. Please investigate!!',\n+ 'height for some of its nodes, which is guaranteed to cause glitchy ' +\n+ 'behavior. Please investigate!!',\n);\n- }\n};\ndismissKeyboard = () => {\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Reduce false complaints about Message height
129,187
26.07.2020 13:47:49
14,400
65ee8aeb79b6c35a65d25a53fdf7f426a8a1458d
[native] Fix TextMessage height measurement to consider composedMessageMaxWidth
[ { "change_type": "MODIFY", "old_path": "native/chat/inner-text-message.react.js", "new_path": "native/chat/inner-text-message.react.js", "diff": "@@ -8,6 +8,7 @@ import type { AppState } from '../redux/redux-setup';\nimport * as React from 'react';\nimport { View, StyleSheet, TouchableOpacity } from 'react-native';\nimport PropTypes from 'prop-types';\n+import { useSelector } from 'react-redux';\nimport { colorIsDark } from 'lib/shared/thread-utils';\nimport { connect } from 'lib/utils/redux-utils';\n@@ -25,16 +26,28 @@ import {\n} from '../themes/colors';\nimport Markdown from '../markdown/markdown.react';\nimport { fullMarkdownRules } from '../markdown/rules.react';\n+import { composedMessageMaxWidthSelector } from './composed-message-width';\nfunction dummyNodeForTextMessageHeightMeasurement(text: string) {\n+ return <DummyTextNode>{text}</DummyTextNode>;\n+}\n+\n+type DummyTextNodeProps = {|\n+ ...React.ElementConfig<typeof View>,\n+ children: string,\n+|};\n+function DummyTextNode(props: DummyTextNodeProps) {\n+ const { children, style, ...rest } = props;\n+ const maxWidth = useSelector(state => composedMessageMaxWidthSelector(state));\n+ const viewStyle = [props.style, styles.dummyMessage, { maxWidth }];\nreturn (\n- <View style={styles.dummyMessage}>\n+ <View {...rest} style={viewStyle}>\n<Markdown\nstyle={styles.text}\nuseDarkStyle={false}\nrules={fullMarkdownRules}\n>\n- {text}\n+ {children}\n</Markdown>\n</View>\n);\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Fix TextMessage height measurement to consider composedMessageMaxWidth
129,187
27.07.2020 10:12:30
14,400
6ad3f02345342608767362c3abb66fdc5937310b
Add container prop to native Markdown
[ { "change_type": "MODIFY", "old_path": "lib/shared/markdown.js", "new_path": "lib/shared/markdown.js", "diff": "// @flow\n-const urlRegex = /^(https?:\\/\\/[^\\s<]+[^<.,:;\"')\\]\\s])/i;\nconst paragraphRegex = /^((?:[^\\n]*)(?:\\n|$))/;\n+const paragraphStripTrailingNewlineRegex = /^([^\\n]*)(?:\\n|$)/;\n+\n+const urlRegex = /^(https?:\\/\\/[^\\s<]+[^<.,:;\"')\\]\\s])/i;\nconst blockQuoteRegex = /^( *>[^\\n]+(?:\\n[^\\n]+)*)/;\nconst headingRegex = /^ *(#{1,6}) ([^\\n]+?)#* *(?![^\\n])/;\nconst codeBlockRegex = /^(?: {4}[^\\n]*\\n*?)+(?!\\n* {4}[^\\n])(?:\\n|$)/;\nconst fenceRegex = /^(`{3,}|~{3,})[^\\n]*\\n([\\s\\S]*\\n)\\1(?:\\n|$)/;\nexport {\n- urlRegex,\nparagraphRegex,\n+ paragraphStripTrailingNewlineRegex,\n+ urlRegex,\nblockQuoteRegex,\nheadingRegex,\ncodeBlockRegex,\n" }, { "change_type": "MODIFY", "old_path": "native/calendar/entry.react.js", "new_path": "native/calendar/entry.react.js", "diff": "@@ -428,6 +428,7 @@ class InternalEntry extends React.Component<Props, State> {\nstyle={textStyle}\nuseDarkStyle={darkColor}\nrules={inlineMarkdownRules}\n+ container=\"Text\"\n>\n{rawText}\n</Markdown>\n" }, { "change_type": "MODIFY", "old_path": "native/chat/inner-text-message.react.js", "new_path": "native/chat/inner-text-message.react.js", "diff": "@@ -46,6 +46,7 @@ function DummyTextNode(props: DummyTextNodeProps) {\nstyle={styles.text}\nuseDarkStyle={false}\nrules={fullMarkdownRules}\n+ container=\"View\"\n>\n{children}\n</Markdown>\n@@ -111,6 +112,7 @@ class InnerTextMessage extends React.PureComponent<Props> {\nstyle={textStyle}\nuseDarkStyle={darkColor}\nrules={fullMarkdownRules}\n+ container=\"View\"\n>\n{text}\n</Markdown>\n" }, { "change_type": "MODIFY", "old_path": "native/chat/robotext-message.react.js", "new_path": "native/chat/robotext-message.react.js", "diff": "@@ -128,6 +128,7 @@ class RobotextMessage extends React.PureComponent<Props> {\nkey={key}\nuseDarkStyle={darkColor}\nrules={inlineMarkdownRules}\n+ container=\"Text\"\n>\n{decodeURI(splitPart)}\n</Markdown>,\n" }, { "change_type": "MODIFY", "old_path": "native/markdown/markdown.react.js", "new_path": "native/markdown/markdown.react.js", "diff": "@@ -6,7 +6,7 @@ import type { MarkdownRules } from './rules.react';\nimport * as React from 'react';\nimport * as SimpleMarkdown from 'simple-markdown';\n-import { Text, StyleSheet } from 'react-native';\n+import { View, Text, StyleSheet } from 'react-native';\nimport invariant from 'invariant';\nimport { onlyEmojiRegex } from 'lib/shared/emojis';\n@@ -18,9 +18,15 @@ type Props = {|\nuseDarkStyle: boolean,\nchildren: string,\nrules: MarkdownRules,\n+ // We need to use a Text container for Entry because it needs to match up\n+ // exactly with TextInput. However, if we use a Text container, we can't\n+ // support styles for things like blockQuote, which rely on rendering as a\n+ // View, and Views can't be nested inside Texts without explicit height and\n+ // width\n+ container: 'View' | 'Text',\n|};\nfunction Markdown(props: Props) {\n- const { style, useDarkStyle, children, rules } = props;\n+ const { style, useDarkStyle, children, rules, container } = props;\nconst markdownStyles = React.useMemo(() => {\nreturn getMarkdownStyles(useDarkStyle ? 'dark' : 'light');\n@@ -35,15 +41,14 @@ function Markdown(props: Props) {\n[simpleMarkdownRules],\n);\nconst ast = React.useMemo(\n- () => parser(children, { disableAutoBlockNewlines: true }),\n- [parser, children],\n+ () => parser(children, { disableAutoBlockNewlines: true, container }),\n+ [parser, children, container],\n);\nconst output = React.useMemo(\n() => SimpleMarkdown.outputFor(simpleMarkdownRules, 'react'),\n[simpleMarkdownRules],\n);\n- const renderedOutput = React.useMemo(() => output(ast), [ast, output]);\nconst emojiOnly = React.useMemo(() => {\nif (emojiOnlyFactor === null || emojiOnlyFactor === undefined) {\n@@ -72,7 +77,16 @@ function Markdown(props: Props) {\nreturn { ...flattened, fontSize: fontSize * emojiOnlyFactor };\n}, [emojiOnly, style, emojiOnlyFactor]);\n- return <Text style={textStyle}>{renderedOutput}</Text>;\n+ const renderedOutput = React.useMemo(\n+ () => output(ast, { textStyle, container }),\n+ [ast, output, textStyle, container],\n+ );\n+\n+ if (container === 'Text') {\n+ return <Text>{renderedOutput}</Text>;\n+ } else {\n+ return <View>{renderedOutput}</View>;\n+ }\n}\nexport default Markdown;\n" }, { "change_type": "MODIFY", "old_path": "native/markdown/rules.react.js", "new_path": "native/markdown/rules.react.js", "diff": "@@ -7,7 +7,7 @@ import * as React from 'react';\nimport { Text, Linking, Alert } from 'react-native';\nimport * as SimpleMarkdown from 'simple-markdown';\n-import { urlRegex, paragraphRegex } from 'lib/shared/markdown';\n+import * as MarkdownRegex from 'lib/shared/markdown';\nimport { normalizeURL } from 'lib/utils/url-utils';\ntype MarkdownRuleSpec = {|\n@@ -50,7 +50,7 @@ function inlineMarkdownRules(\nurl: {\n...SimpleMarkdown.defaultRules.url,\n// simple-markdown is case-sensitive, but we don't want to be\n- match: SimpleMarkdown.inlineRegex(urlRegex),\n+ match: SimpleMarkdown.inlineRegex(MarkdownRegex.urlRegex),\n},\n// Matches '[Google](https://google.com)' during parse phase and handles\n// rendering all 'link' nodes, including for 'autolink' and 'url'\n@@ -74,18 +74,44 @@ function inlineMarkdownRules(\n// parser will be an array of one or more 'paragraph' nodes\nparagraph: {\n...SimpleMarkdown.defaultRules.paragraph,\n- // simple-markdown collapses multiple newlines into one, but we want to\n- // preserve the newlines\n- match: SimpleMarkdown.blockRegex(paragraphRegex),\n+ // simple-markdown's default RegEx collapses multiple newlines into one.\n+ // We want to keep the newlines, but when rendering within a View, we\n+ // strip just one trailing newline off, since the View adds vertical\n+ // spacing between its children\n+ match: (source: string, state: SimpleMarkdown.State) => {\n+ if (state.inline) {\n+ return null;\n+ } else if (state.container === 'View') {\n+ return MarkdownRegex.paragraphStripTrailingNewlineRegex.exec(source);\n+ } else {\n+ return MarkdownRegex.paragraphRegex.exec(source);\n+ }\n+ },\n+ parse(\n+ capture: SimpleMarkdown.Capture,\n+ parse: SimpleMarkdown.Parser,\n+ state: SimpleMarkdown.State,\n+ ) {\n+ let content = capture[1];\n+ if (state.container === 'View') {\n+ // React Native renders empty lines with less height. We want to\n+ // preserve the newline characters, so we replace empty lines with a\n+ // single space\n+ content = content.replace(/^$/m, ' ');\n+ }\n+ return {\n+ content: SimpleMarkdown.parseInline(parse, content, state),\n+ };\n+ },\n// eslint-disable-next-line react/display-name\nreact: (\nnode: SimpleMarkdown.SingleASTNode,\noutput: SimpleMarkdown.Output<SimpleMarkdown.ReactElement>,\nstate: SimpleMarkdown.State,\n) => (\n- <React.Fragment key={state.key}>\n+ <Text key={state.key} style={state.textStyle}>\n{output(node.content, state)}\n- </React.Fragment>\n+ </Text>\n),\n},\n// This is the leaf node in the AST returned by the parse phase\n" }, { "change_type": "MODIFY", "old_path": "web/markdown/markdown.css", "new_path": "web/markdown/markdown.css", "diff": "@@ -46,4 +46,5 @@ div.markdown pre > code {\nmargin: 0;\nbox-sizing: border-box;\nborder-radius: 5px;\n+ tab-size: 2;\n}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Add container prop to native Markdown
129,187
27.07.2020 10:22:50
14,400
6f8644b0836e5b2d74ed451e8e0f5532fbd01837
[native] Move Markdown container prop to MarkdownRuleSpec
[ { "change_type": "MODIFY", "old_path": "native/calendar/entry.react.js", "new_path": "native/calendar/entry.react.js", "diff": "@@ -428,7 +428,6 @@ class InternalEntry extends React.Component<Props, State> {\nstyle={textStyle}\nuseDarkStyle={darkColor}\nrules={inlineMarkdownRules}\n- container=\"Text\"\n>\n{rawText}\n</Markdown>\n" }, { "change_type": "MODIFY", "old_path": "native/chat/inner-text-message.react.js", "new_path": "native/chat/inner-text-message.react.js", "diff": "@@ -46,7 +46,6 @@ function DummyTextNode(props: DummyTextNodeProps) {\nstyle={styles.text}\nuseDarkStyle={false}\nrules={fullMarkdownRules}\n- container=\"View\"\n>\n{children}\n</Markdown>\n@@ -112,7 +111,6 @@ class InnerTextMessage extends React.PureComponent<Props> {\nstyle={textStyle}\nuseDarkStyle={darkColor}\nrules={fullMarkdownRules}\n- container=\"View\"\n>\n{text}\n</Markdown>\n" }, { "change_type": "MODIFY", "old_path": "native/chat/robotext-message.react.js", "new_path": "native/chat/robotext-message.react.js", "diff": "@@ -128,7 +128,6 @@ class RobotextMessage extends React.PureComponent<Props> {\nkey={key}\nuseDarkStyle={darkColor}\nrules={inlineMarkdownRules}\n- container=\"Text\"\n>\n{decodeURI(splitPart)}\n</Markdown>,\n" }, { "change_type": "MODIFY", "old_path": "native/markdown/markdown.react.js", "new_path": "native/markdown/markdown.react.js", "diff": "@@ -18,23 +18,18 @@ type Props = {|\nuseDarkStyle: boolean,\nchildren: string,\nrules: MarkdownRules,\n- // We need to use a Text container for Entry because it needs to match up\n- // exactly with TextInput. However, if we use a Text container, we can't\n- // support styles for things like blockQuote, which rely on rendering as a\n- // View, and Views can't be nested inside Texts without explicit height and\n- // width\n- container: 'View' | 'Text',\n|};\nfunction Markdown(props: Props) {\n- const { style, useDarkStyle, children, rules, container } = props;\n+ const { style, useDarkStyle, children, rules } = props;\nconst markdownStyles = React.useMemo(() => {\nreturn getMarkdownStyles(useDarkStyle ? 'dark' : 'light');\n}, [useDarkStyle]);\n- const { simpleMarkdownRules, emojiOnlyFactor } = React.useMemo(\n- () => rules(markdownStyles),\n- [rules, markdownStyles],\n- );\n+ const {\n+ simpleMarkdownRules,\n+ emojiOnlyFactor,\n+ container,\n+ } = React.useMemo(() => rules(markdownStyles), [rules, markdownStyles]);\nconst parser = React.useMemo(\n() => SimpleMarkdown.parserFor(simpleMarkdownRules),\n" }, { "change_type": "MODIFY", "old_path": "native/markdown/rules.react.js", "new_path": "native/markdown/rules.react.js", "diff": "@@ -13,6 +13,12 @@ import { normalizeURL } from 'lib/utils/url-utils';\ntype MarkdownRuleSpec = {|\n+simpleMarkdownRules: SimpleMarkdown.ParserRules,\n+emojiOnlyFactor: ?number,\n+ // We need to use a Text container for Entry because it needs to match up\n+ // exactly with TextInput. However, if we use a Text container, we can't\n+ // support styles for things like blockQuote, which rely on rendering as a\n+ // View, and Views can't be nested inside Texts without explicit height and\n+ // width\n+ +container: 'View' | 'Text',\n|};\nexport type MarkdownRules = (\nstyles: StyleSheetOf<MarkdownStyles>,\n@@ -120,6 +126,7 @@ function inlineMarkdownRules(\nreturn {\nsimpleMarkdownRules,\nemojiOnlyFactor: null,\n+ container: 'Text',\n};\n}\n@@ -145,6 +152,7 @@ function fullMarkdownRules(\n...inlineRules,\nsimpleMarkdownRules,\nemojiOnlyFactor: 2,\n+ container: 'View',\n};\n}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Move Markdown container prop to MarkdownRuleSpec
129,187
28.07.2020 17:05:54
14,400
df5e626ccf98c7a3fd10fc8766a29a6f8e50532c
unreadHomeCount -> unreadCount Get rid of the old `unreadCount`
[ { "change_type": "MODIFY", "old_path": "lib/selectors/thread-selectors.js", "new_path": "lib/selectors/thread-selectors.js", "diff": "@@ -19,7 +19,6 @@ import _map from 'lodash/fp/map';\nimport _compact from 'lodash/fp/compact';\nimport _filter from 'lodash/fp/filter';\nimport _sortBy from 'lodash/fp/sortBy';\n-import _size from 'lodash/fp/size';\nimport _memoize from 'lodash/memoize';\nimport _find from 'lodash/fp/find';\nconst _mapValuesWithKeys = _mapValues.convert({ cap: false });\n@@ -28,7 +27,6 @@ import { dateString, dateFromString } from '../utils/date-utils';\nimport { values } from '../utils/objects';\nimport { createEntryInfo } from '../shared/entry-utils';\nimport {\n- threadInChatList,\nthreadInHomeChatList,\nthreadInBackgroundChatList,\nthreadInFilterList,\n@@ -167,16 +165,6 @@ const childThreadInfos: (\n);\nconst unreadCount: (state: BaseAppState<*>) => number = createSelector(\n- (state: BaseAppState<*>) => state.threadStore.threadInfos,\n- (threadInfos: { [id: string]: RawThreadInfo }): number =>\n- _flow(\n- _filter(threadInChatList),\n- _filter(threadInfo => threadInfo.currentUser.unread),\n- _size,\n- )(threadInfos),\n-);\n-\n-const unreadHomeCount: (state: BaseAppState<*>) => number = createSelector(\n(state: BaseAppState<*>) => state.threadStore.threadInfos,\n(threadInfos: { [id: string]: RawThreadInfo }): number =>\nvalues(threadInfos).filter(\n@@ -271,7 +259,6 @@ export {\ncurrentDaysToEntries,\nchildThreadInfos,\nunreadCount,\n- unreadHomeCount,\nunreadBackgroundCount,\notherUsersButNoOtherAdmins,\nmostRecentReadThread,\n" }, { "change_type": "MODIFY", "old_path": "native/chat/chat-icon.react.js", "new_path": "native/chat/chat-icon.react.js", "diff": "@@ -8,7 +8,7 @@ import Icon from 'react-native-vector-icons/FontAwesome';\nimport PropTypes from 'prop-types';\nimport { connect } from 'lib/utils/redux-utils';\n-import { unreadHomeCount } from 'lib/selectors/thread-selectors';\n+import { unreadCount } from 'lib/selectors/thread-selectors';\ntype Props = {\ncolor: string,\n@@ -63,5 +63,5 @@ const styles = StyleSheet.create({\n});\nexport default connect((state: AppState) => ({\n- unreadCount: unreadHomeCount(state),\n+ unreadCount: unreadCount(state),\n}))(ChatIcon);\n" }, { "change_type": "MODIFY", "old_path": "native/push/push-handler.react.js", "new_path": "native/push/push-handler.react.js", "diff": "@@ -36,7 +36,7 @@ import {\nimport { connect } from 'lib/utils/redux-utils';\nimport {\n- unreadHomeCount,\n+ unreadCount,\nthreadInfoSelector,\n} from 'lib/selectors/thread-selectors';\nimport {\n@@ -615,7 +615,7 @@ export default connectNav((context: ?NavContextType) => ({\n}))(\nconnect(\n(state: AppState) => ({\n- unreadCount: unreadHomeCount(state),\n+ unreadCount: unreadCount(state),\ndeviceToken: state.deviceToken,\nthreadInfos: threadInfoSelector(state),\nnotifPermissionAlertInfo: state.notifPermissionAlertInfo,\n" }, { "change_type": "MODIFY", "old_path": "web/app.react.js", "new_path": "web/app.react.js", "diff": "@@ -32,7 +32,7 @@ import { connect } from 'lib/utils/redux-utils';\nimport { registerConfig } from 'lib/utils/config';\nimport {\nmostRecentReadThreadSelector,\n- unreadHomeCount,\n+ unreadCount,\n} from 'lib/selectors/thread-selectors';\nimport {\nbackgroundActionType,\n@@ -359,7 +359,7 @@ export default connect(\n!activeChatThreadID ||\nstate.threadStore.threadInfos[activeChatThreadID].currentUser.unread,\nviewerID: state.currentUserInfo && state.currentUserInfo.id,\n- unreadCount: unreadHomeCount(state),\n+ unreadCount: unreadCount(state),\n};\n},\nnull,\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
unreadHomeCount -> unreadCount Get rid of the old `unreadCount`
129,187
28.07.2020 17:18:48
14,400
cbacdcea94610411c6a88c6ae789e048f104314e
[lib] Extract getLastUpdatedTime
[ { "change_type": "MODIFY", "old_path": "lib/selectors/chat-selectors.js", "new_path": "lib/selectors/chat-selectors.js", "diff": "@@ -33,10 +33,10 @@ import { threadInfoSelector } from './thread-selectors';\nimport { threadInChatList } from '../shared/thread-utils';\nexport type ChatThreadItem = {|\n- type: 'chatThreadItem',\n- threadInfo: ThreadInfo,\n- mostRecentMessageInfo?: MessageInfo,\n- lastUpdatedTime: number,\n+ +type: 'chatThreadItem',\n+ +threadInfo: ThreadInfo,\n+ +mostRecentMessageInfo?: MessageInfo,\n+ +lastUpdatedTime: number,\n|};\nconst chatThreadItemPropType = PropTypes.shape({\ntype: PropTypes.oneOf(['chatThreadItem']),\n@@ -55,38 +55,39 @@ const messageInfoSelector: (\ncreateMessageInfo,\n);\n-function createChatThreadItem(\n+function getLastUpdatedTime(\nthreadInfo: ThreadInfo,\nmessageStore: MessageStore,\nmessages: { [id: string]: MessageInfo },\n-): ChatThreadItem {\n+): number {\nconst thread = messageStore.threads[threadInfo.id];\n- if (!thread || thread.messageIDs.length === 0) {\n- return {\n- type: 'chatThreadItem',\n- threadInfo,\n- lastUpdatedTime: threadInfo.creationTime,\n- };\n+ if (!thread) {\n+ return threadInfo.creationTime;\n}\n- let mostRecentMessageInfo = undefined;\n+\n+ let mostRecentMessageInfo;\nfor (let messageID of thread.messageIDs) {\nmostRecentMessageInfo = messages[messageID];\nif (mostRecentMessageInfo) {\nbreak;\n}\n}\n- if (!mostRecentMessageInfo) {\n- return {\n- type: 'chatThreadItem',\n- threadInfo,\n- lastUpdatedTime: threadInfo.creationTime,\n- };\n+ if (mostRecentMessageInfo) {\n+ return mostRecentMessageInfo.time;\n}\n+\n+ return threadInfo.creationTime;\n+}\n+\n+function createChatThreadItem(\n+ threadInfo: ThreadInfo,\n+ messageStore: MessageStore,\n+ messages: { [id: string]: MessageInfo },\n+): ChatThreadItem {\nreturn {\ntype: 'chatThreadItem',\nthreadInfo,\n- mostRecentMessageInfo,\n- lastUpdatedTime: mostRecentMessageInfo.time,\n+ lastUpdatedTime: getLastUpdatedTime(threadInfo, messageStore, messages),\n};\n}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[lib] Extract getLastUpdatedTime
129,187
28.07.2020 17:36:45
14,400
6717bf6532dbc521c8e1404e8751b0875079ac20
Include sidebar info in ChatThreadItem
[ { "change_type": "MODIFY", "old_path": "lib/selectors/chat-selectors.js", "new_path": "lib/selectors/chat-selectors.js", "diff": "// @flow\nimport type { BaseAppState } from '../types/redux-types';\n-import { type ThreadInfo, threadInfoPropType } from '../types/thread-types';\n+import {\n+ type ThreadInfo,\n+ threadInfoPropType,\n+ threadTypes,\n+} from '../types/thread-types';\nimport {\ntype MessageInfo,\ntype MessageStore,\n@@ -29,20 +33,32 @@ import {\nrobotextForMessageInfo,\ncreateMessageInfo,\n} from '../shared/message-utils';\n-import { threadInfoSelector } from './thread-selectors';\n+import { threadInfoSelector, childThreadInfos } from './thread-selectors';\nimport { threadInChatList } from '../shared/thread-utils';\nexport type ChatThreadItem = {|\n+type: 'chatThreadItem',\n+threadInfo: ThreadInfo,\n- +mostRecentMessageInfo?: MessageInfo,\n+ +mostRecentMessageInfo: ?MessageInfo,\n+ +lastUpdatedTime: number,\n+ +lastUpdatedTimeIncludingSidebars: number,\n+ +sidebars: $ReadOnlyArray<{|\n+ +threadInfo: ThreadInfo,\n+lastUpdatedTime: number,\n+ |}>,\n|};\n-const chatThreadItemPropType = PropTypes.shape({\n+const chatThreadItemPropType = PropTypes.exact({\ntype: PropTypes.oneOf(['chatThreadItem']),\nthreadInfo: threadInfoPropType.isRequired,\nmostRecentMessageInfo: messageInfoPropType,\nlastUpdatedTime: PropTypes.number.isRequired,\n+ lastUpdatedTimeIncludingSidebars: PropTypes.number.isRequired,\n+ sidebars: PropTypes.arrayOf(\n+ PropTypes.exact({\n+ threadInfo: threadInfoPropType.isRequired,\n+ lastUpdatedTime: PropTypes.number.isRequired,\n+ }),\n+ ).isRequired,\n});\nconst messageInfoSelector: (\n@@ -55,39 +71,71 @@ const messageInfoSelector: (\ncreateMessageInfo,\n);\n-function getLastUpdatedTime(\n+function getMostRecentMessageInfo(\nthreadInfo: ThreadInfo,\nmessageStore: MessageStore,\nmessages: { [id: string]: MessageInfo },\n-): number {\n+): ?MessageInfo {\nconst thread = messageStore.threads[threadInfo.id];\nif (!thread) {\n- return threadInfo.creationTime;\n+ return null;\n}\n-\n- let mostRecentMessageInfo;\nfor (let messageID of thread.messageIDs) {\n- mostRecentMessageInfo = messages[messageID];\n- if (mostRecentMessageInfo) {\n- break;\n- }\n+ return messages[messageID];\n}\n- if (mostRecentMessageInfo) {\n- return mostRecentMessageInfo.time;\n+ return null;\n}\n- return threadInfo.creationTime;\n+function getLastUpdatedTime(\n+ threadInfo: ThreadInfo,\n+ mostRecentMessageInfo: ?MessageInfo,\n+): number {\n+ return mostRecentMessageInfo\n+ ? mostRecentMessageInfo.time\n+ : threadInfo.creationTime;\n}\nfunction createChatThreadItem(\nthreadInfo: ThreadInfo,\nmessageStore: MessageStore,\nmessages: { [id: string]: MessageInfo },\n+ childThreads: ?(ThreadInfo[]),\n): ChatThreadItem {\n+ const mostRecentMessageInfo = getMostRecentMessageInfo(\n+ threadInfo,\n+ messageStore,\n+ messages,\n+ );\n+ const lastUpdatedTime = getLastUpdatedTime(threadInfo, mostRecentMessageInfo);\n+\n+ const sidebars = [];\n+ let lastUpdatedTimeIncludingSidebars = lastUpdatedTime;\n+ if (childThreads) {\n+ for (const childThreadInfo of childThreads) {\n+ if (childThreadInfo.type !== threadTypes.SIDEBAR) {\n+ continue;\n+ }\n+ const sidebarLastUpdatedTime = getLastUpdatedTime(\n+ childThreadInfo,\n+ getMostRecentMessageInfo(childThreadInfo, messageStore, messages),\n+ );\n+ if (sidebarLastUpdatedTime > lastUpdatedTimeIncludingSidebars) {\n+ lastUpdatedTimeIncludingSidebars = sidebarLastUpdatedTime;\n+ }\n+ sidebars.push({\n+ threadInfo: childThreadInfo,\n+ lastUpdatedTime: sidebarLastUpdatedTime,\n+ });\n+ }\n+ }\n+\nreturn {\ntype: 'chatThreadItem',\nthreadInfo,\n- lastUpdatedTime: getLastUpdatedTime(threadInfo, messageStore, messages),\n+ mostRecentMessageInfo,\n+ lastUpdatedTime,\n+ lastUpdatedTimeIncludingSidebars,\n+ sidebars,\n};\n}\n@@ -97,15 +145,22 @@ const chatListData: (\nthreadInfoSelector,\n(state: BaseAppState<*>) => state.messageStore,\nmessageInfoSelector,\n+ childThreadInfos,\n(\nthreadInfos: { [id: string]: ThreadInfo },\nmessageStore: MessageStore,\nmessageInfos: { [id: string]: MessageInfo },\n+ childThreads: { [id: string]: ThreadInfo[] },\n): ChatThreadItem[] =>\n_flow(\n_filter(threadInChatList),\n_map((threadInfo: ThreadInfo): ChatThreadItem =>\n- createChatThreadItem(threadInfo, messageStore, messageInfos),\n+ createChatThreadItem(\n+ threadInfo,\n+ messageStore,\n+ messageInfos,\n+ childThreads[threadInfo.id],\n+ ),\n),\n_orderBy('lastUpdatedTime')('desc'),\n)(threadInfos),\n" }, { "change_type": "MODIFY", "old_path": "web/selectors/chat-selectors.js", "new_path": "web/selectors/chat-selectors.js", "diff": "@@ -36,7 +36,7 @@ const activeChatThreadItem: (\nif (!threadInfo) {\nreturn null;\n}\n- return createChatThreadItem(threadInfo, messageStore, messageInfos);\n+ return createChatThreadItem(threadInfo, messageStore, messageInfos, null);\n},\n);\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Include sidebar info in ChatThreadItem
129,187
28.07.2020 18:00:43
14,400
5a68506ff5419dc8cdc9ebd378c0a7880446fa4e
[native] List sidebars inline in thread view
[ { "change_type": "MODIFY", "old_path": "lib/selectors/chat-selectors.js", "new_path": "lib/selectors/chat-selectors.js", "diff": "@@ -166,6 +166,34 @@ const chatListData: (\n)(threadInfos),\n);\n+// Requires UI that supports displaying sidebars inline\n+const chatListDataWithNestedSidebars: (\n+ state: BaseAppState<*>,\n+) => ChatThreadItem[] = createSelector(\n+ threadInfoSelector,\n+ (state: BaseAppState<*>) => state.messageStore,\n+ messageInfoSelector,\n+ childThreadInfos,\n+ (\n+ threadInfos: { [id: string]: ThreadInfo },\n+ messageStore: MessageStore,\n+ messageInfos: { [id: string]: MessageInfo },\n+ childThreads: { [id: string]: ThreadInfo[] },\n+ ): ChatThreadItem[] =>\n+ _flow(\n+ _filter(threadInChatList),\n+ _map((threadInfo: ThreadInfo): ChatThreadItem =>\n+ createChatThreadItem(\n+ threadInfo,\n+ messageStore,\n+ messageInfos,\n+ childThreads[threadInfo.id],\n+ ),\n+ ),\n+ _orderBy('lastUpdatedTimeIncludingSidebars')('desc'),\n+ )(threadInfos),\n+);\n+\nexport type RobotextChatMessageInfoItem = {|\nitemType: 'message',\nmessageInfo: RobotextMessageInfo,\n@@ -313,6 +341,7 @@ export {\ncreateChatThreadItem,\nchatThreadItemPropType,\nchatListData,\n+ chatListDataWithNestedSidebars,\nchatMessageItemPropType,\ncreateChatMessageItems,\nmessageListData,\n" }, { "change_type": "MODIFY", "old_path": "native/chat/chat-thread-list-item.react.js", "new_path": "native/chat/chat-thread-list-item.react.js", "diff": "@@ -10,6 +10,7 @@ import type { AppState } from '../redux/redux-setup';\nimport * as React from 'react';\nimport { View, Text } from 'react-native';\nimport PropTypes from 'prop-types';\n+import Icon from 'react-native-vector-icons/Entypo';\nimport { shortAbsoluteDate } from 'lib/utils/date-utils';\nimport { connect } from 'lib/utils/redux-utils';\n@@ -57,12 +58,47 @@ class ChatThreadListItem extends React.PureComponent<Props> {\n}\nrender() {\n+ const { listIosHighlightUnderlay } = this.props.colors;\n+\n+ const sidebars = this.props.data.sidebars.map(sidebar => {\n+ const sidebarThreadInfo = sidebar.threadInfo;\n+ const lastActivity = shortAbsoluteDate(sidebar.lastUpdatedTime);\n+ const sidebarUnreadStyle = sidebarThreadInfo.currentUser.unread\n+ ? this.props.styles.unread\n+ : null;\n+ return (\n+ <Button\n+ iosFormat=\"highlight\"\n+ iosHighlightUnderlayColor={listIosHighlightUnderlay}\n+ iosActiveOpacity={0.85}\n+ style={this.props.styles.sidebar}\n+ key={sidebarThreadInfo.id}\n+ onPress={this.onPress}\n+ >\n+ <Icon\n+ name=\"align-right\"\n+ style={this.props.styles.sidebarIcon}\n+ size={24}\n+ />\n+ <Text\n+ style={[this.props.styles.sidebarName, sidebarUnreadStyle]}\n+ numberOfLines={1}\n+ >\n+ {sidebarThreadInfo.uiName}\n+ </Text>\n+ <Text style={[this.props.styles.sidebarLastActivity, unreadStyle]}>\n+ {lastActivity}\n+ </Text>\n+ </Button>\n+ );\n+ });\n+\nconst lastActivity = shortAbsoluteDate(this.props.data.lastUpdatedTime);\nconst unreadStyle = this.props.data.threadInfo.currentUser.unread\n? this.props.styles.unread\n: null;\n- const { listIosHighlightUnderlay } = this.props.colors;\nreturn (\n+ <>\n<Button\nonPress={this.onPress}\niosFormat=\"highlight\"\n@@ -92,6 +128,8 @@ class ChatThreadListItem extends React.PureComponent<Props> {\n</View>\n</View>\n</Button>\n+ {sidebars}\n+ </>\n);\n}\n@@ -138,6 +176,29 @@ const styles = {\ncolor: 'listForegroundLabel',\nfontWeight: 'bold',\n},\n+ sidebar: {\n+ height: 30,\n+ flexDirection: 'row',\n+ display: 'flex',\n+ marginHorizontal: 20,\n+ alignItems: 'center',\n+ },\n+ sidebarIcon: {\n+ paddingLeft: 10,\n+ color: 'listForegroundSecondaryLabel',\n+ },\n+ sidebarName: {\n+ color: 'listForegroundSecondaryLabel',\n+ flex: 1,\n+ fontSize: 16,\n+ paddingLeft: 5,\n+ paddingBottom: 2,\n+ },\n+ sidebarLastActivity: {\n+ color: 'listForegroundTertiaryLabel',\n+ fontSize: 14,\n+ marginLeft: 10,\n+ },\n};\nconst stylesSelector = styleSelector(styles);\n" }, { "change_type": "MODIFY", "old_path": "native/chat/chat-thread-list.react.js", "new_path": "native/chat/chat-thread-list.react.js", "diff": "@@ -23,7 +23,7 @@ import { connect } from 'lib/utils/redux-utils';\nimport {\ntype ChatThreadItem,\nchatThreadItemPropType,\n- chatListData,\n+ chatListDataWithNestedSidebars,\n} from 'lib/selectors/chat-selectors';\nimport ChatThreadListItem from './chat-thread-list-item.react';\n@@ -182,13 +182,15 @@ class ChatThreadList extends React.PureComponent<Props, State> {\nif (item.type === 'search') {\nreturn Platform.OS === 'ios' ? 54.5 : 55;\n}\n+\n// itemHeight for emptyItem might be wrong because of line wrapping\n// but we don't care because we'll only ever be rendering this item by itself\n// and it should always be on-screen\nif (item.type === 'empty') {\nreturn 123;\n}\n- return 60;\n+\n+ return 60 + item.sidebars.length * 30;\n}\nstatic heightOfItems(data: $ReadOnlyArray<Item>): number {\n@@ -318,7 +320,7 @@ const styles = {\nconst stylesSelector = styleSelector(styles);\nexport default connect((state: AppState) => ({\n- chatListData: chatListData(state),\n+ chatListData: chatListDataWithNestedSidebars(state),\nviewerID: state.currentUserInfo && state.currentUserInfo.id,\nthreadSearchIndex: threadSearchIndex(state),\nstyles: stylesSelector(state),\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] List sidebars inline in thread view
129,187
28.07.2020 18:02:41
14,400
220c0831f33dfb0b45209a0e134654ea53f95e1f
[lib] Don't include sidebars in filter list
[ { "change_type": "MODIFY", "old_path": "lib/shared/thread-utils.js", "new_path": "lib/shared/thread-utils.js", "diff": "@@ -56,6 +56,7 @@ function threadIsInHome(threadInfo: ?(ThreadInfo | RawThreadInfo)): boolean {\nreturn !!(threadInfo && threadInfo.currentUser.subscription.home);\n}\n+// Can have messages\nfunction threadInChatList(threadInfo: ?(ThreadInfo | RawThreadInfo)): boolean {\nreturn (\nviewerIsMember(threadInfo) &&\n@@ -75,10 +76,16 @@ function threadInHomeChatList(\nreturn threadInChatList(threadInfo) && threadIsInHome(threadInfo);\n}\n+// Can have Calendar entries,\n+// does appear as a top-level entity in the thread list\nfunction threadInFilterList(\nthreadInfo: ?(ThreadInfo | RawThreadInfo),\n): boolean {\n- return threadInChatList(threadInfo);\n+ return (\n+ threadInChatList(threadInfo) &&\n+ !!threadInfo &&\n+ threadInfo.type !== threadTypes.SIDEBAR\n+ );\n}\nfunction userIsMember(\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[lib] Don't include sidebars in filter list
129,187
28.07.2020 18:01:52
14,400
6931603a48aec03a3357f941a4059b421f584f3f
[native] Don't include sidebars in list of existing threads in ComposeThread
[ { "change_type": "MODIFY", "old_path": "native/chat/compose-thread.react.js", "new_path": "native/chat/compose-thread.react.js", "diff": "@@ -42,7 +42,7 @@ import {\n} from 'lib/selectors/user-selectors';\nimport SearchIndex from 'lib/shared/search-index';\nimport {\n- threadInChatList,\n+ threadInFilterList,\nuserIsMember,\nthreadInfoFromRawThreadInfo,\n} from 'lib/shared/thread-utils';\n@@ -217,7 +217,7 @@ class ComposeThread extends React.PureComponent<Props, State> {\nreturn _flow(\n_filter(\n(threadInfo: ThreadInfo) =>\n- threadInChatList(threadInfo) &&\n+ threadInFilterList(threadInfo) &&\n(!parentThreadInfo ||\nthreadInfo.parentThreadID === parentThreadInfo.id) &&\nuserIDs.every(userID => userIsMember(threadInfo, userID)),\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Don't include sidebars in list of existing threads in ComposeThread
129,183
27.07.2020 14:10:13
-7,200
371b207756467847370e66090f43951882eb622e
[native] Add more rules Summary: [native] Fix some problems with new lines in native markdown and style components properly Reviewers: ashoat Subscribers: zrebcu411
[ { "change_type": "MODIFY", "old_path": "lib/shared/markdown.js", "new_path": "lib/shared/markdown.js", "diff": "const paragraphRegex = /^((?:[^\\n]*)(?:\\n|$))/;\nconst paragraphStripTrailingNewlineRegex = /^([^\\n]*)(?:\\n|$)/;\n-const urlRegex = /^(https?:\\/\\/[^\\s<]+[^<.,:;\"')\\]\\s])/i;\n-const blockQuoteRegex = /^( *>[^\\n]+(?:\\n[^\\n]+)*)/;\nconst headingRegex = /^ *(#{1,6}) ([^\\n]+?)#* *(?![^\\n])/;\n+const headingStripFollowingNewlineRegex = /^ *(#{1,6}) ([^\\n]+?)#* *(?:\\n|$)/;\n+\n+const fenceRegex = /^(`{3,}|~{3,})[^\\n]*\\n([\\s\\S]*?\\n)\\1(?:\\n|$)/;\n+const fenceStripTrailingNewlineRegex = /^(`{3,}|~{3,})[^\\n]*\\n([\\s\\S]*?)\\n\\1(?:\\n|$)/;\n+\nconst codeBlockRegex = /^(?: {4}[^\\n]*\\n*?)+(?!\\n* {4}[^\\n])(?:\\n|$)/;\n-const fenceRegex = /^(`{3,}|~{3,})[^\\n]*\\n([\\s\\S]*\\n)\\1(?:\\n|$)/;\n+const codeBlockStripTrailingNewlineRegex = /^((?: {4}[^\\n]*\\n*?)+)(?!\\n* {4}[^\\n])(?:\\n|$)/;\n+\n+const blockQuoteRegex = /^( *>[^\\n]+(?:\\n[^\\n]+)*)(?:\\n|$)/;\n+const blockQuoteStripFollowingNewlineRegex = /^( *>[^\\n]+(?:\\n[^\\n]+)*)(?:\\n|$){2}/;\n+\n+const urlRegex = /^(https?:\\/\\/[^\\s<]+[^<.,:;\"')\\]\\s])/i;\nexport {\nparagraphRegex,\nparagraphStripTrailingNewlineRegex,\nurlRegex,\nblockQuoteRegex,\n+ blockQuoteStripFollowingNewlineRegex,\nheadingRegex,\n+ headingStripFollowingNewlineRegex,\ncodeBlockRegex,\n+ codeBlockStripTrailingNewlineRegex,\nfenceRegex,\n+ fenceStripTrailingNewlineRegex,\n};\n" }, { "change_type": "MODIFY", "old_path": "native/markdown/rules.react.js", "new_path": "native/markdown/rules.react.js", "diff": "@@ -4,7 +4,7 @@ import type { StyleSheetOf } from '../themes/colors';\nimport type { MarkdownStyles } from './styles';\nimport * as React from 'react';\n-import { Text, Linking, Alert } from 'react-native';\n+import { Text, Linking, Alert, View } from 'react-native';\nimport * as SimpleMarkdown from 'simple-markdown';\nimport * as MarkdownRegex from 'lib/shared/markdown';\n@@ -147,6 +147,153 @@ function fullMarkdownRules(\n...inlineRules.simpleMarkdownRules.link,\nmatch: SimpleMarkdown.defaultRules.link.match,\n},\n+ mailto: SimpleMarkdown.defaultRules.mailto,\n+ em: {\n+ ...SimpleMarkdown.defaultRules.em,\n+ // eslint-disable-next-line react/display-name\n+ react: (\n+ node: SimpleMarkdown.SingleASTNode,\n+ output: SimpleMarkdown.Output<SimpleMarkdown.ReactElement>,\n+ state: SimpleMarkdown.State,\n+ ) => (\n+ <Text key={state.key} style={styles.italics}>\n+ {output(node.content, state)}\n+ </Text>\n+ ),\n+ },\n+ strong: {\n+ ...SimpleMarkdown.defaultRules.strong,\n+ // eslint-disable-next-line react/display-name\n+ react: (\n+ node: SimpleMarkdown.SingleASTNode,\n+ output: SimpleMarkdown.Output<SimpleMarkdown.ReactElement>,\n+ state: SimpleMarkdown.State,\n+ ) => (\n+ <Text key={state.key} style={styles.bold}>\n+ {output(node.content, state)}\n+ </Text>\n+ ),\n+ },\n+ u: {\n+ ...SimpleMarkdown.defaultRules.u,\n+ // eslint-disable-next-line react/display-name\n+ react: (\n+ node: SimpleMarkdown.SingleASTNode,\n+ output: SimpleMarkdown.Output<SimpleMarkdown.ReactElement>,\n+ state: SimpleMarkdown.State,\n+ ) => (\n+ <Text key={state.key} style={styles.underline}>\n+ {output(node.content, state)}\n+ </Text>\n+ ),\n+ },\n+ del: {\n+ ...SimpleMarkdown.defaultRules.del,\n+ // eslint-disable-next-line react/display-name\n+ react: (\n+ node: SimpleMarkdown.SingleASTNode,\n+ output: SimpleMarkdown.Output<SimpleMarkdown.ReactElement>,\n+ state: SimpleMarkdown.State,\n+ ) => (\n+ <Text key={state.key} style={styles.strikethrough}>\n+ {output(node.content, state)}\n+ </Text>\n+ ),\n+ },\n+ inlineCode: {\n+ ...SimpleMarkdown.defaultRules.inlineCode,\n+ // eslint-disable-next-line react/display-name\n+ react: (\n+ node: SimpleMarkdown.SingleASTNode,\n+ output: SimpleMarkdown.Output<SimpleMarkdown.ReactElement>,\n+ state: SimpleMarkdown.State,\n+ ) => (\n+ <Text key={state.key} style={styles.inlineCode}>\n+ {node.content}\n+ </Text>\n+ ),\n+ },\n+ heading: {\n+ ...SimpleMarkdown.defaultRules.heading,\n+ match: SimpleMarkdown.blockRegex(\n+ MarkdownRegex.headingStripFollowingNewlineRegex,\n+ ),\n+ // eslint-disable-next-line react/display-name\n+ react(\n+ node: SimpleMarkdown.SingleASTNode,\n+ output: SimpleMarkdown.Output<SimpleMarkdown.ReactElement>,\n+ state: SimpleMarkdown.State,\n+ ) {\n+ const headingStyle = styles['h' + node.level];\n+ return (\n+ <Text key={state.key} style={[state.textStyle, headingStyle]}>\n+ {output(node.content, state)}\n+ </Text>\n+ );\n+ },\n+ },\n+ blockQuote: {\n+ ...SimpleMarkdown.defaultRules.blockQuote,\n+ // match end of blockQuote by either \\n\\n or end of string\n+ match: SimpleMarkdown.blockRegex(\n+ MarkdownRegex.blockQuoteStripFollowingNewlineRegex,\n+ ),\n+ parse(\n+ capture: SimpleMarkdown.Capture,\n+ parse: SimpleMarkdown.Parser,\n+ state: SimpleMarkdown.State,\n+ ) {\n+ const content = capture[1].replace(/^ *> ?/gm, '');\n+ return {\n+ content: SimpleMarkdown.parseInline(parse, content, state),\n+ };\n+ },\n+ // eslint-disable-next-line react/display-name\n+ react: (\n+ node: SimpleMarkdown.SingleASTNode,\n+ output: SimpleMarkdown.Output<SimpleMarkdown.ReactElement>,\n+ state: SimpleMarkdown.State,\n+ ) => (\n+ <View key={state.key} style={styles.blockQuote}>\n+ <Text style={state.textStyle}>{output(node.content, state)}</Text>\n+ </View>\n+ ),\n+ },\n+ codeBlock: {\n+ ...SimpleMarkdown.defaultRules.codeBlock,\n+ match: SimpleMarkdown.blockRegex(\n+ MarkdownRegex.codeBlockStripTrailingNewlineRegex,\n+ ),\n+ parse(capture: SimpleMarkdown.Capture) {\n+ return {\n+ content: capture[1].replace(/^ {4}/gm, ''),\n+ };\n+ },\n+ // eslint-disable-next-line react/display-name\n+ react: (\n+ node: SimpleMarkdown.SingleASTNode,\n+ output: SimpleMarkdown.Output<SimpleMarkdown.ReactElement>,\n+ state: SimpleMarkdown.State,\n+ ) => (\n+ <View key={state.key} style={styles.codeBlock}>\n+ <Text style={[state.textStyle, styles.codeBlockText]}>\n+ {node.content}\n+ </Text>\n+ </View>\n+ ),\n+ },\n+ fence: {\n+ ...SimpleMarkdown.defaultRules.fence,\n+ match: SimpleMarkdown.blockRegex(\n+ MarkdownRegex.fenceStripTrailingNewlineRegex,\n+ ),\n+ parse(capture: SimpleMarkdown.Capture) {\n+ return {\n+ type: 'codeBlock',\n+ content: capture[2],\n+ };\n+ },\n+ },\n};\nreturn {\n...inlineRules,\n" }, { "change_type": "MODIFY", "old_path": "native/markdown/styles.js", "new_path": "native/markdown/styles.js", "diff": "import type { GlobalTheme } from '../types/themes';\n+import { Platform } from 'react-native';\n+\nimport { getStylesForTheme } from '../themes/colors';\nconst unboundStyles = {\n@@ -9,6 +11,76 @@ const unboundStyles = {\ncolor: 'link',\ntextDecorationLine: 'underline',\n},\n+ italics: {\n+ fontStyle: 'italic',\n+ },\n+ bold: {\n+ fontWeight: 'bold',\n+ },\n+ underline: {\n+ textDecorationLine: 'underline',\n+ },\n+ strikethrough: {\n+ textDecorationLine: 'line-through',\n+ textDecorationStyle: 'solid',\n+ },\n+ inlineCode: {\n+ backgroundColor: 'codeBackground',\n+ fontFamily: Platform.select({\n+ ios: 'Menlo',\n+ default: 'monospace',\n+ }),\n+ fontSize: Platform.select({\n+ ios: 17,\n+ default: 18,\n+ }),\n+ },\n+ h1: {\n+ fontSize: 32,\n+ fontWeight: 'bold',\n+ },\n+ h2: {\n+ fontSize: 24,\n+ fontWeight: 'bold',\n+ },\n+ h3: {\n+ fontSize: 18,\n+ fontWeight: 'bold',\n+ },\n+ h4: {\n+ fontSize: 16,\n+ fontWeight: 'bold',\n+ },\n+ h5: {\n+ fontSize: 13,\n+ fontWeight: 'bold',\n+ },\n+ h6: {\n+ fontSize: 11,\n+ fontWeight: 'bold',\n+ },\n+ blockQuote: {\n+ backgroundColor: 'blockQuoteBackground',\n+ borderLeftColor: 'blockQuoteBorder',\n+ borderLeftWidth: 5,\n+ padding: 10,\n+ marginBottom: 6,\n+ },\n+ codeBlock: {\n+ backgroundColor: 'codeBackground',\n+ padding: 10,\n+ borderRadius: 5,\n+ },\n+ codeBlockText: {\n+ fontFamily: Platform.select({\n+ ios: 'Menlo',\n+ default: 'monospace',\n+ }),\n+ fontSize: Platform.select({\n+ ios: 17,\n+ default: 18,\n+ }),\n+ },\n};\nexport type MarkdownStyles = typeof unboundStyles;\n" }, { "change_type": "MODIFY", "old_path": "native/themes/colors.js", "new_path": "native/themes/colors.js", "diff": "@@ -66,6 +66,9 @@ const light = Object.freeze({\nnavigationCard: '#FFFFFF',\nfloatingButtonBackground: '#999999',\nfloatingButtonLabel: '#EEEEEE',\n+ blockQuoteBackground: '#D3D3D3',\n+ blockQuoteBorder: '#C0C0C0',\n+ codeBackground: '#DCDCDC',\n});\nexport type Colors = $Exact<typeof light>;\n@@ -127,6 +130,9 @@ const dark: Colors = Object.freeze({\nnavigationCard: '#2A2A2A',\nfloatingButtonBackground: '#666666',\nfloatingButtonLabel: 'white',\n+ blockQuoteBackground: '#A9A9A9',\n+ blockQuoteBorder: '#808080',\n+ codeBackground: '#222222',\n});\nconst colors = { light, dark };\n" }, { "change_type": "MODIFY", "old_path": "web/markdown/markdown.css", "new_path": "web/markdown/markdown.css", "diff": "@@ -14,6 +14,7 @@ div.markdown h6 {\ndiv.markdown blockquote {\ndisplay: inline-block;\npadding: .5em 10px;\n+ margin-bottom: 6px;\nbox-sizing: border-box;\nwidth: 100%;\n}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Add more rules Summary: [native] Fix some problems with new lines in native markdown and style components properly Reviewers: ashoat Reviewed By: ashoat Subscribers: zrebcu411 Differential Revision: https://phabricator.ashoat.com/D8
129,187
29.07.2020 10:16:56
14,400
39aa544c0dfec29c10faf8d5a8687fa8ed71b8c3
Specify bottom margin for codeBlock/fence
[ { "change_type": "MODIFY", "old_path": "native/markdown/styles.js", "new_path": "native/markdown/styles.js", "diff": "@@ -70,6 +70,7 @@ const unboundStyles = {\nbackgroundColor: 'codeBackground',\npadding: 10,\nborderRadius: 5,\n+ marginBottom: 6,\n},\ncodeBlockText: {\nfontFamily: Platform.select({\n" }, { "change_type": "MODIFY", "old_path": "web/markdown/markdown.css", "new_path": "web/markdown/markdown.css", "diff": "@@ -14,7 +14,7 @@ div.markdown h6 {\ndiv.markdown blockquote {\ndisplay: inline-block;\npadding: .5em 10px;\n- margin-bottom: 6px;\n+ margin: 0 0 6px 0;\nbox-sizing: border-box;\nwidth: 100%;\n}\n@@ -44,8 +44,8 @@ div.markdown pre > code {\nwidth: 100%;\ndisplay: inline-block;\npadding: .5em 10px;\n- margin: 0;\nbox-sizing: border-box;\nborder-radius: 5px;\ntab-size: 2;\n+ margin: 0 0 6px 0;\n}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Specify bottom margin for codeBlock/fence
129,183
30.07.2020 10:05:53
-7,200
9820ea45895894b154feb02f86ee6a5df3084239
Add trimming function to preserve spaces for code block Reviewers: ashoat Subscribers: zrebcu411
[ { "change_type": "MODIFY", "old_path": "lib/shared/message-utils.js", "new_path": "lib/shared/message-utils.js", "diff": "@@ -32,6 +32,7 @@ import { prettyDate } from '../utils/date-utils';\nimport { userIDsToRelativeUserInfos } from '../selectors/user-selectors';\nimport { shimUploadURI, multimediaMessagePreview } from '../media/media-utils';\nimport { stringForUser } from './user-utils';\n+import { codeBlockRegex } from './markdown';\n// Prefers localID\nfunction messageKey(messageInfo: MessageInfo | RawMessageInfo): string {\n@@ -876,6 +877,15 @@ function stripLocalIDs(\nreturn output;\n}\n+// Normally we call trim() to remove whitespace at the beginning and end of each\n+// message. However, our Markdown parser supports a \"codeBlock\" format where the\n+// user can indent each line to indicate a code block. If we match the\n+// corresponding RegEx, we'll only trim whitespace off the end.\n+function trimMessage(message: string) {\n+ message = message.replace(/^\\n*/, '');\n+ return codeBlockRegex.exec(message) ? message.trimEnd() : message.trim();\n+}\n+\nexport {\nmessageKey,\nmessageID,\n@@ -895,4 +905,5 @@ export {\ncreateMediaMessageData,\ncreateMediaMessageInfo,\nstripLocalIDs,\n+ trimMessage,\n};\n" }, { "change_type": "MODIFY", "old_path": "native/chat/chat-input-bar.react.js", "new_path": "native/chat/chat-input-bar.react.js", "diff": "@@ -56,6 +56,7 @@ import { saveDraftActionType } from 'lib/actions/miscellaneous-action-types';\nimport { threadHasPermission, viewerIsMember } from 'lib/shared/thread-utils';\nimport { joinThreadActionTypes, joinThread } from 'lib/actions/thread-actions';\nimport { createLoadingStatusSelector } from 'lib/selectors/loading-selectors';\n+import { trimMessage } from 'lib/shared/message-utils';\nimport Button from '../components/button.react';\nimport { nonThreadCalendarQuery } from '../navigation/nav-selectors';\n@@ -149,7 +150,7 @@ class ChatInputBar extends React.PureComponent<Props, State> {\n// eslint-disable-next-line import/no-named-as-default-member\nthis.sendButtonContainerOpen = new Animated.Value(\n- props.draft.trim() ? 1 : 0,\n+ trimMessage(props.draft) ? 1 : 0,\n);\nthis.sendButtonContainerWidth = Animated.interpolate(\nthis.sendButtonContainerOpen,\n@@ -184,8 +185,8 @@ class ChatInputBar extends React.PureComponent<Props, State> {\n}\ncomponentDidUpdate(prevProps: Props, prevState: State) {\n- const currentText = this.state.text.trim();\n- const prevText = prevState.text.trim();\n+ const currentText = trimMessage(this.state.text);\n+ const prevText = trimMessage(prevState.text);\nif (\n(currentText === '' && prevText !== '') ||\n(currentText !== '' && prevText === '')\n@@ -409,7 +410,7 @@ class ChatInputBar extends React.PureComponent<Props, State> {\nonPress={this.onSend}\nactiveOpacity={0.4}\nstyle={this.props.styles.sendButton}\n- disabled={this.state.text.trim() === ''}\n+ disabled={trimMessage(this.state.text) === ''}\n>\n<Icon\nname=\"md-send\"\n@@ -445,7 +446,7 @@ class ChatInputBar extends React.PureComponent<Props, State> {\n}, 400);\nonSend = async () => {\n- if (!this.state.text.trim()) {\n+ if (!trimMessage(this.state.text)) {\nreturn;\n}\nthis.updateSendButton('');\n@@ -456,7 +457,7 @@ class ChatInputBar extends React.PureComponent<Props, State> {\n'clearableTextInput should be sent in onSend',\n);\nlet text = await clearableTextInput.getValueAndReset();\n- text = text.trim();\n+ text = trimMessage(text);\nif (!text) {\nreturn;\n}\n" }, { "change_type": "MODIFY", "old_path": "server/src/responders/message-responders.js", "new_path": "server/src/responders/message-responders.js", "diff": "@@ -17,7 +17,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';\n+import { createMediaMessageData, trimMessage } from 'lib/shared/message-utils';\nimport createMessages from '../creators/message-creator';\nimport { validateInput, tShape } from '../utils/validation-utils';\n@@ -39,7 +39,7 @@ async function textMessageCreationResponder(\nawait validateInput(viewer, sendTextMessageRequestInputValidator, request);\nconst { threadID, localID, text: rawText } = request;\n- const text = rawText.trim();\n+ const text = trimMessage(rawText);\nif (!text) {\nthrow new ServerError('invalid_parameters');\n}\n" }, { "change_type": "MODIFY", "old_path": "web/chat/chat-input-bar.react.js", "new_path": "web/chat/chat-input-bar.react.js", "diff": "@@ -34,6 +34,7 @@ import { connect } from 'lib/utils/redux-utils';\nimport { joinThreadActionTypes, joinThread } from 'lib/actions/thread-actions';\nimport { createLoadingStatusSelector } from 'lib/selectors/loading-selectors';\nimport { threadHasPermission, viewerIsMember } from 'lib/shared/thread-utils';\n+import { trimMessage } from 'lib/shared/message-utils';\nimport css from './chat-message-list.css';\nimport LoadingIndicator from '../loading-indicator.react';\n@@ -266,7 +267,7 @@ class ChatInputBar extends React.PureComponent<Props> {\nsend() {\nlet { nextLocalID } = this.props;\n- const text = this.props.inputState.draft.trim();\n+ const text = trimMessage(this.props.inputState.draft);\nif (text) {\n// TODO we should make the send button appear dynamically\n// iff trimmed text is nonempty, just like native\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Add trimming function to preserve spaces for code block Reviewers: ashoat Reviewed By: ashoat Subscribers: zrebcu411 Differential Revision: https://phabricator.ashoat.com/D9
129,187
02.08.2020 17:49:59
14,400
7abb6231948da0038efa05a320933ec22e1098a5
[server] getParentThreadMembershipRowsForNewUsers -> getParentThreadRelationshipRowsForNewUsers Minor naming fix
[ { "change_type": "MODIFY", "old_path": "server/src/creators/thread-creator.js", "new_path": "server/src/creators/thread-creator.js", "diff": "@@ -22,7 +22,7 @@ import {\nrecalculateAllPermissions,\ncommitMembershipChangeset,\nsetJoinsToUnread,\n- getParentThreadMembershipRowsForNewUsers,\n+ getParentThreadRelationshipRowsForNewUsers,\n} from '../updaters/thread-permission-updaters';\nimport createMessages from './message-creator';\n@@ -128,7 +128,7 @@ async function createThread(\nmembershipRows: initialMembersMembershipRows,\nrelationshipRows: initialMembersRelationshipRows,\n} = initialMembersChangeset;\n- const parentRelationshipRows = getParentThreadMembershipRowsForNewUsers(\n+ const parentRelationshipRows = getParentThreadRelationshipRowsForNewUsers(\nid,\nrecalculateMembershipRows,\ninitialMemberAndCreatorIDs,\n" }, { "change_type": "MODIFY", "old_path": "server/src/updaters/thread-permission-updaters.js", "new_path": "server/src/updaters/thread-permission-updaters.js", "diff": "@@ -678,7 +678,7 @@ function setJoinsToUnread(\n}\n}\n-function getParentThreadMembershipRowsForNewUsers(\n+function getParentThreadRelationshipRowsForNewUsers(\nthreadID: string,\nrecalculateMembershipRows: MembershipRow[],\nnewMemberIDs: string[],\n@@ -707,5 +707,5 @@ export {\nrecalculateAllPermissions,\ncommitMembershipChangeset,\nsetJoinsToUnread,\n- getParentThreadMembershipRowsForNewUsers,\n+ getParentThreadRelationshipRowsForNewUsers,\n};\n" }, { "change_type": "MODIFY", "old_path": "server/src/updaters/thread-updaters.js", "new_path": "server/src/updaters/thread-updaters.js", "diff": "@@ -40,7 +40,7 @@ import {\nrecalculateAllPermissions,\ncommitMembershipChangeset,\nsetJoinsToUnread,\n- getParentThreadMembershipRowsForNewUsers,\n+ getParentThreadRelationshipRowsForNewUsers,\n} from './thread-permission-updaters';\nimport createMessages from '../creators/message-creator';\nimport { fetchMessageInfos } from '../fetchers/message-fetchers';\n@@ -446,7 +446,7 @@ async function updateThread(\nrelationshipRows: recalculateRelationshipRows,\n} = recalculatePermissionsChangeset;\nmembershipRows.push(...recalculateMembershipRows);\n- const parentRelationshipRows = getParentThreadMembershipRowsForNewUsers(\n+ const parentRelationshipRows = getParentThreadRelationshipRowsForNewUsers(\nrequest.threadID,\nrecalculateMembershipRows,\nnewMemberIDs,\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[server] getParentThreadMembershipRowsForNewUsers -> getParentThreadRelationshipRowsForNewUsers Minor naming fix
129,187
02.08.2020 18:23:54
14,400
4658e0d0fe5cbfdc8ea81c47b1622b24aa78964f
[lib] Move userIDs in SharedRelationshipRow to numbers
[ { "change_type": "MODIFY", "old_path": "lib/shared/relationship-utils.js", "new_path": "lib/shared/relationship-utils.js", "diff": "// @flow\n-function sortIDs(firstId: string, secondId: string): number[] {\n- return [Number(firstId), Number(secondId)].sort((a, b) => a - b);\n+function sortIDs(firstId: string, secondId: string): string[] {\n+ return [Number(firstId), Number(secondId)]\n+ .sort((a, b) => a - b)\n+ .map(num => num.toString());\n}\nexport { sortIDs };\n" }, { "change_type": "MODIFY", "old_path": "lib/types/relationship-types.js", "new_path": "lib/types/relationship-types.js", "diff": "@@ -31,8 +31,8 @@ export type RelationshipRequest = {|\n|};\ntype SharedRelationshipRow = {|\n- user1: number,\n- user2: number,\n+ user1: string,\n+ user2: string,\n|};\nexport type DirectedRelationshipRow = {|\n...SharedRelationshipRow,\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[lib] Move userIDs in SharedRelationshipRow to numbers
129,187
02.08.2020 18:25:15
14,400
28bb013cb161a2e090f0145461594cc0bb3fe134
[server] Extract updateDatasForUserPairs and call it from commitMembershipChangeset
[ { "change_type": "MODIFY", "old_path": "server/src/updaters/relationship-updaters.js", "new_path": "server/src/updaters/relationship-updaters.js", "diff": "@@ -9,12 +9,13 @@ import {\nundirectedStatus,\ndirectedStatus,\n} from 'lib/types/relationship-types';\n-import { updateTypes } from 'lib/types/update-types';\n+import { updateTypes, type UpdateData } from 'lib/types/update-types';\nimport invariant from 'invariant';\nimport { ServerError } from 'lib/utils/errors';\nimport { sortIDs } from 'lib/shared/relationship-utils';\n+import { cartesianProduct } from 'lib/utils/array';\nimport { fetchUserInfos } from '../fetchers/user-fetchers';\nimport { fetchFriendRequestRelationshipOperations } from '../fetchers/relationship-fetchers';\n@@ -168,26 +169,33 @@ async function updateRelationships(\ninvariant(false, `action ${action} is invalid or not supported currently`);\n}\n+ await createUpdates(\n+ updateDatasForUserPairs(cartesianProduct([viewer.userID], updateIDs)),\n+ );\n+\n+ return errors;\n+}\n+\n+function updateDatasForUserPairs(\n+ userPairs: $ReadOnlyArray<[string, string]>,\n+): UpdateData[] {\nconst time = Date.now();\nconst updateDatas = [];\n- for (const userID of updateIDs) {\n+ for (const [user1, user2] of userPairs) {\nupdateDatas.push({\ntype: updateTypes.UPDATE_USER,\n- userID,\n+ userID: user1,\ntime,\n- updatedUserID: viewer.userID,\n+ updatedUserID: user2,\n});\nupdateDatas.push({\ntype: updateTypes.UPDATE_USER,\n- userID: viewer.userID,\n+ userID: user2,\ntime,\n- updatedUserID: userID,\n+ updatedUserID: user1,\n});\n}\n-\n- await createUpdates(updateDatas);\n-\n- return errors;\n+ return updateDatas;\n}\nasync function updateUndirectedRelationships(\n@@ -213,4 +221,8 @@ async function updateUndirectedRelationships(\nawait dbQuery(query);\n}\n-export { updateRelationships, updateUndirectedRelationships };\n+export {\n+ updateRelationships,\n+ updateDatasForUserPairs,\n+ updateUndirectedRelationships,\n+};\n" }, { "change_type": "MODIFY", "old_path": "server/src/updaters/thread-permission-updaters.js", "new_path": "server/src/updaters/thread-permission-updaters.js", "diff": "@@ -33,7 +33,10 @@ import {\ntype FetchThreadInfosResult,\n} from '../fetchers/thread-fetchers';\nimport { createUpdates } from '../creators/update-creator';\n-import { updateUndirectedRelationships } from '../updaters/relationship-updaters';\n+import {\n+ updateDatasForUserPairs,\n+ updateUndirectedRelationships,\n+} from '../updaters/relationship-updaters';\nimport { dbQuery, SQL, mergeOrConditions } from '../database';\n@@ -597,10 +600,11 @@ async function commitMembershipChangeset(\ntoSave.push(row);\n}\n}\n+ const uniqueRelationshipRows = _uniqWith(_isEqual)(relationshipRows);\nawait Promise.all([\nsaveMemberships(toSave),\ndeleteMemberships(toDelete),\n- updateUndirectedRelationships(_uniqWith(_isEqual)(relationshipRows)),\n+ updateUndirectedRelationships(uniqueRelationshipRows),\n]);\n// We fetch all threads here because clients still expect the full list of\n@@ -610,7 +614,9 @@ async function commitMembershipChangeset(\nconst { threadInfos: serverThreadInfos } = serverThreadInfoFetchResult;\nconst time = Date.now();\n- const updateDatas = [];\n+ const updateDatas = updateDatasForUserPairs(\n+ uniqueRelationshipRows.map(({ user1, user2 }) => [user1, user2]),\n+ );\nfor (let changedThreadID of changedThreadIDs) {\nconst serverThreadInfo = serverThreadInfos[changedThreadID];\nfor (let memberInfo of serverThreadInfo.members) {\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[server] Extract updateDatasForUserPairs and call it from commitMembershipChangeset
129,187
02.08.2020 18:48:01
14,400
03c926e915d62169bea54038e4879661a0c69612
[server] Check for know_of rows in createThread
[ { "change_type": "MODIFY", "old_path": "server/src/creators/thread-creator.js", "new_path": "server/src/creators/thread-creator.js", "diff": "@@ -9,14 +9,17 @@ import {\nimport { messageTypes } from 'lib/types/message-types';\nimport type { Viewer } from '../session/viewer';\n+import invariant from 'invariant';\n+\nimport { generateRandomColor } from 'lib/shared/thread-utils';\nimport { ServerError } from 'lib/utils/errors';\n+import { promiseAll } from 'lib/utils/promises';\nimport { dbQuery, SQL } from '../database';\nimport { checkThreadPermission } from '../fetchers/thread-fetchers';\nimport createIDs from './id-creator';\nimport { createInitialRolesForNewThread } from './role-creator';\n-import { verifyUserIDs } from '../fetchers/user-fetchers';\n+import { fetchKnownUserInfos } from '../fetchers/user-fetchers';\nimport {\nchangeRole,\nrecalculateAllPermissions,\n@@ -35,18 +38,43 @@ async function createThread(\n}\nconst threadType = request.type;\n- if (threadType !== threadTypes.CHAT_SECRET && !request.parentThreadID) {\n+ const parentThreadID = request.parentThreadID ? request.parentThreadID : null;\n+ const initialMemberIDs =\n+ request.initialMemberIDs && request.initialMemberIDs.length > 0\n+ ? request.initialMemberIDs\n+ : [];\n+\n+ if (threadType !== threadTypes.CHAT_SECRET && !parentThreadID) {\nthrow new ServerError('invalid_parameters');\n}\n- let parentThreadID = null;\n- if (request.parentThreadID) {\n- parentThreadID = request.parentThreadID;\n- const hasPermission = await checkThreadPermission(\n+\n+ const checkPromises = {};\n+ if (parentThreadID) {\n+ checkPromises.hasParentPermission = checkThreadPermission(\nviewer,\nparentThreadID,\nthreadPermissions.CREATE_SUBTHREADS,\n);\n- if (!hasPermission) {\n+ }\n+ if (initialMemberIDs) {\n+ checkPromises.fetchInitialMembers = fetchKnownUserInfos(\n+ viewer,\n+ SQL`\n+ ((r.user1 = ${viewer.userID} AND r.user2 IN (${initialMemberIDs})) OR\n+ (r.user1 IN (${initialMemberIDs}) AND r.user2 = ${viewer.userID}))\n+ `,\n+ );\n+ }\n+ const checkResults = await promiseAll(checkPromises);\n+ if (checkResults.hasParentPermission === false) {\n+ throw new ServerError('invalid_credentials');\n+ }\n+ if (checkResults.fetchInitialMembers) {\n+ invariant(initialMemberIDs, 'should be set');\n+ // Subtract 1 so we don't include the viewer\n+ const confirmedMemberCount =\n+ Object.keys(checkResults.fetchInitialMembers).length - 1;\n+ if (confirmedMemberCount < initialMemberIDs.length) {\nthrow new ServerError('invalid_credentials');\n}\n}\n@@ -77,12 +105,7 @@ async function createThread(\ncreation_time, color, parent_thread_id, default_role)\nVALUES ${[row]}\n`;\n- const [initialMemberIDs] = await Promise.all([\n- request.initialMemberIDs && request.initialMemberIDs.length > 0\n- ? verifyUserIDs(request.initialMemberIDs)\n- : undefined,\n- dbQuery(query),\n- ]);\n+ await dbQuery(query);\nconst [\ncreatorChangeset,\n@@ -90,9 +113,7 @@ async function createThread(\nrecalculatePermissionsChangeset,\n] = await Promise.all([\nchangeRole(id, [viewer.userID], newRoles.creator.id),\n- initialMemberIDs && initialMemberIDs.length > 0\n- ? changeRole(id, initialMemberIDs, null)\n- : undefined,\n+ initialMemberIDs ? changeRole(id, initialMemberIDs, null) : undefined,\nrecalculateAllPermissions(id, threadType),\n]);\n@@ -120,7 +141,7 @@ async function createThread(\n...creatorRelationshipRows,\n...recalculateRelationshipRows,\n];\n- if (initialMemberIDs && initialMemberIDs.length > 0) {\n+ if (initialMemberIDs) {\nif (!initialMembersChangeset) {\nthrow new ServerError('unknown_error');\n}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[server] Check for know_of rows in createThread
129,187
02.08.2020 22:47:50
14,400
2e96bace4e3525469c25ba3e72ddf13839020407
[server] Add createRelationships param to createThread
[ { "change_type": "MODIFY", "old_path": "lib/utils/array.js", "new_path": "lib/utils/array.js", "diff": "// @flow\n-function getAllTuples<T>([head, ...tail]: Array<T>): Array<[T, T]> {\n+function getAllTuples<T>([head, ...tail]: $ReadOnlyArray<T>): Array<[T, T]> {\nif (tail.length > 0) {\nreturn [...tail.map(tailValue => [head, tailValue]), ...getAllTuples(tail)];\n}\n@@ -8,8 +8,8 @@ function getAllTuples<T>([head, ...tail]: Array<T>): Array<[T, T]> {\n}\nfunction cartesianProduct<R, C>(\n- rows: Array<R>,\n- columns: Array<C>,\n+ rows: $ReadOnlyArray<R>,\n+ columns: $ReadOnlyArray<C>,\n): Array<[R, C]> {\nreturn rows.reduce((acc, rowValue) => {\nacc.push(...columns.map(columnValue => [rowValue, columnValue]));\n" }, { "change_type": "MODIFY", "old_path": "server/src/bots/squadbot.js", "new_path": "server/src/bots/squadbot.js", "diff": "@@ -15,7 +15,7 @@ async function createSquadbotThread(userID: string): Promise<string> {\ntype: threadTypes.CHAT_SECRET,\ninitialMemberIDs: [userID],\n};\n- const result = await createThread(squadbotViewer, newThreadRequest);\n+ const result = await createThread(squadbotViewer, newThreadRequest, true);\nreturn result.newThreadInfo.id;\n}\n" }, { "change_type": "MODIFY", "old_path": "server/src/creators/account-creator.js", "new_path": "server/src/creators/account-creator.js", "diff": "@@ -99,15 +99,23 @@ async function createAccount(\n}\nconst [personalThreadResult, ashoatThreadResult] = await Promise.all([\n- createThread(viewer, {\n+ createThread(\n+ viewer,\n+ {\ntype: threadTypes.CHAT_SECRET,\nname: request.username,\ndescription: 'your personal calendar',\n- }),\n- createThread(viewer, {\n+ },\n+ true,\n+ ),\n+ createThread(\n+ viewer,\n+ {\ntype: threadTypes.CHAT_SECRET,\ninitialMemberIDs: [ashoat.id],\n- }),\n+ },\n+ true,\n+ ),\n]);\nlet messageTime = Date.now();\nconst ashoatMessageDatas = ashoatMessages.map(message => ({\n" }, { "change_type": "MODIFY", "old_path": "server/src/creators/thread-creator.js", "new_path": "server/src/creators/thread-creator.js", "diff": "@@ -25,6 +25,7 @@ import {\nrecalculateAllPermissions,\ncommitMembershipChangeset,\nsetJoinsToUnread,\n+ getRelationshipRowsForUsers,\ngetParentThreadRelationshipRowsForNewUsers,\n} from '../updaters/thread-permission-updaters';\nimport createMessages from './message-creator';\n@@ -32,6 +33,7 @@ import createMessages from './message-creator';\nasync function createThread(\nviewer: Viewer,\nrequest: NewThreadRequest,\n+ createRelationships?: boolean = false,\n): Promise<NewThreadResult> {\nif (!viewer.loggedIn) {\nthrow new ServerError('not_logged_in');\n@@ -66,17 +68,23 @@ async function createThread(\n);\n}\nconst checkResults = await promiseAll(checkPromises);\n+\nif (checkResults.hasParentPermission === false) {\nthrow new ServerError('invalid_credentials');\n}\n+\n+ const viewerNeedsRelationshipsWith = [];\nif (checkResults.fetchInitialMembers) {\ninvariant(initialMemberIDs, 'should be set');\n- // Subtract 1 so we don't include the viewer\n- const confirmedMemberCount =\n- Object.keys(checkResults.fetchInitialMembers).length - 1;\n- if (confirmedMemberCount < initialMemberIDs.length) {\n+ for (const initialMemberID of initialMemberIDs) {\n+ if (checkResults.fetchInitialMembers[initialMemberID]) {\n+ continue;\n+ }\n+ if (!createRelationships) {\nthrow new ServerError('invalid_credentials');\n}\n+ viewerNeedsRelationshipsWith.push(initialMemberID);\n+ }\n}\nconst [id] = await createIDs('threads', 1);\n@@ -145,6 +153,12 @@ async function createThread(\nif (!initialMembersChangeset) {\nthrow new ServerError('unknown_error');\n}\n+ relationshipRows.push(\n+ ...getRelationshipRowsForUsers(\n+ viewer.userID,\n+ viewerNeedsRelationshipsWith,\n+ ),\n+ );\nconst {\nmembershipRows: initialMembersMembershipRows,\nrelationshipRows: initialMembersRelationshipRows,\n" }, { "change_type": "MODIFY", "old_path": "server/src/updaters/thread-permission-updaters.js", "new_path": "server/src/updaters/thread-permission-updaters.js", "diff": "@@ -684,10 +684,21 @@ function setJoinsToUnread(\n}\n}\n+function getRelationshipRowsForUsers(\n+ viewerID: string,\n+ userIDs: $ReadOnlyArray<string>,\n+): UndirectedRelationshipRow[] {\n+ return cartesianProduct([viewerID], userIDs).map(pair => {\n+ const [user1, user2] = sortIDs(...pair);\n+ const status = undirectedStatus.KNOW_OF;\n+ return { user1, user2, status };\n+ });\n+}\n+\nfunction getParentThreadRelationshipRowsForNewUsers(\nthreadID: string,\nrecalculateMembershipRows: MembershipRow[],\n- newMemberIDs: string[],\n+ newMemberIDs: $ReadOnlyArray<string>,\n): UndirectedRelationshipRow[] {\nconst parentMemberIDs = recalculateMembershipRows\n.map(rowToSave => rowToSave.userID)\n@@ -713,5 +724,6 @@ export {\nrecalculateAllPermissions,\ncommitMembershipChangeset,\nsetJoinsToUnread,\n+ getRelationshipRowsForUsers,\ngetParentThreadRelationshipRowsForNewUsers,\n};\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[server] Add createRelationships param to createThread
129,187
02.08.2020 22:58:36
14,400
5b00ac224b0bc20a1408c53e62ea7a581eb71139
[server] Check for know_of rows in updateThread
[ { "change_type": "MODIFY", "old_path": "server/src/updaters/thread-updaters.js", "new_path": "server/src/updaters/thread-updaters.js", "diff": "@@ -18,6 +18,7 @@ import { messageTypes, defaultNumberPerThread } from 'lib/types/message-types';\nimport bcrypt from 'twin-bcrypt';\nimport _find from 'lodash/fp/find';\n+import invariant from 'invariant';\nimport { ServerError } from 'lib/utils/errors';\nimport { promiseAll } from 'lib/utils/promises';\n@@ -28,6 +29,7 @@ import { dbQuery, SQL } from '../database';\nimport {\nverifyUserIDs,\nverifyUserOrCookieIDs,\n+ fetchKnownUserInfos,\n} from '../fetchers/user-fetchers';\nimport {\ncheckThreadPermission,\n@@ -307,10 +309,17 @@ async function updateThread(\nsqlUpdate.type = threadType;\n}\n- const unverifiedNewMemberIDs = request.changes.newMemberIDs;\n- if (unverifiedNewMemberIDs) {\n- validationPromises.verifiedNewMemberIDs = verifyUserIDs(\n- unverifiedNewMemberIDs,\n+ const newMemberIDs =\n+ request.changes.newMemberIDs && request.changes.newMemberIDs.length > 0\n+ ? [...request.changes.newMemberIDs]\n+ : null;\n+ if (newMemberIDs) {\n+ validationPromises.fetchNewMembers = fetchKnownUserInfos(\n+ viewer,\n+ SQL`\n+ ((r.user1 = ${viewer.userID} AND r.user2 IN (${newMemberIDs})) OR\n+ (r.user1 IN (${newMemberIDs}) AND r.user2 = ${viewer.userID}))\n+ `,\n);\n}\n@@ -333,17 +342,21 @@ async function updateThread(\nconst {\ncanMoveThread,\nthreadPermissionsBlob,\n- verifiedNewMemberIDs,\n+ fetchNewMembers,\nvalidationQuery: [validationResult],\n} = await promiseAll(validationPromises);\nif (canMoveThread === false) {\nthrow new ServerError('invalid_credentials');\n}\n+ if (fetchNewMembers) {\n+ invariant(newMemberIDs, 'should be set');\n+ for (const newMemberID of newMemberIDs) {\n+ if (!fetchNewMembers[newMemberID]) {\n+ throw new ServerError('invalid_credentials');\n+ }\n+ }\n+ }\n- const newMemberIDs =\n- verifiedNewMemberIDs && verifiedNewMemberIDs.length > 0\n- ? verifiedNewMemberIDs\n- : null;\nif (Object.keys(sqlUpdate).length === 0 && !newMemberIDs) {\nthrow new ServerError('invalid_parameters');\n}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[server] Check for know_of rows in updateThread
129,187
02.08.2020 23:03:09
14,400
afc3de947726316b67b1d57d2f0381bbda5efadb
[server] Update fetchKnownUserInfos to take array of userIDs instead of SQLStatement
[ { "change_type": "MODIFY", "old_path": "server/src/creators/thread-creator.js", "new_path": "server/src/creators/thread-creator.js", "diff": "@@ -61,10 +61,7 @@ async function createThread(\nif (initialMemberIDs) {\ncheckPromises.fetchInitialMembers = fetchKnownUserInfos(\nviewer,\n- SQL`\n- ((r.user1 = ${viewer.userID} AND r.user2 IN (${initialMemberIDs})) OR\n- (r.user1 IN (${initialMemberIDs}) AND r.user2 = ${viewer.userID}))\n- `,\n+ initialMemberIDs,\n);\n}\nconst checkResults = await promiseAll(checkPromises);\n" }, { "change_type": "MODIFY", "old_path": "server/src/fetchers/user-fetchers.js", "new_path": "server/src/fetchers/user-fetchers.js", "diff": "@@ -9,7 +9,7 @@ import type { Viewer } from '../session/viewer';\nimport { ServerError } from 'lib/utils/errors';\n-import { dbQuery, SQL, SQLStatement } from '../database';\n+import { dbQuery, SQL } from '../database';\nasync function fetchUserInfos(userIDs: string[]): Promise<UserInfos> {\nif (userIDs.length <= 0) {\n@@ -41,17 +41,28 @@ async function fetchUserInfos(userIDs: string[]): Promise<UserInfos> {\nreturn userInfos;\n}\n-async function fetchKnownUserInfos(viewer: Viewer, condition?: SQLStatement) {\n+async function fetchKnownUserInfos(\n+ viewer: Viewer,\n+ userIDs?: $ReadOnlyArray<string>,\n+) {\nif (!viewer.loggedIn) {\nthrow new ServerError('not_logged_in');\n}\n- const whereClause = condition ? SQL`AND `.append(condition) : '';\nconst query = SQL`\nSELECT DISTINCT u.id, u.username FROM relationships_undirected r\nLEFT JOIN users u ON r.user1 = u.id OR r.user2 = u.id\n- WHERE (r.user1 = ${viewer.userID} OR r.user2 = ${viewer.userID})\n- `.append(whereClause);\n+ `;\n+ if (userIDs) {\n+ query.append(SQL`\n+ WHERE (r.user1 = ${viewer.userID} AND r.user2 IN (${userIDs})) OR\n+ (r.user1 IN (${userIDs}) AND r.user2 = ${viewer.userID})\n+ `);\n+ } else {\n+ query.append(SQL`\n+ WHERE r.user1 = ${viewer.userID} OR r.user2 = ${viewer.userID}\n+ `);\n+ }\nconst [result] = await dbQuery(query);\nconst userInfos = {};\n" }, { "change_type": "MODIFY", "old_path": "server/src/responders/ping-responders.js", "new_path": "server/src/responders/ping-responders.js", "diff": "@@ -631,13 +631,7 @@ async function checkState(\nif (fetchAllUserInfos) {\nfetchPromises.userInfos = fetchKnownUserInfos(viewer);\n} else if (userIDsToFetch.length > 0) {\n- fetchPromises.userInfos = fetchKnownUserInfos(\n- viewer,\n- SQL`\n- ((r.user1 = ${viewer.userID} AND r.user2 IN (${userIDsToFetch})) OR\n- (r.user1 IN (${userIDsToFetch}) AND r.user2 = ${viewer.userID}))\n- `,\n- );\n+ fetchPromises.userInfos = fetchKnownUserInfos(viewer, userIDsToFetch);\n}\nif (fetchUserInfo) {\nfetchPromises.currentUserInfo = fetchCurrentUserInfo(viewer);\n" }, { "change_type": "MODIFY", "old_path": "server/src/updaters/thread-updaters.js", "new_path": "server/src/updaters/thread-updaters.js", "diff": "@@ -316,10 +316,7 @@ async function updateThread(\nif (newMemberIDs) {\nvalidationPromises.fetchNewMembers = fetchKnownUserInfos(\nviewer,\n- SQL`\n- ((r.user1 = ${viewer.userID} AND r.user2 IN (${newMemberIDs})) OR\n- (r.user1 IN (${newMemberIDs}) AND r.user2 = ${viewer.userID}))\n- `,\n+ newMemberIDs,\n);\n}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[server] Update fetchKnownUserInfos to take array of userIDs instead of SQLStatement
129,187
02.08.2020 23:08:15
14,400
0d37866a000e4320ce7dfe0ff564057fe5eeb236
[server] Create know_of relationship between ashoat and squadbot in create-db.js
[ { "change_type": "MODIFY", "old_path": "server/src/scripts/create-db.js", "new_path": "server/src/scripts/create-db.js", "diff": "// @flow\n+import { threadTypes } from 'lib/types/thread-types';\n+import { undirectedStatus } from 'lib/types/relationship-types';\n+\nimport ashoat from 'lib/facts/ashoat';\nimport bots from 'lib/facts/bots';\nimport {\nmakePermissionsBlob,\nmakePermissionsForChildrenBlob,\n} from 'lib/permissions/thread-permissions';\n-import { threadTypes } from 'lib/types/thread-types';\n+import { sortIDs } from 'lib/shared/relationship-utils';\nimport { setScriptContext } from './script-context';\nimport { endScript } from './utils';\n@@ -306,6 +309,7 @@ async function createTables() {\n}\nasync function createUsers() {\n+ const [user1, user2] = sortIDs(bots.squadbot.userID, ashoat.id);\nawait dbQuery(SQL`\nINSERT INTO ids (id, table_name)\nVALUES\n@@ -318,6 +322,8 @@ async function createUsers() {\nNULL, 1530049900980),\n(${ashoat.id}, 'ashoat', '', ${ashoat.email}, 1,\nNULL, 1463588881886);\n+ INSERT INTO relationships_undirected (user1, user2, status)\n+ VALUES (${user1}, ${user2}, ${undirectedStatus.KNOW_OF});\n`);\n}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[server] Create know_of relationship between ashoat and squadbot in create-db.js
129,187
04.08.2020 10:27:11
14,400
8957123c597015bac5b269ce30cb9c2a05de7b51
[native] Export chatMessageItemKey from chat-list.react.js
[ { "change_type": "MODIFY", "old_path": "native/chat/chat-list.react.js", "new_path": "native/chat/chat-list.react.js", "diff": "@@ -13,6 +13,7 @@ import {\ntype KeyboardState,\nwithKeyboardState,\n} from '../keyboard/keyboard-state';\n+import type { ChatMessageItem } from 'lib/selectors/chat-selectors';\nimport * as React from 'react';\nimport {\n@@ -33,7 +34,7 @@ import { connect } from 'lib/utils/redux-utils';\nimport { messageItemHeight } from './message.react';\nimport NewMessagesPill from './new-messages-pill.react';\n-function chatMessageItemKey(item: ChatMessageItemWithHeight) {\n+function chatMessageItemKey(item: ChatMessageItemWithHeight | ChatMessageItem) {\nif (item.itemType === 'loader') {\nreturn 'loader';\n}\n@@ -312,6 +313,8 @@ const styles = StyleSheet.create({\n},\n});\n-export default connect((state: AppState) => ({\n+const ConnectedChatList = connect((state: AppState) => ({\nviewerID: state.currentUserInfo && state.currentUserInfo.id,\n}))(withKeyboardState(ChatList));\n+\n+export { ConnectedChatList as ChatList, chatMessageItemKey };\n" }, { "change_type": "MODIFY", "old_path": "native/chat/message-list.react.js", "new_path": "native/chat/message-list.react.js", "diff": "@@ -52,7 +52,7 @@ import {\nkeyboardStatePropType,\nwithKeyboardState,\n} from '../keyboard/keyboard-state';\n-import ChatList from './chat-list.react';\n+import { ChatList } from './chat-list.react';\ntype Props = {|\nthreadInfo: ThreadInfo,\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Export chatMessageItemKey from chat-list.react.js
129,187
04.08.2020 16:28:56
14,400
f226fa63962135ac8643adb8fb73aa1ead5c45ef
[server] Update to Node 14.7
[ { "change_type": "MODIFY", "old_path": "server/.nvmrc", "new_path": "server/.nvmrc", "diff": "-13.13\n+14.7\n" }, { "change_type": "MODIFY", "old_path": "server/package.json", "new_path": "server/package.json", "diff": "\"rsync\": \"rsync -rLpmuv --exclude '*/package.json' --exclude '*/node_modules/*' --include '*.json' --include '*.cjs' --exclude '*.*' src/ dist/\",\n\"prod-build\": \"yarn babel-build && yarn rsync && yarn update-geoip\",\n\"update-geoip\": \"yarn script dist/scripts/update-geoip.js\",\n- \"prod\": \"node --experimental-modules --experimental-json-modules --loader ./loader.mjs --es-module-specifier-resolution node dist/server\",\n+ \"prod\": \"node --experimental-json-modules --loader ./loader.mjs --es-module-specifier-resolution node dist/server\",\n\"dev-rsync\": \"yarn --silent chokidar --initial --silent -s 'src/**/*.json' 'src/**/*.cjs' -c 'yarn rsync > /dev/null 2>&1'\",\n- \"dev\": \"yarn concurrently --names=\\\"BABEL,RSYNC,NODEM\\\" -c \\\"bgBlue.bold,bgMagenta.bold,bgGreen.bold\\\" \\\"yarn babel-build --watch\\\" \\\"yarn dev-rsync\\\" \\\". bash/source-nvm.sh && NODE_ENV=dev nodemon -e js,json,cjs --watch dist --experimental-modules --experimental-json-modules --loader ./loader.mjs --es-module-specifier-resolution node dist/server\\\"\",\n- \"script\": \". bash/source-nvm.sh && node --experimental-modules --experimental-json-modules --loader ./loader.mjs --es-module-specifier-resolution node\"\n+ \"dev\": \"yarn concurrently --names=\\\"BABEL,RSYNC,NODEM\\\" -c \\\"bgBlue.bold,bgMagenta.bold,bgGreen.bold\\\" \\\"yarn babel-build --watch\\\" \\\"yarn dev-rsync\\\" \\\". bash/source-nvm.sh && NODE_ENV=dev nodemon -e js,json,cjs --watch dist --experimental-json-modules --loader ./loader.mjs --es-module-specifier-resolution node dist/server\\\"\",\n+ \"script\": \". bash/source-nvm.sh && node --experimental-json-modules --loader ./loader.mjs --es-module-specifier-resolution node\"\n},\n\"devDependencies\": {\n\"@babel/cli\": \"^7.8.4\",\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[server] Update to Node 14.7
129,187
04.08.2020 16:32:41
14,400
57d9d2d79e059f34fcabfb21db685a2abd700974
[native] sleep(0) before changing scrollPos on first scroll on iOS Was doing this on Android before but it started to be an issue on iOS too. I can't figure out when/why... tried builds from almost a year ago and they have the issue. Maybe something about my phone changed? Repros on simulator though.
[ { "change_type": "MODIFY", "old_path": "native/calendar/calendar.react.js", "new_path": "native/calendar/calendar.react.js", "diff": "@@ -214,8 +214,8 @@ class Calendar extends React.PureComponent<Props, State> {\n// cache the most recent value as a member here\nlatestExtraData: ExtraData;\n// For some reason, we have to delay the scrollToToday call after the first\n- // scroll upwards on Android. I don't know why. Might only be on the emulator.\n- firstScrollUpOnAndroidComplete = false;\n+ // scroll upwards\n+ firstScrollComplete = false;\n// When an entry becomes active, we make a note of its key so that once the\n// keyboard event happens, we know where to move the scrollPos to\nlastEntryKeyActive: ?string = null;\n@@ -307,6 +307,7 @@ class Calendar extends React.PureComponent<Props, State> {\nreadyToShowList: false,\nextraData: this.latestExtraData,\n});\n+ this.firstScrollComplete = false;\nthis.topLoaderWaitingToLeaveView = true;\nthis.bottomLoaderWaitingToLeaveView = true;\n}\n@@ -374,11 +375,11 @@ class Calendar extends React.PureComponent<Props, State> {\nif (!this.props.calendarActive) {\nsleep(50).then(() => this.scrollToToday());\n}\n- this.firstScrollUpOnAndroidComplete = false;\n+ this.firstScrollComplete = false;\n} else if (newStartDate < lastStartDate) {\nthis.updateScrollPositionAfterPrepend(lastLDWH, newLDWH);\n} else if (newEndDate > lastEndDate) {\n- this.firstScrollUpOnAndroidComplete = true;\n+ this.firstScrollComplete = true;\n} else if (newLDWH.length > lastLDWH.length) {\nLayoutAnimation.easeInEaseOut();\n}\n@@ -457,11 +458,10 @@ class Calendar extends React.PureComponent<Props, State> {\nanimated: false,\n});\n};\n- if (Platform.OS === 'android' && !this.firstScrollUpOnAndroidComplete) {\n- setTimeout(scrollAction, 0);\n- this.firstScrollUpOnAndroidComplete = true;\n- } else {\nscrollAction();\n+ if (!this.firstScrollComplete) {\n+ setTimeout(scrollAction, 0);\n+ this.firstScrollComplete = true;\n}\n}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] sleep(0) before changing scrollPos on first scroll on iOS Was doing this on Android before but it started to be an issue on iOS too. I can't figure out when/why... tried builds from almost a year ago and they have the issue. Maybe something about my phone changed? Repros on simulator though.
129,187
05.08.2020 13:55:53
14,400
9ca55df82830f5dfbc5b8e36e4aaaba78efa5b44
[native] SingleLine `Text`'s `numberOfLines` prop on iOS only considers the first line, whereas on Android it ignores newlines. This commit introduces a `SingleLine` component whose behavior is consistent across platforms. It only considers the first line, ie. iOS's behavior.
[ { "change_type": "MODIFY", "old_path": "native/calendar/entry.react.js", "new_path": "native/calendar/entry.react.js", "diff": "@@ -76,6 +76,7 @@ import {\nimport { waitForInteractions } from '../utils/interactions';\nimport Markdown from '../markdown/markdown.react';\nimport { inlineMarkdownRules } from '../markdown/rules.react';\n+import { SingleLine } from '../components/single-line.react';\nfunction hueDistance(firstColor: string, secondColor: string): number {\nconst firstHue = tinycolor(firstColor).toHsv().h;\n@@ -359,12 +360,11 @@ class InternalEntry extends React.Component<Props, State> {\niosActiveOpacity={0.85}\nstyle={this.props.styles.button}\n>\n- <Text\n+ <SingleLine\nstyle={[this.props.styles.rightLinksText, actionLinksTextStyle]}\n- numberOfLines={1}\n>\n{this.props.threadInfo.uiName}\n- </Text>\n+ </SingleLine>\n</Button>\n</View>\n</View>\n" }, { "change_type": "MODIFY", "old_path": "native/chat/chat-thread-list-item.react.js", "new_path": "native/chat/chat-thread-list-item.react.js", "diff": "@@ -24,6 +24,7 @@ import {\ncolorsSelector,\nstyleSelector,\n} from '../themes/colors';\n+import { SingleLine } from '../components/single-line.react';\ntype Props = {\ndata: ChatThreadItem,\n@@ -80,12 +81,11 @@ class ChatThreadListItem extends React.PureComponent<Props> {\nstyle={this.props.styles.sidebarIcon}\nsize={24}\n/>\n- <Text\n+ <SingleLine\nstyle={[this.props.styles.sidebarName, sidebarUnreadStyle]}\n- numberOfLines={1}\n>\n{sidebarThreadInfo.uiName}\n- </Text>\n+ </SingleLine>\n<Text style={[this.props.styles.sidebarLastActivity, unreadStyle]}>\n{lastActivity}\n</Text>\n@@ -107,12 +107,9 @@ class ChatThreadListItem extends React.PureComponent<Props> {\n>\n<View style={this.props.styles.container}>\n<View style={this.props.styles.row}>\n- <Text\n- style={[this.props.styles.threadName, unreadStyle]}\n- numberOfLines={1}\n- >\n+ <SingleLine style={[this.props.styles.threadName, unreadStyle]}>\n{this.props.data.threadInfo.uiName}\n- </Text>\n+ </SingleLine>\n<View style={this.props.styles.colorSplotch}>\n<ColorSplotch\ncolor={this.props.data.threadInfo.color}\n" }, { "change_type": "MODIFY", "old_path": "native/chat/message-header.react.js", "new_path": "native/chat/message-header.react.js", "diff": "@@ -5,7 +5,7 @@ import type { AppState } from '../redux/redux-setup';\nimport type { DisplayType } from './timestamp.react';\nimport * as React from 'react';\n-import { View, Text } from 'react-native';\n+import { View } from 'react-native';\nimport { stringForUser } from 'lib/shared/user-utils';\nimport { connect } from 'lib/utils/redux-utils';\n@@ -13,6 +13,7 @@ import { connect } from 'lib/utils/redux-utils';\nimport { Timestamp, timestampHeight } from './timestamp.react';\nimport { styleSelector } from '../themes/colors';\nimport { clusterEndHeight } from './composed-message.react';\n+import { SingleLine } from '../components/single-line.react';\ntype Props = {|\nitem: ChatMessageInfoItemWithHeight,\n@@ -34,9 +35,7 @@ function MessageHeader(props: Props) {\nstyle.push(props.styles.modal);\n}\nauthorName = (\n- <Text style={style} numberOfLines={1}>\n- {stringForUser(creator)}\n- </Text>\n+ <SingleLine style={style}>{stringForUser(creator)}</SingleLine>\n);\n}\n" }, { "change_type": "MODIFY", "old_path": "native/chat/message-preview.react.js", "new_path": "native/chat/message-preview.react.js", "diff": "@@ -21,6 +21,7 @@ import { stringForUser } from 'lib/shared/user-utils';\nimport { connect } from 'lib/utils/redux-utils';\nimport { styleSelector } from '../themes/colors';\n+import { firstLine, SingleLine } from '../components/single-line.react';\ntype Props = {|\nmessageInfo: MessageInfo,\n@@ -54,28 +55,28 @@ class MessagePreview extends React.PureComponent<Props> {\n</Text>\n);\n}\n+ const firstMessageLine = firstLine(messageInfo.text);\nreturn (\n<Text\nstyle={[this.props.styles.lastMessage, unreadStyle]}\nnumberOfLines={1}\n>\n{usernameText}\n- {messageInfo.text}\n+ {firstMessageLine}\n</Text>\n);\n} else {\nconst preview = messagePreviewText(messageInfo, this.props.threadInfo);\nreturn (\n- <Text\n+ <SingleLine\nstyle={[\nthis.props.styles.lastMessage,\nthis.props.styles.preview,\nunreadStyle,\n]}\n- numberOfLines={1}\n>\n{preview}\n- </Text>\n+ </SingleLine>\n);\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "native/chat/settings/thread-settings-child-thread.react.js", "new_path": "native/chat/settings/thread-settings-child-thread.react.js", "diff": "@@ -5,7 +5,7 @@ import type { ThreadSettingsNavigate } from './thread-settings.react';\nimport type { AppState } from '../../redux/redux-setup';\nimport * as React from 'react';\n-import { Text, View, Platform } from 'react-native';\n+import { View, Platform } from 'react-native';\nimport PropTypes from 'prop-types';\nimport { connect } from 'lib/utils/redux-utils';\n@@ -20,6 +20,7 @@ import {\ncolorsSelector,\nstyleSelector,\n} from '../../themes/colors';\n+import { SingleLine } from '../../components/single-line.react';\ntype Props = {|\nthreadInfo: ThreadInfo,\n@@ -50,9 +51,9 @@ class ThreadSettingsChildThread extends React.PureComponent<Props> {\n>\n<View style={this.props.styles.leftSide}>\n<ColorSplotch color={this.props.threadInfo.color} />\n- <Text style={this.props.styles.text} numberOfLines={1}>\n+ <SingleLine style={this.props.styles.text}>\n{this.props.threadInfo.uiName}\n- </Text>\n+ </SingleLine>\n</View>\n<ThreadVisibility\nthreadType={this.props.threadInfo.type}\n" }, { "change_type": "MODIFY", "old_path": "native/chat/settings/thread-settings-member.react.js", "new_path": "native/chat/settings/thread-settings-member.react.js", "diff": "@@ -54,6 +54,7 @@ import {\ntype OverlayContextType,\noverlayContextPropType,\n} from '../../navigation/overlay-context';\n+import { SingleLine } from '../../components/single-line.react';\ntype Props = {|\nmemberInfo: RelativeMemberInfo,\n@@ -133,18 +134,15 @@ class ThreadSettingsMember extends React.PureComponent<Props> {\nlet userInfo = null;\nif (this.props.memberInfo.username) {\nuserInfo = (\n- <Text style={this.props.styles.username} numberOfLines={1}>\n- {userText}\n- </Text>\n+ <SingleLine style={this.props.styles.username}>{userText}</SingleLine>\n);\n} else {\nuserInfo = (\n- <Text\n+ <SingleLine\nstyle={[this.props.styles.username, this.props.styles.anonymous]}\n- numberOfLines={1}\n>\n{userText}\n- </Text>\n+ </SingleLine>\n);\n}\n@@ -176,7 +174,9 @@ class ThreadSettingsMember extends React.PureComponent<Props> {\nif (memberIsAdmin(this.props.memberInfo, this.props.threadInfo)) {\nroleInfo = (\n<View style={this.props.styles.row}>\n- <Text style={this.props.styles.role}>admin</Text>\n+ <Text style={this.props.styles.role} numberOfLines={1}>\n+ admin\n+ </Text>\n</View>\n);\n} else {\n@@ -190,7 +190,9 @@ class ThreadSettingsMember extends React.PureComponent<Props> {\nif (canChangeRoles) {\nroleInfo = (\n<View style={this.props.styles.row}>\n- <Text style={this.props.styles.role}>parent admin</Text>\n+ <Text style={this.props.styles.role} numberOfLines={1}>\n+ parent admin\n+ </Text>\n</View>\n);\n}\n" }, { "change_type": "MODIFY", "old_path": "native/chat/settings/thread-settings-parent.react.js", "new_path": "native/chat/settings/thread-settings-parent.react.js", "diff": "@@ -15,6 +15,7 @@ import { connect } from 'lib/utils/redux-utils';\nimport Button from '../../components/button.react';\nimport { MessageListRouteName } from '../../navigation/route-names';\nimport { styleSelector } from '../../themes/colors';\n+import { SingleLine } from '../../components/single-line.react';\ntype Props = {|\nthreadInfo: ThreadInfo,\n@@ -39,15 +40,14 @@ class ThreadSettingsParent extends React.PureComponent<Props> {\nonPress={this.onPressParentThread}\nstyle={this.props.styles.currentValue}\n>\n- <Text\n+ <SingleLine\nstyle={[\nthis.props.styles.currentValueText,\nthis.props.styles.parentThreadLink,\n]}\n- numberOfLines={1}\n>\n{this.props.parentThreadInfo.uiName}\n- </Text>\n+ </SingleLine>\n</Button>\n);\n} else if (this.props.threadInfo.parentThreadID) {\n@@ -58,6 +58,7 @@ class ThreadSettingsParent extends React.PureComponent<Props> {\nthis.props.styles.currentValueText,\nthis.props.styles.noParent,\n]}\n+ numberOfLines={1}\n>\nSecret parent\n</Text>\n@@ -70,6 +71,7 @@ class ThreadSettingsParent extends React.PureComponent<Props> {\nthis.props.styles.currentValueText,\nthis.props.styles.noParent,\n]}\n+ numberOfLines={1}\n>\nNo parent\n</Text>\n@@ -77,7 +79,9 @@ class ThreadSettingsParent extends React.PureComponent<Props> {\n}\nreturn (\n<View style={this.props.styles.row}>\n- <Text style={this.props.styles.label}>Parent</Text>\n+ <Text style={this.props.styles.label} numberOfLines={1}>\n+ Parent\n+ </Text>\n{parent}\n</View>\n);\n" }, { "change_type": "MODIFY", "old_path": "native/chat/timestamp.react.js", "new_path": "native/chat/timestamp.react.js", "diff": "import type { AppState } from '../redux/redux-setup';\nimport * as React from 'react';\n-import { Text } from 'react-native';\nimport { longAbsoluteDate } from 'lib/utils/date-utils';\nimport { connect } from 'lib/utils/redux-utils';\nimport { styleSelector } from '../themes/colors';\n+import { SingleLine } from '../components/single-line.react';\nexport type DisplayType = 'lowContrast' | 'modal';\n@@ -24,9 +24,9 @@ function Timestamp(props: Props) {\nstyle.push(props.styles.modal);\n}\nreturn (\n- <Text style={style} numberOfLines={1}>\n+ <SingleLine style={style}>\n{longAbsoluteDate(props.time).toUpperCase()}\n- </Text>\n+ </SingleLine>\n);\n}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "native/components/single-line.react.js", "diff": "+// @flow\n+\n+import * as React from 'react';\n+import { Text } from 'react-native';\n+\n+const newlineRegex = /[\\r\\n]/;\n+function firstLine(text: ?string): string {\n+ if (!text) {\n+ return '';\n+ }\n+ return text.split(newlineRegex, 1)[0];\n+}\n+\n+type Props = {|\n+ ...React.ElementConfig<typeof Text>,\n+ children: ?string,\n+|};\n+function SingleLine(props: Props) {\n+ const text = firstLine(props.children);\n+ return (\n+ <Text {...props} numberOfLines={1}>\n+ {text}\n+ </Text>\n+ );\n+}\n+\n+export { firstLine, SingleLine };\n" }, { "change_type": "MODIFY", "old_path": "native/components/thread-list-thread.react.js", "new_path": "native/components/thread-list-thread.react.js", "diff": "@@ -19,6 +19,7 @@ import {\ncolorsSelector,\nstyleSelector,\n} from '../themes/colors';\n+import { SingleLine } from './single-line.react';\ntype Props = {|\nthreadInfo: ThreadInfo,\n@@ -50,12 +51,9 @@ class ThreadListThread extends React.PureComponent<Props> {\nstyle={[this.props.styles.button, this.props.style]}\n>\n<ColorSplotch color={this.props.threadInfo.color} />\n- <Text\n- style={[this.props.styles.text, this.props.textStyle]}\n- numberOfLines={1}\n- >\n+ <SingleLine style={[this.props.styles.text, this.props.textStyle]}>\n{this.props.threadInfo.uiName}\n- </Text>\n+ </SingleLine>\n</Button>\n);\n}\n" }, { "change_type": "MODIFY", "old_path": "native/components/user-list-user.react.js", "new_path": "native/components/user-list-user.react.js", "diff": "@@ -17,6 +17,7 @@ import {\ncolorsSelector,\nstyleSelector,\n} from '../themes/colors';\n+import { SingleLine } from './single-line.react';\n// eslint-disable-next-line no-unused-vars\nconst getUserListItemHeight = (item: UserListItem) => {\n@@ -59,12 +60,9 @@ class UserListUser extends React.PureComponent<Props> {\niosActiveOpacity={0.85}\nstyle={this.props.styles.button}\n>\n- <Text\n- style={[this.props.styles.text, this.props.textStyle]}\n- numberOfLines={1}\n- >\n+ <SingleLine style={[this.props.styles.text, this.props.textStyle]}>\n{this.props.userInfo.username}\n- </Text>\n+ </SingleLine>\n{parentThreadNotice}\n</Button>\n);\n" }, { "change_type": "MODIFY", "old_path": "native/more/more-screen.react.js", "new_path": "native/more/more-screen.react.js", "diff": "@@ -61,6 +61,7 @@ import {\ncolorsSelector,\nstyleSelector,\n} from '../themes/colors';\n+import { firstLine, SingleLine } from '../components/single-line.react';\ntype Props = {\nnavigation: MoreNavigationProp<'MoreScreen'>,\n@@ -177,7 +178,9 @@ class MoreScreen extends React.PureComponent<Props> {\n<View style={this.props.styles.row}>\n<Text style={this.props.styles.label} numberOfLines={1}>\n{'Logged in as '}\n- <Text style={this.props.styles.username}>{this.username}</Text>\n+ <Text style={this.props.styles.username}>\n+ {firstLine(this.username)}\n+ </Text>\n</Text>\n<Button onPress={this.onPressLogOut}>\n<Text style={this.props.styles.logOutText}>Log out</Text>\n@@ -189,9 +192,9 @@ class MoreScreen extends React.PureComponent<Props> {\n<View style={this.props.styles.row}>\n<Text style={this.props.styles.label}>Email</Text>\n<View style={this.props.styles.content}>\n- <Text style={this.props.styles.value} numberOfLines={1}>\n+ <SingleLine style={this.props.styles.value}>\n{this.email}\n- </Text>\n+ </SingleLine>\n{emailVerifiedNode}\n</View>\n<EditSettingButton\n" }, { "change_type": "MODIFY", "old_path": "native/more/relationship-list-item.react.js", "new_path": "native/more/relationship-list-item.react.js", "diff": "import type { AppState } from '../redux/redux-setup';\nimport * as React from 'react';\n-import { View, Text, TouchableOpacity } from 'react-native';\n+import { View, TouchableOpacity } from 'react-native';\nimport { connect } from 'lib/utils/redux-utils';\nimport { type UserInfo } from 'lib/types/user-types';\nimport PencilIcon from '../components/pencil-icon.react';\nimport { type Colors, colorsSelector, styleSelector } from '../themes/colors';\n+import { SingleLine } from '../components/single-line.react';\ntype Props = {|\nuserInfo: UserInfo,\n@@ -28,9 +29,9 @@ class RelationshipListItem extends React.PureComponent<Props> {\nreturn (\n<View style={this.props.styles.container}>\n<View style={[this.props.styles.innerContainer, borderBottom]}>\n- <Text style={this.props.styles.username} numberOfLines={1}>\n+ <SingleLine style={this.props.styles.username}>\n{this.props.userInfo.username}\n- </Text>\n+ </SingleLine>\n<TouchableOpacity\nonPress={this.onPressEdit}\nstyle={styles.editButton}\n" }, { "change_type": "MODIFY", "old_path": "native/navigation/tooltip-item.react.js", "new_path": "native/navigation/tooltip-item.react.js", "diff": "@@ -16,6 +16,8 @@ import {\n} from 'react-native';\nimport PropTypes from 'prop-types';\n+import { SingleLine } from '../components/single-line.react';\n+\nexport type TooltipEntry<Params> = {|\nid: string,\ntext: string,\n@@ -52,9 +54,9 @@ class TooltipItem<\nonPress={this.onPress}\nstyle={[styles.itemContainer, this.props.containerStyle]}\n>\n- <Text style={[styles.label, this.props.labelStyle]} numberOfLines={1}>\n+ <SingleLine style={[styles.label, this.props.labelStyle]}>\n{this.props.spec.text}\n- </Text>\n+ </SingleLine>\n</TouchableOpacity>\n);\n}\n" }, { "change_type": "MODIFY", "old_path": "native/push/in-app-notif.react.js", "new_path": "native/push/in-app-notif.react.js", "diff": "@@ -6,6 +6,8 @@ import * as React from 'react';\nimport { View, Text, StyleSheet, Platform } from 'react-native';\nimport { SafeAreaView } from 'react-native-safe-area-context';\n+import { SingleLine } from '../components/single-line.react';\n+\nconst edges = ['top'];\ntype Props = {|\n@@ -23,10 +25,10 @@ function InAppNotif(props: Props) {\nuseLightStyle ? styles.lightTitle : null,\n];\ntitle = (\n- <Text style={titleStyles} numberOfLines={1}>\n- {props.title}\n+ <>\n+ <SingleLine style={titleStyles}>{props.title}</SingleLine>\n{'\\n'}\n- </Text>\n+ </>\n);\n}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] SingleLine `Text`'s `numberOfLines` prop on iOS only considers the first line, whereas on Android it ignores newlines. This commit introduces a `SingleLine` component whose behavior is consistent across platforms. It only considers the first line, ie. iOS's behavior.
129,187
05.08.2020 14:49:15
14,400
955c8f63418555afd1bedbeddda827bb9a815dcb
[native] Track whether device is rotated in DimensionsInfo `deviceOrientation` should track this, but it lags a little bit compared to `dimensionsInfo`, which causes issues
[ { "change_type": "MODIFY", "old_path": "native/redux/dimensions-updater.react.js", "new_path": "native/redux/dimensions-updater.react.js", "diff": "@@ -24,6 +24,7 @@ export type DimensionsInfo = {|\ntopInset: number,\nbottomInset: number,\ntabBarHeight: number,\n+ rotated: boolean,\n|};\nconst dimensionsInfoPropType = PropTypes.exact({\n@@ -32,6 +33,7 @@ const dimensionsInfoPropType = PropTypes.exact({\ntopInset: PropTypes.number.isRequired,\nbottomInset: PropTypes.number.isRequired,\ntabBarHeight: PropTypes.number.isRequired,\n+ rotated: PropTypes.bool.isRequired,\n});\ntype Metrics = {|\n@@ -56,7 +58,10 @@ function dimensionsUpdateFromMetrics(\nconst defaultDimensionsInfo = {\n...dimensionsUpdateFromMetrics(initialWindowMetrics),\ntabBarHeight: 50,\n+ rotated: false,\n};\n+const defaultIsPortrait =\n+ defaultDimensionsInfo.height >= defaultDimensionsInfo.width;\nfunction DimensionsUpdater() {\nconst dimensions = useSelector(state => state.dimensions);\n@@ -90,6 +95,9 @@ function DimensionsUpdater() {\nreturn;\n}\nconst updates = dimensionsUpdateFromMetrics({ frame, insets });\n+ if (updates.height && updates.width && updates.height !== updates.width) {\n+ updates.rotated = updates.width > updates.height === defaultIsPortrait;\n+ }\nfor (let key in updates) {\nif (updates[key] === dimensions[key]) {\ncontinue;\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Track whether device is rotated in DimensionsInfo `deviceOrientation` should track this, but it lags a little bit compared to `dimensionsInfo`, which causes issues
129,187
05.08.2020 14:51:47
14,400
90611a250c5a2a03b3ad59d9c79b7de7ad4d47db
[native] Ignore device orientation in composedMessageMaxWidthSelector
[ { "change_type": "MODIFY", "old_path": "native/chat/composed-message-width.js", "new_path": "native/chat/composed-message-width.js", "diff": "// @flow\nimport type { AppState } from '../redux/redux-setup';\n+import type { DimensionsInfo } from '../redux/dimensions-updater.react';\nimport { createSelector } from 'reselect';\n@@ -8,8 +9,13 @@ import { createSelector } from 'reselect';\nconst composedMessageMaxWidthSelector: (\nstate: AppState,\n) => number = createSelector(\n- (state: AppState) => state.dimensions.width,\n- (windowWidth: number): number => (windowWidth - 24) * 0.8,\n+ (state: AppState) => state.dimensions,\n+ (dimensionsInfo: DimensionsInfo): number => {\n+ const windowWidth = dimensionsInfo.rotated\n+ ? dimensionsInfo.height\n+ : dimensionsInfo.width;\n+ return (windowWidth - 24) * 0.8;\n+ },\n);\nexport { composedMessageMaxWidthSelector };\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Ignore device orientation in composedMessageMaxWidthSelector
129,187
05.08.2020 15:20:26
14,400
16301f73752b1aff842db7b7015bb56e1381cf0e
[native] Don't measure heights while device is rotated
[ { "change_type": "MODIFY", "old_path": "native/components/node-height-measurer.react.js", "new_path": "native/components/node-height-measurer.react.js", "diff": "@@ -404,8 +404,13 @@ class NodeHeightMeasurer<Item, MergedItem> extends React.PureComponent<\n}\n}\n- onContainerLayout(event: LayoutEvent) {\n- const { width } = event.nativeEvent.layout;\n+ onContainerLayout = (event: LayoutEvent) => {\n+ const { width, height } = event.nativeEvent.layout;\n+ if (width > height) {\n+ // We currently only use NodeHeightMeasurer on interfaces that are\n+ // portrait-locked. If we expand beyond that we'll need to rethink this\n+ return;\n+ }\nif (this.containerWidth === undefined) {\nthis.containerWidth = width;\n} else if (this.containerWidth !== width) {\n@@ -416,7 +421,7 @@ class NodeHeightMeasurer<Item, MergedItem> extends React.PureComponent<\nmeasurableItems: new Map(),\n}));\n}\n- }\n+ };\nonDummyLayout(measureKey: string, iteration: number, event: LayoutEvent) {\nif (iteration !== this.state.iteration) {\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[native] Don't measure heights while device is rotated
129,187
05.08.2020 15:23:43
14,400
27b334e2037dc296129e1e64131ac5ce006ed89e
[native] codeVersion -> 61
[ { "change_type": "MODIFY", "old_path": "native/android/app/build.gradle", "new_path": "native/android/app/build.gradle", "diff": "@@ -133,8 +133,8 @@ android {\napplicationId \"org.squadcal\"\nminSdkVersion rootProject.ext.minSdkVersion\ntargetSdkVersion rootProject.ext.targetSdkVersion\n- versionCode 60\n- versionName \"0.0.60\"\n+ versionCode 61\n+ versionName \"0.0.61\"\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.60</string>\n+ <string>0.0.61</string>\n<key>CFBundleSignature</key>\n<string>????</string>\n<key>CFBundleVersion</key>\n- <string>60</string>\n+ <string>61</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.60</string>\n+ <string>0.0.61</string>\n<key>CFBundleSignature</key>\n<string>????</string>\n<key>CFBundleVersion</key>\n- <string>60</string>\n+ <string>61</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": "@@ -175,7 +175,7 @@ const persistConfig = {\ntimeout: __DEV__ ? 0 : undefined,\n};\n-const codeVersion = 60;\n+const codeVersion = 61;\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 -> 61
129,187
05.08.2020 21:11:11
14,400
bdc6076f9d519b794a2f56223354870ad0bfc718
[server] Deprecate codeVersion < 24 These clients will now get automatically logged off and prompted to update
[ { "change_type": "MODIFY", "old_path": "server/src/session/version.js", "new_path": "server/src/session/version.js", "diff": "@@ -17,10 +17,14 @@ async function verifyClientSupported(\nthrow error;\n}\n-// eslint-disable-next-line no-unused-vars\nfunction clientSupported(platformDetails: ?PlatformDetails): boolean {\n- // In the future when we decide to deprecate server support for an old client\n- // version, we should update this function to return false for those clients\n+ if (!platformDetails || platformDetails.platform === 'web') {\n+ return true;\n+ }\n+ const { codeVersion } = platformDetails;\n+ if (!codeVersion || codeVersion < 24) {\n+ return false;\n+ }\nreturn true;\n}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[server] Deprecate codeVersion < 24 These clients will now get automatically logged off and prompted to update
129,187
05.08.2020 21:24:52
14,400
0ccd9f9a5831c33bd0191b4f55a45db18debfdb4
[server] Deprecate ping endpoint
[ { "change_type": "MODIFY", "old_path": "lib/types/endpoints.js", "new_path": "lib/types/endpoints.js", "diff": "@@ -68,7 +68,6 @@ const socketPreferredEndpoints = Object.freeze({\nCREATE_THREAD: 'create_thread',\nFETCH_MESSAGES: 'fetch_messages',\nJOIN_THREAD: 'join_thread',\n- PING: 'ping',\nCREATE_ERROR_REPORT: 'create_error_report',\nFETCH_ERROR_REPORT_INFOS: 'fetch_error_report_infos',\nREQUEST_ACCESS: 'request_access',\n" }, { "change_type": "DELETE", "old_path": "lib/types/ping-types.js", "new_path": null, "diff": "-// @flow\n-\n-import type { RawThreadInfo } from './thread-types';\n-import type { CurrentUserInfo, UserInfo } from './user-types';\n-import type { CalendarQuery, RawEntryInfo } from './entry-types';\n-import type {\n- RawMessageInfo,\n- MessageTruncationStatuses,\n- MessagesResponse,\n-} from './message-types';\n-import type { UpdatesResult } from './update-types';\n-import type { ServerRequest, ClientResponse } from './request-types';\n-import { stateSyncPayloadTypes } from './socket-types';\n-\n-export type PingRequest = {|\n- type?: PingResponseType,\n- calendarQuery: CalendarQuery,\n- watchedIDs: $ReadOnlyArray<string>,\n- lastPing?: ?number,\n- messagesCurrentAsOf: ?number,\n- updatesCurrentAsOf: ?number,\n- clientResponses?: $ReadOnlyArray<ClientResponse>,\n-|};\n-\n-export const pingResponseTypes = stateSyncPayloadTypes;\n-type PingResponseType = $Values<typeof pingResponseTypes>;\n-\n-export type PingResponse =\n- | {|\n- type: 0,\n- threadInfos: { [id: string]: RawThreadInfo },\n- currentUserInfo: CurrentUserInfo,\n- rawMessageInfos: RawMessageInfo[],\n- truncationStatuses: MessageTruncationStatuses,\n- messagesCurrentAsOf: number,\n- serverTime: number,\n- rawEntryInfos: $ReadOnlyArray<RawEntryInfo>,\n- userInfos: $ReadOnlyArray<UserInfo>,\n- updatesResult?: UpdatesResult,\n- serverRequests?: $ReadOnlyArray<ServerRequest>,\n- deltaEntryInfos?: $ReadOnlyArray<RawEntryInfo>,\n- |}\n- | {|\n- type: 1,\n- messagesResult: MessagesResponse,\n- updatesResult?: UpdatesResult,\n- deltaEntryInfos: $ReadOnlyArray<RawEntryInfo>,\n- userInfos: $ReadOnlyArray<UserInfo>,\n- serverRequests: $ReadOnlyArray<ServerRequest>,\n- |};\n" }, { "change_type": "MODIFY", "old_path": "server/src/endpoints.js", "new_path": "server/src/endpoints.js", "diff": "@@ -43,7 +43,6 @@ import {\nthreadCreationResponder,\nthreadJoinResponder,\n} from './responders/thread-responders';\n-import { pingResponder } from './responders/ping-responders';\nimport {\nreportCreationResponder,\nreportMultiCreationResponder,\n@@ -75,7 +74,6 @@ const jsonEndpoints: { [id: Endpoint]: JSONResponder } = {\ncreate_thread: threadCreationResponder,\nfetch_messages: messageFetchResponder,\njoin_thread: threadJoinResponder,\n- ping: pingResponder,\nlog_out: logOutResponder,\ndelete_account: accountDeletionResponder,\ncreate_account: accountCreationResponder,\n" }, { "change_type": "MODIFY", "old_path": "server/src/responders/ping-responders.js", "new_path": "server/src/responders/ping-responders.js", "diff": "// @flow\n-import {\n- type PingRequest,\n- type PingResponse,\n- pingResponseTypes,\n-} from 'lib/types/ping-types';\n-import { defaultNumberPerThread } from 'lib/types/message-types';\nimport type { Viewer } from '../session/viewer';\nimport {\nserverRequestTypes,\n@@ -32,11 +26,8 @@ import type { SessionUpdate } from '../updaters/session-updaters';\nimport t from 'tcomb';\nimport invariant from 'invariant';\n-import { ServerError } from 'lib/utils/errors';\n-import { mostRecentMessageTimestamp } from 'lib/shared/message-utils';\n-import { mostRecentUpdateTimestamp } from 'lib/shared/update-utils';\nimport { promiseAll } from 'lib/utils/promises';\n-import { values, hash } from 'lib/utils/objects';\n+import { hash } from 'lib/utils/objects';\nimport {\nusersInRawEntryInfos,\nserverEntryInfo,\n@@ -44,34 +35,19 @@ import {\n} from 'lib/shared/entry-utils';\nimport { usersInThreadInfo } from 'lib/shared/thread-utils';\n-import {\n- validateInput,\n- tShape,\n- tPlatform,\n- tPlatformDetails,\n-} from '../utils/validation-utils';\n-import {\n- entryQueryInputValidator,\n- normalizeCalendarQuery,\n- verifyCalendarQueryThreadIDs,\n-} from './entry-responders';\n-import { fetchMessageInfosSince } from '../fetchers/message-fetchers';\n+import { tShape, tPlatform, tPlatformDetails } from '../utils/validation-utils';\nimport { fetchThreadInfos } from '../fetchers/thread-fetchers';\nimport {\nfetchEntryInfos,\nfetchEntryInfosByID,\nfetchEntriesForSession,\n} from '../fetchers/entry-fetchers';\n-import {\n- updateActivityTime,\n- activityUpdater,\n-} from '../updaters/activity-updaters';\n+import { activityUpdater } from '../updaters/activity-updaters';\nimport {\nfetchCurrentUserInfo,\nfetchUserInfos,\nfetchKnownUserInfos,\n} from '../fetchers/user-fetchers';\n-import { fetchUpdateInfos } from '../fetchers/update-fetchers';\nimport {\nsetNewSession,\nsetCookiePlatform,\n@@ -79,9 +55,7 @@ import {\n} from '../session/cookies';\nimport { deviceTokenUpdater } from '../updaters/device-token-updaters';\nimport createReport from '../creators/report-creator';\n-import { commitSessionUpdate } from '../updaters/session-updaters';\nimport { compareNewCalendarQuery } from '../updaters/entry-updaters';\n-import { deleteUpdatesBeforeTimeTargettingSession } from '../deleters/update-deleters';\nimport { activityUpdatesInputValidator } from './activity-responders';\nimport { SQL } from '../database';\nimport {\n@@ -148,195 +122,6 @@ const clientResponseInputValidator = t.union([\n}),\n]);\n-const pingRequestInputValidator = tShape({\n- type: t.maybe(t.Number),\n- calendarQuery: entryQueryInputValidator,\n- lastPing: t.maybe(t.Number), // deprecated\n- messagesCurrentAsOf: t.maybe(t.Number),\n- updatesCurrentAsOf: t.maybe(t.Number),\n- watchedIDs: t.list(t.String),\n- clientResponses: t.maybe(t.list(clientResponseInputValidator)),\n-});\n-\n-async function pingResponder(\n- viewer: Viewer,\n- input: any,\n-): Promise<PingResponse> {\n- const request: PingRequest = input;\n- request.calendarQuery = normalizeCalendarQuery(request.calendarQuery);\n- await validateInput(viewer, pingRequestInputValidator, request);\n-\n- let clientMessagesCurrentAsOf;\n- if (\n- request.messagesCurrentAsOf !== null &&\n- request.messagesCurrentAsOf !== undefined\n- ) {\n- clientMessagesCurrentAsOf = request.messagesCurrentAsOf;\n- } else if (request.lastPing !== null && request.lastPing !== undefined) {\n- clientMessagesCurrentAsOf = request.lastPing;\n- }\n- if (\n- clientMessagesCurrentAsOf === null ||\n- clientMessagesCurrentAsOf === undefined\n- ) {\n- throw new ServerError('invalid_parameters');\n- }\n- const { calendarQuery } = request;\n- await verifyCalendarQueryThreadIDs(calendarQuery);\n-\n- const oldUpdatesCurrentAsOf = request.updatesCurrentAsOf;\n- const sessionInitializationResult = await initializeSession(\n- viewer,\n- calendarQuery,\n- oldUpdatesCurrentAsOf,\n- );\n-\n- const threadCursors = {};\n- for (let watchedThreadID of request.watchedIDs) {\n- threadCursors[watchedThreadID] = null;\n- }\n- const threadSelectionCriteria = { threadCursors, joinedThreads: true };\n- const [\n- messagesResult,\n- { serverRequests, stateCheckStatus },\n- ] = await Promise.all([\n- fetchMessageInfosSince(\n- viewer,\n- threadSelectionCriteria,\n- clientMessagesCurrentAsOf,\n- defaultNumberPerThread,\n- ),\n- processClientResponses(viewer, request.clientResponses),\n- ]);\n- const incrementalUpdate =\n- request.type === pingResponseTypes.INCREMENTAL &&\n- sessionInitializationResult.sessionContinued;\n- const messagesCurrentAsOf = mostRecentMessageTimestamp(\n- messagesResult.rawMessageInfos,\n- clientMessagesCurrentAsOf,\n- );\n-\n- const promises = {};\n- promises.activityUpdate = updateActivityTime(viewer);\n- if (\n- viewer.loggedIn &&\n- oldUpdatesCurrentAsOf !== null &&\n- oldUpdatesCurrentAsOf !== undefined\n- ) {\n- promises.deleteExpiredUpdates = deleteUpdatesBeforeTimeTargettingSession(\n- viewer,\n- oldUpdatesCurrentAsOf,\n- );\n- promises.fetchUpdateResult = fetchUpdateInfos(\n- viewer,\n- oldUpdatesCurrentAsOf,\n- calendarQuery,\n- );\n- }\n- if (incrementalUpdate && stateCheckStatus) {\n- promises.stateCheck = checkState(viewer, stateCheckStatus, calendarQuery);\n- }\n- const { fetchUpdateResult, stateCheck } = await promiseAll(promises);\n-\n- let updateUserInfos = {},\n- updatesResult = null;\n- if (fetchUpdateResult) {\n- invariant(\n- oldUpdatesCurrentAsOf !== null && oldUpdatesCurrentAsOf !== undefined,\n- 'should be set',\n- );\n- updateUserInfos = fetchUpdateResult.userInfos;\n- const { updateInfos } = fetchUpdateResult;\n- const newUpdatesCurrentAsOf = mostRecentUpdateTimestamp(\n- [...updateInfos],\n- oldUpdatesCurrentAsOf,\n- );\n- updatesResult = {\n- newUpdates: updateInfos,\n- currentAsOf: newUpdatesCurrentAsOf,\n- };\n- }\n-\n- if (incrementalUpdate) {\n- invariant(sessionInitializationResult.sessionContinued, 'should be set');\n-\n- let sessionUpdate = sessionInitializationResult.sessionUpdate;\n- if (stateCheck && stateCheck.sessionUpdate) {\n- sessionUpdate = { ...sessionUpdate, ...stateCheck.sessionUpdate };\n- }\n- await commitSessionUpdate(viewer, sessionUpdate);\n-\n- if (stateCheck && stateCheck.checkStateRequest) {\n- serverRequests.push(stateCheck.checkStateRequest);\n- }\n-\n- // $FlowFixMe should be fixed in flow-bin@0.115 / react-native@0.63\n- const incrementalUserInfos = values({\n- ...messagesResult.userInfos,\n- ...updateUserInfos,\n- ...sessionInitializationResult.deltaEntryInfoResult.userInfos,\n- });\n- const response: PingResponse = {\n- type: pingResponseTypes.INCREMENTAL,\n- messagesResult: {\n- rawMessageInfos: messagesResult.rawMessageInfos,\n- truncationStatuses: messagesResult.truncationStatuses,\n- currentAsOf: messagesCurrentAsOf,\n- },\n- deltaEntryInfos:\n- sessionInitializationResult.deltaEntryInfoResult.rawEntryInfos,\n- userInfos: incrementalUserInfos,\n- serverRequests,\n- };\n- if (updatesResult) {\n- response.updatesResult = updatesResult;\n- }\n- return response;\n- }\n-\n- const [threadsResult, entriesResult, currentUserInfo] = await Promise.all([\n- fetchThreadInfos(viewer),\n- fetchEntryInfos(viewer, [calendarQuery]),\n- fetchCurrentUserInfo(viewer),\n- ]);\n-\n- const deltaEntriesUserInfos = sessionInitializationResult.sessionContinued\n- ? sessionInitializationResult.deltaEntryInfoResult.userInfos\n- : undefined;\n- const userInfos = values({\n- ...messagesResult.userInfos,\n- ...entriesResult.userInfos,\n- ...threadsResult.userInfos,\n- ...updateUserInfos,\n- ...deltaEntriesUserInfos,\n- });\n-\n- const response: PingResponse = {\n- type: pingResponseTypes.FULL,\n- threadInfos: threadsResult.threadInfos,\n- currentUserInfo,\n- rawMessageInfos: messagesResult.rawMessageInfos,\n- truncationStatuses: messagesResult.truncationStatuses,\n- messagesCurrentAsOf,\n- serverTime: messagesCurrentAsOf,\n- rawEntryInfos: entriesResult.rawEntryInfos,\n- userInfos,\n- serverRequests,\n- };\n- if (updatesResult) {\n- response.updatesResult = updatesResult;\n- }\n- if (sessionInitializationResult.sessionContinued) {\n- // This will only happen when the client requests a FULL response, which\n- // doesn't occur in recent client versions. The client will use the result\n- // to identify entry inconsistencies.\n- response.deltaEntryInfos =\n- sessionInitializationResult.deltaEntryInfoResult.rawEntryInfos;\n- }\n-\n- return response;\n-}\n-\ntype StateCheckStatus =\n| {| status: 'state_validated' |}\n| {| status: 'state_invalid', invalidKeys: $ReadOnlyArray<string> |}\n@@ -497,7 +282,7 @@ type SessionInitializationResult =\nasync function initializeSession(\nviewer: Viewer,\ncalendarQuery: CalendarQuery,\n- oldLastUpdate: ?number,\n+ oldLastUpdate: number,\n): Promise<SessionInitializationResult> {\nif (!viewer.loggedIn) {\nreturn { sessionContinued: false };\n@@ -514,22 +299,15 @@ async function initializeSession(\nif (comparisonResult) {\nconst { difference, sessionUpdate, oldCalendarQuery } = comparisonResult;\n- if (oldLastUpdate !== null && oldLastUpdate !== undefined) {\nsessionUpdate.lastUpdate = oldLastUpdate;\n- }\nconst deltaEntryInfoResult = await fetchEntriesForSession(\nviewer,\ndifference,\noldCalendarQuery,\n);\nreturn { sessionContinued: true, deltaEntryInfoResult, sessionUpdate };\n- } else if (oldLastUpdate !== null && oldLastUpdate !== undefined) {\n- await setNewSession(viewer, calendarQuery, oldLastUpdate);\n- return { sessionContinued: false };\n} else {\n- // We're only able to create the session if we have oldLastUpdate. At this\n- // time the only code in pingResponder that uses viewer.session should be\n- // gated on oldLastUpdate anyways, so we should be okay just returning.\n+ await setNewSession(viewer, calendarQuery, oldLastUpdate);\nreturn { sessionContinued: false };\n}\n}\n@@ -786,7 +564,6 @@ async function checkState(\nexport {\nclientResponseInputValidator,\n- pingResponder,\nprocessClientResponses,\ninitializeSession,\ncheckState,\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[server] Deprecate ping endpoint
129,187
05.08.2020 21:29:35
14,400
5575f375720115c46f52ef3473e7abfe10ad35e2
[server] ping-responders.js -> session-utils.js
[ { "change_type": "RENAME", "old_path": "server/src/responders/ping-responders.js", "new_path": "server/src/socket/session-utils.js", "diff": "@@ -56,12 +56,12 @@ import {\nimport { deviceTokenUpdater } from '../updaters/device-token-updaters';\nimport createReport from '../creators/report-creator';\nimport { compareNewCalendarQuery } from '../updaters/entry-updaters';\n-import { activityUpdatesInputValidator } from './activity-responders';\n+import { activityUpdatesInputValidator } from '../responders/activity-responders';\nimport { SQL } from '../database';\nimport {\nthreadInconsistencyReportValidatorShape,\nentryInconsistencyReportValidatorShape,\n-} from './report-responders';\n+} from '../responders/report-responders';\nconst clientResponseInputValidator = t.union([\ntShape({\n" }, { "change_type": "MODIFY", "old_path": "server/src/socket/socket.js", "new_path": "server/src/socket/socket.js", "diff": "@@ -54,7 +54,7 @@ import {\nprocessClientResponses,\ninitializeSession,\ncheckState,\n-} from '../responders/ping-responders';\n+} from './session-utils';\nimport { assertSecureRequest } from '../utils/security-utils';\nimport {\nfetchViewerForSocket,\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[server] ping-responders.js -> session-utils.js
129,187
05.08.2020 21:40:07
14,400
2b96124b5215e8c4b36b18b73a35469da758a600
[server] Require platformDetails when creating new user cookie
[ { "change_type": "MODIFY", "old_path": "lib/types/account-types.js", "new_path": "lib/types/account-types.js", "diff": "@@ -49,7 +49,7 @@ export type RegisterRequest = {|\npassword: string,\ncalendarQuery?: ?CalendarQuery,\ndeviceTokenUpdateRequest?: ?DeviceTokenUpdateRequest,\n- platformDetails?: PlatformDetails,\n+ platformDetails: PlatformDetails,\n|};\nexport type RegisterResponse = {|\n@@ -103,7 +103,7 @@ export type LogInRequest = {|\npassword: string,\ncalendarQuery?: ?CalendarQuery,\ndeviceTokenUpdateRequest?: ?DeviceTokenUpdateRequest,\n- platformDetails?: PlatformDetails,\n+ platformDetails: PlatformDetails,\nwatchedIDs: $ReadOnlyArray<string>,\n|};\n@@ -140,7 +140,7 @@ export type UpdatePasswordRequest = {|\npassword: string,\ncalendarQuery?: ?CalendarQuery,\ndeviceTokenUpdateRequest?: ?DeviceTokenUpdateRequest,\n- platformDetails?: PlatformDetails,\n+ platformDetails: PlatformDetails,\nwatchedIDs: $ReadOnlyArray<string>,\n|};\n" }, { "change_type": "MODIFY", "old_path": "server/src/responders/user-responders.js", "new_path": "server/src/responders/user-responders.js", "diff": "@@ -37,7 +37,6 @@ import {\nimport {\nvalidateInput,\ntShape,\n- tPlatform,\ntPlatformDetails,\ntDeviceType,\ntPassword,\n@@ -161,21 +160,13 @@ const registerRequestInputValidator = tShape({\npassword: tPassword,\ncalendarQuery: t.maybe(newEntryQueryInputValidator),\ndeviceTokenUpdateRequest: t.maybe(deviceTokenUpdateRequestInputValidator),\n- platform: t.maybe(tPlatform),\n- platformDetails: t.maybe(tPlatformDetails),\n+ platformDetails: tPlatformDetails,\n});\nasync function accountCreationResponder(\nviewer: Viewer,\ninput: any,\n): Promise<RegisterResponse> {\n- if (!input.platformDetails && input.platform) {\n- input.platformDetails = {\n- ...viewer.platformDetails,\n- platform: input.platform,\n- };\n- delete input.platform;\n- }\nconst request: RegisterRequest = input;\nawait validateInput(viewer, registerRequestInputValidator, request);\nreturn await createAccount(viewer, request);\n@@ -187,8 +178,7 @@ const logInRequestInputValidator = tShape({\nwatchedIDs: t.list(t.String),\ncalendarQuery: t.maybe(entryQueryInputValidator),\ndeviceTokenUpdateRequest: t.maybe(deviceTokenUpdateRequestInputValidator),\n- platform: t.maybe(tPlatform),\n- platformDetails: t.maybe(tPlatformDetails),\n+ platformDetails: tPlatformDetails,\n});\nasync function logInResponder(\n@@ -196,13 +186,6 @@ async function logInResponder(\ninput: any,\n): Promise<LogInResponse> {\nawait validateInput(viewer, logInRequestInputValidator, input);\n- if (!input.platformDetails && input.platform) {\n- input.platformDetails = {\n- ...viewer.platformDetails,\n- platform: input.platform,\n- };\n- delete input.platform;\n- }\nconst request: LogInRequest = input;\nconst calendarQuery = request.calendarQuery\n@@ -298,8 +281,7 @@ const updatePasswordRequestInputValidator = tShape({\nwatchedIDs: t.list(t.String),\ncalendarQuery: t.maybe(entryQueryInputValidator),\ndeviceTokenUpdateRequest: t.maybe(deviceTokenUpdateRequestInputValidator),\n- platform: t.maybe(tPlatform),\n- platformDetails: t.maybe(tPlatformDetails),\n+ platformDetails: tPlatformDetails,\n});\nasync function passwordUpdateResponder(\n@@ -307,13 +289,6 @@ async function passwordUpdateResponder(\ninput: any,\n): Promise<LogInResponse> {\nawait validateInput(viewer, updatePasswordRequestInputValidator, input);\n- if (!input.platformDetails && input.platform) {\n- input.platformDetails = {\n- ...viewer.platformDetails,\n- platform: input.platform,\n- };\n- delete input.platform;\n- }\nconst request: UpdatePasswordRequest = input;\nif (request.calendarQuery) {\nrequest.calendarQuery = normalizeCalendarQuery(request.calendarQuery);\n" }, { "change_type": "MODIFY", "old_path": "server/src/session/cookies.js", "new_path": "server/src/session/cookies.js", "diff": "@@ -110,13 +110,13 @@ async function fetchUserViewer(\nconst cookieRow = result[0];\nlet platformDetails = null;\n- if (cookieRow.platform && cookieRow.versions) {\n+ if (cookieRow.versions) {\nplatformDetails = {\nplatform: cookieRow.platform,\ncodeVersion: cookieRow.versions.codeVersion,\nstateVersion: cookieRow.versions.stateVersion,\n};\n- } else if (cookieRow.platform) {\n+ } else {\nplatformDetails = { platform: cookieRow.platform };\n}\nconst deviceToken = cookieRow.device_token;\n@@ -570,7 +570,7 @@ function addSessionChangeInfoToResult(\nresult.cookieChange = sessionChange;\n}\n-type CookieCreationParams = $Shape<{|\n+type AnonymousCookieCreationParams = $Shape<{|\nplatformDetails: ?PlatformDetails,\ndeviceToken: ?string,\n|}>;\n@@ -584,7 +584,7 @@ const defaultPlatformDetails = {};\n// is passed to the Viewer constructor directly, the resultant Viewer object\n// will throw whenever anybody attempts to access the relevant properties.\nasync function createNewAnonymousCookie(\n- params: CookieCreationParams,\n+ params: AnonymousCookieCreationParams,\n): Promise<AnonymousViewerData> {\nconst { platformDetails, deviceToken } = params;\nconst { platform, ...versions } = platformDetails || defaultPlatformDetails;\n@@ -629,6 +629,11 @@ async function createNewAnonymousCookie(\n};\n}\n+type UserCookieCreationParams = {|\n+ platformDetails: PlatformDetails,\n+ deviceToken?: ?string,\n+|};\n+\n// The result of this function should never be passed directly to the Viewer\n// constructor. Instead, it should be passed to viewer.setNewCookie. There are\n// several fields on UserViewerData that are not set by this function:\n@@ -638,7 +643,7 @@ async function createNewAnonymousCookie(\n// will throw whenever anybody attempts to access the relevant properties.\nasync function createNewUserCookie(\nuserID: string,\n- params: CookieCreationParams,\n+ params: UserCookieCreationParams,\n): Promise<UserViewerData> {\nconst { platformDetails, deviceToken } = params;\nconst { platform, ...versions } = platformDetails || defaultPlatformDetails;\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[server] Require platformDetails when creating new user cookie
129,187
05.08.2020 21:52:44
14,400
d9ec7ed150262dc4eb1936d117ddc592e6409097
[server] Clean up processClientResponses Now that it's not called from deprecated ping code we can simplify a bit
[ { "change_type": "MODIFY", "old_path": "server/src/socket/session-utils.js", "new_path": "server/src/socket/session-utils.js", "diff": "@@ -133,7 +133,7 @@ type ProcessClientResponsesResult = {|\n|};\nasync function processClientResponses(\nviewer: Viewer,\n- clientResponses: ?$ReadOnlyArray<ClientResponse>,\n+ clientResponses: $ReadOnlyArray<ClientResponse>,\n): Promise<ProcessClientResponsesResult> {\nlet viewerMissingPlatform = !viewer.platform;\nconst { platformDetails } = viewer;\n@@ -144,13 +144,10 @@ async function processClientResponses(\nplatformDetails.codeVersion === undefined ||\nplatformDetails.stateVersion === null ||\nplatformDetails.stateVersion === undefined));\n- let viewerMissingDeviceToken =\n- isDeviceType(viewer.platform) && viewer.loggedIn && !viewer.deviceToken;\nconst promises = [];\nlet activityUpdates = [];\nlet stateCheckStatus = null;\n- if (clientResponses) {\nconst clientSentPlatformDetails = clientResponses.some(\nresponse => response.type === serverRequestTypes.PLATFORM_DETAILS,\n);\n@@ -171,14 +168,11 @@ async function processClientResponses(\ndeviceType: assertDeviceType(viewer.platform),\n}),\n);\n- viewerMissingDeviceToken = false;\n} else if (\nclientResponse.type === serverRequestTypes.THREAD_INCONSISTENCY\n) {\npromises.push(recordThreadInconsistency(viewer, clientResponse));\n- } else if (\n- clientResponse.type === serverRequestTypes.ENTRY_INCONSISTENCY\n- ) {\n+ } else if (clientResponse.type === serverRequestTypes.ENTRY_INCONSISTENCY) {\npromises.push(recordEntryInconsistency(viewer, clientResponse));\n} else if (clientResponse.type === serverRequestTypes.PLATFORM_DETAILS) {\npromises.push(\n@@ -197,10 +191,7 @@ async function processClientResponses(\n} else if (\nclientResponse.type === serverRequestTypes.INITIAL_ACTIVITY_UPDATES\n) {\n- activityUpdates = [\n- ...activityUpdates,\n- ...clientResponse.activityUpdates,\n- ];\n+ activityUpdates = [...activityUpdates, ...clientResponse.activityUpdates];\n} else if (clientResponse.type === serverRequestTypes.CHECK_STATE) {\nconst invalidKeys = [];\nfor (let key in clientResponse.hashResults) {\n@@ -215,7 +206,6 @@ async function processClientResponses(\n: { status: 'state_validated' };\n}\n}\n- }\nlet activityUpdateResult;\nif (activityUpdates.length > 0 || promises.length > 0) {\n@@ -242,9 +232,6 @@ async function processClientResponses(\nif (viewerMissingPlatformDetails) {\nserverRequests.push({ type: serverRequestTypes.PLATFORM_DETAILS });\n}\n- if (viewerMissingDeviceToken) {\n- serverRequests.push({ type: serverRequestTypes.DEVICE_TOKEN });\n- }\nreturn { serverRequests, stateCheckStatus, activityUpdateResult };\n}\n" }, { "change_type": "MODIFY", "old_path": "server/src/socket/socket.js", "new_path": "server/src/socket/socket.js", "diff": "@@ -23,7 +23,6 @@ import {\nstateCheckInactivityActivationInterval,\n} from 'lib/types/session-types';\nimport { defaultNumberPerThread } from 'lib/types/message-types';\n-import { serverRequestTypes } from 'lib/types/request-types';\nimport { redisMessageTypes, type RedisMessage } from 'lib/types/redis-types';\nimport { endpointIsSocketSafe } from 'lib/types/endpoints';\n@@ -519,21 +518,14 @@ class Socket {\n});\n}\n- // Clients that support sockets always keep their server aware of their\n- // device token, without needing any requests\n- const filteredServerRequests = serverRequests.filter(\n- request =>\n- request.type !== serverRequestTypes.DEVICE_TOKEN &&\n- request.type !== serverRequestTypes.INITIAL_ACTIVITY_UPDATES,\n- );\n- if (filteredServerRequests.length > 0 || clientResponses.length > 0) {\n+ if (serverRequests.length > 0 || clientResponses.length > 0) {\n// We send this message first since the STATE_SYNC triggers the client's\n// connection status to shift to \"connected\", and we want to make sure the\n// client responses are cleared from Redux before that happens\nresponses.unshift({\ntype: serverSocketMessageTypes.REQUESTS,\nresponseTo: message.id,\n- payload: { serverRequests: filteredServerRequests },\n+ payload: { serverRequests },\n});\n}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[server] Clean up processClientResponses Now that it's not called from deprecated ping code we can simplify a bit
129,187
05.08.2020 21:56:51
14,400
95d2327518e4bc6a2cf8efd9caadd1ca7ded2102
[server] Deprecate serverRequestTypes.DEVICE_TOKEN
[ { "change_type": "MODIFY", "old_path": "lib/types/request-types.js", "new_path": "lib/types/request-types.js", "diff": "@@ -18,7 +18,7 @@ import invariant from 'invariant';\n// clients. Clients then respond to those requests with a \"client response\".\nexport const serverRequestTypes = Object.freeze({\nPLATFORM: 0,\n- DEVICE_TOKEN: 1,\n+ //DEVICE_TOKEN: 1, (DEPRECATED)\nTHREAD_INCONSISTENCY: 2,\nPLATFORM_DETAILS: 3,\nINITIAL_ACTIVITY_UPDATE: 4,\n@@ -32,7 +32,6 @@ export function assertServerRequestType(\n): ServerRequestType {\ninvariant(\nserverRequestType === 0 ||\n- serverRequestType === 1 ||\nserverRequestType === 2 ||\nserverRequestType === 3 ||\nserverRequestType === 4 ||\n@@ -52,14 +51,6 @@ type PlatformClientResponse = {|\nplatform: Platform,\n|};\n-type DeviceTokenServerRequest = {|\n- type: 1,\n-|};\n-type DeviceTokenClientResponse = {|\n- type: 1,\n- deviceToken: string,\n-|};\n-\nexport type ThreadInconsistencyClientResponse = {|\n...ThreadInconsistencyReportShape,\ntype: 2,\n@@ -113,12 +104,10 @@ type InitialActivityUpdatesClientResponse = {|\nexport type ServerRequest =\n| PlatformServerRequest\n- | DeviceTokenServerRequest\n| PlatformDetailsServerRequest\n| CheckStateServerRequest;\nexport type ClientResponse =\n| PlatformClientResponse\n- | DeviceTokenClientResponse\n| ThreadInconsistencyClientResponse\n| PlatformDetailsClientResponse\n| InitialActivityUpdateClientResponse\n@@ -139,7 +128,6 @@ type ClientEntryInconsistencyClientResponse = {|\n|};\nexport type ClientClientResponse =\n| PlatformClientResponse\n- | DeviceTokenClientResponse\n| ClientThreadInconsistencyClientResponse\n| PlatformDetailsClientResponse\n| InitialActivityUpdateClientResponse\n" }, { "change_type": "MODIFY", "old_path": "server/src/socket/session-utils.js", "new_path": "server/src/socket/session-utils.js", "diff": "@@ -9,7 +9,7 @@ import {\ntype ServerRequest,\ntype CheckStateServerRequest,\n} from 'lib/types/request-types';\n-import { isDeviceType, assertDeviceType } from 'lib/types/device-types';\n+import { isDeviceType } from 'lib/types/device-types';\nimport {\nreportTypes,\ntype ThreadInconsistencyReportCreationRequest,\n@@ -53,7 +53,6 @@ import {\nsetCookiePlatform,\nsetCookiePlatformDetails,\n} from '../session/cookies';\n-import { deviceTokenUpdater } from '../updaters/device-token-updaters';\nimport createReport from '../creators/report-creator';\nimport { compareNewCalendarQuery } from '../updaters/entry-updaters';\nimport { activityUpdatesInputValidator } from '../responders/activity-responders';\n@@ -71,13 +70,6 @@ const clientResponseInputValidator = t.union([\n),\nplatform: tPlatform,\n}),\n- tShape({\n- type: t.irreducible(\n- 'serverRequestTypes.DEVICE_TOKEN',\n- x => x === serverRequestTypes.DEVICE_TOKEN,\n- ),\n- deviceToken: t.String,\n- }),\ntShape({\n...threadInconsistencyReportValidatorShape,\ntype: t.irreducible(\n@@ -161,13 +153,6 @@ async function processClientResponses(\nif (!isDeviceType(clientResponse.platform)) {\nviewerMissingPlatformDetails = false;\n}\n- } else if (clientResponse.type === serverRequestTypes.DEVICE_TOKEN) {\n- promises.push(\n- deviceTokenUpdater(viewer, {\n- deviceToken: clientResponse.deviceToken,\n- deviceType: assertDeviceType(viewer.platform),\n- }),\n- );\n} else if (\nclientResponse.type === serverRequestTypes.THREAD_INCONSISTENCY\n) {\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[server] Deprecate serverRequestTypes.DEVICE_TOKEN
129,187
05.08.2020 22:02:49
14,400
d005a4e82c8cbfef8731a2c56a5c6ed2e8a49e9f
[server] Deprecate serverRequestTypes.INITIAL_ACTIVITY_UPDATE
[ { "change_type": "MODIFY", "old_path": "lib/types/request-types.js", "new_path": "lib/types/request-types.js", "diff": "@@ -21,7 +21,7 @@ export const serverRequestTypes = Object.freeze({\n//DEVICE_TOKEN: 1, (DEPRECATED)\nTHREAD_INCONSISTENCY: 2,\nPLATFORM_DETAILS: 3,\n- INITIAL_ACTIVITY_UPDATE: 4,\n+ //INITIAL_ACTIVITY_UPDATE: 4, (DEPRECATED)\nENTRY_INCONSISTENCY: 5,\nCHECK_STATE: 6,\nINITIAL_ACTIVITY_UPDATES: 7,\n@@ -34,7 +34,6 @@ export function assertServerRequestType(\nserverRequestType === 0 ||\nserverRequestType === 2 ||\nserverRequestType === 3 ||\n- serverRequestType === 4 ||\nserverRequestType === 5 ||\nserverRequestType === 6 ||\nserverRequestType === 7,\n@@ -64,11 +63,6 @@ type PlatformDetailsClientResponse = {|\nplatformDetails: PlatformDetails,\n|};\n-type InitialActivityUpdateClientResponse = {|\n- type: 4,\n- threadID: string,\n-|};\n-\nexport type EntryInconsistencyClientResponse = {|\ntype: 5,\n...EntryInconsistencyReportShape,\n@@ -110,7 +104,6 @@ export type ClientResponse =\n| PlatformClientResponse\n| ThreadInconsistencyClientResponse\n| PlatformDetailsClientResponse\n- | InitialActivityUpdateClientResponse\n| EntryInconsistencyClientResponse\n| CheckStateClientResponse\n| InitialActivityUpdatesClientResponse;\n@@ -130,7 +123,6 @@ export type ClientClientResponse =\n| PlatformClientResponse\n| ClientThreadInconsistencyClientResponse\n| PlatformDetailsClientResponse\n- | InitialActivityUpdateClientResponse\n| ClientEntryInconsistencyClientResponse\n| CheckStateClientResponse\n| InitialActivityUpdatesClientResponse;\n" }, { "change_type": "MODIFY", "old_path": "lib/types/socket-types.js", "new_path": "lib/types/socket-types.js", "diff": "@@ -38,7 +38,7 @@ import PropTypes from 'prop-types';\nexport const clientSocketMessageTypes = Object.freeze({\nINITIAL: 0,\nRESPONSES: 1,\n- //ACTIVITY_UPDATES: 2,\n+ //ACTIVITY_UPDATES: 2, (DEPRECATED)\nPING: 3,\nACK_UPDATES: 4,\nAPI_REQUEST: 5,\n" }, { "change_type": "MODIFY", "old_path": "server/src/socket/session-utils.js", "new_path": "server/src/socket/session-utils.js", "diff": "@@ -91,13 +91,6 @@ const clientResponseInputValidator = t.union([\n),\nplatformDetails: tPlatformDetails,\n}),\n- tShape({\n- type: t.irreducible(\n- 'serverRequestTypes.INITIAL_ACTIVITY_UPDATE',\n- x => x === serverRequestTypes.INITIAL_ACTIVITY_UPDATE,\n- ),\n- threadID: t.String,\n- }),\ntShape({\ntype: t.irreducible(\n'serverRequestTypes.CHECK_STATE',\n@@ -165,14 +158,6 @@ async function processClientResponses(\n);\nviewerMissingPlatform = false;\nviewerMissingPlatformDetails = false;\n- } else if (\n- clientResponse.type === serverRequestTypes.INITIAL_ACTIVITY_UPDATE\n- ) {\n- promises.push(\n- activityUpdater(viewer, {\n- updates: [{ focus: true, threadID: clientResponse.threadID }],\n- }),\n- );\n} else if (\nclientResponse.type === serverRequestTypes.INITIAL_ACTIVITY_UPDATES\n) {\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[server] Deprecate serverRequestTypes.INITIAL_ACTIVITY_UPDATE
129,187
06.08.2020 11:13:05
14,400
8e04cd7e0489b75eb8c69a0915d62672df16b900
Add JSON Markdown rule This isn't really Markdown, but I want to pretty-print JSON in a `codeBlock` since `squadbot` occasionally sends me JSON blobs (for `MediaMissionReport`s, for instance).
[ { "change_type": "MODIFY", "old_path": "lib/shared/markdown.js", "new_path": "lib/shared/markdown.js", "diff": "@@ -17,6 +17,49 @@ const blockQuoteStripFollowingNewlineRegex = /^( *>[^\\n]+(?:\\n[^\\n]+)*)(?:\\n|$){\nconst urlRegex = /^(https?:\\/\\/[^\\s<]+[^<.,:;\"')\\]\\s])/i;\n+function jsonMatch(source: string) {\n+ if (!source.startsWith('{')) {\n+ return null;\n+ }\n+\n+ let jsonString = '';\n+ let counter = 0;\n+ for (let i = 0; i < source.length; i++) {\n+ const char = source[i];\n+ jsonString += char;\n+ if (char === '{') {\n+ counter++;\n+ } else if (char === '}') {\n+ counter--;\n+ }\n+ if (counter === 0) {\n+ break;\n+ }\n+ }\n+ if (counter !== 0) {\n+ return null;\n+ }\n+\n+ let json;\n+ try {\n+ json = JSON.parse(jsonString);\n+ } catch {\n+ return null;\n+ }\n+ if (!json || typeof json !== 'object') {\n+ return null;\n+ }\n+\n+ return {\n+ [0]: jsonString,\n+ json,\n+ };\n+}\n+\n+function jsonPrint(json: Object): string {\n+ return JSON.stringify(json, null, ' ');\n+}\n+\nexport {\nparagraphRegex,\nparagraphStripTrailingNewlineRegex,\n@@ -29,4 +72,6 @@ export {\ncodeBlockStripTrailingNewlineRegex,\nfenceRegex,\nfenceStripTrailingNewlineRegex,\n+ jsonMatch,\n+ jsonPrint,\n};\n" }, { "change_type": "MODIFY", "old_path": "native/markdown/rules.react.js", "new_path": "native/markdown/rules.react.js", "diff": "@@ -7,7 +7,7 @@ import * as React from 'react';\nimport { Text, Linking, Alert, View } from 'react-native';\nimport * as SimpleMarkdown from 'simple-markdown';\n-import * as MarkdownRegex from 'lib/shared/markdown';\n+import * as SharedMarkdown from 'lib/shared/markdown';\nimport { normalizeURL } from 'lib/utils/url-utils';\ntype MarkdownRuleSpec = {|\n@@ -56,7 +56,7 @@ function inlineMarkdownRules(\nurl: {\n...SimpleMarkdown.defaultRules.url,\n// simple-markdown is case-sensitive, but we don't want to be\n- match: SimpleMarkdown.inlineRegex(MarkdownRegex.urlRegex),\n+ match: SimpleMarkdown.inlineRegex(SharedMarkdown.urlRegex),\n},\n// Matches '[Google](https://google.com)' during parse phase and handles\n// rendering all 'link' nodes, including for 'autolink' and 'url'\n@@ -88,9 +88,9 @@ function inlineMarkdownRules(\nif (state.inline) {\nreturn null;\n} else if (state.container === 'View') {\n- return MarkdownRegex.paragraphStripTrailingNewlineRegex.exec(source);\n+ return SharedMarkdown.paragraphStripTrailingNewlineRegex.exec(source);\n} else {\n- return MarkdownRegex.paragraphRegex.exec(source);\n+ return SharedMarkdown.paragraphRegex.exec(source);\n}\n},\nparse(\n@@ -216,7 +216,7 @@ function fullMarkdownRules(\nheading: {\n...SimpleMarkdown.defaultRules.heading,\nmatch: SimpleMarkdown.blockRegex(\n- MarkdownRegex.headingStripFollowingNewlineRegex,\n+ SharedMarkdown.headingStripFollowingNewlineRegex,\n),\n// eslint-disable-next-line react/display-name\nreact(\n@@ -236,7 +236,7 @@ function fullMarkdownRules(\n...SimpleMarkdown.defaultRules.blockQuote,\n// match end of blockQuote by either \\n\\n or end of string\nmatch: SimpleMarkdown.blockRegex(\n- MarkdownRegex.blockQuoteStripFollowingNewlineRegex,\n+ SharedMarkdown.blockQuoteStripFollowingNewlineRegex,\n),\nparse(\ncapture: SimpleMarkdown.Capture,\n@@ -262,7 +262,7 @@ function fullMarkdownRules(\ncodeBlock: {\n...SimpleMarkdown.defaultRules.codeBlock,\nmatch: SimpleMarkdown.blockRegex(\n- MarkdownRegex.codeBlockStripTrailingNewlineRegex,\n+ SharedMarkdown.codeBlockStripTrailingNewlineRegex,\n),\nparse(capture: SimpleMarkdown.Capture) {\nreturn {\n@@ -285,14 +285,25 @@ function fullMarkdownRules(\nfence: {\n...SimpleMarkdown.defaultRules.fence,\nmatch: SimpleMarkdown.blockRegex(\n- MarkdownRegex.fenceStripTrailingNewlineRegex,\n+ SharedMarkdown.fenceStripTrailingNewlineRegex,\n),\n- parse(capture: SimpleMarkdown.Capture) {\n- return {\n+ parse: (capture: SimpleMarkdown.Capture) => ({\ntype: 'codeBlock',\ncontent: capture[2],\n- };\n+ }),\n},\n+ json: {\n+ order: SimpleMarkdown.defaultRules.paragraph.order - 1,\n+ match: (source: string, state: SimpleMarkdown.State) => {\n+ if (state.inline) {\n+ return null;\n+ }\n+ return SharedMarkdown.jsonMatch(source);\n+ },\n+ parse: (capture: SimpleMarkdown.Capture) => ({\n+ type: 'codeBlock',\n+ content: SharedMarkdown.jsonPrint(capture.json),\n+ }),\n},\n};\nreturn {\n" }, { "change_type": "MODIFY", "old_path": "web/markdown/markdown.css", "new_path": "web/markdown/markdown.css", "diff": "@@ -40,12 +40,24 @@ div.darkBackground code {\nbackground: #222222;\ncolor: #F3F3F3;\n}\n+\n+div.markdown pre {\n+ padding: .5em 10px;\n+ border-radius: 5px;\n+}\n+div.lightBackground pre {\n+ background: #DCDCDC;\n+ color: #222222;\n+}\n+div.darkBackground pre {\n+ background: #222222;\n+ color: #F3F3F3;\n+}\ndiv.markdown pre > code {\nwidth: 100%;\ndisplay: inline-block;\n- padding: .5em 10px;\nbox-sizing: border-box;\n- border-radius: 5px;\ntab-size: 2;\nmargin: 0 0 6px 0;\n+ overflow-x: scroll;\n}\n" }, { "change_type": "MODIFY", "old_path": "web/markdown/rules.react.js", "new_path": "web/markdown/rules.react.js", "diff": "import * as SimpleMarkdown from 'simple-markdown';\nimport * as React from 'react';\n-import * as MarkdownRegex from 'lib/shared/markdown';\n+import * as SharedMarkdown from 'lib/shared/markdown';\ntype MarkdownRuleSpec = {|\n+simpleMarkdownRules: SimpleMarkdown.Rules,\n@@ -36,7 +36,7 @@ function linkRules(): MarkdownRuleSpec {\n},\nparagraph: {\n...SimpleMarkdown.defaultRules.paragraph,\n- match: SimpleMarkdown.blockRegex(MarkdownRegex.paragraphRegex),\n+ match: SimpleMarkdown.blockRegex(SharedMarkdown.paragraphRegex),\n// eslint-disable-next-line react/display-name\nreact: (\nnode: SimpleMarkdown.SingleASTNode,\n@@ -51,7 +51,7 @@ function linkRules(): MarkdownRuleSpec {\ntext: SimpleMarkdown.defaultRules.text,\nurl: {\n...SimpleMarkdown.defaultRules.url,\n- match: SimpleMarkdown.inlineRegex(MarkdownRegex.urlRegex),\n+ match: SimpleMarkdown.inlineRegex(SharedMarkdown.urlRegex),\n},\n};\nreturn {\n@@ -73,7 +73,7 @@ function markdownRules(): MarkdownRuleSpec {\nblockQuote: {\n...SimpleMarkdown.defaultRules.blockQuote,\n// match end of blockQuote by either \\n\\n or end of string\n- match: SimpleMarkdown.blockRegex(MarkdownRegex.blockQuoteRegex),\n+ match: SimpleMarkdown.blockRegex(SharedMarkdown.blockQuoteRegex),\nparse(\ncapture: SimpleMarkdown.Capture,\nparse: SimpleMarkdown.Parser,\n@@ -92,24 +92,37 @@ function markdownRules(): MarkdownRuleSpec {\nu: SimpleMarkdown.defaultRules.u,\nheading: {\n...SimpleMarkdown.defaultRules.heading,\n- match: SimpleMarkdown.blockRegex(MarkdownRegex.headingRegex),\n+ match: SimpleMarkdown.blockRegex(SharedMarkdown.headingRegex),\n},\nmailto: SimpleMarkdown.defaultRules.mailto,\ncodeBlock: {\n...SimpleMarkdown.defaultRules.codeBlock,\n- match: SimpleMarkdown.blockRegex(MarkdownRegex.codeBlockRegex),\n+ match: SimpleMarkdown.blockRegex(SharedMarkdown.codeBlockRegex),\nparse: (capture: SimpleMarkdown.Capture) => ({\ncontent: capture[0].replace(/^ {4}/gm, ''),\n}),\n},\nfence: {\n...SimpleMarkdown.defaultRules.fence,\n- match: SimpleMarkdown.blockRegex(MarkdownRegex.fenceRegex),\n+ match: SimpleMarkdown.blockRegex(SharedMarkdown.fenceRegex),\nparse: (capture: SimpleMarkdown.Capture) => ({\ntype: 'codeBlock',\ncontent: capture[2],\n}),\n},\n+ json: {\n+ order: SimpleMarkdown.defaultRules.paragraph.order - 1,\n+ match: (source: string, state: SimpleMarkdown.State) => {\n+ if (state.inline) {\n+ return null;\n+ }\n+ return SharedMarkdown.jsonMatch(source);\n+ },\n+ parse: (capture: SimpleMarkdown.Capture) => ({\n+ type: 'codeBlock',\n+ content: SharedMarkdown.jsonPrint(capture.json),\n+ }),\n+ },\n};\nreturn {\n...linkMarkdownRules,\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Add JSON Markdown rule This isn't really Markdown, but I want to pretty-print JSON in a `codeBlock` since `squadbot` occasionally sends me JSON blobs (for `MediaMissionReport`s, for instance).
129,187
06.08.2020 15:58:10
14,400
209be2fb483e21cf7913b82a71ec914f27654206
[lib] Only issue inconsistency reports due to state check We can now rely on the "new" method (ie. `UpdateInfo`s) in reducers instead of the old method (returning updated data structures directly).
[ { "change_type": "MODIFY", "old_path": "lib/reducers/entry-reducer.js", "new_path": "lib/reducers/entry-reducer.js", "diff": "@@ -103,10 +103,12 @@ function filterExistingDaysToEntriesWithNewEntryInfos(\nfunction mergeNewEntryInfos(\ncurrentEntryInfos: { [id: string]: RawEntryInfo },\n+ currentDaysToEntries: ?{ [day: string]: string[] },\nnewEntryInfos: $ReadOnlyArray<RawEntryInfo>,\nthreadInfos: { [id: string]: RawThreadInfo },\n) {\nconst mergedEntryInfos = {};\n+ let someEntryUpdated = false;\nfor (let rawEntryInfo of newEntryInfos) {\nconst serverID = rawEntryInfo.id;\n@@ -144,10 +146,10 @@ function mergeNewEntryInfos(\nif (_isEqual(currentEntryInfo)(newEntryInfo)) {\nmergedEntryInfos[serverID] = currentEntryInfo;\n- continue;\n- }\n-\n+ } else {\nmergedEntryInfos[serverID] = newEntryInfo;\n+ someEntryUpdated = true;\n+ }\n}\nfor (let id in currentEntryInfos) {\n@@ -160,12 +162,17 @@ function mergeNewEntryInfos(\nfor (let id in mergedEntryInfos) {\nconst entryInfo = mergedEntryInfos[id];\nif (!threadInFilterList(threadInfos[entryInfo.threadID])) {\n+ someEntryUpdated = true;\ndelete mergedEntryInfos[id];\n}\n}\n- const daysToEntries = daysToEntriesFromEntryInfos(values(mergedEntryInfos));\n- return [mergedEntryInfos, daysToEntries];\n+ const daysToEntries =\n+ !currentDaysToEntries || someEntryUpdated\n+ ? daysToEntriesFromEntryInfos(values(mergedEntryInfos))\n+ : currentDaysToEntries;\n+ const entryInfos = someEntryUpdated ? mergedEntryInfos : currentEntryInfos;\n+ return [entryInfos, daysToEntries];\n}\nfunction reduceEntryInfos(\n@@ -242,6 +249,7 @@ function reduceEntryInfos(\n} else if (action.type === fetchEntriesActionTypes.success) {\nconst [updatedEntryInfos, updatedDaysToEntries] = mergeNewEntryInfos(\nentryInfos,\n+ daysToEntries,\naction.payload.rawEntryInfos,\nnewThreadInfos,\n);\n@@ -268,6 +276,7 @@ function reduceEntryInfos(\n: lastUserInteractionCalendar;\nconst [updatedEntryInfos, updatedDaysToEntries] = mergeNewEntryInfos(\nentryInfos,\n+ daysToEntries,\naction.payload.rawEntryInfos,\nnewThreadInfos,\n);\n@@ -327,41 +336,18 @@ function reduceEntryInfos(\nreturn entryStore;\n}\n- const updatedEntryInfos = {\n- ...rekeyedEntryInfos,\n- [serverID]: {\n- ...rekeyedEntryInfos[serverID],\n- id: serverID,\n- localID,\n- text: action.payload.text,\n- },\n- };\n- const newDaysToEntries = daysToEntriesFromEntryInfos(\n- values(updatedEntryInfos),\n- );\n-\n- const updateEntryInfos = mergeUpdateEntryInfos(\n- [],\n- action.payload.updatesResult.viewerUpdates,\n- );\n- const [newUpdatedEntryInfos] = mergeNewEntryInfos(\n+ const [updatedEntryInfos, updatedDaysToEntries] = mergeNewEntryInfos(\nrekeyedEntryInfos,\n- updateEntryInfos,\n+ null,\n+ mergeUpdateEntryInfos([], action.payload.updatesResult.viewerUpdates),\nnewThreadInfos,\n);\n- const newInconsistencies = findInconsistencies(\n- entryInfos,\n- action,\n- updatedEntryInfos,\n- newUpdatedEntryInfos,\n- action.payload.calendarQuery,\n- );\nreturn {\nentryInfos: updatedEntryInfos,\n- daysToEntries: newDaysToEntries,\n+ daysToEntries: updatedDaysToEntries,\nlastUserInteractionCalendar: Date.now(),\n- inconsistencyReports: [...inconsistencyReports, ...newInconsistencies],\n+ inconsistencyReports,\n};\n} else if (action.type === saveEntryActionTypes.success) {\nconst serverID = action.payload.entryID;\n@@ -372,39 +358,22 @@ function reduceEntryInfos(\n// This happens if the entry is deauthorized before it's saved\nreturn entryStore;\n}\n- const updatedEntryInfos = {\n- ...entryInfos,\n- [serverID]: {\n- ...entryInfos[serverID],\n- text: action.payload.text,\n- },\n- };\n- const updateEntryInfos = mergeUpdateEntryInfos(\n- [],\n- action.payload.updatesResult.viewerUpdates,\n- );\n- const [newUpdatedEntryInfos] = mergeNewEntryInfos(\n+ const [updatedEntryInfos, updatedDaysToEntries] = mergeNewEntryInfos(\nentryInfos,\n- updateEntryInfos,\n+ daysToEntries,\n+ mergeUpdateEntryInfos([], action.payload.updatesResult.viewerUpdates),\nnewThreadInfos,\n);\n- const newInconsistencies = findInconsistencies(\n- entryInfos,\n- action,\n- updatedEntryInfos,\n- newUpdatedEntryInfos,\n- action.payload.calendarQuery,\n- );\nreturn {\nentryInfos: updatedEntryInfos,\n- daysToEntries,\n+ daysToEntries: updatedDaysToEntries,\nlastUserInteractionCalendar: Date.now(),\n- inconsistencyReports: [...inconsistencyReports, ...newInconsistencies],\n+ inconsistencyReports,\n};\n} else if (action.type === concurrentModificationResetActionType) {\n- const payload = action.payload;\n+ const { payload } = action;\nif (\n!entryInfos[payload.id] ||\n!threadInFilterList(newThreadInfos[entryInfos[payload.id].threadID])\n@@ -447,27 +416,17 @@ function reduceEntryInfos(\n};\n} else if (action.type === deleteEntryActionTypes.success && action.payload) {\nconst { payload } = action;\n- const updateEntryInfos = mergeUpdateEntryInfos(\n- [],\n- payload.updatesResult.viewerUpdates,\n- );\n- const [newUpdatedEntryInfos] = mergeNewEntryInfos(\n+ const [updatedEntryInfos, updatedDaysToEntries] = mergeNewEntryInfos(\nentryInfos,\n- updateEntryInfos,\n+ daysToEntries,\n+ mergeUpdateEntryInfos([], payload.updatesResult.viewerUpdates),\nnewThreadInfos,\n);\n- const newInconsistencies = findInconsistencies(\n- entryInfos,\n- action,\n- entryInfos,\n- newUpdatedEntryInfos,\n- payload.calendarQuery,\n- );\nreturn {\n- entryInfos,\n- daysToEntries,\n+ entryInfos: updatedEntryInfos,\n+ daysToEntries: updatedDaysToEntries,\nlastUserInteractionCalendar,\n- inconsistencyReports: [...inconsistencyReports, ...newInconsistencies],\n+ inconsistencyReports,\n};\n} else if (action.type === fetchRevisionsForEntryActionTypes.success) {\nconst id = action.payload.entryID;\n@@ -494,45 +453,28 @@ function reduceEntryInfos(\ninconsistencyReports,\n};\n} else if (action.type === restoreEntryActionTypes.success) {\n- const entryInfo = action.payload.entryInfo;\n- const key = entryID(entryInfo);\n- const updatedEntryInfos = {\n- ...entryInfos,\n- [key]: entryInfo,\n- };\n-\n- const updateEntryInfos = mergeUpdateEntryInfos(\n- [],\n- action.payload.updatesResult.viewerUpdates,\n- );\n- const [newUpdatedEntryInfos] = mergeNewEntryInfos(\n+ const [updatedEntryInfos, updatedDaysToEntries] = mergeNewEntryInfos(\nentryInfos,\n- updateEntryInfos,\n+ daysToEntries,\n+ mergeUpdateEntryInfos([], action.payload.updatesResult.viewerUpdates),\nnewThreadInfos,\n);\n- const newInconsistencies = findInconsistencies(\n- entryInfos,\n- action,\n- updatedEntryInfos,\n- newUpdatedEntryInfos,\n- action.payload.calendarQuery,\n- );\n-\nreturn {\nentryInfos: updatedEntryInfos,\n- daysToEntries,\n+ daysToEntries: updatedDaysToEntries,\nlastUserInteractionCalendar: Date.now(),\n- inconsistencyReports: [...inconsistencyReports, ...newInconsistencies],\n+ inconsistencyReports,\n};\n} else if (\naction.type === logInActionTypes.success ||\naction.type === resetPasswordActionTypes.success ||\naction.type === joinThreadActionTypes.success\n) {\n- const calendarResult = action.payload.calendarResult;\n+ const { calendarResult } = action.payload;\nif (calendarResult) {\nconst [updatedEntryInfos, updatedDaysToEntries] = mergeNewEntryInfos(\nentryInfos,\n+ daysToEntries,\ncalendarResult.rawEntryInfos,\nnewThreadInfos,\n);\n@@ -544,13 +486,13 @@ function reduceEntryInfos(\n};\n}\n} else if (action.type === incrementalStateSyncActionType) {\n- const updateEntryInfos = mergeUpdateEntryInfos(\n- action.payload.deltaEntryInfos,\n- action.payload.updatesResult.newUpdates,\n- );\nconst [updatedEntryInfos, updatedDaysToEntries] = mergeNewEntryInfos(\nentryInfos,\n- updateEntryInfos,\n+ daysToEntries,\n+ mergeUpdateEntryInfos(\n+ action.payload.deltaEntryInfos,\n+ action.payload.updatesResult.newUpdates,\n+ ),\nnewThreadInfos,\n);\nconst deletionMarkedEntryInfos = markDeletedEntries(\n@@ -564,13 +506,10 @@ function reduceEntryInfos(\ninconsistencyReports,\n};\n} else if (action.type === processUpdatesActionType) {\n- const updateEntryInfos = mergeUpdateEntryInfos(\n- [],\n- action.payload.updatesResult.newUpdates,\n- );\nconst [updatedEntryInfos, updatedDaysToEntries] = mergeNewEntryInfos(\nentryInfos,\n- updateEntryInfos,\n+ daysToEntries,\n+ mergeUpdateEntryInfos([], action.payload.updatesResult.newUpdates),\nnewThreadInfos,\n);\nreturn {\n@@ -582,6 +521,7 @@ function reduceEntryInfos(\n} else if (action.type === fullStateSyncActionType) {\nconst [updatedEntryInfos, updatedDaysToEntries] = mergeNewEntryInfos(\nentryInfos,\n+ daysToEntries,\naction.payload.rawEntryInfos,\nnewThreadInfos,\n);\n@@ -654,6 +594,7 @@ function reduceEntryInfos(\nif (rawEntryInfos) {\n[updatedEntryInfos, updatedDaysToEntries] = mergeNewEntryInfos(\nupdatedEntryInfos,\n+ null,\nrawEntryInfos,\nnewThreadInfos,\n);\n" }, { "change_type": "MODIFY", "old_path": "lib/reducers/thread-reducer.js", "new_path": "lib/reducers/thread-reducer.js", "diff": "@@ -173,51 +173,17 @@ export default function reduceThreadInfos(\naction.type === deleteThreadActionTypes.success ||\naction.type === changeThreadSettingsActionTypes.success ||\naction.type === removeUsersFromThreadActionTypes.success ||\n- action.type === changeThreadMemberRolesActionTypes.success\n- ) {\n- if (\n- _isEqual(state.threadInfos)(action.payload.threadInfos) &&\n- action.payload.updatesResult.newUpdates.length === 0\n- ) {\n- return state;\n- }\n- const oldResult = action.payload.threadInfos;\n- const newResult = reduceThreadUpdates(state.threadInfos, action.payload);\n- return {\n- threadInfos: oldResult,\n- inconsistencyReports: [\n- ...state.inconsistencyReports,\n- ...findInconsistencies(state.threadInfos, action, oldResult, newResult),\n- ],\n- };\n- } else if (\n+ action.type === changeThreadMemberRolesActionTypes.success ||\naction.type === incrementalStateSyncActionType ||\n- action.type === processUpdatesActionType\n- ) {\n- const updateResult = reduceThreadUpdates(state.threadInfos, action.payload);\n- return {\n- threadInfos: updateResult,\n- inconsistencyReports: state.inconsistencyReports,\n- };\n- } else if (action.type === newThreadActionTypes.success) {\n- const newThreadInfo = action.payload.newThreadInfo;\n- if (\n- _isEqual(state.threadInfos[newThreadInfo.id])(newThreadInfo) &&\n- action.payload.updatesResult.newUpdates.length === 0\n+ action.type === processUpdatesActionType ||\n+ action.type === newThreadActionTypes.success\n) {\n+ if (action.payload.updatesResult.newUpdates.length === 0) {\nreturn state;\n}\n- const oldResult = {\n- ...state.threadInfos,\n- [newThreadInfo.id]: newThreadInfo,\n- };\n- const newResult = reduceThreadUpdates(state.threadInfos, action.payload);\nreturn {\n- threadInfos: oldResult,\n- inconsistencyReports: [\n- ...state.inconsistencyReports,\n- ...findInconsistencies(state.threadInfos, action, oldResult, newResult),\n- ],\n+ threadInfos: reduceThreadUpdates(state.threadInfos, action.payload),\n+ inconsistencyReports: state.inconsistencyReports,\n};\n} else if (action.type === updateSubscriptionActionTypes.success) {\nconst newThreadInfos = {\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[lib] Only issue inconsistency reports due to state check We can now rely on the "new" method (ie. `UpdateInfo`s) in reducers instead of the old method (returning updated data structures directly).
129,187
06.08.2020 16:30:04
14,400
14788d4e8d38be3df43073d419c3f9c755b7250d
[lib] Clean up pre-UpdateInfo params from thread actions
[ { "change_type": "MODIFY", "old_path": "lib/actions/thread-actions.js", "new_path": "lib/actions/thread-actions.js", "diff": "// @flow\nimport type {\n- ChangeThreadSettingsResult,\n+ ChangeThreadSettingsPayload,\nLeaveThreadPayload,\nUpdateThreadRequest,\nNewThreadRequest,\n@@ -30,8 +30,6 @@ async function deleteThread(\naccountPassword: currentAccountPassword,\n});\nreturn {\n- threadID,\n- threadInfos: response.threadInfos,\nupdatesResult: response.updatesResult,\n};\n}\n@@ -44,15 +42,14 @@ const changeThreadSettingsActionTypes = Object.freeze({\nasync function changeThreadSettings(\nfetchJSON: FetchJSON,\nrequest: UpdateThreadRequest,\n-): Promise<ChangeThreadSettingsResult> {\n+): Promise<ChangeThreadSettingsPayload> {\nconst response = await fetchJSON('update_thread', request);\ninvariant(\nObject.keys(request.changes).length > 0,\n'No changes provided to changeThreadSettings!',\n);\nreturn {\n- threadInfo: response.threadInfo,\n- threadInfos: response.threadInfos,\n+ threadID: request.threadID,\nupdatesResult: response.updatesResult,\nnewMessageInfos: response.newMessageInfos,\n};\n@@ -67,14 +64,13 @@ async function removeUsersFromThread(\nfetchJSON: FetchJSON,\nthreadID: string,\nmemberIDs: string[],\n-): Promise<ChangeThreadSettingsResult> {\n+): Promise<ChangeThreadSettingsPayload> {\nconst response = await fetchJSON('remove_members', {\nthreadID,\nmemberIDs,\n});\nreturn {\n- threadInfo: response.threadInfo,\n- threadInfos: response.threadInfos,\n+ threadID,\nupdatesResult: response.updatesResult,\nnewMessageInfos: response.newMessageInfos,\n};\n@@ -90,15 +86,14 @@ async function changeThreadMemberRoles(\nthreadID: string,\nmemberIDs: string[],\nnewRole: string,\n-): Promise<ChangeThreadSettingsResult> {\n+): Promise<ChangeThreadSettingsPayload> {\nconst response = await fetchJSON('update_role', {\nthreadID,\nmemberIDs,\nrole: newRole,\n});\nreturn {\n- threadInfo: response.threadInfo,\n- threadInfos: response.threadInfos,\n+ threadID,\nupdatesResult: response.updatesResult,\nnewMessageInfos: response.newMessageInfos,\n};\n@@ -133,8 +128,6 @@ async function joinThread(\nconst response = await fetchJSON('join_thread', request);\nconst userInfos = values(response.userInfos);\nreturn {\n- threadID: request.threadID,\n- threadInfos: response.threadInfos,\nupdatesResult: response.updatesResult,\nrawMessageInfos: response.rawMessageInfos,\ntruncationStatuses: response.truncationStatuses,\n@@ -158,8 +151,6 @@ async function leaveThread(\n): Promise<LeaveThreadPayload> {\nconst response = await fetchJSON('leave_thread', { threadID });\nreturn {\n- threadID,\n- threadInfos: response.threadInfos,\nupdatesResult: response.updatesResult,\n};\n}\n" }, { "change_type": "MODIFY", "old_path": "lib/reducers/message-reducer.js", "new_path": "lib/reducers/message-reducer.js", "diff": "@@ -581,7 +581,7 @@ function reduceMessageStore(\nreturn mergeNewMessages(\nmessageStore,\naction.payload.newMessageInfos,\n- { [action.payload.threadInfo.id]: messageTruncationStatus.UNCHANGED },\n+ { [action.payload.threadID]: messageTruncationStatus.UNCHANGED },\nnewThreadInfos,\naction.type,\n);\n" }, { "change_type": "MODIFY", "old_path": "lib/shared/thread-utils.js", "new_path": "lib/shared/thread-utils.js", "diff": "@@ -11,6 +11,7 @@ import {\nthreadPermissions,\n} from '../types/thread-types';\nimport type { UserInfo } from '../types/user-types';\n+import { type UpdateInfo, updateTypes } from '../types/update-types';\nimport tinycolor from 'tinycolor2';\n@@ -272,13 +273,12 @@ function memberIsAdmin(memberInfo: RelativeMemberInfo, threadInfo: ThreadInfo) {\n}\nfunction identifyInvalidatedThreads(\n- prevThreadInfos: { [id: string]: RawThreadInfo },\n- newThreadInfos: { [id: string]: RawThreadInfo },\n+ updateInfos: $ReadOnlyArray<UpdateInfo>,\n): Set<string> {\nconst invalidated = new Set();\n- for (let threadID in prevThreadInfos) {\n- if (!newThreadInfos[threadID]) {\n- invalidated.add(threadID);\n+ for (const updateInfo of updateInfos) {\n+ if (updateInfo.type === updateTypes.DELETE_THREAD) {\n+ invalidated.add(updateInfo.threadID);\n}\n}\nreturn invalidated;\n" }, { "change_type": "MODIFY", "old_path": "lib/types/redux-types.js", "new_path": "lib/types/redux-types.js", "diff": "import type {\nThreadStore,\n- ChangeThreadSettingsResult,\n+ ChangeThreadSettingsPayload,\nLeaveThreadPayload,\nNewThreadResult,\nThreadJoinPayload,\n@@ -329,7 +329,7 @@ export type BaseAction =\n|}\n| {|\ntype: 'CHANGE_THREAD_SETTINGS_SUCCESS',\n- payload: ChangeThreadSettingsResult,\n+ payload: ChangeThreadSettingsPayload,\nloadingInfo: LoadingInfo,\n|}\n| {|\n@@ -377,7 +377,7 @@ export type BaseAction =\n|}\n| {|\ntype: 'REMOVE_USERS_FROM_THREAD_SUCCESS',\n- payload: ChangeThreadSettingsResult,\n+ payload: ChangeThreadSettingsPayload,\nloadingInfo: LoadingInfo,\n|}\n| {|\n@@ -393,7 +393,7 @@ export type BaseAction =\n|}\n| {|\ntype: 'CHANGE_THREAD_MEMBER_ROLES_SUCCESS',\n- payload: ChangeThreadSettingsResult,\n+ payload: ChangeThreadSettingsPayload,\nloadingInfo: LoadingInfo,\n|}\n| {|\n" }, { "change_type": "MODIFY", "old_path": "lib/types/thread-types.js", "new_path": "lib/types/thread-types.js", "diff": "@@ -270,6 +270,14 @@ export type ChangeThreadSettingsResult = {|\nnewMessageInfos: $ReadOnlyArray<RawMessageInfo>,\n|};\n+export type ChangeThreadSettingsPayload = {|\n+ threadID: string,\n+ updatesResult: {\n+ newUpdates: $ReadOnlyArray<UpdateInfo>,\n+ },\n+ newMessageInfos: $ReadOnlyArray<RawMessageInfo>,\n+|};\n+\nexport type LeaveThreadRequest = {|\nthreadID: string,\n|};\n@@ -281,8 +289,9 @@ export type LeaveThreadResult = {|\n|};\nexport type LeaveThreadPayload = {|\n- ...LeaveThreadResult,\n- threadID: string,\n+ updatesResult: {\n+ newUpdates: $ReadOnlyArray<UpdateInfo>,\n+ },\n|};\nexport type ThreadChanges = $Shape<{|\n@@ -335,8 +344,6 @@ export type ThreadJoinResult = {|\nrawEntryInfos?: ?$ReadOnlyArray<RawEntryInfo>,\n|};\nexport type ThreadJoinPayload = {|\n- threadID: string,\n- threadInfos: { [id: string]: RawThreadInfo },\nupdatesResult: {\nnewUpdates: $ReadOnlyArray<UpdateInfo>,\n},\n" }, { "change_type": "MODIFY", "old_path": "native/chat/settings/add-users-modal.react.js", "new_path": "native/chat/settings/add-users-modal.react.js", "diff": "@@ -4,7 +4,7 @@ import type { AppState } from '../../redux/redux-setup';\nimport {\ntype ThreadInfo,\nthreadInfoPropType,\n- type ChangeThreadSettingsResult,\n+ type ChangeThreadSettingsPayload,\ntype UpdateThreadRequest,\n} from 'lib/types/thread-types';\nimport {\n@@ -72,7 +72,7 @@ type Props = {|\n// async functions that hit server APIs\nchangeThreadSettings: (\nrequest: UpdateThreadRequest,\n- ) => Promise<ChangeThreadSettingsResult>,\n+ ) => Promise<ChangeThreadSettingsPayload>,\nsearchUsers: (usernamePrefix: string) => Promise<UserSearchResult>,\n|};\ntype State = {|\n" }, { "change_type": "MODIFY", "old_path": "native/chat/settings/color-picker-modal.react.js", "new_path": "native/chat/settings/color-picker-modal.react.js", "diff": "@@ -5,7 +5,7 @@ import type { DispatchActionPromise } from 'lib/utils/action-utils';\nimport {\ntype ThreadInfo,\nthreadInfoPropType,\n- type ChangeThreadSettingsResult,\n+ type ChangeThreadSettingsPayload,\ntype UpdateThreadRequest,\n} from 'lib/types/thread-types';\nimport type { RootNavigationProp } from '../../navigation/root-navigator.react';\n@@ -50,7 +50,7 @@ type Props = {|\n// async functions that hit server APIs\nchangeThreadSettings: (\nrequest: UpdateThreadRequest,\n- ) => Promise<ChangeThreadSettingsResult>,\n+ ) => Promise<ChangeThreadSettingsPayload>,\n|};\nclass ColorPickerModal extends React.PureComponent<Props> {\nstatic propTypes = {\n" }, { "change_type": "MODIFY", "old_path": "native/chat/settings/delete-thread.react.js", "new_path": "native/chat/settings/delete-thread.react.js", "diff": "@@ -8,8 +8,6 @@ import {\ntype ThreadInfo,\nthreadInfoPropType,\ntype LeaveThreadPayload,\n- type RawThreadInfo,\n- rawThreadInfoPropType,\n} from 'lib/types/thread-types';\nimport { type GlobalTheme, globalThemePropType } from '../../types/themes';\nimport type { ChatNavigationProp } from '../chat.react';\n@@ -65,7 +63,6 @@ type Props = {|\nactiveTheme: ?GlobalTheme,\ncolors: Colors,\nstyles: typeof styles,\n- rawThreadInfos: { [id: string]: RawThreadInfo },\n// Redux dispatch functions\ndispatchActionPromise: DispatchActionPromise,\n// async functions that hit server APIs\n@@ -96,7 +93,6 @@ class DeleteThread extends React.PureComponent<Props, State> {\nactiveTheme: globalThemePropType,\ncolors: colorsPropType.isRequired,\nstyles: PropTypes.objectOf(PropTypes.object).isRequired,\n- rawThreadInfos: PropTypes.objectOf(rawThreadInfoPropType).isRequired,\ndispatchActionPromise: PropTypes.func.isRequired,\ndeleteThread: PropTypes.func.isRequired,\nnavContext: navContextPropType,\n@@ -247,8 +243,7 @@ class DeleteThread extends React.PureComponent<Props, State> {\nthis.state.password,\n);\nconst invalidated = identifyInvalidatedThreads(\n- this.props.rawThreadInfos,\n- result.threadInfos,\n+ result.updatesResult.newUpdates,\n);\nnavContext.dispatch({\ntype: clearThreadsActionType,\n@@ -358,7 +353,6 @@ export default connect(\nactiveTheme: state.globalThemeInfo.activeTheme,\ncolors: colorsSelector(state),\nstyles: stylesSelector(state),\n- rawThreadInfos: state.threadStore.threadInfos,\n};\n},\n{ deleteThread },\n" }, { "change_type": "MODIFY", "old_path": "native/chat/settings/thread-settings-description.react.js", "new_path": "native/chat/settings/thread-settings-description.react.js", "diff": "@@ -4,7 +4,7 @@ import {\ntype ThreadInfo,\nthreadInfoPropType,\nthreadPermissions,\n- type ChangeThreadSettingsResult,\n+ type ChangeThreadSettingsPayload,\ntype UpdateThreadRequest,\n} from 'lib/types/thread-types';\nimport type { DispatchActionPromise } from 'lib/utils/action-utils';\n@@ -60,7 +60,7 @@ type Props = {|\n// async functions that hit server APIs\nchangeThreadSettings: (\nupdate: UpdateThreadRequest,\n- ) => Promise<ChangeThreadSettingsResult>,\n+ ) => Promise<ChangeThreadSettingsPayload>,\n|};\nclass ThreadSettingsDescription extends React.PureComponent<Props> {\nstatic propTypes = {\n" }, { "change_type": "MODIFY", "old_path": "native/chat/settings/thread-settings-leave-thread.react.js", "new_path": "native/chat/settings/thread-settings-leave-thread.react.js", "diff": "@@ -4,8 +4,6 @@ import {\ntype ThreadInfo,\nthreadInfoPropType,\ntype LeaveThreadPayload,\n- type RawThreadInfo,\n- rawThreadInfoPropType,\n} from 'lib/types/thread-types';\nimport type { LoadingStatus } from 'lib/types/loading-types';\nimport { loadingStatusPropType } from 'lib/types/loading-types';\n@@ -48,7 +46,6 @@ type Props = {|\notherUsersButNoOtherAdmins: boolean,\ncolors: Colors,\nstyles: typeof styles,\n- rawThreadInfos: { [id: string]: RawThreadInfo },\n// Redux dispatch functions\ndispatchActionPromise: DispatchActionPromise,\n// async functions that hit server APIs\n@@ -64,7 +61,6 @@ class ThreadSettingsLeaveThread extends React.PureComponent<Props> {\notherUsersButNoOtherAdmins: PropTypes.bool.isRequired,\ncolors: colorsPropType.isRequired,\nstyles: PropTypes.objectOf(PropTypes.object).isRequired,\n- rawThreadInfos: PropTypes.objectOf(rawThreadInfoPropType).isRequired,\ndispatchActionPromise: PropTypes.func.isRequired,\nleaveThread: PropTypes.func.isRequired,\nnavContext: navContextPropType,\n@@ -134,8 +130,7 @@ class ThreadSettingsLeaveThread extends React.PureComponent<Props> {\ntry {\nconst result = await this.props.leaveThread(threadID);\nconst invalidated = identifyInvalidatedThreads(\n- this.props.rawThreadInfos,\n- result.threadInfos,\n+ result.updatesResult.newUpdates,\n);\nnavContext.dispatch({\ntype: clearThreadsActionType,\n@@ -183,7 +178,6 @@ export default connect(\n)(state),\ncolors: colorsSelector(state),\nstyles: stylesSelector(state),\n- rawThreadInfos: state.threadStore.threadInfos,\n}),\n{ leaveThread },\n)(withNavContext(ThreadSettingsLeaveThread));\n" }, { "change_type": "MODIFY", "old_path": "native/chat/settings/thread-settings-name.react.js", "new_path": "native/chat/settings/thread-settings-name.react.js", "diff": "import {\ntype ThreadInfo,\nthreadInfoPropType,\n- type ChangeThreadSettingsResult,\n+ type ChangeThreadSettingsPayload,\ntype UpdateThreadRequest,\n} from 'lib/types/thread-types';\nimport type { DispatchActionPromise } from 'lib/utils/action-utils';\n@@ -52,7 +52,7 @@ type Props = {|\n// async functions that hit server APIs\nchangeThreadSettings: (\nupdate: UpdateThreadRequest,\n- ) => Promise<ChangeThreadSettingsResult>,\n+ ) => Promise<ChangeThreadSettingsPayload>,\n|};\nclass ThreadSettingsName extends React.PureComponent<Props> {\nstatic propTypes = {\n" }, { "change_type": "MODIFY", "old_path": "web/modals/threads/thread-settings-modal.react.js", "new_path": "web/modals/threads/thread-settings-modal.react.js", "diff": "@@ -5,7 +5,7 @@ import {\nthreadInfoPropType,\nthreadTypes,\nassertThreadType,\n- type ChangeThreadSettingsResult,\n+ type ChangeThreadSettingsPayload,\ntype UpdateThreadRequest,\ntype LeaveThreadPayload,\nthreadPermissions,\n@@ -81,7 +81,7 @@ type Props = {\n) => Promise<LeaveThreadPayload>,\nchangeThreadSettings: (\nupdate: UpdateThreadRequest,\n- ) => Promise<ChangeThreadSettingsResult>,\n+ ) => Promise<ChangeThreadSettingsPayload>,\n};\ntype State = {|\nqueuedChanges: ThreadChanges,\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[lib] Clean up pre-UpdateInfo params from thread actions
129,187
06.08.2020 16:54:46
14,400
b70cfd0998ace2e0702f475ef606f79461de8d9f
[lib] Clean up pre-UpdateInfo params from entry actions
[ { "change_type": "MODIFY", "old_path": "lib/actions/entry-actions.js", "new_path": "lib/actions/entry-actions.js", "diff": "@@ -4,13 +4,13 @@ import type {\nRawEntryInfo,\nCalendarQuery,\nSaveEntryInfo,\n- SaveEntryResult,\n+ SaveEntryResponse,\nCreateEntryInfo,\nCreateEntryPayload,\nDeleteEntryInfo,\n- DeleteEntryPayload,\n+ DeleteEntryResponse,\nRestoreEntryInfo,\n- RestoreEntryPayload,\n+ RestoreEntryResult,\nFetchEntryInfosResult,\nCalendarQueryUpdateResult,\n} from '../types/entry-types';\n@@ -91,12 +91,10 @@ async function createEntry(\nconst result = await fetchJSON('create_entry', request);\nreturn {\nentryID: result.entryID,\n- text: request.text,\nnewMessageInfos: result.newMessageInfos,\nthreadID: request.threadID,\nlocalID: request.localID,\nupdatesResult: result.updatesResult,\n- calendarQuery: request.calendarQuery,\n};\n}\n@@ -109,14 +107,12 @@ const concurrentModificationResetActionType = 'CONCURRENT_MODIFICATION_RESET';\nasync function saveEntry(\nfetchJSON: FetchJSON,\nrequest: SaveEntryInfo,\n-): Promise<SaveEntryResult> {\n+): Promise<SaveEntryResponse> {\nconst result = await fetchJSON('update_entry', request);\nreturn {\nentryID: result.entryID,\n- text: request.text,\nnewMessageInfos: result.newMessageInfos,\nupdatesResult: result.updatesResult,\n- calendarQuery: request.calendarQuery,\n};\n}\n@@ -128,7 +124,7 @@ const deleteEntryActionTypes = Object.freeze({\nasync function deleteEntry(\nfetchJSON: FetchJSON,\ninfo: DeleteEntryInfo,\n-): Promise<DeleteEntryPayload> {\n+): Promise<DeleteEntryResponse> {\nconst response = await fetchJSON('delete_entry', {\n...info,\ntimestamp: Date.now(),\n@@ -137,7 +133,6 @@ async function deleteEntry(\nnewMessageInfos: response.newMessageInfos,\nthreadID: response.threadID,\nupdatesResult: response.updatesResult,\n- calendarQuery: info.calendarQuery,\n};\n}\n@@ -162,16 +157,14 @@ const restoreEntryActionTypes = Object.freeze({\nasync function restoreEntry(\nfetchJSON: FetchJSON,\ninfo: RestoreEntryInfo,\n-): Promise<RestoreEntryPayload> {\n+): Promise<RestoreEntryResult> {\nconst response = await fetchJSON('restore_entry', {\n...info,\ntimestamp: Date.now(),\n});\nreturn {\nnewMessageInfos: response.newMessageInfos,\n- entryInfo: response.entryInfo,\nupdatesResult: response.updatesResult,\n- calendarQuery: info.calendarQuery,\n};\n}\n" }, { "change_type": "MODIFY", "old_path": "lib/reducers/message-reducer.js", "new_path": "lib/reducers/message-reducer.js", "diff": "@@ -608,7 +608,7 @@ function reduceMessageStore(\n);\n}\n} else if (action.type === restoreEntryActionTypes.success) {\n- const threadID = action.payload.entryInfo.threadID;\n+ const { threadID } = action.payload;\nreturn mergeNewMessages(\nmessageStore,\naction.payload.newMessageInfos,\n" }, { "change_type": "MODIFY", "old_path": "lib/types/entry-types.js", "new_path": "lib/types/entry-types.js", "diff": "@@ -130,14 +130,8 @@ export type SaveEntryResponse = {|\nupdatesResult: CreateUpdatesResponse,\n|};\n-export type SaveEntryResult = {|\n- ...SaveEntryResponse,\n- text: string,\n- calendarQuery: CalendarQuery,\n-|};\n-\nexport type SaveEntryPayload = {|\n- ...SaveEntryResult,\n+ ...SaveEntryResponse,\nthreadID: string,\n|};\n@@ -193,19 +187,19 @@ export type DeleteEntryResponse = {|\nthreadID: string,\nupdatesResult: CreateUpdatesResponse,\n|};\n-export type DeleteEntryPayload = {|\n- ...DeleteEntryResponse,\n- calendarQuery: CalendarQuery,\n-|};\nexport type RestoreEntryResponse = {|\nnewMessageInfos: $ReadOnlyArray<RawMessageInfo>,\nentryInfo: RawEntryInfo,\nupdatesResult: CreateUpdatesResponse,\n|};\n+export type RestoreEntryResult = {|\n+ newMessageInfos: $ReadOnlyArray<RawMessageInfo>,\n+ updatesResult: CreateUpdatesResponse,\n+|};\nexport type RestoreEntryPayload = {|\n- ...RestoreEntryResponse,\n- calendarQuery: CalendarQuery,\n+ ...RestoreEntryResult,\n+ threadID: string,\n|};\nexport type FetchEntryInfosResponse = {|\n" }, { "change_type": "MODIFY", "old_path": "lib/types/redux-types.js", "new_path": "lib/types/redux-types.js", "diff": "@@ -13,7 +13,7 @@ import type {\nCalendarQuery,\nSaveEntryPayload,\nCreateEntryPayload,\n- DeleteEntryPayload,\n+ DeleteEntryResponse,\nRestoreEntryPayload,\nFetchEntryInfosResult,\nCalendarResult,\n@@ -215,7 +215,7 @@ export type BaseAction =\n|}\n| {|\ntype: 'DELETE_ENTRY_SUCCESS',\n- payload: ?DeleteEntryPayload,\n+ payload: ?DeleteEntryResponse,\nloadingInfo: LoadingInfo,\n|}\n| {|\n" }, { "change_type": "MODIFY", "old_path": "native/calendar/entry.react.js", "new_path": "native/calendar/entry.react.js", "diff": "@@ -5,10 +5,10 @@ import {\nentryInfoPropType,\ntype CreateEntryInfo,\ntype SaveEntryInfo,\n- type SaveEntryResult,\n+ type SaveEntryResponse,\ntype CreateEntryPayload,\ntype DeleteEntryInfo,\n- type DeleteEntryPayload,\n+ type DeleteEntryResponse,\ntype CalendarQuery,\n} from 'lib/types/entry-types';\nimport type { ThreadInfo } from 'lib/types/thread-types';\n@@ -117,8 +117,8 @@ type Props = {|\ndispatchActionPromise: DispatchActionPromise,\n// async functions that hit server APIs\ncreateEntry: (info: CreateEntryInfo) => Promise<CreateEntryPayload>,\n- saveEntry: (info: SaveEntryInfo) => Promise<SaveEntryResult>,\n- deleteEntry: (info: DeleteEntryInfo) => Promise<DeleteEntryPayload>,\n+ saveEntry: (info: SaveEntryInfo) => Promise<SaveEntryResponse>,\n+ deleteEntry: (info: DeleteEntryInfo) => Promise<DeleteEntryResponse>,\n|};\ntype State = {|\nediting: boolean,\n" }, { "change_type": "MODIFY", "old_path": "web/calendar/entry.react.js", "new_path": "web/calendar/entry.react.js", "diff": "@@ -5,10 +5,10 @@ import {\nentryInfoPropType,\ntype CreateEntryInfo,\ntype SaveEntryInfo,\n- type SaveEntryResult,\n+ type SaveEntryResponse,\ntype CreateEntryPayload,\ntype DeleteEntryInfo,\n- type DeleteEntryPayload,\n+ type DeleteEntryResponse,\ntype CalendarQuery,\n} from 'lib/types/entry-types';\nimport type { ThreadInfo } from 'lib/types/thread-types';\n@@ -65,8 +65,8 @@ type Props = {|\ndispatchActionPromise: DispatchActionPromise,\n// async functions that hit server APIs\ncreateEntry: (info: CreateEntryInfo) => Promise<CreateEntryPayload>,\n- saveEntry: (info: SaveEntryInfo) => Promise<SaveEntryResult>,\n- deleteEntry: (info: DeleteEntryInfo) => Promise<DeleteEntryPayload>,\n+ saveEntry: (info: SaveEntryInfo) => Promise<SaveEntryResponse>,\n+ deleteEntry: (info: DeleteEntryInfo) => Promise<DeleteEntryResponse>,\n|};\ntype State = {|\nfocused: boolean,\n" }, { "change_type": "MODIFY", "old_path": "web/modals/history/history-entry.react.js", "new_path": "web/modals/history/history-entry.react.js", "diff": "@@ -6,7 +6,7 @@ import {\ntype EntryInfo,\nentryInfoPropType,\ntype RestoreEntryInfo,\n- type RestoreEntryPayload,\n+ type RestoreEntryResult,\ntype CalendarQuery,\n} from 'lib/types/entry-types';\nimport type { AppState } from '../../redux-setup';\n@@ -43,7 +43,7 @@ type Props = {\n// Redux dispatch functions\ndispatchActionPromise: DispatchActionPromise,\n// async functions that hit server APIs\n- restoreEntry: (info: RestoreEntryInfo) => Promise<RestoreEntryPayload>,\n+ restoreEntry: (info: RestoreEntryInfo) => Promise<RestoreEntryResult>,\n};\nclass HistoryEntry extends React.PureComponent<Props> {\n@@ -142,7 +142,7 @@ class HistoryEntry extends React.PureComponent<Props> {\ncalendarQuery: this.props.calendarQuery(),\n});\nthis.props.animateAndLoadEntry(entryID);\n- return result;\n+ return { ...result, threadID: this.props.threadInfo.id };\n}\n}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[lib] Clean up pre-UpdateInfo params from entry actions
129,187
06.08.2020 17:33:12
14,400
4da0afe856b6ac9123fe54c223149baad1527765
[server] Don't return entryInfo from restore_entry Only web ever calls `restoreEntry`, and we just updated it so it doesn't need the `entryInfo`
[ { "change_type": "MODIFY", "old_path": "lib/actions/entry-actions.js", "new_path": "lib/actions/entry-actions.js", "diff": "@@ -10,7 +10,7 @@ import type {\nDeleteEntryInfo,\nDeleteEntryResponse,\nRestoreEntryInfo,\n- RestoreEntryResult,\n+ RestoreEntryResponse,\nFetchEntryInfosResult,\nCalendarQueryUpdateResult,\n} from '../types/entry-types';\n@@ -157,7 +157,7 @@ const restoreEntryActionTypes = Object.freeze({\nasync function restoreEntry(\nfetchJSON: FetchJSON,\ninfo: RestoreEntryInfo,\n-): Promise<RestoreEntryResult> {\n+): Promise<RestoreEntryResponse> {\nconst response = await fetchJSON('restore_entry', {\n...info,\ntimestamp: Date.now(),\n" }, { "change_type": "MODIFY", "old_path": "lib/types/entry-types.js", "new_path": "lib/types/entry-types.js", "diff": "@@ -189,16 +189,11 @@ export type DeleteEntryResponse = {|\n|};\nexport type RestoreEntryResponse = {|\n- newMessageInfos: $ReadOnlyArray<RawMessageInfo>,\n- entryInfo: RawEntryInfo,\n- updatesResult: CreateUpdatesResponse,\n-|};\n-export type RestoreEntryResult = {|\nnewMessageInfos: $ReadOnlyArray<RawMessageInfo>,\nupdatesResult: CreateUpdatesResponse,\n|};\nexport type RestoreEntryPayload = {|\n- ...RestoreEntryResult,\n+ ...RestoreEntryResponse,\nthreadID: string,\n|};\n" }, { "change_type": "MODIFY", "old_path": "server/src/deleters/entry-deleters.js", "new_path": "server/src/deleters/entry-deleters.js", "diff": "@@ -202,7 +202,6 @@ async function restoreEntry(\nfetchUpdateInfoForEntryUpdate(viewer, request.entryID),\n]);\nreturn {\n- entryInfo: oldEntryInfo,\nnewMessageInfos: rawMessageInfo ? [rawMessageInfo] : [],\nupdatesResult: {\nviewerUpdates: fetchUpdatesResult.updateInfos,\n@@ -262,7 +261,7 @@ async function restoreEntry(\nPromise.all(dbPromises),\n]);\n- return { entryInfo: newEntryInfo, newMessageInfos, updatesResult };\n+ return { newMessageInfos, updatesResult };\n}\nasync function deleteOrphanedEntries(): Promise<void> {\n" }, { "change_type": "MODIFY", "old_path": "web/modals/history/history-entry.react.js", "new_path": "web/modals/history/history-entry.react.js", "diff": "@@ -6,7 +6,7 @@ import {\ntype EntryInfo,\nentryInfoPropType,\ntype RestoreEntryInfo,\n- type RestoreEntryResult,\n+ type RestoreEntryResponse,\ntype CalendarQuery,\n} from 'lib/types/entry-types';\nimport type { AppState } from '../../redux-setup';\n@@ -43,7 +43,7 @@ type Props = {\n// Redux dispatch functions\ndispatchActionPromise: DispatchActionPromise,\n// async functions that hit server APIs\n- restoreEntry: (info: RestoreEntryInfo) => Promise<RestoreEntryResult>,\n+ restoreEntry: (info: RestoreEntryInfo) => Promise<RestoreEntryResponse>,\n};\nclass HistoryEntry extends React.PureComponent<Props> {\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[server] Don't return entryInfo from restore_entry Only web ever calls `restoreEntry`, and we just updated it so it doesn't need the `entryInfo`
129,187
06.08.2020 17:44:01
14,400
4a4f339b51fd259d5dbed056933a9a6d8fbcf80e
[lib] hasMinCodeVersion
[ { "change_type": "MODIFY", "old_path": "lib/shared/message-utils.js", "new_path": "lib/shared/message-utils.js", "diff": "@@ -33,6 +33,7 @@ import { userIDsToRelativeUserInfos } from '../selectors/user-selectors';\nimport { shimUploadURI, multimediaMessagePreview } from '../media/media-utils';\nimport { stringForUser } from './user-utils';\nimport { codeBlockRegex } from './markdown';\n+import { hasMinCodeVersion } from '../shared/version-utils';\n// Prefers localID\nfunction messageKey(messageInfo: MessageInfo | RawMessageInfo): string {\n@@ -652,19 +653,13 @@ 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 => {\nif (rawMessageInfo.type === messageTypes.IMAGES) {\nconst shimmedRawMessageInfo = shimMediaMessageInfo(\nrawMessageInfo,\nplatformDetails,\n);\n- if (codeVersion && codeVersion > 29) {\n+ if (hasMinCodeVersion(platformDetails, 30)) {\nreturn shimmedRawMessageInfo;\n}\nconst { id } = shimmedRawMessageInfo;\n@@ -684,7 +679,7 @@ function shimUnsupportedRawMessageInfos(\nplatformDetails,\n);\n// TODO figure out first native codeVersion supporting video playback\n- if (codeVersion && codeVersion > 41) {\n+ if (hasMinCodeVersion(platformDetails, 62)) {\nreturn shimmedRawMessageInfo;\n}\nconst { id } = shimmedRawMessageInfo;\n" }, { "change_type": "ADD", "old_path": null, "new_path": "lib/shared/version-utils.js", "diff": "+// @flow\n+\n+import type { PlatformDetails } from '../types/device-types';\n+\n+function hasMinCodeVersion(\n+ platformDetails: ?PlatformDetails,\n+ minCodeVersion: number,\n+): boolean {\n+ if (!platformDetails || platformDetails.platform === 'web') {\n+ return true;\n+ }\n+ const { codeVersion } = platformDetails;\n+ if (!codeVersion || codeVersion < minCodeVersion) {\n+ return false;\n+ }\n+ return true;\n+}\n+\n+export { hasMinCodeVersion };\n" }, { "change_type": "MODIFY", "old_path": "server/src/session/version.js", "new_path": "server/src/session/version.js", "diff": "@@ -4,12 +4,13 @@ import type { PlatformDetails } from 'lib/types/device-types';\nimport type { Viewer } from '../session/viewer';\nimport { ServerError } from 'lib/utils/errors';\n+import { hasMinCodeVersion } from 'lib/shared/version-utils';\nasync function verifyClientSupported(\nviewer: Viewer,\nplatformDetails: ?PlatformDetails,\n) {\n- if (clientSupported(platformDetails)) {\n+ if (hasMinCodeVersion(platformDetails, 24)) {\nreturn;\n}\nconst error = new ServerError('client_version_unsupported');\n@@ -17,15 +18,4 @@ async function verifyClientSupported(\nthrow error;\n}\n-function clientSupported(platformDetails: ?PlatformDetails): boolean {\n- if (!platformDetails || platformDetails.platform === 'web') {\n- return true;\n- }\n- const { codeVersion } = platformDetails;\n- if (!codeVersion || codeVersion < 24) {\n- return false;\n- }\n- return true;\n-}\n-\nexport { verifyClientSupported };\n" }, { "change_type": "MODIFY", "old_path": "server/src/socket/session-utils.js", "new_path": "server/src/socket/session-utils.js", "diff": "@@ -34,6 +34,7 @@ import {\nserverEntryInfosObject,\n} from 'lib/shared/entry-utils';\nimport { usersInThreadInfo } from 'lib/shared/thread-utils';\n+import { hasMinCodeVersion } from 'lib/shared/version-utils';\nimport { tShape, tPlatform, tPlatformDetails } from '../utils/validation-utils';\nimport { fetchThreadInfos } from '../fetchers/thread-fetchers';\n@@ -278,13 +279,7 @@ async function checkState(\nstatus: StateCheckStatus,\ncalendarQuery: CalendarQuery,\n): Promise<StateCheckResult> {\n- const { platformDetails } = viewer;\n- const shouldCheckUserInfos =\n- (platformDetails && platformDetails.platform === 'web') ||\n- (platformDetails &&\n- platformDetails.codeVersion !== null &&\n- platformDetails.codeVersion !== undefined &&\n- platformDetails.codeVersion > 58);\n+ const shouldCheckUserInfos = hasMinCodeVersion(viewer.platformDetails, 59);\nif (status.status === 'state_validated') {\nreturn { sessionUpdate: { lastValidated: Date.now() } };\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
[lib] hasMinCodeVersion