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 | 26.05.2017 15:22:02 | 14,400 | 8839d92aac472ce5394ec241362f2c7d93c76edc | Fixing Android header height right corrected some jittering bugs and explains the 75 number I had to previously adjust by | [
{
"change_type": "MODIFY",
"old_path": "native/calendar/calendar.react.js",
"new_path": "native/calendar/calendar.react.js",
"diff": "@@ -269,18 +269,18 @@ class InnerCalendar extends React.PureComponent {\n}\n}\n- componentDidUpdate(prevProps: Props, prevState: State) {\n+ componentWillUpdate(nextProps: Props, nextState: State) {\n// If the sessionID gets reset and the user isn't looking we scroll to today\nif (\n- this.props.sessionID !== prevProps.sessionID &&\n- !this.props.tabActive &&\n+ nextProps.sessionID !== this.props.sessionID &&\n+ !nextProps.tabActive &&\nthis.flatList\n) {\nthis.scrollToToday();\n}\n- const lastLDWH = prevState.listDataWithHeights;\n- const newLDWH = this.state.listDataWithHeights;\n+ const lastLDWH = this.state.listDataWithHeights;\n+ const newLDWH = nextState.listDataWithHeights;\nif (!lastLDWH || !newLDWH) {\nreturn;\n}\n@@ -353,10 +353,6 @@ class InnerCalendar extends React.PureComponent {\nconst currentScrollPosition =\nMath.max(this.currentScrollPosition, 0);\nlet offset = currentScrollPosition + heightOfNewItems;\n- if (Platform.OS === \"android\") {\n- // I am not sure why we do this. I have no idea what's going on.\n- offset += 75;\n- }\nflatList.scrollToOffset({\noffset,\nanimated: false,\n@@ -499,11 +495,10 @@ class InnerCalendar extends React.PureComponent {\n}\nstatic itemHeight(item: CalendarItemWithHeight): number {\n- // TODO test these values on Android\nif (item.itemType === \"loader\") {\nreturn 56;\n} else if (item.itemType === \"header\") {\n- return 29;\n+ return 31;\n} else if (item.itemType === \"entryInfo\") {\nreturn 20 + item.entryInfo.textHeight;\n} else if (item.itemType === \"footer\") {\n@@ -588,7 +583,7 @@ class InnerCalendar extends React.PureComponent {\nwhile (heightLeft > 0) {\nheightLeft -= InnerCalendar.itemHeight(data[--returnIndex]);\n}\n- return returnIndex + 1;\n+ return returnIndex;\n}\ntextHeightMeasurerRef = (textHeightMeasurer: ?TextHeightMeasurer) => {\n@@ -730,6 +725,7 @@ const styles = StyleSheet.create({\nmarginTop: contentVerticalOffset,\n},\nsectionHeader: {\n+ height: 31,\nbackgroundColor: '#EEEEEE',\nborderBottomWidth: 2,\nborderColor: '#FFFFFF',\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Fixing Android header height right corrected some jittering bugs and explains the 75 number I had to previously adjust by |
129,187 | 26.05.2017 17:08:01 | 14,400 | d0d823ebeb7e3675f43122df262b1ad49cf46e70 | When an entry is clicked, scroll to a position where it's viewable even with the keyboard being shown | [
{
"change_type": "MODIFY",
"old_path": "native/account/logged-out-modal.react.js",
"new_path": "native/account/logged-out-modal.react.js",
"diff": "@@ -10,6 +10,7 @@ import type { Dispatch } from 'lib/types/redux-types';\nimport type { Action } from '../navigation-setup';\nimport type { PingStartingPayload, PingResult } from 'lib/types/ping-types';\nimport type { CalendarQuery } from 'lib/selectors/nav-selectors';\n+import type { KeyboardEvent } from '../keyboard';\nimport React from 'react';\nimport {\n@@ -46,15 +47,6 @@ import ConnectedStatusBar from '../connected-status-bar.react';\nimport { getNativeCookie, setNativeCookie } from './native-credentials';\nimport { createIsForegroundSelector } from '../selectors/nav-selectors';\n-type KeyboardEvent = {\n- duration: number,\n- endCoordinates: {\n- width: number,\n- height: number,\n- screenX: number,\n- screenY: number,\n- },\n-};\ntype LoggedOutMode = \"loading\" | \"prompt\" | \"log-in\" | \"register\";\ntype Props = {\nnavigation: NavigationScreenProp<*, *>,\n@@ -177,9 +169,11 @@ class InnerLoggedOutModal extends React.PureComponent {\nonBackground() {\nif (this.keyboardShowListener) {\nthis.keyboardShowListener.remove();\n+ this.keyboardShowListener = null;\n}\nif (this.keyboardHideListener) {\nthis.keyboardHideListener.remove();\n+ this.keyboardHideListener = null;\n}\nBackHandler.removeEventListener('hardwareBackPress', this.hardwareBack);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "native/account/verification-modal.react.js",
"new_path": "native/account/verification-modal.react.js",
"diff": "@@ -8,6 +8,7 @@ import type {\nDispatchActionPromise,\n} from 'lib/utils/action-utils';\nimport type { VerifyField } from 'lib/utils/verify-utils';\n+import type { KeyboardEvent } from '../keyboard';\nimport React from 'react';\nimport {\n@@ -46,15 +47,6 @@ import ConnectedStatusBar from '../connected-status-bar.react';\nimport ResetPasswordPanel from './reset-password-panel.react';\nimport { createIsForegroundSelector } from '../selectors/nav-selectors';\n-type KeyboardEvent = {\n- duration: number,\n- endCoordinates: {\n- width: number,\n- height: number,\n- screenX: number,\n- screenY: number,\n- },\n-};\ntype VerificationModalMode = \"simple-text\" | \"reset-password\";\ntype VerificationModalNavProps = {\nverifyCode: string,\n@@ -185,9 +177,11 @@ class InnerVerificationModal extends React.PureComponent {\nonBackground() {\nif (this.keyboardShowListener) {\nthis.keyboardShowListener.remove();\n+ this.keyboardShowListener = null;\n}\nif (this.keyboardHideListener) {\nthis.keyboardHideListener.remove();\n+ this.keyboardHideListener = null;\n}\nBackHandler.removeEventListener('hardwareBackPress', this.hardwareBack);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "native/calendar/calendar.react.js",
"new_path": "native/calendar/calendar.react.js",
"diff": "@@ -8,6 +8,7 @@ import type { ViewToken } from 'react-native/Libraries/Lists/ViewabilityHelper';\nimport type { DispatchActionPromise } from 'lib/utils/action-utils';\nimport type { CalendarResult } from 'lib/actions/entry-actions';\nimport type { CalendarQuery } from 'lib/selectors/nav-selectors';\n+import type { KeyboardEvent } from '../keyboard';\nimport React from 'react';\nimport {\n@@ -18,7 +19,7 @@ import {\nAppState as NativeAppState,\nPlatform,\nActivityIndicator,\n- InteractionManager,\n+ Keyboard,\n} from 'react-native';\nimport Icon from 'react-native-vector-icons/FontAwesome';\nimport { connect } from 'react-redux';\n@@ -160,6 +161,10 @@ class InnerCalendar extends React.PureComponent {\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.\nfirstScrollUpOnAndroidComplete = false;\n+ // When an entry is focused, we make a note of which one was focused so that\n+ // once the keyboard event happens, we know where to move the scrollPos to\n+ lastEntryKeyFocused: ?string = null;\n+ keyboardShowListener: ?Object;\nconstructor(props: Props) {\nsuper(props);\n@@ -193,6 +198,12 @@ class InnerCalendar extends React.PureComponent {\ncomponentDidMount() {\nNativeAppState.addEventListener('change', this.handleAppStateChange);\n+ if (this.props.tabActive) {\n+ this.keyboardShowListener = Keyboard.addListener(\n+ Platform.OS === \"ios\" ? \"keyboardWillShow\" : \"keyboardDidShow\",\n+ this.keyboardShow,\n+ );\n+ }\n}\ncomponentWillUnmount() {\n@@ -270,6 +281,24 @@ class InnerCalendar extends React.PureComponent {\n}\ncomponentWillUpdate(nextProps: Props, nextState: State) {\n+ if (\n+ nextProps.tabActive &&\n+ !this.props.tabActive &&\n+ !this.keyboardShowListener\n+ ) {\n+ this.keyboardShowListener = Keyboard.addListener(\n+ Platform.OS === \"ios\" ? \"keyboardWillShow\" : \"keyboardDidShow\",\n+ this.keyboardShow,\n+ );\n+ } else if (\n+ !nextProps.tabActive &&\n+ this.props.tabActive &&\n+ this.keyboardShowListener\n+ ) {\n+ this.keyboardShowListener.remove();\n+ this.keyboardShowListener = null;\n+ }\n+\n// If the sessionID gets reset and the user isn't looking we scroll to today\nif (\nnextProps.sessionID !== this.props.sessionID &&\n@@ -333,10 +362,7 @@ class InnerCalendar extends React.PureComponent {\nlastLDWH: $ReadOnlyArray<CalendarItemWithHeight>,\nnewLDWH: $ReadOnlyArray<CalendarItemWithHeight>,\n) {\n- const existingKeys = new Set(\n- _map((item: CalendarItemWithHeight) => InnerCalendar.keyExtractor(item))\n- (lastLDWH),\n- );\n+ const existingKeys = new Set(_map(InnerCalendar.keyExtractor)(lastLDWH));\nconst newItems = _filter(\n(item: CalendarItemWithHeight) =>\n!existingKeys.has(InnerCalendar.keyExtractor(item)),\n@@ -569,17 +595,20 @@ class InnerCalendar extends React.PureComponent {\n);\n}\n+ static flatListHeight() {\n+ return Platform.OS === \"android\"\n+ ? windowHeight - contentVerticalOffset - 50\n+ : windowHeight - contentVerticalOffset - 49;\n+ }\n+\ninitialScrollIndex = () => {\nconst data = this.state.listDataWithHeights;\ninvariant(data, \"should be set\");\nconst todayIndex = _findIndex(['dateString', dateString(new Date())])(data);\n- const flatListHeight = Platform.OS === \"android\"\n- ? windowHeight - contentVerticalOffset - 125\n- : windowHeight - contentVerticalOffset - 49;\nconst heightOfTodayHeader = InnerCalendar.itemHeight(data[todayIndex]);\nlet returnIndex = todayIndex;\n- let heightLeft = (flatListHeight - heightOfTodayHeader) / 2;\n+ let heightLeft = (InnerCalendar.flatListHeight() - heightOfTodayHeader) / 2;\nwhile (heightLeft > 0) {\nheightLeft -= InnerCalendar.itemHeight(data[--returnIndex]);\n}\n@@ -603,9 +632,42 @@ class InnerCalendar extends React.PureComponent {\nvisibleEntries: this.extraData.visibleEntries,\nfocusedEntries: { [key]: true },\n};\n+ this.lastEntryKeyFocused = key;\nthis.setState({ extraData: this.extraData });\n}\n+ keyboardShow = (event: KeyboardEvent) => {\n+ const lastEntryKeyFocused = this.lastEntryKeyFocused;\n+ if (!lastEntryKeyFocused) {\n+ return;\n+ }\n+ const data = this.state.listDataWithHeights;\n+ invariant(data, \"should be set\");\n+ const index = _findIndex(\n+ (item: CalendarItemWithHeight) =>\n+ InnerCalendar.keyExtractor(item) === lastEntryKeyFocused,\n+ )(data);\n+ const itemStart = InnerCalendar.heightOfItems(\n+ data.filter((_, i) => i < index),\n+ );\n+ const itemHeight = InnerCalendar.itemHeight(data[index]);\n+ const itemEnd = itemStart + itemHeight;\n+ const visibleHeight = InnerCalendar.flatListHeight() -\n+ event.endCoordinates.height;\n+ invariant(this.currentScrollPosition, \"should be set\");\n+ if (\n+ itemStart > this.currentScrollPosition &&\n+ itemEnd < this.currentScrollPosition + visibleHeight\n+ ) {\n+ return;\n+ }\n+ invariant(this.flatList, \"flatList should be set\");\n+ this.flatList.scrollToOffset({\n+ offset: itemStart - (visibleHeight - itemHeight) / 2,\n+ animated: true,\n+ });\n+ }\n+\nallHeightsMeasured = (\ntextToMeasure: string[],\nnewTextHeights: { [text: string]: number },\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/keyboard.js",
"diff": "+// @flow\n+\n+export type KeyboardEvent = {\n+ duration: number,\n+ endCoordinates: {\n+ width: number,\n+ height: number,\n+ screenX: number,\n+ screenY: number,\n+ },\n+};\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | When an entry is clicked, scroll to a position where it's viewable even with the keyboard being shown |
129,187 | 26.05.2017 19:11:33 | 14,400 | fcee6dfb8b822065d1a4e5bcc5b7a72a90311df6 | LayoutAnimation! Wow this rocks
Also, keyboardShouldPersistTaps="handled"
Also, handle keyboard/focus events regardless of order
And guard against all unmounted setStates in Entry
And some other stuff too! | [
{
"change_type": "MODIFY",
"old_path": "native/calendar/calendar.react.js",
"new_path": "native/calendar/calendar.react.js",
"diff": "@@ -165,6 +165,7 @@ class InnerCalendar extends React.PureComponent {\n// once the keyboard event happens, we know where to move the scrollPos to\nlastEntryKeyFocused: ?string = null;\nkeyboardShowListener: ?Object;\n+ keyboardShownHeight: ?number = null;\nconstructor(props: Props) {\nsuper(props);\n@@ -493,6 +494,7 @@ class InnerCalendar extends React.PureComponent {\n}\nonAdd = (dayString: string) => {\n+ Keyboard.dismiss();\nthis.setState({ pickerOpenForDateString: dayString });\n}\n@@ -553,6 +555,7 @@ class InnerCalendar extends React.PureComponent {\nonViewableItemsChanged={this.onViewableItemsChanged}\nonScroll={this.onScroll}\ninitialScrollIndex={this.initialScrollIndex()}\n+ keyboardShouldPersistTaps=\"handled\"\nextraData={this.extraData}\nstyle={[styles.flatList, flatListStyle]}\nref={this.flatListRef}\n@@ -632,15 +635,27 @@ class InnerCalendar extends React.PureComponent {\nvisibleEntries: this.extraData.visibleEntries,\nfocusedEntries: { [key]: true },\n};\n- this.lastEntryKeyFocused = key;\nthis.setState({ extraData: this.extraData });\n+ const keyboardShownHeight = this.keyboardShownHeight;\n+ if (keyboardShownHeight) {\n+ this.scrollToKey(key, keyboardShownHeight);\n+ } else {\n+ this.lastEntryKeyFocused = key;\n+ }\n}\nkeyboardShow = (event: KeyboardEvent) => {\nconst lastEntryKeyFocused = this.lastEntryKeyFocused;\n- if (!lastEntryKeyFocused) {\n- return;\n+ if (lastEntryKeyFocused) {\n+ this.scrollToKey(lastEntryKeyFocused, event.endCoordinates.height);\n+ } else {\n+ this.keyboardShownHeight = event.endCoordinates.height;\n}\n+ }\n+\n+ scrollToKey(lastEntryKeyFocused: string, keyboardHeight: number) {\n+ this.lastEntryKeyFocused = null;\n+ this.keyboardShownHeight = null;\nconst data = this.state.listDataWithHeights;\ninvariant(data, \"should be set\");\nconst index = _findIndex(\n@@ -653,7 +668,7 @@ class InnerCalendar extends React.PureComponent {\nconst itemHeight = InnerCalendar.itemHeight(data[index]);\nconst itemEnd = itemStart + itemHeight;\nconst visibleHeight = InnerCalendar.flatListHeight() -\n- event.endCoordinates.height;\n+ keyboardHeight;\ninvariant(this.currentScrollPosition, \"should be set\");\nif (\nitemStart > this.currentScrollPosition &&\n"
},
{
"change_type": "MODIFY",
"old_path": "native/calendar/entry.react.js",
"new_path": "native/calendar/entry.react.js",
"diff": "@@ -21,6 +21,7 @@ import {\nPlatform,\nTouchableWithoutFeedback,\nAlert,\n+ LayoutAnimation,\n} from 'react-native';\nimport { connect } from 'react-redux';\nimport PropTypes from 'prop-types';\n@@ -112,7 +113,7 @@ class Entry extends React.Component {\nneedsUpdateAfterCreation = false;\nneedsDeleteAfterCreation = false;\nnextSaveAttemptIndex = 0;\n- mounted = true;\n+ mounted = false;\nconstructor(props: Props) {\nsuper(props);\n@@ -129,9 +130,15 @@ class Entry extends React.Component {\n};\n}\n+ guardedSetState(input) {\n+ if (this.mounted) {\n+ this.setState(input);\n+ }\n+ }\n+\ncomponentWillReceiveProps(nextProps: Props) {\nif (\n- !this.props.focused &&\n+ !Entry.isFocused(nextProps) &&\n(nextProps.entryInfo.text !== this.props.entryInfo.text &&\nnextProps.entryInfo.text !== this.state.text) ||\n(nextProps.entryInfo.textHeight !== this.props.entryInfo.textHeight &&\n@@ -160,22 +167,38 @@ class Entry extends React.Component {\n!_isEqual(nextProps.entryInfo, this.props.entryInfo);\n}\n+ componentWillUpdate(nextProps: Props, nextState: State) {\n+ if (\n+ nextState.height !== this.state.height ||\n+ Entry.isFocused(nextProps) !== Entry.isFocused(this.props)\n+ ) {\n+ LayoutAnimation.easeInEaseOut();\n+ }\n+ }\n+\ncomponentDidMount() {\n// Whenever a new Entry is created, focus on it\nif (!this.props.entryInfo.id) {\ninvariant(this.textInput, \"textInput ref not set\");\nthis.textInput.focus();\n}\n+ this.mounted = true;\n}\ncomponentWillUnmount() {\nthis.mounted = false;\n}\n+ static isFocused(props: Props) {\n+ return props.focused || !props.entryInfo.id;\n+ }\n+\nrender() {\n+ const focused = Entry.isFocused(this.props);\n+\nconst darkColor = colorIsDark(this.state.color);\nlet actionLinks = null;\n- if (this.props.focused) {\n+ if (focused) {\nconst actionLinksColor = darkColor ? '#D3D3D3' : '#808080';\nconst actionLinksTextStyle = { color: actionLinksColor };\nconst actionLinksUnderlayColor = darkColor ? \"#AAAAAA88\" : \"#CCCCCCDD\";\n@@ -206,13 +229,14 @@ class Entry extends React.Component {\nconst textInputStyle: Object = {\ncolor: textColor,\n};\n- if (this.props.focused) {\n+ if (focused) {\ntextInputStyle.paddingBottom = 0;\n} else {\ntextInputStyle.height = this.state.height;\n}\nlet text;\n- if (this.props.visible || !this.props.entryInfo.id) {\n+ const visible = this.props.visible || !this.props.entryInfo.id;\n+ if (visible || !this.props.entryInfo.id) {\ntext = (\n<TextInput\nstyle={[styles.textInput, textInputStyle]}\n@@ -261,27 +285,27 @@ class Entry extends React.Component {\n}\nonContentSizeChange = (event) => {\n- if (!this.props.focused) {\n+ if (!Entry.isFocused(this.props)) {\nreturn;\n}\nlet height = event.nativeEvent.contentSize.height;\n// iOS doesn't include the margin on this callback\nheight = Platform.OS === \"ios\" ? height + 10 : height + 5;\n- this.setState({ height });\n+ this.guardedSetState({ height });\n}\n// On Android, onContentSizeChange only gets called once when the TextInput is\n// first rendered. Which is like, what? Anyways, instead you're supposed to\n// use onChange.\nonChange = (event) => {\n- if (Platform.OS !== \"android\" || !this.props.focused) {\n+ if (Platform.OS !== \"android\" || !Entry.isFocused(this.props)) {\nreturn;\n}\n- this.setState({ height: event.nativeEvent.contentSize.height });\n+ this.guardedSetState({ height: event.nativeEvent.contentSize.height });\n}\nonChangeText = (newText: string) => {\n- this.setState({ text: newText });\n+ this.guardedSetState({ text: newText });\n}\nsave(serverID: ?string, newText: string) {\n@@ -313,9 +337,7 @@ class Entry extends React.Component {\nasync saveAction(serverID: ?string, newText: string) {\nconst curSaveAttempt = this.nextSaveAttemptIndex++;\n- if (this.mounted) {\n- this.setState({ loadingStatus: \"loading\" });\n- }\n+ this.guardedSetState({ loadingStatus: \"loading\" });\ntry {\nconst response = await this.props.saveEntry(\nserverID,\n@@ -328,8 +350,8 @@ class Entry extends React.Component {\nthis.props.entryInfo.calendarID,\nthis.props.entryInfo.creationTime,\n);\n- if (this.mounted && curSaveAttempt + 1 === this.nextSaveAttemptIndex) {\n- this.setState({ loadingStatus: \"inactive\" });\n+ if (curSaveAttempt + 1 === this.nextSaveAttemptIndex) {\n+ this.guardedSetState({ loadingStatus: \"inactive\" });\n}\nconst payload = {\nlocalID: (null: ?string),\n@@ -354,12 +376,12 @@ class Entry extends React.Component {\n}\nreturn payload;\n} catch(e) {\n- if (this.mounted && curSaveAttempt + 1 === this.nextSaveAttemptIndex) {\n- this.setState({ loadingStatus: \"error\" });\n+ if (curSaveAttempt + 1 === this.nextSaveAttemptIndex) {\n+ this.guardedSetState({ loadingStatus: \"error\" });\n}\nif (e instanceof ServerError && e.message === 'concurrent_modification') {\nconst onRefresh = () => {\n- this.setState({ loadingStatus: \"inactive\" });\n+ this.guardedSetState({ loadingStatus: \"inactive\" });\nthis.props.dispatchActionPayload(\nconcurrentModificationResetActionType,\n{ id: serverID, dbText: e.result.db },\n@@ -384,6 +406,7 @@ class Entry extends React.Component {\n}\ndelete(serverID: ?string) {\n+ LayoutAnimation.easeInEaseOut();\nconst startingPayload: {[key: string]: ?string} = {\nlocalID: this.props.entryInfo.localID,\nserverID: serverID,\n"
},
{
"change_type": "MODIFY",
"old_path": "native/calendar/thread-picker.react.js",
"new_path": "native/calendar/thread-picker.react.js",
"diff": "@@ -13,6 +13,7 @@ import {\nTouchableWithoutFeedback,\nFlatList,\nTouchableHighlight,\n+ LayoutAnimation,\n} from 'react-native';\nimport Icon from 'react-native-vector-icons/FontAwesome';\nimport { connect } from 'react-redux';\n@@ -105,6 +106,7 @@ class ThreadPicker extends React.PureComponent {\nthreadPicked = (calendarID: string) => {\nthis.props.close();\n+ LayoutAnimation.easeInEaseOut();\nthis.props.dispatchActionPayload(\ncreateLocalEntryActionType,\ncreateLocalEntry(calendarID, this.props.dateString, this.props.username),\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | LayoutAnimation! Wow this rocks
Also, keyboardShouldPersistTaps="handled"
Also, handle keyboard/focus events regardless of order
And guard against all unmounted setStates in Entry
And some other stuff too! |
129,187 | 26.05.2017 20:05:08 | 14,400 | 5fbf4fe00ad1bbaf08f51b65d196213fcb613910 | Faster response and move of LayoutAnimation call to a more precise place | [
{
"change_type": "MODIFY",
"old_path": "native/calendar/calendar.react.js",
"new_path": "native/calendar/calendar.react.js",
"diff": "@@ -20,6 +20,7 @@ import {\nPlatform,\nActivityIndicator,\nKeyboard,\n+ LayoutAnimation,\n} from 'react-native';\nimport Icon from 'react-native-vector-icons/FontAwesome';\nimport { connect } from 'react-redux';\n@@ -348,6 +349,8 @@ class InnerCalendar extends React.PureComponent {\n} else if (newEndDate > lastEndDate) {\nthis.loadingNewEntriesFromScroll = false;\nthis.firstScrollUpOnAndroidComplete = true;\n+ } else if (newLDWH.length > lastLDWH.length) {\n+ LayoutAnimation.easeInEaseOut();\n}\n}\n@@ -631,6 +634,12 @@ class InnerCalendar extends React.PureComponent {\n}\nonEntryFocus = (key: string) => {\n+ if (\n+ _size(this.extraData.focusedEntries) === 1 &&\n+ this.extraData.focusedEntries[key]\n+ ) {\n+ return;\n+ }\nthis.extraData = {\nvisibleEntries: this.extraData.visibleEntries,\nfocusedEntries: { [key]: true },\n"
},
{
"change_type": "MODIFY",
"old_path": "native/calendar/entry.react.js",
"new_path": "native/calendar/entry.react.js",
"diff": "@@ -224,22 +224,20 @@ class Entry extends React.Component {\n);\n}\nconst entryStyle = { backgroundColor: `#${this.state.color}` };\n- const textColor = darkColor ? 'white' : 'black';\n- const textStyle = { color: textColor };\n- const textInputStyle: Object = {\n- color: textColor,\n+ const textStyle: Object = {\n+ color: darkColor ? 'white' : 'black',\n};\nif (focused) {\n- textInputStyle.paddingBottom = 0;\n+ textStyle.paddingBottom = 0;\n} else {\n- textInputStyle.height = this.state.height;\n+ textStyle.height = this.state.height;\n}\nlet text;\nconst visible = this.props.visible || !this.props.entryInfo.id;\nif (visible || !this.props.entryInfo.id) {\ntext = (\n<TextInput\n- style={[styles.textInput, textInputStyle]}\n+ style={[styles.textInput, textStyle]}\nunderlineColorAndroid=\"transparent\"\nvalue={this.state.text}\nonChangeText={this.onChangeText}\n@@ -253,14 +251,17 @@ class Entry extends React.Component {\n);\n} else {\ntext = (\n- <Text style={[styles.textInput, textInputStyle]}>\n+ <Text style={[styles.textInput, textStyle]}>\n{this.state.text}\n</Text>\n);\n}\nreturn (\n<View style={styles.container}>\n- <View style={[styles.entry, entryStyle]}>\n+ <View\n+ style={[styles.entry, entryStyle]}\n+ onStartShouldSetResponderCapture={this.onFocus}\n+ >\n{text}\n{actionLinks}\n</View>\n@@ -274,6 +275,7 @@ class Entry extends React.Component {\nonFocus = () => {\nthis.props.onFocus(entryKey(this.props.entryInfo));\n+ return false;\n}\nonBlur = (event: SyntheticEvent) => {\n"
},
{
"change_type": "MODIFY",
"old_path": "native/calendar/thread-picker.react.js",
"new_path": "native/calendar/thread-picker.react.js",
"diff": "@@ -13,7 +13,6 @@ import {\nTouchableWithoutFeedback,\nFlatList,\nTouchableHighlight,\n- LayoutAnimation,\n} from 'react-native';\nimport Icon from 'react-native-vector-icons/FontAwesome';\nimport { connect } from 'react-redux';\n@@ -106,7 +105,6 @@ class ThreadPicker extends React.PureComponent {\nthreadPicked = (calendarID: string) => {\nthis.props.close();\n- LayoutAnimation.easeInEaseOut();\nthis.props.dispatchActionPayload(\ncreateLocalEntryActionType,\ncreateLocalEntry(calendarID, this.props.dateString, this.props.username),\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Faster response and move of LayoutAnimation call to a more precise place |
129,187 | 26.05.2017 20:11:52 | 14,400 | 7f4805a0c2874bab99d890e43e8aeb5cd8898d37 | Android improvements on entry behavior on select and text change | [
{
"change_type": "MODIFY",
"old_path": "native/calendar/entry.react.js",
"new_path": "native/calendar/entry.react.js",
"diff": "@@ -226,18 +226,13 @@ class Entry extends React.Component {\nconst entryStyle = { backgroundColor: `#${this.state.color}` };\nconst textStyle: Object = {\ncolor: darkColor ? 'white' : 'black',\n+ height: this.state.height,\n};\n- if (focused) {\n- textStyle.paddingBottom = 0;\n- } else {\n- textStyle.height = this.state.height;\n- }\nlet text;\n- const visible = this.props.visible || !this.props.entryInfo.id;\n- if (visible || !this.props.entryInfo.id) {\n+ if (this.props.visible || !this.props.entryInfo.id) {\ntext = (\n<TextInput\n- style={[styles.textInput, textStyle]}\n+ style={[styles.text, textStyle]}\nunderlineColorAndroid=\"transparent\"\nvalue={this.state.text}\nonChangeText={this.onChangeText}\n@@ -251,7 +246,7 @@ class Entry extends React.Component {\n);\n} else {\ntext = (\n- <Text style={[styles.textInput, textStyle]}>\n+ <Text style={[styles.text, textStyle]}>\n{this.state.text}\n</Text>\n);\n@@ -448,7 +443,7 @@ const styles = StyleSheet.create({\nmargin: 5,\noverflow: 'hidden',\n},\n- textInput: {\n+ text: {\nfontSize: 16,\npaddingTop: 5,\npaddingBottom: 5,\n@@ -461,6 +456,7 @@ const styles = StyleSheet.create({\nactionLinks: {\nflex: 1,\nflexDirection: 'row',\n+ marginTop: -5,\n},\ndeleteButton: {\npaddingLeft: 10,\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Android improvements on entry behavior on select and text change |
129,187 | 26.05.2017 20:44:58 | 14,400 | e285ee521808ff026058679e0603910df1a78e9b | Display thread name on the right side of the entry in the action links | [
{
"change_type": "MODIFY",
"old_path": "native/calendar/entry.react.js",
"new_path": "native/calendar/entry.react.js",
"diff": "@@ -204,6 +204,7 @@ class Entry extends React.Component {\nconst actionLinksUnderlayColor = darkColor ? \"#AAAAAA88\" : \"#CCCCCCDD\";\nactionLinks = (\n<View style={styles.actionLinks}>\n+ <View style={styles.leftLinks}>\n<Button\nonSubmit={this.onPressDelete}\nunderlayColor={actionLinksUnderlayColor}\n@@ -215,12 +216,21 @@ class Entry extends React.Component {\nsize={14}\ncolor={actionLinksColor}\n/>\n- <Text style={[styles.actionLinksText, actionLinksTextStyle]}>\n+ <Text style={[styles.leftLinksText, actionLinksTextStyle]}>\nDELETE\n</Text>\n</View>\n</Button>\n</View>\n+ <View style={styles.rightLinks}>\n+ <Text\n+ style={[styles.rightLinksText, actionLinksTextStyle]}\n+ numberOfLines={1}\n+ >\n+ {this.props.calendarInfo.name}\n+ </Text>\n+ </View>\n+ </View>\n);\n}\nconst entryStyle = { backgroundColor: `#${this.state.color}` };\n@@ -456,6 +466,7 @@ const styles = StyleSheet.create({\nactionLinks: {\nflex: 1,\nflexDirection: 'row',\n+ justifyContent: 'space-between',\nmarginTop: -5,\n},\ndeleteButton: {\n@@ -468,11 +479,27 @@ const styles = StyleSheet.create({\nflex: 1,\nflexDirection: 'row',\n},\n- actionLinksText: {\n+ leftLinks: {\n+ flex: 1,\n+ flexDirection: 'row',\n+ justifyContent: 'flex-start',\n+ },\n+ leftLinksText: {\npaddingLeft: 5,\nfontWeight: 'bold',\nfontSize: 12,\n},\n+ rightLinks: {\n+ flex: 1,\n+ flexDirection: 'row',\n+ justifyContent: 'flex-end',\n+ },\n+ rightLinksText: {\n+ paddingTop: 5,\n+ paddingRight: 10,\n+ fontWeight: 'bold',\n+ fontSize: 12,\n+ },\n});\nexport default connect(\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Display thread name on the right side of the entry in the action links |
129,187 | 27.05.2017 13:52:22 | 14,400 | 7629754891a3690a3f9bab0dac4c3010e568124a | expectedEntriesOnScreen: a shared way to handle listShrinkingloadingNewEntriesFromScroll, and readyToShowList without timers!
Basically, we just determine which entries we expect to see on screen, and wait for onViewableItemsChanged to tell us they are there | [
{
"change_type": "MODIFY",
"old_path": "native/calendar/calendar.react.js",
"new_path": "native/calendar/calendar.react.js",
"diff": "@@ -154,7 +154,6 @@ class InnerCalendar extends React.PureComponent {\ntextHeights: ?{ [text: string]: number } = null;\ncurrentState: ?string = NativeAppState.currentState;\nloadingNewEntriesFromScroll = false;\n- listShrinking = false;\ncurrentScrollPosition: ?number = null;\n// See comment in State extraData flow type above\nextraDataUpdateTimeout: ?number = null;\n@@ -167,6 +166,10 @@ class InnerCalendar extends React.PureComponent {\nlastEntryKeyFocused: ?string = null;\nkeyboardShowListener: ?Object;\nkeyboardShownHeight: ?number = null;\n+ // We calculate what we expect to be the expected entries, and then we wait\n+ // until they're on actually screen to do stuff\n+ expectedEntriesOnScreen: ?string[] = null;\n+ expectedEntriesHaveBeenDisplayed = false;\nconstructor(props: Props) {\nsuper(props);\n@@ -221,6 +224,7 @@ class InnerCalendar extends React.PureComponent {\nlastState.match(/inactive|background/) &&\nthis.currentState === \"active\" &&\nthis.props.sessionExpired() &&\n+ !this.props.tabActive &&\nthis.flatList\n) {\nthis.scrollToToday();\n@@ -242,6 +246,8 @@ class InnerCalendar extends React.PureComponent {\nreadyToShowList: false,\nextraData: this.extraData,\n});\n+ this.expectedEntriesOnScreen = null;\n+ this.expectedEntriesHaveBeenDisplayed = false;\n} else {\n// If we had no entries and just got some we'll scroll to today\nconst newTextToMeasure = InnerCalendar.textToMeasureFromListData(\n@@ -339,12 +345,11 @@ class InnerCalendar extends React.PureComponent {\nif (newStartDate > lastStartDate || newEndDate < lastEndDate) {\n// If there are fewer items in our new data, which happens when the\n// current calendar query gets reset due to inactivity, let's reset the\n- // scroll position to the center (today). Once we're done, we can allow\n- // scrolling logic once again.\n+ // scroll position to the center (today)\nsetTimeout(() => this.scrollToToday(), 50);\n- setTimeout(() => this.listShrinking = false, 200);\nthis.firstScrollUpOnAndroidComplete = false;\n} else if (newStartDate < lastStartDate) {\n+ this.loadingNewEntriesFromScroll = false;\nthis.updateScrollPositionAfterPrepend(lastLDWH, newLDWH);\n} else if (newEndDate > lastEndDate) {\nthis.loadingNewEntriesFromScroll = false;\n@@ -394,7 +399,6 @@ class InnerCalendar extends React.PureComponent {\n} else {\nscrollAction();\n}\n- setTimeout(() => this.loadingNewEntriesFromScroll = false, 500);\n}\nmergeHeightsIntoListData(listData: $ReadOnlyArray<CalendarItem>) {\n@@ -418,15 +422,16 @@ class InnerCalendar extends React.PureComponent {\n};\n})(listData);\nif (\n- this.state.listDataWithHeights &&\n+ // At the start, we need to set expectedEntriesOnScreen since we need to\n+ // wait for our expected items to appear on screen\n+ !this.state.listDataWithHeights ||\n+ // We know that this is going to shrink our FlatList. When our FlatList\n+ // shrinks, componentWillUpdate will trigger scrollToToday\nlistDataWithHeights.length < this.state.listDataWithHeights.length\n) {\n- // We know that this is going to shrink our FlatList, which may cause\n- // either of the ListLoadingIndicators to come into view. When our\n- // FlatList shrinks, componentDidUpdate will trigger scrollToToday (we\n- // can't do it any earlier because of FlatList weirdness). After that\n- // happens, we will reset this back.\n- this.listShrinking = true;\n+ this.expectedEntriesHaveBeenDisplayed = false;\n+ this.expectedEntriesOnScreen =\n+ InnerCalendar.initialEntriesOnScreen(listDataWithHeights);\n}\nif (this.state.listDataWithHeights) {\nthis.setState({ listDataWithHeights, initialNumToRender: 0 });\n@@ -546,9 +551,9 @@ class InnerCalendar extends React.PureComponent {\nconst listDataWithHeights = this.state.listDataWithHeights;\nlet flatList = null;\nif (listDataWithHeights) {\n- const flatListStyle = {\n- opacity: this.state.readyToShowList ? 1 : 0,\n- };\n+ const flatListStyle = { opacity: this.state.readyToShowList ? 1 : 0 };\n+ const initialScrollIndex =\n+ InnerCalendar.initialScrollIndex(listDataWithHeights);\nflatList = (\n<FlatList\ndata={listDataWithHeights}\n@@ -557,7 +562,7 @@ class InnerCalendar extends React.PureComponent {\ngetItemLayout={InnerCalendar.getItemLayout}\nonViewableItemsChanged={this.onViewableItemsChanged}\nonScroll={this.onScroll}\n- initialScrollIndex={this.initialScrollIndex()}\n+ initialScrollIndex={initialScrollIndex}\nkeyboardShouldPersistTaps=\"handled\"\nextraData={this.extraData}\nstyle={[styles.flatList, flatListStyle]}\n@@ -607,9 +612,7 @@ class InnerCalendar extends React.PureComponent {\n: windowHeight - contentVerticalOffset - 49;\n}\n- initialScrollIndex = () => {\n- const data = this.state.listDataWithHeights;\n- invariant(data, \"should be set\");\n+ static initialScrollIndex(data: $ReadOnlyArray<CalendarItemWithHeight>) {\nconst todayIndex = _findIndex(['dateString', dateString(new Date())])(data);\nconst heightOfTodayHeader = InnerCalendar.itemHeight(data[todayIndex]);\n@@ -621,16 +624,28 @@ class InnerCalendar extends React.PureComponent {\nreturn returnIndex;\n}\n+ static initialEntriesOnScreen(data: $ReadOnlyArray<CalendarItemWithHeight>) {\n+ const initialScrollIndex = InnerCalendar.initialScrollIndex(data);\n+ const flatListHeight = InnerCalendar.flatListHeight();\n+ const entries = [];\n+ for (\n+ let i = initialScrollIndex, height = 0;\n+ i < data.length && height < flatListHeight;\n+ i++, height += InnerCalendar.itemHeight(data[i])\n+ ) {\n+ if (data[i].itemType === \"entryInfo\") {\n+ entries.push(entryKey(data[i].entryInfo));\n+ }\n+ }\n+ return entries;\n+ }\n+\ntextHeightMeasurerRef = (textHeightMeasurer: ?TextHeightMeasurer) => {\nthis.textHeightMeasurer = textHeightMeasurer;\n}\nflatListRef = (flatList: ?FlatList<CalendarItemWithHeight>) => {\nthis.flatList = flatList;\n- if (flatList && !this.state.readyToShowList) {\n- const waitTime = Platform.OS === \"android\" ? 250 : 50;\n- setTimeout(() => this.setState({ readyToShowList: true }), waitTime);\n- }\n}\nonEntryFocus = (key: string) => {\n@@ -709,11 +724,28 @@ class InnerCalendar extends React.PureComponent {\nviewableItems: ViewToken[],\nchanged: ViewToken[],\n}) => {\n+ if (this.loadingNewEntriesFromScroll) {\n+ return;\n+ }\n+\nconst viewableEntries = _compact(_map(\n(token: ViewToken) => token.item.itemType === \"entryInfo\"\n? entryKey(token.item.entryInfo)\n: null,\n)(info.viewableItems));\n+ if (!this.expectedEntriesHaveBeenDisplayed) {\n+ if (\n+ _difference(this.expectedEntriesOnScreen)(viewableEntries).length === 0\n+ ) {\n+ this.expectedEntriesHaveBeenDisplayed = true;\n+ if (!this.state.readyToShowList) {\n+ this.setState({ readyToShowList: true });\n+ }\n+ } else {\n+ return;\n+ }\n+ }\n+\nconst visibleEntries = {};\nfor (let viewableEntry of viewableEntries) {\nvisibleEntries[viewableEntry] = true;\n@@ -725,11 +757,7 @@ class InnerCalendar extends React.PureComponent {\n};\nconst newDataSameAsCurrent =\n_isEqual(this.state.extraData)(this.extraData);\n- if (\n- !this.extraDataUpdateTimeout &&\n- !newDataSameAsCurrent &&\n- !this.loadingNewEntriesFromScroll\n- ) {\n+ if (!this.extraDataUpdateTimeout && !newDataSameAsCurrent) {\nthis.extraDataUpdateTimeout =\nsetTimeout(this.triggerExtraDataUpdate, 1000);\n} else if (this.extraDataUpdateTimeout && newDataSameAsCurrent) {\n@@ -737,13 +765,6 @@ class InnerCalendar extends React.PureComponent {\nthis.extraDataUpdateTimeout = null;\n}\n- if (\n- !this.state.readyToShowList ||\n- this.loadingNewEntriesFromScroll ||\n- this.listShrinking\n- ) {\n- return;\n- }\nconst firstItem = _find({ key: \"TopLoader\" })(info.viewableItems);\nconst lastItem = _find({ key: \"BottomLoader\" })(info.viewableItems);\nlet start: ?Date = null;\n@@ -762,6 +783,8 @@ class InnerCalendar extends React.PureComponent {\nreturn;\n}\nthis.loadingNewEntriesFromScroll = true;\n+ this.expectedEntriesOnScreen = viewableEntries;\n+ this.expectedEntriesHaveBeenDisplayed = false;\nif (this.extraDataUpdateTimeout) {\nclearTimeout(this.extraDataUpdateTimeout);\nthis.extraDataUpdateTimeout = null;\n@@ -782,10 +805,10 @@ class InnerCalendar extends React.PureComponent {\n// To avoid this effect, whenever onViewableItemsChanged triggers we schedule\n// an extra data update, which we only execute once per second max.\ntriggerExtraDataUpdate = () => {\n+ this.extraDataUpdateTimeout = null;\nif (!_isEqual(this.state.extraData)(this.extraData)) {\nthis.setState({ extraData: this.extraData });\n}\n- this.extraDataUpdateTimeout = null;\n}\nonScroll = (event: { nativeEvent: { contentOffset: { y: number } } }) => {\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | expectedEntriesOnScreen: a shared way to handle listShrinkingloadingNewEntriesFromScroll, and readyToShowList without timers!
Basically, we just determine which entries we expect to see on screen, and wait for onViewableItemsChanged to tell us they are there |
129,187 | 27.05.2017 16:25:27 | 14,400 | d06473fcd1c33c02d7281f70f130d5b384858d98 | Get rid of unused prop initialNumToRender on Calendar | [
{
"change_type": "MODIFY",
"old_path": "native/calendar/calendar.react.js",
"new_path": "native/calendar/calendar.react.js",
"diff": "@@ -98,7 +98,6 @@ type State = {\ntextToMeasure: string[],\nlistDataWithHeights: ?$ReadOnlyArray<CalendarItemWithHeight>,\nreadyToShowList: bool,\n- initialNumToRender: number,\npickerOpenForDateString: ?string,\n// We actually don't pay much attention to this extraData... we pass\n// this.extraData around instead. This exists here because sometimes we update\n@@ -184,7 +183,6 @@ class InnerCalendar extends React.PureComponent {\ntextToMeasure,\nlistDataWithHeights: null,\nreadyToShowList: false,\n- initialNumToRender: 31,\npickerOpenForDateString: null,\nextraData: this.extraData,\n};\n@@ -433,12 +431,8 @@ class InnerCalendar extends React.PureComponent {\nthis.expectedEntriesOnScreen =\nInnerCalendar.initialEntriesOnScreen(listDataWithHeights);\n}\n- if (this.state.listDataWithHeights) {\n- this.setState({ listDataWithHeights, initialNumToRender: 0 });\n- } else {\nthis.setState({ listDataWithHeights });\n}\n- }\nscrollToToday = (animated: ?bool = undefined) => {\nif (animated === undefined) {\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Get rid of unused prop initialNumToRender on Calendar |
129,187 | 27.05.2017 16:29:14 | 14,400 | af5ecea4833235c81127536effeda726104c5346 | minHeight on TextHeightMeasurer (20 for calendar entries) | [
{
"change_type": "MODIFY",
"old_path": "native/calendar/calendar.react.js",
"new_path": "native/calendar/calendar.react.js",
"diff": "@@ -590,6 +590,7 @@ class InnerCalendar extends React.PureComponent {\n<TextHeightMeasurer\ntextToMeasure={this.state.textToMeasure}\nallHeightsMeasuredCallback={this.allHeightsMeasured}\n+ minHeight={20}\nstyle={styles.text}\nref={this.textHeightMeasurerRef}\n/>\n"
},
{
"change_type": "MODIFY",
"old_path": "native/text-height-measurer.react.js",
"new_path": "native/text-height-measurer.react.js",
"diff": "@@ -19,6 +19,7 @@ type Props = {\ntextToMeasure: string[],\nheights: TextToHeight,\n) => void,\n+ minHeight?: number,\nstyle: StyleObj,\n};\ntype State = {\n@@ -33,6 +34,7 @@ class TextHeightMeasurer extends React.PureComponent {\nstatic propTypes = {\ntextToMeasure: PropTypes.arrayOf(PropTypes.string).isRequired,\nallHeightsMeasuredCallback: PropTypes.func.isRequired,\n+ minHeight: PropTypes.number,\nstyle: Text.propTypes.style,\n};\n@@ -77,7 +79,10 @@ class TextHeightMeasurer extends React.PureComponent {\nevent: { nativeEvent: { layout: { height: number }}},\n) {\ninvariant(this.nextTextToHeight, \"nextTextToHeight should be set\");\n- this.nextTextToHeight[text] = event.nativeEvent.layout.height;\n+ this.nextTextToHeight[text] =\n+ this.props.minHeight !== undefined && this.props.minHeight !== null\n+ ? Math.max(event.nativeEvent.layout.height, this.props.minHeight)\n+ : event.nativeEvent.layout.height;\nthis.leftToMeasure.delete(text);\nthis.leftInBatch--;\nif (this.leftToMeasure.size === 0) {\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | minHeight on TextHeightMeasurer (20 for calendar entries) |
129,187 | 27.05.2017 17:26:47 | 14,400 | 616ea24dd9fbaf49679eedb8bf7b10210729c3aa | Way less jerkiness! Used secret ScrollView callbacks onMomentumScrollEnd and onScrollEndDrag to detect when scrolling stops, and only focus Entries at that point to minimize off-screen TextInput renders, which are the primary cause of the jerkiness | [
{
"change_type": "MODIFY",
"old_path": "native/calendar/calendar.react.js",
"new_path": "native/calendar/calendar.react.js",
"diff": "@@ -99,12 +99,6 @@ type State = {\nlistDataWithHeights: ?$ReadOnlyArray<CalendarItemWithHeight>,\nreadyToShowList: bool,\npickerOpenForDateString: ?string,\n- // We actually don't pay much attention to this extraData... we pass\n- // this.extraData around instead. This exists here because sometimes we update\n- // extraData without a corresponding update in something else, and so we need\n- // to trigger a re-render with setState. But in many cases a re-render is\n- // going to get triggered anyways, and in those cases we may update\n- // this.extraData without updating this.state.extraData.\nextraData: ExtraData,\n};\nclass InnerCalendar extends React.PureComponent {\n@@ -154,9 +148,9 @@ class InnerCalendar extends React.PureComponent {\ncurrentState: ?string = NativeAppState.currentState;\nloadingNewEntriesFromScroll = false;\ncurrentScrollPosition: ?number = null;\n- // See comment in State extraData flow type above\n- extraDataUpdateTimeout: ?number = null;\n- extraData: ExtraData;\n+ // We don't always want an extraData update to trigger a state update, so we\n+ // cache the most recent value as a member here\n+ latestExtraData: 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.\nfirstScrollUpOnAndroidComplete = false;\n@@ -175,7 +169,7 @@ class InnerCalendar extends React.PureComponent {\nconst textToMeasure = props.listData\n? InnerCalendar.textToMeasureFromListData(props.listData)\n: [];\n- this.extraData = {\n+ this.latestExtraData = {\nfocusedEntries: {},\nvisibleEntries: {},\n};\n@@ -184,7 +178,7 @@ class InnerCalendar extends React.PureComponent {\nlistDataWithHeights: null,\nreadyToShowList: false,\npickerOpenForDateString: null,\n- extraData: this.extraData,\n+ extraData: this.latestExtraData,\n};\n}\n@@ -234,7 +228,7 @@ class InnerCalendar extends React.PureComponent {\nif (newProps.listData !== this.props.listData) {\nconst newListData = newProps.listData;\nif (!newListData) {\n- this.extraData = {\n+ this.latestExtraData = {\nfocusedEntries: {},\nvisibleEntries: {},\n};\n@@ -242,7 +236,7 @@ class InnerCalendar extends React.PureComponent {\ntextToMeasure: [],\nlistDataWithHeights: null,\nreadyToShowList: false,\n- extraData: this.extraData,\n+ extraData: this.latestExtraData,\n});\nthis.expectedEntriesOnScreen = null;\nthis.expectedEntriesHaveBeenDisplayed = false;\n@@ -460,8 +454,8 @@ class InnerCalendar extends React.PureComponent {\nreturn (\n<Entry\nentryInfo={item.entryInfo}\n- focused={!!this.extraData.focusedEntries[key]}\n- visible={!!this.extraData.visibleEntries[key]}\n+ focused={!!this.state.extraData.focusedEntries[key]}\n+ visible={!!this.state.extraData.visibleEntries[key]}\nonFocus={this.onEntryFocus}\n/>\n);\n@@ -558,7 +552,9 @@ class InnerCalendar extends React.PureComponent {\nonScroll={this.onScroll}\ninitialScrollIndex={initialScrollIndex}\nkeyboardShouldPersistTaps=\"handled\"\n- extraData={this.extraData}\n+ onMomentumScrollEnd={this.onMomentumScrollEnd}\n+ onScrollEndDrag={this.onScrollEndDrag}\n+ extraData={this.state.extraData}\nstyle={[styles.flatList, flatListStyle]}\nref={this.flatListRef}\n/>\n@@ -645,16 +641,25 @@ class InnerCalendar extends React.PureComponent {\nonEntryFocus = (key: string) => {\nif (\n- _size(this.extraData.focusedEntries) === 1 &&\n- this.extraData.focusedEntries[key]\n+ _size(this.state.extraData.focusedEntries) === 1 &&\n+ this.state.extraData.focusedEntries[key]\n) {\n+ if (\n+ _size(this.latestExtraData.focusedEntries) !== 1 ||\n+ !this.latestExtraData.focusedEntries[key]\n+ ) {\n+ this.latestExtraData = {\n+ visibleEntries: this.latestExtraData.visibleEntries,\n+ focusedEntries: this.state.extraData.focusedEntries,\n+ };\n+ }\nreturn;\n}\n- this.extraData = {\n- visibleEntries: this.extraData.visibleEntries,\n+ this.latestExtraData = {\n+ visibleEntries: this.latestExtraData.visibleEntries,\nfocusedEntries: { [key]: true },\n};\n- this.setState({ extraData: this.extraData });\n+ this.setState({ extraData: this.latestExtraData });\nconst keyboardShownHeight = this.keyboardShownHeight;\nif (keyboardShownHeight) {\nthis.scrollToKey(key, keyboardShownHeight);\n@@ -719,10 +724,6 @@ class InnerCalendar extends React.PureComponent {\nviewableItems: ViewToken[],\nchanged: ViewToken[],\n}) => {\n- if (this.loadingNewEntriesFromScroll) {\n- return;\n- }\n-\nconst viewableEntries = _compact(_map(\n(token: ViewToken) => token.item.itemType === \"entryInfo\"\n? entryKey(token.item.entryInfo)\n@@ -741,24 +742,19 @@ class InnerCalendar extends React.PureComponent {\n}\n}\n+ if (this.loadingNewEntriesFromScroll) {\n+ return;\n+ }\n+\nconst visibleEntries = {};\nfor (let viewableEntry of viewableEntries) {\nvisibleEntries[viewableEntry] = true;\n}\n- this.extraData = {\n+ this.latestExtraData = {\nfocusedEntries:\n- _pick(viewableEntries)(this.extraData.focusedEntries),\n+ _pick(viewableEntries)(this.latestExtraData.focusedEntries),\nvisibleEntries,\n};\n- const newDataSameAsCurrent =\n- _isEqual(this.state.extraData)(this.extraData);\n- if (!this.extraDataUpdateTimeout && !newDataSameAsCurrent) {\n- this.extraDataUpdateTimeout =\n- setTimeout(this.triggerExtraDataUpdate, 1000);\n- } else if (this.extraDataUpdateTimeout && newDataSameAsCurrent) {\n- clearTimeout(this.extraDataUpdateTimeout);\n- this.extraDataUpdateTimeout = null;\n- }\nconst firstItem = _find({ key: \"TopLoader\" })(info.viewableItems);\nconst lastItem = _find({ key: \"BottomLoader\" })(info.viewableItems);\n@@ -780,10 +776,6 @@ class InnerCalendar extends React.PureComponent {\nthis.loadingNewEntriesFromScroll = true;\nthis.expectedEntriesOnScreen = viewableEntries;\nthis.expectedEntriesHaveBeenDisplayed = false;\n- if (this.extraDataUpdateTimeout) {\n- clearTimeout(this.extraDataUpdateTimeout);\n- this.extraDataUpdateTimeout = null;\n- }\nthis.props.dispatchActionPromise(\nfetchEntriesAndAppendRangeActionType,\nthis.props.fetchEntriesWithRange({\n@@ -794,20 +786,30 @@ class InnerCalendar extends React.PureComponent {\n);\n}\n- // We want to avoid updating extraData too often, as it leads to update cycles\n- // on the FlatList. However, onViewableItemsChanged is primarily responsible\n- // for updating the FlatList, and it likes to send tons of updates in spurts.\n- // To avoid this effect, whenever onViewableItemsChanged triggers we schedule\n- // an extra data update, which we only execute once per second max.\n- triggerExtraDataUpdate = () => {\n- this.extraDataUpdateTimeout = null;\n- if (!_isEqual(this.state.extraData)(this.extraData)) {\n- this.setState({ extraData: this.extraData });\n+ onScroll = (event: { nativeEvent: { contentOffset: { y: number } } }) => {\n+ this.currentScrollPosition = event.nativeEvent.contentOffset.y;\n}\n+\n+ // When the user \"flicks\" the scroll view, this callback gets triggered after\n+ // the scrolling ends\n+ onMomentumScrollEnd = () => {\n+ this.setState({ extraData: this.latestExtraData });\n}\n- onScroll = (event: { nativeEvent: { contentOffset: { y: number } } }) => {\n- this.currentScrollPosition = event.nativeEvent.contentOffset.y;\n+ // This callback gets triggered when the user lets go of scrolling the scroll\n+ // view, regardless of whether it was a \"flick\" or a pan\n+ onScrollEndDrag = () => {\n+ // We need to figure out if this was a flick or not. If it's a flick, we'll\n+ // let onMomentumScrollEnd handle it once scroll position stabilizes\n+ const currentScrollPosition = this.currentScrollPosition;\n+ setTimeout(\n+ () => {\n+ if (this.currentScrollPosition === currentScrollPosition) {\n+ this.setState({ extraData: this.latestExtraData });\n+ }\n+ },\n+ 50,\n+ );\n}\nclosePicker = () => {\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Way less jerkiness! Used secret ScrollView callbacks onMomentumScrollEnd and onScrollEndDrag to detect when scrolling stops, and only focus Entries at that point to minimize off-screen TextInput renders, which are the primary cause of the jerkiness |
129,187 | 27.05.2017 19:50:51 | 14,400 | 7e9a6cfff3a55105b54133d07f84626a23c8c7d3 | Numerous refinements to the Calendar FlatList, primarily around scroll behavior. It's finally starting to actually sorta look good! | [
{
"change_type": "MODIFY",
"old_path": "native/calendar/calendar.react.js",
"new_path": "native/calendar/calendar.react.js",
"diff": "@@ -33,9 +33,9 @@ import _find from 'lodash/fp/find';\nimport _difference from 'lodash/fp/difference';\nimport _filter from 'lodash/fp/filter';\nimport _sum from 'lodash/fp/sum';\n-import _pick from 'lodash/fp/pick';\n+import _pickBy from 'lodash/fp/pickBy';\nimport _size from 'lodash/fp/size';\n-import _compact from 'lodash/fp/compact';\n+import _intersection from 'lodash/fp/intersection';\nimport { entryKey } from 'lib/shared/entry-utils';\nimport { dateString, prettyDate, dateFromString } from 'lib/utils/date-utils';\n@@ -146,7 +146,7 @@ class InnerCalendar extends React.PureComponent {\nflatList: ?FlatList<CalendarItemWithHeight> = null;\ntextHeights: ?{ [text: string]: number } = null;\ncurrentState: ?string = NativeAppState.currentState;\n- loadingNewEntriesFromScroll = false;\n+ loadingFromScrollState: (\"inactive\" | \"loading\" | \"willUpdate\") = \"inactive\";\ncurrentScrollPosition: ?number = null;\n// We don't always want an extraData update to trigger a state update, so we\n// cache the most recent value as a member here\n@@ -161,8 +161,11 @@ class InnerCalendar extends React.PureComponent {\nkeyboardShownHeight: ?number = null;\n// We calculate what we expect to be the expected entries, and then we wait\n// until they're on actually screen to do stuff\n- expectedEntriesOnScreen: ?string[] = null;\n- expectedEntriesHaveBeenDisplayed = false;\n+ expectedKeysOnScreen: ?string[] = null;\n+ expectedKeysHaveBeenDisplayed = false;\n+ // This is just delayed 100ms after expectedKeysHaveBeenDisplayed to make sure\n+ // we don't double-trigger prepends\n+ readyForScroll = false;\nconstructor(props: Props) {\nsuper(props);\n@@ -238,8 +241,9 @@ class InnerCalendar extends React.PureComponent {\nreadyToShowList: false,\nextraData: this.latestExtraData,\n});\n- this.expectedEntriesOnScreen = null;\n- this.expectedEntriesHaveBeenDisplayed = false;\n+ this.expectedKeysOnScreen = null;\n+ this.expectedKeysHaveBeenDisplayed = false;\n+ this.readyForScroll = false;\n} else {\n// If we had no entries and just got some we'll scroll to today\nconst newTextToMeasure = InnerCalendar.textToMeasureFromListData(\n@@ -313,7 +317,43 @@ class InnerCalendar extends React.PureComponent {\nif (!lastLDWH || !newLDWH) {\nreturn;\n}\n+ const { lastStartDate, newStartDate, lastEndDate, newEndDate }\n+ = InnerCalendar.datesFromListData(lastLDWH, newLDWH);\n+ if (newStartDate > lastStartDate || newEndDate < lastEndDate) {\n+ // If there are fewer items in our new data, which happens when the\n+ // current calendar query gets reset due to inactivity, let's reset the\n+ // scroll position to the center (today)\n+ setTimeout(() => this.scrollToToday(), 50);\n+ this.firstScrollUpOnAndroidComplete = false;\n+ } else if (newStartDate < lastStartDate) {\n+ this.updateScrollPositionAfterPrepend(lastLDWH, newLDWH);\n+ this.loadingFromScrollState = \"willUpdate\";\n+ } else if (newEndDate > lastEndDate) {\n+ this.firstScrollUpOnAndroidComplete = true;\n+ this.loadingFromScrollState = \"willUpdate\";\n+ } else if (newLDWH.length > lastLDWH.length) {\n+ LayoutAnimation.easeInEaseOut();\n+ }\n+ }\n+\n+ componentDidUpdate(prevProps: Props, prevState: State) {\n+ const lastLDWH = prevState.listDataWithHeights;\n+ const newLDWH = this.state.listDataWithHeights;\n+ if (!lastLDWH || !newLDWH) {\n+ return;\n+ }\n+ const { lastStartDate, newStartDate, lastEndDate, newEndDate }\n+ = InnerCalendar.datesFromListData(lastLDWH, newLDWH);\n+ if (newStartDate < lastStartDate || newEndDate > lastEndDate) {\n+ this.loadingFromScrollState = \"inactive\";\n+ }\n+ }\n+\n+ static datesFromListData(\n+ lastLDWH: $ReadOnlyArray<CalendarItemWithHeight>,\n+ newLDWH: $ReadOnlyArray<CalendarItemWithHeight>,\n+ ) {\nconst lastSecondItem = lastLDWH[1];\nconst newSecondItem = newLDWH[1];\ninvariant(\n@@ -334,21 +374,7 @@ class InnerCalendar extends React.PureComponent {\nconst lastEndDate = dateFromString(lastPenultimateItem.dateString);\nconst newEndDate = dateFromString(newPenultimateItem.dateString);\n- if (newStartDate > lastStartDate || newEndDate < lastEndDate) {\n- // If there are fewer items in our new data, which happens when the\n- // current calendar query gets reset due to inactivity, let's reset the\n- // scroll position to the center (today)\n- setTimeout(() => this.scrollToToday(), 50);\n- this.firstScrollUpOnAndroidComplete = false;\n- } else if (newStartDate < lastStartDate) {\n- this.loadingNewEntriesFromScroll = false;\n- this.updateScrollPositionAfterPrepend(lastLDWH, newLDWH);\n- } else if (newEndDate > lastEndDate) {\n- this.loadingNewEntriesFromScroll = false;\n- this.firstScrollUpOnAndroidComplete = true;\n- } else if (newLDWH.length > lastLDWH.length) {\n- LayoutAnimation.easeInEaseOut();\n- }\n+ return { lastStartDate, newStartDate, lastEndDate, newEndDate };\n}\n/**\n@@ -414,16 +440,17 @@ class InnerCalendar extends React.PureComponent {\n};\n})(listData);\nif (\n- // At the start, we need to set expectedEntriesOnScreen since we need to\n+ // At the start, we need to set expectedKeysOnScreen since we need to\n// wait for our expected items to appear on screen\n!this.state.listDataWithHeights ||\n// We know that this is going to shrink our FlatList. When our FlatList\n// shrinks, componentWillUpdate will trigger scrollToToday\nlistDataWithHeights.length < this.state.listDataWithHeights.length\n) {\n- this.expectedEntriesHaveBeenDisplayed = false;\n- this.expectedEntriesOnScreen =\n- InnerCalendar.initialEntriesOnScreen(listDataWithHeights);\n+ this.expectedKeysHaveBeenDisplayed = false;\n+ this.readyForScroll = false;\n+ this.expectedKeysOnScreen =\n+ InnerCalendar.initialKeysOnScreen(listDataWithHeights);\n}\nthis.setState({ listDataWithHeights });\n}\n@@ -615,7 +642,7 @@ class InnerCalendar extends React.PureComponent {\nreturn returnIndex;\n}\n- static initialEntriesOnScreen(data: $ReadOnlyArray<CalendarItemWithHeight>) {\n+ static initialKeysOnScreen(data: $ReadOnlyArray<CalendarItemWithHeight>) {\nconst initialScrollIndex = InnerCalendar.initialScrollIndex(data);\nconst flatListHeight = InnerCalendar.flatListHeight();\nconst entries = [];\n@@ -624,9 +651,7 @@ class InnerCalendar extends React.PureComponent {\ni < data.length && height < flatListHeight;\ni++, height += InnerCalendar.itemHeight(data[i])\n) {\n- if (data[i].itemType === \"entryInfo\") {\n- entries.push(entryKey(data[i].entryInfo));\n- }\n+ entries.push(InnerCalendar.keyExtractor(data[i]));\n}\nreturn entries;\n}\n@@ -724,38 +749,59 @@ class InnerCalendar extends React.PureComponent {\nviewableItems: ViewToken[],\nchanged: ViewToken[],\n}) => {\n- const viewableEntries = _compact(_map(\n- (token: ViewToken) => token.item.itemType === \"entryInfo\"\n- ? entryKey(token.item.entryInfo)\n- : null,\n- )(info.viewableItems));\n- if (!this.expectedEntriesHaveBeenDisplayed) {\n+ const viewableItems = _map(\n+ (token: ViewToken) => InnerCalendar.keyExtractor(token.item),\n+ )(info.viewableItems);\n+ const expectedKeysOnScreen = this.expectedKeysOnScreen;\n+ let expectedEntriesDisplayed = false;\nif (\n- _difference(this.expectedEntriesOnScreen)(viewableEntries).length === 0\n+ // If we already displayed the new items and triggered the scroll\n+ this.loadingFromScrollState !== \"loading\" &&\n+ // But we haven't yet displayed the expected entries\n+ !this.expectedKeysHaveBeenDisplayed &&\n+ expectedKeysOnScreen &&\n+ // And at least one of the expected entries is on the screen\n+ _intersection(expectedKeysOnScreen)(viewableItems).length > 0\n) {\n- this.expectedEntriesHaveBeenDisplayed = true;\n- if (!this.state.readyToShowList) {\n- this.setState({ readyToShowList: true });\n- }\n- } else {\n- return;\n- }\n+ // We have very low standards for what counts as displayed the expected\n+ // entries. That's because the sort of scrolls that this technique is\n+ // meant to detect are invariably many pages of items, and there are\n+ // quirky situations where the expected entries are off a bit from what\n+ // actually ends up being displayed.\n+ this.expectedKeysHaveBeenDisplayed = true;\n+ setTimeout(() => this.readyForScroll = true, 100);\n+ expectedEntriesDisplayed = true;\n}\n-\n- if (this.loadingNewEntriesFromScroll) {\n- return;\n+ if (this.loadingFromScrollState === \"loading\") {\n+ // Maintain the most recent value for expectedKeysOnScreen since we'll\n+ // use the most recent scroll position to calculate the new one\n+ this.expectedKeysOnScreen = viewableItems;\n}\nconst visibleEntries = {};\n- for (let viewableEntry of viewableEntries) {\n- visibleEntries[viewableEntry] = true;\n+ for (let token of info.viewableItems) {\n+ if (token.item.itemType === \"entryInfo\") {\n+ visibleEntries[entryKey(token.item.entryInfo)] = true;\n+ }\n}\nthis.latestExtraData = {\n- focusedEntries:\n- _pick(viewableEntries)(this.latestExtraData.focusedEntries),\n+ focusedEntries: _pickBy((_, key: string) => visibleEntries[key])\n+ (this.latestExtraData.focusedEntries),\nvisibleEntries,\n};\n+ if (!this.state.readyToShowList && expectedEntriesDisplayed) {\n+ this.setState({\n+ readyToShowList: true,\n+ extraData: this.latestExtraData,\n+ });\n+ }\n+\n+ if (!this.readyForScroll) {\n+ // Don't allow triggering start/end load until we see the expected entries\n+ return;\n+ }\n+\nconst firstItem = _find({ key: \"TopLoader\" })(info.viewableItems);\nconst lastItem = _find({ key: \"BottomLoader\" })(info.viewableItems);\nlet start: ?Date = null;\n@@ -773,9 +819,10 @@ class InnerCalendar extends React.PureComponent {\n} else {\nreturn;\n}\n- this.loadingNewEntriesFromScroll = true;\n- this.expectedEntriesOnScreen = viewableEntries;\n- this.expectedEntriesHaveBeenDisplayed = false;\n+ this.loadingFromScrollState = \"loading\";\n+ this.expectedKeysOnScreen = viewableItems;\n+ this.expectedKeysHaveBeenDisplayed = false;\n+ this.readyForScroll = false;\nthis.props.dispatchActionPromise(\nfetchEntriesAndAppendRangeActionType,\nthis.props.fetchEntriesWithRange({\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Numerous refinements to the Calendar FlatList, primarily around scroll behavior. It's finally starting to actually sorta look good! |
129,187 | 27.05.2017 20:48:59 | 14,400 | 99ad80a7646bc04a7858b170e224790d31769152 | Much better detect-new-items-added method - just make sure the loader items aren't on-screen anymore. Way simpler, and works better. | [
{
"change_type": "MODIFY",
"old_path": "native/calendar/calendar.react.js",
"new_path": "native/calendar/calendar.react.js",
"diff": "@@ -35,7 +35,6 @@ import _filter from 'lodash/fp/filter';\nimport _sum from 'lodash/fp/sum';\nimport _pickBy from 'lodash/fp/pickBy';\nimport _size from 'lodash/fp/size';\n-import _intersection from 'lodash/fp/intersection';\nimport { entryKey } from 'lib/shared/entry-utils';\nimport { dateString, prettyDate, dateFromString } from 'lib/utils/date-utils';\n@@ -146,7 +145,7 @@ class InnerCalendar extends React.PureComponent {\nflatList: ?FlatList<CalendarItemWithHeight> = null;\ntextHeights: ?{ [text: string]: number } = null;\ncurrentState: ?string = NativeAppState.currentState;\n- loadingFromScrollState: (\"inactive\" | \"loading\" | \"willUpdate\") = \"inactive\";\n+ loadingFromScroll = false;\ncurrentScrollPosition: ?number = null;\n// We don't always want an extraData update to trigger a state update, so we\n// cache the most recent value as a member here\n@@ -159,13 +158,9 @@ class InnerCalendar extends React.PureComponent {\nlastEntryKeyFocused: ?string = null;\nkeyboardShowListener: ?Object;\nkeyboardShownHeight: ?number = null;\n- // We calculate what we expect to be the expected entries, and then we wait\n- // until they're on actually screen to do stuff\n- expectedKeysOnScreen: ?string[] = null;\n- expectedKeysHaveBeenDisplayed = false;\n- // This is just delayed 100ms after expectedKeysHaveBeenDisplayed to make sure\n- // we don't double-trigger prepends\n- readyForScroll = false;\n+ // We wait until the loaders leave view before letting them be triggered again\n+ topLoaderWaitingToLeaveView = true;\n+ bottomLoaderWaitingToLeaveView = true;\nconstructor(props: Props) {\nsuper(props);\n@@ -241,9 +236,8 @@ class InnerCalendar extends React.PureComponent {\nreadyToShowList: false,\nextraData: this.latestExtraData,\n});\n- this.expectedKeysOnScreen = null;\n- this.expectedKeysHaveBeenDisplayed = false;\n- this.readyForScroll = false;\n+ this.topLoaderWaitingToLeaveView = true;\n+ this.bottomLoaderWaitingToLeaveView = true;\n} else {\n// If we had no entries and just got some we'll scroll to today\nconst newTextToMeasure = InnerCalendar.textToMeasureFromListData(\n@@ -328,10 +322,8 @@ class InnerCalendar extends React.PureComponent {\nthis.firstScrollUpOnAndroidComplete = false;\n} else if (newStartDate < lastStartDate) {\nthis.updateScrollPositionAfterPrepend(lastLDWH, newLDWH);\n- this.loadingFromScrollState = \"willUpdate\";\n} else if (newEndDate > lastEndDate) {\nthis.firstScrollUpOnAndroidComplete = true;\n- this.loadingFromScrollState = \"willUpdate\";\n} else if (newLDWH.length > lastLDWH.length) {\nLayoutAnimation.easeInEaseOut();\n}\n@@ -346,7 +338,7 @@ class InnerCalendar extends React.PureComponent {\nconst { lastStartDate, newStartDate, lastEndDate, newEndDate }\n= InnerCalendar.datesFromListData(lastLDWH, newLDWH);\nif (newStartDate < lastStartDate || newEndDate > lastEndDate) {\n- this.loadingFromScrollState = \"inactive\";\n+ this.loadingFromScroll = false;\n}\n}\n@@ -440,17 +432,15 @@ class InnerCalendar extends React.PureComponent {\n};\n})(listData);\nif (\n- // At the start, we need to set expectedKeysOnScreen since we need to\n- // wait for our expected items to appear on screen\n+ // At the start, we need to set LoaderWaitingToLeaveView since we don't\n+ // want the loaders to trigger when nothing is there\n!this.state.listDataWithHeights ||\n// We know that this is going to shrink our FlatList. When our FlatList\n// shrinks, componentWillUpdate will trigger scrollToToday\nlistDataWithHeights.length < this.state.listDataWithHeights.length\n) {\n- this.expectedKeysHaveBeenDisplayed = false;\n- this.readyForScroll = false;\n- this.expectedKeysOnScreen =\n- InnerCalendar.initialKeysOnScreen(listDataWithHeights);\n+ this.topLoaderWaitingToLeaveView = true;\n+ this.bottomLoaderWaitingToLeaveView = true;\n}\nthis.setState({ listDataWithHeights });\n}\n@@ -642,20 +632,6 @@ class InnerCalendar extends React.PureComponent {\nreturn returnIndex;\n}\n- static initialKeysOnScreen(data: $ReadOnlyArray<CalendarItemWithHeight>) {\n- const initialScrollIndex = InnerCalendar.initialScrollIndex(data);\n- const flatListHeight = InnerCalendar.flatListHeight();\n- const entries = [];\n- for (\n- let i = initialScrollIndex, height = 0;\n- i < data.length && height < flatListHeight;\n- i++, height += InnerCalendar.itemHeight(data[i])\n- ) {\n- entries.push(InnerCalendar.keyExtractor(data[i]));\n- }\n- return entries;\n- }\n-\ntextHeightMeasurerRef = (textHeightMeasurer: ?TextHeightMeasurer) => {\nthis.textHeightMeasurer = textHeightMeasurer;\n}\n@@ -718,7 +694,11 @@ class InnerCalendar extends React.PureComponent {\nconst itemEnd = itemStart + itemHeight;\nconst visibleHeight = InnerCalendar.flatListHeight() -\nkeyboardHeight;\n- invariant(this.currentScrollPosition, \"should be set\");\n+ invariant(\n+ this.currentScrollPosition !== undefined &&\n+ this.currentScrollPosition !== null,\n+ \"should be set\",\n+ );\nif (\nitemStart > this.currentScrollPosition &&\nitemEnd < this.currentScrollPosition + visibleHeight\n@@ -749,35 +729,6 @@ class InnerCalendar extends React.PureComponent {\nviewableItems: ViewToken[],\nchanged: ViewToken[],\n}) => {\n- const viewableItems = _map(\n- (token: ViewToken) => InnerCalendar.keyExtractor(token.item),\n- )(info.viewableItems);\n- const expectedKeysOnScreen = this.expectedKeysOnScreen;\n- let expectedEntriesDisplayed = false;\n- if (\n- // If we already displayed the new items and triggered the scroll\n- this.loadingFromScrollState !== \"loading\" &&\n- // But we haven't yet displayed the expected entries\n- !this.expectedKeysHaveBeenDisplayed &&\n- expectedKeysOnScreen &&\n- // And at least one of the expected entries is on the screen\n- _intersection(expectedKeysOnScreen)(viewableItems).length > 0\n- ) {\n- // We have very low standards for what counts as displayed the expected\n- // entries. That's because the sort of scrolls that this technique is\n- // meant to detect are invariably many pages of items, and there are\n- // quirky situations where the expected entries are off a bit from what\n- // actually ends up being displayed.\n- this.expectedKeysHaveBeenDisplayed = true;\n- setTimeout(() => this.readyForScroll = true, 100);\n- expectedEntriesDisplayed = true;\n- }\n- if (this.loadingFromScrollState === \"loading\") {\n- // Maintain the most recent value for expectedKeysOnScreen since we'll\n- // use the most recent scroll position to calculate the new one\n- this.expectedKeysOnScreen = viewableItems;\n- }\n-\nconst visibleEntries = {};\nfor (let token of info.viewableItems) {\nif (token.item.itemType === \"entryInfo\") {\n@@ -790,28 +741,38 @@ class InnerCalendar extends React.PureComponent {\nvisibleEntries,\n};\n- if (!this.state.readyToShowList && expectedEntriesDisplayed) {\n+ const topLoader = _find({ key: \"TopLoader\" })(info.viewableItems);\n+ const bottomLoader = _find({ key: \"BottomLoader\" })(info.viewableItems);\n+ if (!this.loadingFromScroll) {\n+ if (this.topLoaderWaitingToLeaveView && !topLoader) {\n+ this.topLoaderWaitingToLeaveView = false;\n+ }\n+ if (this.bottomLoaderWaitingToLeaveView && !bottomLoader) {\n+ this.bottomLoaderWaitingToLeaveView = false;\n+ }\n+ }\n+\n+ if (\n+ !this.state.readyToShowList &&\n+ !this.topLoaderWaitingToLeaveView &&\n+ !this.bottomLoaderWaitingToLeaveView\n+ ) {\nthis.setState({\nreadyToShowList: true,\nextraData: this.latestExtraData,\n});\n}\n- if (!this.readyForScroll) {\n- // Don't allow triggering start/end load until we see the expected entries\n- return;\n- }\n-\n- const firstItem = _find({ key: \"TopLoader\" })(info.viewableItems);\n- const lastItem = _find({ key: \"BottomLoader\" })(info.viewableItems);\nlet start: ?Date = null;\nlet end: ?Date = null;\n- if (firstItem) {\n+ if (topLoader && !this.topLoaderWaitingToLeaveView) {\n+ this.topLoaderWaitingToLeaveView = true;\nstart = dateFromString(this.props.startDate);\nstart.setDate(start.getDate() - 31);\nend = dateFromString(this.props.startDate);\nend.setDate(end.getDate() - 1);\n- } else if (lastItem) {\n+ } else if (bottomLoader && !this.bottomLoaderWaitingToLeaveView) {\n+ this.bottomLoaderWaitingToLeaveView = true;\nstart = dateFromString(this.props.endDate);\nstart.setDate(start.getDate() + 1);\nend = dateFromString(this.props.endDate);\n@@ -819,10 +780,7 @@ class InnerCalendar extends React.PureComponent {\n} else {\nreturn;\n}\n- this.loadingFromScrollState = \"loading\";\n- this.expectedKeysOnScreen = viewableItems;\n- this.expectedKeysHaveBeenDisplayed = false;\n- this.readyForScroll = false;\n+ this.loadingFromScroll = true;\nthis.props.dispatchActionPromise(\nfetchEntriesAndAppendRangeActionType,\nthis.props.fetchEntriesWithRange({\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Much better detect-new-items-added method - just make sure the loader items aren't on-screen anymore. Way simpler, and works better. |
129,187 | 28.05.2017 12:33:52 | 14,400 | 3c6512f3b17d992e219a412b19be09a8d7c65ce9 | More refinements! Here's a list
Avoid assumption of keyboardShow/onEntryFocus events in pairs for scrollToKey,
No more minHeight
Make sure onBlur always fires when focus lost
Ese autoFocus prop in Entry
Avoid double-deletes and double-saves in Entry
Detect presses on Entry View in lieu of TextInput onFocus | [
{
"change_type": "MODIFY",
"old_path": "native/calendar/calendar.react.js",
"new_path": "native/calendar/calendar.react.js",
"diff": "@@ -603,7 +603,6 @@ class InnerCalendar extends React.PureComponent {\n<TextHeightMeasurer\ntextToMeasure={this.state.textToMeasure}\nallHeightsMeasuredCallback={this.allHeightsMeasured}\n- minHeight={20}\nstyle={styles.text}\nref={this.textHeightMeasurerRef}\n/>\n@@ -670,17 +669,15 @@ class InnerCalendar extends React.PureComponent {\n}\nkeyboardShow = (event: KeyboardEvent) => {\n+ this.keyboardShownHeight = event.endCoordinates.height;\nconst lastEntryKeyFocused = this.lastEntryKeyFocused;\nif (lastEntryKeyFocused) {\nthis.scrollToKey(lastEntryKeyFocused, event.endCoordinates.height);\n- } else {\n- this.keyboardShownHeight = event.endCoordinates.height;\n+ this.lastEntryKeyFocused = null;\n}\n}\nscrollToKey(lastEntryKeyFocused: string, keyboardHeight: number) {\n- this.lastEntryKeyFocused = null;\n- this.keyboardShownHeight = null;\nconst data = this.state.listDataWithHeights;\ninvariant(data, \"should be set\");\nconst index = _findIndex(\n"
},
{
"change_type": "MODIFY",
"old_path": "native/calendar/entry.react.js",
"new_path": "native/calendar/entry.react.js",
"diff": "@@ -114,6 +114,8 @@ class Entry extends React.Component {\nneedsDeleteAfterCreation = false;\nnextSaveAttemptIndex = 0;\nmounted = false;\n+ deleted = false;\n+ currentlySaving: ?string;\nconstructor(props: Props) {\nsuper(props);\n@@ -155,9 +157,12 @@ class Entry extends React.Component {\n) {\nthis.setState({ color: nextProps.calendarInfo.color });\n}\n- if (!nextProps.focused && this.props.focused && this.textInput) {\n+ if (!nextProps.focused && this.props.focused) {\n+ if (this.textInput) {\nthis.textInput.blur();\n}\n+ this.onBlur();\n+ }\n}\nshouldComponentUpdate(nextProps: Props, nextState: State) {\n@@ -177,11 +182,6 @@ class Entry extends React.Component {\n}\ncomponentDidMount() {\n- // Whenever a new Entry is created, focus on it\n- if (!this.props.entryInfo.id) {\n- invariant(this.textInput, \"textInput ref not set\");\n- this.textInput.focus();\n- }\nthis.mounted = true;\n}\n@@ -239,7 +239,7 @@ class Entry extends React.Component {\nheight: this.state.height,\n};\nlet text;\n- if (this.props.visible || !this.props.entryInfo.id) {\n+ if (this.props.visible || focused) {\ntext = (\n<TextInput\nstyle={[styles.text, textStyle]}\n@@ -251,6 +251,7 @@ class Entry extends React.Component {\nonFocus={this.onFocus}\nonContentSizeChange={this.onContentSizeChange}\nonChange={this.onChange}\n+ autoFocus={focused}\nref={this.textInputRef}\n/>\n);\n@@ -263,7 +264,12 @@ class Entry extends React.Component {\n}\nreturn (\n<View style={styles.container}>\n- <View style={[styles.entry, entryStyle]}>\n+ <View\n+ style={[styles.entry, entryStyle]}\n+ onStartShouldSetResponder={this.onStartShouldSetResponder}\n+ onResponderGrant={this.onFocus}\n+ onResponderTerminationRequest={this.onResponderTerminationRequest}\n+ >\n{text}\n{actionLinks}\n</View>\n@@ -275,11 +281,13 @@ class Entry extends React.Component {\nthis.textInput = textInput;\n}\n- onFocus = () => {\n- this.props.onFocus(entryKey(this.props.entryInfo));\n- }\n+ onFocus = () => this.props.onFocus(entryKey(this.props.entryInfo));\n+\n+ onStartShouldSetResponder = () => true;\n+\n+ onResponderTerminationRequest = (event) => true;\n- onBlur = (event: SyntheticEvent) => {\n+ onBlur = () => {\nif (this.state.text.trim() === \"\") {\nthis.delete(this.props.entryInfo.id);\n} else if (this.props.entryInfo.text !== this.state.text) {\n@@ -312,6 +320,11 @@ class Entry extends React.Component {\n}\nsave(serverID: ?string, newText: string) {\n+ if (this.currentlySaving === newText) {\n+ return;\n+ }\n+ this.currentlySaving = newText;\n+\nif (newText.trim() === \"\") {\n// We don't save the empty string, since as soon as the element loses\n// focus it'll get deleted\n@@ -409,6 +422,10 @@ class Entry extends React.Component {\n}\ndelete(serverID: ?string) {\n+ if (this.deleted) {\n+ return;\n+ }\n+ this.deleted = true;\nLayoutAnimation.easeInEaseOut();\nconst startingPayload: {[key: string]: ?string} = {\nlocalID: this.props.entryInfo.localID,\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | More refinements! Here's a list
- Avoid assumption of keyboardShow/onEntryFocus events in pairs for scrollToKey,
- No more minHeight
- Make sure onBlur always fires when focus lost
- Ese autoFocus prop in Entry
- Avoid double-deletes and double-saves in Entry
- Detect presses on Entry View in lieu of TextInput onFocus |
129,187 | 28.05.2017 13:20:20 | 14,400 | d9fb58016ad17af6ee60c65ec70048d1e0c97b1f | Make sure info.viewableItems.length > 0 for readyToShowList gets set, since Android will render nothing first for some reason | [
{
"change_type": "MODIFY",
"old_path": "native/calendar/calendar.react.js",
"new_path": "native/calendar/calendar.react.js",
"diff": "@@ -770,7 +770,8 @@ class InnerCalendar extends React.PureComponent {\nif (\n!this.state.readyToShowList &&\n!this.topLoaderWaitingToLeaveView &&\n- !this.bottomLoaderWaitingToLeaveView\n+ !this.bottomLoaderWaitingToLeaveView &&\n+ info.viewableItems.length > 0\n) {\nthis.setState({\nreadyToShowList: true,\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Make sure info.viewableItems.length > 0 for readyToShowList gets set, since Android will render nothing first for some reason |
129,187 | 28.05.2017 14:55:34 | 14,400 | 0d17fde013e9a4b6215fce33278ca14d5831d551 | On iOS have the network spinner spin when networking requests are active | [
{
"change_type": "MODIFY",
"old_path": "native/calendar/calendar.react.js",
"new_path": "native/calendar/calendar.react.js",
"diff": "@@ -48,6 +48,7 @@ import {\nbindServerCalls,\n} from 'lib/utils/action-utils';\nimport { simpleNavID } from 'lib/selectors/nav-selectors';\n+import { registerFetchKey } from 'lib/reducers/loading-reducer';\nimport Entry from './entry.react';\nimport { contentVerticalOffset, windowHeight } from '../dimensions';\n@@ -57,6 +58,7 @@ import TextHeightMeasurer from '../text-height-measurer.react';\nimport ListLoadingIndicator from './list-loading-indicator.react';\nimport SectionFooter from './section-footer.react';\nimport ThreadPicker from './thread-picker.react';\n+import ConnectedStatusBar from '../connected-status-bar.react';\nexport type EntryInfoWithHeight = EntryInfo & { textHeight: number };\ntype CalendarItemWithHeight =\n@@ -601,6 +603,7 @@ class InnerCalendar extends React.PureComponent {\n}\nreturn (\n<View style={styles.container}>\n+ <ConnectedStatusBar />\n<TextHeightMeasurer\ntextToMeasure={this.state.textToMeasure}\nallHeightsMeasuredCallback={this.allHeightsMeasured}\n@@ -881,6 +884,8 @@ const styles = StyleSheet.create({\n},\n});\n+registerFetchKey(fetchEntriesAndAppendRangeActionType);\n+\nconst CalendarRouteName = 'Calendar';\nconst activeTabSelector = createActiveTabSelector(CalendarRouteName);\nconst Calendar = connect(\n"
},
{
"change_type": "MODIFY",
"old_path": "native/calendar/entry.react.js",
"new_path": "native/calendar/entry.react.js",
"diff": "@@ -50,6 +50,7 @@ import {\n} from 'lib/utils/action-utils';\nimport { ServerError } from 'lib/utils/fetch-utils';\nimport { entryKey } from 'lib/shared/entry-utils';\n+import { registerFetchKey } from 'lib/reducers/loading-reducer';\nimport { Button } from '../shared-components';\n@@ -536,6 +537,9 @@ const styles = StyleSheet.create({\n},\n});\n+registerFetchKey(saveEntryActionType);\n+registerFetchKey(deleteEntryActionType);\n+\nexport default connect(\n(state: AppState, ownProps: { entryInfo: EntryInfoWithHeight }) => ({\ncalendarInfo: state.calendarInfos[ownProps.entryInfo.calendarID],\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | On iOS have the network spinner spin when networking requests are active |
129,187 | 28.05.2017 20:38:35 | 14,400 | ac86c4b6ad0e2259daf61154ac82bba42793b231 | Update versions of stuff | [
{
"change_type": "MODIFY",
"old_path": "native/package.json",
"new_path": "native/package.json",
"diff": "\"dependencies\": {\n\"invariant\": \"^2.2.2\",\n\"react\": \"^16.0.0-alpha.12\",\n- \"react-native\": \"^0.45.0-rc.0\",\n- \"react-native-cookies\": \"^3.0.0\",\n+ \"react-native\": \"^0.45.0-rc.2\",\n+ \"react-native-cookies\": \"^3.1.0\",\n\"react-native-keychain\": \"^1.2.0\",\n\"react-native-onepassword\": \"^1.0.4\",\n\"react-native-vector-icons\": \"^4.1.1\",\n\"react-navigation\": \"^1.0.0-beta.11\",\n- \"react-redux\": \"^5.0.4\",\n+ \"react-redux\": \"^5.0.5\",\n\"redux\": \"^3.6.0\",\n- \"redux-persist\": \"^4.7.1\",\n+ \"redux-persist\": \"^4.8.0\",\n\"redux-thunk\": \"^2.2.0\",\n- \"reselect\": \"^3.0.0\",\n+ \"reselect\": \"^3.0.1\",\n\"shallowequal\": \"^0.2.2\",\n- \"url-parse\": \"^1.1.8\"\n+ \"url-parse\": \"^1.1.9\"\n},\n\"devDependencies\": {\n- \"babel-jest\": \"19.0.0\",\n- \"babel-plugin-transform-remove-console\": \"^6.8.1\",\n- \"babel-preset-react-native\": \"1.9.1\",\n+ \"babel-jest\": \"20.0.3\",\n+ \"babel-plugin-transform-remove-console\": \"^6.8.3\",\n+ \"babel-preset-react-native\": \"1.9.2\",\n\"flow-bin\": \"^0.45.0\",\n- \"jest\": \"^19.0.2\",\n- \"react-devtools\": \"^2.0.12\",\n+ \"jest\": \"^20.0.4\",\n+ \"react-devtools\": \"^2.2.1\",\n\"react-test-renderer\": \"^15.5.4\",\n- \"remote-redux-devtools\": \"^0.5.7\"\n+ \"remote-redux-devtools\": \"^0.5.11\"\n},\n\"jest\": {\n\"preset\": \"react-native\"\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Update versions of stuff |
129,187 | 30.05.2017 16:47:17 | 14,400 | 57a90a7f94861b1216292ae371890f611029efec | fetch_messages.php & message_lib.php | [
{
"change_type": "ADD",
"old_path": null,
"new_path": "server/fetch_messages.php",
"diff": "+<?php\n+\n+require_once('async_lib.php');\n+require_once('message_lib.php');\n+\n+async_start();\n+\n+$input = isset($_GET['input']) ? $_GET['input'] : null;\n+$number_per_thread = isset($_GET['number_per_thread'])\n+ ? (int)$_GET['number_per_thread']\n+ : 10;\n+\n+$messages = get_message_infos($input, $number_per_thread);\n+\n+async_end(array(\n+ 'success' => true,\n+ 'result' => $messages,\n+));\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "server/message_lib.php",
"diff": "+<?php\n+\n+require_once('config.php');\n+require_once('auth.php');\n+require_once('thread_lib.php');\n+\n+// this function will fetch the newest $number_per_thread messages from each\n+// thread ID included as a KEY in the $input array. the values are the IDs of\n+// the newest message NOT to fetch from each thread, ie. every result message\n+// should be newer than the specified message. in other words, we use the\n+// message ID as the \"cursor\" for paging. if the value is falsey, we will simply\n+// fetch the very newest $number_per_thread from that thread. if $input itself\n+// is null, we will fetch from every thread that the user is subscribed to\n+function get_message_infos($input, $number_per_thread) {\n+ global $conn;\n+\n+ $viewer_id = get_viewer_id();\n+ $visibility_closed = VISIBILITY_CLOSED;\n+ $role_successful_auth = ROLE_SUCCESSFUL_AUTH;\n+\n+ if (is_array($input)) {\n+ $conditions = array();\n+ foreach ($input as $thread => $cursor) {\n+ $int_thread = (int)$thread;\n+ if ($cursor) {\n+ $int_cursor = (int)$cursor;\n+ $conditions[] = \"(m.thread = $int_thread AND m.id < $int_cursor)\";\n+ } else {\n+ $conditions[] = \"m.thread = $int_thread\";\n+ }\n+ }\n+ $additional_condition = \"(\".implode(\" OR \", $conditions).\")\";\n+ } else {\n+ $additional_condition = \"r.subscribed = 1\";\n+ }\n+\n+ $int_number_per_thread = (int)$number_per_thread;\n+ $query = <<<SQL\n+SET @num := 0, @thread := '';\n+SELECT x.id, x.thread, x.user, u.username, x.text, x.time\n+FROM (\n+ SELECT m.id, m.user, m.text, m.time,\n+ @num := if(@thread = m.thread, @num + 1, 1) AS number,\n+ @thread := m.thread AS thread\n+ FROM messages m\n+ LEFT JOIN threads t ON t.id = m.thread\n+ LEFT JOIN roles r ON r.thread = m.thread AND r.user = {$viewer_id}\n+ WHERE (t.visibility_rules < {$visibility_closed} OR\n+ (r.thread IS NOT NULL AND r.role >= {$role_successful_auth})) AND\n+ {$additional_condition}\n+ ORDER BY m.thread, m.time DESC\n+) x\n+LEFT JOIN users u ON u.id = x.user\n+WHERE x.number <= {$int_number_per_thread};\n+SQL;\n+ $query_result = $conn->multi_query($query);\n+ if (!$query_result) {\n+ return null;\n+ }\n+ $conn->next_result();\n+ $row_result = $conn->store_result();\n+\n+ $messages = array();\n+ while ($row = $row_result->fetch_assoc()) {\n+ $messages[] = $row;\n+ }\n+ return $messages;\n+}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | fetch_messages.php & message_lib.php |
129,187 | 03.06.2017 17:46:51 | 14,400 | 789299b510bf207155175dc4ea8e70b1aa51c25f | Piping in the thread info to the chat screen | [
{
"change_type": "MODIFY",
"old_path": "native/calendar/calendar.react.js",
"new_path": "native/calendar/calendar.react.js",
"diff": "import type { EntryInfo } from 'lib/types/entry-types';\nimport { entryInfoPropType } from 'lib/types/entry-types';\nimport type { AppState } from '../redux-setup';\n-import type { CalendarItem } from '../selectors/entry-selectors';\n+import type { CalendarItem } from '../selectors/calendar-selectors';\nimport type { ViewToken } from 'react-native/Libraries/Lists/ViewabilityHelper';\nimport type { DispatchActionPromise } from 'lib/utils/action-utils';\nimport type { CalendarResult } from 'lib/actions/entry-actions';\n@@ -52,7 +52,7 @@ import { registerFetchKey } from 'lib/reducers/loading-reducer';\nimport Entry from './entry.react';\nimport { contentVerticalOffset, windowHeight } from '../dimensions';\n-import { calendarListData } from '../selectors/entry-selectors';\n+import { calendarListData } from '../selectors/calendar-selectors';\nimport { createActiveTabSelector } from '../selectors/nav-selectors';\nimport TextHeightMeasurer from '../text-height-measurer.react';\nimport ListLoadingIndicator from './list-loading-indicator.react';\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/chat.react.js",
"new_path": "native/chat/chat.react.js",
"diff": "// @flow\n+import type { AppState } from '../redux-setup';\n+import type { ThreadInfo } from 'lib/types/thread-types';\n+import type { ChatThreadItem } from '../selectors/chat-selectors';\n+import { chatThreadItemPropType } from '../selectors/chat-selectors';\n+\nimport React from 'react';\n-import { View, StyleSheet, Text } from 'react-native';\n+import { View, StyleSheet, Text, FlatList } from 'react-native';\nimport Icon from 'react-native-vector-icons/FontAwesome';\n+import { connect } from 'react-redux';\n+import PropTypes from 'prop-types';\n+\n+import { chatListData } from '../selectors/chat-selectors';\ntype Props = {\n+ // Redux state\n+ chatListData: $ReadOnlyArray<ChatThreadItem>,\n};\ntype State = {\n};\n-\n-class Chat extends React.PureComponent {\n+class InnerChat extends React.PureComponent {\nprops: Props;\nstate: State;\n-\n+ static propTypes = {\n+ chatListData: PropTypes.arrayOf(chatThreadItemPropType).isRequired,\n+ };\nstatic navigationOptions = {\ntabBarLabel: 'Chat',\ntabBarIcon: ({ tintColor }) => (\n@@ -23,6 +35,7 @@ class Chat extends React.PureComponent {\n/>\n),\n};\n+ flatList: ?FlatList<ChatThreadItem> = null;\nrender() {\nreturn (\n@@ -53,4 +66,12 @@ const styles = StyleSheet.create({\n},\n});\n-export default Chat;\n+const ChatRouteName = 'Chat';\n+const Chat = connect((state: AppState) => ({\n+ chatListData: chatListData(state),\n+}))(InnerChat);\n+\n+export {\n+ Chat,\n+ ChatRouteName,\n+};\n"
},
{
"change_type": "MODIFY",
"old_path": "native/navigation-setup.js",
"new_path": "native/navigation-setup.js",
"diff": "@@ -29,7 +29,10 @@ import {\nCalendar,\nCalendarRouteName,\n} from './calendar/calendar.react';\n-import Chat from './chat/chat.react';\n+import {\n+ Chat,\n+ ChatRouteName,\n+} from './chat/chat.react';\nimport More from './more/more.react';\nimport {\nLoggedOutModal,\n@@ -52,7 +55,7 @@ export type Action = BaseAction |\nconst AppNavigator = TabNavigator(\n{\n[CalendarRouteName]: { screen: Calendar },\n- Chat: { screen: Chat },\n+ [ChatRouteName]: { screen: Chat },\nMore: { screen: More },\n},\n{\n@@ -140,7 +143,7 @@ const defaultNavigationState = {\nindex: 0,\nroutes: [\n{ key: 'Calendar', routeName: CalendarRouteName },\n- { key: 'Chat', routeName: 'Chat' },\n+ { key: 'Chat', routeName: ChatRouteName },\n{ key: 'More', routeName: 'More' },\n],\n},\n"
},
{
"change_type": "RENAME",
"old_path": "native/selectors/entry-selectors.js",
"new_path": "native/selectors/calendar-selectors.js",
"diff": ""
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/selectors/chat-selectors.js",
"diff": "+// @flow\n+\n+import type { BaseAppState } from 'lib/types/redux-types';\n+import type { ThreadInfo } from 'lib/types/thread-types';\n+import { threadInfoPropType } from 'lib/types/thread-types';\n+import type { MessageStore } from 'lib/types/message-types';\n+\n+import { createSelector } from 'reselect';\n+import _flow from 'lodash/fp/flow';\n+import _filter from 'lodash/fp/filter';\n+import _map from 'lodash/fp/map';\n+import _orderBy from 'lodash/fp/orderBy';\n+import PropTypes from 'prop-types';\n+\n+export type ChatThreadItem = {\n+ threadInfo: ThreadInfo,\n+ lastUpdatedTime: number,\n+};\n+\n+const chatThreadItemPropType = PropTypes.shape({\n+ threadInfo: threadInfoPropType.isRequired,\n+ lastUpdatedTime: PropTypes.number.isRequired,\n+});\n+\n+const chatListData = createSelector(\n+ (state: BaseAppState) => state.threadInfos,\n+ (state: BaseAppState) => state.messageStore,\n+ (\n+ threadInfos: {[id: string]: ThreadInfo},\n+ messageStore: MessageStore,\n+ ): ChatThreadItem[] => _flow(\n+ _filter('authorized'),\n+ _map((threadInfo: ThreadInfo) => {\n+ const messageIDs = messageStore.threads[threadInfo.id].messageIDs;\n+ const lastUpdatedTime = messageIDs.length === 0\n+ ? threadInfo.creationTime\n+ : messageStore.messages[messageIDs[0]].time;\n+ return { threadInfo, lastUpdatedTime };\n+ }),\n+ _orderBy(\"lastUpdatedTime\")(\"desc\"),\n+ )(threadInfos),\n+);\n+\n+export {\n+ chatThreadItemPropType,\n+ chatListData,\n+};\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Piping in the thread info to the chat screen |
129,187 | 04.06.2017 16:36:13 | 14,400 | e6f7c391b54bc68017e72a0d4c4436d6191383ce | Add 5-height ListHeaderComponent to ChatThreadList | [
{
"change_type": "MODIFY",
"old_path": "native/chat/chat-thread-list.react.js",
"new_path": "native/chat/chat-thread-list.react.js",
"diff": "@@ -67,6 +67,10 @@ class InnerChatThreadList extends React.PureComponent {\nreturn _sum(data.map(InnerChatThreadList.itemHeight));\n}\n+ static ListHeaderComponent(props: {}) {\n+ return <View style={styles.header} />;\n+ }\n+\nrender() {\nreturn (\n<View style={styles.container}>\n@@ -75,6 +79,7 @@ class InnerChatThreadList extends React.PureComponent {\nrenderItem={this.renderItem}\nkeyExtractor={InnerChatThreadList.keyExtractor}\ngetItemLayout={InnerChatThreadList.getItemLayout}\n+ ListHeaderComponent={InnerChatThreadList.ListHeaderComponent}\nstyle={styles.flatList}\nref={this.flatListRef}\n/>\n@@ -95,6 +100,9 @@ const styles = StyleSheet.create({\ncontainer: {\nflex: 1,\n},\n+ header: {\n+ height: 5,\n+ },\nflatList: {\nflex: 1,\nbackgroundColor: '#FFFFFF',\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Add 5-height ListHeaderComponent to ChatThreadList |
129,187 | 04.06.2017 17:35:06 | 14,400 | 6fb463d5839e799d0c10156cb760a97b9429c31d | Add last activity time to ChatThreadListItem | [
{
"change_type": "MODIFY",
"old_path": "lib/utils/date-utils.js",
"new_path": "lib/utils/date-utils.js",
"diff": "@@ -77,6 +77,22 @@ function dateFromString(dayString: string): Date {\n);\n}\n+const millisecondsInDay = 24 * 60 * 60 * 1000;\n+const millisecondsInWeek = millisecondsInDay * 7;\n+\n+// Takes a millisecond timestamp and displays the time in the local timezone\n+function shortAbsoluteDate(timestamp: number) {\n+ const now = Date.now();\n+ const msSince = now - timestamp;\n+ if (msSince < millisecondsInDay) {\n+ return dateFormat(timestamp, \"h:MM tt\");\n+ } else if (msSince < millisecondsInWeek) {\n+ return dateFormat(timestamp, \"ddd\");\n+ } else {\n+ return dateFormat(timestamp, \"mmm d\");\n+ }\n+}\n+\nexport {\ngetDate,\npadMonthOrDay,\n@@ -87,4 +103,5 @@ export {\nfifteenDaysLater,\nprettyDate,\ndateFromString,\n+ shortAbsoluteDate,\n}\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": "import type { ChatThreadItem } from '../selectors/chat-selectors';\nimport { chatThreadItemPropType } from '../selectors/chat-selectors';\n+import { shortAbsoluteDate } from 'lib/utils/date-utils';\n+\nimport React from 'react';\nimport { View, StyleSheet, Text } from 'react-native';\nimport PropTypes from 'prop-types';\n@@ -28,7 +30,7 @@ class ChatThreadListItem extends React.PureComponent {\n);\n}\nconst username = mostRecentMessageInfo.creatorID === this.props.userID\n- ? \"You: \"\n+ ? \"you: \"\n: `${mostRecentMessageInfo.creator}: `;\nreturn (\n<Text style={styles.lastMessage} numberOfLines={1}>\n@@ -42,6 +44,7 @@ class ChatThreadListItem extends React.PureComponent {\nconst colorSplotchStyle = {\nbackgroundColor: `#${this.props.data.threadInfo.color}`,\n};\n+ const lastActivity = shortAbsoluteDate(this.props.data.lastUpdatedTime);\nreturn (\n<View style={styles.container}>\n<View style={styles.row}>\n@@ -52,6 +55,7 @@ class ChatThreadListItem extends React.PureComponent {\n</View>\n<View style={styles.row}>\n{this.lastMessage()}\n+ <Text style={styles.lastActivity}>{lastActivity}</Text>\n</View>\n</View>\n);\n@@ -79,9 +83,9 @@ const styles = StyleSheet.create({\ncolor: '#333333',\n},\ncolorSplotch: {\n- height: 25,\n+ height: 20,\njustifyContent: 'flex-end',\n- width: 25,\n+ width: 20,\nborderRadius: 5,\n},\nnoMessages: {\n@@ -98,6 +102,10 @@ const styles = StyleSheet.create({\nusername: {\ncolor: '#AAAAAA',\n},\n+ lastActivity: {\n+ fontSize: 16,\n+ color: '#666666',\n+ },\n});\nexport default ChatThreadListItem;\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Add last activity time to ChatThreadListItem |
129,187 | 05.06.2017 09:20:42 | 14,400 | 57e40a113616077bb212af926e4391eab80aa31c | onPressItem in ChatThreadList and some styling fixes after testing on Android | [
{
"change_type": "MODIFY",
"old_path": "native/chat/chat-thread-list-item.react.js",
"new_path": "native/chat/chat-thread-list-item.react.js",
"diff": "@@ -9,15 +9,19 @@ import React from 'react';\nimport { View, StyleSheet, Text } from 'react-native';\nimport PropTypes from 'prop-types';\n+import { Button } from '../shared-components';\n+\nclass ChatThreadListItem extends React.PureComponent {\nprops: {\ndata: ChatThreadItem,\nuserID: ?string,\n+ onPressItem: (threadID: string) => void,\n};\nstatic propTypes = {\ndata: chatThreadItemPropType.isRequired,\nuserID: PropTypes.string,\n+ onPressItem: PropTypes.func.isRequired,\n};\nlastMessage() {\n@@ -46,6 +50,7 @@ class ChatThreadListItem extends React.PureComponent {\n};\nconst lastActivity = shortAbsoluteDate(this.props.data.lastUpdatedTime);\nreturn (\n+ <Button onSubmit={this.onPress} underlayColor=\"#DDDDDDDD\">\n<View style={styles.container}>\n<View style={styles.row}>\n<Text style={styles.threadName} numberOfLines={1}>\n@@ -58,9 +63,14 @@ class ChatThreadListItem extends React.PureComponent {\n<Text style={styles.lastActivity}>{lastActivity}</Text>\n</View>\n</View>\n+ </Button>\n);\n}\n+ onPress = () => {\n+ this.props.onPressItem(this.props.data.threadInfo.id);\n+ }\n+\n}\nconst styles = StyleSheet.create({\n@@ -68,7 +78,6 @@ const styles = StyleSheet.create({\nheight: 60,\npaddingLeft: 10,\npaddingTop: 5,\n- paddingBottom: 5,\npaddingRight: 10,\n},\nrow: {\n@@ -78,14 +87,14 @@ const styles = StyleSheet.create({\n},\nthreadName: {\npaddingLeft: 10,\n- paddingBottom: 20,\nfontSize: 20,\ncolor: '#333333',\n},\ncolorSplotch: {\n- height: 20,\n+ height: 18,\n+ width: 18,\n+ marginTop: 2,\njustifyContent: 'flex-end',\n- width: 20,\nborderRadius: 5,\n},\nnoMessages: {\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/chat-thread-list.react.js",
"new_path": "native/chat/chat-thread-list.react.js",
"diff": "@@ -32,7 +32,13 @@ class InnerChatThreadList extends React.PureComponent {\nflatList: ?FlatList<ChatThreadItem> = null;\nrenderItem = (row: { item: ChatThreadItem }) => {\n- return <ChatThreadListItem data={row.item} userID={this.props.userID} />;\n+ return (\n+ <ChatThreadListItem\n+ data={row.item}\n+ userID={this.props.userID}\n+ onPressItem={this.onPressItem}\n+ />\n+ );\n}\nstatic keyExtractor(item: ChatThreadItem) {\n@@ -83,6 +89,10 @@ class InnerChatThreadList extends React.PureComponent {\nthis.flatList = flatList;\n}\n+ onPressItem = (threadID: string) => {\n+ console.log(`threadID ${threadID} pressed!`);\n+ }\n+\n}\nconst styles = StyleSheet.create({\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | onPressItem in ChatThreadList and some styling fixes after testing on Android |
129,187 | 05.06.2017 12:12:34 | 14,400 | 95abbf5317e04b2477344bb65bda8ec7a3204e0c | Typesystem stuff done for now... action-utils has fewer "any"s now | [
{
"change_type": "MODIFY",
"old_path": "lib/types/redux-types.js",
"new_path": "lib/types/redux-types.js",
"diff": "@@ -369,12 +369,16 @@ export type BaseAction =\nloadingInfo: LoadingInfo,\n};\n-type ThunkedAction<A> = (dispatch: Dispatch<A>) => void;\n-type PromisedAction<A> = (dispatch: Dispatch<A>) => Promise<void>;\n-export type Dispatch<A> =\n- ((promisedAction: PromisedAction<BaseAction>) => Promise<void>) &\n- ((promisedAction: PromisedAction<A>) => Promise<void>) &\n- ((thunkedAction: ThunkedAction<BaseAction>) => void) &\n- ((thunkedAction: ThunkedAction<A>) => void) &\n- ((action: BaseAction) => void) &\n- ((action: A) => void);\n+export type ActionPayload = ?(Object | Array<*> | string);\n+export type SuperAction = {\n+ type: $Subtype<string>,\n+ payload?: ActionPayload,\n+ loadingInfo?: LoadingInfo,\n+ error?: bool,\n+};\n+type ThunkedAction = (dispatch: Dispatch) => void;\n+export type PromisedAction = (dispatch: Dispatch) => Promise<void>;\n+export type Dispatch =\n+ ((promisedAction: PromisedAction) => Promise<void>) &\n+ ((thunkedAction: ThunkedAction) => void) &\n+ ((action: SuperAction) => void);\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/utils/action-utils.js",
"new_path": "lib/utils/action-utils.js",
"diff": "// @flow\n-import type { Dispatch, BaseAppState, BaseAction } from '../types/redux-types';\n+import type {\n+ ActionPayload,\n+ Dispatch,\n+ PromisedAction,\n+ SuperAction,\n+} from '../types/redux-types';\nimport type { LoadingOptions, LoadingInfo } from '../types/loading-types';\nimport type { FetchJSON } from './fetch-json';\nimport type {\n@@ -16,38 +21,40 @@ import { getConfig } from './config';\nlet nextPromiseIndex = 0;\n-export type ActionTypes<AT: string, BT: string, CT: string> = {\n+export type ActionTypes<\n+ AT: $Subtype<string>,\n+ BT: $Subtype<string>,\n+ CT: $Subtype<string>,\n+> = {\nstarted: AT,\nsuccess: BT,\nfailed: CT,\n};\n-type ActionSupportingPromise<AT: string, AP, BT: string, BP, CT: string> =\n+type ActionSupportingPromise<\n+ AT: $Subtype<string>,\n+ AP: ActionPayload,\n+ BT: $Subtype<string>,\n+ BP: ActionPayload,\n+ CT: $Subtype<string>,\n+> =\n{ type: AT, loadingInfo: LoadingInfo, payload?: AP } |\n{ type: BT, loadingInfo: LoadingInfo, payload?: BP } |\n{ type: CT, loadingInfo: LoadingInfo, payload: Error } |\n{ type: AT, payload?: AP };\n-type MagicDispatch<\n- AT: string, // *_STARTED action type (string literal)\n- AP, // *_STARTED payload\n- BT: string, // *_SUCCESS action type (string literal)\n- BP, // *_SUCCESS payload\n- CT: string, // *_FAILED action type (string literal)\n-> = Dispatch<ActionSupportingPromise<AT, AP, BT, BP, CT>>;\n-\nfunction wrapActionPromise<\n- AT: string, // *_STARTED action type (string literal)\n- AP, // *_STARTED payload\n- BT: string, // *_SUCCESS action type (string literal)\n- BP, // *_SUCCESS payload\n- CT: string, // *_FAILED action type (string literal)\n+ AT: $Subtype<string>, // *_STARTED action type (string literal)\n+ AP: ActionPayload, // *_STARTED payload\n+ BT: $Subtype<string>, // *_SUCCESS action type (string literal)\n+ BP: ActionPayload, // *_SUCCESS payload\n+ CT: $Subtype<string>, // *_FAILED action type (string literal)\n>(\nactionTypes: ActionTypes<AT, BT, CT>,\npromise: Promise<BP>,\nloadingOptions?: ?LoadingOptions,\nstartingPayload?: ?AP,\n-): (dispatch: MagicDispatch<AT, AP, BT, BP, CT>) => Promise<void> {\n+): PromisedAction {\nconst loadingInfo = {\nfetchIndex: nextPromiseIndex++,\ntrackMultipleRequests:\n@@ -56,9 +63,7 @@ function wrapActionPromise<\n? loadingOptions.customKeyName\n: null,\n};\n- return (async (\n- dispatch: MagicDispatch<AT, AP, BT, BP, CT>,\n- ): Promise<void> => {\n+ return (async (dispatch: Dispatch): Promise<void> => {\nconst startAction = startingPayload\n? {\ntype: (actionTypes.started: AT),\n@@ -90,13 +95,13 @@ function wrapActionPromise<\n}\nexport type DispatchActionPayload =\n- <T: string, P>(actionType: T, payload: P) => void;\n+ <T: $Subtype<string>, P: ActionPayload>(actionType: T, payload: P) => void;\nexport type DispatchActionPromise = <\n- AT: string, // *_STARTED action type (string literal)\n- AP, // *_STARTED payload\n- BT: string, // *_SUCCESS action type (string literal)\n- BP, // *_SUCCESS payload\n- CT: string, // *_FAILED action type (string literal)\n+ AT: $Subtype<string>, // *_STARTED action type (string literal)\n+ AP: ActionPayload, // *_STARTED payload\n+ BT: $Subtype<string>, // *_SUCCESS action type (string literal)\n+ BP: ActionPayload, // *_SUCCESS payload\n+ CT: $Subtype<string>, // *_FAILED action type (string literal)\n>(\nactionTypes: ActionTypes<AT, BT, CT>,\npromise: Promise<BP>,\n@@ -108,37 +113,43 @@ type DispatchActionHelperProps = {\ndispatchActionPayload?: bool,\ndispatchActionPromise?: bool,\n};\n-type BoundActions<A> = {\n- dispatch: Dispatch<A>,\n+type BoundActions = {\n+ dispatch: Dispatch,\ndispatchActionPayload?: DispatchActionPayload,\ndispatchActionPromise?: DispatchActionPromise,\n};\n-function includeDispatchActionProps<A>(\n+function includeDispatchActionProps(\nwhichOnes: DispatchActionHelperProps,\n-): (dispatch: Dispatch<A>) => BoundActions<A> {\n- return (dispatch: Dispatch<A>) => {\n- const boundActions: BoundActions<A> = { dispatch };\n+): (dispatch: Dispatch) => BoundActions {\n+ return (dispatch: Dispatch) => {\n+ const boundActions: BoundActions = { dispatch };\nif (whichOnes.dispatchActionPromise) {\nboundActions.dispatchActionPromise =\n- function<AT: string, AP, BT: string, BP, CT: string>(\n- actionTypes: ActionTypes<AT, BT, CT>,\n- promise: Promise<BP>,\n+ function<A: SuperAction, B: SuperAction, C: SuperAction>(\n+ actionTypes: ActionTypes<\n+ $PropertyType<A, 'type'>,\n+ $PropertyType<B, 'type'>,\n+ $PropertyType<C, 'type'>,\n+ >,\n+ promise: Promise<$PropertyType<B, 'payload'>>,\nloadingOptions?: LoadingOptions,\n- startingPayload?: AP,\n- ) {\n- const wrappedActionPromise: $FlowFixMe = wrapActionPromise(\n+ startingPayload?: $PropertyType<A, 'payload'>,\n+ ): Promise<void> {\n+ return dispatch(wrapActionPromise(\nactionTypes,\npromise,\nloadingOptions,\nstartingPayload,\n- );\n- return dispatch(wrappedActionPromise);\n+ ));\n};\n}\nif (whichOnes.dispatchActionPayload) {\nboundActions.dispatchActionPayload =\n- function<T: string, P>(actionType: T, payload: P) {\n- const action: $FlowFixMe = { type: actionType, payload };\n+ function<T: $Subtype<string>, P: ActionPayload>(\n+ actionType: T,\n+ payload: P,\n+ ) {\n+ const action = { type: actionType, payload };\ndispatch(action);\n};\n}\n@@ -149,13 +160,6 @@ function includeDispatchActionProps<A>(\nlet currentlyWaitingForNewCookie = false;\nlet fetchJSONCallsWaitingForNewCookie: ((fetchJSON: ?FetchJSON) => void)[] = [];\n-export type RecoveryDispatch = MagicDispatch<\n- 'LOG_IN_STARTED',\n- LogInStartingPayload,\n- 'LOG_IN_SUCCESS',\n- LogInResult,\n- 'LOG_IN_FAILED'\n->;\nexport type DispatchRecoveryAttempt = (\nactionTypes: ActionTypes<\n'LOG_IN_STARTED',\n@@ -166,7 +170,7 @@ export type DispatchRecoveryAttempt = (\n) => Promise<?string>;\nfunction setCookie(\n- dispatch: (action: BaseAction) => void,\n+ dispatch: Dispatch,\ncurrentCookie: ?string,\nnewCookie: ?string,\nresponse: ?Object,\n@@ -182,24 +186,24 @@ function setCookie(\n\"all server calls that return a new cookie should include a valid \" +\n\"cookie_change object in their payload\",\n);\n- dispatch(({\n+ dispatch({\ntype: \"SET_COOKIE\",\npayload: {\ncookie: newCookie,\nthreadInfos: response.cookie_change.thread_infos,\ncookieInvalidated: response.cookie_change.cookie_invalidated,\n},\n- }: BaseAction));\n+ });\n} else {\n- dispatch(({\n+ dispatch({\ntype: \"SET_COOKIE\",\npayload: { cookie: newCookie },\n- }: BaseAction));\n+ });\n}\n}\nasync function fetchNewCookieFromNativeCredentials(\n- dispatch: RecoveryDispatch,\n+ dispatch: Dispatch,\ncookie: ?string,\nsource: null |\n\"COOKIE_INVALIDATION_RESOLUTION_ATTEMPT\" |\n@@ -262,7 +266,7 @@ async function fetchNewCookieFromNativeCredentials(\n// Third param is optional and gets called with newCookie if we get a new cookie\n// Necessary to propagate cookie in cookieInvalidationRecovery below\nfunction bindCookieAndUtilsIntoFetchJSON(\n- dispatch: RecoveryDispatch,\n+ dispatch: Dispatch,\ncookie: ?string,\n): FetchJSON {\nconst boundSetCookie = (newCookie: ?string, response: Object) => {\n@@ -341,7 +345,7 @@ function bindCookieAndUtilsIntoFetchJSON(\n// parameter on to the server call.\nfunction bindCookieAndUtilsIntoServerCall<P>(\nactionFunc: (fetchJSON: FetchJSON, ...rest: $FlowFixMe) => Promise<P>,\n- dispatch: RecoveryDispatch,\n+ dispatch: Dispatch,\ncookie: ?string,\n): (...rest: $FlowFixMe) => Promise<P> {\nconst boundFetchJSON = bindCookieAndUtilsIntoFetchJSON(dispatch, cookie);\n"
},
{
"change_type": "MODIFY",
"old_path": "native/account/logged-out-modal.react.js",
"new_path": "native/account/logged-out-modal.react.js",
"diff": "@@ -4,8 +4,8 @@ import type { NavigationScreenProp } from 'react-navigation';\nimport type {\nDispatchActionPayload,\nDispatchActionPromise,\n- RecoveryDispatch,\n} from 'lib/utils/action-utils';\n+import type { Dispatch } from 'lib/types/redux-types';\nimport type { AppState } from '../redux-setup';\nimport type { Action } from '../navigation-setup';\nimport type { PingStartingPayload, PingResult } from 'lib/types/ping-types';\n@@ -58,7 +58,7 @@ type Props = {\npingStartingPayload: () => PingStartingPayload,\ncurrentAsOf: number,\n// Redux dispatch functions\n- dispatch: RecoveryDispatch,\n+ dispatch: Dispatch,\ndispatchActionPayload: DispatchActionPayload,\ndispatchActionPromise: DispatchActionPromise,\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "native/app.react.js",
"new_path": "native/app.react.js",
"diff": "@@ -94,7 +94,7 @@ class AppWithNavigationState extends React.PureComponent {\npingStartingPayload: () => PingStartingPayload,\ncurrentAsOf: number,\n// Redux dispatch functions\n- dispatch: Dispatch<AppState, Action>,\n+ dispatch: Dispatch,\ndispatchActionPayload: DispatchActionPayload,\ndispatchActionPromise: DispatchActionPromise,\n// async functions that hit server APIs\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": "@@ -35,7 +35,7 @@ class ChatThreadListItem extends React.PureComponent {\n}\nconst username = mostRecentMessageInfo.creatorID === this.props.userID\n? \"you: \"\n- : `${mostRecentMessageInfo.creator}: `;\n+ : `${mostRecentMessageInfo.creator || \"\"}: `;\nreturn (\n<Text style={styles.lastMessage} numberOfLines={1}>\n<Text style={styles.username}>{username}</Text>\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Typesystem stuff done for now... action-utils has fewer "any"s now |
129,187 | 05.06.2017 16:12:56 | 14,400 | e4cdb74fc2a289335a591f836eafa6ba5da20b00 | Basic chat view that just lists messages as Text | [
{
"change_type": "MODIFY",
"old_path": "native/account/logged-out-modal.react.js",
"new_path": "native/account/logged-out-modal.react.js",
"diff": "// @flow\n-import type { NavigationScreenProp } from 'react-navigation';\n+import type {\n+ NavigationScreenProp,\n+ NavigationRoute,\n+ NavigationAction,\n+} from 'react-navigation';\nimport type {\nDispatchActionPayload,\nDispatchActionPromise,\n@@ -49,7 +53,7 @@ import { createIsForegroundSelector } from '../selectors/nav-selectors';\ntype LoggedOutMode = \"loading\" | \"prompt\" | \"log-in\" | \"register\";\ntype Props = {\n- navigation: NavigationScreenProp<*, *>,\n+ navigation: NavigationScreenProp<NavigationRoute, NavigationAction>,\n// Redux state\nrehydrateConcluded: bool,\ncookie: ?string,\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": "import type { ChatThreadItem } from '../selectors/chat-selectors';\nimport { chatThreadItemPropType } from '../selectors/chat-selectors';\n+import type { ThreadInfo } from 'lib/types/thread-types';\nimport { shortAbsoluteDate } from 'lib/utils/date-utils';\n@@ -16,7 +17,7 @@ class ChatThreadListItem extends React.PureComponent {\nprops: {\ndata: ChatThreadItem,\nuserID: ?string,\n- onPressItem: (threadID: string) => void,\n+ onPressItem: (threadInfo: ThreadInfo) => void,\n};\nstatic propTypes = {\ndata: chatThreadItemPropType.isRequired,\n@@ -68,7 +69,7 @@ class ChatThreadListItem extends React.PureComponent {\n}\nonPress = () => {\n- this.props.onPressItem(this.props.data.threadInfo.id);\n+ this.props.onPressItem(this.props.data.threadInfo);\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/chat-thread-list.react.js",
"new_path": "native/chat/chat-thread-list.react.js",
"diff": "@@ -4,6 +4,11 @@ import type { AppState } from '../redux-setup';\nimport type { ThreadInfo } from 'lib/types/thread-types';\nimport type { ChatThreadItem } from '../selectors/chat-selectors';\nimport { chatThreadItemPropType } from '../selectors/chat-selectors';\n+import type {\n+ NavigationScreenProp,\n+ NavigationRoute,\n+ NavigationAction,\n+} from 'react-navigation';\nimport React from 'react';\nimport { View, StyleSheet, FlatList } from 'react-native';\n@@ -14,22 +19,26 @@ import _sum from 'lodash/fp/sum';\nimport { chatListData } from '../selectors/chat-selectors';\nimport ChatThreadListItem from './chat-thread-list-item.react';\n+import { MessageListRouteName } from './message-list.react';\nclass InnerChatThreadList extends React.PureComponent {\nprops: {\n+ navigation: NavigationScreenProp<NavigationRoute, NavigationAction>,\n// Redux state\nchatListData: $ReadOnlyArray<ChatThreadItem>,\nuserID: ?string,\n};\nstatic propTypes = {\n+ navigation: PropTypes.shape({\n+ navigate: PropTypes.func.isRequired,\n+ }).isRequired,\nchatListData: PropTypes.arrayOf(chatThreadItemPropType).isRequired,\nuserID: PropTypes.string,\n};\nstatic navigationOptions = {\n- title: 'Chat',\n+ title: 'Threads',\n};\n- flatList: ?FlatList<ChatThreadItem> = null;\nrenderItem = (row: { item: ChatThreadItem }) => {\nreturn (\n@@ -79,18 +88,16 @@ class InnerChatThreadList extends React.PureComponent {\nListHeaderComponent={InnerChatThreadList.ListHeaderComponent}\nextraData={this.props.userID}\nstyle={styles.flatList}\n- ref={this.flatListRef}\n/>\n</View>\n);\n}\n- flatListRef = (flatList: ?FlatList<ChatThreadItem>) => {\n- this.flatList = flatList;\n- }\n-\n- onPressItem = (threadID: string) => {\n- console.log(`threadID ${threadID} pressed!`);\n+ onPressItem = (threadInfo: ThreadInfo) => {\n+ this.props.navigation.navigate(\n+ MessageListRouteName,\n+ { threadInfo },\n+ );\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/chat.react.js",
"new_path": "native/chat/chat.react.js",
"diff": "@@ -9,9 +9,11 @@ import {\nChatThreadList,\nChatThreadListRouteName,\n} from './chat-thread-list.react';\n+import { MessageList, MessageListRouteName } from './message-list.react';\nconst Chat = StackNavigator({\n[ChatThreadListRouteName]: { screen: ChatThreadList },\n+ [MessageListRouteName]: { screen: MessageList },\n});\nChat.navigationOptions = {\ntabBarLabel: 'Chat',\n"
},
{
"change_type": "MODIFY",
"old_path": "native/selectors/chat-selectors.js",
"new_path": "native/selectors/chat-selectors.js",
"diff": "@@ -12,6 +12,7 @@ import _filter from 'lodash/fp/filter';\nimport _map from 'lodash/fp/map';\nimport _orderBy from 'lodash/fp/orderBy';\nimport PropTypes from 'prop-types';\n+import _memoize from 'lodash/memoize';\nexport type ChatThreadItem = {\nthreadInfo: ThreadInfo,\n@@ -49,7 +50,23 @@ const chatListData = createSelector(\n)(threadInfos),\n);\n+const baseMessageListData = (threadID: string) => createSelector(\n+ (state: BaseAppState) => state.messageStore,\n+ (messageStore: MessageStore): MessageInfo[] => {\n+ const thread = messageStore.threads[threadID];\n+ if (!thread) {\n+ return [];\n+ }\n+ return thread.messageIDs\n+ .map((messageID: string) => messageStore.messages[messageID])\n+ .filter(x => x);\n+ },\n+);\n+\n+const messageListData = _memoize(baseMessageListData);\n+\nexport {\nchatThreadItemPropType,\nchatListData,\n+ messageListData,\n};\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Basic chat view that just lists messages as Text |
129,187 | 05.06.2017 19:15:35 | 14,400 | 8e391fdf34beff1bc484a167f671c0b42185e01f | Create Message React component and give it some style yo | [
{
"change_type": "ADD",
"old_path": null,
"new_path": "lib/package-lock.json",
"diff": "+{\n+ \"name\": \"lib\",\n+ \"version\": \"0.0.1\",\n+ \"lockfileVersion\": 1,\n+ \"dependencies\": {\n+ \"asap\": {\n+ \"version\": \"2.0.5\",\n+ \"resolved\": \"https://registry.npmjs.org/asap/-/asap-2.0.5.tgz\",\n+ \"integrity\": \"sha1-UidltQw1EEkOUtfc/ghe+bqWlY8=\"\n+ },\n+ \"core-js\": {\n+ \"version\": \"1.2.7\",\n+ \"resolved\": \"https://registry.npmjs.org/core-js/-/core-js-1.2.7.tgz\",\n+ \"integrity\": \"sha1-ZSKUwUZR2yj6k70tX/KYOk8IxjY=\"\n+ },\n+ \"dateformat\": {\n+ \"version\": \"2.0.0\",\n+ \"resolved\": \"https://registry.npmjs.org/dateformat/-/dateformat-2.0.0.tgz\",\n+ \"integrity\": \"sha1-J0Pjq7XD/CRi5SfcpEXgTp9N7hc=\"\n+ },\n+ \"encoding\": {\n+ \"version\": \"0.1.12\",\n+ \"resolved\": \"https://registry.npmjs.org/encoding/-/encoding-0.1.12.tgz\",\n+ \"integrity\": \"sha1-U4tm8+5izRq1HsMjgp0flIDHS+s=\"\n+ },\n+ \"fbjs\": {\n+ \"version\": \"0.8.12\",\n+ \"resolved\": \"https://registry.npmjs.org/fbjs/-/fbjs-0.8.12.tgz\",\n+ \"integrity\": \"sha1-ELXZL3bUVXX9Y6IX1OoCvqL47QQ=\"\n+ },\n+ \"flow-bin\": {\n+ \"version\": \"0.44.2\",\n+ \"resolved\": \"https://registry.npmjs.org/flow-bin/-/flow-bin-0.44.2.tgz\",\n+ \"integrity\": \"sha1-OJPH213gQ+2CZ08yegSxMJ2yCLU=\",\n+ \"dev\": true\n+ },\n+ \"iconv-lite\": {\n+ \"version\": \"0.4.17\",\n+ \"resolved\": \"https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.17.tgz\",\n+ \"integrity\": \"sha1-T9qjs4rLwsAxsEXQ7c3+HsqxjI0=\"\n+ },\n+ \"invariant\": {\n+ \"version\": \"2.2.2\",\n+ \"resolved\": \"https://registry.npmjs.org/invariant/-/invariant-2.2.2.tgz\",\n+ \"integrity\": \"sha1-nh9WrArNtr8wMwbzOL47IErmA2A=\"\n+ },\n+ \"is-stream\": {\n+ \"version\": \"1.1.0\",\n+ \"resolved\": \"https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz\",\n+ \"integrity\": \"sha1-EtSj3U5o4Lec6428hBc66A2RykQ=\"\n+ },\n+ \"isomorphic-fetch\": {\n+ \"version\": \"2.2.1\",\n+ \"resolved\": \"https://registry.npmjs.org/isomorphic-fetch/-/isomorphic-fetch-2.2.1.tgz\",\n+ \"integrity\": \"sha1-YRrhrPFPXoH3KVB0coGf6XM1WKk=\"\n+ },\n+ \"jquery-param\": {\n+ \"version\": \"0.2.0\",\n+ \"resolved\": \"https://registry.npmjs.org/jquery-param/-/jquery-param-0.2.0.tgz\",\n+ \"integrity\": \"sha1-VdqBMEKMUJgOtRZJHBt3zHjw3LE=\"\n+ },\n+ \"js-tokens\": {\n+ \"version\": \"3.0.1\",\n+ \"resolved\": \"https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.1.tgz\",\n+ \"integrity\": \"sha1-COnxMkhKLEWjCQfp3E1VZ7fxFNc=\"\n+ },\n+ \"lodash\": {\n+ \"version\": \"4.17.4\",\n+ \"resolved\": \"https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz\",\n+ \"integrity\": \"sha1-eCA6TRwyiuHYbcpkYONptX9AVa4=\"\n+ },\n+ \"loose-envify\": {\n+ \"version\": \"1.3.1\",\n+ \"resolved\": \"https://registry.npmjs.org/loose-envify/-/loose-envify-1.3.1.tgz\",\n+ \"integrity\": \"sha1-0aitM/qc4OcT1l/dCsi3SNR4yEg=\"\n+ },\n+ \"node-fetch\": {\n+ \"version\": \"1.7.1\",\n+ \"resolved\": \"https://registry.npmjs.org/node-fetch/-/node-fetch-1.7.1.tgz\",\n+ \"integrity\": \"sha512-j8XsFGCLw79vWXkZtMSmmLaOk9z5SQ9bV/tkbZVCqvgwzrjAGq66igobLofHtF63NvMTp2WjytpsNTGKa+XRIQ==\"\n+ },\n+ \"object-assign\": {\n+ \"version\": \"4.1.1\",\n+ \"resolved\": \"https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz\",\n+ \"integrity\": \"sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=\"\n+ },\n+ \"promise\": {\n+ \"version\": \"7.1.1\",\n+ \"resolved\": \"https://registry.npmjs.org/promise/-/promise-7.1.1.tgz\",\n+ \"integrity\": \"sha1-SJZUxpJha4qlWwck+oCbt9tJxb8=\"\n+ },\n+ \"prop-types\": {\n+ \"version\": \"15.5.10\",\n+ \"resolved\": \"https://registry.npmjs.org/prop-types/-/prop-types-15.5.10.tgz\",\n+ \"integrity\": \"sha1-J5ffwxJhguOpXj37suiT3ddFYVQ=\"\n+ },\n+ \"reselect\": {\n+ \"version\": \"3.0.1\",\n+ \"resolved\": \"https://registry.npmjs.org/reselect/-/reselect-3.0.1.tgz\",\n+ \"integrity\": \"sha1-79qpjqdFEyTQkrKyFjpqHXqaIUc=\"\n+ },\n+ \"setimmediate\": {\n+ \"version\": \"1.0.5\",\n+ \"resolved\": \"https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz\",\n+ \"integrity\": \"sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU=\"\n+ },\n+ \"tokenize-text\": {\n+ \"version\": \"1.1.3\",\n+ \"resolved\": \"https://registry.npmjs.org/tokenize-text/-/tokenize-text-1.1.3.tgz\",\n+ \"integrity\": \"sha1-iwWdatojYYQC8TPbOAjjdSXNXns=\",\n+ \"dependencies\": {\n+ \"lodash\": {\n+ \"version\": \"3.10.1\",\n+ \"resolved\": \"https://registry.npmjs.org/lodash/-/lodash-3.10.1.tgz\",\n+ \"integrity\": \"sha1-W/Rejkm6QYnhfUgnid/RW9FAt7Y=\"\n+ }\n+ }\n+ },\n+ \"ua-parser-js\": {\n+ \"version\": \"0.7.12\",\n+ \"resolved\": \"https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-0.7.12.tgz\",\n+ \"integrity\": \"sha1-BMgamb3V3FImPqKdJMa/jUgYpLs=\"\n+ },\n+ \"whatwg-fetch\": {\n+ \"version\": \"2.0.3\",\n+ \"resolved\": \"https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-2.0.3.tgz\",\n+ \"integrity\": \"sha1-nITsLc9oGH/wC8ZOEnS0QhduHIQ=\"\n+ }\n+ }\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "native/calendar/entry.react.js",
"new_path": "native/calendar/entry.react.js",
"diff": "@@ -89,7 +89,7 @@ type State = {\ntext: string,\nloadingStatus: LoadingStatus,\nheight: number,\n- color: string,\n+ threadInfo: ThreadInfo,\n};\nclass Entry extends React.Component {\n@@ -125,11 +125,11 @@ class Entry extends React.Component {\ntext: props.entryInfo.text,\nloadingStatus: \"inactive\",\nheight: props.entryInfo.textHeight + 10,\n- // On log out, it's possible for the calendar to be deauthorized before\n+ // On log out, it's possible for the thread to be deauthorized before\n// the log out animation completes. To avoid having rendering issues in\n- // that case, we cache the color in state and don't reset it when the\n+ // that case, we cache the threadInfo in state and don't reset it when the\n// threadInfo is undefined.\n- color: props.threadInfo.color,\n+ threadInfo: props.threadInfo,\n};\n}\n@@ -154,9 +154,9 @@ class Entry extends React.Component {\n}\nif (\nnextProps.threadInfo &&\n- nextProps.threadInfo.color !== this.state.color\n+ !_isEqual(nextProps.threadInfo)(this.state.threadInfo)\n) {\n- this.setState({ color: nextProps.threadInfo.color });\n+ this.setState({ threadInfo: nextProps.threadInfo });\n}\nif (!nextProps.focused && this.props.focused) {\nif (this.textInput) {\n@@ -197,7 +197,7 @@ class Entry extends React.Component {\nrender() {\nconst focused = Entry.isFocused(this.props);\n- const darkColor = colorIsDark(this.state.color);\n+ const darkColor = colorIsDark(this.state.threadInfo.color);\nlet actionLinks = null;\nif (focused) {\nconst actionLinksColor = darkColor ? '#D3D3D3' : '#808080';\n@@ -228,13 +228,13 @@ class Entry extends React.Component {\nstyle={[styles.rightLinksText, actionLinksTextStyle]}\nnumberOfLines={1}\n>\n- {this.props.threadInfo.name}\n+ {this.state.threadInfo.name}\n</Text>\n</View>\n</View>\n);\n}\n- const entryStyle = { backgroundColor: `#${this.state.color}` };\n+ const entryStyle = { backgroundColor: `#${this.state.threadInfo.color}` };\nconst textStyle = {\ncolor: darkColor ? 'white' : 'black',\nheight: this.state.height,\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/message-list.react.js",
"new_path": "native/chat/message-list.react.js",
"diff": "@@ -13,12 +13,15 @@ import { messageInfoPropType } from 'lib/types/message-types';\nimport React from 'react';\nimport { connect } from 'react-redux';\nimport PropTypes from 'prop-types';\n-import { View, Text, StyleSheet, FlatList } from 'react-native';\n+import { View, StyleSheet } from 'react-native';\nimport _sum from 'lodash/fp/sum';\n+import { InvertibleFlatList } from 'react-native-invertible-flat-list';\n-import { messageListData } from '../selectors/chat-selectors';\nimport { messageKey } from 'lib/shared/message-utils';\n+import { messageListData } from '../selectors/chat-selectors';\n+import Message from './message.react';\n+\ntype NavProp = NavigationScreenProp<NavigationRoute, NavigationAction>;\nclass InnerMessageList extends React.PureComponent {\n@@ -43,7 +46,7 @@ class InnerMessageList extends React.PureComponent {\n});\nrenderItem = (row: { item: MessageInfo }) => {\n- return <Text numberOfLines={1}>{row.item.text}</Text>;\n+ return <Message messageInfo={row.item} />;\n}\nstatic getItemLayout(data: $ReadOnlyArray<MessageInfo>, index: number) {\n@@ -65,7 +68,8 @@ class InnerMessageList extends React.PureComponent {\nrender() {\nreturn (\n<View style={styles.container}>\n- <FlatList\n+ <InvertibleFlatList\n+ inverted={true}\ndata={this.props.messageListData}\nrenderItem={this.renderItem}\nkeyExtractor={messageKey}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/chat/message.react.js",
"diff": "+// @flow\n+\n+import type { MessageInfo } from 'lib/types/message-types';\n+import { messageInfoPropType } from 'lib/types/message-types';\n+import type { ThreadInfo } from 'lib/types/thread-types';\n+import { threadInfoPropType } from 'lib/types/thread-types';\n+import type { AppState } from '../redux-setup';\n+\n+import React from 'react';\n+import { Text, StyleSheet, View } from 'react-native';\n+import { connect } from 'react-redux';\n+import _isEqual from 'lodash/fp/isEqual';\n+import invariant from 'invariant';\n+import PropTypes from 'prop-types';\n+\n+import { colorIsDark } from 'lib/selectors/thread-selectors';\n+\n+type Props = {\n+ messageInfo: MessageInfo,\n+ // Redux state\n+ threadInfo: ThreadInfo,\n+ userID: ?string,\n+};\n+type State = {\n+ threadInfo: ThreadInfo,\n+};\n+class Message extends React.PureComponent {\n+\n+ props: Props;\n+ state: State;\n+ static propTypes = {\n+ messageInfo: messageInfoPropType.isRequired,\n+ threadInfo: threadInfoPropType.isRequired,\n+ userID: PropTypes.string,\n+ };\n+\n+ constructor(props: Props) {\n+ super(props);\n+ invariant(props.threadInfo, \"should be set\");\n+ this.state = {\n+ // On log out, it's possible for the thread to be deauthorized before\n+ // the log out animation completes. To avoid having rendering issues in\n+ // that case, we cache the threadInfo in state and don't reset it when the\n+ // threadInfo is undefined.\n+ threadInfo: props.threadInfo,\n+ };\n+ }\n+\n+ componentWillReceiveProps(nextProps: Props) {\n+ if (\n+ nextProps.threadInfo &&\n+ !_isEqual(nextProps.threadInfo)(this.state.threadInfo)\n+ ) {\n+ this.setState({ threadInfo: nextProps.threadInfo });\n+ }\n+ }\n+\n+ render() {\n+ const isYou = this.props.messageInfo.creatorID === this.props.userID;\n+ let containerStyle = null,\n+ messageStyle = null,\n+ textStyle = null,\n+ authorName = null;\n+ if (isYou) {\n+ containerStyle = { alignSelf: 'flex-end' };\n+ messageStyle = {\n+ backgroundColor: `#${this.state.threadInfo.color}`,\n+ };\n+ const darkColor = colorIsDark(this.state.threadInfo.color);\n+ textStyle = darkColor ? styles.whiteText : styles.blackText;\n+ } else {\n+ containerStyle = { alignSelf: 'flex-start' };\n+ textStyle = styles.blackText;\n+ authorName = (\n+ <Text style={styles.authorName}>\n+ {this.props.messageInfo.creator}\n+ </Text>\n+ );\n+ }\n+ return (\n+ <View style={[styles.container, containerStyle]}>\n+ {authorName}\n+ <View style={[styles.message, messageStyle]}>\n+ <Text\n+ numberOfLines={1}\n+ style={[styles.text, textStyle]}\n+ >{this.props.messageInfo.text}</Text>\n+ </View>\n+ </View>\n+ );\n+ }\n+\n+}\n+\n+const styles = StyleSheet.create({\n+ text: {\n+ fontSize: 18,\n+ },\n+ whiteText: {\n+ color: 'white',\n+ },\n+ blackText: {\n+ color: 'black',\n+ },\n+ container: {\n+ },\n+ message: {\n+ borderRadius: 8,\n+ overflow: 'hidden',\n+ paddingVertical: 6,\n+ paddingHorizontal: 12,\n+ backgroundColor: \"#AAAAAABB\",\n+ marginBottom: 12,\n+ marginHorizontal: 12,\n+ },\n+ authorName: {\n+ color: '#777777',\n+ fontSize: 14,\n+ paddingHorizontal: 24,\n+ paddingVertical: 4,\n+ },\n+});\n+\n+export default connect(\n+ (state: AppState, ownProps: { messageInfo: MessageInfo }) => ({\n+ threadInfo: state.threadInfos[ownProps.messageInfo.threadID],\n+ userID: state.userInfo && state.userInfo.id,\n+ }),\n+)(Message);\n"
},
{
"change_type": "MODIFY",
"old_path": "native/package.json",
"new_path": "native/package.json",
"diff": "\"react\": \"^16.0.0-alpha.12\",\n\"react-native\": \"^0.45.0-rc.2\",\n\"react-native-cookies\": \"^3.1.0\",\n+ \"react-native-invertible-flat-list\": \"^1.0.0\",\n\"react-native-keychain\": \"^1.2.0\",\n\"react-native-onepassword\": \"^1.0.4\",\n\"react-native-vector-icons\": \"^4.1.1\",\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Create Message React component and give it some style yo |
129,187 | 06.06.2017 09:26:46 | 14,400 | ecef8d8a3a004b8b8601558f0f6efe8e9af1f25d | Set up MessageList to use TextHeightMeasurer | [
{
"change_type": "MODIFY",
"old_path": "native/calendar/calendar.react.js",
"new_path": "native/calendar/calendar.react.js",
"diff": "@@ -143,7 +143,6 @@ class InnerCalendar extends React.PureComponent {\n/>\n),\n};\n- textHeightMeasurer: ?TextHeightMeasurer = null;\nflatList: ?FlatList<CalendarItemWithHeight> = null;\ntextHeights: ?{ [text: string]: number } = null;\ncurrentState: ?string = NativeAppState.currentState;\n@@ -225,8 +224,11 @@ class InnerCalendar extends React.PureComponent {\ncomponentWillReceiveProps(newProps: Props) {\n// When the listData changes we may need to recalculate some heights\n- if (newProps.listData !== this.props.listData) {\n+ if (newProps.listData === this.props.listData) {\n+ return;\n+ }\nconst newListData = newProps.listData;\n+\nif (!newListData) {\nthis.latestExtraData = {\nfocusedEntries: {},\n@@ -240,8 +242,9 @@ class InnerCalendar extends React.PureComponent {\n});\nthis.topLoaderWaitingToLeaveView = true;\nthis.bottomLoaderWaitingToLeaveView = true;\n- } else {\n- // If we had no entries and just got some we'll scroll to today\n+ return;\n+ }\n+\nconst newTextToMeasure = InnerCalendar.textToMeasureFromListData(\nnewListData,\n);\n@@ -256,10 +259,11 @@ class InnerCalendar extends React.PureComponent {\n}\n}\n}\n-\nif (allTextAlreadyMeasured) {\nthis.mergeHeightsIntoListData(newListData);\n- } else {\n+ return;\n+ }\n+\nconst newText =\n_difference(newTextToMeasure)(this.state.textToMeasure);\nif (newText.length === 0) {\n@@ -276,9 +280,6 @@ class InnerCalendar extends React.PureComponent {\nthis.setState({ textToMeasure: newTextToMeasure });\n}\n}\n- }\n- }\n- }\ncomponentWillUpdate(nextProps: Props, nextState: State) {\nif (\n@@ -414,13 +415,14 @@ class InnerCalendar extends React.PureComponent {\n}\nmergeHeightsIntoListData(listData: $ReadOnlyArray<CalendarItem>) {\n+ const textHeights = this.textHeights;\n+ invariant(textHeights, \"textHeights should be set\");\nconst listDataWithHeights = _map((item: CalendarItem) => {\nif (item.itemType !== \"entryInfo\") {\nreturn item;\n}\nconst entryInfo = item.entryInfo;\n- invariant(this.textHeights, \"textHeights should be set\");\n- const textHeight = this.textHeights[entryInfo.text];\n+ const textHeight = textHeights[entryInfo.text];\ninvariant(\ntextHeight,\n`height for ${entryKey(entryInfo)} should be set`,\n@@ -608,7 +610,6 @@ class InnerCalendar extends React.PureComponent {\ntextToMeasure={this.state.textToMeasure}\nallHeightsMeasuredCallback={this.allHeightsMeasured}\nstyle={styles.text}\n- ref={this.textHeightMeasurerRef}\n/>\n{loadingIndicator}\n{flatList}\n@@ -635,10 +636,6 @@ class InnerCalendar extends React.PureComponent {\nreturn returnIndex;\n}\n- textHeightMeasurerRef = (textHeightMeasurer: ?TextHeightMeasurer) => {\n- this.textHeightMeasurer = textHeightMeasurer;\n- }\n-\nflatListRef = (flatList: ?FlatList<CalendarItemWithHeight>) => {\nthis.flatList = flatList;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/message-list.react.js",
"new_path": "native/chat/message-list.react.js",
"diff": "@@ -13,24 +13,35 @@ import { messageInfoPropType } from 'lib/types/message-types';\nimport React from 'react';\nimport { connect } from 'react-redux';\nimport PropTypes from 'prop-types';\n-import { View, StyleSheet } from 'react-native';\n-import _sum from 'lodash/fp/sum';\n+import { View, StyleSheet, ActivityIndicator } from 'react-native';\nimport { InvertibleFlatList } from 'react-native-invertible-flat-list';\n+import invariant from 'invariant';\n+import _sum from 'lodash/fp/sum';\n+import _difference from 'lodash/fp/difference';\nimport { messageKey } from 'lib/shared/message-utils';\nimport { messageListData } from '../selectors/chat-selectors';\nimport Message from './message.react';\n+import TextHeightMeasurer from '../text-height-measurer.react';\ntype NavProp = NavigationScreenProp<NavigationRoute, NavigationAction>;\n-class InnerMessageList extends React.PureComponent {\n-\n- props: {\n+export type MessageInfoWithHeight = MessageInfo & { textHeight: number };\n+type Props = {\nnavigation: NavProp,\n// Redux state\nmessageListData: $ReadOnlyArray<MessageInfo>,\n+ userID: ?string,\n};\n+type State = {\n+ textToMeasure: string[],\n+ listDataWithHeights: ?$ReadOnlyArray<MessageInfoWithHeight>,\n+};\n+class InnerMessageList extends React.PureComponent {\n+\n+ props: Props;\n+ state: State;\nstatic propTypes = {\nnavigation: PropTypes.shape({\nstate: PropTypes.shape({\n@@ -40,45 +51,160 @@ class InnerMessageList extends React.PureComponent {\n}).isRequired,\n}).isRequired,\nmessageListData: PropTypes.arrayOf(messageInfoPropType).isRequired,\n+ userID: PropTypes.string,\n};\nstatic navigationOptions = ({ navigation }) => ({\ntitle: navigation.state.params.threadInfo.name,\n});\n+ textHeights: ?{ [text: string]: number } = null;\n+\n+ constructor(props: Props) {\n+ super(props);\n+ const textToMeasure = props.messageListData\n+ ? InnerMessageList.textToMeasureFromListData(props.messageListData)\n+ : [];\n+ this.state = {\n+ textToMeasure,\n+ listDataWithHeights: null,\n+ };\n+ }\n+\n+ static textToMeasureFromListData(listData: $ReadOnlyArray<MessageInfo>) {\n+ return listData.map((messageInfo: MessageInfo) => messageInfo.text);\n+ }\n+\n+ componentWillReceiveProps(nextProps: Props) {\n+ if (nextProps.listData === this.props.messageListData) {\n+ return;\n+ }\n+ const newListData = nextProps.messageListData;\n+\n+ if (!newListData) {\n+ this.setState({\n+ textToMeasure: [],\n+ listDataWithHeights: null,\n+ });\n+ return;\n+ }\n+\n+ const newTextToMeasure = InnerMessageList.textToMeasureFromListData(\n+ newListData,\n+ );\n+\n+ let allTextAlreadyMeasured = false;\n+ if (this.textHeights) {\n+ allTextAlreadyMeasured = true;\n+ for (let text of newTextToMeasure) {\n+ if (this.textHeights[text] === undefined) {\n+ allTextAlreadyMeasured = false;\n+ break;\n+ }\n+ }\n+ }\n+ if (allTextAlreadyMeasured) {\n+ this.mergeHeightsIntoListData(newListData);\n+ return;\n+ }\n+\n+ const newText =\n+ _difference(newTextToMeasure)(this.state.textToMeasure);\n+ if (newText.length === 0) {\n+ // Since we don't have everything in textHeights, but we do have\n+ // everything in textToMeasure, we can conclude that we're just\n+ // waiting for the measurement to complete and then we'll be good.\n+ } else {\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+ }\n+\n+ }\n+\n+ mergeHeightsIntoListData(listData: $ReadOnlyArray<MessageInfo>) {\n+ const textHeights = this.textHeights;\n+ invariant(textHeights, \"textHeights should be set\");\n+ const listDataWithHeights = listData.map((item: MessageInfo) => {\n+ const textHeight = textHeights[item.text];\n+ invariant(textHeight, `height for ${messageKey(item)} should be set`);\n+ return { ...item, textHeight };\n+ });\n+ this.setState({ listDataWithHeights });\n+ }\n- renderItem = (row: { item: MessageInfo }) => {\n+ renderItem = (row: { item: MessageInfoWithHeight }) => {\nreturn <Message messageInfo={row.item} />;\n}\n- static getItemLayout(data: $ReadOnlyArray<MessageInfo>, index: number) {\n- const offset =\n- InnerMessageList.heightOfItems(data.filter((_, i) => i < index));\n+ getItemLayout = (\n+ data: $ReadOnlyArray<MessageInfoWithHeight>,\n+ index: number,\n+ ) => {\n+ const offset = this.heightOfItems(data.filter((_, i) => i < index));\nconst item = data[index];\n- const length = item ? InnerMessageList.itemHeight(item) : 0;\n+ const length = item ? Message.itemHeight(item, this.props.userID) : 0;\nreturn { length, offset, index };\n}\n- static itemHeight(item: MessageInfo): number {\n- return 40;\n- }\n-\n- static heightOfItems(data: $ReadOnlyArray<MessageInfo>): number {\n- return _sum(data.map(InnerMessageList.itemHeight));\n+ heightOfItems(data: $ReadOnlyArray<MessageInfoWithHeight>): number {\n+ return _sum(data.map(\n+ (messageInfo: MessageInfoWithHeight) =>\n+ Message.itemHeight(messageInfo, this.props.userID),\n+ ));\n}\nrender() {\n- return (\n- <View style={styles.container}>\n+ const listDataWithHeights = this.state.listDataWithHeights;\n+ let flatList = null;\n+ if (listDataWithHeights) {\n+ flatList = (\n<InvertibleFlatList\ninverted={true}\n- data={this.props.messageListData}\n+ data={listDataWithHeights}\nrenderItem={this.renderItem}\nkeyExtractor={messageKey}\n- getItemLayout={InnerMessageList.getItemLayout}\n+ getItemLayout={this.getItemLayout}\nstyle={styles.flatList}\n/>\n+ );\n+ } else {\n+ flatList = (\n+ <View style={styles.loadingIndicatorContainer}>\n+ <ActivityIndicator\n+ color=\"black\"\n+ size=\"large\"\n+ style={styles.loadingIndicator}\n+ />\n</View>\n);\n}\n+ return (\n+ <View style={styles.container}>\n+ <TextHeightMeasurer\n+ textToMeasure={this.state.textToMeasure}\n+ allHeightsMeasuredCallback={this.allHeightsMeasured}\n+ style={styles.text}\n+ />\n+ {flatList}\n+ </View>\n+ );\n+ }\n+\n+ allHeightsMeasured = (\n+ textToMeasure: string[],\n+ newTextHeights: { [text: string]: number },\n+ ) => {\n+ if (textToMeasure !== this.state.textToMeasure) {\n+ return;\n+ }\n+ this.textHeights = newTextHeights;\n+ if (this.props.messageListData) {\n+ this.mergeHeightsIntoListData(this.props.messageListData);\n+ }\n+ }\n}\n@@ -90,6 +216,22 @@ const styles = StyleSheet.create({\nflex: 1,\nbackgroundColor: '#FFFFFF',\n},\n+ text: {\n+ left: 24,\n+ right: 24,\n+ fontSize: 18,\n+ fontFamily: 'Arial',\n+ },\n+ loadingIndicator: {\n+ flex: 1,\n+ },\n+ loadingIndicatorContainer: {\n+ position: 'absolute',\n+ top: 0,\n+ bottom: 0,\n+ left: 0,\n+ right: 0,\n+ },\n});\n@@ -98,6 +240,7 @@ const MessageList = connect(\n(state: AppState, ownProps: { navigation: NavProp }) => ({\nmessageListData: messageListData\n(ownProps.navigation.state.params.threadInfo.id)(state),\n+ userID: state.userInfo && state.userInfo.id,\n}),\n)(InnerMessageList);\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/message.react.js",
"new_path": "native/chat/message.react.js",
"diff": "// @flow\n-import type { MessageInfo } from 'lib/types/message-types';\nimport { messageInfoPropType } from 'lib/types/message-types';\nimport type { ThreadInfo } from 'lib/types/thread-types';\nimport { threadInfoPropType } from 'lib/types/thread-types';\nimport type { AppState } from '../redux-setup';\n+import type { MessageInfoWithHeight } from './message-list.react';\nimport React from 'react';\nimport { Text, StyleSheet, View } from 'react-native';\n@@ -16,7 +16,7 @@ import PropTypes from 'prop-types';\nimport { colorIsDark } from 'lib/selectors/thread-selectors';\ntype Props = {\n- messageInfo: MessageInfo,\n+ messageInfo: MessageInfoWithHeight,\n// Redux state\nthreadInfo: ThreadInfo,\nuserID: ?string,\n@@ -55,6 +55,14 @@ class Message extends React.PureComponent {\n}\n}\n+ static itemHeight(messageInfo: MessageInfoWithHeight, userID: ?string) {\n+ if (messageInfo.creatorID === userID) {\n+ return 24 + messageInfo.textHeight;\n+ } else {\n+ return 24 + 25 + messageInfo.textHeight;\n+ }\n+ }\n+\nrender() {\nconst isYou = this.props.messageInfo.creatorID === this.props.userID;\nlet containerStyle = null,\n@@ -95,6 +103,7 @@ class Message extends React.PureComponent {\nconst styles = StyleSheet.create({\ntext: {\nfontSize: 18,\n+ fontFamily: 'Arial',\n},\nwhiteText: {\ncolor: 'white',\n@@ -122,7 +131,7 @@ const styles = StyleSheet.create({\n});\nexport default connect(\n- (state: AppState, ownProps: { messageInfo: MessageInfo }) => ({\n+ (state: AppState, ownProps: { messageInfo: MessageInfoWithHeight }) => ({\nthreadInfo: state.threadInfos[ownProps.messageInfo.threadID],\nuserID: state.userInfo && state.userInfo.id,\n}),\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Set up MessageList to use TextHeightMeasurer |
129,187 | 06.06.2017 17:06:32 | 14,400 | 7cc411390949ddf68abc874a9d255af4bf19280d | Auto-grow the chat TextInput on iOS and Android and make it look pretty | [
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/chat/input-bar.react.js",
"diff": "+// @flow\n+\n+import React from 'react';\n+import {\n+ View,\n+ StyleSheet,\n+ TextInput,\n+ TouchableOpacity,\n+ LayoutAnimation,\n+ Platform,\n+} from 'react-native';\n+import Icon from 'react-native-vector-icons/FontAwesome';\n+import { connect } from 'react-redux';\n+\n+type Props = {\n+};\n+type State = {\n+ focused: bool,\n+ inputText: string,\n+ height: number,\n+};\n+class InputBar extends React.PureComponent {\n+\n+ props: Props;\n+ state: State = {\n+ focused: false,\n+ inputText: \"\",\n+ height: 0,\n+ };\n+ textInput: ?TextInput;\n+\n+ componentWillUpdate(nextProps: Props, nextState: State) {\n+ if (\n+ this.state.inputText === \"\" && nextState.inputText !== \"\" ||\n+ this.state.inputText !== \"\" && nextState.inputText === \"\"\n+ ) {\n+ LayoutAnimation.easeInEaseOut();\n+ }\n+ }\n+\n+ render() {\n+ let button = null;\n+ if (this.state.focused && this.state.inputText) {\n+ button = (\n+ <TouchableOpacity\n+ onPress={this.onSend}\n+ activeOpacity={0.4}\n+ style={styles.sendButton}\n+ >\n+ <Icon\n+ name=\"chevron-right\"\n+ size={25}\n+ style={styles.sendIcon}\n+ color=\"#88BB88\"\n+ />\n+ </TouchableOpacity>\n+ );\n+ }\n+ const textInputStyle = {\n+ height: Math.max(this.state.height, 30),\n+ };\n+ return (\n+ <View style={styles.container}>\n+ <View style={styles.textInputContainer}>\n+ <TextInput\n+ value={this.state.inputText}\n+ onChangeText={this.onChangeText}\n+ underlineColorAndroid=\"transparent\"\n+ placeholder=\"Send a message...\"\n+ placeholderTextColor=\"#888888\"\n+ multiline={true}\n+ onFocus={this.onFocus}\n+ onBlur={this.onBlur}\n+ onContentSizeChange={this.onContentSizeChange}\n+ onChange={this.onChange}\n+ style={[styles.textInput, textInputStyle]}\n+ ref={this.textInputRef}\n+ />\n+ </View>\n+ {button}\n+ </View>\n+ );\n+ }\n+\n+ textInputRef = (textInput: ?TextInput) => {\n+ this.textInput = textInput;\n+ }\n+\n+ onChangeText = (text: string) => {\n+ this.setState({ inputText: text });\n+ }\n+\n+ onFocus = () => {\n+ LayoutAnimation.easeInEaseOut();\n+ this.setState({ focused: true });\n+ }\n+\n+ onBlur = () => {\n+ LayoutAnimation.easeInEaseOut();\n+ this.setState({ focused: false });\n+ }\n+\n+ onContentSizeChange = (event) => {\n+ let height = event.nativeEvent.contentSize.height;\n+ // iOS doesn't include the margin on this callback\n+ height = Platform.OS === \"ios\" ? height + 10 : height;\n+ this.setState({ height });\n+ }\n+\n+ // On Android, onContentSizeChange only gets called once when the TextInput is\n+ // first rendered. Which is like, what? Anyways, instead you're supposed to\n+ // use onChange.\n+ onChange = (event) => {\n+ if (Platform.OS === \"android\") {\n+ this.setState({ height: event.nativeEvent.contentSize.height });\n+ }\n+ }\n+\n+\n+ onSend = () => {\n+ this.setState({ inputText: \"\" });\n+ }\n+\n+}\n+\n+const styles = StyleSheet.create({\n+ container: {\n+ flexDirection: 'row',\n+ backgroundColor: '#EEEEEEEE',\n+ borderTopWidth: 1,\n+ borderColor: '#AAAAAAAA',\n+ },\n+ textInputContainer: {\n+ flex: 1,\n+ },\n+ textInput: {\n+ backgroundColor: 'white',\n+ marginVertical: 5,\n+ marginHorizontal: 8,\n+ paddingVertical: 5,\n+ paddingHorizontal: 10,\n+ borderRadius: 10,\n+ fontSize: 16,\n+ borderColor: '#AAAAAAAA',\n+ borderWidth: 1,\n+ },\n+ sendButton: {\n+ alignSelf: 'flex-end',\n+ paddingBottom: 7,\n+ },\n+ sendIcon: {\n+ paddingLeft: 2,\n+ paddingRight: 8,\n+ },\n+});\n+\n+export default connect(\n+ undefined,\n+ includeDispatchActionProps({ dispatchActionPromise: true }),\n+ bindServerCalls({ deleteEntry }),\n+)(InputBar);\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/message-list.react.js",
"new_path": "native/chat/message-list.react.js",
"diff": "@@ -13,7 +13,13 @@ import { messageInfoPropType } from 'lib/types/message-types';\nimport React from 'react';\nimport { connect } from 'react-redux';\nimport PropTypes from 'prop-types';\n-import { View, StyleSheet, ActivityIndicator } from 'react-native';\n+import {\n+ View,\n+ StyleSheet,\n+ ActivityIndicator,\n+ KeyboardAvoidingView,\n+ Platform,\n+} from 'react-native';\nimport { InvertibleFlatList } from 'react-native-invertible-flat-list';\nimport invariant from 'invariant';\nimport _sum from 'lodash/fp/sum';\n@@ -24,6 +30,7 @@ import { messageKey } from 'lib/shared/message-utils';\nimport { messageListData } from '../selectors/chat-selectors';\nimport Message from './message.react';\nimport TextHeightMeasurer from '../text-height-measurer.react';\n+import InputBar from './input-bar.react';\ntype NavProp = NavigationScreenProp<NavigationRoute, NavigationAction>;\n@@ -157,6 +164,13 @@ class InnerMessageList extends React.PureComponent {\n}\nrender() {\n+ const textHeightMeasurer = (\n+ <TextHeightMeasurer\n+ textToMeasure={this.state.textToMeasure}\n+ allHeightsMeasuredCallback={this.allHeightsMeasured}\n+ style={styles.text}\n+ />\n+ );\nconst listDataWithHeights = this.state.listDataWithHeights;\nlet flatList = null;\nif (listDataWithHeights) {\n@@ -167,7 +181,6 @@ class InnerMessageList extends React.PureComponent {\nrenderItem={this.renderItem}\nkeyExtractor={messageKey}\ngetItemLayout={this.getItemLayout}\n- style={styles.flatList}\n/>\n);\n} else {\n@@ -181,15 +194,21 @@ class InnerMessageList extends React.PureComponent {\n</View>\n);\n}\n+\n+ const behavior = Platform.OS === \"android\" ? undefined : \"padding\";\n+ const keyboardVerticalOffset = Platform.OS === \"ios\" ? 64 : 0;\nreturn (\n- <View style={styles.container}>\n- <TextHeightMeasurer\n- textToMeasure={this.state.textToMeasure}\n- allHeightsMeasuredCallback={this.allHeightsMeasured}\n- style={styles.text}\n- />\n+ <KeyboardAvoidingView\n+ behavior={behavior}\n+ keyboardVerticalOffset={keyboardVerticalOffset}\n+ style={styles.container}\n+ >\n+ {textHeightMeasurer}\n+ <View style={styles.flatListContainer}>\n{flatList}\n</View>\n+ <InputBar />\n+ </KeyboardAvoidingView>\n);\n}\n@@ -212,7 +231,7 @@ const styles = StyleSheet.create({\ncontainer: {\nflex: 1,\n},\n- flatList: {\n+ flatListContainer: {\nflex: 1,\nbackgroundColor: '#FFFFFF',\n},\n@@ -226,15 +245,10 @@ const styles = StyleSheet.create({\nflex: 1,\n},\nloadingIndicatorContainer: {\n- position: 'absolute',\n- top: 0,\n- bottom: 0,\n- left: 0,\n- right: 0,\n+ flex: 1,\n},\n});\n-\nconst MessageListRouteName = 'MessageList';\nconst MessageList = connect(\n(state: AppState, ownProps: { navigation: NavProp }) => ({\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/message.react.js",
"new_path": "native/chat/message.react.js",
"diff": "@@ -118,7 +118,7 @@ const styles = StyleSheet.create({\noverflow: 'hidden',\npaddingVertical: 6,\npaddingHorizontal: 12,\n- backgroundColor: \"#AAAAAABB\",\n+ backgroundColor: \"#DDDDDDBB\",\nmarginBottom: 12,\nmarginHorizontal: 12,\n},\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Auto-grow the chat TextInput on iOS and Android and make it look pretty |
129,187 | 07.06.2017 11:27:13 | 14,400 | 7f115ba182874e726467ecdb5a5b819b5cc0e29f | Error handling for failed message sends (delete them) | [
{
"change_type": "MODIFY",
"old_path": "lib/reducers/message-reducer.js",
"new_path": "lib/reducers/message-reducer.js",
"diff": "@@ -315,6 +315,25 @@ function reduceMessageStore(\n},\ncurrentAsOf: messageStore.currentAsOf,\n};\n+ } else if (action.type === \"SEND_MESSAGE_FAILED\") {\n+ const payload = action.payload;\n+ const isNotLocalID = (localID: ?string) => localID !== payload.localID;\n+ const newMessages = _pickBy(\n+ (messageInfo: MessageInfo) => isNotLocalID(messageInfo.localID),\n+ )(messageStore.messages);\n+ const newMessageIDs =\n+ messageStore.threads[payload.threadID].messageIDs.filter(isNotLocalID);\n+ return {\n+ messages: newMessages,\n+ threads: {\n+ ...messageStore.threads,\n+ [payload.threadID]: {\n+ ...messageStore.threads[payload.threadID],\n+ messageIDs: newMessageIDs,\n+ },\n+ },\n+ currentAsOf: messageStore.currentAsOf,\n+ };\n} else if (action.type === \"SEND_MESSAGE_SUCCESS\") {\nconst payload = action.payload;\nconst replaceMessageKey =\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/types/redux-types.js",
"new_path": "lib/types/redux-types.js",
"diff": "@@ -374,7 +374,10 @@ export type BaseAction =\n} | {\ntype: \"SEND_MESSAGE_FAILED\",\nerror: true,\n- payload: Error,\n+ payload: Error & {\n+ localID: string,\n+ threadID: string,\n+ },\nloadingInfo: LoadingInfo,\n} | {\ntype: \"SEND_MESSAGE_SUCCESS\",\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/input-bar.react.js",
"new_path": "native/chat/input-bar.react.js",
"diff": "@@ -168,7 +168,8 @@ class InputBar extends React.PureComponent {\ntime: result.time,\n};\n} catch (e) {\n- // TODO dispatch an action to remove this message from the store\n+ e.localID = messageInfo.localID;\n+ e.threadID = messageInfo.threadID;\nthrow e;\n}\n}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Error handling for failed message sends (delete them) |
129,187 | 07.06.2017 12:07:02 | 14,400 | 1df30b9a8dcf7787b17fdee84401fc78e8e63066 | Wrap MessageInfo passed to MessageList/Message in ChatMessageItem that can support additional fields | [
{
"change_type": "MODIFY",
"old_path": "native/chat/message-list.react.js",
"new_path": "native/chat/message-list.react.js",
"diff": "@@ -7,8 +7,8 @@ import type {\nNavigationAction,\n} from 'react-navigation';\nimport { threadInfoPropType } from 'lib/types/thread-types';\n-import type { MessageInfo } from 'lib/types/message-types';\n-import { messageInfoPropType } from 'lib/types/message-types';\n+import type { ChatMessageItem } from '../selectors/chat-selectors';\n+import { chatMessageItemPropType } from '../selectors/chat-selectors';\nimport React from 'react';\nimport { connect } from 'react-redux';\n@@ -34,16 +34,17 @@ import InputBar from './input-bar.react';\ntype NavProp = NavigationScreenProp<NavigationRoute, NavigationAction>;\n-export type MessageInfoWithHeight = MessageInfo & { textHeight: number };\n+export type ChatMessageItemWithHeight = ChatMessageItem\n+ & { textHeight: number };\ntype Props = {\nnavigation: NavProp,\n// Redux state\n- messageListData: $ReadOnlyArray<MessageInfo>,\n+ messageListData: $ReadOnlyArray<ChatMessageItem>,\nuserID: ?string,\n};\ntype State = {\ntextToMeasure: string[],\n- listDataWithHeights: ?$ReadOnlyArray<MessageInfoWithHeight>,\n+ listDataWithHeights: ?$ReadOnlyArray<ChatMessageItemWithHeight>,\n};\nclass InnerMessageList extends React.PureComponent {\n@@ -57,7 +58,7 @@ class InnerMessageList extends React.PureComponent {\n}).isRequired,\n}).isRequired,\n}).isRequired,\n- messageListData: PropTypes.arrayOf(messageInfoPropType).isRequired,\n+ messageListData: PropTypes.arrayOf(chatMessageItemPropType).isRequired,\nuserID: PropTypes.string,\n};\nstatic navigationOptions = ({ navigation }) => ({\n@@ -76,8 +77,8 @@ class InnerMessageList extends React.PureComponent {\n};\n}\n- static textToMeasureFromListData(listData: $ReadOnlyArray<MessageInfo>) {\n- return listData.map((messageInfo: MessageInfo) => messageInfo.text);\n+ static textToMeasureFromListData(listData: $ReadOnlyArray<ChatMessageItem>) {\n+ return listData.map((item: ChatMessageItem) => item.messageInfo.text);\n}\ncomponentWillReceiveProps(nextProps: Props) {\n@@ -131,23 +132,26 @@ class InnerMessageList extends React.PureComponent {\n}\n- mergeHeightsIntoListData(listData: $ReadOnlyArray<MessageInfo>) {\n+ mergeHeightsIntoListData(listData: $ReadOnlyArray<ChatMessageItem>) {\nconst textHeights = this.textHeights;\ninvariant(textHeights, \"textHeights should be set\");\n- const listDataWithHeights = listData.map((item: MessageInfo) => {\n- const textHeight = textHeights[item.text];\n- invariant(textHeight, `height for ${messageKey(item)} should be set`);\n+ const listDataWithHeights = listData.map((item: ChatMessageItem) => {\n+ const textHeight = textHeights[item.messageInfo.text];\n+ invariant(\n+ textHeight,\n+ `height for ${messageKey(item.messageInfo)} should be set`,\n+ );\nreturn { ...item, textHeight };\n});\nthis.setState({ listDataWithHeights });\n}\n- renderItem = (row: { item: MessageInfoWithHeight }) => {\n- return <Message messageInfo={row.item} />;\n+ renderItem = (row: { item: ChatMessageItemWithHeight }) => {\n+ return <Message item={row.item} />;\n}\ngetItemLayout = (\n- data: $ReadOnlyArray<MessageInfoWithHeight>,\n+ data: $ReadOnlyArray<ChatMessageItemWithHeight>,\nindex: number,\n) => {\nconst offset = this.heightOfItems(data.filter((_, i) => i < index));\n@@ -156,10 +160,10 @@ class InnerMessageList extends React.PureComponent {\nreturn { length, offset, index };\n}\n- heightOfItems(data: $ReadOnlyArray<MessageInfoWithHeight>): number {\n+ heightOfItems(data: $ReadOnlyArray<ChatMessageItemWithHeight>): number {\nreturn _sum(data.map(\n- (messageInfo: MessageInfoWithHeight) =>\n- Message.itemHeight(messageInfo, this.props.userID),\n+ (item: ChatMessageItemWithHeight) =>\n+ Message.itemHeight(item, this.props.userID),\n));\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/message.react.js",
"new_path": "native/chat/message.react.js",
"diff": "// @flow\n-import { messageInfoPropType } from 'lib/types/message-types';\nimport type { ThreadInfo } from 'lib/types/thread-types';\nimport { threadInfoPropType } from 'lib/types/thread-types';\nimport type { AppState } from '../redux-setup';\n-import type { MessageInfoWithHeight } from './message-list.react';\n+import type { ChatMessageItemWithHeight } from './message-list.react';\n+import { chatMessageItemPropType } from '../selectors/chat-selectors';\nimport React from 'react';\nimport { Text, StyleSheet, View } from 'react-native';\n@@ -16,7 +16,7 @@ import PropTypes from 'prop-types';\nimport { colorIsDark } from 'lib/selectors/thread-selectors';\ntype Props = {\n- messageInfo: MessageInfoWithHeight,\n+ item: ChatMessageItemWithHeight,\n// Redux state\nthreadInfo: ThreadInfo,\nuserID: ?string,\n@@ -29,7 +29,7 @@ class Message extends React.PureComponent {\nprops: Props;\nstate: State;\nstatic propTypes = {\n- messageInfo: messageInfoPropType.isRequired,\n+ item: chatMessageItemPropType.isRequired,\nthreadInfo: threadInfoPropType.isRequired,\nuserID: PropTypes.string,\n};\n@@ -55,16 +55,16 @@ class Message extends React.PureComponent {\n}\n}\n- static itemHeight(messageInfo: MessageInfoWithHeight, userID: ?string) {\n- if (messageInfo.creatorID === userID) {\n- return 24 + messageInfo.textHeight;\n+ static itemHeight(item: ChatMessageItemWithHeight, userID: ?string) {\n+ if (item.messageInfo.creatorID === userID) {\n+ return 24 + item.textHeight;\n} else {\n- return 24 + 25 + messageInfo.textHeight;\n+ return 24 + 25 + item.textHeight;\n}\n}\nrender() {\n- const isYou = this.props.messageInfo.creatorID === this.props.userID;\n+ const isYou = this.props.item.messageInfo.creatorID === this.props.userID;\nlet containerStyle = null,\nmessageStyle = null,\ntextStyle = null,\n@@ -81,7 +81,7 @@ class Message extends React.PureComponent {\ntextStyle = styles.blackText;\nauthorName = (\n<Text style={styles.authorName}>\n- {this.props.messageInfo.creator}\n+ {this.props.item.messageInfo.creator}\n</Text>\n);\n}\n@@ -92,7 +92,7 @@ class Message extends React.PureComponent {\n<Text\nnumberOfLines={1}\nstyle={[styles.text, textStyle]}\n- >{this.props.messageInfo.text}</Text>\n+ >{this.props.item.messageInfo.text}</Text>\n</View>\n</View>\n);\n@@ -131,8 +131,8 @@ const styles = StyleSheet.create({\n});\nexport default connect(\n- (state: AppState, ownProps: { messageInfo: MessageInfoWithHeight }) => ({\n- threadInfo: state.threadInfos[ownProps.messageInfo.threadID],\n+ (state: AppState, ownProps: { item: ChatMessageItemWithHeight }) => ({\n+ threadInfo: state.threadInfos[ownProps.item.messageInfo.threadID],\nuserID: state.userInfo && state.userInfo.id,\n}),\n)(Message);\n"
},
{
"change_type": "MODIFY",
"old_path": "native/selectors/chat-selectors.js",
"new_path": "native/selectors/chat-selectors.js",
"diff": "@@ -19,13 +19,11 @@ export type ChatThreadItem = {\nmostRecentMessageInfo?: MessageInfo,\nlastUpdatedTime: number,\n};\n-\nconst chatThreadItemPropType = PropTypes.shape({\nthreadInfo: threadInfoPropType.isRequired,\nmostRecentMessageInfo: messageInfoPropType,\nlastUpdatedTime: PropTypes.number.isRequired,\n});\n-\nconst chatListData = createSelector(\n(state: BaseAppState) => state.threadInfos,\n(state: BaseAppState) => state.messageStore,\n@@ -50,16 +48,31 @@ const chatListData = createSelector(\n)(threadInfos),\n);\n+export type ChatMessageItem = {\n+ messageInfo: MessageInfo,\n+ startsConversation: bool,\n+ startsCluster: bool,\n+};\n+const chatMessageItemPropType = PropTypes.shape({\n+ messageInfo: messageInfoPropType.isRequired,\n+ startsConversation: PropTypes.bool.isRequired,\n+ startsCluster: PropTypes.bool.isRequired,\n+});\nconst baseMessageListData = (threadID: string) => createSelector(\n(state: BaseAppState) => state.messageStore,\n- (messageStore: MessageStore): MessageInfo[] => {\n+ (messageStore: MessageStore): ChatMessageItem[] => {\nconst thread = messageStore.threads[threadID];\nif (!thread) {\nreturn [];\n}\nreturn thread.messageIDs\n.map((messageID: string) => messageStore.messages[messageID])\n- .filter(x => x);\n+ .filter(x => x)\n+ .map((messageInfo: MessageInfo) => ({\n+ messageInfo,\n+ startsConversation: false,\n+ startsCluster: false,\n+ }));\n},\n);\n@@ -68,5 +81,6 @@ const messageListData = _memoize(baseMessageListData);\nexport {\nchatThreadItemPropType,\nchatListData,\n+ chatMessageItemPropType,\nmessageListData,\n};\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Wrap MessageInfo passed to MessageList/Message in ChatMessageItem that can support additional fields |
129,187 | 07.06.2017 14:02:53 | 14,400 | 5f5bf8add3badd3c748309af78f147b08de49122 | Set messageListData to actually compute secondary info correctly, and a bugfix | [
{
"change_type": "MODIFY",
"old_path": "native/chat/message-list.react.js",
"new_path": "native/chat/message-list.react.js",
"diff": "@@ -150,6 +150,10 @@ class InnerMessageList extends React.PureComponent {\nreturn <Message item={row.item} />;\n}\n+ static keyExtractor(item: ChatMessageItemWithHeight) {\n+ return messageKey(item.messageInfo);\n+ }\n+\ngetItemLayout = (\ndata: $ReadOnlyArray<ChatMessageItemWithHeight>,\nindex: number,\n@@ -183,7 +187,7 @@ class InnerMessageList extends React.PureComponent {\ninverted={true}\ndata={listDataWithHeights}\nrenderItem={this.renderItem}\n- keyExtractor={messageKey}\n+ keyExtractor={InnerMessageList.keyExtractor}\ngetItemLayout={this.getItemLayout}\n/>\n);\n"
},
{
"change_type": "MODIFY",
"old_path": "native/selectors/chat-selectors.js",
"new_path": "native/selectors/chat-selectors.js",
"diff": "@@ -58,6 +58,7 @@ const chatMessageItemPropType = PropTypes.shape({\nstartsConversation: PropTypes.bool.isRequired,\nstartsCluster: PropTypes.bool.isRequired,\n});\n+const msInFiveMinutes = 5 * 60 * 1000;\nconst baseMessageListData = (threadID: string) => createSelector(\n(state: BaseAppState) => state.messageStore,\n(messageStore: MessageStore): ChatMessageItem[] => {\n@@ -65,14 +66,31 @@ const baseMessageListData = (threadID: string) => createSelector(\nif (!thread) {\nreturn [];\n}\n- return thread.messageIDs\n+ const messageInfos = thread.messageIDs\n.map((messageID: string) => messageStore.messages[messageID])\n- .filter(x => x)\n- .map((messageInfo: MessageInfo) => ({\n+ .filter(x => x);\n+ let chatMessageItems = [];\n+ let lastMessageInfo = null;\n+ for (let messageInfo of messageInfos) {\n+ let startsConversation = true;\n+ let startsCluster = true;\n+ if (\n+ lastMessageInfo &&\n+ lastMessageInfo.time + msInFiveMinutes > messageInfo.time\n+ ) {\n+ startsConversation = false;\n+ if (lastMessageInfo.creatorID === messageInfo.creatorID) {\n+ startsCluster = false;\n+ }\n+ }\n+ chatMessageItems.push({\nmessageInfo,\n- startsConversation: false,\n- startsCluster: false,\n- }));\n+ startsConversation,\n+ startsCluster,\n+ });\n+ lastMessageInfo = messageInfo;\n+ }\n+ return chatMessageItems;\n},\n);\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Set messageListData to actually compute secondary info correctly, and a bugfix |
129,187 | 07.06.2017 15:30:25 | 14,400 | 616731b8159b0d1472234c306e8a759728ed5724 | Set up groupings by cluster and a time bar! | [
{
"change_type": "MODIFY",
"old_path": "lib/utils/date-utils.js",
"new_path": "lib/utils/date-utils.js",
"diff": "@@ -93,6 +93,19 @@ function shortAbsoluteDate(timestamp: number) {\n}\n}\n+// Same as above, but longer\n+function longAbsoluteDate(timestamp: number) {\n+ const now = Date.now();\n+ const msSince = now - timestamp;\n+ if (msSince < millisecondsInDay) {\n+ return dateFormat(timestamp, \"h:MM tt\");\n+ } else if (msSince < millisecondsInWeek) {\n+ return dateFormat(timestamp, \"ddd h:MM tt\");\n+ } else {\n+ return dateFormat(timestamp, \"mmmm d, h:MM tt\");\n+ }\n+}\n+\nexport {\ngetDate,\npadMonthOrDay,\n@@ -104,4 +117,5 @@ export {\nprettyDate,\ndateFromString,\nshortAbsoluteDate,\n+ longAbsoluteDate,\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/message.react.js",
"new_path": "native/chat/message.react.js",
"diff": "@@ -14,6 +14,7 @@ import invariant from 'invariant';\nimport PropTypes from 'prop-types';\nimport { colorIsDark } from 'lib/selectors/thread-selectors';\n+import { longAbsoluteDate } from 'lib/utils/date-utils';\ntype Props = {\nitem: ChatMessageItemWithHeight,\n@@ -64,16 +65,23 @@ class Message extends React.PureComponent {\n}\nrender() {\n+ let conversationHeader = null;\n+ if (this.props.item.startsConversation) {\n+ conversationHeader = (\n+ <Text style={styles.conversationHeader}>\n+ {longAbsoluteDate(this.props.item.messageInfo.time).toUpperCase()}\n+ </Text>\n+ );\n+ }\n+\nconst isYou = this.props.item.messageInfo.creatorID === this.props.userID;\nlet containerStyle = null,\n- messageStyle = null,\n+ messageStyle = {},\ntextStyle = null,\nauthorName = null;\nif (isYou) {\ncontainerStyle = { alignSelf: 'flex-end' };\n- messageStyle = {\n- backgroundColor: `#${this.state.threadInfo.color}`,\n- };\n+ messageStyle.backgroundColor = `#${this.state.threadInfo.color}`;\nconst darkColor = colorIsDark(this.state.threadInfo.color);\ntextStyle = darkColor ? styles.whiteText : styles.blackText;\n} else {\n@@ -85,8 +93,20 @@ class Message extends React.PureComponent {\n</Text>\n);\n}\n+ messageStyle.borderTopRightRadius =\n+ isYou && !this.props.item.startsCluster ? 0 : 8;\n+ messageStyle.borderBottomRightRadius =\n+ isYou && !this.props.item.endsCluster ? 0 : 8;\n+ messageStyle.borderTopLeftRadius =\n+ !isYou && !this.props.item.startsCluster ? 0 : 8;\n+ messageStyle.borderBottomLeftRadius =\n+ !isYou && !this.props.item.endsCluster ? 0 : 8;\n+ messageStyle.marginBottom = this.props.item.endsCluster ? 12 : 5;\n+\nreturn (\n- <View style={[styles.container, containerStyle]}>\n+ <View>\n+ {conversationHeader}\n+ <View style={containerStyle}>\n{authorName}\n<View style={[styles.message, messageStyle]}>\n<Text\n@@ -95,12 +115,19 @@ class Message extends React.PureComponent {\n>{this.props.item.messageInfo.text}</Text>\n</View>\n</View>\n+ </View>\n);\n}\n}\nconst styles = StyleSheet.create({\n+ conversationHeader: {\n+ color: '#777777',\n+ fontSize: 14,\n+ paddingBottom: 7,\n+ alignSelf: 'center',\n+ },\ntext: {\nfontSize: 18,\nfontFamily: 'Arial',\n@@ -111,15 +138,11 @@ const styles = StyleSheet.create({\nblackText: {\ncolor: 'black',\n},\n- container: {\n- },\nmessage: {\n- borderRadius: 8,\noverflow: 'hidden',\npaddingVertical: 6,\npaddingHorizontal: 12,\nbackgroundColor: \"#DDDDDDBB\",\n- marginBottom: 12,\nmarginHorizontal: 12,\n},\nauthorName: {\n"
},
{
"change_type": "MODIFY",
"old_path": "native/selectors/chat-selectors.js",
"new_path": "native/selectors/chat-selectors.js",
"diff": "@@ -52,11 +52,13 @@ export type ChatMessageItem = {\nmessageInfo: MessageInfo,\nstartsConversation: bool,\nstartsCluster: bool,\n+ endsCluster: bool,\n};\nconst chatMessageItemPropType = PropTypes.shape({\nmessageInfo: messageInfoPropType.isRequired,\nstartsConversation: PropTypes.bool.isRequired,\nstartsCluster: PropTypes.bool.isRequired,\n+ endsCluster: PropTypes.bool.isRequired,\n});\nconst msInFiveMinutes = 5 * 60 * 1000;\nconst baseMessageListData = (threadID: string) => createSelector(\n@@ -71,7 +73,8 @@ const baseMessageListData = (threadID: string) => createSelector(\n.filter(x => x);\nlet chatMessageItems = [];\nlet lastMessageInfo = null;\n- for (let messageInfo of messageInfos) {\n+ for (let i = messageInfos.length - 1; i >= 0; i--) {\n+ const messageInfo = messageInfos[i];\nlet startsConversation = true;\nlet startsCluster = true;\nif (\n@@ -83,14 +86,21 @@ const baseMessageListData = (threadID: string) => createSelector(\nstartsCluster = false;\n}\n}\n+ if (startsCluster && chatMessageItems.length > 0) {\n+ chatMessageItems[chatMessageItems.length - 1].endsCluster = true;\n+ }\nchatMessageItems.push({\nmessageInfo,\nstartsConversation,\nstartsCluster,\n+ endsCluster: false,\n});\nlastMessageInfo = messageInfo;\n}\n- return chatMessageItems;\n+ if (chatMessageItems.length > 0) {\n+ chatMessageItems[chatMessageItems.length - 1].endsCluster = true;\n+ }\n+ return chatMessageItems.reverse();\n},\n);\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Set up groupings by cluster and a time bar! |
129,187 | 07.06.2017 16:43:10 | 14,400 | 7790d5168879cb232f1f85de66037c571c18fed9 | Update Message.itemHeight to be accurate with recent changes in Message rendering behavior | [
{
"change_type": "MODIFY",
"old_path": "native/chat/message.react.js",
"new_path": "native/chat/message.react.js",
"diff": "@@ -72,11 +72,17 @@ class Message extends React.PureComponent {\n}\nstatic itemHeight(item: ChatMessageItemWithHeight, userID: ?string) {\n- if (item.messageInfo.creatorID === userID) {\n- return 24 + item.textHeight;\n- } else {\n- return 24 + 25 + item.textHeight;\n+ let height = 17 + item.textHeight; // for padding, margin, and text\n+ if (item.messageInfo.creatorID !== userID && item.startsCluster) {\n+ height += 25; // for username\n+ }\n+ if (item.startsConversation) {\n+ height += 26; // for time bar\n+ }\n+ if (item.endsCluster) {\n+ height += 7; // extra padding at the end of a cluster\n}\n+ return height;\n}\nrender() {\n@@ -92,17 +98,19 @@ class Message extends React.PureComponent {\nconst isYou = this.props.item.messageInfo.creatorID === this.props.userID;\nlet containerStyle = null,\nmessageStyle = {},\n- textStyle = null,\n- authorName = null;\n+ textStyle = {};\nif (isYou) {\ncontainerStyle = { alignSelf: 'flex-end' };\nmessageStyle.backgroundColor = `#${this.state.threadInfo.color}`;\nconst darkColor = colorIsDark(this.state.threadInfo.color);\n- textStyle = darkColor ? styles.whiteText : styles.blackText;\n+ textStyle.color = darkColor ? 'white' : 'black';\n} else {\ncontainerStyle = { alignSelf: 'flex-start' };\nmessageStyle.backgroundColor = \"#DDDDDDBB\";\n- textStyle = styles.blackText;\n+ textStyle.color = 'black';\n+ }\n+ let authorName = null;\n+ if (!isYou && this.props.item.startsCluster) {\nauthorName = (\n<Text style={styles.authorName}>\n{this.props.item.messageInfo.creator}\n@@ -122,6 +130,7 @@ class Message extends React.PureComponent {\nmessageStyle.backgroundColor =\nColor(messageStyle.backgroundColor).darken(0.15).hex();\n}\n+ textStyle.height = this.props.item.textHeight;\nreturn (\n<View>\n@@ -160,17 +169,12 @@ const styles = StyleSheet.create({\nfontSize: 14,\npaddingBottom: 7,\nalignSelf: 'center',\n+ height: 26,\n},\ntext: {\nfontSize: 18,\nfontFamily: 'Arial',\n},\n- whiteText: {\n- color: 'white',\n- },\n- blackText: {\n- color: 'black',\n- },\nmessage: {\noverflow: 'hidden',\npaddingVertical: 6,\n@@ -182,6 +186,7 @@ const styles = StyleSheet.create({\nfontSize: 14,\npaddingHorizontal: 24,\npaddingVertical: 4,\n+ height: 25,\n},\n});\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Update Message.itemHeight to be accurate with recent changes in Message rendering behavior |
129,187 | 07.06.2017 16:53:45 | 14,400 | b0918a383d70523a4786cde27ffd19542ed4f92b | Chat items that go off screen lose focus, and add some spacing at the top of the chat | [
{
"change_type": "MODIFY",
"old_path": "native/chat/message-list.react.js",
"new_path": "native/chat/message-list.react.js",
"diff": "@@ -9,6 +9,7 @@ import type {\nimport { threadInfoPropType } from 'lib/types/thread-types';\nimport type { ChatMessageItem } from '../selectors/chat-selectors';\nimport { chatMessageItemPropType } from '../selectors/chat-selectors';\n+import type { ViewToken } from 'react-native/Libraries/Lists/ViewabilityHelper';\nimport React from 'react';\nimport { connect } from 'react-redux';\n@@ -190,6 +191,11 @@ class InnerMessageList extends React.PureComponent {\n));\n}\n+ static ListFooterComponent(props: {}) {\n+ // Actually header, it's just that our FlatList is inverted\n+ return <View style={styles.header} />;\n+ }\n+\nrender() {\nconst textHeightMeasurer = (\n<TextHeightMeasurer\n@@ -208,6 +214,8 @@ class InnerMessageList extends React.PureComponent {\nrenderItem={this.renderItem}\nkeyExtractor={InnerMessageList.keyExtractor}\ngetItemLayout={this.getItemLayout}\n+ onViewableItemsChanged={this.onViewableItemsChanged}\n+ ListFooterComponent={InnerMessageList.ListFooterComponent}\nextraData={this.state.focusedMessageKey}\n/>\n);\n@@ -256,6 +264,25 @@ class InnerMessageList extends React.PureComponent {\n}\n}\n+ onViewableItemsChanged = (info: {\n+ viewableItems: ViewToken[],\n+ changed: ViewToken[],\n+ }) => {\n+ if (!this.state.focusedMessageKey) {\n+ return;\n+ }\n+ let focusedMessageVisible = false;\n+ for (let token of info.viewableItems) {\n+ if (messageKey(token.item.messageInfo) === this.state.focusedMessageKey) {\n+ focusedMessageVisible = true;\n+ break;\n+ }\n+ }\n+ if (!focusedMessageVisible) {\n+ this.setState({ focusedMessageKey: null });\n+ }\n+ }\n+\n}\nconst styles = StyleSheet.create({\n@@ -278,6 +305,9 @@ const styles = StyleSheet.create({\nloadingIndicatorContainer: {\nflex: 1,\n},\n+ header: {\n+ height: 12,\n+ },\n});\nconst MessageListRouteName = 'MessageList';\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Chat items that go off screen lose focus, and add some spacing at the top of the chat |
129,187 | 24.06.2017 18:43:51 | 14,400 | 1a7cf34f5b2db2786f9895a4d46c3c68893a36fe | Minor bugfix for when loading pretty old state | [
{
"change_type": "MODIFY",
"old_path": "native/selectors/calendar-selectors.js",
"new_path": "native/selectors/calendar-selectors.js",
"diff": "@@ -33,13 +33,9 @@ const calendarListData = createSelector(\nloggedIn: bool,\ndaysToEntries: {[dayString: string]: EntryInfo[]},\n) => {\n- if (!loggedIn) {\n+ if (!loggedIn || daysToEntries[dateString(new Date())] === undefined) {\nreturn null;\n}\n- invariant(\n- daysToEntries[dateString(new Date())] !== undefined,\n- \"today should have an entry in currentDaysToEntries on native\",\n- );\nconst items: CalendarItem[] = [{ itemType: \"loader\", key: \"TopLoader\" }];\nfor (let dayString in daysToEntries) {\nitems.push({ itemType: \"header\", dateString: dayString });\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Minor bugfix for when loading pretty old state |
129,187 | 24.06.2017 22:06:01 | 14,400 | 4c384fd6121996929517ecf3c186f170937401ae | Uhh somehow I am able to get working now? | [
{
"change_type": "MODIFY",
"old_path": "lib/package-lock.json",
"new_path": "lib/package-lock.json",
"diff": "\"version\": \"0.0.1\",\n\"lockfileVersion\": 1,\n\"dependencies\": {\n- \"asap\": {\n- \"version\": \"2.0.5\",\n- \"resolved\": \"https://registry.npmjs.org/asap/-/asap-2.0.5.tgz\",\n- \"integrity\": \"sha1-UidltQw1EEkOUtfc/ghe+bqWlY8=\"\n- },\n\"color\": {\n\"version\": \"1.0.3\",\n\"resolved\": \"https://registry.npmjs.org/color/-/color-1.0.3.tgz\",\n"
},
{
"change_type": "MODIFY",
"old_path": "native/.flowconfig",
"new_path": "native/.flowconfig",
"diff": "@@ -47,4 +47,4 @@ suppress_comment=\\\\(.\\\\|\\n\\\\)*\\\\$FlowExpectedError\nunsafe.enable_getters_and_setters=true\n[version]\n-^0.48.0\n+^0.45.0\n"
},
{
"change_type": "MODIFY",
"old_path": "native/navigation-setup.js",
"new_path": "native/navigation-setup.js",
"diff": "@@ -126,16 +126,13 @@ const ReduxWrappedAppNavigator = connect((state: AppState) => ({\nisForeground: isForegroundSelector(state),\natInitialRoute: state.navInfo.navigationState.routes[0].index === 0,\n}))(WrappedAppNavigator);\n-const ReduxWrappedAppNavigatorWithRouter = {\n- ...ReduxWrappedAppNavigator,\n- router: AppNavigator.router,\n-};\n+ReduxWrappedAppNavigator.router = AppNavigator.router;\nconst RootNavigator = StackNavigator(\n{\n[LoggedOutModalRouteName]: { screen: LoggedOutModal },\n[VerificationModalRouteName]: { screen: VerificationModal },\n- [AppRouteName]: { screen: ReduxWrappedAppNavigatorWithRouter },\n+ [AppRouteName]: { screen: ReduxWrappedAppNavigator },\n},\n{\nheaderMode: 'none',\n"
},
{
"change_type": "MODIFY",
"old_path": "native/package-lock.json",
"new_path": "native/package-lock.json",
"diff": "\"integrity\": \"sha512-7+0Ai8r8Xt6NNVM0Eo+XSqiZsBUYXg2yrCwyBhQzSfFHTGQWzFv/pk9106vPR8HWjKmGK+zzUj244POs4xfO2g==\",\n\"dev\": true\n},\n- \"1PasswordExtension\": {\n- \"version\": \"git+https://github.com/jjshammas/onepassword-app-extension.git#acf20f71c890e92ee489fc8e7bb0f7df922e855d\"\n- },\n\"abab\": {\n\"version\": \"1.0.3\",\n\"resolved\": \"https://registry.npmjs.org/abab/-/abab-1.0.3.tgz\",\n\"ansi-escapes\": {\n\"version\": \"1.4.0\",\n\"resolved\": \"https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-1.4.0.tgz\",\n- \"integrity\": \"sha1-06ioOzGapneTZisT52HHkRQiMG4=\",\n- \"dev\": true\n+ \"integrity\": \"sha1-06ioOzGapneTZisT52HHkRQiMG4=\"\n},\n\"ansi-regex\": {\n\"version\": \"2.1.1\",\n\"dev\": true\n},\n\"babel-preset-react-native\": {\n- \"version\": \"1.9.2\",\n- \"resolved\": \"https://registry.npmjs.org/babel-preset-react-native/-/babel-preset-react-native-1.9.2.tgz\",\n- \"integrity\": \"sha1-sird0uNV/zs5Zxt5voB+Ut+hRfI=\",\n+ \"version\": \"2.0.0\",\n+ \"resolved\": \"https://registry.npmjs.org/babel-preset-react-native/-/babel-preset-react-native-2.0.0.tgz\",\n+ \"integrity\": \"sha1-wmxwZsc5nfMJJvoDwBLvh/LM5bc=\",\n\"dev\": true\n},\n\"babel-register\": {\n\"dev\": true\n},\n\"cli-cursor\": {\n- \"version\": \"2.1.0\",\n- \"resolved\": \"https://registry.npmjs.org/cli-cursor/-/cli-cursor-2.1.0.tgz\",\n- \"integrity\": \"sha1-s12sN2R5+sw+lHR9QdDQ9SOP/LU=\"\n+ \"version\": \"1.0.2\",\n+ \"resolved\": \"https://registry.npmjs.org/cli-cursor/-/cli-cursor-1.0.2.tgz\",\n+ \"integrity\": \"sha1-ZNo/fValRBLll5S9Ytw1KV6PKYc=\"\n},\n\"cli-width\": {\n\"version\": \"2.1.0\",\n\"integrity\": \"sha1-TrZGejaglfq7KXD/nV4/t7zm68M=\",\n\"dev\": true\n},\n+ \"exit-hook\": {\n+ \"version\": \"1.1.1\",\n+ \"resolved\": \"https://registry.npmjs.org/exit-hook/-/exit-hook-1.1.1.tgz\",\n+ \"integrity\": \"sha1-8FyiM7SMBdVP/wd2XfhQfpXAL/g=\"\n+ },\n\"expand-brackets\": {\n\"version\": \"0.1.5\",\n\"resolved\": \"https://registry.npmjs.org/expand-brackets/-/expand-brackets-0.1.5.tgz\",\n\"resolved\": \"https://registry.npmjs.org/extend/-/extend-3.0.1.tgz\",\n\"integrity\": \"sha1-p1Xqe8Gt/MWjHOfnYtuq3F5jZEQ=\"\n},\n- \"external-editor\": {\n- \"version\": \"2.0.4\",\n- \"resolved\": \"https://registry.npmjs.org/external-editor/-/external-editor-2.0.4.tgz\",\n- \"integrity\": \"sha1-HtkZnanL/i7y96MbL96LDRI2iXI=\"\n- },\n\"extglob\": {\n\"version\": \"0.3.2\",\n\"resolved\": \"https://registry.npmjs.org/extglob/-/extglob-0.3.2.tgz\",\n\"dev\": true\n},\n\"figures\": {\n- \"version\": \"2.0.0\",\n- \"resolved\": \"https://registry.npmjs.org/figures/-/figures-2.0.0.tgz\",\n- \"integrity\": \"sha1-OrGi0qYsi/tDGgyUy3l6L84nyWI=\"\n+ \"version\": \"1.7.0\",\n+ \"resolved\": \"https://registry.npmjs.org/figures/-/figures-1.7.0.tgz\",\n+ \"integrity\": \"sha1-y+Hjr/zxzUS4DK3+0o3Hk6lwHS4=\"\n},\n\"filename-regex\": {\n\"version\": \"2.0.1\",\n\"integrity\": \"sha1-ay6YIrGizgpgq2TWEOzK1TyyTQ8=\"\n},\n\"flow-bin\": {\n- \"version\": \"0.48.0\",\n- \"resolved\": \"https://registry.npmjs.org/flow-bin/-/flow-bin-0.48.0.tgz\",\n- \"integrity\": \"sha1-ctB1FDUkNY24kBUl48eE3BOnx+4=\",\n+ \"version\": \"0.45.0\",\n+ \"resolved\": \"https://registry.npmjs.org/flow-bin/-/flow-bin-0.45.0.tgz\",\n+ \"integrity\": \"sha1-AJ3Q9Xej9mXHTKi+gnrowt2P1rU=\",\n\"dev\": true\n},\n\"for-in\": {\n\"dev\": true\n},\n\"inquirer\": {\n- \"version\": \"3.1.1\",\n- \"resolved\": \"https://registry.npmjs.org/inquirer/-/inquirer-3.1.1.tgz\",\n- \"integrity\": \"sha512-H50sHQwgvvaTBd3HpKMVtL/u6LoHDvYym51gd7bGQe/+9HkCE+J0/3N5FJLfd6O6oz44hHewC2Pc2LodzWVafQ==\",\n- \"dependencies\": {\n- \"ansi-escapes\": {\n- \"version\": \"2.0.0\",\n- \"resolved\": \"https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-2.0.0.tgz\",\n- \"integrity\": \"sha1-W65SvkJIeN2Xg+iRDj/Cki6DyBs=\"\n- },\n- \"is-fullwidth-code-point\": {\n- \"version\": \"2.0.0\",\n- \"resolved\": \"https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz\",\n- \"integrity\": \"sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=\"\n- },\n- \"rx-lite\": {\n- \"version\": \"4.0.8\",\n- \"resolved\": \"https://registry.npmjs.org/rx-lite/-/rx-lite-4.0.8.tgz\",\n- \"integrity\": \"sha1-Cx4Rr4vESDbwSmQH6S2kJGe3lEQ=\"\n- },\n- \"string-width\": {\n- \"version\": \"2.0.0\",\n- \"resolved\": \"https://registry.npmjs.org/string-width/-/string-width-2.0.0.tgz\",\n- \"integrity\": \"sha1-Y1xUNsxypuDDh87KJ41OLuxSaH4=\"\n- }\n- }\n+ \"version\": \"0.12.0\",\n+ \"resolved\": \"https://registry.npmjs.org/inquirer/-/inquirer-0.12.0.tgz\",\n+ \"integrity\": \"sha1-HvK/1jUE3wvHV4X/+MLEHfEvB34=\"\n},\n\"invariant\": {\n\"version\": \"2.2.2\",\n\"resolved\": \"https://registry.npmjs.org/is-primitive/-/is-primitive-2.0.0.tgz\",\n\"integrity\": \"sha1-IHurkWOEmcB7Kt8kCkGochADRXU=\"\n},\n- \"is-promise\": {\n- \"version\": \"2.1.0\",\n- \"resolved\": \"https://registry.npmjs.org/is-promise/-/is-promise-2.1.0.tgz\",\n- \"integrity\": \"sha1-eaKp7OfwlugPNtKy87wWwf9L8/o=\"\n- },\n\"is-redirect\": {\n\"version\": \"1.0.0\",\n\"resolved\": \"https://registry.npmjs.org/is-redirect/-/is-redirect-1.0.0.tgz\",\n\"resolved\": \"https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz\",\n\"integrity\": \"sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=\"\n},\n+ \"isemail\": {\n+ \"version\": \"1.2.0\",\n+ \"resolved\": \"https://registry.npmjs.org/isemail/-/isemail-1.2.0.tgz\",\n+ \"integrity\": \"sha1-vgPfjMPineTSxd9lASY/H6RZXpo=\"\n+ },\n\"isexe\": {\n\"version\": \"2.0.0\",\n\"resolved\": \"https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz\",\n}\n}\n},\n+ \"joi\": {\n+ \"version\": \"6.10.1\",\n+ \"resolved\": \"https://registry.npmjs.org/joi/-/joi-6.10.1.tgz\",\n+ \"integrity\": \"sha1-TVDDGAeRIgAP5fFq8f+OGRe3fgY=\"\n+ },\n\"js-tokens\": {\n\"version\": \"3.0.1\",\n\"resolved\": \"https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.1.tgz\",\n\"integrity\": \"sha1-peZUwuWi3rXyAdls77yoDA7y9RM=\",\n\"optional\": true\n},\n- \"jschardet\": {\n- \"version\": \"1.4.2\",\n- \"resolved\": \"https://registry.npmjs.org/jschardet/-/jschardet-1.4.2.tgz\",\n- \"integrity\": \"sha1-KqEH8UKvQSHRRWWdRPUIMJYeaZo=\"\n- },\n\"jsdom\": {\n\"version\": \"9.12.0\",\n\"resolved\": \"https://registry.npmjs.org/jsdom/-/jsdom-9.12.0.tgz\",\n\"dependencies\": {\n\"lodash\": {\n\"version\": \"3.10.1\",\n- \"resolved\": \"https://registry.npmjs.org/lodash/-/lodash-3.10.1.tgz\",\n- \"integrity\": \"sha1-W/Rejkm6QYnhfUgnid/RW9FAt7Y=\"\n+ \"bundled\": true\n}\n}\n},\n}\n}\n},\n- \"mimic-fn\": {\n- \"version\": \"1.1.0\",\n- \"resolved\": \"https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.1.0.tgz\",\n- \"integrity\": \"sha1-5md4PZLonb00KBi1IwudYqZyrRg=\"\n- },\n\"min-document\": {\n\"version\": \"2.19.0\",\n\"resolved\": \"https://registry.npmjs.org/min-document/-/min-document-2.19.0.tgz\",\n}\n}\n},\n+ \"moment\": {\n+ \"version\": \"2.18.1\",\n+ \"resolved\": \"https://registry.npmjs.org/moment/-/moment-2.18.1.tgz\",\n+ \"integrity\": \"sha1-w2GT3Tzhwu7SrbfIAtu8d6gbHA8=\"\n+ },\n\"morgan\": {\n\"version\": \"1.6.1\",\n\"resolved\": \"https://registry.npmjs.org/morgan/-/morgan-1.6.1.tgz\",\n\"integrity\": \"sha1-Ko8t33Du1WTf8tV/HhoTfZ8FB4s=\"\n},\n\"mute-stream\": {\n- \"version\": \"0.0.7\",\n- \"resolved\": \"https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.7.tgz\",\n- \"integrity\": \"sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s=\"\n+ \"version\": \"0.0.5\",\n+ \"resolved\": \"https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.5.tgz\",\n+ \"integrity\": \"sha1-j7+rsKmKJT0xhDMfno3rc3L6xsA=\"\n},\n\"natural-compare\": {\n\"version\": \"1.4.0\",\n\"integrity\": \"sha1-WDsap3WWHUsROsF9nFC6753Xa9E=\"\n},\n\"onetime\": {\n- \"version\": \"2.0.1\",\n- \"resolved\": \"https://registry.npmjs.org/onetime/-/onetime-2.0.1.tgz\",\n- \"integrity\": \"sha1-BnQoIw/WdEOyeUsiu6UotoZ5YtQ=\"\n+ \"version\": \"1.1.0\",\n+ \"resolved\": \"https://registry.npmjs.org/onetime/-/onetime-1.1.0.tgz\",\n+ \"integrity\": \"sha1-ofeDj4MUxRbwXs78vEzP4EtO14k=\"\n},\n\"opn\": {\n\"version\": \"3.0.3\",\n\"dev\": true\n},\n\"react\": {\n- \"version\": \"16.0.0-alpha.13\",\n- \"resolved\": \"https://registry.npmjs.org/react/-/react-16.0.0-alpha.13.tgz\",\n- \"integrity\": \"sha1-3jfgNbBig6Fc+5FsaUO5sGayXeA=\"\n+ \"version\": \"16.0.0-alpha.12\",\n+ \"resolved\": \"https://registry.npmjs.org/react/-/react-16.0.0-alpha.12.tgz\",\n+ \"integrity\": \"sha1-jFlIUoFIXfMZtvd2gtjdBiHAgZQ=\"\n},\n\"react-clone-referenced-element\": {\n\"version\": \"1.0.1\",\n\"version\": \"2.3.3\",\n\"resolved\": \"https://registry.npmjs.org/react-devtools-core/-/react-devtools-core-2.3.3.tgz\",\n\"integrity\": \"sha1-OpUObyDyyOZ9BBnkKMhQDn2L80c=\",\n- \"dev\": true,\n\"dependencies\": {\n\"safe-buffer\": {\n\"version\": \"5.0.1\",\n\"resolved\": \"https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.0.1.tgz\",\n- \"integrity\": \"sha1-0mPKVGls2KMGtcplUekt5XkY++c=\",\n- \"dev\": true\n+ \"integrity\": \"sha1-0mPKVGls2KMGtcplUekt5XkY++c=\"\n},\n\"ws\": {\n\"version\": \"2.3.1\",\n\"resolved\": \"https://registry.npmjs.org/ws/-/ws-2.3.1.tgz\",\n- \"integrity\": \"sha1-a5Sz5EfLajY/eF6vlK9jWejoHIA=\",\n- \"dev\": true\n+ \"integrity\": \"sha1-a5Sz5EfLajY/eF6vlK9jWejoHIA=\"\n}\n}\n},\n\"react-native\": {\n- \"version\": \"git+https://git@github.com/facebook/react-native.git#1faf40b02acb9f3bf4b264a879e5199fd517e983\",\n+ \"version\": \"0.45.1\",\n+ \"resolved\": \"https://registry.npmjs.org/react-native/-/react-native-0.45.1.tgz\",\n+ \"integrity\": \"sha1-syg8SogjNCH5xmKi/xpMzIqfB8A=\",\n\"dependencies\": {\n\"babel-preset-react-native\": {\n- \"version\": \"2.0.0\",\n- \"resolved\": \"https://registry.npmjs.org/babel-preset-react-native/-/babel-preset-react-native-2.0.0.tgz\",\n- \"integrity\": \"sha1-wmxwZsc5nfMJJvoDwBLvh/LM5bc=\"\n+ \"version\": \"1.9.2\",\n+ \"resolved\": \"https://registry.npmjs.org/babel-preset-react-native/-/babel-preset-react-native-1.9.2.tgz\",\n+ \"integrity\": \"sha1-sird0uNV/zs5Zxt5voB+Ut+hRfI=\"\n},\n\"core-js\": {\n\"version\": \"2.4.1\",\n\"resolved\": \"https://registry.npmjs.org/core-js/-/core-js-2.4.1.tgz\",\n\"integrity\": \"sha1-TekR5mew6ukSTjQlS1OupvxhjT4=\"\n},\n- \"metro-bundler\": {\n- \"version\": \"0.9.0\",\n- \"resolved\": \"https://registry.npmjs.org/metro-bundler/-/metro-bundler-0.9.0.tgz\",\n- \"integrity\": \"sha512-BW8RD1jXDtqv0KUbT7aWJ0Y7LCz09BG+rWuKu1zPLtIh0y52WZ4lryIzK3H/8FLAKqs6iZYms+YeDRFSY2TyGQ==\",\n- \"dependencies\": {\n- \"babel-preset-react-native\": {\n- \"version\": \"1.9.2\",\n- \"resolved\": \"https://registry.npmjs.org/babel-preset-react-native/-/babel-preset-react-native-1.9.2.tgz\",\n- \"integrity\": \"sha1-sird0uNV/zs5Zxt5voB+Ut+hRfI=\"\n- }\n- }\n- },\n- \"react-devtools-core\": {\n- \"version\": \"2.3.1\",\n- \"resolved\": \"https://registry.npmjs.org/react-devtools-core/-/react-devtools-core-2.3.1.tgz\",\n- \"integrity\": \"sha1-3IOrqFc17/5eHcOGoWFMtejQBH0=\",\n- \"dependencies\": {\n- \"ws\": {\n- \"version\": \"2.3.1\",\n- \"resolved\": \"https://registry.npmjs.org/ws/-/ws-2.3.1.tgz\",\n- \"integrity\": \"sha1-a5Sz5EfLajY/eF6vlK9jWejoHIA=\"\n- }\n- }\n- },\n- \"safe-buffer\": {\n- \"version\": \"5.0.1\",\n- \"resolved\": \"https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.0.1.tgz\",\n- \"integrity\": \"sha1-0mPKVGls2KMGtcplUekt5XkY++c=\"\n- },\n\"whatwg-fetch\": {\n\"version\": \"1.1.1\",\n\"resolved\": \"https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-1.1.1.tgz\",\n\"resolved\": \"https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.2.tgz\",\n\"integrity\": \"sha1-WgTfBeT1f+Pw3Gj90R3FyXx+b00=\"\n},\n+ \"readline2\": {\n+ \"version\": \"1.0.1\",\n+ \"resolved\": \"https://registry.npmjs.org/readline2/-/readline2-1.0.1.tgz\",\n+ \"integrity\": \"sha1-QQWWCP/BVHV7cV2ZidGZ/783LjU=\"\n+ },\n\"rebound\": {\n\"version\": \"0.0.13\",\n\"resolved\": \"https://registry.npmjs.org/rebound/-/rebound-0.0.13.tgz\",\n}\n},\n\"restore-cursor\": {\n- \"version\": \"2.0.0\",\n- \"resolved\": \"https://registry.npmjs.org/restore-cursor/-/restore-cursor-2.0.0.tgz\",\n- \"integrity\": \"sha1-n37ih/gv0ybU/RYpI9YhKe7g368=\"\n+ \"version\": \"1.0.1\",\n+ \"resolved\": \"https://registry.npmjs.org/restore-cursor/-/restore-cursor-1.0.1.tgz\",\n+ \"integrity\": \"sha1-NGYfRohjJ/7SmRR5FSJS35LapUE=\"\n},\n\"right-align\": {\n\"version\": \"0.1.3\",\n\"integrity\": \"sha1-8z/pz7Urv9UgqhgyO8ZdsRCht2w=\"\n},\n\"run-async\": {\n- \"version\": \"2.3.0\",\n- \"resolved\": \"https://registry.npmjs.org/run-async/-/run-async-2.3.0.tgz\",\n- \"integrity\": \"sha1-A3GrSuC91yDUFm19/aZP96RFpsA=\"\n+ \"version\": \"0.1.0\",\n+ \"resolved\": \"https://registry.npmjs.org/run-async/-/run-async-0.1.0.tgz\",\n+ \"integrity\": \"sha1-yK1KXhEGYeQCp9IbUw4AnyX444k=\"\n},\n\"rx-lite\": {\n\"version\": \"3.1.2\",\n\"resolved\": \"https://registry.npmjs.org/rx-lite/-/rx-lite-3.1.2.tgz\",\n\"integrity\": \"sha1-Gc5QLKVyZl87ZHsQk5+X/RYV8QI=\"\n},\n- \"rx-lite-aggregates\": {\n- \"version\": \"4.0.8\",\n- \"resolved\": \"https://registry.npmjs.org/rx-lite-aggregates/-/rx-lite-aggregates-4.0.8.tgz\",\n- \"integrity\": \"sha1-dTuHqJoRyVRnxKwWJsTvxOBcZ74=\"\n- },\n\"safe-buffer\": {\n\"version\": \"5.1.1\",\n\"resolved\": \"https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz\",\n\"signal-exit\": {\n\"version\": \"3.0.2\",\n\"resolved\": \"https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz\",\n- \"integrity\": \"sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=\"\n+ \"integrity\": \"sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=\",\n+ \"dev\": true\n},\n\"simple-plist\": {\n\"version\": \"0.2.1\",\n\"integrity\": \"sha1-8y6srFoXW+ol1/q1Zas+2HQe9W8=\",\n\"dev\": true\n},\n- \"tmp\": {\n- \"version\": \"0.0.31\",\n- \"resolved\": \"https://registry.npmjs.org/tmp/-/tmp-0.0.31.tgz\",\n- \"integrity\": \"sha1-jzirlDjhcxXl29izZX6L+yd65Kc=\"\n- },\n\"tmpl\": {\n\"version\": \"1.0.4\",\n\"resolved\": \"https://registry.npmjs.org/tmpl/-/tmpl-1.0.4.tgz\",\n\"resolved\": \"https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-1.0.3.tgz\",\n\"integrity\": \"sha1-uDVx+k2MJbguIxsG46MFXeTKGkc=\"\n},\n+ \"topo\": {\n+ \"version\": \"1.1.0\",\n+ \"resolved\": \"https://registry.npmjs.org/topo/-/topo-1.1.0.tgz\",\n+ \"integrity\": \"sha1-6ddRYV0buH3IZdsYL6HKCl71NtU=\"\n+ },\n\"tough-cookie\": {\n\"version\": \"2.3.2\",\n\"resolved\": \"https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.2.tgz\",\n"
},
{
"change_type": "MODIFY",
"old_path": "native/package.json",
"new_path": "native/package.json",
"diff": "\"invariant\": \"^2.2.2\",\n\"lib\": \"file:../lib\",\n\"react\": \"^16.0.0-alpha.12\",\n- \"react-native\": \"git+https://git@github.com/facebook/react-native.git\",\n+ \"react-native\": \"^0.45.1\",\n\"react-native-cookies\": \"^3.1.0\",\n\"react-native-invertible-flat-list\": \"^1.1.0\",\n\"react-native-keychain\": \"^1.2.0\",\n\"redux-persist\": \"^4.8.1\",\n\"redux-thunk\": \"^2.2.0\",\n\"reselect\": \"^3.0.1\",\n- \"shallowequal\": \"^1.0.1\",\n+ \"shallowequal\": \"^0.2.2\",\n\"url-parse\": \"^1.1.9\"\n},\n\"devDependencies\": {\n\"babel-jest\": \"20.0.3\",\n\"babel-plugin-transform-remove-console\": \"^6.8.4\",\n\"babel-preset-react-native\": \"2.0.0\",\n- \"flow-bin\": \"^0.48.0\",\n+ \"flow-bin\": \"^0.45.0\",\n\"jest\": \"^20.0.4\",\n\"react-devtools\": \"^2.3.3\",\n\"react-test-renderer\": \"^15.6.1\",\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Uhh somehow I am able to get RN@0.45.1 working now? |
129,187 | 26.06.2017 11:43:14 | 14,400 | 597235bed9a2fb592dd93b379ff7d33a5ee1c6ef | AddThreadButton on native | [
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/chat/add-thread-button.react.js",
"diff": "+// @flow\n+\n+import React from 'react';\n+import { Platform, StyleSheet, TouchableOpacity } from 'react-native';\n+import Icon from 'react-native-vector-icons/Ionicons';\n+\n+class AddThreadButton extends React.PureComponent {\n+\n+ render() {\n+ let icon;\n+ if (Platform.OS === \"ios\") {\n+ icon = (\n+ <Icon\n+ name=\"ios-add\"\n+ size={36}\n+ style={styles.addButton}\n+ color=\"#0077CC\"\n+ />\n+ );\n+ } else {\n+ icon = (\n+ <Icon\n+ name=\"md-add\"\n+ size={36}\n+ style={styles.addButton}\n+ color=\"#0077CC\"\n+ />\n+ );\n+ }\n+ return (\n+ <TouchableOpacity\n+ onPress={this.onPress}\n+ activeOpacity={0.4}\n+ >\n+ {icon}\n+ </TouchableOpacity>\n+ );\n+ }\n+\n+ onPress = () => {\n+ }\n+\n+}\n+\n+const styles = StyleSheet.create({\n+ addButton: {\n+ paddingRight: 10,\n+ },\n+});\n+\n+export default AddThreadButton;\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/chat-thread-list.react.js",
"new_path": "native/chat/chat-thread-list.react.js",
"diff": "@@ -20,6 +20,7 @@ import _sum from 'lodash/fp/sum';\nimport { chatListData } from '../selectors/chat-selectors';\nimport ChatThreadListItem from './chat-thread-list-item.react';\nimport { MessageListRouteName } from './message-list.react';\n+import AddThreadButton from './add-thread-button.react';\nclass InnerChatThreadList extends React.PureComponent {\n@@ -38,6 +39,7 @@ class InnerChatThreadList extends React.PureComponent {\n};\nstatic navigationOptions = {\ntitle: 'Threads',\n+ headerRight: <AddThreadButton />,\n};\nrenderItem = (row: { item: ChatThreadItem }) => {\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/message-list.react.js",
"new_path": "native/chat/message-list.react.js",
"diff": "@@ -34,12 +34,6 @@ import _difference from 'lodash/fp/difference';\nimport _find from 'lodash/fp/find';\nimport { messageKey } from 'lib/shared/message-utils';\n-\n-import { messageListData } from '../selectors/chat-selectors';\n-import { Message, messageItemHeight } from './message.react';\n-import TextHeightMeasurer from '../text-height-measurer.react';\n-import InputBar from './input-bar.react';\n-import ListLoadingIndicator from '../list-loading-indicator.react';\nimport {\nincludeDispatchActionProps,\nbindServerCalls,\n@@ -49,6 +43,13 @@ import {\nfetchMessages,\n} from 'lib/actions/message-actions';\n+import { messageListData } from '../selectors/chat-selectors';\n+import { Message, messageItemHeight } from './message.react';\n+import TextHeightMeasurer from '../text-height-measurer.react';\n+import InputBar from './input-bar.react';\n+import ListLoadingIndicator from '../list-loading-indicator.react';\n+import AddThreadButton from './add-thread-button.react';\n+\ntype NavProp = NavigationScreenProp<NavigationRoute, NavigationAction>;\nexport type ChatMessageInfoItemWithHeight = {\n@@ -102,6 +103,7 @@ class InnerMessageList extends React.PureComponent {\n};\nstatic navigationOptions = ({ navigation }) => ({\ntitle: navigation.state.params.threadInfo.name,\n+ headerRight: <AddThreadButton />,\n});\ntextHeights: ?{ [text: string]: number } = null;\nloadingFromScroll = false;\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | AddThreadButton on native |
129,187 | 26.06.2017 17:21:49 | 14,400 | c03abf10e19c6fe6b7f4225192f0bfb40202bdcf | Forgot this one from the last commit... | [
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/chat/message-preview.react.js",
"diff": "+// @flow\n+\n+import type { AppState } from '../redux-setup';\n+import type { MessageInfo } from 'lib/types/message-types';\n+import { messageInfoPropType } from 'lib/types/message-types';\n+\n+import React from 'react';\n+import PropTypes from 'prop-types';\n+import { connect } from 'react-redux';\n+import { StyleSheet, Text } from 'react-native';\n+\n+import { messageType } from 'lib/types/message-types';\n+\n+class MessagePreview extends React.PureComponent {\n+\n+ props: {\n+ messageInfo: MessageInfo,\n+ // Redux state\n+ userID: ?string,\n+ };\n+ static propTypes = {\n+ messageInfo: messageInfoPropType.isRequired,\n+ userID: PropTypes.string,\n+ };\n+\n+ render() {\n+ const messageInfo = this.props.messageInfo;\n+ const username = messageInfo.creatorID === this.props.userID\n+ ? \"you: \"\n+ : `${messageInfo.creator || \"\"}: `;\n+ if (messageInfo.type === messageType.TEXT) {\n+ return (\n+ <Text style={styles.lastMessage} numberOfLines={1}>\n+ <Text style={styles.username}>{username}</Text>\n+ {messageInfo.text}\n+ </Text>\n+ );\n+ } else {\n+ // TODO actually handle all cases\n+ return (\n+ <Text style={styles.lastMessage} numberOfLines={1}>\n+ Test\n+ </Text>\n+ );\n+ }\n+ }\n+\n+}\n+\n+const styles = StyleSheet.create({\n+ lastMessage: {\n+ paddingLeft: 10,\n+ fontSize: 16,\n+ color: '#666666',\n+ },\n+ username: {\n+ color: '#AAAAAA',\n+ },\n+});\n+\n+export default connect((state: AppState) => ({\n+ userID: state.userInfo && state.userInfo.id,\n+}))(MessagePreview);\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Forgot this one from the last commit... |
129,187 | 26.06.2017 17:39:51 | 14,400 | c40153696204b1a5925ee14bee5c97a564d76a22 | Relinked things | [
{
"change_type": "MODIFY",
"old_path": "native/android/app/src/main/assets/fonts/MaterialCommunityIcons.ttf",
"new_path": "native/android/app/src/main/assets/fonts/MaterialCommunityIcons.ttf",
"diff": "Binary files a/native/android/app/src/main/assets/fonts/MaterialCommunityIcons.ttf and b/native/android/app/src/main/assets/fonts/MaterialCommunityIcons.ttf differ\n"
},
{
"change_type": "MODIFY",
"old_path": "native/ios/SquadCal.xcodeproj/project.pbxproj",
"new_path": "native/ios/SquadCal.xcodeproj/project.pbxproj",
"diff": "2D02E4BC1E0B4A80006451C7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB01A68108700A75B9A /* AppDelegate.m */; };\n2D02E4BD1E0B4A84006451C7 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; };\n2D02E4BF1E0B4AB3006451C7 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; };\n- 2D02E4C21E0B4AEC006451C7 /* libRCTAnimation-tvOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5E9157351DD0AC6500FF2AA8 /* libRCTAnimation-tvOS.a */; };\n+ 2D02E4C21E0B4AEC006451C7 /* libRCTAnimation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5E9157351DD0AC6500FF2AA8 /* libRCTAnimation.a */; };\n2D02E4C31E0B4AEC006451C7 /* libRCTImage-tvOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3DAD3E841DF850E9000B6D8A /* libRCTImage-tvOS.a */; };\n2D02E4C41E0B4AEC006451C7 /* libRCTLinking-tvOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3DAD3E881DF850E9000B6D8A /* libRCTLinking-tvOS.a */; };\n2D02E4C51E0B4AEC006451C7 /* libRCTNetwork-tvOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3DAD3E8C1DF850E9000B6D8A /* libRCTNetwork-tvOS.a */; };\n2D02E4C91E0B4AEC006451C7 /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3DAD3EA31DF850E9000B6D8A /* libReact.a */; };\n2DCD954D1E0B4F2C00145EB5 /* SquadCalTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 00E356F21AD99517003FC87E /* SquadCalTests.m */; };\n2E5ADC2BAEA24F1AAD81E147 /* Zocial.ttf in Resources */ = {isa = PBXBuildFile; fileRef = EBD8879422144B0188A8336F /* Zocial.ttf */; };\n- 3ACC3CE62D76452D871EE584 /* libOnePassword.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 45E5772A9A1B46B9B488B032 /* libOnePassword.a */; };\n569C48070423498795574595 /* EvilIcons.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 3430816A291640AEACA13234 /* EvilIcons.ttf */; };\n5E9157361DD0AC6A00FF2AA8 /* libRCTAnimation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5E9157331DD0AC6500FF2AA8 /* libRCTAnimation.a */; };\n781ED432789E4AFC93FA578A /* Entypo.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 1E94F1BD692B4E6EBE1BFBFB /* Entypo.ttf */; };\n7E350429243446AAA3856078 /* MaterialCommunityIcons.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 8D919BA72D8545CBBBF6B74F /* MaterialCommunityIcons.ttf */; };\n+ 7F033BB61F01B5E400700D63 /* libOnePassword.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7FB58AD41E80C21000B4C1B1 /* libOnePassword.a */; };\n7FB58ABE1E7F6BD500B4C1B1 /* Anaheim-Regular.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 7FB58ABB1E7F6BC600B4C1B1 /* Anaheim-Regular.ttf */; };\n7FB58ABF1E7F6BD600B4C1B1 /* Anaheim-Regular.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 7FB58ABB1E7F6BC600B4C1B1 /* Anaheim-Regular.ttf */; };\n7FB58AC01E7F6BD800B4C1B1 /* OpenSans-Regular.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 7FB58ABC1E7F6BC600B4C1B1 /* OpenSans-Regular.ttf */; };\nremoteGlobalIDString = 134814201AA4EA6300B7C361;\nremoteInfo = RCTLinking;\n};\n+ 7F033BAF1F01B5E100700D63 /* PBXContainerItemProxy */ = {\n+ isa = PBXContainerItemProxy;\n+ containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */;\n+ proxyType = 2;\n+ remoteGlobalIDString = 139D7ECE1E25DB7D00323FB7;\n+ remoteInfo = \"third-party\";\n+ };\n+ 7F033BB11F01B5E100700D63 /* PBXContainerItemProxy */ = {\n+ isa = PBXContainerItemProxy;\n+ containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */;\n+ proxyType = 2;\n+ remoteGlobalIDString = 139D7E881E25C6D100323FB7;\n+ remoteInfo = \"double-conversion\";\n+ };\n7F9636351E9820C10068E9B6 /* PBXContainerItemProxy */ = {\nisa = PBXContainerItemProxy;\ncontainerPortal = 322DB7445CF14220B93E01D2 /* RNCookieManagerIOS.xcodeproj */;\n322DB7445CF14220B93E01D2 /* RNCookieManagerIOS.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = \"wrapper.pb-project\"; name = RNCookieManagerIOS.xcodeproj; path = \"../node_modules/react-native-cookies/RNCookieManagerIOS.xcodeproj\"; sourceTree = \"<group>\"; };\n3430816A291640AEACA13234 /* EvilIcons.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = EvilIcons.ttf; path = \"../node_modules/react-native-vector-icons/Fonts/EvilIcons.ttf\"; sourceTree = \"<group>\"; };\n414381A5DC394FE6BF2D28F3 /* libRNVectorIcons.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRNVectorIcons.a; sourceTree = \"<group>\"; };\n- 45E5772A9A1B46B9B488B032 /* libOnePassword.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libOnePassword.a; sourceTree = \"<group>\"; };\n4AB1FC0EFD3A4ED1A082E32F /* FontAwesome.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = FontAwesome.ttf; path = \"../node_modules/react-native-vector-icons/Fonts/FontAwesome.ttf\"; sourceTree = \"<group>\"; };\n4ACC468F28D944F293B91ACC /* Ionicons.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = Ionicons.ttf; path = \"../node_modules/react-native-vector-icons/Fonts/Ionicons.ttf\"; sourceTree = \"<group>\"; };\n5E91572D1DD0AC6500FF2AA8 /* RCTAnimation.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = \"wrapper.pb-project\"; name = RCTAnimation.xcodeproj; path = \"../node_modules/react-native/Libraries/NativeAnimation/RCTAnimation.xcodeproj\"; sourceTree = \"<group>\"; };\n00C302EA1ABCBA2D00DB3ED1 /* libRCTVibration.a in Frameworks */,\n139FDEF61B0652A700C62182 /* libRCTWebSocket.a in Frameworks */,\n98856FAEFDD5420882A5C010 /* libRNVectorIcons.a in Frameworks */,\n- 3ACC3CE62D76452D871EE584 /* libOnePassword.a in Frameworks */,\nA1F391C5F8A84FB28AEA9876 /* libRNKeychain.a in Frameworks */,\nF2F6CEBA0FA0436A84C54751 /* libRNCookieManagerIOS.a in Frameworks */,\n+ 7F033BB61F01B5E400700D63 /* libOnePassword.a in Frameworks */,\n);\nrunOnlyForDeploymentPostprocessing = 0;\n};\nbuildActionMask = 2147483647;\nfiles = (\n2D02E4C91E0B4AEC006451C7 /* libReact.a in Frameworks */,\n- 2D02E4C21E0B4AEC006451C7 /* libRCTAnimation-tvOS.a in Frameworks */,\n+ 2D02E4C21E0B4AEC006451C7 /* libRCTAnimation.a in Frameworks */,\n2D02E4C31E0B4AEC006451C7 /* libRCTImage-tvOS.a in Frameworks */,\n2D02E4C41E0B4AEC006451C7 /* libRCTLinking-tvOS.a in Frameworks */,\n2D02E4C51E0B4AEC006451C7 /* libRCTNetwork-tvOS.a in Frameworks */,\n3DAD3EAB1DF850E9000B6D8A /* libcxxreact.a */,\n3DAD3EAD1DF850E9000B6D8A /* libjschelpers.a */,\n3DAD3EAF1DF850E9000B6D8A /* libjschelpers.a */,\n+ 7F033BB01F01B5E100700D63 /* libthird-party.a */,\n+ 7F033BB21F01B5E100700D63 /* libdouble-conversion.a */,\n);\nname = Products;\nsourceTree = \"<group>\";\nisa = PBXGroup;\nchildren = (\n5E9157331DD0AC6500FF2AA8 /* libRCTAnimation.a */,\n- 5E9157351DD0AC6500FF2AA8 /* libRCTAnimation-tvOS.a */,\n+ 5E9157351DD0AC6500FF2AA8 /* libRCTAnimation.a */,\n);\nname = Products;\nsourceTree = \"<group>\";\nremoteRef = 5E9157321DD0AC6500FF2AA8 /* PBXContainerItemProxy */;\nsourceTree = BUILT_PRODUCTS_DIR;\n};\n- 5E9157351DD0AC6500FF2AA8 /* libRCTAnimation-tvOS.a */ = {\n+ 5E9157351DD0AC6500FF2AA8 /* libRCTAnimation.a */ = {\nisa = PBXReferenceProxy;\nfileType = archive.ar;\n- path = \"libRCTAnimation-tvOS.a\";\n+ path = libRCTAnimation.a;\nremoteRef = 5E9157341DD0AC6500FF2AA8 /* PBXContainerItemProxy */;\nsourceTree = BUILT_PRODUCTS_DIR;\n};\nremoteRef = 78C398B81ACF4ADC00677621 /* PBXContainerItemProxy */;\nsourceTree = BUILT_PRODUCTS_DIR;\n};\n+ 7F033BB01F01B5E100700D63 /* libthird-party.a */ = {\n+ isa = PBXReferenceProxy;\n+ fileType = archive.ar;\n+ path = \"libthird-party.a\";\n+ remoteRef = 7F033BAF1F01B5E100700D63 /* PBXContainerItemProxy */;\n+ sourceTree = BUILT_PRODUCTS_DIR;\n+ };\n+ 7F033BB21F01B5E100700D63 /* libdouble-conversion.a */ = {\n+ isa = PBXReferenceProxy;\n+ fileType = archive.ar;\n+ path = \"libdouble-conversion.a\";\n+ remoteRef = 7F033BB11F01B5E100700D63 /* PBXContainerItemProxy */;\n+ sourceTree = BUILT_PRODUCTS_DIR;\n+ };\n7F9636361E9820C10068E9B6 /* libRNCookieManagerIOS.a */ = {\nisa = PBXReferenceProxy;\nfileType = archive.ar;\n"
},
{
"change_type": "MODIFY",
"old_path": "native/package-lock.json",
"new_path": "native/package-lock.json",
"diff": "\"integrity\": \"sha512-7+0Ai8r8Xt6NNVM0Eo+XSqiZsBUYXg2yrCwyBhQzSfFHTGQWzFv/pk9106vPR8HWjKmGK+zzUj244POs4xfO2g==\",\n\"dev\": true\n},\n+ \"1PasswordExtension\": {\n+ \"version\": \"git+https://github.com/jjshammas/onepassword-app-extension.git#acf20f71c890e92ee489fc8e7bb0f7df922e855d\"\n+ },\n\"abab\": {\n\"version\": \"1.0.3\",\n\"resolved\": \"https://registry.npmjs.org/abab/-/abab-1.0.3.tgz\",\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Relinked things |
129,187 | 28.06.2017 10:43:32 | 14,400 | 7ad00658eb5e0c9d5eb1e734ae78f72e261bccd5 | Return $users from every endpoint that returns messages | [
{
"change_type": "MODIFY",
"old_path": "server/auth_thread.php",
"new_path": "server/auth_thread.php",
"diff": "@@ -54,7 +54,7 @@ $conn->query(\n\"role = GREATEST(VALUES(role), role)\"\n);\n-list($message_infos, $truncation_status) =\n+list($message_infos, $truncation_status, $users) =\nget_message_infos(array($thread => false), DEFAULT_NUMBER_PER_THREAD);\n$thread_infos = get_thread_infos(\"c.id = $thread\");\n@@ -63,4 +63,5 @@ async_end(array(\n'thread_info' => $thread_infos[$thread],\n'message_infos' => $message_infos,\n'truncation_status' => $truncation_status[$thread],\n+ 'users' => $users,\n));\n"
},
{
"change_type": "MODIFY",
"old_path": "server/fetch_messages.php",
"new_path": "server/fetch_messages.php",
"diff": "@@ -10,11 +10,12 @@ $number_per_thread = isset($_POST['number_per_thread'])\n? (int)$_POST['number_per_thread']\n: DEFAULT_NUMBER_PER_THREAD;\n-list($message_infos, $truncation_status) =\n+list($message_infos, $truncation_status, $users) =\nget_message_infos($input, $number_per_thread);\nasync_end(array(\n'success' => true,\n'message_infos' => $message_infos,\n'truncation_status' => $truncation_status,\n+ 'users' => $users,\n));\n"
},
{
"change_type": "MODIFY",
"old_path": "server/index.php",
"new_path": "server/index.php",
"diff": "@@ -167,7 +167,7 @@ while ($row = $result->fetch_assoc()) {\n}\n$current_as_of = round(microtime(true) * 1000); // in milliseconds\n-list($message_infos, $truncation_status) =\n+list($message_infos, $truncation_status, $users) =\nget_message_infos(null, DEFAULT_NUMBER_PER_THREAD);\n$fonts_css_url = DEV\n@@ -210,6 +210,7 @@ HTML;\nvar current_as_of = <?=$current_as_of?>;\nvar message_infos = <?=json_encode($message_infos)?>;\nvar truncation_status = <?=json_encode($truncation_status)?>;\n+ var users = <?=json_decode($users)?>;\n</script>\n</head>\n<body>\n"
},
{
"change_type": "MODIFY",
"old_path": "server/login.php",
"new_path": "server/login.php",
"diff": "@@ -36,7 +36,7 @@ $id = intval($user_row['id']);\ncreate_user_cookie($id);\n$current_as_of = round(microtime(true) * 1000); // in milliseconds\n-list($message_infos, $truncation_status) =\n+list($message_infos, $truncation_status, $users) =\nget_message_infos(null, DEFAULT_NUMBER_PER_THREAD);\n$return = array(\n@@ -50,6 +50,7 @@ $return = array(\n'message_infos' => $message_infos,\n'truncation_status' => $truncation_status,\n'server_time' => $current_as_of,\n+ 'users' => $users,\n);\nif (!empty($_POST['inner_entry_query'])) {\n"
},
{
"change_type": "MODIFY",
"old_path": "server/message_lib.php",
"new_path": "server/message_lib.php",
"diff": "@@ -87,8 +87,13 @@ SQL;\n$row_result = $conn->store_result();\n$messages = array();\n+ $users = array();\n$thread_to_message_count = array();\nwhile ($row = $row_result->fetch_assoc()) {\n+ $users[$row['creatorID']] = array(\n+ 'id' => $row['creatorID'],\n+ 'username' => $row['creator'],\n+ );\n$messages[] = message_from_row($row);\nif (!isset($thread_to_message_count[$row['threadID']])) {\n$thread_to_message_count[$row['threadID']] = 1;\n@@ -111,7 +116,9 @@ SQL;\n}\n}\n- return array($messages, $truncation_status);\n+ $all_users = get_all_users($messages, $users);\n+\n+ return array($messages, $truncation_status, $all_users);\n}\n// In contrast with the above function, which is used at the start of a session,\n@@ -146,6 +153,7 @@ SQL;\n$current_thread = null;\n$num_for_thread = 0;\n$messages = array();\n+ $users = array();\n$truncation_status = array();\nwhile ($row = $result->fetch_assoc()) {\n$thread = $row[\"threadID\"];\n@@ -157,13 +165,19 @@ SQL;\n$num_for_thread++;\n}\nif ($num_for_thread <= $max_number_per_thread) {\n+ $users[$row['creatorID']] = array(\n+ 'id' => $row['creatorID'],\n+ 'username' => $row['creator'],\n+ );\n$messages[] = message_from_row($row);\n} else if ($num_for_thread === $max_number_per_thread + 1) {\n$truncation_status[$thread] = TRUNCATION_TRUNCATED;\n}\n}\n- return array($messages, $truncation_status);\n+ $all_users = get_all_users($messages, $users);\n+\n+ return array($messages, $truncation_status, $all_users);\n}\nfunction message_from_row($row) {\n@@ -173,7 +187,6 @@ function message_from_row($row) {\n'threadID' => $row['threadID'],\n'time' => (int)$row['time'],\n'type' => $type,\n- 'creator' => $row['creator'],\n'creatorID' => $row['creatorID'],\n);\nif ($type === MESSAGE_TYPE_TEXT) {\n@@ -184,3 +197,33 @@ function message_from_row($row) {\n}\nreturn $message;\n}\n+\n+// $users it takes is keyed on user ID\n+// $all_users it returns is a flat array\n+function get_all_users($messages, $users) {\n+ $all_added_user_ids = array();\n+ foreach ($messages as $message) {\n+ if ($message['type'] !== MESSAGE_TYPE_ADD_USERS) {\n+ continue;\n+ }\n+ foreach ($message['addedUserIDs'] as $user_id) {\n+ if (!isset($users[$user_id])) {\n+ $all_added_user_ids[] = $user_id;\n+ }\n+ }\n+ }\n+\n+ $where_in = implode(',', $all_added_user_ids);\n+ $query = <<<SQL\n+SELECT id, username FROM users WHERE id IN ({$where_in})\n+SQL;\n+ $result = $conn->query($query);\n+\n+ while ($row = $result->fetch_assoc()) {\n+ $users[$row['id']] = array(\n+ 'id' => $row['id'],\n+ 'username' => $row['username'],\n+ );\n+ }\n+ return array_values($users);\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "server/ping.php",
"new_path": "server/ping.php",
"diff": "@@ -34,10 +34,10 @@ if ($user_logged_in) {\n$time = round(microtime(true) * 1000); // in milliseconds\nif (isset($_REQUEST['last_ping']) && $_REQUEST['last_ping']) {\n$last_ping = (int)$_REQUEST['last_ping'];\n- list($message_infos, $truncation_status) =\n+ list($message_infos, $truncation_status, $users) =\nget_messages_since($last_ping, DEFAULT_NUMBER_PER_THREAD);\n} else {\n- list($message_infos, $truncation_status) =\n+ list($message_infos, $truncation_status, $users) =\nget_message_infos(null, DEFAULT_NUMBER_PER_THREAD);\n}\n@@ -47,6 +47,7 @@ $return = array(\n'thread_infos' => get_thread_infos(),\n'message_infos' => $message_infos,\n'truncation_status' => $truncation_status,\n+ 'users' => $users,\n);\nif (isset($_REQUEST['last_ping'])) {\n"
},
{
"change_type": "MODIFY",
"old_path": "server/reset_password.php",
"new_path": "server/reset_password.php",
"diff": "@@ -55,7 +55,7 @@ create_user_cookie($user);\nclear_verify_codes($user, VERIFY_FIELD_RESET_PASSWORD);\n$current_as_of = round(microtime(true) * 1000); // in milliseconds\n-list($message_infos, $truncation_status) =\n+list($message_infos, $truncation_status, $users) =\nget_message_infos(null, DEFAULT_NUMBER_PER_THREAD);\n$return = array(\n@@ -69,6 +69,7 @@ $return = array(\n'message_infos' => $message_infos,\n'truncation_status' => $truncation_status,\n'server_time' => $current_as_of,\n+ 'users' => $users,\n);\nif (!empty($_POST['inner_entry_query'])) {\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Return $users from every endpoint that returns messages |
129,187 | 07.07.2017 16:09:11 | 14,400 | 1c191060c0d120aaedf8ffb0c9d527b451e059ca | RN -> 0.46.1 | [
{
"change_type": "MODIFY",
"old_path": "native/.flowconfig",
"new_path": "native/.flowconfig",
"diff": "@@ -28,8 +28,6 @@ emoji=true\nmodule.system=haste\n-experimental.strict_type_args=true\n-\nmunge_underscores=true\nmodule.name_mapper='^[./a-zA-Z0-9$_-]+\\.\\(bmp\\|gif\\|jpg\\|jpeg\\|png\\|psd\\|svg\\|webp\\|m4v\\|mov\\|mp4\\|mpeg\\|mpg\\|webm\\|aac\\|aiff\\|caf\\|m4a\\|mp3\\|wav\\|html\\|pdf\\)$' -> 'RelativeImageStub'\n@@ -39,12 +37,12 @@ suppress_type=$FlowIssue\nsuppress_type=$FlowFixMe\nsuppress_type=$FixMe\n-suppress_comment=\\\\(.\\\\|\\n\\\\)*\\\\$FlowFixMe\\\\($\\\\|[^(]\\\\|(\\\\(>=0\\\\.\\\\(4[0-2]\\\\|[1-3][0-9]\\\\|[0-9]\\\\).[0-9]\\\\)? *\\\\(site=[a-z,_]*react_native[a-z,_]*\\\\)?)\\\\)\n-suppress_comment=\\\\(.\\\\|\\n\\\\)*\\\\$FlowIssue\\\\((\\\\(>=0\\\\.\\\\(4[0-2]\\\\|[1-3][0-9]\\\\|[0-9]\\\\).[0-9]\\\\)? *\\\\(site=[a-z,_]*react_native[a-z,_]*\\\\)?)\\\\)?:? #[0-9]+\n+suppress_comment=\\\\(.\\\\|\\n\\\\)*\\\\$FlowFixMe\\\\($\\\\|[^(]\\\\|(\\\\(>=0\\\\.\\\\(4[0-7]\\\\|[1-3][0-9]\\\\|[0-9]\\\\).[0-9]\\\\)? *\\\\(site=[a-z,_]*react_native[a-z,_]*\\\\)?)\\\\)\n+suppress_comment=\\\\(.\\\\|\\n\\\\)*\\\\$FlowIssue\\\\((\\\\(>=0\\\\.\\\\(4[0-7]\\\\|[1-3][0-9]\\\\|[0-9]\\\\).[0-9]\\\\)? *\\\\(site=[a-z,_]*react_native[a-z,_]*\\\\)?)\\\\)?:? #[0-9]+\nsuppress_comment=\\\\(.\\\\|\\n\\\\)*\\\\$FlowFixedInNextDeploy\nsuppress_comment=\\\\(.\\\\|\\n\\\\)*\\\\$FlowExpectedError\nunsafe.enable_getters_and_setters=true\n[version]\n-^0.45.0\n+^0.47.0\n"
},
{
"change_type": "MODIFY",
"old_path": "native/ios/SquadCal.xcodeproj/project.pbxproj",
"new_path": "native/ios/SquadCal.xcodeproj/project.pbxproj",
"diff": ");\nrunOnlyForDeploymentPostprocessing = 0;\nshellPath = /bin/sh;\n- shellScript = \"export NODE_BINARY=node\\n../node_modules/react-native/packager/react-native-xcode.sh\";\n+ shellScript = \"export NODE_BINARY=node\\n../node_modules/react-native/scripts/react-native-xcode.sh\";\n};\n2D02E4CB1E0B4B27006451C7 /* Bundle React Native Code And Images */ = {\nisa = PBXShellScriptBuildPhase;\n);\nrunOnlyForDeploymentPostprocessing = 0;\nshellPath = /bin/sh;\n- shellScript = \"export NODE_BINARY=node\\n../node_modules/react-native/packager/react-native-xcode.sh\";\n+ shellScript = \"export NODE_BINARY=node\\n../node_modules/react-native/scripts/react-native-xcode.sh\";\n};\n/* End PBXShellScriptBuildPhase section */\n"
},
{
"change_type": "MODIFY",
"old_path": "native/navigation-setup.js",
"new_path": "native/navigation-setup.js",
"diff": "@@ -45,10 +45,10 @@ import {\n} from './account/verification-modal.react';\nimport { createIsForegroundSelector } from './selectors/nav-selectors';\n-type InexactNavInfo = BaseNavInfo & {\n+export type NavInfo = {|\n+ ...$Exact<BaseNavInfo>,\nnavigationState: NavigationState,\n-};\n-export type NavInfo = $Exact<InexactNavInfo>;\n+|};\nexport type Action = BaseAction |\n{| type: \"HANDLE_URL\", payload: string |} |\n@@ -127,7 +127,7 @@ const ReduxWrappedAppNavigator = connect((state: AppState) => ({\nisForeground: isForegroundSelector(state),\natInitialRoute: state.navInfo.navigationState.routes[0].index === 0,\n}))(WrappedAppNavigator);\n-ReduxWrappedAppNavigator.router = AppNavigator.router;\n+(ReduxWrappedAppNavigator: Object).router = AppNavigator.router;\nconst RootNavigator = StackNavigator(\n{\n@@ -180,12 +180,21 @@ function reduceNavInfo(state: NavInfo, action: Action): NavInfo {\nstate.navigationState,\n)\nif (navigationState && navigationState !== state.navigationState) {\n- return { ...state, navigationState };\n+ return {\n+ startDate: state.startDate,\n+ endDate: state.endDate,\n+ home: state.home,\n+ threadID: state.threadID,\n+ navigationState,\n+ };\n}\n// Deep linking\nif (action.type === \"HANDLE_URL\") {\nreturn {\n- ...state,\n+ startDate: state.startDate,\n+ endDate: state.endDate,\n+ home: state.home,\n+ threadID: state.threadID,\nnavigationState: handleURL(state.navigationState, action.payload),\n};\n} else if (\n@@ -194,7 +203,10 @@ function reduceNavInfo(state: NavInfo, action: Action): NavInfo {\naction.type === \"NAVIGATE_TO_APP\"\n) {\nreturn {\n- ...state,\n+ startDate: state.startDate,\n+ endDate: state.endDate,\n+ home: state.home,\n+ threadID: state.threadID,\nnavigationState: removeModals(state.navigationState),\n};\n} else if (\n@@ -206,7 +218,10 @@ function reduceNavInfo(state: NavInfo, action: Action): NavInfo {\nreturn logOutIfCookieInvalidated(state, action.payload);\n} else if (action.type === \"PING_SUCCESS\") {\nreturn {\n- ...state,\n+ startDate: state.startDate,\n+ endDate: state.endDate,\n+ home: state.home,\n+ threadID: state.threadID,\nnavigationState: removeModalsIfPingIndicatesLoggedIn(\nstate.navigationState,\naction.payload,\n@@ -294,10 +309,19 @@ function resetNavInfoAndEnsureLoggedOutModalPresence(state: NavInfo): NavInfo {\nconst currentModalIndex =\n_findIndex(['routeName', LoggedOutModalRouteName])(navigationState.routes);\nif (currentModalIndex >= 0 && navigationState.index >= currentModalIndex) {\n- return { ...defaultNavInfo, navigationState };\n+ return {\n+ startDate: defaultNavInfo.startDate,\n+ endDate: defaultNavInfo.endDate,\n+ home: defaultNavInfo.home,\n+ threadID: defaultNavInfo.threadID,\n+ navigationState,\n+ };\n} else if (currentModalIndex >= 0) {\nreturn {\n- ...defaultNavInfo,\n+ startDate: defaultNavInfo.startDate,\n+ endDate: defaultNavInfo.endDate,\n+ home: defaultNavInfo.home,\n+ threadID: defaultNavInfo.threadID,\nnavigationState: {\n...navigationState,\nindex: currentModalIndex,\n@@ -305,7 +329,10 @@ function resetNavInfoAndEnsureLoggedOutModalPresence(state: NavInfo): NavInfo {\n};\n}\nreturn {\n- ...defaultNavInfo,\n+ startDate: defaultNavInfo.startDate,\n+ endDate: defaultNavInfo.endDate,\n+ home: defaultNavInfo.home,\n+ threadID: defaultNavInfo.threadID,\nnavigationState: {\nindex: navigationState.routes.length,\nroutes: [\n"
},
{
"change_type": "MODIFY",
"old_path": "native/package-lock.json",
"new_path": "native/package-lock.json",
"diff": "\"ansi-escapes\": {\n\"version\": \"1.4.0\",\n\"resolved\": \"https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-1.4.0.tgz\",\n- \"integrity\": \"sha1-06ioOzGapneTZisT52HHkRQiMG4=\"\n+ \"integrity\": \"sha1-06ioOzGapneTZisT52HHkRQiMG4=\",\n+ \"dev\": true\n},\n\"ansi-regex\": {\n\"version\": \"2.1.1\",\n\"integrity\": \"sha1-T6kXw+WclKAEzWH47lCdplFocUM=\",\n\"dev\": true\n},\n- \"cli-cursor\": {\n- \"version\": \"1.0.2\",\n- \"resolved\": \"https://registry.npmjs.org/cli-cursor/-/cli-cursor-1.0.2.tgz\",\n- \"integrity\": \"sha1-ZNo/fValRBLll5S9Ytw1KV6PKYc=\"\n- },\n\"cli-width\": {\n\"version\": \"2.1.0\",\n\"resolved\": \"https://registry.npmjs.org/cli-width/-/cli-width-2.1.0.tgz\",\n\"integrity\": \"sha1-TrZGejaglfq7KXD/nV4/t7zm68M=\",\n\"dev\": true\n},\n- \"exit-hook\": {\n- \"version\": \"1.1.1\",\n- \"resolved\": \"https://registry.npmjs.org/exit-hook/-/exit-hook-1.1.1.tgz\",\n- \"integrity\": \"sha1-8FyiM7SMBdVP/wd2XfhQfpXAL/g=\"\n- },\n\"expand-brackets\": {\n\"version\": \"0.1.5\",\n\"resolved\": \"https://registry.npmjs.org/expand-brackets/-/expand-brackets-0.1.5.tgz\",\n\"resolved\": \"https://registry.npmjs.org/extend/-/extend-3.0.1.tgz\",\n\"integrity\": \"sha1-p1Xqe8Gt/MWjHOfnYtuq3F5jZEQ=\"\n},\n+ \"external-editor\": {\n+ \"version\": \"2.0.4\",\n+ \"resolved\": \"https://registry.npmjs.org/external-editor/-/external-editor-2.0.4.tgz\",\n+ \"integrity\": \"sha1-HtkZnanL/i7y96MbL96LDRI2iXI=\"\n+ },\n\"extglob\": {\n\"version\": \"0.3.2\",\n\"resolved\": \"https://registry.npmjs.org/extglob/-/extglob-0.3.2.tgz\",\n\"integrity\": \"sha1-i1vL2ewyfFBBv5qwI/1nUPEXfmU=\",\n\"dev\": true\n},\n- \"figures\": {\n- \"version\": \"1.7.0\",\n- \"resolved\": \"https://registry.npmjs.org/figures/-/figures-1.7.0.tgz\",\n- \"integrity\": \"sha1-y+Hjr/zxzUS4DK3+0o3Hk6lwHS4=\"\n- },\n\"filename-regex\": {\n\"version\": \"2.0.1\",\n\"resolved\": \"https://registry.npmjs.org/filename-regex/-/filename-regex-2.0.1.tgz\",\n\"integrity\": \"sha1-ay6YIrGizgpgq2TWEOzK1TyyTQ8=\"\n},\n\"flow-bin\": {\n- \"version\": \"0.45.0\",\n- \"resolved\": \"https://registry.npmjs.org/flow-bin/-/flow-bin-0.45.0.tgz\",\n- \"integrity\": \"sha1-AJ3Q9Xej9mXHTKi+gnrowt2P1rU=\",\n+ \"version\": \"0.47.0\",\n+ \"resolved\": \"https://registry.npmjs.org/flow-bin/-/flow-bin-0.47.0.tgz\",\n+ \"integrity\": \"sha1-oqCKs+DR8ctX0X4nswsRi2L9o2c=\",\n\"dev\": true\n},\n\"for-in\": {\n\"integrity\": \"sha1-BTfLedr1m1mhpRff9wbIbsA5Fi4=\",\n\"dev\": true\n},\n- \"inquirer\": {\n- \"version\": \"0.12.0\",\n- \"resolved\": \"https://registry.npmjs.org/inquirer/-/inquirer-0.12.0.tgz\",\n- \"integrity\": \"sha1-HvK/1jUE3wvHV4X/+MLEHfEvB34=\"\n- },\n\"invariant\": {\n\"version\": \"2.2.2\",\n\"resolved\": \"https://registry.npmjs.org/invariant/-/invariant-2.2.2.tgz\",\n\"resolved\": \"https://registry.npmjs.org/is-primitive/-/is-primitive-2.0.0.tgz\",\n\"integrity\": \"sha1-IHurkWOEmcB7Kt8kCkGochADRXU=\"\n},\n+ \"is-promise\": {\n+ \"version\": \"2.1.0\",\n+ \"resolved\": \"https://registry.npmjs.org/is-promise/-/is-promise-2.1.0.tgz\",\n+ \"integrity\": \"sha1-eaKp7OfwlugPNtKy87wWwf9L8/o=\"\n+ },\n\"is-redirect\": {\n\"version\": \"1.0.0\",\n\"resolved\": \"https://registry.npmjs.org/is-redirect/-/is-redirect-1.0.0.tgz\",\n\"resolved\": \"https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz\",\n\"integrity\": \"sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=\"\n},\n- \"isemail\": {\n- \"version\": \"1.2.0\",\n- \"resolved\": \"https://registry.npmjs.org/isemail/-/isemail-1.2.0.tgz\",\n- \"integrity\": \"sha1-vgPfjMPineTSxd9lASY/H6RZXpo=\"\n- },\n\"isexe\": {\n\"version\": \"2.0.0\",\n\"resolved\": \"https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz\",\n}\n}\n},\n- \"joi\": {\n- \"version\": \"6.10.1\",\n- \"resolved\": \"https://registry.npmjs.org/joi/-/joi-6.10.1.tgz\",\n- \"integrity\": \"sha1-TVDDGAeRIgAP5fFq8f+OGRe3fgY=\"\n- },\n\"js-tokens\": {\n\"version\": \"3.0.1\",\n\"resolved\": \"https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.1.tgz\",\n\"integrity\": \"sha1-peZUwuWi3rXyAdls77yoDA7y9RM=\",\n\"optional\": true\n},\n+ \"jschardet\": {\n+ \"version\": \"1.4.2\",\n+ \"resolved\": \"https://registry.npmjs.org/jschardet/-/jschardet-1.4.2.tgz\",\n+ \"integrity\": \"sha1-KqEH8UKvQSHRRWWdRPUIMJYeaZo=\"\n+ },\n\"jsdom\": {\n\"version\": \"9.12.0\",\n\"resolved\": \"https://registry.npmjs.org/jsdom/-/jsdom-9.12.0.tgz\",\n\"resolved\": \"https://registry.npmjs.org/methods/-/methods-1.1.2.tgz\",\n\"integrity\": \"sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=\"\n},\n+ \"metro-bundler\": {\n+ \"version\": \"0.7.8\",\n+ \"resolved\": \"https://registry.npmjs.org/metro-bundler/-/metro-bundler-0.7.8.tgz\",\n+ \"integrity\": \"sha512-6djvyY3giKujmgnC+n3HgPQ7/tREwtSv7T1puCsA9Ourz+A2VjgeYa4HBTs1IPWYQYWucjBWzA8F7EJc0voMyg==\",\n+ \"dependencies\": {\n+ \"babel-preset-react-native\": {\n+ \"version\": \"1.9.2\",\n+ \"resolved\": \"https://registry.npmjs.org/babel-preset-react-native/-/babel-preset-react-native-1.9.2.tgz\",\n+ \"integrity\": \"sha1-sird0uNV/zs5Zxt5voB+Ut+hRfI=\"\n+ },\n+ \"core-js\": {\n+ \"version\": \"2.4.1\",\n+ \"resolved\": \"https://registry.npmjs.org/core-js/-/core-js-2.4.1.tgz\",\n+ \"integrity\": \"sha1-TekR5mew6ukSTjQlS1OupvxhjT4=\"\n+ }\n+ }\n+ },\n\"micromatch\": {\n\"version\": \"2.3.11\",\n\"resolved\": \"https://registry.npmjs.org/micromatch/-/micromatch-2.3.11.tgz\",\n}\n}\n},\n+ \"mimic-fn\": {\n+ \"version\": \"1.1.0\",\n+ \"resolved\": \"https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.1.0.tgz\",\n+ \"integrity\": \"sha1-5md4PZLonb00KBi1IwudYqZyrRg=\"\n+ },\n\"min-document\": {\n\"version\": \"2.19.0\",\n\"resolved\": \"https://registry.npmjs.org/min-document/-/min-document-2.19.0.tgz\",\n}\n}\n},\n- \"moment\": {\n- \"version\": \"2.18.1\",\n- \"resolved\": \"https://registry.npmjs.org/moment/-/moment-2.18.1.tgz\",\n- \"integrity\": \"sha1-w2GT3Tzhwu7SrbfIAtu8d6gbHA8=\"\n- },\n\"morgan\": {\n\"version\": \"1.6.1\",\n\"resolved\": \"https://registry.npmjs.org/morgan/-/morgan-1.6.1.tgz\",\n\"resolved\": \"https://registry.npmjs.org/multipipe/-/multipipe-0.1.2.tgz\",\n\"integrity\": \"sha1-Ko8t33Du1WTf8tV/HhoTfZ8FB4s=\"\n},\n- \"mute-stream\": {\n- \"version\": \"0.0.5\",\n- \"resolved\": \"https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.5.tgz\",\n- \"integrity\": \"sha1-j7+rsKmKJT0xhDMfno3rc3L6xsA=\"\n- },\n\"natural-compare\": {\n\"version\": \"1.4.0\",\n\"resolved\": \"https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz\",\n\"resolved\": \"https://registry.npmjs.org/once/-/once-1.4.0.tgz\",\n\"integrity\": \"sha1-WDsap3WWHUsROsF9nFC6753Xa9E=\"\n},\n- \"onetime\": {\n- \"version\": \"1.1.0\",\n- \"resolved\": \"https://registry.npmjs.org/onetime/-/onetime-1.1.0.tgz\",\n- \"integrity\": \"sha1-ofeDj4MUxRbwXs78vEzP4EtO14k=\"\n- },\n\"opn\": {\n\"version\": \"3.0.3\",\n\"resolved\": \"https://registry.npmjs.org/opn/-/opn-3.0.3.tgz\",\n\"version\": \"2.3.3\",\n\"resolved\": \"https://registry.npmjs.org/react-devtools-core/-/react-devtools-core-2.3.3.tgz\",\n\"integrity\": \"sha1-OpUObyDyyOZ9BBnkKMhQDn2L80c=\",\n+ \"dev\": true,\n\"dependencies\": {\n\"safe-buffer\": {\n\"version\": \"5.0.1\",\n\"resolved\": \"https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.0.1.tgz\",\n- \"integrity\": \"sha1-0mPKVGls2KMGtcplUekt5XkY++c=\"\n+ \"integrity\": \"sha1-0mPKVGls2KMGtcplUekt5XkY++c=\",\n+ \"dev\": true\n},\n\"ws\": {\n\"version\": \"2.3.1\",\n\"resolved\": \"https://registry.npmjs.org/ws/-/ws-2.3.1.tgz\",\n- \"integrity\": \"sha1-a5Sz5EfLajY/eF6vlK9jWejoHIA=\"\n+ \"integrity\": \"sha1-a5Sz5EfLajY/eF6vlK9jWejoHIA=\",\n+ \"dev\": true\n}\n}\n},\n\"react-native\": {\n- \"version\": \"0.45.1\",\n- \"resolved\": \"https://registry.npmjs.org/react-native/-/react-native-0.45.1.tgz\",\n- \"integrity\": \"sha1-syg8SogjNCH5xmKi/xpMzIqfB8A=\",\n+ \"version\": \"0.46.1\",\n+ \"resolved\": \"https://registry.npmjs.org/react-native/-/react-native-0.46.1.tgz\",\n+ \"integrity\": \"sha1-o/gebWwSrawIgBDvNB8n76HmbQI=\",\n\"dependencies\": {\n+ \"ansi-escapes\": {\n+ \"version\": \"2.0.0\",\n+ \"resolved\": \"https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-2.0.0.tgz\",\n+ \"integrity\": \"sha1-W65SvkJIeN2Xg+iRDj/Cki6DyBs=\"\n+ },\n+ \"ansi-regex\": {\n+ \"version\": \"3.0.0\",\n+ \"resolved\": \"https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz\",\n+ \"integrity\": \"sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=\"\n+ },\n\"babel-preset-react-native\": {\n\"version\": \"1.9.2\",\n\"resolved\": \"https://registry.npmjs.org/babel-preset-react-native/-/babel-preset-react-native-1.9.2.tgz\",\n\"integrity\": \"sha1-sird0uNV/zs5Zxt5voB+Ut+hRfI=\"\n},\n+ \"cli-cursor\": {\n+ \"version\": \"2.1.0\",\n+ \"resolved\": \"https://registry.npmjs.org/cli-cursor/-/cli-cursor-2.1.0.tgz\",\n+ \"integrity\": \"sha1-s12sN2R5+sw+lHR9QdDQ9SOP/LU=\"\n+ },\n\"core-js\": {\n\"version\": \"2.4.1\",\n\"resolved\": \"https://registry.npmjs.org/core-js/-/core-js-2.4.1.tgz\",\n\"integrity\": \"sha1-TekR5mew6ukSTjQlS1OupvxhjT4=\"\n},\n+ \"figures\": {\n+ \"version\": \"2.0.0\",\n+ \"resolved\": \"https://registry.npmjs.org/figures/-/figures-2.0.0.tgz\",\n+ \"integrity\": \"sha1-OrGi0qYsi/tDGgyUy3l6L84nyWI=\"\n+ },\n+ \"inquirer\": {\n+ \"version\": \"3.1.1\",\n+ \"resolved\": \"https://registry.npmjs.org/inquirer/-/inquirer-3.1.1.tgz\",\n+ \"integrity\": \"sha512-H50sHQwgvvaTBd3HpKMVtL/u6LoHDvYym51gd7bGQe/+9HkCE+J0/3N5FJLfd6O6oz44hHewC2Pc2LodzWVafQ==\"\n+ },\n+ \"is-fullwidth-code-point\": {\n+ \"version\": \"2.0.0\",\n+ \"resolved\": \"https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz\",\n+ \"integrity\": \"sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=\"\n+ },\n+ \"mute-stream\": {\n+ \"version\": \"0.0.7\",\n+ \"resolved\": \"https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.7.tgz\",\n+ \"integrity\": \"sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s=\"\n+ },\n+ \"onetime\": {\n+ \"version\": \"2.0.1\",\n+ \"resolved\": \"https://registry.npmjs.org/onetime/-/onetime-2.0.1.tgz\",\n+ \"integrity\": \"sha1-BnQoIw/WdEOyeUsiu6UotoZ5YtQ=\"\n+ },\n+ \"react-devtools-core\": {\n+ \"version\": \"2.3.1\",\n+ \"resolved\": \"https://registry.npmjs.org/react-devtools-core/-/react-devtools-core-2.3.1.tgz\",\n+ \"integrity\": \"sha1-3IOrqFc17/5eHcOGoWFMtejQBH0=\",\n+ \"dependencies\": {\n+ \"ws\": {\n+ \"version\": \"2.3.1\",\n+ \"resolved\": \"https://registry.npmjs.org/ws/-/ws-2.3.1.tgz\",\n+ \"integrity\": \"sha1-a5Sz5EfLajY/eF6vlK9jWejoHIA=\"\n+ }\n+ }\n+ },\n+ \"restore-cursor\": {\n+ \"version\": \"2.0.0\",\n+ \"resolved\": \"https://registry.npmjs.org/restore-cursor/-/restore-cursor-2.0.0.tgz\",\n+ \"integrity\": \"sha1-n37ih/gv0ybU/RYpI9YhKe7g368=\"\n+ },\n+ \"run-async\": {\n+ \"version\": \"2.3.0\",\n+ \"resolved\": \"https://registry.npmjs.org/run-async/-/run-async-2.3.0.tgz\",\n+ \"integrity\": \"sha1-A3GrSuC91yDUFm19/aZP96RFpsA=\"\n+ },\n+ \"rx-lite\": {\n+ \"version\": \"4.0.8\",\n+ \"resolved\": \"https://registry.npmjs.org/rx-lite/-/rx-lite-4.0.8.tgz\",\n+ \"integrity\": \"sha1-Cx4Rr4vESDbwSmQH6S2kJGe3lEQ=\"\n+ },\n+ \"safe-buffer\": {\n+ \"version\": \"5.0.1\",\n+ \"resolved\": \"https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.0.1.tgz\",\n+ \"integrity\": \"sha1-0mPKVGls2KMGtcplUekt5XkY++c=\"\n+ },\n+ \"string-width\": {\n+ \"version\": \"2.1.0\",\n+ \"resolved\": \"https://registry.npmjs.org/string-width/-/string-width-2.1.0.tgz\",\n+ \"integrity\": \"sha1-AwZkVh/BRslCPsfZeP4kV0N/5tA=\",\n+ \"dependencies\": {\n+ \"strip-ansi\": {\n+ \"version\": \"4.0.0\",\n+ \"resolved\": \"https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz\",\n+ \"integrity\": \"sha1-qEeQIusaw2iocTibY1JixQXuNo8=\"\n+ }\n+ }\n+ },\n\"whatwg-fetch\": {\n\"version\": \"1.1.1\",\n\"resolved\": \"https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-1.1.1.tgz\",\n\"resolved\": \"https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.2.tgz\",\n\"integrity\": \"sha1-WgTfBeT1f+Pw3Gj90R3FyXx+b00=\"\n},\n- \"readline2\": {\n- \"version\": \"1.0.1\",\n- \"resolved\": \"https://registry.npmjs.org/readline2/-/readline2-1.0.1.tgz\",\n- \"integrity\": \"sha1-QQWWCP/BVHV7cV2ZidGZ/783LjU=\"\n- },\n\"rebound\": {\n\"version\": \"0.0.13\",\n\"resolved\": \"https://registry.npmjs.org/rebound/-/rebound-0.0.13.tgz\",\n}\n}\n},\n- \"restore-cursor\": {\n- \"version\": \"1.0.1\",\n- \"resolved\": \"https://registry.npmjs.org/restore-cursor/-/restore-cursor-1.0.1.tgz\",\n- \"integrity\": \"sha1-NGYfRohjJ/7SmRR5FSJS35LapUE=\"\n- },\n\"right-align\": {\n\"version\": \"0.1.3\",\n\"resolved\": \"https://registry.npmjs.org/right-align/-/right-align-0.1.3.tgz\",\n\"resolved\": \"https://registry.npmjs.org/rndm/-/rndm-1.2.0.tgz\",\n\"integrity\": \"sha1-8z/pz7Urv9UgqhgyO8ZdsRCht2w=\"\n},\n- \"run-async\": {\n- \"version\": \"0.1.0\",\n- \"resolved\": \"https://registry.npmjs.org/run-async/-/run-async-0.1.0.tgz\",\n- \"integrity\": \"sha1-yK1KXhEGYeQCp9IbUw4AnyX444k=\"\n- },\n\"rx-lite\": {\n\"version\": \"3.1.2\",\n\"resolved\": \"https://registry.npmjs.org/rx-lite/-/rx-lite-3.1.2.tgz\",\n\"integrity\": \"sha1-Gc5QLKVyZl87ZHsQk5+X/RYV8QI=\"\n},\n+ \"rx-lite-aggregates\": {\n+ \"version\": \"4.0.8\",\n+ \"resolved\": \"https://registry.npmjs.org/rx-lite-aggregates/-/rx-lite-aggregates-4.0.8.tgz\",\n+ \"integrity\": \"sha1-dTuHqJoRyVRnxKwWJsTvxOBcZ74=\"\n+ },\n\"safe-buffer\": {\n\"version\": \"5.1.1\",\n\"resolved\": \"https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz\",\n\"signal-exit\": {\n\"version\": \"3.0.2\",\n\"resolved\": \"https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz\",\n- \"integrity\": \"sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=\",\n- \"dev\": true\n+ \"integrity\": \"sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=\"\n},\n\"simple-plist\": {\n\"version\": \"0.2.1\",\n\"integrity\": \"sha1-8y6srFoXW+ol1/q1Zas+2HQe9W8=\",\n\"dev\": true\n},\n+ \"tmp\": {\n+ \"version\": \"0.0.31\",\n+ \"resolved\": \"https://registry.npmjs.org/tmp/-/tmp-0.0.31.tgz\",\n+ \"integrity\": \"sha1-jzirlDjhcxXl29izZX6L+yd65Kc=\"\n+ },\n\"tmpl\": {\n\"version\": \"1.0.4\",\n\"resolved\": \"https://registry.npmjs.org/tmpl/-/tmpl-1.0.4.tgz\",\n\"resolved\": \"https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-1.0.3.tgz\",\n\"integrity\": \"sha1-uDVx+k2MJbguIxsG46MFXeTKGkc=\"\n},\n- \"topo\": {\n- \"version\": \"1.1.0\",\n- \"resolved\": \"https://registry.npmjs.org/topo/-/topo-1.1.0.tgz\",\n- \"integrity\": \"sha1-6ddRYV0buH3IZdsYL6HKCl71NtU=\"\n- },\n\"tough-cookie\": {\n\"version\": \"2.3.2\",\n\"resolved\": \"https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.2.tgz\",\n"
},
{
"change_type": "MODIFY",
"old_path": "native/package.json",
"new_path": "native/package.json",
"diff": "\"invariant\": \"^2.2.2\",\n\"lib\": \"file:../lib\",\n\"react\": \"^16.0.0-alpha.12\",\n- \"react-native\": \"^0.45.1\",\n+ \"react-native\": \"^0.46.1\",\n\"react-native-cookies\": \"^3.1.0\",\n\"react-native-invertible-flat-list\": \"^1.1.0\",\n\"react-native-keychain\": \"^1.2.0\",\n\"babel-jest\": \"20.0.3\",\n\"babel-plugin-transform-remove-console\": \"^6.8.4\",\n\"babel-preset-react-native\": \"2.0.0\",\n- \"flow-bin\": \"^0.45.0\",\n+ \"flow-bin\": \"^0.47.0\",\n\"jest\": \"^20.0.4\",\n\"react-devtools\": \"^2.3.3\",\n\"react-test-renderer\": \"^15.6.1\",\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | RN -> 0.46.1 |
129,187 | 07.07.2017 16:19:20 | 14,400 | f4bc5b7a0b5b606a8256fdc080cee4643cc385bb | onContentSizeChange is finally fixed on Android, and consequently the hack in onChange where it included contentSize is no longer present | [
{
"change_type": "MODIFY",
"old_path": "native/calendar/entry.react.js",
"new_path": "native/calendar/entry.react.js",
"diff": "@@ -327,16 +327,6 @@ class Entry extends React.Component {\nthis.guardedSetState({ height });\n}\n- // On Android, onContentSizeChange only gets called once when the TextInput is\n- // first rendered. Which is like, what? Anyways, instead you're supposed to\n- // use onChange.\n- onChange = (event) => {\n- if (Platform.OS !== \"android\" || !Entry.isFocused(this.props)) {\n- return;\n- }\n- this.guardedSetState({ height: event.nativeEvent.contentSize.height });\n- }\n-\nonChangeText = (newText: string) => {\nthis.guardedSetState({ text: newText });\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/input-bar.react.js",
"new_path": "native/chat/input-bar.react.js",
"diff": "@@ -126,15 +126,6 @@ class InputBar extends React.PureComponent {\nthis.setState({ height });\n}\n- // On Android, onContentSizeChange only gets called once when the TextInput is\n- // first rendered. Which is like, what? Anyways, instead you're supposed to\n- // use onChange.\n- onChange = (event) => {\n- if (Platform.OS === \"android\") {\n- this.setState({ height: event.nativeEvent.contentSize.height });\n- }\n- }\n-\nonSend = () => {\nconst localID = `local${getNewLocalID()}`;\nconst creatorID = this.props.userID;\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | onContentSizeChange is finally fixed on Android, and consequently the hack in onChange where it included contentSize is no longer present |
129,187 | 07.07.2017 16:20:45 | 14,400 | 531c39b78dfd18c2cb111cb7c5a1b209eb0c42cf | Forgot to remove the props... | [
{
"change_type": "MODIFY",
"old_path": "native/calendar/entry.react.js",
"new_path": "native/calendar/entry.react.js",
"diff": "@@ -251,7 +251,6 @@ class Entry extends React.Component {\nonBlur={this.onBlur}\nonFocus={this.onFocus}\nonContentSizeChange={this.onContentSizeChange}\n- onChange={this.onChange}\nautoFocus={focused}\nref={this.textInputRef}\n/>\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/input-bar.react.js",
"new_path": "native/chat/input-bar.react.js",
"diff": "@@ -101,7 +101,6 @@ class InputBar extends React.PureComponent {\nplaceholderTextColor=\"#888888\"\nmultiline={true}\nonContentSizeChange={this.onContentSizeChange}\n- onChange={this.onChange}\nstyle={[styles.textInput, textInputStyle]}\nref={this.textInputRef}\n/>\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Forgot to remove the props... |
129,187 | 10.07.2017 13:54:28 | 14,400 | 51f972d906d735de28367e8c6f67ce662df32df5 | Source all EntryInfo creator names from userInfos | [
{
"change_type": "MODIFY",
"old_path": "lib/actions/entry-actions.js",
"new_path": "lib/actions/entry-actions.js",
"diff": "// @flow\nimport type { BaseAppState } from '../types/redux-types';\n-import type { EntryInfo } from '../types/entry-types';\n+import type { RawEntryInfo } from '../types/entry-types';\nimport type { FetchJSON } from '../utils/fetch-json';\nimport type { HistoryRevisionInfo } from '../types/history-types';\nimport type { CalendarQuery } from '../selectors/nav-selectors';\n@@ -17,7 +17,7 @@ const fetchEntriesActionTypes = {\nasync function fetchEntries(\nfetchJSON: FetchJSON,\ncalendarQuery: CalendarQuery,\n-): Promise<EntryInfo[]> {\n+): Promise<RawEntryInfo[]> {\nconst response = await fetchJSON('fetch_entries.php', {\n'nav': calendarQuery.navID,\n'start_date': calendarQuery.startDate,\n@@ -28,7 +28,7 @@ async function fetchEntries(\n}\nexport type CalendarResult = {\n- entryInfos: EntryInfo[],\n+ entryInfos: RawEntryInfo[],\ncalendarQuery: CalendarQuery,\n};\nconst fetchEntriesAndSetRangeActionTypes = {\n@@ -53,10 +53,10 @@ const createLocalEntryActionType = \"CREATE_LOCAL_ENTRY\";\nfunction createLocalEntry(\nthreadID: string,\ndateString: string,\n- creator: ?string,\n-): EntryInfo {\n+ creatorID: string,\n+): RawEntryInfo {\nconst date = dateFromString(dateString);\n- const newEntryInfo: EntryInfo = {\n+ const newEntryInfo: RawEntryInfo = {\nlocalID: `local${getNewLocalID()}`,\nthreadID,\ntext: \"\",\n@@ -64,7 +64,7 @@ function createLocalEntry(\nmonth: date.getMonth() + 1,\nday: date.getDate(),\ncreationTime: Date.now(),\n- creator,\n+ creatorID,\ndeleted: false,\n};\nreturn newEntryInfo;\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/actions/user-actions.js",
"new_path": "lib/actions/user-actions.js",
"diff": "@@ -4,7 +4,6 @@ import type { FetchJSON } from '../utils/fetch-json';\nimport type { ThreadInfo } from '../types/thread-types';\nimport type { VerifyField } from '../utils/verify-utils';\nimport type { CurrentUserInfo, UserInfo } from '../types/user-types';\n-import type { EntryInfo } from '../types/entry-types';\nimport type { CalendarResult } from './entry-actions';\nimport type { CalendarQuery } from '../selectors/nav-selectors';\nimport type { GenericMessagesResult } from './message-actions';\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/reducers/entry-reducer.js",
"new_path": "lib/reducers/entry-reducer.js",
"diff": "@@ -4,7 +4,7 @@ import type {\nBaseAppState,\nBaseAction,\n} from '../types/redux-types';\n-import type { EntryInfo } from '../types/entry-types';\n+import type { RawEntryInfo } from '../types/entry-types';\nimport _flow from 'lodash/fp/flow';\nimport _map from 'lodash/fp/map';\n@@ -27,19 +27,19 @@ import invariant from 'invariant';\nimport { dateString } from '../utils/date-utils';\nimport { setHighestLocalID } from '../utils/local-ids';\n-function daysToEntriesFromEntryInfos(entryInfos: EntryInfo[]) {\n+function daysToEntriesFromEntryInfos(entryInfos: RawEntryInfo[]) {\nreturn _flow(\n_groupBy(\n- (entryInfo: EntryInfo) =>\n+ (entryInfo: RawEntryInfo) =>\ndateString(entryInfo.year, entryInfo.month, entryInfo.day),\n),\n- _mapValues((entryInfoGroup: EntryInfo[]) => _map('id')(entryInfoGroup)),\n+ _mapValues((entryInfoGroup: RawEntryInfo[]) => _map('id')(entryInfoGroup)),\n)(entryInfos);\n}\nfunction filterExistingDaysToEntriesWithNewEntryInfos(\noldDaysToEntries: {[id: string]: string[]},\n- newEntryInfos: {[id: string]: EntryInfo},\n+ newEntryInfos: {[id: string]: RawEntryInfo},\n) {\nreturn _mapValues(\n(entryIDs: string[]) => _filter(\n@@ -49,12 +49,12 @@ function filterExistingDaysToEntriesWithNewEntryInfos(\n}\nfunction mergeNewEntryInfos(\n- oldEntryInfos: {[id: string]: EntryInfo},\n+ oldEntryInfos: {[id: string]: RawEntryInfo},\noldDaysToEntries: {[id: string]: string[]},\n- newEntryInfos: EntryInfo[],\n+ newEntryInfos: RawEntryInfo[],\n) {\nconst addedEntryInfos = _flow(\n- _map((entryInfo: EntryInfo) => {\n+ _map((entryInfo: RawEntryInfo) => {\ninvariant(entryInfo.id, \"new entryInfos should have serverID\");\nconst currentEntryInfo = oldEntryInfos[entryInfo.id];\nif (currentEntryInfo && currentEntryInfo.localID) {\n@@ -69,7 +69,7 @@ function mergeNewEntryInfos(\nmonth: entryInfo.month,\nday: entryInfo.day,\ncreationTime: entryInfo.creationTime,\n- creator: entryInfo.creator,\n+ creatorID: entryInfo.creatorID,\ndeleted: entryInfo.deleted,\n};\n}\n@@ -97,7 +97,7 @@ function mergeNewEntryInfos(\n}\nfunction reduceEntryInfos(\n- inputEntryInfos: {[id: string]: EntryInfo},\n+ inputEntryInfos: {[id: string]: RawEntryInfo},\ninputDaysToEntries: {[id: string]: string[]},\ninputLastUserInteractionCalendar: number,\naction: BaseAction,\n@@ -112,7 +112,7 @@ function reduceEntryInfos(\nconst threadInfos = action.payload;\nconst authorizedThreadInfos = _pickBy('authorized')(threadInfos);\nconst newEntryInfos = _pickBy(\n- (entry: EntryInfo) => authorizedThreadInfos[entry.threadID],\n+ (entry: RawEntryInfo) => authorizedThreadInfos[entry.threadID],\n)(entryInfos);\nconst newDaysToEntries = filterExistingDaysToEntriesWithNewEntryInfos(\ndaysToEntries,\n@@ -122,7 +122,7 @@ function reduceEntryInfos(\n} else if (action.type === \"DELETE_THREAD_SUCCESS\") {\nconst threadID = action.payload;\nconst newEntryInfos = _omitBy(\n- (entry: EntryInfo) => entry.threadID === threadID,\n+ (entry: RawEntryInfo) => entry.threadID === threadID,\n)(entryInfos);\nconst newDaysToEntries = filterExistingDaysToEntriesWithNewEntryInfos(\ndaysToEntries,\n@@ -133,7 +133,7 @@ function reduceEntryInfos(\nconst threadInfos = action.payload.threadInfos;\nconst authorizedThreadInfos = _pickBy('authorized')(threadInfos);\nconst newEntryInfos = _pickBy(\n- (entry: EntryInfo) => authorizedThreadInfos[entry.threadID],\n+ (entry: RawEntryInfo) => authorizedThreadInfos[entry.threadID],\n)(entryInfos);\nconst newDaysToEntries = filterExistingDaysToEntriesWithNewEntryInfos(\ndaysToEntries,\n@@ -190,7 +190,7 @@ function reduceEntryInfos(\n// entry, and this probably won't happen often, so for now we can just\n// keep the serverID entry.\nnewEntryInfos = _omitBy(\n- (candidate: EntryInfo) => candidate.localID === localID,\n+ (candidate: RawEntryInfo) => candidate.localID === localID,\n)(entryInfos);\n} else if (entryInfos[localID]) {\nnewEntryInfos = _mapKeys(\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/selectors/thread-selectors.js",
"new_path": "lib/selectors/thread-selectors.js",
"diff": "import type { BaseAppState } from '../types/redux-types';\nimport type { ThreadInfo } from '../types/thread-types';\n-import type { EntryInfo } from '../types/entry-types';\n+import type { RawEntryInfo, EntryInfo } from '../types/entry-types';\n+import type { UserInfo } from '../types/user-types';\nimport { createSelector } from 'reselect';\nimport Color from 'color';\n@@ -18,6 +19,26 @@ const _mapValuesWithKeys = _mapValues.convert({ cap: false });\nimport { currentNavID } from './nav-selectors';\nimport { dateString, dateFromString } from '../utils/date-utils';\n+function createEntryInfo(\n+ rawEntryInfo: RawEntryInfo,\n+ viewerID: ?string,\n+ userInfos: {[id: string]: UserInfo},\n+): EntryInfo {\n+ const creatorInfo = userInfos[rawEntryInfo.creatorID];\n+ return {\n+ id: rawEntryInfo.id,\n+ localID: rawEntryInfo.localID,\n+ threadID: rawEntryInfo.threadID,\n+ text: rawEntryInfo.text,\n+ year: rawEntryInfo.year,\n+ month: rawEntryInfo.month,\n+ day: rawEntryInfo.day,\n+ creationTime: rawEntryInfo.creationTime,\n+ creator: creatorInfo.username,\n+ deleted: rawEntryInfo.deleted,\n+ };\n+}\n+\nfunction colorIsDark(color: string) {\nreturn Color(`#${color}`).dark();\n}\n@@ -76,12 +97,16 @@ const currentDaysToEntries = createSelector(\n(state: BaseAppState) => state.daysToEntries,\n(state: BaseAppState) => state.navInfo.startDate,\n(state: BaseAppState) => state.navInfo.endDate,\n+ (state: BaseAppState) => state.userInfos,\n+ (state: BaseAppState) => state.currentUserInfo && state.currentUserInfo.id,\nonScreenThreadInfos,\n(\n- entryInfos: {[id: string]: EntryInfo},\n+ entryInfos: {[id: string]: RawEntryInfo},\ndaysToEntries: {[day: string]: string[]},\nstartDateString: string,\nendDateString: string,\n+ userInfos: {[id: string]: UserInfo},\n+ viewerID: ?string,\nonScreenThreadInfos: ThreadInfo[],\n) => {\nconst allDaysWithinRange = {},\n@@ -96,7 +121,10 @@ const currentDaysToEntries = createSelector(\n}\nreturn _mapValuesWithKeys(\n(_: string[], dayString: string) => _flow(\n- _map((entryID: string) => entryInfos[entryID]),\n+ _map(\n+ (entryID: string) =>\n+ createEntryInfo(entryInfos[entryID], viewerID, userInfos),\n+ ),\n_compact,\n_filter(\n(entryInfo: EntryInfo) => !entryInfo.deleted &&\n@@ -109,6 +137,7 @@ const currentDaysToEntries = createSelector(\n);\nexport {\n+ createEntryInfo,\ncolorIsDark,\nonScreenThreadInfos,\ntypeaheadSortedThreadInfos,\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/types/entry-types.js",
"new_path": "lib/types/entry-types.js",
"diff": "import PropTypes from 'prop-types';\n+export type RawEntryInfo = {|\n+ id?: string, // null if local copy without ID yet\n+ localID?: string, // for optimistic creations\n+ threadID: string,\n+ text: string,\n+ year: number,\n+ month: number, // 1-indexed\n+ day: number, // 1-indexed\n+ creationTime: number, // millisecond timestamp\n+ creatorID: string,\n+ deleted: bool,\n+|};\n+\n+export const rawEntryInfoPropType = PropTypes.shape({\n+ id: PropTypes.string,\n+ localID: PropTypes.string,\n+ threadID: PropTypes.string.isRequired,\n+ text: PropTypes.string.isRequired,\n+ year: PropTypes.number.isRequired,\n+ month: PropTypes.number.isRequired,\n+ day: PropTypes.number.isRequired,\n+ creationTime: PropTypes.number.isRequired,\n+ creatorID: PropTypes.string.isRequired,\n+ deleted: PropTypes.bool.isRequired,\n+});\n+\nexport type EntryInfo = {|\nid?: string, // null if local copy without ID yet\nlocalID?: string, // for optimistic creations\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/types/history-types.js",
"new_path": "lib/types/history-types.js",
"diff": "@@ -4,6 +4,25 @@ import PropTypes from 'prop-types';\nexport type HistoryMode = \"day\" | \"entry\";\n+export type RawHistoryRevisionInfo = {|\n+ id: string,\n+ entryID: string,\n+ authorID: string,\n+ text: string,\n+ lastUpdate: number,\n+ deleted: bool,\n+ threadID: string,\n+|};\n+export const rawHistoryRevisionInfoPropType = PropTypes.shape({\n+ id: PropTypes.string.isRequired,\n+ entryID: PropTypes.string.isRequired,\n+ authorID: PropTypes.string.isRequired,\n+ text: PropTypes.string.isRequired,\n+ lastUpdate: PropTypes.number.isRequired,\n+ deleted: PropTypes.bool.isRequired,\n+ threadID: PropTypes.string.isRequired,\n+});\n+\nexport type HistoryRevisionInfo = {|\nid: string,\nentryID: string,\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/types/redux-types.js",
"new_path": "lib/types/redux-types.js",
"diff": "// @flow\nimport type { ThreadInfo } from './thread-types';\n-import type { EntryInfo } from './entry-types';\n+import type { RawEntryInfo } from './entry-types';\nimport type { LoadingStatus, LoadingInfo } from './loading-types';\nimport type { BaseNavInfo } from './nav-types';\nimport type { CurrentUserInfo, UserInfo } from './user-types';\n@@ -27,7 +27,7 @@ export type BaseAppState = {\n+navInfo: BaseNavInfo,\ncurrentUserInfo: ?CurrentUserInfo,\nsessionID: string,\n- entryInfos: {[id: string]: EntryInfo},\n+ entryInfos: {[id: string]: RawEntryInfo},\ndaysToEntries: {[day: string]: string[]},\nlastUserInteraction: {[section: string]: number},\nthreadInfos: {[id: string]: ThreadInfo},\n@@ -63,7 +63,7 @@ export type BaseAction =\nloadingInfo: LoadingInfo,\n|} | {|\ntype: \"FETCH_ENTRIES_SUCCESS\",\n- payload: EntryInfo[],\n+ payload: RawEntryInfo[],\nloadingInfo: LoadingInfo,\n|} | {|\ntype: \"LOG_OUT_STARTED\",\n@@ -91,7 +91,7 @@ export type BaseAction =\nloadingInfo: LoadingInfo,\n|} | {|\ntype: \"CREATE_LOCAL_ENTRY\",\n- payload: EntryInfo,\n+ payload: RawEntryInfo,\n|} | {|\ntype: \"SAVE_ENTRY_STARTED\",\nloadingInfo: LoadingInfo,\n"
},
{
"change_type": "MODIFY",
"old_path": "native/calendar/thread-picker.react.js",
"new_path": "native/calendar/thread-picker.react.js",
"diff": "@@ -16,6 +16,7 @@ import {\n} from 'react-native';\nimport Icon from 'react-native-vector-icons/FontAwesome';\nimport { connect } from 'react-redux';\n+import invariant from 'invariant';\nimport { onScreenThreadInfos } from 'lib/selectors/thread-selectors';\nimport {\n@@ -33,7 +34,7 @@ class ThreadPicker extends React.PureComponent {\nclose: () => void,\n// Redux state\nonScreenThreadInfos: $ReadOnlyArray<ThreadInfo>,\n- username: ?string,\n+ userID: string,\n// Redux dispatch functions\ndispatchActionPayload: (actionType: string, payload: *) => void,\n};\n@@ -41,7 +42,7 @@ class ThreadPicker extends React.PureComponent {\ndateString: PropTypes.string.isRequired,\nclose: PropTypes.func.isRequired,\nonScreenThreadInfos: PropTypes.arrayOf(threadInfoPropType).isRequired,\n- username: PropTypes.string,\n+ userID: PropTypes.string.isRequired,\ndispatchActionPayload: PropTypes.func.isRequired,\n};\n@@ -107,7 +108,7 @@ class ThreadPicker extends React.PureComponent {\nthis.props.close();\nthis.props.dispatchActionPayload(\ncreateLocalEntryActionType,\n- createLocalEntry(threadID, this.props.dateString, this.props.username),\n+ createLocalEntry(threadID, this.props.dateString, this.props.userID),\n);\n}\n@@ -175,9 +176,13 @@ const styles = StyleSheet.create({\n});\nexport default connect(\n- (state: AppState) => ({\n+ (state: AppState) => {\n+ const userID = state.currentUserInfo && state.currentUserInfo.id;\n+ invariant(userID, \"should be logged in to use ThreadPicker\");\n+ return {\nonScreenThreadInfos: onScreenThreadInfos(state),\n- username: state.currentUserInfo && state.currentUserInfo.username,\n- }),\n+ userID,\n+ };\n+ },\nincludeDispatchActionProps,\n)(ThreadPicker);\n"
},
{
"change_type": "MODIFY",
"old_path": "native/package-lock.json",
"new_path": "native/package-lock.json",
"diff": "\"integrity\": \"sha1-yQOmR7bTZHU/dGbkOoVRCqwqUeg=\"\n},\n\"react-native-tab-view\": {\n- \"version\": \"0.0.65\",\n- \"resolved\": \"https://registry.npmjs.org/react-native-tab-view/-/react-native-tab-view-0.0.65.tgz\",\n- \"integrity\": \"sha1-toXqMIH/fJZIbNmXNhAmxAcwLFk=\"\n+ \"version\": \"0.0.66\",\n+ \"resolved\": \"https://registry.npmjs.org/react-native-tab-view/-/react-native-tab-view-0.0.66.tgz\",\n+ \"integrity\": \"sha1-aBqRvw5xTekrvVJVg5/Alvz/S7U=\"\n},\n\"react-native-vector-icons\": {\n\"version\": \"4.2.0\",\n\"integrity\": \"sha1-BZS2jevddY3OTFZb8C4tZNcATYI=\"\n},\n\"react-navigation\": {\n- \"version\": \"1.0.0-beta.11\",\n- \"resolved\": \"https://registry.npmjs.org/react-navigation/-/react-navigation-1.0.0-beta.11.tgz\",\n- \"integrity\": \"sha1-QnHtsjzbzG64hgL3/eCnfw73oWA=\"\n+ \"version\": \"git+https://github.com/ashoat/react-navigation.git#094a9cc47dfaf779ce16621c193aaf8d92f59ef8\"\n},\n\"react-proxy\": {\n\"version\": \"1.1.8\",\n"
},
{
"change_type": "MODIFY",
"old_path": "native/package.json",
"new_path": "native/package.json",
"diff": "\"react-native-keychain\": \"^1.2.0\",\n\"react-native-onepassword\": \"^1.0.4\",\n\"react-native-vector-icons\": \"^4.2.0\",\n- \"react-navigation\": \"^1.0.0-beta.11\",\n+ \"react-navigation\": \"git+https://github.com/ashoat/react-navigation.git\",\n\"react-redux\": \"^5.0.5\",\n\"redux\": \"^3.7.0\",\n\"redux-persist\": \"^4.8.1\",\n"
},
{
"change_type": "MODIFY",
"old_path": "native/redux-setup.js",
"new_path": "native/redux-setup.js",
"diff": "// @flow\nimport type { ThreadInfo } from 'lib/types/thread-types';\n-import type { EntryInfo } from 'lib/types/entry-types';\n+import type { RawEntryInfo } from 'lib/types/entry-types';\nimport type { LoadingStatus } from 'lib/types/loading-types';\nimport type { CurrentUserInfo, UserInfo } from 'lib/types/user-types';\nimport type { MessageStore } from 'lib/types/message-types';\n@@ -30,7 +30,7 @@ export type AppState = {|\nnavInfo: NavInfo,\ncurrentUserInfo: ?CurrentUserInfo,\nsessionID: string,\n- entryInfos: {[id: string]: EntryInfo},\n+ entryInfos: {[id: string]: RawEntryInfo},\ndaysToEntries: {[day: string]: string[]},\nlastUserInteraction: {[section: string]: number},\nthreadInfos: {[id: string]: ThreadInfo},\n"
},
{
"change_type": "MODIFY",
"old_path": "web/app.react.js",
"new_path": "web/app.react.js",
"diff": "@@ -7,7 +7,6 @@ import type {\nDispatchActionPayload,\nDispatchActionPromise,\n} from 'lib/utils/action-utils';\n-import type { EntryInfo } from 'lib/types/entry-types';\nimport type { VerifyField } from 'lib/utils/verify-utils';\nimport type { CalendarResult } from 'lib/actions/entry-actions';\nimport type { CalendarQuery } from 'lib/selectors/nav-selectors';\n"
},
{
"change_type": "MODIFY",
"old_path": "web/calendar/day.react.js",
"new_path": "web/calendar/day.react.js",
"diff": "@@ -40,7 +40,7 @@ type Props = {\nstartingTabIndex: number,\n// Redux state\nonScreenThreadInfos: ThreadInfo[],\n- username: ?string,\n+ userID: string,\nloggedIn: bool,\n// Redux dispatch functions\ndispatchActionPayload: (actionType: string, payload: *) => void,\n@@ -248,7 +248,7 @@ class Day extends React.PureComponent {\ncreateLocalEntry(\nthreadID,\nthis.props.dayString,\n- this.props.username,\n+ this.props.userID,\n),\n);\n}\n@@ -284,16 +284,20 @@ Day.propTypes = {\nclearModal: PropTypes.func.isRequired,\nstartingTabIndex: PropTypes.number.isRequired,\nonScreenThreadInfos: PropTypes.arrayOf(threadInfoPropType).isRequired,\n- username: PropTypes.string,\n+ userID: PropTypes.string.isRequired,\nloggedIn: PropTypes.bool.isRequired,\ndispatchActionPayload: PropTypes.func.isRequired,\n};\nexport default connect(\n- (state: AppState) => ({\n+ (state: AppState) => {\n+ const userID = state.currentUserInfo && state.currentUserInfo.id;\n+ invariant(userID, \"should be logged in to use ThreadPicker\");\n+ return {\nonScreenThreadInfos: onScreenThreadInfos(state),\n- username: state.currentUserInfo && state.currentUserInfo.username,\n+ userID,\nloggedIn: !!state.currentUserInfo,\n- }),\n+ };\n+ },\nincludeDispatchActionProps,\n)(Day);\n"
},
{
"change_type": "MODIFY",
"old_path": "web/redux-setup.js",
"new_path": "web/redux-setup.js",
"diff": "import type { BaseNavInfo } from 'lib/types/nav-types';\nimport type { ThreadInfo } from 'lib/types/thread-types';\n-import type { EntryInfo } from 'lib/types/entry-types';\n+import type { RawEntryInfo } from 'lib/types/entry-types';\nimport type { BaseAction } from 'lib/types/redux-types';\nimport type { LoadingStatus } from 'lib/types/loading-types';\nimport type { CurrentUserInfo, UserInfo } from 'lib/types/user-types';\n@@ -32,7 +32,7 @@ export type AppState = {|\nsessionID: string,\nverifyField: ?VerifyField,\nresetPasswordUsername: string,\n- entryInfos: {[id: string]: EntryInfo},\n+ entryInfos: {[id: string]: RawEntryInfo},\ndaysToEntries: {[day: string]: string[]},\nlastUserInteraction: {[section: string]: number},\nthreadInfos: {[id: string]: ThreadInfo},\n"
},
{
"change_type": "MODIFY",
"old_path": "web/script.js",
"new_path": "web/script.js",
"diff": "@@ -5,7 +5,7 @@ import 'isomorphic-fetch';\nimport type { Store } from 'redux';\nimport type { ThreadInfo } from 'lib/types/thread-types';\n-import type { EntryInfo } from 'lib/types/entry-types';\n+import type { RawEntryInfo } from 'lib/types/entry-types';\nimport type {\nRawMessageInfo,\nMessageTruncationStatus,\n@@ -45,7 +45,7 @@ declare var username: string;\ndeclare var email: string;\ndeclare var email_verified: bool;\ndeclare var thread_infos: {[id: string]: ThreadInfo};\n-declare var entry_infos: EntryInfo[];\n+declare var entry_infos: RawEntryInfo[];\ndeclare var month: number;\ndeclare var year: number;\ndeclare var verify_code: ?string;\n"
},
{
"change_type": "MODIFY",
"old_path": "web/selectors/entry-selectors.js",
"new_path": "web/selectors/entry-selectors.js",
"diff": "// @flow\nimport type { AppState } from '../redux-setup';\n-import type { EntryInfo } from 'lib/types/entry-types';\n+import type { RawEntryInfo } from 'lib/types/entry-types';\n+import type { UserInfo } from 'lib/types/user-types';\nimport { createSelector } from 'reselect';\nimport _mapValues from 'lodash/fp/mapValues';\n@@ -9,15 +10,24 @@ import _flow from 'lodash/fp/flow';\nimport _map from 'lodash/fp/map';\nimport _compact from 'lodash/fp/compact';\n+import { createEntryInfo } from 'lib/selectors/thread-selectors';\n+\nconst allDaysToEntries = createSelector(\n(state: AppState) => state.entryInfos,\n(state: AppState) => state.daysToEntries,\n+ (state: AppState) => state.userInfos,\n+ (state: AppState) => state.currentUserInfo && state.currentUserInfo.id,\n(\n- entryInfos: {[id: string]: EntryInfo},\n+ entryInfos: {[id: string]: RawEntryInfo},\ndaysToEntries: {[day: string]: string[]},\n+ userInfos: {[id: string]: UserInfo},\n+ viewerID: ?string,\n) => _mapValues((entryIDs: string[]) =>\n_flow(\n- _map((entryID: string) => entryInfos[entryID]),\n+ _map(\n+ (entryID: string) =>\n+ createEntryInfo(entryInfos[entryID], viewerID, userInfos),\n+ ),\n_compact,\n)(entryIDs),\n)(daysToEntries),\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Source all EntryInfo creator names from userInfos |
129,187 | 10.07.2017 14:08:37 | 14,400 | ae82b2836647826222ab4bc61789b1f822affb7e | Update actions and reducers to keep userInfos in sync in parallel with entryInfos | [
{
"change_type": "MODIFY",
"old_path": "lib/actions/entry-actions.js",
"new_path": "lib/actions/entry-actions.js",
"diff": "@@ -5,10 +5,15 @@ import type { RawEntryInfo } from '../types/entry-types';\nimport type { FetchJSON } from '../utils/fetch-json';\nimport type { HistoryRevisionInfo } from '../types/history-types';\nimport type { CalendarQuery } from '../selectors/nav-selectors';\n+import type { UserInfo } from '../types/user-types';\nimport { dateFromString } from '../utils/date-utils'\nimport { getNewLocalID } from '../utils/local-ids';\n+export type FetchEntriesResult = {\n+ entryInfos: RawEntryInfo[],\n+ userInfos: UserInfo[],\n+};\nconst fetchEntriesActionTypes = {\nstarted: \"FETCH_ENTRIES_STARTED\",\nsuccess: \"FETCH_ENTRIES_SUCCESS\",\n@@ -17,19 +22,23 @@ const fetchEntriesActionTypes = {\nasync function fetchEntries(\nfetchJSON: FetchJSON,\ncalendarQuery: CalendarQuery,\n-): Promise<RawEntryInfo[]> {\n+): Promise<FetchEntriesResult> {\nconst response = await fetchJSON('fetch_entries.php', {\n'nav': calendarQuery.navID,\n'start_date': calendarQuery.startDate,\n'end_date': calendarQuery.endDate,\n'include_deleted': !!calendarQuery.includeDeleted,\n});\n- return response.result;\n+ return {\n+ entryInfos: response.entry_infos,\n+ userInfos: response.user_infos,\n+ };\n}\nexport type CalendarResult = {\nentryInfos: RawEntryInfo[],\ncalendarQuery: CalendarQuery,\n+ userInfos: UserInfo[],\n};\nconst fetchEntriesAndSetRangeActionTypes = {\nstarted: \"FETCH_ENTRIES_AND_SET_RANGE_STARTED\",\n@@ -45,8 +54,12 @@ async function fetchEntriesWithRange(\nfetchJSON: FetchJSON,\ncalendarQuery: CalendarQuery,\n): Promise<CalendarResult> {\n- const entryInfos = await fetchEntries(fetchJSON, calendarQuery);\n- return { entryInfos, calendarQuery };\n+ const fetchEntriesResult = await fetchEntries(fetchJSON, calendarQuery);\n+ return {\n+ entryInfos: fetchEntriesResult.entryInfos,\n+ calendarQuery,\n+ userInfos: fetchEntriesResult.userInfos,\n+ };\n}\nconst createLocalEntryActionType = \"CREATE_LOCAL_ENTRY\";\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/actions/ping-actions.js",
"new_path": "lib/actions/ping-actions.js",
"diff": "@@ -37,6 +37,7 @@ async function ping(\ncalendarResult: {\ncalendarQuery,\nentryInfos: response.entries,\n+ userInfos: response.user_infos,\n},\nmessagesResult: {\nmessageInfos: response.message_infos,\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/actions/user-actions.js",
"new_path": "lib/actions/user-actions.js",
"diff": "@@ -127,6 +127,7 @@ async function logInAndFetchInitialData(\ncalendarResult: {\ncalendarQuery,\nentryInfos: response.entries,\n+ userInfos: response.user_infos,\n},\nmessagesResult: {\nmessageInfos: response.message_infos,\n@@ -197,6 +198,7 @@ async function resetPasswordAndFetchInitialData(\ncalendarResult: {\ncalendarQuery,\nentryInfos: response.entries,\n+ userInfos: response.user_infos,\n},\nmessagesResult: {\nmessageInfos: response.message_infos,\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/reducers/entry-reducer.js",
"new_path": "lib/reducers/entry-reducer.js",
"diff": "@@ -157,7 +157,7 @@ function reduceEntryInfos(\nconst [updatedEntryInfos, updatedDaysToEntries] = mergeNewEntryInfos(\nentryInfos,\ndaysToEntries,\n- action.payload,\n+ action.payload.entryInfos,\n);\nreturn [\nupdatedEntryInfos,\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/reducers/user-reducer.js",
"new_path": "lib/reducers/user-reducer.js",
"diff": "@@ -46,7 +46,10 @@ function reduceUserInfos(\naction.type === \"RESET_PASSWORD_SUCCESS\" ||\naction.type === \"PING_SUCCESS\" ||\naction.type === \"AUTH_THREAD_SUCCESS\" ||\n- action.type === \"FETCH_MESSAGES_SUCCESS\"\n+ action.type === \"FETCH_MESSAGES_SUCCESS\" ||\n+ action.type === \"FETCH_ENTRIES_AND_SET_RANGE_SUCCESS\" ||\n+ action.type === \"FETCH_ENTRIES_AND_APPEND_RANGE_SUCCESS\" ||\n+ action.type === \"FETCH_ENTRIES_SUCCESS\"\n) {\nreturn {\n...state,\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/types/redux-types.js",
"new_path": "lib/types/redux-types.js",
"diff": "@@ -14,7 +14,10 @@ import type {\nPingStartingPayload,\nPingSuccessPayload,\n} from '../types/ping-types';\n-import type { CalendarResult } from '../actions/entry-actions';\n+import type {\n+ FetchEntriesResult,\n+ CalendarResult,\n+} from '../actions/entry-actions';\nimport type { CalendarQuery } from '../selectors/nav-selectors';\nimport type { MessageStore, RawTextMessageInfo } from './message-types';\nimport type { PageMessagesResult } from '../actions/message-actions';\n@@ -63,7 +66,7 @@ export type BaseAction =\nloadingInfo: LoadingInfo,\n|} | {|\ntype: \"FETCH_ENTRIES_SUCCESS\",\n- payload: RawEntryInfo[],\n+ payload: FetchEntriesResult,\nloadingInfo: LoadingInfo,\n|} | {|\ntype: \"LOG_OUT_STARTED\",\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Update actions and reducers to keep userInfos in sync in parallel with entryInfos |
129,187 | 11.07.2017 10:35:36 | 14,400 | 119178fb34e2220148f3b7463d245a171aa10066 | Fix three bugs on native | [
{
"change_type": "MODIFY",
"old_path": "native/app.react.js",
"new_path": "native/app.react.js",
"diff": "@@ -74,11 +74,6 @@ registerConfig({\ncalendarRangeInactivityLimit: sessionInactivityLimit,\n});\n-if (Platform.OS === \"android\") {\n- UIManager.setLayoutAnimationEnabledExperimental &&\n- UIManager.setLayoutAnimationEnabledExperimental(true);\n-}\n-\n// We can't push yet, so we rely on pings to keep Redux state updated with the\n// server. As a result, we do them fairly frequently (once every 3s) while the\n// app is active and the user is logged in.\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/message.react.js",
"new_path": "native/chat/message.react.js",
"diff": "@@ -155,10 +155,7 @@ class InnerMessage extends React.PureComponent {\nonResponderGrant={this.onResponderGrant}\nonResponderTerminationRequest={this.onResponderTerminationRequest}\n>\n- <Text\n- numberOfLines={1}\n- style={[styles.text, textStyle]}\n- >{text}</Text>\n+ <Text style={[styles.text, textStyle]}>{text}</Text>\n</View>\n</View>\n</View>\n"
},
{
"change_type": "MODIFY",
"old_path": "server/send_message.php",
"new_path": "server/send_message.php",
"diff": "@@ -31,10 +31,11 @@ $time = round(microtime(true) * 1000); // in milliseconds\n$conn->query(\"INSERT INTO ids(table_name) VALUES('messages')\");\n$id = $conn->insert_id;\n-$conn->query(\n- \"INSERT INTO messages(id, thread, user, type, text, time) \".\n- \"VALUES ($id, $thread, $viewer_id, 0, '$text', $time)\"\n-);\n+$insert_query = <<<SQL\n+INSERT INTO messages(id, thread, user, type, content, time)\n+VALUES ({$id}, {$thread}, {$viewer_id}, 0, '{$text}', {$time})\n+SQL;\n+$conn->query($insert_query);\nasync_end(array(\n'success' => true,\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Fix three bugs on native |
129,187 | 11.07.2017 11:34:19 | 14,400 | d6183ab88271dd2ce7a65e7d1c264d9678bc2c66 | Fix some bugs regarding how the Calendar is scrolled to avoid the keyboard on Android | [
{
"change_type": "MODIFY",
"old_path": "native/calendar/calendar.react.js",
"new_path": "native/calendar/calendar.react.js",
"diff": "@@ -101,6 +101,7 @@ type State = {\nreadyToShowList: bool,\npickerOpenForDateString: ?string,\nextraData: ExtraData,\n+ scrollToOffsetAfterSuppressingKeyboardDismissal: ?number,\n};\nclass InnerCalendar extends React.PureComponent {\n@@ -158,6 +159,7 @@ class InnerCalendar extends React.PureComponent {\n// once the keyboard event happens, we know where to move the scrollPos to\nlastEntryKeyFocused: ?string = null;\nkeyboardShowListener: ?Object;\n+ keyboardDismissListener: ?Object;\nkeyboardShownHeight: ?number = null;\n// We wait until the loaders leave view before letting them be triggered again\ntopLoaderWaitingToLeaveView = true;\n@@ -178,6 +180,7 @@ class InnerCalendar extends React.PureComponent {\nreadyToShowList: false,\npickerOpenForDateString: null,\nextraData: this.latestExtraData,\n+ scrollToOffsetAfterSuppressingKeyboardDismissal: null,\n};\n}\n@@ -199,6 +202,10 @@ class InnerCalendar extends React.PureComponent {\nPlatform.OS === \"ios\" ? \"keyboardWillShow\" : \"keyboardDidShow\",\nthis.keyboardShow,\n);\n+ this.keyboardDismissListener = Keyboard.addListener(\n+ Platform.OS === \"ios\" ? \"keyboardWillHide\" : \"keyboardDidHide\",\n+ this.keyboardDismiss,\n+ );\n}\n}\n@@ -282,23 +289,29 @@ class InnerCalendar extends React.PureComponent {\n}\ncomponentWillUpdate(nextProps: Props, nextState: State) {\n- if (\n- nextProps.tabActive &&\n- !this.props.tabActive &&\n- !this.keyboardShowListener\n- ) {\n+ if (nextProps.tabActive && !this.props.tabActive) {\n+ if (!this.keyboardShowListener) {\nthis.keyboardShowListener = Keyboard.addListener(\nPlatform.OS === \"ios\" ? \"keyboardWillShow\" : \"keyboardDidShow\",\nthis.keyboardShow,\n);\n- } else if (\n- !nextProps.tabActive &&\n- this.props.tabActive &&\n- this.keyboardShowListener\n- ) {\n+ }\n+ if (!this.keyboardDismissListener) {\n+ this.keyboardDismissListener = Keyboard.addListener(\n+ Platform.OS === \"ios\" ? \"keyboardWillHide\" : \"keyboardDidHide\",\n+ this.keyboardDismiss,\n+ );\n+ }\n+ } else if (!nextProps.tabActive && this.props.tabActive) {\n+ if (this.keyboardShowListener) {\nthis.keyboardShowListener.remove();\nthis.keyboardShowListener = null;\n}\n+ if (this.keyboardDismissListener) {\n+ this.keyboardDismissListener.remove();\n+ this.keyboardDismissListener = null;\n+ }\n+ }\n// If the sessionID gets reset and the user isn't looking we scroll to today\nif (\n@@ -333,6 +346,29 @@ class InnerCalendar extends React.PureComponent {\n}\ncomponentDidUpdate(prevProps: Props, prevState: State) {\n+ // On Android, if the keyboardDismissMode is set to \"on-drag\", our attempt\n+ // to scroll the FlatList to avoid the keyboard when the keyboard is being\n+ // shown can cause the keyboard to immediately get dismissed. To avoid this,\n+ // we make sure to temporarily set the keyboardDismissMode to \"none\" when\n+ // doing this scroll. Only after that do we execute the scroll, and we make\n+ // sure to reset keyboardDismissMode 0.5s after the scroll starts.\n+ const newOffset =\n+ this.state.scrollToOffsetAfterSuppressingKeyboardDismissal;\n+ const oldOffset = prevState.scrollToOffsetAfterSuppressingKeyboardDismissal;\n+ if (\n+ (newOffset !== undefined && newOffset !== null) &&\n+ (oldOffset === undefined || oldOffset === null)\n+ ) {\n+ invariant(this.flatList, \"flatList should be set\");\n+ this.flatList.scrollToOffset({ offset: newOffset, animated: true });\n+ setTimeout(\n+ () => this.setState({\n+ scrollToOffsetAfterSuppressingKeyboardDismissal: null,\n+ }),\n+ 500,\n+ );\n+ }\n+\nconst lastLDWH = prevState.listDataWithHeights;\nconst newLDWH = this.state.listDataWithHeights;\nif (!lastLDWH || !newLDWH) {\n@@ -563,6 +599,12 @@ class InnerCalendar extends React.PureComponent {\nconst flatListStyle = { opacity: this.state.readyToShowList ? 1 : 0 };\nconst initialScrollIndex =\nInnerCalendar.initialScrollIndex(listDataWithHeights);\n+ const pendingScrollOffset =\n+ this.state.scrollToOffsetAfterSuppressingKeyboardDismissal;\n+ const keyboardDismissMode =\n+ pendingScrollOffset !== null && pendingScrollOffset !== undefined\n+ ? \"none\"\n+ : \"on-drag\";\nflatList = (\n<FlatList\ndata={listDataWithHeights}\n@@ -573,7 +615,7 @@ class InnerCalendar extends React.PureComponent {\nonScroll={this.onScroll}\ninitialScrollIndex={initialScrollIndex}\nkeyboardShouldPersistTaps=\"handled\"\n- keyboardDismissMode=\"on-drag\"\n+ keyboardDismissMode={keyboardDismissMode}\nonMomentumScrollEnd={this.onMomentumScrollEnd}\nonScrollEndDrag={this.onScrollEndDrag}\nextraData={this.state.extraData}\n@@ -696,6 +738,10 @@ class InnerCalendar extends React.PureComponent {\n}\n}\n+ keyboardDismiss = (event: KeyboardEvent) => {\n+ this.keyboardShownHeight = null;\n+ }\n+\nscrollToKey(lastEntryKeyFocused: string, keyboardHeight: number) {\nconst data = this.state.listDataWithHeights;\ninvariant(data, \"should be set\");\n@@ -721,11 +767,18 @@ class InnerCalendar extends React.PureComponent {\n) {\nreturn;\n}\n- invariant(this.flatList, \"flatList should be set\");\n- this.flatList.scrollToOffset({\n- offset: itemStart - (visibleHeight - itemHeight) / 2,\n- animated: true,\n+ const offset = itemStart - (visibleHeight - itemHeight) / 2;\n+ if (Platform.OS === \"android\") {\n+ // On Android, we need to wait for the keyboardDismissMode to be updated\n+ // before executing this scroll. See the comment in componentDidUpdate for\n+ // more details\n+ this.setState({\n+ scrollToOffsetAfterSuppressingKeyboardDismissal: offset,\n});\n+ return;\n+ }\n+ invariant(this.flatList, \"flatList should be set\");\n+ this.flatList.scrollToOffset({ offset, animated: true });\n}\nallHeightsMeasured = (\n"
},
{
"change_type": "MODIFY",
"old_path": "native/calendar/entry.react.js",
"new_path": "native/calendar/entry.react.js",
"diff": "@@ -314,6 +314,7 @@ class Entry extends React.Component {\n} else if (this.props.entryInfo.text !== this.state.text) {\nthis.save(this.props.entryInfo.id, this.state.text);\n}\n+ this.props.onFocus(entryKey(this.props.entryInfo), false);\n}\nonContentSizeChange = (event) => {\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Fix some bugs regarding how the Calendar is scrolled to avoid the keyboard on Android |
129,187 | 12.07.2017 22:18:59 | 14,400 | 31adadd66e2f722f1e251a2378f027a45b576aa1 | Handle new message types in MessagePreview | [
{
"change_type": "MODIFY",
"old_path": "lib/shared/message-utils.js",
"new_path": "lib/shared/message-utils.js",
"diff": "@@ -4,6 +4,8 @@ import type { MessageInfo, RawMessageInfo } from '../types/message-types';\nimport invariant from 'invariant';\n+import { messageType } from '../types/message-types';\n+\n// Prefers localID\nfunction messageKey(messageInfo: MessageInfo | RawMessageInfo): string {\nif (messageInfo.type === 0 && messageInfo.localID) {\n@@ -23,4 +25,43 @@ function messageID(messageInfo: MessageInfo | RawMessageInfo): string {\nreturn messageInfo.localID;\n}\n-export { messageKey, messageID }\n+function robotextForMessageInfo(messageInfo: MessageInfo): [string, string] {\n+ invariant(\n+ messageInfo.type !== messageType.TEXT,\n+ \"robotext is no substitute for human text!\",\n+ );\n+ let creator;\n+ if (messageInfo.isViewer) {\n+ creator = \"you\";\n+ } else if (messageInfo.creator) {\n+ creator = messageInfo.creator;\n+ } else {\n+ creator = \"anonymous\";\n+ }\n+ if (messageInfo.type === messageType.CREATE_THREAD) {\n+ return [creator, \"created the thread\"];\n+ } else if (messageInfo.type === messageType.ADD_USER) {\n+ const usernames = messageInfo.addedUsernames;\n+ invariant(usernames.length !== 0, \"added who??\");\n+ let addedUsersString;\n+ if (usernames.length === 1) {\n+ addedUsersString = usernames[0];\n+ } else if (usernames.length === 2) {\n+ addedUsersString = `${usernames[0]} and ${usernames[1]}`;\n+ } else if (usernames.length === 3) {\n+ addedUsersString =\n+ `${usernames[0]}, ${usernames[1]}, and ${usernames[2]}`;\n+ } else {\n+ addedUsersString = `${usernames[0]}, ${usernames[1]}, ` +\n+ `and ${usernames.length - 2} others`;\n+ }\n+ return [creator, `added ${addedUsersString}`];\n+ }\n+ invariant(false, `${messageInfo.type} is not a messageType!`);\n+}\n+\n+export {\n+ messageKey,\n+ messageID,\n+ robotextForMessageInfo,\n+};\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/message-preview.react.js",
"new_path": "native/chat/message-preview.react.js",
"diff": "@@ -8,6 +8,7 @@ import PropTypes from 'prop-types';\nimport { StyleSheet, Text } from 'react-native';\nimport { messageType } from 'lib/types/message-types';\n+import { robotextForMessageInfo } from 'lib/shared/message-utils';\nclass MessagePreview extends React.PureComponent {\n@@ -31,10 +32,12 @@ class MessagePreview extends React.PureComponent {\n</Text>\n);\n} else {\n- // TODO actually handle all cases\n+ const [actor, robotext] = robotextForMessageInfo(messageInfo);\nreturn (\n- <Text style={styles.lastMessage} numberOfLines={1}>\n- Test\n+ <Text style={[styles.lastMessage, styles.robotext]} numberOfLines={1}>\n+ {actor}\n+ {\" \"}\n+ {robotext}\n</Text>\n);\n}\n@@ -51,6 +54,9 @@ const styles = StyleSheet.create({\nusername: {\ncolor: '#AAAAAA',\n},\n+ robotext: {\n+ color: '#AAAAAA',\n+ },\n});\nexport default MessagePreview;\n"
},
{
"change_type": "MODIFY",
"old_path": "native/selectors/chat-selectors.js",
"new_path": "native/selectors/chat-selectors.js",
"diff": "@@ -55,6 +55,14 @@ function createMessageInfo(\ntime: rawMessageInfo.time,\n};\n} else if (rawMessageInfo.type === messageType.ADD_USER) {\n+ const addedUsernames = [];\n+ for (let userID of rawMessageInfo.addedUserIDs) {\n+ if (userID === viewerID) {\n+ addedUsernames.unshift(\"you\");\n+ } else {\n+ addedUsernames.push(userInfos[userID].username);\n+ }\n+ }\nreturn {\ntype: messageType.ADD_USER,\nid: rawMessageInfo.id,\n@@ -62,7 +70,7 @@ function createMessageInfo(\ncreator: creatorInfo.username,\nisViewer: rawMessageInfo.creatorID === viewerID,\ntime: rawMessageInfo.time,\n- addedUsernames: rawMessageInfo.addedUserIDs,\n+ addedUsernames,\n};\n}\ninvariant(false, `${rawMessageInfo.type} is not a messageType!`);\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Handle new message types in MessagePreview |
129,187 | 13.07.2017 12:01:28 | 14,400 | 9e5e27720ceb36217b25506c182cbca7b4d09d84 | Extend TextHeightMeasurer to be able to handle different styles for individual entries | [
{
"change_type": "MODIFY",
"old_path": "native/calendar/calendar.react.js",
"new_path": "native/calendar/calendar.react.js",
"diff": "@@ -9,6 +9,7 @@ import type { DispatchActionPromise } from 'lib/utils/action-utils';\nimport type { CalendarResult } from 'lib/actions/entry-actions';\nimport type { CalendarQuery } from 'lib/selectors/nav-selectors';\nimport type { KeyboardEvent } from '../keyboard';\n+import type { TextToMeasure } from '../text-height-measurer.react';\nimport React from 'react';\nimport {\n@@ -96,7 +97,7 @@ type ExtraData = {\nvisibleEntries: {[key: string]: bool},\n};\ntype State = {\n- textToMeasure: string[],\n+ textToMeasure: TextToMeasure[],\nlistDataWithHeights: ?$ReadOnlyArray<CalendarItemWithHeight>,\nreadyToShowList: bool,\npickerOpenForDateString: ?string,\n@@ -145,7 +146,7 @@ class InnerCalendar extends React.PureComponent {\n),\n};\nflatList: ?FlatList<CalendarItemWithHeight> = null;\n- textHeights: ?{ [text: string]: number } = null;\n+ textHeights: ?Map<string, number> = null;\ncurrentState: ?string = NativeAppState.currentState;\nloadingFromScroll = false;\ncurrentScrollPosition: ?number = null;\n@@ -190,7 +191,10 @@ class InnerCalendar extends React.PureComponent {\nif (item.itemType !== \"entryInfo\") {\ncontinue;\n}\n- textToMeasure.push(item.entryInfo.text);\n+ textToMeasure.push({\n+ id: entryKey(item.entryInfo),\n+ text: item.entryInfo.text,\n+ });\n}\nreturn textToMeasure;\n}\n@@ -259,8 +263,8 @@ class InnerCalendar extends React.PureComponent {\nlet allTextAlreadyMeasured = false;\nif (this.textHeights) {\nallTextAlreadyMeasured = true;\n- for (let text of newTextToMeasure) {\n- if (this.textHeights[text] === undefined) {\n+ for (let textToMeasure of newTextToMeasure) {\n+ if (!this.textHeights.has(textToMeasure.id)) {\nallTextAlreadyMeasured = false;\nbreak;\n}\n@@ -458,7 +462,7 @@ class InnerCalendar extends React.PureComponent {\nreturn item;\n}\nconst entryInfo = item.entryInfo;\n- const textHeight = textHeights[entryInfo.text];\n+ const textHeight = textHeights.get(entryKey(entryInfo));\ninvariant(\ntextHeight,\n`height for ${entryKey(entryInfo)} should be set`,\n@@ -782,8 +786,8 @@ class InnerCalendar extends React.PureComponent {\n}\nallHeightsMeasured = (\n- textToMeasure: string[],\n- newTextHeights: { [text: string]: number },\n+ textToMeasure: TextToMeasure[],\n+ newTextHeights: Map<string, number>,\n) => {\nif (textToMeasure !== this.state.textToMeasure) {\nreturn;\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/message-list.react.js",
"new_path": "native/chat/message-list.react.js",
"diff": "@@ -16,6 +16,7 @@ import type { ViewToken } from 'react-native/Libraries/Lists/ViewabilityHelper';\nimport type { MessageInfo } from 'lib/types/message-types';\nimport type { DispatchActionPromise } from 'lib/utils/action-utils';\nimport type { PageMessagesResult } from 'lib/actions/message-actions';\n+import type { TextToMeasure } from '../text-height-measurer.react';\nimport React from 'react';\nimport { connect } from 'react-redux';\n@@ -30,8 +31,9 @@ import {\nimport { InvertibleFlatList } from 'react-native-invertible-flat-list';\nimport invariant from 'invariant';\nimport _sum from 'lodash/fp/sum';\n-import _difference from 'lodash/fp/difference';\n+import _differenceWith from 'lodash/fp/differenceWith';\nimport _find from 'lodash/fp/find';\n+import _isEqual from 'lodash/fp/isEqual';\nimport { messageKey } from 'lib/shared/message-utils';\nimport {\n@@ -80,7 +82,7 @@ type Props = {\n) => Promise<PageMessagesResult>,\n};\ntype State = {\n- textToMeasure: string[],\n+ textToMeasure: TextToMeasure[],\nlistDataWithHeights: ?$ReadOnlyArray<ChatMessageItemWithHeight>,\nfocusedMessageKey: ?string,\n};\n@@ -106,7 +108,7 @@ class InnerMessageList extends React.PureComponent {\ntitle: navigation.state.params.threadInfo.name,\nheaderRight: <AddThreadButton />,\n});\n- textHeights: ?{ [text: string]: number } = null;\n+ textHeights: ?Map<string, number> = null;\nloadingFromScroll = false;\nconstructor(props: Props) {\n@@ -132,7 +134,10 @@ class InnerMessageList extends React.PureComponent {\n// TODO actually measure textHeight\ncontinue;\n}\n- textToMeasure.push(messageInfo.text);\n+ textToMeasure.push({\n+ id: messageKey(messageInfo),\n+ text: messageInfo.text,\n+ });\n}\nreturn textToMeasure;\n}\n@@ -159,8 +164,8 @@ class InnerMessageList extends React.PureComponent {\nlet allTextAlreadyMeasured = false;\nif (this.textHeights) {\nallTextAlreadyMeasured = true;\n- for (let text of newTextToMeasure) {\n- if (this.textHeights[text] === undefined) {\n+ for (let textToMeasure of newTextToMeasure) {\n+ if (!this.textHeights.has(textToMeasure.id)) {\nallTextAlreadyMeasured = false;\nbreak;\n}\n@@ -172,7 +177,7 @@ class InnerMessageList extends React.PureComponent {\n}\nconst newText =\n- _difference(newTextToMeasure)(this.state.textToMeasure);\n+ _differenceWith(_isEqual)(newTextToMeasure)(this.state.textToMeasure);\nif (newText.length === 0) {\n// Since we don't have everything in textHeights, but we do have\n// everything in textToMeasure, we can conclude that we're just\n@@ -204,7 +209,8 @@ class InnerMessageList extends React.PureComponent {\ntextHeight: 0,\n}: ChatMessageInfoItemWithHeight);\n}\n- const textHeight = textHeights[messageInfoItem.messageInfo.text];\n+ const textHeight =\n+ textHeights.get(messageKey(messageInfoItem.messageInfo));\ninvariant(\ntextHeight,\n`height for ${messageKey(messageInfoItem.messageInfo)} should be set`,\n@@ -334,8 +340,8 @@ class InnerMessageList extends React.PureComponent {\n}\nallHeightsMeasured = (\n- textToMeasure: string[],\n- newTextHeights: { [text: string]: number },\n+ textToMeasure: TextToMeasure[],\n+ newTextHeights: Map<string, number>,\n) => {\nif (textToMeasure !== this.state.textToMeasure) {\nreturn;\n"
},
{
"change_type": "MODIFY",
"old_path": "native/text-height-measurer.react.js",
"new_path": "native/text-height-measurer.react.js",
"diff": "@@ -12,18 +12,23 @@ import _isEmpty from 'lodash/fp/isEmpty';\nconst measureBatchSize = 50;\n-type TextToHeight = { [text: string]: number };\n+export type TextToMeasure = {\n+ id: string,\n+ text: string,\n+ style?: StyleObj,\n+};\n+type TextToHeight = Map<string, number>;\ntype Props = {\n- textToMeasure: string[],\n+ textToMeasure: TextToMeasure[],\nallHeightsMeasuredCallback: (\n- textToMeasure: string[],\n+ textToMeasure: TextToMeasure[],\nheights: TextToHeight,\n) => void,\nminHeight?: number,\n- style: StyleObj,\n+ style?: StyleObj,\n};\ntype State = {\n- currentlyMeasuring: ?Set<string>,\n+ currentlyMeasuring: ?Set<TextToMeasure>,\n};\nclass TextHeightMeasurer extends React.PureComponent {\n@@ -32,15 +37,19 @@ class TextHeightMeasurer extends React.PureComponent {\ncurrentlyMeasuring: null,\n};\nstatic propTypes = {\n- textToMeasure: PropTypes.arrayOf(PropTypes.string).isRequired,\n+ textToMeasure: PropTypes.arrayOf(PropTypes.shape({\n+ id: PropTypes.string.isRequired,\n+ text: PropTypes.string.isRequired,\n+ style: Text.propTypes.style,\n+ })).isRequired,\nallHeightsMeasuredCallback: PropTypes.func.isRequired,\nminHeight: PropTypes.number,\nstyle: Text.propTypes.style,\n};\n- currentTextToHeight: TextToHeight = {};\n+ currentTextToHeight: TextToHeight = new Map();\nnextTextToHeight: ?TextToHeight = null;\n- leftToMeasure: Set<string> = new Set();\n+ leftToMeasure: Set<TextToMeasure> = new Set();\nleftInBatch = 0;\ncomponentDidMount() {\n@@ -54,16 +63,20 @@ class TextHeightMeasurer extends React.PureComponent {\n}\n// resets this.leftToMeasure and this.nextTextToHeight\n- resetInternalState(newTextToMeasure: string[]) {\n+ resetInternalState(newTextToMeasure: TextToMeasure[]) {\nthis.leftToMeasure = new Set();\n- const nextNextTextToHeight = {};\n- for (let text of newTextToMeasure) {\n- if (this.currentTextToHeight[text]) {\n- nextNextTextToHeight[text] = this.currentTextToHeight[text];\n- } else if (this.nextTextToHeight && this.nextTextToHeight[text]) {\n- nextNextTextToHeight[text] = this.nextTextToHeight[text];\n+ const nextNextTextToHeight = new Map();\n+ for (let textToMeasure of newTextToMeasure) {\n+ const id = textToMeasure.id;\n+ const current = this.currentTextToHeight.get(id);\n+ if (current) {\n+ nextNextTextToHeight.set(id, current);\n+ } else if (this.nextTextToHeight && this.nextTextToHeight.has(id)) {\n+ const currentNext = this.nextTextToHeight.get(id);\n+ invariant(currentNext, \"has() check said it had it!\");\n+ nextNextTextToHeight.set(id, currentNext);\n} else {\n- this.leftToMeasure.add(text);\n+ this.leftToMeasure.add(textToMeasure);\n}\n}\nthis.nextTextToHeight = nextNextTextToHeight;\n@@ -75,15 +88,17 @@ class TextHeightMeasurer extends React.PureComponent {\n}\nonTextLayout(\n- text: string,\n+ textToMeasure: TextToMeasure,\nevent: { nativeEvent: { layout: { height: number }}},\n) {\ninvariant(this.nextTextToHeight, \"nextTextToHeight should be set\");\n- this.nextTextToHeight[text] =\n+ this.nextTextToHeight.set(\n+ textToMeasure.id,\nthis.props.minHeight !== undefined && this.props.minHeight !== null\n? Math.max(event.nativeEvent.layout.height, this.props.minHeight)\n- : event.nativeEvent.layout.height;\n- this.leftToMeasure.delete(text);\n+ : event.nativeEvent.layout.height,\n+ );\n+ this.leftToMeasure.delete(textToMeasure);\nthis.leftInBatch--;\nif (this.leftToMeasure.size === 0) {\nthis.done(this.props.textToMeasure);\n@@ -92,7 +107,7 @@ class TextHeightMeasurer extends React.PureComponent {\n}\n}\n- done(textToMeasure: string[]) {\n+ done(textToMeasure: TextToMeasure[]) {\ninvariant(this.leftToMeasure.size === 0, \"should be 0 left to measure\");\ninvariant(this.leftInBatch === 0, \"batch should be complete\");\ninvariant(this.nextTextToHeight, \"nextTextToHeight should be set\");\n@@ -124,15 +139,19 @@ class TextHeightMeasurer extends React.PureComponent {\nreturn null;\n}\ninvariant(set, \"should be set\");\n- const dummies = Array.from(set).map((text: string) => (\n+ const dummies = Array.from(set).map((textToMeasure: TextToMeasure) => {\n+ const style = textToMeasure.style ? textToMeasure.style : this.props.style;\n+ invariant(style, \"style should exist for every text being measured!\");\n+ return (\n<Text\n- style={[styles.text, this.props.style]}\n- onLayout={(event) => this.onTextLayout(text, event)}\n- key={text}\n+ style={[styles.text, style]}\n+ onLayout={(event) => this.onTextLayout(textToMeasure, event)}\n+ key={textToMeasure.id}\n>\n- {text}\n+ {textToMeasure.text}\n</Text>\n- ));\n+ );\n+ });\nreturn <View>{dummies}</View>;\n}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Extend TextHeightMeasurer to be able to handle different styles for individual entries |
129,187 | 13.07.2017 15:26:52 | 14,400 | 2cf50145121344ff35be3920c027f13ebcbd131d | Add support for robotext to MessageList | [
{
"change_type": "MODIFY",
"old_path": "native/chat/message-list.react.js",
"new_path": "native/chat/message-list.react.js",
"diff": "@@ -35,7 +35,7 @@ import _differenceWith from 'lodash/fp/differenceWith';\nimport _find from 'lodash/fp/find';\nimport _isEqual from 'lodash/fp/isEqual';\n-import { messageKey } from 'lib/shared/message-utils';\n+import { messageKey, robotextForMessageInfo } from 'lib/shared/message-utils';\nimport {\nincludeDispatchActionProps,\nbindServerCalls,\n@@ -130,15 +130,22 @@ class InnerMessageList extends React.PureComponent {\ncontinue;\n}\nconst messageInfo = item.messageInfo;\n- if (messageInfo.type !== messageType.TEXT) {\n- // TODO actually measure textHeight\n- continue;\n- }\n+ if (messageInfo.type === messageType.TEXT) {\ntextToMeasure.push({\nid: messageKey(messageInfo),\ntext: messageInfo.text,\n+ style: styles.text,\n+ });\n+ } else {\n+ const robotext = robotextForMessageInfo(messageInfo);\n+ const text = robotext[0] + \" \" + robotext[1];\n+ textToMeasure.push({\n+ id: messageKey(messageInfo),\n+ text: text,\n+ style: styles.robotext,\n});\n}\n+ }\nreturn textToMeasure;\n}\n@@ -284,7 +291,6 @@ class InnerMessageList extends React.PureComponent {\n<TextHeightMeasurer\ntextToMeasure={this.state.textToMeasure}\nallHeightsMeasuredCallback={this.allHeightsMeasured}\n- style={styles.text}\n/>\n);\nconst listDataWithHeights = this.state.listDataWithHeights;\n@@ -417,6 +423,12 @@ const styles = StyleSheet.create({\nfontSize: 18,\nfontFamily: 'Arial',\n},\n+ robotext: {\n+ left: 24,\n+ right: 24,\n+ fontSize: 15,\n+ fontFamily: 'Arial',\n+ },\nloadingIndicator: {\nflex: 1,\n},\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/message.react.js",
"new_path": "native/chat/message.react.js",
"diff": "@@ -11,34 +11,35 @@ import {\nText,\nStyleSheet,\nView,\n- TouchableOpacity,\nLayoutAnimation,\n} from 'react-native';\nimport { connect } from 'react-redux';\nimport _isEqual from 'lodash/fp/isEqual';\nimport invariant from 'invariant';\nimport PropTypes from 'prop-types';\n-import Color from 'color';\n-import { colorIsDark } from 'lib/selectors/thread-selectors';\nimport { longAbsoluteDate } from 'lib/utils/date-utils';\n-import { messageKey } from 'lib/shared/message-utils';\nimport { messageType } from 'lib/types/message-types';\n+import { TextMessage, textMessageItemHeight } from './text-message.react';\n+import {\n+ RobotextMessage,\n+ robotextMessageItemHeight,\n+} from './robotext-message.react';\n+\nfunction messageItemHeight(\nitem: ChatMessageInfoItemWithHeight,\nviewerID: ?string,\n) {\n- let height = 17 + item.textHeight; // for padding, margin, and text\n- if (item.messageInfo.creatorID !== viewerID && item.startsCluster) {\n- height += 25; // for username\n+ let height = 0;\n+ if (item.messageInfo.type === messageType.TEXT) {\n+ height += textMessageItemHeight(item, viewerID);\n+ } else {\n+ height += robotextMessageItemHeight(item, viewerID);\n}\nif (item.startsConversation) {\nheight += 26; // for time bar\n}\n- if (item.endsCluster) {\n- height += 7; // extra padding at the end of a cluster\n- }\nreturn height;\n}\n@@ -82,92 +83,50 @@ class InnerMessage extends React.PureComponent {\n) {\nthis.setState({ threadInfo: nextProps.threadInfo });\n}\n- if (nextProps.focused !== this.props.focused) {\n+ if (\n+ (nextProps.focused || nextProps.item.startsConversation) !==\n+ (this.props.focused || this.props.item.startsConversation)\n+ ) {\nLayoutAnimation.easeInEaseOut();\n}\n}\nrender() {\nlet conversationHeader = null;\n- if (this.props.item.startsConversation || this.props.focused) {\n+ if (this.props.focused || this.props.item.startsConversation) {\nconversationHeader = (\n<Text style={styles.conversationHeader}>\n{longAbsoluteDate(this.props.item.messageInfo.time).toUpperCase()}\n</Text>\n);\n}\n-\n- const isViewer = this.props.item.messageInfo.isViewer;\n- let containerStyle = null,\n- messageStyle = {},\n- textStyle = {};\n- if (isViewer) {\n- containerStyle = { alignSelf: 'flex-end' };\n- messageStyle.backgroundColor = `#${this.state.threadInfo.color}`;\n- const darkColor = colorIsDark(this.state.threadInfo.color);\n- textStyle.color = darkColor ? 'white' : 'black';\n- } else {\n- containerStyle = { alignSelf: 'flex-start' };\n- messageStyle.backgroundColor = \"#DDDDDDBB\";\n- textStyle.color = 'black';\n- }\n- let authorName = null;\n- if (!isViewer && this.props.item.startsCluster) {\n- authorName = (\n- <Text style={styles.authorName}>\n- {this.props.item.messageInfo.creator}\n- </Text>\n- );\n- }\n- messageStyle.borderTopRightRadius =\n- isViewer && !this.props.item.startsCluster ? 0 : 8;\n- messageStyle.borderBottomRightRadius =\n- isViewer && !this.props.item.endsCluster ? 0 : 8;\n- messageStyle.borderTopLeftRadius =\n- !isViewer && !this.props.item.startsCluster ? 0 : 8;\n- messageStyle.borderBottomLeftRadius =\n- !isViewer && !this.props.item.endsCluster ? 0 : 8;\n- messageStyle.marginBottom = this.props.item.endsCluster ? 12 : 5;\n- if (this.props.focused) {\n- messageStyle.backgroundColor =\n- Color(messageStyle.backgroundColor).darken(0.15).hex();\n- }\n- textStyle.height = this.props.item.textHeight;\n-\n- let text;\n+ let message;\nif (this.props.item.messageInfo.type === messageType.TEXT) {\n- text = this.props.item.messageInfo.text;\n+ message = (\n+ <TextMessage\n+ item={this.props.item}\n+ focused={this.props.focused}\n+ onFocus={this.props.onFocus}\n+ threadInfo={this.props.threadInfo}\n+ />\n+ );\n} else {\n- // TODO actually handle all cases\n- text = \"Test\";\n+ message = (\n+ <RobotextMessage\n+ item={this.props.item}\n+ onFocus={this.props.onFocus}\n+ threadInfo={this.props.threadInfo}\n+ />\n+ );\n}\n-\nreturn (\n<View>\n{conversationHeader}\n- <View style={containerStyle}>\n- {authorName}\n- <View\n- style={[styles.message, messageStyle]}\n- onStartShouldSetResponder={this.onStartShouldSetResponder}\n- onResponderGrant={this.onResponderGrant}\n- onResponderTerminationRequest={this.onResponderTerminationRequest}\n- >\n- <Text style={[styles.text, textStyle]}>{text}</Text>\n- </View>\n- </View>\n+ {message}\n</View>\n);\n}\n- onStartShouldSetResponder = () => true;\n-\n- onResponderGrant = () => {\n- this.props.onFocus(messageKey(this.props.item.messageInfo));\n- }\n-\n- onResponderTerminationRequest = () => true;\n-\n}\nconst styles = StyleSheet.create({\n@@ -178,23 +137,6 @@ const styles = StyleSheet.create({\nalignSelf: 'center',\nheight: 26,\n},\n- text: {\n- fontSize: 18,\n- fontFamily: 'Arial',\n- },\n- message: {\n- overflow: 'hidden',\n- paddingVertical: 6,\n- paddingHorizontal: 12,\n- marginHorizontal: 12,\n- },\n- authorName: {\n- color: '#777777',\n- fontSize: 14,\n- paddingHorizontal: 24,\n- paddingVertical: 4,\n- height: 25,\n- },\n});\nconst Message = connect(\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/chat/robotext-message.react.js",
"diff": "+// @flow\n+\n+import type { ThreadInfo } from 'lib/types/thread-types';\n+import { threadInfoPropType } from 'lib/types/thread-types';\n+import type { ChatMessageInfoItemWithHeight } from './message-list.react';\n+import { chatMessageItemPropType } from '../selectors/chat-selectors';\n+\n+import React from 'react';\n+import {\n+ Text,\n+ StyleSheet,\n+ View,\n+} from 'react-native';\n+import invariant from 'invariant';\n+import PropTypes from 'prop-types';\n+\n+import { messageKey, robotextForMessageInfo } from 'lib/shared/message-utils';\n+import { messageType } from 'lib/types/message-types';\n+\n+function robotextMessageItemHeight(\n+ item: ChatMessageInfoItemWithHeight,\n+ viewerID: ?string,\n+) {\n+ let height = 17 + item.textHeight; // for padding, margin, and text\n+}\n+\n+type Props = {\n+ item: ChatMessageInfoItemWithHeight,\n+ onFocus: (messageKey: string) => void,\n+ threadInfo: ThreadInfo,\n+};\n+class RobotextMessage extends React.PureComponent {\n+\n+ props: Props;\n+ static propTypes = {\n+ item: chatMessageItemPropType.isRequired,\n+ onFocus: PropTypes.func.isRequired,\n+ threadInfo: threadInfoPropType.isRequired,\n+ };\n+\n+ constructor(props: Props) {\n+ super(props);\n+ invariant(\n+ props.item.messageInfo.type !== messageType.TEXT,\n+ \"TextMessage cannot be used for messageType.TEXT\",\n+ );\n+ }\n+\n+ componentWillReceiveProps(nextProps: Props) {\n+ invariant(\n+ nextProps.item.messageInfo.type !== messageType.TEXT,\n+ \"TextMessage cannot be used for messageType.TEXT\",\n+ );\n+ }\n+\n+ render() {\n+ const robotext = robotextForMessageInfo(this.props.item.messageInfo);\n+ return (\n+ <View\n+ onStartShouldSetResponder={this.onStartShouldSetResponder}\n+ onResponderGrant={this.onResponderGrant}\n+ onResponderTerminationRequest={this.onResponderTerminationRequest}\n+ >\n+ <Text style={styles.robotext}>{robotext[0] + \" \" + robotext[1]}</Text>\n+ </View>\n+ );\n+ }\n+\n+ onStartShouldSetResponder = () => true;\n+\n+ onResponderGrant = () => {\n+ this.props.onFocus(messageKey(this.props.item.messageInfo));\n+ }\n+\n+ onResponderTerminationRequest = () => true;\n+\n+}\n+\n+const styles = StyleSheet.create({\n+ robotext: {\n+ textAlign: 'center',\n+ color: '#333333',\n+ paddingVertical: 6,\n+ marginBottom: 5,\n+ marginHorizontal: 24,\n+ fontSize: 15,\n+ fontFamily: 'Arial',\n+ },\n+});\n+\n+export {\n+ RobotextMessage,\n+ robotextMessageItemHeight,\n+};\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/chat/text-message.react.js",
"diff": "+// @flow\n+\n+import type { ThreadInfo } from 'lib/types/thread-types';\n+import { threadInfoPropType } from 'lib/types/thread-types';\n+import type { ChatMessageInfoItemWithHeight } from './message-list.react';\n+import { chatMessageItemPropType } from '../selectors/chat-selectors';\n+\n+import React from 'react';\n+import {\n+ Text,\n+ StyleSheet,\n+ View,\n+ TouchableOpacity,\n+ LayoutAnimation,\n+} from 'react-native';\n+import invariant from 'invariant';\n+import PropTypes from 'prop-types';\n+import Color from 'color';\n+\n+import { colorIsDark } from 'lib/selectors/thread-selectors';\n+import { messageKey } from 'lib/shared/message-utils';\n+import { messageType } from 'lib/types/message-types';\n+\n+function textMessageItemHeight(\n+ item: ChatMessageInfoItemWithHeight,\n+ viewerID: ?string,\n+) {\n+ let height = 17 + item.textHeight; // for padding, margin, and text\n+ if (item.messageInfo.creatorID !== viewerID && item.startsCluster) {\n+ height += 25; // for username\n+ }\n+ if (item.endsCluster) {\n+ height += 7; // extra padding at the end of a cluster\n+ }\n+ return height;\n+}\n+\n+type Props = {\n+ item: ChatMessageInfoItemWithHeight,\n+ focused: bool,\n+ onFocus: (messageKey: string) => void,\n+ threadInfo: ThreadInfo,\n+};\n+class TextMessage extends React.PureComponent {\n+\n+ props: Props;\n+ static propTypes = {\n+ item: chatMessageItemPropType.isRequired,\n+ focused: PropTypes.bool.isRequired,\n+ onFocus: PropTypes.func.isRequired,\n+ threadInfo: threadInfoPropType.isRequired,\n+ };\n+\n+ constructor(props: Props) {\n+ super(props);\n+ invariant(\n+ props.item.messageInfo.type === messageType.TEXT,\n+ \"TextMessage should only be used for messageType.TEXT\",\n+ );\n+ }\n+\n+ componentWillReceiveProps(nextProps: Props) {\n+ invariant(\n+ nextProps.item.messageInfo.type === messageType.TEXT,\n+ \"TextMessage should only be used for messageType.TEXT\",\n+ );\n+ }\n+\n+ render() {\n+ const isViewer = this.props.item.messageInfo.isViewer;\n+ let containerStyle = null,\n+ messageStyle = {},\n+ textStyle = {};\n+ if (isViewer) {\n+ containerStyle = { alignSelf: 'flex-end' };\n+ messageStyle.backgroundColor = `#${this.props.threadInfo.color}`;\n+ const darkColor = colorIsDark(this.props.threadInfo.color);\n+ textStyle.color = darkColor ? 'white' : 'black';\n+ } else {\n+ containerStyle = { alignSelf: 'flex-start' };\n+ messageStyle.backgroundColor = \"#DDDDDDBB\";\n+ textStyle.color = 'black';\n+ }\n+ let authorName = null;\n+ if (!isViewer && this.props.item.startsCluster) {\n+ authorName = (\n+ <Text style={styles.authorName}>\n+ {this.props.item.messageInfo.creator}\n+ </Text>\n+ );\n+ }\n+ messageStyle.borderTopRightRadius =\n+ isViewer && !this.props.item.startsCluster ? 0 : 8;\n+ messageStyle.borderBottomRightRadius =\n+ isViewer && !this.props.item.endsCluster ? 0 : 8;\n+ messageStyle.borderTopLeftRadius =\n+ !isViewer && !this.props.item.startsCluster ? 0 : 8;\n+ messageStyle.borderBottomLeftRadius =\n+ !isViewer && !this.props.item.endsCluster ? 0 : 8;\n+ messageStyle.marginBottom = this.props.item.endsCluster ? 12 : 5;\n+ if (this.props.focused) {\n+ messageStyle.backgroundColor =\n+ Color(messageStyle.backgroundColor).darken(0.15).hex();\n+ }\n+ textStyle.height = this.props.item.textHeight;\n+\n+ invariant(\n+ this.props.item.messageInfo.type === messageType.TEXT,\n+ \"TextMessage should only be used for messageType.TEXT\",\n+ );\n+ const text = this.props.item.messageInfo.text;\n+\n+ return (\n+ <View style={containerStyle}>\n+ {authorName}\n+ <View\n+ style={[styles.message, messageStyle]}\n+ onStartShouldSetResponder={this.onStartShouldSetResponder}\n+ onResponderGrant={this.onResponderGrant}\n+ onResponderTerminationRequest={this.onResponderTerminationRequest}\n+ >\n+ <Text style={[styles.text, textStyle]}>{text}</Text>\n+ </View>\n+ </View>\n+ );\n+ }\n+\n+ onStartShouldSetResponder = () => true;\n+\n+ onResponderGrant = () => {\n+ this.props.onFocus(messageKey(this.props.item.messageInfo));\n+ }\n+\n+ onResponderTerminationRequest = () => true;\n+\n+}\n+\n+const styles = StyleSheet.create({\n+ text: {\n+ fontSize: 18,\n+ fontFamily: 'Arial',\n+ },\n+ message: {\n+ overflow: 'hidden',\n+ paddingVertical: 6,\n+ paddingHorizontal: 12,\n+ marginHorizontal: 12,\n+ },\n+ authorName: {\n+ color: '#777777',\n+ fontSize: 14,\n+ paddingHorizontal: 24,\n+ paddingVertical: 4,\n+ height: 25,\n+ },\n+});\n+\n+export {\n+ TextMessage,\n+ textMessageItemHeight,\n+};\n"
},
{
"change_type": "MODIFY",
"old_path": "native/selectors/chat-selectors.js",
"new_path": "native/selectors/chat-selectors.js",
"diff": "@@ -170,7 +170,11 @@ const baseMessageListData = (threadID: string) => createSelector(\nlastMessageInfo.time + msInFiveMinutes > rawMessageInfo.time\n) {\nstartsConversation = false;\n- if (lastMessageInfo.creatorID === rawMessageInfo.creatorID) {\n+ if (\n+ lastMessageInfo.type === messageType.TEXT &&\n+ rawMessageInfo.type === messageType.TEXT &&\n+ lastMessageInfo.creatorID === rawMessageInfo.creatorID\n+ ) {\nstartsCluster = false;\n}\n}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Add support for robotext to MessageList |
129,187 | 13.07.2017 19:20:18 | 14,400 | 6d1e727f23782b27a45d76dd49abc9d355bdab93 | Only calculate robotext once (in selector) | [
{
"change_type": "MODIFY",
"old_path": "lib/types/message-types.js",
"new_path": "lib/types/message-types.js",
"diff": "@@ -57,8 +57,7 @@ export type TextMessageInfo = {|\ntext: string,\n|};\n-export type MessageInfo = TextMessageInfo |\n-{|\n+export type RobotextMessageInfo = {|\ntype: 1,\nid: string,\nthreadID: string,\n@@ -75,6 +74,8 @@ export type MessageInfo = TextMessageInfo |\naddedUsernames: string[],\n|};\n+export type MessageInfo = TextMessageInfo | RobotextMessageInfo;\n+\nexport const messageInfoPropType = PropTypes.oneOfType([\nPropTypes.shape({\ntype: PropTypes.oneOf([0]).isRequired,\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/message-list.react.js",
"new_path": "native/chat/message-list.react.js",
"diff": "@@ -13,7 +13,10 @@ import type {\n} from '../selectors/chat-selectors';\nimport { chatMessageItemPropType } from '../selectors/chat-selectors';\nimport type { ViewToken } from 'react-native/Libraries/Lists/ViewabilityHelper';\n-import type { MessageInfo } from 'lib/types/message-types';\n+import type {\n+ TextMessageInfo,\n+ RobotextMessageInfo,\n+} from 'lib/types/message-types';\nimport type { DispatchActionPromise } from 'lib/utils/action-utils';\nimport type { PageMessagesResult } from 'lib/actions/message-actions';\nimport type { TextToMeasure } from '../text-height-measurer.react';\n@@ -35,7 +38,7 @@ import _differenceWith from 'lodash/fp/differenceWith';\nimport _find from 'lodash/fp/find';\nimport _isEqual from 'lodash/fp/isEqual';\n-import { messageKey, robotextForMessageInfo } from 'lib/shared/message-utils';\n+import { messageKey } from 'lib/shared/message-utils';\nimport {\nincludeDispatchActionProps,\nbindServerCalls,\n@@ -55,16 +58,24 @@ import AddThreadButton from './add-thread-button.react';\ntype NavProp = NavigationScreenProp<NavigationRoute, NavigationAction>;\n-export type ChatMessageInfoItemWithHeight = {\n+export type ChatMessageInfoItemWithHeight = {|\nitemType: \"message\",\n- messageInfo: MessageInfo,\n+ messageInfo: RobotextMessageInfo,\nstartsConversation: bool,\nstartsCluster: bool,\nendsCluster: bool,\n+ robotext: string,\ntextHeight: number,\n-};\n+|} | {|\n+ itemType: \"message\",\n+ messageInfo: TextMessageInfo,\n+ startsConversation: bool,\n+ startsCluster: bool,\n+ endsCluster: bool,\n+ textHeight: number,\n+|};\ntype ChatMessageItemWithHeight =\n- { itemType: \"loader\" } |\n+ {| itemType: \"loader\" |} |\nChatMessageInfoItemWithHeight;\ntype Props = {\n@@ -136,12 +147,17 @@ class InnerMessageList extends React.PureComponent {\ntext: messageInfo.text,\nstyle: styles.text,\n});\n- } else {\n- const robotext = robotextForMessageInfo(messageInfo);\n- const text = robotext[0] + \" \" + robotext[1];\n+ } else if (\n+ item.messageInfo.type === messageType.CREATE_THREAD ||\n+ item.messageInfo.type === messageType.ADD_USER\n+ ) {\n+ invariant(\n+ item.robotext && typeof item.robotext === \"string\",\n+ \"Flow can't handle our fancy types :(\",\n+ );\ntextToMeasure.push({\nid: messageKey(messageInfo),\n- text: text,\n+ text: item.robotext,\nstyle: styles.robotext,\n});\n}\n@@ -208,23 +224,40 @@ class InnerMessageList extends React.PureComponent {\nif (item.itemType !== \"message\") {\nreturn item;\n}\n- const messageInfoItem: ChatMessageInfoItem = item;\n- if (messageInfoItem.messageInfo.type !== messageType.TEXT) {\n- // TODO actually measure textHeight\n- return ({\n- ...messageInfoItem,\n- textHeight: 0,\n- }: ChatMessageInfoItemWithHeight);\n- }\n- const textHeight =\n- textHeights.get(messageKey(messageInfoItem.messageInfo));\n+ const textHeight = textHeights.get(messageKey(item.messageInfo));\ninvariant(\ntextHeight,\n- `height for ${messageKey(messageInfoItem.messageInfo)} should be set`,\n+ `height for ${messageKey(item.messageInfo)} should be set`,\n);\n- const withHeight =\n- ({ ...messageInfoItem, textHeight }: ChatMessageInfoItemWithHeight);\n- return withHeight;\n+ if (item.messageInfo.type === messageType.TEXT) {\n+ return {\n+ itemType: \"message\",\n+ messageInfo: item.messageInfo,\n+ startsConversation: item.startsConversation,\n+ startsCluster: item.startsCluster,\n+ endsCluster: item.endsCluster,\n+ textHeight,\n+ };\n+ } else if (\n+ item.messageInfo.type === messageType.CREATE_THREAD ||\n+ item.messageInfo.type === messageType.ADD_USER\n+ ) {\n+ invariant(\n+ typeof item.robotext === \"string\",\n+ \"Flow can't handle our fancy types :(\",\n+ );\n+ return {\n+ itemType: \"message\",\n+ messageInfo: item.messageInfo,\n+ startsConversation: item.startsConversation,\n+ startsCluster: item.startsCluster,\n+ endsCluster: item.endsCluster,\n+ robotext: item.robotext,\n+ textHeight,\n+ };\n+ } else {\n+ invariant(false, `${item.messageInfo.type} is not a messageType!`);\n+ }\n});\nthis.setState({ listDataWithHeights });\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/robotext-message.react.js",
"new_path": "native/chat/robotext-message.react.js",
"diff": "@@ -14,7 +14,7 @@ import {\nimport invariant from 'invariant';\nimport PropTypes from 'prop-types';\n-import { messageKey, robotextForMessageInfo } from 'lib/shared/message-utils';\n+import { messageKey } from 'lib/shared/message-utils';\nimport { messageType } from 'lib/types/message-types';\nfunction robotextMessageItemHeight(\n@@ -54,14 +54,18 @@ class RobotextMessage extends React.PureComponent {\n}\nrender() {\n- const robotext = robotextForMessageInfo(this.props.item.messageInfo);\n+ const item = this.props.item;\n+ invariant(\n+ item.robotext && typeof item.robotext === \"string\",\n+ \"Flow can't handle our fancy types :(\",\n+ );\nreturn (\n<View\nonStartShouldSetResponder={this.onStartShouldSetResponder}\nonResponderGrant={this.onResponderGrant}\nonResponderTerminationRequest={this.onResponderTerminationRequest}\n>\n- <Text style={styles.robotext}>{robotext[0] + \" \" + robotext[1]}</Text>\n+ <Text style={styles.robotext}>{item.robotext}</Text>\n</View>\n);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "native/selectors/chat-selectors.js",
"new_path": "native/selectors/chat-selectors.js",
"diff": "@@ -8,6 +8,7 @@ import type {\nMessageStore,\nRawMessageInfo,\nTextMessageInfo,\n+ RobotextMessageInfo,\n} from 'lib/types/message-types';\nimport { messageInfoPropType } from 'lib/types/message-types';\nimport type { UserInfo } from 'lib/types/user-types';\n@@ -22,6 +23,7 @@ import _orderBy from 'lodash/fp/orderBy';\nimport _memoize from 'lodash/memoize';\nimport { messageType } from 'lib/types/message-types';\n+import { robotextForMessageInfo } from 'lib/shared/message-utils';\nfunction createMessageInfo(\nrawMessageInfo: RawMessageInfo,\n@@ -120,15 +122,22 @@ const chatListData = createSelector(\n)(threadInfos),\n);\n-export type ChatMessageInfoItem = {\n+export type ChatMessageInfoItem = {|\nitemType: \"message\",\n- messageInfo: MessageInfo,\n+ messageInfo: RobotextMessageInfo,\nstartsConversation: bool,\nstartsCluster: bool,\nendsCluster: bool,\n-};\n+ robotext: string,\n+|} | {|\n+ itemType: \"message\",\n+ messageInfo: TextMessageInfo,\n+ startsConversation: bool,\n+ startsCluster: bool,\n+ endsCluster: bool,\n+|};\nexport type ChatMessageItem =\n- { itemType: \"loader\" } |\n+ {| itemType: \"loader\" |} |\nChatMessageInfoItem;\nconst chatMessageItemPropType = PropTypes.oneOfType([\nPropTypes.shape({\n@@ -140,6 +149,7 @@ const chatMessageItemPropType = PropTypes.oneOfType([\nstartsConversation: PropTypes.bool.isRequired,\nstartsCluster: PropTypes.bool.isRequired,\nendsCluster: PropTypes.bool.isRequired,\n+ robotext: PropTypes.string,\n}),\n]);\nconst msInFiveMinutes = 5 * 60 * 1000;\n@@ -188,6 +198,7 @@ const baseMessageListData = (threadID: string) => createSelector(\nviewerID,\nuserInfos,\n);\n+ if (messageInfo.type === messageType.TEXT) {\nchatMessageItems.push({\nitemType: \"message\",\nmessageInfo,\n@@ -195,6 +206,22 @@ const baseMessageListData = (threadID: string) => createSelector(\nstartsCluster,\nendsCluster: false,\n});\n+ } else if (\n+ messageInfo.type === messageType.CREATE_THREAD ||\n+ messageInfo.type === messageType.ADD_USER\n+ ) {\n+ const robotextParts = robotextForMessageInfo(messageInfo);\n+ chatMessageItems.push({\n+ itemType: \"message\",\n+ messageInfo,\n+ startsConversation,\n+ startsCluster,\n+ endsCluster: false,\n+ robotext: `${robotextParts[0]} ${robotextParts[1]}`,\n+ });\n+ } else {\n+ invariant(false, `${messageInfo.type} is not a messageType!`);\n+ }\nlastMessageInfo = messageInfo;\n}\nif (chatMessageItems.length > 0) {\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Only calculate robotext once (in selector) |
129,187 | 14.07.2017 14:55:35 | 14,400 | d9cfedce879a85daef40685865d9fc58809ab566 | Pass parentThreadID into AddThreadButton | [
{
"change_type": "MODIFY",
"old_path": "native/chat/add-thread-button.react.js",
"new_path": "native/chat/add-thread-button.react.js",
"diff": "import React from 'react';\nimport { Platform, StyleSheet, TouchableOpacity } from 'react-native';\nimport Icon from 'react-native-vector-icons/Ionicons';\n+import PropTypes from 'prop-types';\nclass AddThreadButton extends React.PureComponent {\n+ props: {\n+ parentThreadID?: string,\n+ };\n+ static propTypes = {\n+ parentThreadID: PropTypes.string,\n+ };\n+\nrender() {\nlet icon;\nif (Platform.OS === \"ios\") {\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/message-list.react.js",
"new_path": "native/chat/message-list.react.js",
"diff": "@@ -117,7 +117,11 @@ class InnerMessageList extends React.PureComponent {\n};\nstatic navigationOptions = ({ navigation }) => ({\ntitle: navigation.state.params.threadInfo.name,\n- headerRight: <AddThreadButton />,\n+ headerRight: (\n+ <AddThreadButton\n+ parentThreadID={navigation.state.params.threadInfo.id}\n+ />\n+ ),\n});\ntextHeights: ?Map<string, number> = null;\nloadingFromScroll = false;\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Pass parentThreadID into AddThreadButton |
129,187 | 14.07.2017 15:12:17 | 14,400 | df254e4f6b3a209ce7bbe6eee44af7bd448331cd | Create search_users.php endpoint for user typeahead | [
{
"change_type": "ADD",
"old_path": null,
"new_path": "server/search_users.php",
"diff": "+<?php\n+\n+require_once('async_lib.php');\n+require_once('config.php');\n+\n+async_start();\n+\n+$prefix_fragment = \"\";\n+if (isset($_POST['prefix'])) {\n+ $prefix_fragment = \"WHERE username LIKE '\"\n+ . $conn->real_escape_string($_POST['prefix'])\n+ . \"%' \";\n+}\n+\n+$query = \"SELECT id, username FROM users {$prefix_fragment}LIMIT 20\";\n+$result = $conn->query($query);\n+\n+$user_infos = array();\n+while ($row = $result->fetch_assoc()) {\n+ $user_infos[] = $row;\n+}\n+\n+async_end(array(\n+ 'success' => true,\n+ 'user_infos' => $user_infos,\n+));\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Create search_users.php endpoint for user typeahead |
129,187 | 14.07.2017 16:40:58 | 14,400 | 95d746855995e957a88b680e91e90ef9ab6aebbf | Basic AddThread screen | [
{
"change_type": "MODIFY",
"old_path": "native/chat/add-thread-button.react.js",
"new_path": "native/chat/add-thread-button.react.js",
"diff": "// @flow\n+import type { NavigationParams } from 'react-navigation';\n+\nimport React from 'react';\nimport { Platform, StyleSheet, TouchableOpacity } from 'react-native';\nimport Icon from 'react-native-vector-icons/Ionicons';\nimport PropTypes from 'prop-types';\n+import { AddThreadRouteName } from './add-thread.react';\n+\nclass AddThreadButton extends React.PureComponent {\nprops: {\nparentThreadID?: string,\n+ navigate: (\n+ routeName: string,\n+ params?: NavigationParams,\n+ ) => boolean,\n};\nstatic propTypes = {\nparentThreadID: PropTypes.string,\n+ navigate: PropTypes.func.isRequired,\n};\nrender() {\n@@ -46,6 +55,10 @@ class AddThreadButton extends React.PureComponent {\n}\nonPress = () => {\n+ this.props.navigate(\n+ AddThreadRouteName,\n+ { parentThreadID: this.props.parentThreadID },\n+ );\n}\n}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/chat/add-thread.react.js",
"diff": "+// @flow\n+\n+import type {\n+ NavigationScreenProp,\n+ NavigationRoute,\n+ NavigationAction,\n+} from 'react-navigation';\n+\n+import React from 'react';\n+import PropTypes from 'prop-types';\n+import { View, Text, StyleSheet } from 'react-native';\n+\n+type NavProp = NavigationScreenProp<NavigationRoute, NavigationAction>;\n+\n+class AddThread extends React.PureComponent {\n+\n+ props: {\n+ navigation: NavProp,\n+ };\n+ static propTypes = {\n+ navigation: PropTypes.shape({\n+ state: PropTypes.shape({\n+ params: PropTypes.shape({\n+ parentThreadID: PropTypes.string,\n+ }).isRequired,\n+ }).isRequired,\n+ }).isRequired,\n+ };\n+ static navigationOptions = {\n+ title: 'New thread',\n+ };\n+\n+ render() {\n+ return (\n+ <View style={styles.container}>\n+ <Text>{this.props.navigation.state.params.parentThreadID}</Text>\n+ </View>\n+ );\n+ }\n+\n+}\n+\n+const styles = StyleSheet.create({\n+ container: {\n+ flex: 1,\n+ },\n+});\n+\n+const AddThreadRouteName = 'AddThread';\n+\n+export {\n+ AddThread,\n+ AddThreadRouteName,\n+};\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/chat-thread-list.react.js",
"new_path": "native/chat/chat-thread-list.react.js",
"diff": "@@ -37,10 +37,10 @@ class InnerChatThreadList extends React.PureComponent {\nchatListData: PropTypes.arrayOf(chatThreadItemPropType).isRequired,\nviewerID: PropTypes.string,\n};\n- static navigationOptions = {\n+ static navigationOptions = ({ navigation }) => ({\ntitle: 'Threads',\n- headerRight: <AddThreadButton />,\n- };\n+ headerRight: <AddThreadButton navigate={navigation.navigate} />,\n+ });\nrenderItem = (row: { item: ChatThreadItem }) => {\nreturn (\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/chat.react.js",
"new_path": "native/chat/chat.react.js",
"diff": "@@ -10,10 +10,12 @@ import {\nChatThreadListRouteName,\n} from './chat-thread-list.react';\nimport { MessageList, MessageListRouteName } from './message-list.react';\n+import { AddThread, AddThreadRouteName } from './add-thread.react';\nconst Chat = StackNavigator({\n[ChatThreadListRouteName]: { screen: ChatThreadList },\n[MessageListRouteName]: { screen: MessageList },\n+ [AddThreadRouteName]: { screen: AddThread },\n});\nChat.navigationOptions = {\ntabBarLabel: 'Chat',\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/message-list.react.js",
"new_path": "native/chat/message-list.react.js",
"diff": "@@ -105,9 +105,10 @@ class InnerMessageList extends React.PureComponent {\nnavigation: PropTypes.shape({\nstate: PropTypes.shape({\nparams: PropTypes.shape({\n- threadInfo: threadInfoPropType,\n+ threadInfo: threadInfoPropType.isRequired,\n}).isRequired,\n}).isRequired,\n+ navigate: PropTypes.func.isRequired,\n}).isRequired,\nmessageListData: PropTypes.arrayOf(chatMessageItemPropType).isRequired,\nviewerID: PropTypes.string,\n@@ -120,6 +121,7 @@ class InnerMessageList extends React.PureComponent {\nheaderRight: (\n<AddThreadButton\nparentThreadID={navigation.state.params.threadInfo.id}\n+ navigate={navigation.navigate}\n/>\n),\n});\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Basic AddThread screen |
129,187 | 18.07.2017 14:32:22 | 14,400 | 17d60bad7d95f739fdd90d119fb38c11694033e9 | AddThread basic UI | [
{
"change_type": "MODIFY",
"old_path": "native/account/forgot-password-panel.react.js",
"new_path": "native/account/forgot-password-panel.react.js",
"diff": "@@ -81,7 +81,7 @@ class ForgotPasswordPanel extends React.PureComponent {\nautoCorrect={false}\nautoCapitalize=\"none\"\nkeyboardType=\"ascii-capable\"\n- returnKeyType='go'\n+ returnKeyType=\"go\"\nblurOnSubmit={false}\nonSubmitEditing={this.onSubmit}\neditable={this.props.loadingStatus !== \"loading\"}\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/add-thread.react.js",
"new_path": "native/chat/add-thread.react.js",
"diff": "@@ -5,17 +5,49 @@ import type {\nNavigationRoute,\nNavigationAction,\n} from 'react-navigation';\n+import type { AppState } from '../redux-setup';\n+import type { LoadingStatus } from 'lib/types/loading-types';\n+import type { ThreadInfo } from 'lib/types/thread-types';\n+import { threadInfoPropType } from 'lib/types/thread-types';\nimport React from 'react';\nimport PropTypes from 'prop-types';\n-import { View, Text, StyleSheet } from 'react-native';\n+import { View, Text, StyleSheet, TextInput } from 'react-native';\n+import { connect } from 'react-redux';\n+import TagInput from 'react-native-tag-input';\n+import SegmentedControlTab from 'react-native-segmented-control-tab';\n+import invariant from 'invariant';\n+\n+import {\n+ includeDispatchActionProps,\n+ bindServerCalls,\n+} from 'lib/utils/action-utils';\n+import {\n+ newThreadActionTypes,\n+ newThread,\n+} from 'lib/actions/thread-actions';\n+import { createLoadingStatusSelector } from 'lib/selectors/loading-selectors';\ntype NavProp = NavigationScreenProp<NavigationRoute, NavigationAction>;\n+const segmentedPrivacyOptions = ['Open', 'Closed'];\n+type TagData = string | {[key: string]: string};\n-class AddThread extends React.PureComponent {\n+class InnerAddThread extends React.PureComponent {\nprops: {\nnavigation: NavProp,\n+ // Redux state\n+ loadingStatus: LoadingStatus,\n+ threadInfo: ?ThreadInfo,\n+ };\n+ state: {\n+ nameInputText: string,\n+ usernameInputArray: $ReadOnlyArray<string>,\n+ selectedPrivacyIndex: number,\n+ } = {\n+ nameInputText: \"\",\n+ usernameInputArray: [],\n+ selectedPrivacyIndex: 0,\n};\nstatic propTypes = {\nnavigation: PropTypes.shape({\n@@ -25,29 +57,174 @@ class AddThread extends React.PureComponent {\n}).isRequired,\n}).isRequired,\n}).isRequired,\n+ loadingStatus: PropTypes.string.isRequired,\n+ threadInfo: threadInfoPropType,\n};\nstatic navigationOptions = {\ntitle: 'New thread',\n};\n+ nameInput: ?TextInput;\nrender() {\n+ let parentThreadName;\n+ if (this.props.threadInfo) {\n+ parentThreadName = (\n+ <Text\n+ style={styles.parentThreadName}\n+ numberOfLines={1}\n+ >\n+ <Text style={styles.parentThreadNameRobotext}>\n+ {\"within \"}\n+ </Text>\n+ {this.props.threadInfo.name}\n+ </Text>\n+ );\n+ }\nreturn (\n<View style={styles.container}>\n- <Text>{this.props.navigation.state.params.parentThreadID}</Text>\n+ <View style={styles.row}>\n+ <Text style={styles.label}>Name</Text>\n+ <View style={styles.input}>\n+ <TextInput\n+ style={styles.textInput}\n+ value={this.state.nameInputText}\n+ onChangeText={this.onChangeNameInputText}\n+ placeholder=\"thread name\"\n+ autoFocus={true}\n+ autoCorrect={false}\n+ autoCapitalize=\"none\"\n+ keyboardType=\"ascii-capable\"\n+ returnKeyType=\"next\"\n+ editable={this.props.loadingStatus !== \"loading\"}\n+ underlineColorAndroid=\"transparent\"\n+ ref={this.nameInputRef}\n+ />\n+ </View>\n+ </View>\n+ <View style={styles.row}>\n+ <Text style={styles.label}>Privacy</Text>\n+ <View style={styles.input}>\n+ <SegmentedControlTab\n+ values={segmentedPrivacyOptions}\n+ selectedIndex={this.state.selectedPrivacyIndex}\n+ onTabPress={this.handleIndexChange}\n+ tabStyle={styles.segmentedTabStyle}\n+ activeTabStyle={styles.segmentedActiveTabStyle}\n+ tabTextStyle={styles.segmentedTextStyle}\n+ />\n+ {parentThreadName}\n+ </View>\n+ </View>\n+ <View style={styles.row}>\n+ <Text style={styles.tagInputLabel}>People</Text>\n+ <View style={styles.input}>\n+ <TagInput\n+ onChange={this.onChangeTagInput}\n+ value={this.state.usernameInputArray}\n+ />\n+ </View>\n+ </View>\n</View>\n);\n}\n+ nameInputRef = (nameInput: ?TextInput) => {\n+ this.nameInput = nameInput;\n+ }\n+\n+ onChangeNameInputText = (text: string) => {\n+ this.setState({ nameInputText: text });\n+ }\n+\n+ onChangeTagInput = (usernameInputArray: $ReadOnlyArray<TagData>) => {\n+ const stringArray: string[] = [];\n+ for (const tagData of usernameInputArray) {\n+ invariant(typeof tagData === \"string\", \"AddThread uses string TagData\");\n+ stringArray.push(tagData);\n+ }\n+ this.setState({ usernameInputArray: stringArray });\n+ }\n+\n+ handleIndexChange = (index: number) => {\n+ this.setState({ selectedPrivacyIndex: index });\n+ }\n+\n}\nconst styles = StyleSheet.create({\ncontainer: {\n+ paddingTop: 5,\n+ flex: 1,\n+ backgroundColor: '#FFFFFF',\n+ },\n+ row: {\n+ flexDirection: 'row',\n+ marginBottom: 10,\n+ },\n+ input: {\n+ flex: 3,\n+ paddingRight: 12,\n+ },\n+ label: {\n+ paddingTop: 2,\n+ paddingLeft: 12,\n+ fontSize: 20,\nflex: 1,\n},\n+ tagInputLabel: {\n+ paddingTop: 2,\n+ paddingLeft: 12,\n+ fontSize: 20,\n+ flex: 1,\n+ },\n+ textInput: {\n+ fontSize: 18,\n+ paddingTop: 4,\n+ paddingBottom: 0,\n+ paddingHorizontal: 0,\n+ margin: 0,\n+ },\n+ parentThreadName: {\n+ paddingTop: 5,\n+ fontSize: 18,\n+ },\n+ parentThreadNameRobotext: {\n+ color: '#AAAAAA',\n+ },\n+ segmentedTabStyle: {\n+ borderColor: '#777',\n+ },\n+ segmentedActiveTabStyle: {\n+ backgroundColor: '#777',\n+ },\n+ segmentedTextStyle: {\n+ color: '#777',\n+ },\n});\nconst AddThreadRouteName = 'AddThread';\n+const loadingStatusSelector\n+ = createLoadingStatusSelector(newThreadActionTypes);\n+\n+const AddThread = connect(\n+ (state: AppState, ownProps: { navigation: NavProp }) => {\n+ let threadInfo = null;\n+ const threadID = ownProps.navigation.state.params.parentThreadID;\n+ if (threadID) {\n+ threadInfo = state.threadInfos[threadID];\n+ invariant(threadInfo, \"parent thread should exist\");\n+ }\n+ return {\n+ loadingStatus: loadingStatusSelector(state),\n+ threadInfo,\n+ cookie: state.cookie,\n+ };\n+ },\n+ includeDispatchActionProps,\n+ bindServerCalls({ newThread }),\n+)(InnerAddThread);\n+\nexport {\nAddThread,\nAddThreadRouteName,\n"
},
{
"change_type": "MODIFY",
"old_path": "native/package-lock.json",
"new_path": "native/package-lock.json",
"diff": "\"1PasswordExtension\": \"git+https://github.com/jjshammas/onepassword-app-extension.git#acf20f71c890e92ee489fc8e7bb0f7df922e855d\"\n}\n},\n+ \"react-native-segmented-control-tab\": {\n+ \"version\": \"git+https://github.com/ashoat/react-native-segmented-control-tab.git#926720e71aebf8a6c51b54d0c9f3d5930539e5c8\",\n+ \"requires\": {\n+ \"prop-types\": \"15.5.10\"\n+ }\n+ },\n+ \"react-native-tag-input\": {\n+ \"version\": \"git+https://github.com/ashoat/react-native-tag-input.git#371c5fa857409ef49297726b15dbca46d6fad3cc\",\n+ \"requires\": {\n+ \"invariant\": \"2.2.2\",\n+ \"prop-types\": \"15.5.10\"\n+ }\n+ },\n\"react-native-vector-icons\": {\n\"version\": \"4.2.0\",\n\"resolved\": \"https://registry.npmjs.org/react-native-vector-icons/-/react-native-vector-icons-4.2.0.tgz\",\n"
},
{
"change_type": "MODIFY",
"old_path": "native/package.json",
"new_path": "native/package.json",
"diff": "\"react-native-invertible-flat-list\": \"^1.1.0\",\n\"react-native-keychain\": \"^1.2.0\",\n\"react-native-onepassword\": \"^1.0.4\",\n+ \"react-native-segmented-control-tab\": \"git+https://github.com/ashoat/react-native-segmented-control-tab.git\",\n+ \"react-native-tag-input\": \"git+https://github.com/ashoat/react-native-tag-input.git\",\n\"react-native-vector-icons\": \"^4.2.0\",\n\"react-navigation\": \"git+https://github.com/ashoat/react-navigation.git\",\n\"react-redux\": \"^5.0.5\",\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | AddThread basic UI |
129,187 | 18.07.2017 14:33:09 | 14,400 | b60c3cdfc86105e61183bbd96a8dcce68e68f89b | otherUserInfos (for use by AddThread) | [
{
"change_type": "ADD",
"old_path": null,
"new_path": "lib/selectors/user-selectors.js",
"diff": "+// @flow\n+\n+import type { BaseAppState } from '../types/redux-types';\n+import type { UserInfo } from '../types/user-types';\n+\n+import { createSelector } from 'reselect';\n+\n+// other than the logged-in user\n+const otherUserInfos = createSelector(\n+ (state: BaseAppState) => state.userInfos,\n+ (state: BaseAppState) => state.currentUserInfo && state.currentUserInfo.id,\n+ (\n+ userInfos: {[id: string]: UserInfo},\n+ userID: ?string,\n+ ): $ReadOnlyArray<UserInfo> => {\n+ const userInfoArray = [];\n+ for (let id in userInfos) {\n+ userInfoArray.push(userInfos[id]);\n+ }\n+ return userInfoArray.filter((userInfo: UserInfo) => userInfo.id !== userID);\n+ },\n+);\n+\n+export {\n+ otherUserInfos,\n+};\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | otherUserInfos (for use by AddThread) |
129,187 | 18.07.2017 18:10:46 | 14,400 | e8948fbe1ad3c903f818de5e49201239bfa7fbec | Privacy -> Visibility, only show if has a parent thread (otherwise Secret) | [
{
"change_type": "MODIFY",
"old_path": "native/chat/add-thread.react.js",
"new_path": "native/chat/add-thread.react.js",
"diff": "@@ -29,7 +29,7 @@ import {\nimport { createLoadingStatusSelector } from 'lib/selectors/loading-selectors';\ntype NavProp = NavigationScreenProp<NavigationRoute, NavigationAction>;\n-const segmentedPrivacyOptions = ['Open', 'Closed'];\n+const segmentedPrivacyOptions = ['Public', 'Secret'];\ntype TagData = string | {[key: string]: string};\nclass InnerAddThread extends React.PureComponent {\n@@ -66,9 +66,20 @@ class InnerAddThread extends React.PureComponent {\nnameInput: ?TextInput;\nrender() {\n- let parentThreadName;\n+ let visibility;\nif (this.props.threadInfo) {\n- parentThreadName = (\n+ visibility = (\n+ <View style={styles.row}>\n+ <Text style={styles.label}>Visibility</Text>\n+ <View style={styles.input}>\n+ <SegmentedControlTab\n+ values={segmentedPrivacyOptions}\n+ selectedIndex={this.state.selectedPrivacyIndex}\n+ onTabPress={this.handleIndexChange}\n+ tabStyle={styles.segmentedTabStyle}\n+ activeTabStyle={styles.segmentedActiveTabStyle}\n+ tabTextStyle={styles.segmentedTextStyle}\n+ />\n<Text\nstyle={styles.parentThreadName}\nnumberOfLines={1}\n@@ -78,6 +89,8 @@ class InnerAddThread extends React.PureComponent {\n</Text>\n{this.props.threadInfo.name}\n</Text>\n+ </View>\n+ </View>\n);\n}\nreturn (\n@@ -101,20 +114,7 @@ class InnerAddThread extends React.PureComponent {\n/>\n</View>\n</View>\n- <View style={styles.row}>\n- <Text style={styles.label}>Privacy</Text>\n- <View style={styles.input}>\n- <SegmentedControlTab\n- values={segmentedPrivacyOptions}\n- selectedIndex={this.state.selectedPrivacyIndex}\n- onTabPress={this.handleIndexChange}\n- tabStyle={styles.segmentedTabStyle}\n- activeTabStyle={styles.segmentedActiveTabStyle}\n- tabTextStyle={styles.segmentedTextStyle}\n- />\n- {parentThreadName}\n- </View>\n- </View>\n+ {visibility}\n<View style={styles.row}>\n<Text style={styles.tagInputLabel}>People</Text>\n<View style={styles.input}>\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Privacy -> Visibility, only show if has a parent thread (otherwise Secret) |
129,187 | 18.07.2017 19:04:27 | 14,400 | dc489fb53389b796c70b3e6f3fd1e7011ed7024a | Create userSearchIndex selector | [
{
"change_type": "MODIFY",
"old_path": "lib/reducers/user-reducer.js",
"new_path": "lib/reducers/user-reducer.js",
"diff": "@@ -8,6 +8,7 @@ import type { CurrentUserInfo, UserInfo } from '../types/user-types';\nimport invariant from 'invariant';\nimport _keyBy from 'lodash/fp/keyBy';\n+import _isEqual from 'lodash/fp/isEqual';\nfunction reduceCurrentUserInfo(\nstate: ?CurrentUserInfo,\n@@ -57,10 +58,13 @@ function reduceUserInfos(\naction.type === \"FETCH_ENTRIES_AND_APPEND_RANGE_SUCCESS\" ||\naction.type === \"FETCH_ENTRIES_SUCCESS\"\n) {\n- return {\n+ const updated = {\n...state,\n..._keyBy('id')(action.payload.userInfos),\n};\n+ if (!_isEqual(state)(updated)) {\n+ return updated;\n+ }\n}\nreturn state;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/selectors/user-selectors.js",
"new_path": "lib/selectors/user-selectors.js",
"diff": "@@ -5,6 +5,8 @@ import type { UserInfo } from '../types/user-types';\nimport { createSelector } from 'reselect';\n+import SearchIndex from '../shared/search-index';\n+\n// other than the logged-in user\nconst otherUserInfos = createSelector(\n(state: BaseAppState) => state.userInfos,\n@@ -21,6 +23,18 @@ const otherUserInfos = createSelector(\n},\n);\n+const userSearchIndex = createSelector(\n+ otherUserInfos,\n+ (userInfos: $ReadOnlyArray<UserInfo>) => {\n+ const searchIndex = new SearchIndex();\n+ for (const userInfo of userInfos) {\n+ searchIndex.addEntry(userInfo.id, userInfo.username);\n+ }\n+ return searchIndex;\n+ },\n+);\n+\nexport {\notherUserInfos,\n+ userSearchIndex,\n};\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Create userSearchIndex selector |
129,187 | 18.07.2017 19:50:42 | 14,400 | 0d23483f93a4125009642425445d4594de6f7a85 | Lift username input state from TagInput to AddThread and make sure when last Tag is deleted, new last Tag calls onLayoutLastTag | [
{
"change_type": "MODIFY",
"old_path": "native/chat/add-thread.react.js",
"new_path": "native/chat/add-thread.react.js",
"diff": "@@ -43,10 +43,12 @@ class InnerAddThread extends React.PureComponent {\n};\nstate: {\nnameInputText: string,\n+ usernameInputText: string,\nusernameInputArray: $ReadOnlyArray<string>,\nselectedPrivacyIndex: number,\n} = {\nnameInputText: \"\",\n+ usernameInputText: \"\",\nusernameInputArray: [],\nselectedPrivacyIndex: 0,\n};\n@@ -122,6 +124,8 @@ class InnerAddThread extends React.PureComponent {\n<TagInput\nonChange={this.onChangeTagInput}\nvalue={this.state.usernameInputArray}\n+ text={this.state.usernameInputText}\n+ setText={this.setUsernameInputText}\n/>\n</View>\n</View>\n@@ -150,6 +154,10 @@ class InnerAddThread extends React.PureComponent {\nthis.setState({ selectedPrivacyIndex: index });\n}\n+ setUsernameInputText = (text: string) => {\n+ this.setState({ usernameInputText: text });\n+ }\n+\n}\nconst styles = StyleSheet.create({\n"
},
{
"change_type": "MODIFY",
"old_path": "native/components/tag-input.react.js",
"new_path": "native/components/tag-input.react.js",
"diff": "@@ -28,6 +28,10 @@ const tagDataPropType = PropTypes.oneOfType([\n]);\ntype Props = {\n+ // The text currently being displayed as the user types\n+ text: string,\n+ // Callback to update the text being displayed\n+ setText: (text: string) => void,\n// A handler to be called when array of tags change\nonChange: (items: $ReadOnlyArray<TagData>) => void,\n// An array of tags\n@@ -55,7 +59,6 @@ type Props = {\n};\ntype State = {\n- text: string,\ninputWidth: ?number,\nlines: number,\n};\n@@ -81,7 +84,6 @@ class TagInput extends React.PureComponent {\n};\nprops: Props;\nstate: State = {\n- text: '',\ninputWidth: null,\nlines: 1,\n};\n@@ -106,38 +108,40 @@ class TagInput extends React.PureComponent {\n}\nonChangeText = (text: string) => {\n- this.setState({ text: text });\n+ this.props.setText(text);\nconst lastTyped = text.charAt(text.length - 1);\nconst parseWhen = this.props.separators || DEFAULT_SEPARATORS;\nif (parseWhen.indexOf(lastTyped) > -1) {\n- this.parseTags();\n+ this.parseTags(text);\n}\n}\nonBlur = (event: { nativeEvent: { text: string } }) => {\n- this.setState({ text: event.nativeEvent.text });\n+ const text = event.nativeEvent.text;\n+ this.props.setText(text);\nif (this.props.parseOnBlur) {\n- this.parseTags();\n+ this.parseTags(text);\n}\n}\n- parseTags = () => {\n- const { text } = this.state;\n+ parseTags = (text: ?string) => {\n+ text = text ? text : this.props.text;\n+\nconst { value } = this.props;\nconst regex = this.props.regex || DEFAULT_TAG_REGEX;\nconst results = text.match(regex);\nif (results && results.length > 0) {\n- this.setState({ text: '' });\n+ this.props.setText('');\nthis.props.onChange([...new Set([...value, ...results])]);\n}\n}\nonKeyPress = (event: { nativeEvent: { key: string } }) => {\n- if (this.state.text !== '' || event.nativeEvent.key !== 'Backspace') {\n+ if (this.props.text !== '' || event.nativeEvent.key !== 'Backspace') {\nreturn;\n}\nconst tags = [...this.props.value];\n@@ -172,7 +176,7 @@ class TagInput extends React.PureComponent {\n}\nrender() {\n- const { text, inputWidth, lines } = this.state;\n+ const { inputWidth, lines } = this.state;\nconst { inputColor } = this.props;\nconst defaultInputProps = {\n@@ -232,7 +236,7 @@ class TagInput extends React.PureComponent {\nref={this.tagInputRef}\nblurOnSubmit={false}\nonKeyPress={this.onKeyPress}\n- value={text}\n+ value={this.props.text}\nstyle={[styles.textInput, {\nwidth: width,\ncolor: inputColor,\n@@ -289,9 +293,7 @@ class TagInput extends React.PureComponent {\n}\n-class Tag extends React.PureComponent {\n-\n- props: {\n+type TagProps = {\nindex: number,\ntag: TagData,\nisLastTag: bool,\n@@ -303,6 +305,9 @@ class Tag extends React.PureComponent {\ntagContainerStyle?: StyleObj,\ntagTextStyle?: StyleObj,\n};\n+class Tag extends React.PureComponent {\n+\n+ props: TagProps;\nstatic propTypes = {\nindex: PropTypes.number.isRequired,\ntag: tagDataPropType.isRequired,\n@@ -315,16 +320,24 @@ class Tag extends React.PureComponent {\ntagContainerStyle: ViewPropTypes.style,\ntagTextStyle: Text.propTypes.style,\n};\n+ curPos: ?number = null;\n- render() {\n- let onLayout = undefined;\n- if (this.props.isLastTag) {\n- onLayout = this.onLayoutLastTag;\n+ componentWillReceiveProps(nextProps: TagProps) {\n+ if (\n+ !this.props.isLastTag &&\n+ nextProps.isLastTag &&\n+ this.curPos !== null &&\n+ this.curPos !== undefined\n+ ) {\n+ this.props.onLayoutLastTag(this.curPos);\n}\n+ }\n+\n+ render() {\nreturn (\n<TouchableOpacity\nonPress={this.onPress}\n- onLayout={onLayout}\n+ onLayout={this.onLayoutLastTag}\nstyle={[\nstyles.tag,\n{ backgroundColor: this.props.tagColor },\n@@ -351,7 +364,10 @@ class Tag extends React.PureComponent {\nevent: { nativeEvent: { layout: { x: number, width: number } } },\n) => {\nconst layout = event.nativeEvent.layout;\n- this.props.onLayoutLastTag(layout.width + layout.x);\n+ this.curPos = layout.width + layout.x;\n+ if (this.props.isLastTag) {\n+ this.props.onLayoutLastTag(this.curPos);\n+ }\n}\ngetLabelValue = () => {\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Lift username input state from TagInput to AddThread and make sure when last Tag is deleted, new last Tag calls onLayoutLastTag |
129,187 | 18.07.2017 19:57:32 | 14,400 | 6dd3a2625b12d871623192f8a5115effb7e2e719 | Get rid of logic to push new tags into the TagInput from the TagInput | [
{
"change_type": "MODIFY",
"old_path": "native/components/tag-input.react.js",
"new_path": "native/components/tag-input.react.js",
"diff": "@@ -36,10 +36,6 @@ type Props = {\nonChange: (items: $ReadOnlyArray<TagData>) => void,\n// An array of tags\nvalue: $ReadOnlyArray<TagData>,\n- // An array os characters to use as tag separators\n- separators?: $ReadOnlyArray<string>,\n- // A RegExp to test tags after enter, space, or a comma is pressed\n- regex?: RegExp,\n// Background color of tags\ntagColor: string,\n// Text color of tags\n@@ -57,22 +53,15 @@ type Props = {\n// maximum number of lines of this component\nnumberOfLines: number,\n};\n-\ntype State = {\ninputWidth: ?number,\nlines: number,\n};\n-\n-const DEFAULT_SEPARATORS = [',', ' ', ';', '\\n'];\n-const DEFAULT_TAG_REGEX = /(.+)/gi;\n-\nclass TagInput extends React.PureComponent {\nstatic propTypes = {\nonChange: PropTypes.func.isRequired,\nvalue: PropTypes.arrayOf(tagDataPropType).isRequired,\n- separators: PropTypes.arrayOf(PropTypes.string),\n- regex: PropTypes.object,\ntagColor: PropTypes.string,\ntagTextColor: PropTypes.string,\ntagContainerStyle: ViewPropTypes.style,\n@@ -109,35 +98,10 @@ class TagInput extends React.PureComponent {\nonChangeText = (text: string) => {\nthis.props.setText(text);\n- const lastTyped = text.charAt(text.length - 1);\n-\n- const parseWhen = this.props.separators || DEFAULT_SEPARATORS;\n-\n- if (parseWhen.indexOf(lastTyped) > -1) {\n- this.parseTags(text);\n- }\n}\nonBlur = (event: { nativeEvent: { text: string } }) => {\n- const text = event.nativeEvent.text;\n- this.props.setText(text);\n- if (this.props.parseOnBlur) {\n- this.parseTags(text);\n- }\n- }\n-\n- parseTags = (text: ?string) => {\n- text = text ? text : this.props.text;\n-\n- const { value } = this.props;\n-\n- const regex = this.props.regex || DEFAULT_TAG_REGEX;\n- const results = text.match(regex);\n-\n- if (results && results.length > 0) {\n- this.props.setText('');\n- this.props.onChange([...new Set([...value, ...results])]);\n- }\n+ this.props.setText(event.nativeEvent.text);\n}\nonKeyPress = (event: { nativeEvent: { key: string } }) => {\n@@ -243,7 +207,6 @@ class TagInput extends React.PureComponent {\n}]}\nonBlur={this.onBlur}\nonChangeText={this.onChangeText}\n- onSubmitEditing={this.parseTags}\n{...inputProps}\n/>\n</View>\n@@ -422,5 +385,3 @@ const styles = StyleSheet.create({\n});\nexport default TagInput;\n-\n-export { DEFAULT_SEPARATORS, DEFAULT_TAG_REGEX }\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Get rid of logic to push new tags into the TagInput from the TagInput |
129,187 | 18.07.2017 20:39:00 | 14,400 | e4a983c3e7fe50fd01b324af6ef64c3439bfb9c2 | Maintain userSearchResults in AddThread state | [
{
"change_type": "MODIFY",
"old_path": "lib/shared/search-index.js",
"new_path": "lib/shared/search-index.js",
"diff": "@@ -69,9 +69,7 @@ class SearchIndex {\nif (!fullMatches) {\nreturn [];\n}\n- possibleMatches = possibleMatches.filter(\n- (navID) => fullMatches.has(navID)\n- );\n+ possibleMatches = possibleMatches.filter((id) => fullMatches.has(id));\nif (possibleMatches.length === 0) {\nreturn [];\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/add-thread.react.js",
"new_path": "native/chat/add-thread.react.js",
"diff": "@@ -37,9 +37,7 @@ type NavProp = NavigationScreenProp<NavigationRoute, NavigationAction>;\nconst segmentedPrivacyOptions = ['Public', 'Secret'];\ntype TagData = string | {[key: string]: string};\n-class InnerAddThread extends React.PureComponent {\n-\n- props: {\n+type Props = {\nnavigation: NavProp,\n// Redux state\nloadingStatus: LoadingStatus,\n@@ -47,16 +45,15 @@ class InnerAddThread extends React.PureComponent {\notherUserInfos: {[id: string]: UserInfo},\nuserSearchIndex: SearchIndex,\n};\n+class InnerAddThread extends React.PureComponent {\n+\n+ props: Props;\nstate: {\nnameInputText: string,\nusernameInputText: string,\nusernameInputArray: $ReadOnlyArray<string>,\n+ userSearchResults: $ReadOnlyArray<UserInfo>,\nselectedPrivacyIndex: number,\n- } = {\n- nameInputText: \"\",\n- usernameInputText: \"\",\n- usernameInputArray: [],\n- selectedPrivacyIndex: 0,\n};\nstatic propTypes = {\nnavigation: PropTypes.shape({\n@@ -76,6 +73,55 @@ class InnerAddThread extends React.PureComponent {\n};\nnameInput: ?TextInput;\n+ static getUserSearchResults(\n+ text: string,\n+ userInfos: {[id: string]: UserInfo},\n+ searchIndex: SearchIndex,\n+ ) {\n+ const results = [];\n+ if (text === \"\") {\n+ for (let id in userInfos) {\n+ results.push(userInfos[id]);\n+ }\n+ } else {\n+ const ids = searchIndex.getSearchResults(text);\n+ for (let id of ids) {\n+ results.push(userInfos[id]);\n+ }\n+ }\n+ return results;\n+ }\n+\n+ constructor(props: Props) {\n+ super(props);\n+ const userSearchResults = InnerAddThread.getUserSearchResults(\n+ \"\",\n+ props.otherUserInfos,\n+ props.userSearchIndex,\n+ );\n+ this.state = {\n+ nameInputText: \"\",\n+ usernameInputText: \"\",\n+ usernameInputArray: [],\n+ userSearchResults,\n+ selectedPrivacyIndex: 0,\n+ };\n+ }\n+\n+ componentWillReceiveProps(nextProps: Props) {\n+ if (\n+ this.props.otherUserInfos !== nextProps.otherUserInfos ||\n+ this.props.userSearchIndex !== nextProps.userSearchIndex\n+ ) {\n+ const userSearchResults = InnerAddThread.getUserSearchResults(\n+ this.state.usernameInputText,\n+ nextProps.otherUserInfos,\n+ nextProps.userSearchIndex,\n+ );\n+ this.setState({ userSearchResults });\n+ }\n+ }\n+\nrender() {\nlet visibility;\nif (this.props.threadInfo) {\n@@ -163,7 +209,12 @@ class InnerAddThread extends React.PureComponent {\n}\nsetUsernameInputText = (text: string) => {\n- this.setState({ usernameInputText: text });\n+ const userSearchResults = InnerAddThread.getUserSearchResults(\n+ text,\n+ this.props.otherUserInfos,\n+ this.props.userSearchIndex,\n+ );\n+ this.setState({ usernameInputText: text, userSearchResults });\n}\n}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Maintain userSearchResults in AddThread state |
129,187 | 19.07.2017 15:13:48 | 14,400 | eefbf66422fb5c69a1bcc524162eb9b14be97fa5 | Really primitive user autocomplete for creating new threads | [
{
"change_type": "MODIFY",
"old_path": "native/chat/add-thread.react.js",
"new_path": "native/chat/add-thread.react.js",
"diff": "@@ -32,6 +32,7 @@ import { otherUserInfos, userSearchIndex } from 'lib/selectors/user-selectors';\nimport SearchIndex from 'lib/shared/search-index';\nimport TagInput from '../components/tag-input.react';\n+import UserList from '../components/user-list.react';\ntype NavProp = NavigationScreenProp<NavigationRoute, NavigationAction>;\nconst segmentedPrivacyOptions = ['Public', 'Secret'];\n@@ -77,16 +78,22 @@ class InnerAddThread extends React.PureComponent {\ntext: string,\nuserInfos: {[id: string]: UserInfo},\nsearchIndex: SearchIndex,\n+ usernameInputArray: $ReadOnlyArray<string>,\n) {\nconst results = [];\n+ const appendUserInfo = (userInfo: UserInfo) => {\n+ if (!usernameInputArray.includes(userInfo.username)) {\n+ results.push(userInfo);\n+ }\n+ };\nif (text === \"\") {\nfor (let id in userInfos) {\n- results.push(userInfos[id]);\n+ appendUserInfo(userInfos[id]);\n}\n} else {\nconst ids = searchIndex.getSearchResults(text);\nfor (let id of ids) {\n- results.push(userInfos[id]);\n+ appendUserInfo(userInfos[id]);\n}\n}\nreturn results;\n@@ -98,6 +105,7 @@ class InnerAddThread extends React.PureComponent {\n\"\",\nprops.otherUserInfos,\nprops.userSearchIndex,\n+ [],\n);\nthis.state = {\nnameInputText: \"\",\n@@ -117,6 +125,7 @@ class InnerAddThread extends React.PureComponent {\nthis.state.usernameInputText,\nnextProps.otherUserInfos,\nnextProps.userSearchIndex,\n+ this.state.usernameInputArray,\n);\nthis.setState({ userSearchResults });\n}\n@@ -183,6 +192,10 @@ class InnerAddThread extends React.PureComponent {\n/>\n</View>\n</View>\n+ <UserList\n+ userInfos={this.state.userSearchResults}\n+ onSelect={this.onUserSelect}\n+ />\n</View>\n);\n}\n@@ -201,7 +214,13 @@ class InnerAddThread extends React.PureComponent {\ninvariant(typeof tagData === \"string\", \"AddThread uses string TagData\");\nstringArray.push(tagData);\n}\n- this.setState({ usernameInputArray: stringArray });\n+ const userSearchResults = InnerAddThread.getUserSearchResults(\n+ this.state.usernameInputText,\n+ this.props.otherUserInfos,\n+ this.props.userSearchIndex,\n+ stringArray,\n+ );\n+ this.setState({ usernameInputArray: stringArray, userSearchResults });\n}\nhandleIndexChange = (index: number) => {\n@@ -213,10 +232,33 @@ class InnerAddThread extends React.PureComponent {\ntext,\nthis.props.otherUserInfos,\nthis.props.userSearchIndex,\n+ this.state.usernameInputArray,\n);\nthis.setState({ usernameInputText: text, userSearchResults });\n}\n+ onUserSelect = (userID: string) => {\n+ const username = this.props.otherUserInfos[userID].username;\n+ if (this.state.usernameInputArray.includes(username)) {\n+ return;\n+ }\n+ const usernameInputArray = [\n+ ...this.state.usernameInputArray,\n+ this.props.otherUserInfos[userID].username,\n+ ];\n+ const userSearchResults = InnerAddThread.getUserSearchResults(\n+ \"\",\n+ this.props.otherUserInfos,\n+ this.props.userSearchIndex,\n+ usernameInputArray,\n+ );\n+ this.setState({\n+ usernameInputArray,\n+ usernameInputText: \"\",\n+ userSearchResults,\n+ });\n+ }\n+\n}\nconst styles = StyleSheet.create({\n@@ -230,20 +272,20 @@ const styles = StyleSheet.create({\nmarginBottom: 10,\n},\ninput: {\n- flex: 3,\n+ flex: 1,\npaddingRight: 12,\n},\nlabel: {\npaddingTop: 2,\npaddingLeft: 12,\nfontSize: 20,\n- flex: 1,\n+ width: 100,\n},\ntagInputLabel: {\npaddingTop: 2,\npaddingLeft: 12,\nfontSize: 20,\n- flex: 1,\n+ width: 100,\n},\ntextInput: {\nfontSize: 18,\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/components/user-list-user.react.js",
"diff": "+// @flow\n+\n+import type { UserInfo } from 'lib/types/user-types';\n+import { userInfoPropType } from 'lib/types/user-types';\n+\n+import React from 'react';\n+import PropTypes from 'prop-types';\n+import {\n+ StyleSheet,\n+ Text,\n+} from 'react-native';\n+\n+import Button from './button.react';\n+\n+class UserListUser extends React.PureComponent {\n+\n+ props: {\n+ userInfo: UserInfo,\n+ onSelect: (userID: string) => void,\n+ };\n+ static propTypes = {\n+ userInfo: userInfoPropType.isRequired,\n+ onSelect: PropTypes.func.isRequired,\n+ };\n+\n+ render() {\n+ return (\n+ <Button onSubmit={this.onSelect}>\n+ <Text style={styles.text}>{this.props.userInfo.username}</Text>\n+ </Button>\n+ );\n+ }\n+\n+ onSelect = () => {\n+ this.props.onSelect(this.props.userInfo.id);\n+ }\n+\n+}\n+\n+const styles = StyleSheet.create({\n+ text: {\n+ paddingHorizontal: 12,\n+ paddingVertical: 6,\n+ fontSize: 16,\n+ },\n+});\n+\n+\n+export default UserListUser;\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/components/user-list.react.js",
"diff": "+// @flow\n+\n+import type { UserInfo } from 'lib/types/user-types';\n+import { userInfoPropType } from 'lib/types/user-types';\n+\n+import React from 'react';\n+import PropTypes from 'prop-types';\n+import {\n+ FlatList,\n+ StyleSheet,\n+} from 'react-native';\n+\n+import UserListUser from './user-list-user.react';\n+\n+class UserList extends React.PureComponent {\n+\n+ props: {\n+ userInfos: $ReadOnlyArray<UserInfo>,\n+ onSelect: (userID: string) => void,\n+ };\n+ static propTypes = {\n+ userInfos: PropTypes.arrayOf(userInfoPropType).isRequired,\n+ onSelect: PropTypes.func.isRequired,\n+ };\n+\n+ render() {\n+ return (\n+ <FlatList\n+ data={this.props.userInfos}\n+ renderItem={this.renderItem}\n+ keyExtractor={UserList.keyExtractor}\n+ getItemLayout={UserList.getItemLayout}\n+ keyboardShouldPersistTaps=\"handled\"\n+ style={styles.flatList}\n+ />\n+ );\n+ }\n+\n+ static keyExtractor(threadInfo: UserInfo) {\n+ return threadInfo.id;\n+ }\n+\n+ renderItem = (row: { item: UserInfo }) => {\n+ return (\n+ <UserListUser\n+ userInfo={row.item}\n+ onSelect={this.props.onSelect}\n+ />\n+ );\n+ }\n+\n+ static getItemLayout(data: $ReadOnlyArray<UserInfo>, index: number) {\n+ return { length: 24, offset: 24 * index, index };\n+ }\n+\n+}\n+\n+const styles = StyleSheet.create({\n+ flatList: {\n+ marginLeft: 88,\n+ marginRight: 12,\n+ },\n+});\n+\n+export default UserList;\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Really primitive user autocomplete for creating new threads |
129,187 | 21.07.2017 15:43:04 | 14,400 | 1c893a869920a62cc4520e6b70dae79e738c8072 | Upgrade react-native to 0.46.4 | [
{
"change_type": "MODIFY",
"old_path": "native/package-lock.json",
"new_path": "native/package-lock.json",
"diff": "\"integrity\": \"sha1-HtkZnanL/i7y96MbL96LDRI2iXI=\",\n\"requires\": {\n\"iconv-lite\": \"0.4.18\",\n- \"jschardet\": \"1.4.2\",\n+ \"jschardet\": \"1.5.0\",\n\"tmp\": \"0.0.31\"\n}\n},\n\"optional\": true\n},\n\"jschardet\": {\n- \"version\": \"1.4.2\",\n- \"resolved\": \"https://registry.npmjs.org/jschardet/-/jschardet-1.4.2.tgz\",\n- \"integrity\": \"sha1-KqEH8UKvQSHRRWWdRPUIMJYeaZo=\"\n+ \"version\": \"1.5.0\",\n+ \"resolved\": \"https://registry.npmjs.org/jschardet/-/jschardet-1.5.0.tgz\",\n+ \"integrity\": \"sha512-+Q8JsoEQbrdE+a/gg1F9XO92gcKXgpE5UACqr0sIubjDmBEkd+OOWPGzQeMrWSLxd73r4dHxBeRW7edHu5LmJQ==\"\n},\n\"jsdom\": {\n\"version\": \"9.12.0\",\n}\n},\n\"react\": {\n- \"version\": \"16.0.0-alpha.13\",\n- \"resolved\": \"https://registry.npmjs.org/react/-/react-16.0.0-alpha.13.tgz\",\n- \"integrity\": \"sha1-3jfgNbBig6Fc+5FsaUO5sGayXeA=\",\n+ \"version\": \"16.0.0-alpha.12\",\n+ \"resolved\": \"https://registry.npmjs.org/react/-/react-16.0.0-alpha.12.tgz\",\n+ \"integrity\": \"sha1-jFlIUoFIXfMZtvd2gtjdBiHAgZQ=\",\n\"requires\": {\n+ \"create-react-class\": \"15.6.0\",\n\"fbjs\": \"0.8.12\",\n\"loose-envify\": \"1.3.1\",\n\"object-assign\": \"4.1.1\",\n}\n},\n\"react-native\": {\n- \"version\": \"0.46.2\",\n- \"resolved\": \"https://registry.npmjs.org/react-native/-/react-native-0.46.2.tgz\",\n- \"integrity\": \"sha1-6HqA+ou5ScvQVi+hE5kpOFKkR6o=\",\n+ \"version\": \"0.46.4\",\n+ \"resolved\": \"https://registry.npmjs.org/react-native/-/react-native-0.46.4.tgz\",\n+ \"integrity\": \"sha1-KBu8wWXlw2tMjqqGjmdoVD6BG8s=\",\n\"requires\": {\n\"absolute-path\": \"0.0.0\",\n\"art\": \"0.10.1\",\n\"resolved\": \"https://registry.npmjs.org/react-native-dismiss-keyboard/-/react-native-dismiss-keyboard-1.0.0.tgz\",\n\"integrity\": \"sha1-MohiQrPyMX4SHzrrmwpYXiuHm0k=\"\n},\n+ \"react-native-drawer-layout\": {\n+ \"version\": \"1.3.2\",\n+ \"resolved\": \"https://registry.npmjs.org/react-native-drawer-layout/-/react-native-drawer-layout-1.3.2.tgz\",\n+ \"integrity\": \"sha512-fjO0scqbJUfNu2wuEpvywL7DYLXuCXJ2W/zYhWz986rdLytidbys1QGVvkaszHrb4Y7OqO96mTkgpOcP8KWevw==\",\n+ \"requires\": {\n+ \"react-native-dismiss-keyboard\": \"1.0.0\"\n+ }\n+ },\n+ \"react-native-drawer-layout-polyfill\": {\n+ \"version\": \"1.3.2\",\n+ \"resolved\": \"https://registry.npmjs.org/react-native-drawer-layout-polyfill/-/react-native-drawer-layout-polyfill-1.3.2.tgz\",\n+ \"integrity\": \"sha512-XzPhfLDJrYHru+e8+dFwhf0FtTeAp7JXPpFYezYV6P1nTeA1Tia/kDpFT+O2DWTrBKBEI8FGhZnThrroZmHIxg==\",\n+ \"requires\": {\n+ \"react-native-drawer-layout\": \"1.3.2\"\n+ }\n+ },\n\"react-native-invertible-flat-list\": {\n\"version\": \"1.1.0\",\n\"resolved\": \"https://registry.npmjs.org/react-native-invertible-flat-list/-/react-native-invertible-flat-list-1.1.0.tgz\",\n\"prop-types\": \"15.5.10\"\n}\n},\n+ \"react-native-tab-view\": {\n+ \"version\": \"0.0.67\",\n+ \"resolved\": \"https://registry.npmjs.org/react-native-tab-view/-/react-native-tab-view-0.0.67.tgz\",\n+ \"integrity\": \"sha1-zdFG/l5dS6/2yJ8tXQsV+iPbOdA=\",\n+ \"requires\": {\n+ \"prop-types\": \"15.5.10\"\n+ }\n+ },\n\"react-native-vector-icons\": {\n\"version\": \"4.2.0\",\n\"resolved\": \"https://registry.npmjs.org/react-native-vector-icons/-/react-native-vector-icons-4.2.0.tgz\",\n}\n},\n\"react-navigation\": {\n- \"version\": \"git+https://github.com/ashoat/react-navigation.git#8a694530a18802e14899bc743de525f6658f0fac\",\n+ \"version\": \"git+https://github.com/ashoat/react-navigation.git#b2078e113c945f7468494fef6277827e50ad22f2\",\n\"requires\": {\n\"clamp\": \"1.0.1\",\n\"hoist-non-react-statics\": \"1.2.0\",\n\"prop-types\": \"15.5.10\",\n\"react-native-drawer-layout-polyfill\": \"1.3.2\",\n\"react-native-tab-view\": \"0.0.67\"\n- },\n- \"dependencies\": {\n- \"react-native-drawer-layout-polyfill\": {\n- \"version\": \"1.3.2\",\n- \"resolved\": \"https://registry.npmjs.org/react-native-drawer-layout-polyfill/-/react-native-drawer-layout-polyfill-1.3.2.tgz\",\n- \"integrity\": \"sha512-XzPhfLDJrYHru+e8+dFwhf0FtTeAp7JXPpFYezYV6P1nTeA1Tia/kDpFT+O2DWTrBKBEI8FGhZnThrroZmHIxg==\",\n- \"requires\": {\n- \"react-native-drawer-layout\": \"1.3.2\"\n- },\n- \"dependencies\": {\n- \"react-native-drawer-layout\": {\n- \"version\": \"1.3.2\",\n- \"resolved\": \"https://registry.npmjs.org/react-native-drawer-layout/-/react-native-drawer-layout-1.3.2.tgz\",\n- \"integrity\": \"sha512-fjO0scqbJUfNu2wuEpvywL7DYLXuCXJ2W/zYhWz986rdLytidbys1QGVvkaszHrb4Y7OqO96mTkgpOcP8KWevw==\",\n- \"requires\": {\n- \"react-native-dismiss-keyboard\": \"1.0.0\"\n- }\n- }\n- }\n- },\n- \"react-native-tab-view\": {\n- \"version\": \"0.0.67\",\n- \"resolved\": \"https://registry.npmjs.org/react-native-tab-view/-/react-native-tab-view-0.0.67.tgz\",\n- \"integrity\": \"sha1-zdFG/l5dS6/2yJ8tXQsV+iPbOdA=\",\n- \"requires\": {\n- \"prop-types\": \"15.5.10\"\n- }\n- }\n}\n},\n\"react-proxy\": {\n"
},
{
"change_type": "MODIFY",
"old_path": "native/package.json",
"new_path": "native/package.json",
"diff": "\"invariant\": \"^2.2.2\",\n\"lib\": \"file:../lib\",\n\"react\": \"^16.0.0-alpha.12\",\n- \"react-native\": \"^0.46.1\",\n+ \"react-native\": \"^0.46.4\",\n\"react-native-cookies\": \"^3.1.0\",\n\"react-native-invertible-flat-list\": \"^1.1.0\",\n\"react-native-keychain\": \"^1.2.0\",\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Upgrade react-native to 0.46.4 |
129,187 | 01.08.2017 21:18:12 | 14,400 | 3ec7558589ba0c71c9d50d02e711f0845f6ecfc6 | Only add cookie to POST on native (getConfig().setCookieOnRequest) | [
{
"change_type": "MODIFY",
"old_path": "lib/utils/config.js",
"new_path": "lib/utils/config.js",
"diff": "@@ -11,6 +11,7 @@ export type Config = {\ndispatchRecoveryAttempt: DispatchRecoveryAttempt,\n) => Promise<void>),\ngetNewCookie: ?((response: Object) => Promise<?string>),\n+ setCookieOnRequest: bool,\ncalendarRangeInactivityLimit: ?number,\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/utils/fetch-json.js",
"new_path": "lib/utils/fetch-json.js",
"diff": "@@ -37,7 +37,9 @@ async function fetchJSON(\nreturn await possibleReplacement(url, data);\n}\n- const mergedData = { ...data, cookie };\n+ const mergedData = getConfig().setCookieOnRequest\n+ ? { ...data, cookie }\n+ : data;\nconst prefixedURL = getConfig().urlPrefix + url;\nconst fetchPromise = fetch(prefixedURL, {\n// Flow gets confused by some enum type, so we need this cast\n"
},
{
"change_type": "MODIFY",
"old_path": "native/app.react.js",
"new_path": "native/app.react.js",
"diff": "@@ -71,6 +71,7 @@ registerConfig({\n}\nreturn null;\n},\n+ setCookieOnRequest: true,\ncalendarRangeInactivityLimit: sessionInactivityLimit,\n});\n"
},
{
"change_type": "MODIFY",
"old_path": "web/script.js",
"new_path": "web/script.js",
"diff": "@@ -67,6 +67,7 @@ registerConfig({\n// We use httponly cookies on web to protect against XSS attacks, so we have\n// no access to the cookies from JavaScript\ngetNewCookie: null,\n+ setCookieOnRequest: false,\n// Never reset the calendar range\ncalendarRangeInactivityLimit: null,\n});\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Only add cookie to POST on native (getConfig().setCookieOnRequest) |
129,187 | 01.08.2017 21:18:31 | 14,400 | 20ab9e5fcffbd3cc318c08c635cdbb0a807dc2d5 | Prefer $_POST['cookie'] to $_COOKIE | [
{
"change_type": "MODIFY",
"old_path": "server/auth.php",
"new_path": "server/auth.php",
"diff": "@@ -62,11 +62,8 @@ function cookie_has_changed() {\n}\nfunction get_input_user_cookie() {\n- if (isset($_COOKIE['user'])) {\n- return $_COOKIE['user'];\n- }\nif (!isset($_POST['cookie'])) {\n- return null;\n+ return isset($_COOKIE['user']) ? $_COOKIE['user'] : null;\n}\n$matches = array();\n$num_matches = preg_match(\"/user=(.+)/\", $_POST['cookie'], $matches);\n@@ -77,11 +74,8 @@ function get_input_user_cookie() {\n}\nfunction get_input_anonymous_cookie() {\n- if (isset($_COOKIE['anonymous'])) {\n- return $_COOKIE['anonymous'];\n- }\nif (!isset($_POST['cookie'])) {\n- return null;\n+ return isset($_COOKIE['cookie']) ? $_COOKIE['cookie'] : null;\n}\n$matches = array();\n$num_matches = preg_match(\"/anonymous=(.+)/\", $_POST['cookie'], $matches);\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Prefer $_POST['cookie'] to $_COOKIE |
129,187 | 01.08.2017 21:52:31 | 14,400 | 0f57c2f3fe5414609feb9f9c233851a2febe8a40 | Parse .native.js files in native/.flowconfig for react-navigation | [
{
"change_type": "MODIFY",
"old_path": "native/.flowconfig",
"new_path": "native/.flowconfig",
"diff": "@@ -33,6 +33,11 @@ munge_underscores=true\nmodule.name_mapper='^[./a-zA-Z0-9$_-]+\\.\\(bmp\\|gif\\|jpg\\|jpeg\\|png\\|psd\\|svg\\|webp\\|m4v\\|mov\\|mp4\\|mpeg\\|mpg\\|webm\\|aac\\|aiff\\|caf\\|m4a\\|mp3\\|wav\\|html\\|pdf\\)$' -> 'RelativeImageStub'\nmodule.name_mapper='^lib/(.*)$' -> '<PROJECT_ROOT>/../lib/\\1'\n+module.file_ext=.js\n+module.file_ext=.jsx\n+module.file_ext=.json\n+module.file_ext=.native.js\n+\nsuppress_type=$FlowIssue\nsuppress_type=$FlowFixMe\nsuppress_type=$FixMe\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Parse .native.js files in native/.flowconfig for react-navigation |
129,187 | 02.08.2017 15:19:46 | 14,400 | 31b14728ad4e34c4b52da4a6bfca033f508ced82 | `babel-plugin-transform-remove-strict-mode` so we can run on Android | [
{
"change_type": "MODIFY",
"old_path": "native/.babelrc",
"new_path": "native/.babelrc",
"diff": "{\npresets: ['react-native'],\n+ plugins: ['transform-remove-strict-mode'],\nenv: {\nproduction: {\nplugins: ['transform-remove-console'],\n"
},
{
"change_type": "MODIFY",
"old_path": "native/package-lock.json",
"new_path": "native/package-lock.json",
"diff": "\"integrity\": \"sha1-Qf3awZpymkw91+8pZOrAewlvmo8=\",\n\"dev\": true\n},\n+ \"babel-plugin-transform-remove-strict-mode\": {\n+ \"version\": \"0.0.2\",\n+ \"resolved\": \"https://registry.npmjs.org/babel-plugin-transform-remove-strict-mode/-/babel-plugin-transform-remove-strict-mode-0.0.2.tgz\",\n+ \"integrity\": \"sha1-kTaFqrlUOfOg7YjliPvV6ZeJBXk=\"\n+ },\n\"babel-plugin-transform-strict-mode\": {\n\"version\": \"6.24.1\",\n\"resolved\": \"https://registry.npmjs.org/babel-plugin-transform-strict-mode/-/babel-plugin-transform-strict-mode-6.24.1.tgz\",\n"
},
{
"change_type": "MODIFY",
"old_path": "native/package.json",
"new_path": "native/package.json",
"diff": "\"devtools\": \"react-devtools\"\n},\n\"dependencies\": {\n+ \"babel-plugin-transform-remove-strict-mode\": \"0.0.2\",\n\"color\": \"^1.0.3\",\n\"invariant\": \"^2.2.2\",\n\"lib\": \"file:../lib\",\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | `babel-plugin-transform-remove-strict-mode` so we can run on Android |
129,187 | 03.08.2017 15:22:43 | 14,400 | 157f680f13ca2b18170887b4c7bc7da44bfc432c | Stabilize TagInput | [
{
"change_type": "MODIFY",
"old_path": "native/chat/add-thread.react.js",
"new_path": "native/chat/add-thread.react.js",
"diff": "@@ -73,6 +73,7 @@ class InnerAddThread extends React.PureComponent {\nusernameInputArray: $ReadOnlyArray<string>,\nuserSearchResults: $ReadOnlyArray<UserInfo>,\nselectedPrivacyIndex: number,\n+ tagInputHeight: number,\n};\nstatic propTypes = {\nnavigation: PropTypes.shape({\n@@ -134,6 +135,7 @@ class InnerAddThread extends React.PureComponent {\nusernameInputArray: [],\nuserSearchResults,\nselectedPrivacyIndex: 0,\n+ tagInputHeight: 36,\n};\n}\n@@ -206,7 +208,7 @@ class InnerAddThread extends React.PureComponent {\n</View>\n</View>\n{visibility}\n- <View style={styles.row}>\n+ <View style={[styles.row, { height: this.state.tagInputHeight }]}>\n<Text style={styles.tagInputLabel}>People</Text>\n<View style={styles.input}>\n<TagInput\n@@ -214,6 +216,7 @@ class InnerAddThread extends React.PureComponent {\nvalue={this.state.usernameInputArray}\ntext={this.state.usernameInputText}\nsetText={this.setUsernameInputText}\n+ onHeightChange={this.onTagInputHeightChange}\n/>\n</View>\n</View>\n@@ -292,6 +295,10 @@ class InnerAddThread extends React.PureComponent {\n});\n}\n+ onTagInputHeightChange = (height: number) => {\n+ this.setState({ tagInputHeight: height });\n+ }\n+\n}\nconst styles = StyleSheet.create({\n"
},
{
"change_type": "MODIFY",
"old_path": "native/components/tag-input.react.js",
"new_path": "native/components/tag-input.react.js",
"diff": "@@ -21,6 +21,14 @@ import {\nimport invariant from 'invariant';\nconst windowWidth = Dimensions.get('window').width;\n+const defaultInputProps = {\n+ autoCapitalize: 'none',\n+ autoCorrect: false,\n+ placeholder: 'username',\n+ returnKeyType: 'done',\n+ keyboardType: 'default',\n+ underlineColorAndroid: 'rgba(0,0,0,0)',\n+};\ntype TagData = string | {[key: string]: string};\nconst tagDataPropType = PropTypes.oneOfType([\n@@ -51,12 +59,14 @@ type Props = {\ninputProps?: $PropertyType<Text, 'props'>,\n// path of the label in tags objects\nlabelKey?: string,\n- // maximum number of lines of this component\n- numberOfLines: number,\n+ // maximum height of this component\n+ maxHeight: number,\n+ // callback that gets triggered when the component height changes\n+ onHeightChange: ?(height: number) => void,\n};\ntype State = {\n- inputWidth: ?number,\n- lines: number,\n+ inputWidth: number,\n+ wrapperHeight: number,\n};\nclass TagInput extends React.PureComponent {\n@@ -70,14 +80,16 @@ class TagInput extends React.PureComponent {\ninputColor: PropTypes.string,\ninputProps: PropTypes.object,\nlabelKey: PropTypes.string,\n- numberOfLines: PropTypes.number,\n+ maxHeight: PropTypes.number,\n+ onHeightChange: PropTypes.func,\n};\nprops: Props;\nstate: State = {\n- inputWidth: null,\n- lines: 1,\n+ inputWidth: 90,\n+ wrapperHeight: 36,\n};\nwrapperWidth = windowWidth;\n+ spaceLeft = 0;\n// scroll to bottom\ncontentHeight = 0;\nscrollViewHeight = 0;\n@@ -89,12 +101,49 @@ class TagInput extends React.PureComponent {\ntagColor: '#dddddd',\ntagTextColor: '#777777',\ninputColor: '#777777',\n- numberOfLines: 2,\n+ maxHeight: 75,\n};\n+ static inputWidth(text: string, spaceLeft: number, wrapperWidth: number) {\n+ if (text === \"\") {\n+ return 90;\n+ } else if (spaceLeft >= 100) {\n+ return spaceLeft - 10;\n+ } else {\n+ return wrapperWidth;\n+ }\n+ }\n+\n+ componentWillReceiveProps(nextProps: Props) {\n+ const inputWidth = TagInput.inputWidth(\n+ nextProps.text,\n+ this.spaceLeft,\n+ this.wrapperWidth,\n+ );\n+ if (inputWidth !== this.state.inputWidth) {\n+ this.setState({ inputWidth });\n+ }\n+ }\n+\n+ componentWillUpdate(nextProps: Props, nextState: State) {\n+ if (\n+ this.props.onHeightChange &&\n+ nextState.wrapperHeight !== this.state.wrapperHeight\n+ ) {\n+ this.props.onHeightChange(nextState.wrapperHeight);\n+ }\n+ }\n+\nmeasureWrapper = (event: { nativeEvent: { layout: { width: number } } }) => {\nthis.wrapperWidth = event.nativeEvent.layout.width;\n- this.setState({ inputWidth: this.wrapperWidth });\n+ const inputWidth = TagInput.inputWidth(\n+ this.props.text,\n+ this.spaceLeft,\n+ this.wrapperWidth,\n+ );\n+ if (inputWidth !== this.state.inputWidth) {\n+ this.setState({ inputWidth });\n+ }\n}\nonChangeText = (text: string) => {\n@@ -142,23 +191,9 @@ class TagInput extends React.PureComponent {\n}\nrender() {\n- const { inputWidth, lines } = this.state;\n- const { inputColor } = this.props;\n-\n- const defaultInputProps = {\n- autoCapitalize: 'none',\n- autoCorrect: false,\n- placeholder: 'username',\n- returnKeyType: 'done',\n- keyboardType: 'default',\n- underlineColorAndroid: 'rgba(0,0,0,0)',\n- }\n-\nconst inputProps = { ...defaultInputProps, ...this.props.inputProps };\n- const wrapperHeight = (lines - 1) * 40 + 36;\n-\n- const width = inputWidth ? inputWidth : 400;\n+ const inputWidth = this.state.inputWidth;\nconst tags = this.props.value.map((tag, index) => (\n<Tag\n@@ -183,7 +218,7 @@ class TagInput extends React.PureComponent {\nonLayout={this.measureWrapper}\n>\n<View\n- style={[styles.wrapper, { height: wrapperHeight }]}\n+ style={[styles.wrapper, { height: this.state.wrapperHeight }]}\n>\n<ScrollView\nref={this.scrollViewRef}\n@@ -196,17 +231,17 @@ class TagInput extends React.PureComponent {\n{tags}\n<View style={[\nstyles.textInputContainer,\n- { width: this.state.inputWidth },\n+ { width: inputWidth },\n]}>\n<TextInput\nref={this.tagInputRef}\nblurOnSubmit={false}\nonKeyPress={this.onKeyPress}\nvalue={this.props.text}\n- style={[styles.textInput, {\n- width: width,\n- color: inputColor,\n- }]}\n+ style={[\n+ styles.textInput,\n+ { width: inputWidth, color: this.props.inputColor },\n+ ]}\nonBlur={Platform.OS === \"ios\" ? this.onBlur : undefined}\nonChangeText={this.onChangeText}\n{...inputProps}\n@@ -228,6 +263,20 @@ class TagInput extends React.PureComponent {\n}\nonScrollViewContentSizeChange = (w: number, h: number) => {\n+ if (this.contentHeight === h) {\n+ return;\n+ }\n+ const nextWrapperHeight = h > this.props.maxHeight\n+ ? this.props.maxHeight\n+ : h;\n+ if (nextWrapperHeight !== this.state.wrapperHeight) {\n+ this.setState(\n+ { wrapperHeight: nextWrapperHeight },\n+ this.contentHeight < h ? this.scrollToBottom : undefined,\n+ );\n+ } else if (this.contentHeight < h) {\n+ this.scrollToBottom();\n+ }\nthis.contentHeight = h;\n}\n@@ -239,19 +288,13 @@ class TagInput extends React.PureComponent {\nonLayoutLastTag = (endPosOfTag: number) => {\nconst margin = 3;\n- const spaceLeft = this.wrapperWidth - endPosOfTag - margin - 10;\n-\n- const inputWidth = (spaceLeft < 100) ? this.wrapperWidth : spaceLeft - 10;\n-\n- if (spaceLeft < 100) {\n- if (this.state.lines < this.props.numberOfLines) {\n- const lines = this.state.lines + 1;\n-\n- this.setState({ inputWidth, lines });\n- } else {\n- this.setState({ inputWidth }, this.scrollToBottom);\n- }\n- } else {\n+ this.spaceLeft = this.wrapperWidth - endPosOfTag - margin - 10;\n+ const inputWidth = TagInput.inputWidth(\n+ this.props.text,\n+ this.spaceLeft,\n+ this.wrapperWidth,\n+ );\n+ if (inputWidth !== this.state.inputWidth) {\nthis.setState({ inputWidth });\n}\n}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Stabilize TagInput |
129,187 | 03.08.2017 16:07:46 | 14,400 | ee597035f988a2bc5969f4b388faf1200da767e1 | Avoid calling setState in LoggedOutModal when it's unmounted | [
{
"change_type": "MODIFY",
"old_path": "native/account/logged-out-modal.react.js",
"new_path": "native/account/logged-out-modal.react.js",
"diff": "@@ -115,6 +115,7 @@ class InnerLoggedOutModal extends React.PureComponent {\nkeyboardShowListener: ?Object;\nkeyboardHideListener: ?Object;\n+ mounted = false;\nnextMode: LoggedOutMode = \"loading\";\nactiveAlert = false;\nactiveKeyboard = false;\n@@ -140,13 +141,20 @@ class InnerLoggedOutModal extends React.PureComponent {\n} catch (e) {\nonePasswordSupported = false;\n}\n+ if (this.mounted) {\nthis.setState({ onePasswordSupported });\n}\n+ }\ncomponentDidMount() {\nif (this.props.isForeground) {\nthis.onForeground();\n}\n+ this.mounted = true;\n+ }\n+\n+ componentWillUnmount() {\n+ this.mounted = false;\n}\ncomponentWillReceiveProps(nextProps: Props) {\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Avoid calling setState in LoggedOutModal when it's unmounted |
129,187 | 03.08.2017 16:47:36 | 14,400 | 1147efeac881e8d90a4ffca8131eb70c6f8f9007 | CreateThreadButton and several refinements | [
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/chat/create-thread-button.react.js",
"diff": "+// @flow\n+\n+import React from 'react';\n+import { Text, StyleSheet, Platform } from 'react-native';\n+import PropTypes from 'prop-types';\n+\n+import Button from '../components/button.react';\n+\n+class CreateThreadButton extends React.PureComponent {\n+\n+ props: {\n+ onPress: () => void,\n+ };\n+ static propTypes = {\n+ onPress: PropTypes.func.isRequired,\n+ };\n+\n+ render() {\n+ return (\n+ <Button onSubmit={this.props.onPress} defaultFormat=\"opacity\">\n+ <Text style={styles.text}>Create</Text>\n+ </Button>\n+ );\n+ }\n+\n+}\n+\n+const styles = StyleSheet.create({\n+ text: {\n+ fontSize: 17,\n+ paddingHorizontal: 10,\n+ color: Platform.select({\n+ ios: '#037AFF',\n+ android: '#0077CC',\n+ }),\n+ fontWeight: Platform.select({ android: 'bold' }),\n+ },\n+});\n+\n+export default CreateThreadButton;\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | CreateThreadButton and several refinements |
129,187 | 08.08.2017 10:54:52 | 14,400 | f61521e088e9e4eac2864ae84baea5a0926caa58 | Update entry_lib and message_lib to use new thread permissions SQL logic | [
{
"change_type": "MODIFY",
"old_path": "server/entry_lib.php",
"new_path": "server/entry_lib.php",
"diff": "@@ -38,10 +38,11 @@ function get_entry_infos($input) {\n$thread = intval($input['nav']);\n}\n- $additional_condition = $home ? \"r.subscribed = 1\" : \"d.thread = $thread\";\n+ $additional_condition = $home ? \"tr.subscribed = 1\" : \"d.thread = $thread\";\n$deleted_condition = $include_deleted ? \"\" : \"AND e.deleted = 0 \";\n$viewer_id = get_viewer_id();\n$visibility_closed = VISIBILITY_CLOSED;\n+ $visibility_nested_open = VISIBILITY_NESTED_OPEN;\n$role_successful_auth = ROLE_SUCCESSFUL_AUTH;\n$select_query = <<<SQL\nSELECT DAY(d.date) AS day, MONTH(d.date) AS month, YEAR(d.date) AS year,\n@@ -50,12 +51,21 @@ SELECT DAY(d.date) AS day, MONTH(d.date) AS month, YEAR(d.date) AS year,\nFROM entries e\nLEFT JOIN days d ON d.id = e.day\nLEFT JOIN threads t ON t.id = d.thread\n-LEFT JOIN roles r ON r.thread = d.thread AND r.user = {$viewer_id}\n+LEFT JOIN roles tr ON tr.thread = d.thread AND tr.user = {$viewer_id}\n+LEFT JOIN threads a ON a.id = t.concrete_ancestor_thread_id\n+LEFT JOIN roles ar\n+ ON ar.thread = t.concrete_ancestor_thread_id AND ar.user = {$viewer_id}\nLEFT JOIN users u ON u.id = e.creator\n-WHERE d.date BETWEEN '{$start_date}' AND '{$end_date}' AND\n- (t.visibility_rules < {$visibility_closed} OR\n- (r.thread IS NOT NULL AND r.role >= {$role_successful_auth})) AND\n- {$additional_condition} {$deleted_condition}\n+WHERE (\n+ t.visibility_rules < {$visibility_closed} OR\n+ t.visibility_rules = {$visibility_nested_open} OR\n+ (tr.thread IS NOT NULL AND tr.role >= {$role_successful_auth})\n+ ) AND (\n+ t.visibility_rules != {$visibility_nested_open} OR\n+ a.visibility_rules < {$visibility_closed} OR\n+ (ar.thread IS NOT NULL AND ar.role >= {$role_successful_auth})\n+ ) AND d.date BETWEEN '{$start_date}' AND '{$end_date}'\n+ AND {$additional_condition} {$deleted_condition}\nORDER BY e.creation_time DESC\nSQL;\n$result = $conn->query($select_query);\n"
},
{
"change_type": "MODIFY",
"old_path": "server/message_lib.php",
"new_path": "server/message_lib.php",
"diff": "@@ -42,6 +42,7 @@ function get_message_infos($input, $number_per_thread) {\n$viewer_id = get_viewer_id();\n$visibility_closed = VISIBILITY_CLOSED;\n$role_successful_auth = ROLE_SUCCESSFUL_AUTH;\n+ $visibility_nested_open = VISIBILITY_NESTED_OPEN;\nif (is_array($input)) {\n$conditions = array();\n@@ -56,7 +57,7 @@ function get_message_infos($input, $number_per_thread) {\n}\n$additional_condition = \"(\".implode(\" OR \", $conditions).\")\";\n} else {\n- $additional_condition = \"r.subscribed = 1\";\n+ $additional_condition = \"tr.subscribed = 1\";\n}\n$int_number_per_thread = (int)$number_per_thread;\n@@ -70,10 +71,19 @@ FROM (\n@thread := m.thread AS thread\nFROM messages m\nLEFT JOIN threads t ON t.id = m.thread\n- LEFT JOIN roles r ON r.thread = m.thread AND r.user = {$viewer_id}\n- WHERE (t.visibility_rules < {$visibility_closed} OR\n- (r.thread IS NOT NULL AND r.role >= {$role_successful_auth})) AND\n- {$additional_condition}\n+ LEFT JOIN roles tr ON tr.thread = m.thread AND tr.user = {$viewer_id}\n+ LEFT JOIN threads a ON a.id = t.concrete_ancestor_thread_id\n+ LEFT JOIN roles ar\n+ ON ar.thread = t.concrete_ancestor_thread_id AND ar.user = {$viewer_id}\n+ WHERE (\n+ t.visibility_rules < {$visibility_closed} OR\n+ t.visibility_rules = {$visibility_nested_open} OR\n+ (tr.thread IS NOT NULL AND tr.role >= {$role_successful_auth})\n+ ) AND (\n+ t.visibility_rules != {$visibility_nested_open} OR\n+ a.visibility_rules < {$visibility_closed} OR\n+ (ar.thread IS NOT NULL AND ar.role >= {$role_successful_auth})\n+ ) AND {$additional_condition}\nORDER BY m.thread, m.time DESC\n) x\nLEFT JOIN users u ON u.id = x.user\n@@ -134,6 +144,7 @@ function get_messages_since($current_as_of, $max_number_per_thread) {\n$viewer_id = get_viewer_id();\n$visibility_closed = VISIBILITY_CLOSED;\n+ $visibility_nested_open = VISIBILITY_NESTED_OPEN;\n$role_successful_auth = ROLE_SUCCESSFUL_AUTH;\n$query = <<<SQL\n@@ -141,11 +152,20 @@ SELECT m.id, m.thread AS threadID, m.content, m.time, m.type,\nu.username AS creator, m.user AS creatorID\nFROM messages m\nLEFT JOIN threads t ON t.id = m.thread\n-LEFT JOIN roles r ON r.thread = m.thread AND r.user = {$viewer_id}\n+LEFT JOIN roles tr ON tr.thread = m.thread AND tr.user = {$viewer_id}\n+LEFT JOIN threads a ON a.id = t.concrete_ancestor_thread_id\n+LEFT JOIN roles ar\n+ ON ar.thread = t.concrete_ancestor_thread_id AND ar.user = {$viewer_id}\nLEFT JOIN users u ON u.id = m.user\n-WHERE (t.visibility_rules < {$visibility_closed} OR\n- (r.thread IS NOT NULL AND r.role >= {$role_successful_auth})) AND\n- m.time > {$current_as_of}\n+WHERE (\n+ t.visibility_rules < {$visibility_closed} OR\n+ t.visibility_rules = {$visibility_nested_open} OR\n+ (tr.thread IS NOT NULL AND tr.role >= {$role_successful_auth})\n+ ) AND (\n+ t.visibility_rules != {$visibility_nested_open} OR\n+ a.visibility_rules < {$visibility_closed} OR\n+ (ar.thread IS NOT NULL AND ar.role >= {$role_successful_auth})\n+ ) AND m.time > {$current_as_of}\nORDER BY m.thread, m.time DESC\nSQL;\n$result = $conn->query($query);\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Update entry_lib and message_lib to use new thread permissions SQL logic |
129,187 | 08.08.2017 14:37:27 | 14,400 | 4e27bb9321894d56cf642d89c0297acfc155053c | create_user_roles / delete_user_roles functions | [
{
"change_type": "MODIFY",
"old_path": "server/auth.php",
"new_path": "server/auth.php",
"diff": "@@ -214,32 +214,21 @@ function create_user_cookie($user_id) {\n\"SELECT thread, creation_time, last_view, role, subscribed FROM roles \".\n\"WHERE user = $anonymous_cookie_id\"\n);\n- $new_rows = array();\n+ $role_rows = array();\nwhile ($row = $result->fetch_assoc()) {\n- $new_rows[] = \"(\".implode(\", \", array(\n- $row['thread'],\n- $user_id,\n- $row['creation_time'],\n- $row['last_view'],\n- $row['role'],\n- $row['subscribed']\n- )).\")\";\n- }\n- if ($new_rows) {\n- $conn->query(\n- \"INSERT INTO roles(thread, user, \".\n- \"creation_time, last_view, role, subscribed) \".\n- \"VALUES \".implode(', ', $new_rows).\" \".\n- \"ON DUPLICATE KEY UPDATE \".\n- \"creation_time = LEAST(VALUES(creation_time), creation_time), \".\n- \"last_view = GREATEST(VALUES(last_view), last_view), \".\n- \"role = GREATEST(VALUES(role), role), \".\n- \"subscribed = GREATEST(VALUES(subscribed), subscribed)\"\n- );\n- $conn->query(\n- \"DELETE FROM roles WHERE user = $anonymous_cookie_id\"\n+ $role_rows[] = array(\n+ \"user\" => $user_id,\n+ \"thread\" => (int)$row['thread'],\n+ \"role\" => (int)$row['role'],\n+ \"creation_time\" => (int)$row['creation_time'],\n+ \"last_view\" => (int)$row['last_view'],\n+ \"subscribed\" => !!$row['subscribed'],\n);\n}\n+ if ($role_rows) {\n+ create_user_roles($role_rows);\n+ $conn->query(\"DELETE FROM roles WHERE user = $anonymous_cookie_id\");\n+ }\n$conn->query(\n\"DELETE c, i FROM cookies c LEFT JOIN ids i ON i.id = c.id \".\n\"WHERE c.id = $anonymous_cookie_id\"\n"
},
{
"change_type": "MODIFY",
"old_path": "server/auth_thread.php",
"new_path": "server/auth_thread.php",
"diff": "@@ -42,17 +42,11 @@ if (!password_verify($_POST['password'], $thread_row['hash'])) {\n}\n$viewer_id = get_viewer_id();\n-\n-$time = round(microtime(true) * 1000); // in milliseconds\n-$conn->query(\n- \"INSERT INTO roles(thread, user, \".\n- \"creation_time, last_view, role, subscribed) \".\n- \"VALUES ($thread, $viewer_id, $time, $time, \".\n- ROLE_SUCCESSFUL_AUTH.\", 0) ON DUPLICATE KEY UPDATE \".\n- \"creation_time = LEAST(VALUES(creation_time), creation_time), \".\n- \"last_view = GREATEST(VALUES(last_view), last_view), \".\n- \"role = GREATEST(VALUES(role), role)\"\n-);\n+create_user_roles(array(array(\n+ \"user\" => $viewer_id,\n+ \"thread\" => $thread,\n+ \"role\" => ROLE_SUCCESSFUL_AUTH,\n+)));\nlist($message_infos, $truncation_status, $users) =\nget_message_infos(array($thread => false), DEFAULT_NUMBER_PER_THREAD);\n"
},
{
"change_type": "MODIFY",
"old_path": "server/entry_lib.php",
"new_path": "server/entry_lib.php",
"diff": "@@ -71,17 +71,11 @@ SQL;\n$result = $conn->query($select_query);\nif ($thread !== null) {\n- $time = round(microtime(true) * 1000); // in milliseconds\n- $role_viewed = ROLE_VIEWED;\n- $role_insert_query = <<<SQL\n-INSERT INTO roles(thread, user, creation_time, last_view, role, subscribed)\n-VALUES ({$thread}, {$viewer_id}, {$time}, {$time}, {$role_viewed}, 0)\n-ON DUPLICATE KEY UPDATE\n- creation_time = LEAST(VALUES(creation_time), creation_time),\n- last_view = GREATEST(VALUES(last_view), last_view),\n- role = GREATEST(VALUES(role), role)\n-SQL;\n- $conn->query($role_insert_query);\n+ create_user_roles(array(array(\n+ \"user\" => $viewer_id,\n+ \"thread\" => $thread,\n+ \"role\" => ROLE_VIEWED,\n+ )));\n}\n$entries = array();\n"
},
{
"change_type": "MODIFY",
"old_path": "server/new_thread.php",
"new_path": "server/new_thread.php",
"diff": "@@ -111,11 +111,14 @@ $conn->query(\n\"VALUES ($message_id, $id, $creator, 1, $time)\"\n);\n-$conn->query(\n- \"INSERT INTO roles(thread, user, creation_time, last_view, role, \".\n- \"subscribed) \".\n- \"VALUES ($id, $creator, $time, $time, \".ROLE_CREATOR.\", 1)\"\n-);\n+create_user_roles(array(array(\n+ \"user\" => $creator,\n+ \"thread\" => $id,\n+ \"role\" => ROLE_CREATOR,\n+ \"creation_time\" => $time,\n+ \"last_view\" => $time,\n+ \"subscribed\" => true,\n+)));\nasync_end(array(\n'success' => true,\n"
},
{
"change_type": "MODIFY",
"old_path": "server/subscribe.php",
"new_path": "server/subscribe.php",
"diff": "require_once('async_lib.php');\nrequire_once('config.php');\nrequire_once('auth.php');\n+require_once('thread_lib.php');\nasync_start();\n@@ -27,16 +28,11 @@ if (!$can_see) {\n}\n$viewer_id = get_viewer_id();\n-$time = round(microtime(true) * 1000); // in milliseconds\n-$conn->query(\n- \"INSERT INTO roles(thread, user, \".\n- \"creation_time, last_view, role, subscribed) \".\n- \"VALUES ($thread, $viewer_id, $time, $time, \".\n- ROLE_VIEWED.\", $subscribe) ON DUPLICATE KEY UPDATE \".\n- \"creation_time = LEAST(VALUES(creation_time), creation_time), \".\n- \"last_view = GREATEST(VALUES(last_view), last_view), \".\n- \"role = GREATEST(VALUES(role), role), subscribed = VALUES(subscribed)\"\n-);\n+create_user_roles(array(array(\n+ \"user\" => $viewer_id,\n+ \"thread\" => $thread,\n+ \"role\" => ROLE_SUCCESSFUL_AUTH,\n+)));\nasync_end(array(\n'success' => true,\n"
},
{
"change_type": "MODIFY",
"old_path": "server/thread_lib.php",
"new_path": "server/thread_lib.php",
"diff": "@@ -95,3 +95,70 @@ SQL;\n? (int)$row['concrete_ancestor_thread_id']\n: $parent_thread_id;\n}\n+\n+// roles is an array of arrays of:\n+// - user: required int\n+// - thread: required int\n+// - role: required int\n+// - creation_time: optional int\n+// - last_view: optional int\n+// - subscribed: optional bool\n+function create_user_roles($role_rows) {\n+ global $conn;\n+\n+ if (!$role_rows) {\n+ return;\n+ }\n+\n+ $time = round(microtime(true) * 1000); // in milliseconds\n+ $values_sql_strings = array();\n+ foreach ($role_rows as $role_row) {\n+ $creation_time = isset($role_row['creation_time'])\n+ ? $role_row['creation_time']\n+ : $time;\n+ $last_view = isset($role_row['last_view'])\n+ ? $role_row['last_view']\n+ : $time;\n+ $subscribed = isset($role_row['subscribed'])\n+ ? $role_row['subscribed']\n+ : $role_row['role'] >= ROLE_SUCCESSFUL_AUTH;\n+ $values_sql_strings[] = \"(\" . implode(\",\", array(\n+ $role_row['user'],\n+ $role_row['thread'],\n+ $role_row['role'],\n+ $creation_time,\n+ $last_view,\n+ $subscribed ? 1 : 0,\n+ )) . \")\";\n+ }\n+\n+ $values_sql_string = implode(\", \", $values_sql_strings);\n+ $query = <<<SQL\n+INSERT INTO roles (user, thread, role, creation_time, last_view, subscribed)\n+VALUES {$values_sql_string}\n+ON DUPLICATE KEY UPDATE\n+ creation_time = LEAST(VALUES(creation_time), creation_time),\n+ last_view = GREATEST(VALUES(last_view), last_view),\n+ role = GREATEST(VALUES(role), role),\n+ subscribed = GREATEST(VALUES(subscribed), subscribed)\n+SQL;\n+ $conn->query($query);\n+}\n+\n+// roles is an array of { user, thread }\n+function delete_user_roles($role_rows) {\n+ global $conn;\n+\n+ if (!$role_rows) {\n+ return;\n+ }\n+\n+ $where_sql_strings = array();\n+ foreach ($role_rows as $role_row) {\n+ $where_sql_strings[] =\n+ \"(user = {$role_row['user']} AND thread = {$role_row['thread']})\";\n+ }\n+\n+ $where_sql_string = implode(\" OR \", $where_sql_strings);\n+ $conn->query(\"DELETE FROM roles WHERE {$where_sql_string}\");\n+}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | create_user_roles / delete_user_roles functions |
129,187 | 08.08.2017 14:47:41 | 14,400 | e80756a9d399bcd717711be2f06b74d9e0a06584 | Fix up subscribe.php | [
{
"change_type": "MODIFY",
"old_path": "server/subscribe.php",
"new_path": "server/subscribe.php",
"diff": "@@ -13,7 +13,7 @@ if (!isset($_POST['thread']) || !isset($_POST['subscribe'])) {\n));\n}\n$thread = (int)$_POST['thread'];\n-$subscribe = $_POST['subscribe'] ? 1 : 0;\n+$new_subscribed = !!$_POST['subscribe'];\n$can_see = viewer_can_see_thread($thread);\nif ($can_see === null) {\n@@ -31,7 +31,8 @@ $viewer_id = get_viewer_id();\ncreate_user_roles(array(array(\n\"user\" => $viewer_id,\n\"thread\" => $thread,\n- \"role\" => ROLE_SUCCESSFUL_AUTH,\n+ \"role\" => $new_subscribed ? ROLE_SUCCESSFUL_AUTH : ROLE_VIEWED,\n+ \"subscribed\" => $new_subscribed,\n)));\nasync_end(array(\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Fix up subscribe.php |
129,187 | 09.08.2017 15:40:07 | 14,400 | 3e2f26a7f405b35e1b5388872dae63b38ac2c428 | Actually verify the thread ID we get passed in is a thread ID before setting rows with it... | [
{
"change_type": "MODIFY",
"old_path": "server/entry_lib.php",
"new_path": "server/entry_lib.php",
"diff": "@@ -4,6 +4,26 @@ require_once('config.php');\nrequire_once('auth.php');\nrequire_once('thread_lib.php');\n+// Doesn't verify $input['nav'] is actually a thread, if not \"home\"\n+// Use verify_entry_info_query\n+function raw_verify_entry_info_query($input) {\n+ // Be careful with the regex below; bad validation could lead to SQL injection\n+ return\n+ is_array($input) &&\n+ isset($input['start_date']) &&\n+ isset($input['end_date']) &&\n+ preg_match(\"/^[0-9]{4}-[0-1][0-9]-[0-3][0-9]$/\", $input['start_date']) &&\n+ preg_match(\"/^[0-9]{4}-[0-1][0-9]-[0-3][0-9]$/\", $input['end_date']) &&\n+ isset($input['nav']);\n+}\n+\n+function verify_entry_info_query($input) {\n+ return raw_verify_entry_info_query($input) && (\n+ $input['nav'] === \"home\" ||\n+ verify_thread_id($input['nav'])\n+ );\n+}\n+\n// $input should be an array that contains:\n// - start_date key with date formatted like 2017-04-20\n// - end_date key with same date format\n@@ -13,15 +33,7 @@ require_once('thread_lib.php');\nfunction get_entry_infos($input) {\nglobal $conn;\n- // Be careful with the regex below; bad validation could lead to SQL injection\n- if (\n- !is_array($input) ||\n- !isset($input['start_date']) ||\n- !isset($input['end_date']) ||\n- !preg_match(\"/^[0-9]{4}-[0-1][0-9]-[0-3][0-9]$/\", $input['start_date']) ||\n- !preg_match(\"/^[0-9]{4}-[0-1][0-9]-[0-3][0-9]$/\", $input['end_date']) ||\n- !isset($input['nav'])\n- ) {\n+ if (!raw_verify_entry_info_query($input)) {\nreturn null;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "server/fetch_entries.php",
"new_path": "server/fetch_entries.php",
"diff": "@@ -5,6 +5,12 @@ require_once('entry_lib.php');\nasync_start();\n+if (!verify_entry_info_query($_POST)) {\n+ async_end(array(\n+ 'error' => 'invalid_parameters',\n+ ));\n+}\n+\n$entry_result = get_entry_infos($_POST);\nif ($entry_result === null) {\nasync_end(array(\n"
},
{
"change_type": "MODIFY",
"old_path": "server/index.php",
"new_path": "server/index.php",
"diff": "@@ -40,14 +40,10 @@ if (!$home_rewrite_matched && $thread_rewrite_matched) {\n}\n$thread_infos = get_thread_infos();\n-if (!$home && !isset($thread_infos[$thread])) {\n- $result = $conn->query(\"SELECT id FROM threads WHERE id = $thread\");\n- $thread_id_check_row = $result->fetch_assoc();\n- if (!$thread_id_check_row) {\n+if (!$home && !isset($thread_infos[$thread]) && !verify_thread_id($thread)) {\nheader($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error', true, 500);\nexit;\n}\n-}\n$month_beginning_timestamp = date_create(\"$month/1/$year\");\nif ($month < 1 || $month > 12) {\n"
},
{
"change_type": "MODIFY",
"old_path": "server/login.php",
"new_path": "server/login.php",
"diff": "@@ -16,6 +16,15 @@ if (!isset($_POST['username']) || !isset($_POST['password'])) {\n$username = $conn->real_escape_string($_POST['username']);\n$password = $_POST['password'];\n+if (\n+ !empty($_POST['inner_entry_query']) &&\n+ !verify_entry_info_query($_POST['inner_entry_query'])\n+) {\n+ async_end(array(\n+ 'error' => 'invalid_parameters',\n+ ));\n+}\n+\n$result = $conn->query(\n\"SELECT id, hash, username, email, email_verified \".\n\"FROM users WHERE username = '$username' OR email = '$username'\"\n"
},
{
"change_type": "MODIFY",
"old_path": "server/ping.php",
"new_path": "server/ping.php",
"diff": "@@ -35,6 +35,15 @@ if ($user_logged_in) {\n);\n}\n+if (\n+ !empty($_POST['inner_entry_query']) &&\n+ !verify_entry_info_query($_POST['inner_entry_query'])\n+) {\n+ async_end(array(\n+ 'error' => 'invalid_parameters',\n+ ));\n+}\n+\n$time = round(microtime(true) * 1000); // in milliseconds\nif (isset($_REQUEST['last_ping']) && $_REQUEST['last_ping']) {\n$last_ping = (int)$_REQUEST['last_ping'];\n"
},
{
"change_type": "MODIFY",
"old_path": "server/reset_password.php",
"new_path": "server/reset_password.php",
"diff": "@@ -22,6 +22,15 @@ if (trim($password) === '') {\n));\n}\n+if (\n+ !empty($_POST['inner_entry_query']) &&\n+ !verify_entry_info_query($_POST['inner_entry_query'])\n+) {\n+ async_end(array(\n+ 'error' => 'invalid_parameters',\n+ ));\n+}\n+\n$code = $_POST['code'];\n$verification_result = verify_code($code);\nif (!$verification_result) {\n"
},
{
"change_type": "MODIFY",
"old_path": "server/thread_lib.php",
"new_path": "server/thread_lib.php",
"diff": "@@ -162,3 +162,13 @@ function delete_user_roles($role_rows) {\n$where_sql_string = implode(\" OR \", $where_sql_strings);\n$conn->query(\"DELETE FROM roles WHERE {$where_sql_string}\");\n}\n+\n+function verify_thread_id($thread) {\n+ global $conn;\n+\n+ $thread = (int)$thread;\n+ $thread_id_check_result =\n+ $conn->query(\"SELECT id FROM threads WHERE id = {$thread}\");\n+ $thread_id_check_row = $thread_id_check_result->fetch_assoc();\n+ return !!$thread_id_check_row;\n+}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Actually verify the thread ID we get passed in is a thread ID before setting rows with it... |
129,187 | 09.08.2017 15:48:37 | 14,400 | bc44a1cfc339241460d3a260f7db0ecd70392e61 | Minor server fixes | [
{
"change_type": "MODIFY",
"old_path": "server/delete_thread.php",
"new_path": "server/delete_thread.php",
"diff": "@@ -21,16 +21,20 @@ $user = get_viewer_id();\n$thread = (int)$_POST['thread'];\n$password = $_POST['password'];\n-$result = $conn->query(\n- \"SELECT hash \".\n- \"FROM roles r LEFT JOIN users u ON u.id = r.user \".\n- \"WHERE r.thread = $thread AND r.user = $user \".\n- \"AND r.role >= \".ROLE_CREATOR\n-);\n+$role_creator = ROLE_CREATOR;\n+$query = <<<SQL\n+SELECT u.hash\n+FROM roles r\n+LEFT JOIN users u ON u.id = r.user\n+WHERE r.thread = {$thread}\n+ AND r.user = {$user}\n+ AND r.role >= {$role_creator}\n+SQL;\n+$result = $conn->query($query);\n$row = $result->fetch_assoc();\nif (!$row) {\nasync_end(array(\n- 'error' => 'internal_error',\n+ 'error' => 'invalid_parameters',\n));\n}\nif (!password_verify($password, $row['hash'])) {\n"
},
{
"change_type": "MODIFY",
"old_path": "server/edit_thread.php",
"new_path": "server/edit_thread.php",
"diff": "@@ -112,7 +112,7 @@ WHERE r.thread = {$thread} AND r.user = {$user} AND r.role >= {$role_creator}\nSQL;\n$result = $conn->query($query);\n$row = $result->fetch_assoc();\n-if (!$row) {\n+if (!$row || $row['visibility_rules'] === null) {\nasync_end(array(\n'error' => 'internal_error',\n));\n"
},
{
"change_type": "MODIFY",
"old_path": "server/join_thread.php",
"new_path": "server/join_thread.php",
"diff": "@@ -100,6 +100,7 @@ SQL;\n\"user\" => $viewer_id,\n\"thread\" => $current_thread_id,\n\"role\" => ROLE_SUCCESSFUL_AUTH,\n+ \"subscribed\" => false,\n);\n$message_cursors_to_query[$current_thread_id] = false;\n$current_thread_id = (int)$ancestor_row['parent_thread_id'];\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Minor server fixes |
129,187 | 09.08.2017 16:13:11 | 14,400 | 9770fca332caa57f0fd0a4a9bf328ec783cc02b1 | Allow member IDs to be specified in edit_thread.php/new_thread.php | [
{
"change_type": "MODIFY",
"old_path": "server/edit_thread.php",
"new_path": "server/edit_thread.php",
"diff": "@@ -4,6 +4,7 @@ require_once('async_lib.php');\nrequire_once('config.php');\nrequire_once('auth.php');\nrequire_once('thread_lib.php');\n+require_once('user_lib.php');\nasync_start();\n@@ -92,7 +93,11 @@ if (isset($_POST['visibility_rules'])) {\n$changed_sql_fields['visibility_rules'] = $vis_rules;\n}\n-if (!$changed_sql_fields) {\n+$add_member_ids = isset($_POST['add_member_ids'])\n+ ? verify_user_ids($_POST['add_member_ids'])\n+ : array();\n+\n+if (!$changed_sql_fields && !$add_member_ids) {\nasync_end(array(\n'error' => 'invalid_parameters',\n));\n@@ -192,12 +197,14 @@ if (\n$concrete_ancestor_thread_id;\n}\n+if ($changed_sql_fields) {\n$sql_set_strings = array();\nforeach ($changed_sql_fields as $field_name => $field_sql_string) {\n$sql_set_strings[] = \"{$field_name} = {$field_sql_string}\";\n}\n$sql_set_string = implode(\", \", $sql_set_strings);\n$conn->query(\"UPDATE threads SET {$sql_set_string} WHERE id = {$thread}\");\n+}\n// If we're switching from NESTED_OPEN to THREAD_SECRET, all of our NESTED_OPEN\n// descendants need to be updated to have us as their concrete ancestor thread\n@@ -251,6 +258,16 @@ SQL;\n$conn->query($update_query);\n}\n+$roles_to_save = array();\n+foreach ($add_member_ids as $add_member_id) {\n+ $roles_to_save[] = array(\n+ \"user\" => $add_member_id,\n+ \"thread\" => $thread,\n+ \"role\" => ROLE_SUCCESSFUL_AUTH,\n+ );\n+}\n+create_user_roles($roles_to_save);\n+\nasync_end(array(\n'success' => true,\n));\n"
},
{
"change_type": "MODIFY",
"old_path": "server/new_thread.php",
"new_path": "server/new_thread.php",
"diff": "@@ -4,6 +4,7 @@ require_once('async_lib.php');\nrequire_once('config.php');\nrequire_once('auth.php');\nrequire_once('thread_lib.php');\n+require_once('user_lib.php');\nasync_start();\n@@ -111,14 +112,28 @@ $conn->query(\n\"VALUES ($message_id, $id, $creator, 1, $time)\"\n);\n-create_user_roles(array(array(\n+$roles_to_save = array(array(\n\"user\" => $creator,\n\"thread\" => $id,\n\"role\" => ROLE_CREATOR,\n\"creation_time\" => $time,\n\"last_view\" => $time,\n\"subscribed\" => true,\n-)));\n+));\n+$initial_member_ids = isset($_POST['initial_member_ids'])\n+ ? verify_user_ids($_POST['initial_member_ids'])\n+ : array();\n+foreach ($initial_member_ids as $initial_member_id) {\n+ $roles_to_save[] = array(\n+ \"user\" => $initial_member_id,\n+ \"thread\" => $id,\n+ \"role\" => ROLE_SUCCESSFUL_AUTH,\n+ \"creation_time\" => $time,\n+ \"last_view\" => $time,\n+ \"subscribed\" => true,\n+ );\n+}\n+create_user_roles($roles_to_save);\nasync_end(array(\n'success' => true,\n"
},
{
"change_type": "MODIFY",
"old_path": "server/thread_lib.php",
"new_path": "server/thread_lib.php",
"diff": "@@ -167,8 +167,7 @@ function verify_thread_id($thread) {\nglobal $conn;\n$thread = (int)$thread;\n- $thread_id_check_result =\n- $conn->query(\"SELECT id FROM threads WHERE id = {$thread}\");\n- $thread_id_check_row = $thread_id_check_result->fetch_assoc();\n- return !!$thread_id_check_row;\n+ $result = $conn->query(\"SELECT id FROM threads WHERE id = {$thread}\");\n+ $row = $result->fetch_assoc();\n+ return !!$row;\n}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "server/user_lib.php",
"diff": "+<?php\n+\n+require_once('auth.php');\n+\n+// $user_ids is a string of implode'd user IDs\n+// returns an array of validated user IDs\n+function verify_user_ids($user_ids) {\n+ global $conn;\n+\n+ // Be careful with the regex below; bad validation could lead to SQL injection\n+ if (!preg_match('/^(([0-9]+,)*([0-9]+))?$/', $user_ids)) {\n+ return array();\n+ }\n+\n+ $result = $conn->query(\"SELECT id FROM users WHERE id IN ({$user_ids})\");\n+ $verified_user_ids = array();\n+ while ($row = $result->fetch_assoc()) {\n+ $verified_user_ids[] = (int)$row['id'];\n+ }\n+ return $verified_user_ids;\n+}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Allow member IDs to be specified in edit_thread.php/new_thread.php |
129,187 | 13.08.2017 17:08:29 | 14,400 | 501f7f21e6cd338da4a29e0c7ee94984268e3068 | Make sure that if subscribe leads to joining a NESTED_OPEN thread whose ancestors are not joined, those ancestors are joined as well | [
{
"change_type": "MODIFY",
"old_path": "server/join_thread.php",
"new_path": "server/join_thread.php",
"diff": "@@ -17,7 +17,7 @@ if (!isset($_POST['thread'])) {\n$thread = intval($_POST['thread']);\n$thread_query = <<<SQL\n-SELECT visibility_rules, hash, parent_thread_id FROM threads WHERE id={$thread}\n+SELECT visibility_rules, hash FROM threads WHERE id={$thread}\nSQL;\n$thread_result = $conn->query($thread_query);\n$thread_row = $thread_result->fetch_assoc();\n@@ -29,7 +29,6 @@ if (!$thread_row) {\n$viewer_id = get_viewer_id();\n$vis_rules = (int)$thread_row['visibility_rules'];\n-$parent_thread_id = (int)$thread_row['parent_thread_id'];\n$roles_to_save = array();\n$message_cursors_to_query = array();\n@@ -81,30 +80,15 @@ if ($vis_rules === VISIBILITY_OPEN) {\n\"role\" => ROLE_SUCCESSFUL_AUTH,\n);\n$message_cursors_to_query[$thread] = false;\n- $current_thread_id = $parent_thread_id;\n- while (true) {\n- $ancestor_query = <<<SQL\n-SELECT t.parent_thread_id, t.visibility_rules, r.role\n-FROM threads t\n-LEFT JOIN roles p ON p.thread = t.id AND p.user = {$viewer_id}\n-WHERE t.id = {$current_thread_id}\n-SQL;\n- $ancestor_result = $conn->query($ancestor_query);\n- $ancestor_row = $ancestor_result->fetch_assoc();\n- if (\n- (int)$ancestor_row['visibility_rules'] !== VISIBILITY_NESTED_OPEN ||\n- (int)$ancestor_row['role'] >= ROLE_SUCCESSFUL_AUTH\n- ) {\n- break;\n+ $extra_roles = get_extra_roles_for_joined_thread_id($thread);\n+ if ($extra_roles === null) {\n+ async_end(array(\n+ 'error' => 'unknown_error',\n+ ));\n}\n- $roles_to_save[] = array(\n- \"user\" => $viewer_id,\n- \"thread\" => $current_thread_id,\n- \"role\" => ROLE_SUCCESSFUL_AUTH,\n- \"subscribed\" => false,\n- );\n- $message_cursors_to_query[$current_thread_id] = false;\n- $current_thread_id = (int)$ancestor_row['parent_thread_id'];\n+ foreach ($extra_roles as $extra_role) {\n+ $roles_to_save[] = $extra_role;\n+ $message_cursors_to_query[$extra_role['thread']] = false;\n}\n} else if ($vis_rules === VISIBILITY_THREAD_SECRET) {\n// There's no way to add yourself to a secret thread; you need to be added by\n"
},
{
"change_type": "MODIFY",
"old_path": "server/subscribe.php",
"new_path": "server/subscribe.php",
"diff": "@@ -28,12 +28,22 @@ if (!$can_see) {\n}\n$viewer_id = get_viewer_id();\n-create_user_roles(array(array(\n+$roles = array(array(\n\"user\" => $viewer_id,\n\"thread\" => $thread,\n\"role\" => $new_subscribed ? ROLE_SUCCESSFUL_AUTH : ROLE_VIEWED,\n\"subscribed\" => $new_subscribed,\n-)));\n+));\n+if ($new_subscribed) {\n+ $extra_roles = get_extra_roles_for_joined_thread_id($thread);\n+ if ($extra_roles === null) {\n+ async_end(array(\n+ 'error' => 'unknown_error',\n+ ));\n+ }\n+ $roles = array_merge($roles, $extra_roles);\n+}\n+create_user_roles($roles);\nasync_end(array(\n'success' => true,\n"
},
{
"change_type": "MODIFY",
"old_path": "server/thread_lib.php",
"new_path": "server/thread_lib.php",
"diff": "@@ -195,3 +195,49 @@ function verify_thread_id($thread) {\n$row = $result->fetch_assoc();\nreturn !!$row;\n}\n+\n+function get_extra_roles_for_joined_thread_id($thread_id) {\n+ global $conn;\n+\n+ $thread_query = <<<SQL\n+SELECT visibility_rules, parent_thread_id FROM threads WHERE id={$thread_id}\n+SQL;\n+ $thread_result = $conn->query($thread_query);\n+ $thread_row = $thread_result->fetch_assoc();\n+ if (!$thread_row) {\n+ return null;\n+ }\n+\n+ $vis_rules = (int)$thread_row['visibility_rules'];\n+ if ($vis_rules !== VISIBILITY_NESTED_OPEN) {\n+ return array();\n+ }\n+\n+ $roles = array();\n+ $viewer_id = get_viewer_id();\n+ $current_thread_id = (int)$thread_row['parent_thread_id'];\n+ while (true) {\n+ $ancestor_query = <<<SQL\n+SELECT t.parent_thread_id, t.visibility_rules, r.role\n+FROM threads t\n+LEFT JOIN roles p ON p.thread = t.id AND p.user = {$viewer_id}\n+WHERE t.id = {$current_thread_id}\n+SQL;\n+ $ancestor_result = $conn->query($ancestor_query);\n+ $ancestor_row = $ancestor_result->fetch_assoc();\n+ if (\n+ (int)$ancestor_row['visibility_rules'] !== VISIBILITY_NESTED_OPEN ||\n+ (int)$ancestor_row['role'] >= ROLE_SUCCESSFUL_AUTH\n+ ) {\n+ break;\n+ }\n+ $roles[] = array(\n+ \"user\" => $viewer_id,\n+ \"thread\" => $current_thread_id,\n+ \"role\" => ROLE_SUCCESSFUL_AUTH,\n+ \"subscribed\" => false,\n+ );\n+ $current_thread_id = (int)$ancestor_row['parent_thread_id'];\n+ }\n+ return $roles;\n+}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Make sure that if subscribe leads to joining a NESTED_OPEN thread whose ancestors are not joined, those ancestors are joined as well |
129,187 | 13.08.2017 17:22:27 | 14,400 | a504f9d850f1024e8df281123d59dccd96c9c46c | Separate authorized and viewerIsMember properties of ThreadInfo | [
{
"change_type": "MODIFY",
"old_path": "lib/actions/thread-actions.js",
"new_path": "lib/actions/thread-actions.js",
"diff": "@@ -78,6 +78,7 @@ async function newThread(\nid: newThreadID,\nname,\ndescription,\n+ authorized: true,\nviewerIsMember: true,\nsubscribed: true,\ncanChangeSettings: true,\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/reducers/entry-reducer.js",
"new_path": "lib/reducers/entry-reducer.js",
"diff": "@@ -108,7 +108,7 @@ function reduceEntryInfos(\naction.type === \"DELETE_ACCOUNT_SUCCESS\"\n) {\nconst threadInfos = action.payload.threadInfos;\n- const authorizedThreadInfos = _pickBy('viewerIsMember')(threadInfos);\n+ const authorizedThreadInfos = _pickBy('authorized')(threadInfos);\nconst newEntryInfos = _pickBy(\n(entry: RawEntryInfo) => authorizedThreadInfos[entry.threadID],\n)(entryInfos);\n@@ -137,7 +137,7 @@ function reduceEntryInfos(\n};\n} else if (action.type === \"SET_COOKIE\" && action.payload.threadInfos) {\nconst threadInfos = action.payload.threadInfos;\n- const authorizedThreadInfos = _pickBy('viewerIsMember')(threadInfos);\n+ const authorizedThreadInfos = _pickBy('authorized')(threadInfos);\nconst newEntryInfos = _pickBy(\n(entry: RawEntryInfo) => authorizedThreadInfos[entry.threadID],\n)(entryInfos);\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/selectors/nav-selectors.js",
"new_path": "lib/selectors/nav-selectors.js",
"diff": "@@ -44,7 +44,7 @@ const currentNavID = createSelector(\n}\ninvariant(navInfo.threadID, \"either home or threadID should be set\");\nconst threadInfo = threadInfos[navInfo.threadID];\n- if (!threadInfo || !threadInfo.viewerIsMember) {\n+ if (!threadInfo || !threadInfo.authorized) {\nreturn null;\n}\nreturn navInfo.threadID;\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/types/thread-types.js",
"new_path": "lib/types/thread-types.js",
"diff": "@@ -45,6 +45,7 @@ export type ThreadInfo = {|\nid: string,\nname: string,\ndescription: string,\n+ authorized: bool,\nviewerIsMember: bool,\nsubscribed: bool,\ncanChangeSettings: bool,\n@@ -60,6 +61,7 @@ export const threadInfoPropType = PropTypes.shape({\nid: PropTypes.string.isRequired,\nname: PropTypes.string.isRequired,\ndescription: PropTypes.string.isRequired,\n+ authorized: PropTypes.bool.isRequired,\nviewerIsMember: PropTypes.bool.isRequired,\nsubscribed: PropTypes.bool.isRequired,\ncanChangeSettings: PropTypes.bool.isRequired,\n"
},
{
"change_type": "MODIFY",
"old_path": "server/index.php",
"new_path": "server/index.php",
"diff": "@@ -62,7 +62,7 @@ if ($home) {\n}\n} else {\n$null_state = !isset($thread_infos[$thread])\n- || !$thread_infos[$thread]['viewerIsMember'];\n+ || !$thread_infos[$thread]['authorized'];\n}\n$verify_rewrite_matched = preg_match(\n"
},
{
"change_type": "MODIFY",
"old_path": "server/thread_lib.php",
"new_path": "server/thread_lib.php",
"diff": "@@ -48,17 +48,18 @@ SQL;\n$thread_ids = array();\nwhile ($row = $result->fetch_assoc()) {\n$vis_rules = (int)$row['visibility_rules'];\n- $viewer_is_member = !$row['requires_auth'];\n- if (!$viewer_is_member && $vis_rules >= VISIBILITY_SECRET) {\n+ $authorized = !$row['requires_auth'];\n+ if (!$authorized && $vis_rules >= VISIBILITY_SECRET) {\ncontinue;\n}\n$thread_ids[] = $row['id'];\n- $subscribed_authorized = $viewer_is_member && $row['subscribed'];\n+ $subscribed_authorized = $authorized && $row['subscribed'];\n$thread_infos[$row['id']] = array(\n'id' => $row['id'],\n'name' => $row['name'],\n'description' => $row['description'],\n- 'viewerIsMember' => $viewer_is_member,\n+ 'authorized' => $authorized,\n+ 'viewerIsMember' => (int)$row['role'] >= ROLE_SUCCESSFUL_AUTH,\n'subscribed' => $subscribed_authorized,\n'parentThreadID' => $row['parent_thread_id'],\n'canChangeSettings' => (int)$row['role'] >= ROLE_CREATOR,\n"
},
{
"change_type": "MODIFY",
"old_path": "web/modals/thread-settings-modal.react.js",
"new_path": "web/modals/thread-settings-modal.react.js",
"diff": "@@ -592,6 +592,7 @@ class ThreadSettingsModal extends React.PureComponent {\nid: this.state.threadInfo.id,\nname,\ndescription: this.state.threadInfo.description,\n+ authorized: this.state.threadInfo.authorized,\nviewerIsMember: this.state.threadInfo.viewerIsMember,\nsubscribed: this.state.threadInfo.subscribed,\ncanChangeSettings: this.state.threadInfo.canChangeSettings,\n"
},
{
"change_type": "MODIFY",
"old_path": "web/typeahead/typeahead-option-buttons.react.js",
"new_path": "web/typeahead/typeahead-option-buttons.react.js",
"diff": "@@ -65,7 +65,7 @@ class TypeaheadOptionButtons extends React.PureComponent {\nstate: State;\nrender() {\n- if (!this.props.threadInfo.viewerIsMember) {\n+ if (!this.props.threadInfo.authorized) {\nreturn (\n<ul className={css['thread-nav-option-buttons']}>\n<li>Closed</li>\n"
},
{
"change_type": "MODIFY",
"old_path": "web/typeahead/typeahead-thread-option.react.js",
"new_path": "web/typeahead/typeahead-thread-option.react.js",
"diff": "@@ -217,7 +217,7 @@ class TypeaheadThreadOption extends React.PureComponent {\nonClick = (event: SyntheticEvent) => {\nconst id = TypeaheadThreadOption.getID(this.props);\n- if (this.props.threadInfo && this.props.threadInfo.viewerIsMember) {\n+ if (this.props.threadInfo && this.props.threadInfo.authorized) {\nhistory.push(`/thread/${id}/${this.props.monthURL}`);\nthis.props.onTransition();\n} else {\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Separate authorized and viewerIsMember properties of ThreadInfo |
129,187 | 13.08.2017 17:58:07 | 14,400 | 803b1dfcfd2e087a96ef849b55186fe10a91f8c1 | Fixes on server side | [
{
"change_type": "MODIFY",
"old_path": "server/index.php",
"new_path": "server/index.php",
"diff": "@@ -132,9 +132,14 @@ list($message_infos, $truncation_status, $message_users) =\n$users = array_merge(\n$message_users,\n$entry_users,\n- $thread_users,\n+ $thread_users\n);\n+if (!$thread_infos) {\n+ // Casting empty array to object guarantees JSON encoding as {} rather than []\n+ $thread_infos = (object)$thread_infos;\n+}\n+\n$fonts_css_url = DEV\n? \"fonts/local-fonts.css\"\n: \"https://fonts.googleapis.com/css?family=Open+Sans:300,600%7CAnaheim\";\n@@ -162,7 +167,7 @@ HTML;\nvar viewer_id = \"<?=$viewer_id?>\";\nvar email = \"<?=$email?>\";\nvar email_verified = <?=($email_verified ? \"true\" : \"false\")?>;\n- var thread_infos = <?=json_encode($thread_infos, JSON_FORCE_OBJECT)?>;\n+ var thread_infos = <?=json_encode($thread_infos)?>;\nvar entry_infos = <?=json_encode($entries)?>;\nvar month = <?=$month?>;\nvar year = <?=$year?>;\n"
},
{
"change_type": "MODIFY",
"old_path": "server/join_thread.php",
"new_path": "server/join_thread.php",
"diff": "@@ -107,7 +107,7 @@ list($thread_infos, $thread_users) = get_thread_infos();\n$user_infos = combine_keyed_user_info_arrays(\n$message_users,\n- $thread_users,\n+ $thread_users\n);\nasync_end(array(\n"
},
{
"change_type": "MODIFY",
"old_path": "server/login.php",
"new_path": "server/login.php",
"diff": "@@ -73,7 +73,7 @@ if (!empty($_POST['inner_entry_query'])) {\n$return['user_infos'] = combine_keyed_user_info_arrays(\n$message_users,\n- $entry_users,\n+ $entry_users\n);\nasync_end($return);\n"
},
{
"change_type": "MODIFY",
"old_path": "server/ping.php",
"new_path": "server/ping.php",
"diff": "@@ -82,7 +82,7 @@ if (!empty($_POST['inner_entry_query'])) {\n$return['user_infos'] = combine_keyed_user_info_arrays(\n$message_users,\n$entry_users,\n- $thread_users,\n+ $thread_users\n);\nasync_end($return);\n"
},
{
"change_type": "MODIFY",
"old_path": "server/reset_password.php",
"new_path": "server/reset_password.php",
"diff": "@@ -92,7 +92,7 @@ if (!empty($_POST['inner_entry_query'])) {\n$return['user_infos'] = combine_keyed_user_info_arrays(\n$message_users,\n- $entry_users,\n+ $entry_users\n);\nasync_end($return);\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Fixes on server side |
129,187 | 14.08.2017 12:17:48 | 25,200 | e352e95e7519b3614fee12d397ff7cfdcb5eb782 | Move createEntryInfo and colorIsDark out of thread-selectors.js | [
{
"change_type": "MODIFY",
"old_path": "lib/selectors/thread-selectors.js",
"new_path": "lib/selectors/thread-selectors.js",
"diff": "@@ -6,7 +6,6 @@ import type { RawEntryInfo, EntryInfo } from '../types/entry-types';\nimport type { UserInfo } from '../types/user-types';\nimport { createSelector } from 'reselect';\n-import Color from 'color';\nimport _flow from 'lodash/fp/flow';\nimport _some from 'lodash/fp/some';\nimport _mapValues from 'lodash/fp/mapValues';\n@@ -18,30 +17,7 @@ const _mapValuesWithKeys = _mapValues.convert({ cap: false });\nimport { currentNavID } from './nav-selectors';\nimport { dateString, dateFromString } from '../utils/date-utils';\n-\n-function createEntryInfo(\n- rawEntryInfo: RawEntryInfo,\n- viewerID: ?string,\n- userInfos: {[id: string]: UserInfo},\n-): EntryInfo {\n- const creatorInfo = userInfos[rawEntryInfo.creatorID];\n- return {\n- id: rawEntryInfo.id,\n- localID: rawEntryInfo.localID,\n- threadID: rawEntryInfo.threadID,\n- text: rawEntryInfo.text,\n- year: rawEntryInfo.year,\n- month: rawEntryInfo.month,\n- day: rawEntryInfo.day,\n- creationTime: rawEntryInfo.creationTime,\n- creator: creatorInfo && creatorInfo.username,\n- deleted: rawEntryInfo.deleted,\n- };\n-}\n-\n-function colorIsDark(color: string) {\n- return Color(`#${color}`).dark();\n-}\n+import { createEntryInfo } from '../shared/entry-utils';\nconst onScreenThreadInfos = createSelector(\ncurrentNavID,\n@@ -137,8 +113,6 @@ const currentDaysToEntries = createSelector(\n);\nexport {\n- createEntryInfo,\n- colorIsDark,\nonScreenThreadInfos,\ntypeaheadSortedThreadInfos,\ncurrentDaysToEntries,\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/entry-utils.js",
"new_path": "lib/shared/entry-utils.js",
"diff": "// @flow\n-import type { EntryInfo } from '../types/entry-types';\n+import type { RawEntryInfo, EntryInfo } from '../types/entry-types';\n+import type { UserInfo } from '../types/user-types';\nimport invariant from 'invariant';\n@@ -12,4 +13,27 @@ function entryKey(entryInfo: EntryInfo): string {\nreturn entryInfo.id;\n}\n-export { entryKey }\n+function createEntryInfo(\n+ rawEntryInfo: RawEntryInfo,\n+ viewerID: ?string,\n+ userInfos: {[id: string]: UserInfo},\n+): EntryInfo {\n+ const creatorInfo = userInfos[rawEntryInfo.creatorID];\n+ return {\n+ id: rawEntryInfo.id,\n+ localID: rawEntryInfo.localID,\n+ threadID: rawEntryInfo.threadID,\n+ text: rawEntryInfo.text,\n+ year: rawEntryInfo.year,\n+ month: rawEntryInfo.month,\n+ day: rawEntryInfo.day,\n+ creationTime: rawEntryInfo.creationTime,\n+ creator: creatorInfo && creatorInfo.username,\n+ deleted: rawEntryInfo.deleted,\n+ };\n+}\n+\n+export {\n+ entryKey,\n+ createEntryInfo,\n+}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "lib/shared/thread-utils.js",
"diff": "+// @flow\n+\n+import Color from 'color';\n+\n+function colorIsDark(color: string) {\n+ return Color(`#${color}`).dark();\n+}\n+\n+export {\n+ colorIsDark,\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "native/calendar/entry.react.js",
"new_path": "native/calendar/entry.react.js",
"diff": "@@ -31,7 +31,7 @@ import _omit from 'lodash/fp/omit';\nimport _isEqual from 'lodash/fp/isEqual';\nimport Icon from 'react-native-vector-icons/FontAwesome';\n-import { colorIsDark } from 'lib/selectors/thread-selectors';\n+import { colorIsDark } from 'lib/shared/thread-utils';\nimport {\ncurrentSessionID,\nnextSessionID,\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/text-message.react.js",
"new_path": "native/chat/text-message.react.js",
"diff": "@@ -17,7 +17,7 @@ import invariant from 'invariant';\nimport PropTypes from 'prop-types';\nimport Color from 'color';\n-import { colorIsDark } from 'lib/selectors/thread-selectors';\n+import { colorIsDark } from 'lib/shared/thread-utils';\nimport { messageKey } from 'lib/shared/message-utils';\nimport { messageType } from 'lib/types/message-types';\n"
},
{
"change_type": "MODIFY",
"old_path": "web/calendar/entry.react.js",
"new_path": "web/calendar/entry.react.js",
"diff": "@@ -19,7 +19,7 @@ import { connect } from 'react-redux';\nimport PropTypes from 'prop-types';\nimport { entryKey } from 'lib/shared/entry-utils';\n-import { colorIsDark } from 'lib/selectors/thread-selectors';\n+import { colorIsDark } from 'lib/shared/thread-utils';\nimport {\nincludeDispatchActionProps,\nbindServerCalls,\n"
},
{
"change_type": "MODIFY",
"old_path": "web/modals/history/history-entry.react.js",
"new_path": "web/modals/history/history-entry.react.js",
"diff": "@@ -15,7 +15,7 @@ import { connect } from 'react-redux';\nimport invariant from 'invariant';\nimport PropTypes from 'prop-types';\n-import { colorIsDark } from 'lib/selectors/thread-selectors';\n+import { colorIsDark } from 'lib/shared/thread-utils';\nimport {\nrestoreEntryActionTypes,\nrestoreEntry,\n"
},
{
"change_type": "MODIFY",
"old_path": "web/modals/history/history-revision.react.js",
"new_path": "web/modals/history/history-revision.react.js",
"diff": "@@ -15,7 +15,7 @@ import dateFormat from 'dateformat';\nimport { connect } from 'react-redux';\nimport PropTypes from 'prop-types';\n-import { colorIsDark } from 'lib/selectors/thread-selectors';\n+import { colorIsDark } from 'lib/shared/thread-utils';\nimport css from '../../style.css';\n"
},
{
"change_type": "MODIFY",
"old_path": "web/selectors/entry-selectors.js",
"new_path": "web/selectors/entry-selectors.js",
"diff": "@@ -10,7 +10,7 @@ import _flow from 'lodash/fp/flow';\nimport _map from 'lodash/fp/map';\nimport _compact from 'lodash/fp/compact';\n-import { createEntryInfo } from 'lib/selectors/thread-selectors';\n+import { createEntryInfo } from 'lib/shared/entry-utils';\nconst allDaysToEntries = createSelector(\n(state: AppState) => state.entryStore.entryInfos,\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Move createEntryInfo and colorIsDark out of thread-selectors.js |
129,187 | 15.08.2017 10:39:06 | 25,200 | 3ff1ee5e8fc5a750af5f266271d35e87c9582b00 | Client actually sends verify_user_ids an array of strings, not an imploded string | [
{
"change_type": "MODIFY",
"old_path": "server/user_lib.php",
"new_path": "server/user_lib.php",
"diff": "require_once('auth.php');\n-// $user_ids is a string of implode'd user IDs\n+// $user_ids is an array of user IDs as strings\n// returns an array of validated user IDs\nfunction verify_user_ids($user_ids) {\nglobal $conn;\n- // Be careful with the regex below; bad validation could lead to SQL injection\n- if (!preg_match('/^(([0-9]+,)*([0-9]+))?$/', $user_ids)) {\n- return array();\n- }\n+ $int_user_ids = array_map('intval', $user_ids);\n+ $user_ids_string = implode(\",\", $int_user_ids);\n- $result = $conn->query(\"SELECT id FROM users WHERE id IN ({$user_ids})\");\n+ $query = <<<SQL\n+SELECT id FROM users WHERE id IN ({$user_ids_string})\n+SQL;\n+ $result = $conn->query($query);\n$verified_user_ids = array();\nwhile ($row = $result->fetch_assoc()) {\n$verified_user_ids[] = (int)$row['id'];\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Client actually sends verify_user_ids an array of strings, not an imploded string |
129,187 | 15.08.2017 10:40:07 | 25,200 | 67d9c6a15c80ca1e4c00b08bcd1cdbbfb39e9427 | Fix bug in user-loading code in get_thread_infos, and make sure to skip anonymous users | [
{
"change_type": "MODIFY",
"old_path": "server/thread_lib.php",
"new_path": "server/thread_lib.php",
"diff": "@@ -76,18 +76,19 @@ SQL;\nSELECT r.thread, r.user, u.username\nFROM roles r\nLEFT JOIN users u ON r.user = u.id\n-WHERE r.thread IN ({$thread_id_sql_string})\n+WHERE r.thread IN ({$thread_id_sql_string}) AND u.username IS NOT NULL\nSQL;\n$user_result = $conn->query($user_query);\n$users = array();\n- while ($row = $result->fetch_assoc()) {\n+ while ($row = $user_result->fetch_assoc()) {\n$thread_id = $row['thread'];\n$user_id = $row['user'];\n+ $username = $row['username'];\n$thread_infos[$thread_id]['memberIDs'][] = $user_id;\n$users[$user_id] = array(\n'id' => $user_id,\n- 'username' => $row['username'],\n+ 'username' => $username,\n);\n}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Fix bug in user-loading code in get_thread_infos, and make sure to skip anonymous users |
129,187 | 15.08.2017 10:57:27 | 25,200 | 6dc715dc2964318f6879aafa4079e43cbe2108b8 | Make sure get_messages_since returns TRUNCATION_EXHAUSTIVE for a thread's $truncation_status if it sees a CREATE_THREAD message | [
{
"change_type": "MODIFY",
"old_path": "server/message_lib.php",
"new_path": "server/message_lib.php",
"diff": "@@ -185,6 +185,10 @@ SQL;\n$num_for_thread++;\n}\nif ($num_for_thread <= $max_number_per_thread) {\n+ if ((int)$row['type'] === 1) {\n+ // If a CREATE_THREAD message is here, then we have all messages\n+ $truncation_status[$thread] = TRUNCATION_EXHAUSTIVE;\n+ }\n$users[$row['creatorID']] = array(\n'id' => $row['creatorID'],\n'username' => $row['creator'],\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Make sure get_messages_since returns TRUNCATION_EXHAUSTIVE for a thread's $truncation_status if it sees a CREATE_THREAD message |
129,187 | 15.08.2017 14:08:47 | 25,200 | a0d7d5447b7e1c0c02afba3cce85c6763b57fe95 | Make sure that when people are added to a NESTED_OPEN thread whose ancestors they are not members of, they are added to their ancestors as well | [
{
"change_type": "MODIFY",
"old_path": "server/edit_thread.php",
"new_path": "server/edit_thread.php",
"diff": "@@ -266,6 +266,15 @@ foreach ($add_member_ids as $add_member_id) {\n\"role\" => ROLE_SUCCESSFUL_AUTH,\n);\n}\n+if ($add_member_ids && $next_vis_rules === VISIBILITY_NESTED_OPEN) {\n+ $roles_to_save = array_merge(\n+ $roles_to_save,\n+ get_extra_roles_for_parent_of_joined_thread_id(\n+ $next_parent_thread_id,\n+ $add_member_ids\n+ )\n+ );\n+}\ncreate_user_roles($roles_to_save);\nasync_end(array(\n"
},
{
"change_type": "MODIFY",
"old_path": "server/join_thread.php",
"new_path": "server/join_thread.php",
"diff": "@@ -80,7 +80,10 @@ if ($vis_rules === VISIBILITY_OPEN) {\n\"role\" => ROLE_SUCCESSFUL_AUTH,\n);\n$message_cursors_to_query[$thread] = false;\n- $extra_roles = get_extra_roles_for_joined_thread_id($thread);\n+ $extra_roles = get_extra_roles_for_joined_thread_id(\n+ $thread,\n+ array($viewer_id)\n+ );\nif ($extra_roles === null) {\nasync_end(array(\n'error' => 'unknown_error',\n"
},
{
"change_type": "MODIFY",
"old_path": "server/new_thread.php",
"new_path": "server/new_thread.php",
"diff": "@@ -133,6 +133,15 @@ foreach ($initial_member_ids as $initial_member_id) {\n\"subscribed\" => true,\n);\n}\n+if ($initial_member_ids && $vis_rules === VISIBILITY_NESTED_OPEN) {\n+ $roles_to_save = array_merge(\n+ $roles_to_save,\n+ get_extra_roles_for_parent_of_joined_thread_id(\n+ $parent_thread_id,\n+ $initial_member_ids\n+ )\n+ );\n+}\ncreate_user_roles($roles_to_save);\n$member_ids = array_merge(\n"
},
{
"change_type": "MODIFY",
"old_path": "server/subscribe.php",
"new_path": "server/subscribe.php",
"diff": "@@ -35,7 +35,10 @@ $roles = array(array(\n\"subscribed\" => $new_subscribed,\n));\nif ($new_subscribed) {\n- $extra_roles = get_extra_roles_for_joined_thread_id($thread);\n+ $extra_roles = get_extra_roles_for_joined_thread_id(\n+ $thread,\n+ array($viewer_id)\n+ );\nif ($extra_roles === null) {\nasync_end(array(\n'error' => 'unknown_error',\n"
},
{
"change_type": "MODIFY",
"old_path": "server/thread_lib.php",
"new_path": "server/thread_lib.php",
"diff": "@@ -198,7 +198,8 @@ function verify_thread_id($thread) {\nreturn !!$row;\n}\n-function get_extra_roles_for_joined_thread_id($thread_id) {\n+// $users not sanitized!\n+function get_extra_roles_for_joined_thread_id($thread_id, $users) {\nglobal $conn;\n$thread_query = <<<SQL\n@@ -215,30 +216,60 @@ SQL;\nreturn array();\n}\n+ return get_extra_roles_for_parent_of_joined_thread_id(\n+ (int)$thread_row['parent_thread_id'],\n+ $users\n+ );\n+}\n+\n+// $users not sanitized!\n+function get_extra_roles_for_parent_of_joined_thread_id($parent_thread_id, $users) {\n+ global $conn;\n+\n$roles = array();\n- $viewer_id = get_viewer_id();\n- $current_thread_id = (int)$thread_row['parent_thread_id'];\n- while (true) {\n- $ancestor_query = <<<SQL\n-SELECT t.parent_thread_id, t.visibility_rules, r.role\n-FROM threads t\n-LEFT JOIN roles p ON p.thread = t.id AND p.user = {$viewer_id}\n-WHERE t.id = {$current_thread_id}\n+ $users_still_tracing = $users;\n+ $current_thread_id = $parent_thread_id;\n+ while ($users_still_tracing) {\n+ $user_still_tracing_sql_string = implode(\",\", $users_still_tracing);\n+ $roles_query = <<<SQL\n+SELECT role, user\n+FROM roles\n+WHERE user IN ({$user_still_tracing_sql_string}) AND\n+ thread = {$current_thread_id}\nSQL;\n- $ancestor_result = $conn->query($ancestor_query);\n- $ancestor_row = $ancestor_result->fetch_assoc();\n- if (\n- (int)$ancestor_row['visibility_rules'] !== VISIBILITY_NESTED_OPEN ||\n- (int)$ancestor_row['role'] >= ROLE_SUCCESSFUL_AUTH\n- ) {\n- break;\n+ $roles_result = $conn->query($roles_query);\n+\n+ $users_no_longer_tracing = array();\n+ while ($roles_row = $roles_result->fetch_assoc()) {\n+ $user_id = (int)$roles_row['user'];\n+ if ((int)$roles_row['role'] >= ROLE_SUCCESSFUL_AUTH) {\n+ $users_no_longer_tracing[$user_id] = $user_id;\n+ }\n}\n+ $new_users_still_tracing = array();\n+ foreach ($users_still_tracing as $user_id) {\n+ if (!isset($users_no_longer_tracing[$user_id])) {\n$roles[] = array(\n- \"user\" => $viewer_id,\n+ \"user\" => $user_id,\n\"thread\" => $current_thread_id,\n\"role\" => ROLE_SUCCESSFUL_AUTH,\n\"subscribed\" => false,\n);\n+ $new_users_still_tracing[] = $user_id;\n+ }\n+ }\n+ $users_still_tracing = $new_users_still_tracing;\n+\n+ $ancestor_query = <<<SQL\n+SELECT parent_thread_id, visibility_rules\n+FROM threads\n+WHERE id = {$current_thread_id}\n+SQL;\n+ $ancestor_result = $conn->query($ancestor_query);\n+ $ancestor_row = $ancestor_result->fetch_assoc();\n+ if ((int)$ancestor_row['visibility_rules'] !== VISIBILITY_NESTED_OPEN) {\n+ break;\n+ }\n$current_thread_id = (int)$ancestor_row['parent_thread_id'];\n}\nreturn $roles;\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Make sure that when people are added to a NESTED_OPEN thread whose ancestors they are not members of, they are added to their ancestors as well |
129,187 | 11.09.2017 00:30:08 | 14,400 | 63b1269a841aaf0186530641554dcfd51b8e484d | Update to work with (which I will now deprecate) | [
{
"change_type": "MODIFY",
"old_path": "native/account/native-credentials.js",
"new_path": "native/account/native-credentials.js",
"diff": "@@ -234,23 +234,18 @@ async function resolveInvalidatedCookie(\n}\n}\n-function getNativeCookie() {\n- return new Promise((resolve, reject) => {\n- CookieManager.get(getConfig().urlPrefix, (err, res) => {\n- if (err) {\n- reject(new Error(err));\n- } else if (res.user) {\n- resolve(`user=${decodeURIComponent(res.user)}`);\n+async function getNativeCookie() {\n+ const res = await CookieManager.get(getConfig().urlPrefix);\n+ if (res.user) {\n+ return `user=${decodeURIComponent(res.user)}`;\n} else if (res.anonymous) {\n- resolve(`anonymous=${decodeURIComponent(res.anonymous)}`);\n+ return `anonymous=${decodeURIComponent(res.anonymous)}`;\n} else {\n- resolve(null);\n+ return null;\n}\n- });\n- });\n}\n-function setNativeCookie(cookie: string) {\n+async function setNativeCookie(cookie: string) {\nconst maxAge = 2592000; // 30 days, in seconds\nconst date = new Date();\ndate.setDate(date.getDate() + 30);\n@@ -263,16 +258,18 @@ function setNativeCookie(cookie: string) {\nconst constructedCookieHeader =\n`${encodedCookie}; domain=${parsedURL.host}; path=${parsedURL.pathname}; ` +\n`expires=${date.toUTCString()}; Max-Age=${maxAge}; ${secure}httponly`;\n- const cookieInput = Platform.OS === \"ios\"\n- ? { 'Set-Cookie': constructedCookieHeader }\n- : constructedCookieHeader;\n- return new Promise((resolve, reject) => {\n- CookieManager.setFromResponse(\n+ if (Platform.OS === \"ios\") {\n+ await CookieManager.setFromResponse(\ngetConfig().urlPrefix,\n- cookieInput,\n- alwaysNull => resolve(),\n+ { 'Set-Cookie': constructedCookieHeader },\n+ () => {},\n);\n- });\n+ } else {\n+ await CookieManager.setFromResponse(\n+ getConfig().urlPrefix,\n+ constructedCookieHeader,\n+ );\n+ }\n}\nexport {\n"
},
{
"change_type": "MODIFY",
"old_path": "native/package-lock.json",
"new_path": "native/package-lock.json",
"diff": "\"integrity\": \"sha1-PBrfhx6pzWyUMbbqK9dKD/BVxME=\",\n\"dev\": true\n},\n- \"path-to-regexp\": {\n- \"version\": \"2.0.0\",\n- \"resolved\": \"https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-2.0.0.tgz\",\n- \"integrity\": \"sha512-DPZblKdQsbV6B3fHknj89h6Nw/Z5zFK0nFX+DVN7y8a+IUHf9taJWvMK+ue0+AEjXrke0KVRCcfm2pOYGSRk8g==\"\n- },\n\"path-type\": {\n\"version\": \"1.1.0\",\n\"resolved\": \"https://registry.npmjs.org/path-type/-/path-type-1.1.0.tgz\",\n\"prop-types\": \"15.5.10\"\n}\n},\n- \"react-native-tab-view\": {\n- \"version\": \"0.0.69\",\n- \"resolved\": \"https://registry.npmjs.org/react-native-tab-view/-/react-native-tab-view-0.0.69.tgz\",\n- \"integrity\": \"sha512-0K1wr40cDN90vZWZl3BfwYnUDb2mfRqFHIqkIsJCOlgu6t3vU9/I/afu/whpB3chKgumB925g5qBeC/OdGAODA==\",\n- \"requires\": {\n- \"prop-types\": \"15.5.10\"\n- }\n- },\n\"react-native-vector-icons\": {\n\"version\": \"4.3.0\",\n\"resolved\": \"https://registry.npmjs.org/react-native-vector-icons/-/react-native-vector-icons-4.3.0.tgz\",\n\"prop-types\": \"15.5.10\",\n\"react-native-drawer-layout-polyfill\": \"1.3.2\",\n\"react-native-tab-view\": \"0.0.69\"\n+ },\n+ \"dependencies\": {\n+ \"path-to-regexp\": {\n+ \"version\": \"2.0.0\",\n+ \"resolved\": \"https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-2.0.0.tgz\",\n+ \"integrity\": \"sha512-DPZblKdQsbV6B3fHknj89h6Nw/Z5zFK0nFX+DVN7y8a+IUHf9taJWvMK+ue0+AEjXrke0KVRCcfm2pOYGSRk8g==\"\n+ },\n+ \"react-native-tab-view\": {\n+ \"version\": \"0.0.69\",\n+ \"resolved\": \"https://registry.npmjs.org/react-native-tab-view/-/react-native-tab-view-0.0.69.tgz\",\n+ \"integrity\": \"sha512-0K1wr40cDN90vZWZl3BfwYnUDb2mfRqFHIqkIsJCOlgu6t3vU9/I/afu/whpB3chKgumB925g5qBeC/OdGAODA==\",\n+ \"requires\": {\n+ \"prop-types\": \"15.5.10\"\n+ }\n+ }\n}\n},\n\"react-proxy\": {\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Update to work with react-native-cookies@3.2.0 (which I will now deprecate) |
129,187 | 11.09.2017 00:47:10 | 14,400 | 3309ecba8fec4cac1900e08cac7d80b6a1fe5557 | Get rid of react-native-cookies in favor of storing cookie in Redux | [
{
"change_type": "MODIFY",
"old_path": "lib/reducers/entry-reducer.js",
"new_path": "lib/reducers/entry-reducer.js",
"diff": "@@ -135,7 +135,7 @@ function reduceEntryInfos(\ndaysToEntries: newDaysToEntries,\nlastUserInteractionCalendar: Date.now(),\n};\n- } else if (action.type === \"SET_COOKIE\" && action.payload.threadInfos) {\n+ } else if (action.type === \"SET_COOKIE\") {\nconst threadInfos = action.payload.threadInfos;\nconst authorizedThreadInfos = _pickBy('authorized')(threadInfos);\nconst newEntryInfos = _pickBy(\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/reducers/message-reducer.js",
"new_path": "lib/reducers/message-reducer.js",
"diff": "@@ -285,11 +285,10 @@ function reduceMessageStore(\n);\n} else if (\naction.type === \"LOG_OUT_SUCCESS\" ||\n- action.type === \"DELETE_ACCOUNT_SUCCESS\"\n+ action.type === \"DELETE_ACCOUNT_SUCCESS\" ||\n+ action.type === \"SET_COOKIE\"\n) {\nreturn filterByNewThreadInfos(messageStore, action.payload.threadInfos);\n- } else if (action.type === \"SET_COOKIE\" && action.payload.threadInfos) {\n- return filterByNewThreadInfos(messageStore, action.payload.threadInfos);\n} else if (action.type === \"DELETE_THREAD_SUCCESS\") {\nconst threadID = action.payload;\nconst messageIDs = messageStore.threads[threadID].messageIDs;\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/reducers/thread-reducer.js",
"new_path": "lib/reducers/thread-reducer.js",
"diff": "@@ -26,15 +26,13 @@ export default function reduceThreadInfos(\naction.type === \"LOG_IN_SUCCESS\" ||\naction.type === \"RESET_PASSWORD_SUCCESS\" ||\naction.type === \"PING_SUCCESS\" ||\n- action.type === \"JOIN_THREAD_SUCCESS\"\n+ action.type === \"JOIN_THREAD_SUCCESS\" ||\n+ action.type === \"SET_COOKIE\"\n) {\nif (_isEqual(state)(action.payload.threadInfos)) {\nreturn state;\n}\nreturn action.payload.threadInfos;\n- } else if (action.type === \"SET_COOKIE\" && action.payload.threadInfos) {\n- const threadInfos = action.payload.threadInfos;\n- return _isEqual(state)(threadInfos) ? state : threadInfos;\n} else if (action.type === \"CHANGE_THREAD_SETTINGS_SUCCESS\") {\nif (_isEqual(state[action.payload.id])(action.payload)) {\nreturn state;\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/reducers/user-reducer.js",
"new_path": "lib/reducers/user-reducer.js",
"diff": "@@ -69,17 +69,14 @@ function reduceUserInfos(\nreturn updated;\n}\n} else if (action.type === \"SET_COOKIE\") {\n- const payload = action.payload;\n- if (payload.userInfos) {\nconst updated = {\n...state,\n- ..._keyBy('id')(payload.userInfos),\n+ ..._keyBy('id')(action.payload.userInfos),\n};\nif (!_isEqual(state)(updated)) {\nreturn updated;\n}\n}\n- }\nreturn state;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/utils/action-utils.js",
"new_path": "lib/utils/action-utils.js",
"diff": "@@ -160,8 +160,6 @@ export type DispatchRecoveryAttempt = (\nexport type SetCookiePayload = {|\ncookie: ?string,\n-|} | {|\n- cookie: ?string,\nthreadInfos: {[id: string]: ThreadInfo},\nuserInfos: UserInfo[],\ncookieInvalidated: false,\n"
},
{
"change_type": "MODIFY",
"old_path": "native/account/logged-out-modal.react.js",
"new_path": "native/account/logged-out-modal.react.js",
"diff": "@@ -47,7 +47,6 @@ import { windowHeight } from '../dimensions';\nimport LogInPanelContainer from './log-in-panel-container.react';\nimport RegisterPanel from './register-panel.react';\nimport ConnectedStatusBar from '../connected-status-bar.react';\n-import { getNativeCookie, setNativeCookie } from './native-credentials';\nimport { createIsForegroundSelector } from '../selectors/nav-selectors';\nimport { pingNativeStartingPayload } from '../selectors/ping-selectors';\n@@ -195,18 +194,7 @@ class InnerLoggedOutModal extends React.PureComponent {\n// This gets triggered when an app is killed and restarted\n// Not when it is returned from being backgrounded\nasync onInitialAppLoad(nextProps: Props) {\n- // First, let's make sure that the native cookie and Redux are in sync\nlet cookie = nextProps.cookie;\n- if (cookie) {\n- await setNativeCookie(cookie);\n- } else {\n- const nativeCookie = await getNativeCookie();\n- if (nativeCookie) {\n- cookie = nativeCookie;\n- nextProps.dispatchActionPayload(\"SET_COOKIE\", { cookie });\n- }\n- }\n-\nconst showPrompt = () => {\nthis.nextMode = \"prompt\";\nthis.setState({ mode: \"prompt\" });\n"
},
{
"change_type": "MODIFY",
"old_path": "native/account/native-credentials.js",
"new_path": "native/account/native-credentials.js",
"diff": "@@ -11,7 +11,6 @@ import {\nsetSharedWebCredentials,\nresetInternetCredentials,\n} from 'react-native-keychain';\n-import CookieManager from 'react-native-cookies';\nimport URL from 'url-parse';\nimport { logInActionTypes, logIn } from 'lib/actions/user-actions';\n@@ -234,50 +233,10 @@ async function resolveInvalidatedCookie(\n}\n}\n-async function getNativeCookie() {\n- const res = await CookieManager.get(getConfig().urlPrefix);\n- if (res.user) {\n- return `user=${decodeURIComponent(res.user)}`;\n- } else if (res.anonymous) {\n- return `anonymous=${decodeURIComponent(res.anonymous)}`;\n- } else {\n- return null;\n- }\n-}\n-\n-async function setNativeCookie(cookie: string) {\n- const maxAge = 2592000; // 30 days, in seconds\n- const date = new Date();\n- date.setDate(date.getDate() + 30);\n- const parsedURL = new URL(getConfig().urlPrefix);\n- const secure = parsedURL.protocol.toLowerCase() === \"https:\"\n- ? \"secure; \"\n- : \"\";\n- const cookieParts = cookie.split(\"=\");\n- const encodedCookie = `${cookieParts[0]}=${encodeURIComponent(cookieParts[1])}`;\n- const constructedCookieHeader =\n- `${encodedCookie}; domain=${parsedURL.host}; path=${parsedURL.pathname}; ` +\n- `expires=${date.toUTCString()}; Max-Age=${maxAge}; ${secure}httponly`;\n- if (Platform.OS === \"ios\") {\n- await CookieManager.setFromResponse(\n- getConfig().urlPrefix,\n- { 'Set-Cookie': constructedCookieHeader },\n- () => {},\n- );\n- } else {\n- await CookieManager.setFromResponse(\n- getConfig().urlPrefix,\n- constructedCookieHeader,\n- );\n- }\n-}\n-\nexport {\nfetchNativeCredentials,\ngetNativeSharedWebCredentials,\nsetNativeCredentials,\ndeleteNativeCredentialsFor,\nresolveInvalidatedCookie,\n- getNativeCookie,\n- setNativeCookie,\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "native/android/app/build.gradle",
"new_path": "native/android/app/build.gradle",
"diff": "@@ -135,7 +135,6 @@ android {\ndependencies {\ncompile project(':react-native-vector-icons')\ncompile project(':react-native-keychain')\n- compile project(':react-native-cookies')\ncompile fileTree(dir: \"libs\", include: [\"*.jar\"])\ncompile \"com.android.support:appcompat-v7:23.0.1\"\ncompile \"com.facebook.react:react-native:+\" // From node_modules\n"
},
{
"change_type": "MODIFY",
"old_path": "native/android/app/src/main/java/org/squadcal/MainApplication.java",
"new_path": "native/android/app/src/main/java/org/squadcal/MainApplication.java",
"diff": "@@ -5,7 +5,6 @@ import android.app.Application;\nimport com.facebook.react.ReactApplication;\nimport com.oblador.vectoricons.VectorIconsPackage;\nimport com.oblador.keychain.KeychainPackage;\n-import com.psykar.cookiemanager.CookieManagerPackage;\nimport com.facebook.react.ReactNativeHost;\nimport com.facebook.react.ReactPackage;\nimport com.facebook.react.shell.MainReactPackage;\n@@ -27,8 +26,7 @@ public class MainApplication extends Application implements ReactApplication {\nreturn Arrays.<ReactPackage>asList(\nnew MainReactPackage(),\nnew VectorIconsPackage(),\n- new KeychainPackage(),\n- new CookieManagerPackage()\n+ new KeychainPackage()\n);\n}\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "native/android/settings.gradle",
"new_path": "native/android/settings.gradle",
"diff": "@@ -3,7 +3,5 @@ include ':react-native-vector-icons'\nproject(':react-native-vector-icons').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-vector-icons/android')\ninclude ':react-native-keychain'\nproject(':react-native-keychain').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-keychain/android')\n-include ':react-native-cookies'\n-project(':react-native-cookies').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-cookies/android')\ninclude ':app'\n"
},
{
"change_type": "MODIFY",
"old_path": "native/app.react.js",
"new_path": "native/app.react.js",
"diff": "@@ -34,10 +34,7 @@ import { sessionInactivityLimit } from 'lib/selectors/session-selectors';\nimport { RootNavigator } from './navigation-setup';\nimport { store } from './redux-setup';\n-import {\n- resolveInvalidatedCookie,\n- getNativeCookie,\n-} from './account/native-credentials';\n+import { resolveInvalidatedCookie } from './account/native-credentials';\nimport { pingNativeStartingPayload } from './selectors/ping-selectors';\nlet urlPrefix;\n"
},
{
"change_type": "DELETE",
"old_path": "native/flow-typed/npm/react-native-cookies_vx.x.x.js",
"new_path": null,
"diff": "-// flow-typed signature: 32bb2f3002f59ba625845eae6efa88dc\n-// flow-typed version: <<STUB>>/react-native-cookies_v^3.1.0/flow_v0.51.1\n-\n-/**\n- * This is an autogenerated libdef stub for:\n- *\n- * 'react-native-cookies'\n- *\n- * Fill this stub out by replacing all the `any` types.\n- *\n- * Once filled out, we encourage you to share your work with the\n- * community by sending a pull request to:\n- * https://github.com/flowtype/flow-typed\n- */\n-\n-declare module 'react-native-cookies' {\n- declare module.exports: any;\n-}\n-\n-/**\n- * We include stubs for each file inside this npm package in case you need to\n- * require those files directly. Feel free to delete any files that aren't\n- * needed.\n- */\n-\n-\n-// Filename aliases\n-declare module 'react-native-cookies/index' {\n- declare module.exports: $Exports<'react-native-cookies'>;\n-}\n-declare module 'react-native-cookies/index.js' {\n- declare module.exports: $Exports<'react-native-cookies'>;\n-}\n"
},
{
"change_type": "MODIFY",
"old_path": "native/ios/SquadCal.xcodeproj/project.pbxproj",
"new_path": "native/ios/SquadCal.xcodeproj/project.pbxproj",
"diff": "A1145AA76F5B4EF5B3ACB31D /* MaterialIcons.ttf in Resources */ = {isa = PBXBuildFile; fileRef = E4E90F44E9F4420080594671 /* MaterialIcons.ttf */; };\nA1F391C5F8A84FB28AEA9876 /* libRNKeychain.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F7A1F0235EA94B91A16863FA /* libRNKeychain.a */; };\nAFA44E75249D4766A4ED74C7 /* Octicons.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 2D04F3CCBAFF4A8184206FAC /* Octicons.ttf */; };\n- F2F6CEBA0FA0436A84C54751 /* libRNCookieManagerIOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 6F3B9EAD140A460AAD6DB028 /* libRNCookieManagerIOS.a */; };\nFA7F2215AD7646E2BE985BF3 /* SimpleLineIcons.ttf in Resources */ = {isa = PBXBuildFile; fileRef = AE31AFFF88FB4112A29ADE33 /* SimpleLineIcons.ttf */; };\n/* End PBXBuildFile section */\nremoteGlobalIDString = 139D7E881E25C6D100323FB7;\nremoteInfo = \"double-conversion\";\n};\n- 7F9636351E9820C10068E9B6 /* PBXContainerItemProxy */ = {\n- isa = PBXContainerItemProxy;\n- containerPortal = 322DB7445CF14220B93E01D2 /* RNCookieManagerIOS.xcodeproj */;\n- proxyType = 2;\n- remoteGlobalIDString = 1BD725DA1CF77A8B005DBD79;\n- remoteInfo = RNCookieManagerIOS;\n- };\n7FB58AB91E7F6B4400B4C1B1 /* PBXContainerItemProxy */ = {\nisa = PBXContainerItemProxy;\ncontainerPortal = C3BA31E561EB497494D7882F /* RNVectorIcons.xcodeproj */;\n2D02E47B1E0B4A5D006451C7 /* SquadCal-tvOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = \"SquadCal-tvOS.app\"; sourceTree = BUILT_PRODUCTS_DIR; };\n2D02E4901E0B4A5D006451C7 /* SquadCal-tvOSTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = \"SquadCal-tvOSTests.xctest\"; sourceTree = BUILT_PRODUCTS_DIR; };\n2D04F3CCBAFF4A8184206FAC /* Octicons.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = Octicons.ttf; path = \"../node_modules/react-native-vector-icons/Fonts/Octicons.ttf\"; sourceTree = \"<group>\"; };\n- 322DB7445CF14220B93E01D2 /* RNCookieManagerIOS.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = \"wrapper.pb-project\"; name = RNCookieManagerIOS.xcodeproj; path = \"../node_modules/react-native-cookies/RNCookieManagerIOS.xcodeproj\"; sourceTree = \"<group>\"; };\n3430816A291640AEACA13234 /* EvilIcons.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = EvilIcons.ttf; path = \"../node_modules/react-native-vector-icons/Fonts/EvilIcons.ttf\"; sourceTree = \"<group>\"; };\n414381A5DC394FE6BF2D28F3 /* libRNVectorIcons.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRNVectorIcons.a; sourceTree = \"<group>\"; };\n4AB1FC0EFD3A4ED1A082E32F /* FontAwesome.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = FontAwesome.ttf; path = \"../node_modules/react-native-vector-icons/Fonts/FontAwesome.ttf\"; sourceTree = \"<group>\"; };\n4ACC468F28D944F293B91ACC /* Ionicons.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = Ionicons.ttf; path = \"../node_modules/react-native-vector-icons/Fonts/Ionicons.ttf\"; sourceTree = \"<group>\"; };\n5E91572D1DD0AC6500FF2AA8 /* RCTAnimation.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = \"wrapper.pb-project\"; name = RCTAnimation.xcodeproj; path = \"../node_modules/react-native/Libraries/NativeAnimation/RCTAnimation.xcodeproj\"; sourceTree = \"<group>\"; };\n- 6F3B9EAD140A460AAD6DB028 /* libRNCookieManagerIOS.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRNCookieManagerIOS.a; sourceTree = \"<group>\"; };\n78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = \"wrapper.pb-project\"; name = RCTLinking.xcodeproj; path = \"../node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj\"; sourceTree = \"<group>\"; };\n7FB58ABB1E7F6BC600B4C1B1 /* Anaheim-Regular.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = \"Anaheim-Regular.ttf\"; sourceTree = \"<group>\"; };\n7FB58ABC1E7F6BC600B4C1B1 /* OpenSans-Regular.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = \"OpenSans-Regular.ttf\"; sourceTree = \"<group>\"; };\n139FDEF61B0652A700C62182 /* libRCTWebSocket.a in Frameworks */,\n98856FAEFDD5420882A5C010 /* libRNVectorIcons.a in Frameworks */,\nA1F391C5F8A84FB28AEA9876 /* libRNKeychain.a in Frameworks */,\n- F2F6CEBA0FA0436A84C54751 /* libRNCookieManagerIOS.a in Frameworks */,\n7F033BB61F01B5E400700D63 /* libOnePassword.a in Frameworks */,\n);\nrunOnlyForDeploymentPostprocessing = 0;\nname = Products;\nsourceTree = \"<group>\";\n};\n- 7F9636181E9820C10068E9B6 /* Products */ = {\n- isa = PBXGroup;\n- children = (\n- 7F9636361E9820C10068E9B6 /* libRNCookieManagerIOS.a */,\n- );\n- name = Products;\n- sourceTree = \"<group>\";\n- };\n7FB58A9D1E7F6B4300B4C1B1 /* Products */ = {\nisa = PBXGroup;\nchildren = (\nC3BA31E561EB497494D7882F /* RNVectorIcons.xcodeproj */,\nE7D7D614C3184B1BB95EE661 /* OnePassword.xcodeproj */,\n95EEFC35D4D14053ACA7E064 /* RNKeychain.xcodeproj */,\n- 322DB7445CF14220B93E01D2 /* RNCookieManagerIOS.xcodeproj */,\n);\nname = Libraries;\nsourceTree = \"<group>\";\nProductGroup = 146834001AC3E56700842450 /* Products */;\nProjectRef = 146833FF1AC3E56700842450 /* React.xcodeproj */;\n},\n- {\n- ProductGroup = 7F9636181E9820C10068E9B6 /* Products */;\n- ProjectRef = 322DB7445CF14220B93E01D2 /* RNCookieManagerIOS.xcodeproj */;\n- },\n{\nProductGroup = 7FEB2DCE1E8D64D200C4B763 /* Products */;\nProjectRef = 95EEFC35D4D14053ACA7E064 /* RNKeychain.xcodeproj */;\nremoteRef = 7F033BB11F01B5E100700D63 /* PBXContainerItemProxy */;\nsourceTree = BUILT_PRODUCTS_DIR;\n};\n- 7F9636361E9820C10068E9B6 /* libRNCookieManagerIOS.a */ = {\n- isa = PBXReferenceProxy;\n- fileType = archive.ar;\n- path = libRNCookieManagerIOS.a;\n- remoteRef = 7F9636351E9820C10068E9B6 /* PBXContainerItemProxy */;\n- sourceTree = BUILT_PRODUCTS_DIR;\n- };\n7FB58ABA1E7F6B4400B4C1B1 /* libRNVectorIcons.a */ = {\nisa = PBXReferenceProxy;\nfileType = archive.ar;\n\"$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager\",\n\"$(SRCROOT)/../node_modules/react-native-onepassword\",\n\"$(SRCROOT)/../node_modules/react-native-keychain/RNKeychainManager\",\n- \"$(SRCROOT)/../node_modules/react-native-cookies/RNCookieManagerIOS\",\n);\nINFOPLIST_FILE = SquadCalTests/Info.plist;\nIPHONEOS_DEPLOYMENT_TARGET = 8.0;\nLD_RUNPATH_SEARCH_PATHS = \"$(inherited) @executable_path/Frameworks @loader_path/Frameworks\";\nLIBRARY_SEARCH_PATHS = (\n\"$(inherited)\",\n- \"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n- \"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n- \"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n- \"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n);\nOTHER_LDFLAGS = (\n\"-ObjC\",\n\"$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager\",\n\"$(SRCROOT)/../node_modules/react-native-onepassword\",\n\"$(SRCROOT)/../node_modules/react-native-keychain/RNKeychainManager\",\n- \"$(SRCROOT)/../node_modules/react-native-cookies/RNCookieManagerIOS\",\n);\nINFOPLIST_FILE = SquadCalTests/Info.plist;\nIPHONEOS_DEPLOYMENT_TARGET = 8.0;\nLD_RUNPATH_SEARCH_PATHS = \"$(inherited) @executable_path/Frameworks @loader_path/Frameworks\";\nLIBRARY_SEARCH_PATHS = (\n\"$(inherited)\",\n- \"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n- \"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n- \"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n- \"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n);\nOTHER_LDFLAGS = (\n\"-ObjC\",\n\"$(SRCROOT)/../node_modules/react-native-onepassword\",\n\"$(SRCROOT)/../node_modules/react-native/Libraries/LinkingIOS\",\n\"$(SRCROOT)/../node_modules/react-native-keychain/RNKeychainManager\",\n- \"$(SRCROOT)/../node_modules/react-native-cookies/RNCookieManagerIOS\",\n);\nINFOPLIST_FILE = SquadCal/Info.plist;\nLD_RUNPATH_SEARCH_PATHS = \"$(inherited) @executable_path/Frameworks\";\n\"$(SRCROOT)/../node_modules/react-native-onepassword\",\n\"$(SRCROOT)/../node_modules/react-native/Libraries/LinkingIOS\",\n\"$(SRCROOT)/../node_modules/react-native-keychain/RNKeychainManager\",\n- \"$(SRCROOT)/../node_modules/react-native-cookies/RNCookieManagerIOS\",\n);\nINFOPLIST_FILE = SquadCal/Info.plist;\nLD_RUNPATH_SEARCH_PATHS = \"$(inherited) @executable_path/Frameworks\";\n\"$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager\",\n\"$(SRCROOT)/../node_modules/react-native-onepassword\",\n\"$(SRCROOT)/../node_modules/react-native-keychain/RNKeychainManager\",\n- \"$(SRCROOT)/../node_modules/react-native-cookies/RNCookieManagerIOS\",\n);\nINFOPLIST_FILE = \"SquadCal-tvOS/Info.plist\";\nLD_RUNPATH_SEARCH_PATHS = \"$(inherited) @executable_path/Frameworks\";\nLIBRARY_SEARCH_PATHS = (\n\"$(inherited)\",\n- \"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n- \"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n- \"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n- \"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n);\nOTHER_LDFLAGS = (\n\"-ObjC\",\n\"$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager\",\n\"$(SRCROOT)/../node_modules/react-native-onepassword\",\n\"$(SRCROOT)/../node_modules/react-native-keychain/RNKeychainManager\",\n- \"$(SRCROOT)/../node_modules/react-native-cookies/RNCookieManagerIOS\",\n);\nINFOPLIST_FILE = \"SquadCal-tvOS/Info.plist\";\nLD_RUNPATH_SEARCH_PATHS = \"$(inherited) @executable_path/Frameworks\";\nLIBRARY_SEARCH_PATHS = (\n\"$(inherited)\",\n- \"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n- \"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n- \"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n- \"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n);\nOTHER_LDFLAGS = (\n\"-ObjC\",\nLD_RUNPATH_SEARCH_PATHS = \"$(inherited) @executable_path/Frameworks @loader_path/Frameworks\";\nLIBRARY_SEARCH_PATHS = (\n\"$(inherited)\",\n- \"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n- \"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n- \"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n- \"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n);\nPRODUCT_BUNDLE_IDENTIFIER = \"com.facebook.REACT.SquadCal-tvOSTests\";\nPRODUCT_NAME = \"$(TARGET_NAME)\";\nLD_RUNPATH_SEARCH_PATHS = \"$(inherited) @executable_path/Frameworks @loader_path/Frameworks\";\nLIBRARY_SEARCH_PATHS = (\n\"$(inherited)\",\n- \"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n- \"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n- \"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n- \"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n);\nPRODUCT_BUNDLE_IDENTIFIER = \"com.facebook.REACT.SquadCal-tvOSTests\";\nPRODUCT_NAME = \"$(TARGET_NAME)\";\n"
},
{
"change_type": "MODIFY",
"old_path": "native/package-lock.json",
"new_path": "native/package-lock.json",
"diff": "}\n}\n},\n- \"react-native-cookies\": {\n- \"version\": \"3.2.0\",\n- \"resolved\": \"https://registry.npmjs.org/react-native-cookies/-/react-native-cookies-3.2.0.tgz\",\n- \"integrity\": \"sha1-EHnU02i7KH0cipPzubYKS95lmWY=\",\n- \"requires\": {\n- \"invariant\": \"2.2.2\"\n- }\n- },\n\"react-native-dismiss-keyboard\": {\n\"version\": \"1.0.0\",\n\"resolved\": \"https://registry.npmjs.org/react-native-dismiss-keyboard/-/react-native-dismiss-keyboard-1.0.0.tgz\",\n"
},
{
"change_type": "MODIFY",
"old_path": "native/package.json",
"new_path": "native/package.json",
"diff": "\"lib\": \"file:../lib\",\n\"react\": \"^16.0.0-rc.2\",\n\"react-native\": \"^0.48.2\",\n- \"react-native-cookies\": \"^3.2.0\",\n\"react-native-keychain\": \"^1.2.1\",\n\"react-native-onepassword\": \"^1.0.4\",\n\"react-native-segmented-control-tab\": \"git+https://github.com/ashoat/react-native-segmented-control-tab.git\",\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Get rid of react-native-cookies in favor of storing cookie in Redux |
129,187 | 11.09.2017 01:03:46 | 14,400 | aa5aab9e111dcd1c01e4d3b781e9695df3fc0bbc | I'm going to upgrade to the latest react-navigation version, and just suppress the Flow errors | [
{
"change_type": "MODIFY",
"old_path": "native/.flowconfig",
"new_path": "native/.flowconfig",
"diff": ".*/Libraries/react-native/React.js\n.*/Libraries/react-native/ReactNative.js\n+.*/node_modules/react-navigation/.*\n+\n[include]\n../lib\n"
},
{
"change_type": "MODIFY",
"old_path": "native/package-lock.json",
"new_path": "native/package-lock.json",
"diff": "\"integrity\": \"sha1-PBrfhx6pzWyUMbbqK9dKD/BVxME=\",\n\"dev\": true\n},\n+ \"path-to-regexp\": {\n+ \"version\": \"1.7.0\",\n+ \"resolved\": \"https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-1.7.0.tgz\",\n+ \"integrity\": \"sha1-Wf3g9DW62suhA6hOnTvGTpa5k30=\",\n+ \"requires\": {\n+ \"isarray\": \"0.0.1\"\n+ },\n+ \"dependencies\": {\n+ \"isarray\": {\n+ \"version\": \"0.0.1\",\n+ \"resolved\": \"https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz\",\n+ \"integrity\": \"sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=\"\n+ }\n+ }\n+ },\n\"path-type\": {\n\"version\": \"1.1.0\",\n\"resolved\": \"https://registry.npmjs.org/path-type/-/path-type-1.1.0.tgz\",\n\"prop-types\": \"15.5.10\"\n}\n},\n+ \"react-native-tab-view\": {\n+ \"version\": \"0.0.67\",\n+ \"resolved\": \"https://registry.npmjs.org/react-native-tab-view/-/react-native-tab-view-0.0.67.tgz\",\n+ \"integrity\": \"sha1-zdFG/l5dS6/2yJ8tXQsV+iPbOdA=\",\n+ \"requires\": {\n+ \"prop-types\": \"15.5.10\"\n+ }\n+ },\n\"react-native-vector-icons\": {\n\"version\": \"4.3.0\",\n\"resolved\": \"https://registry.npmjs.org/react-native-vector-icons/-/react-native-vector-icons-4.3.0.tgz\",\n}\n},\n\"react-navigation\": {\n- \"version\": \"git+https://github.com/ashoat/react-navigation.git#c1dc2f045d5f0e8f8d0295bb744684112534be17\",\n+ \"version\": \"1.0.0-beta.12\",\n+ \"resolved\": \"https://registry.npmjs.org/react-navigation/-/react-navigation-1.0.0-beta.12.tgz\",\n+ \"integrity\": \"sha1-zw8E/7+f7+QfXFodq5IQa0iinwo=\",\n\"requires\": {\n\"clamp\": \"1.0.1\",\n\"hoist-non-react-statics\": \"2.3.1\",\n- \"path-to-regexp\": \"2.0.0\",\n+ \"path-to-regexp\": \"1.7.0\",\n\"prop-types\": \"15.5.10\",\n\"react-native-drawer-layout-polyfill\": \"1.3.2\",\n- \"react-native-tab-view\": \"0.0.69\"\n- },\n- \"dependencies\": {\n- \"path-to-regexp\": {\n- \"version\": \"2.0.0\",\n- \"resolved\": \"https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-2.0.0.tgz\",\n- \"integrity\": \"sha512-DPZblKdQsbV6B3fHknj89h6Nw/Z5zFK0nFX+DVN7y8a+IUHf9taJWvMK+ue0+AEjXrke0KVRCcfm2pOYGSRk8g==\"\n- },\n- \"react-native-tab-view\": {\n- \"version\": \"0.0.69\",\n- \"resolved\": \"https://registry.npmjs.org/react-native-tab-view/-/react-native-tab-view-0.0.69.tgz\",\n- \"integrity\": \"sha512-0K1wr40cDN90vZWZl3BfwYnUDb2mfRqFHIqkIsJCOlgu6t3vU9/I/afu/whpB3chKgumB925g5qBeC/OdGAODA==\",\n- \"requires\": {\n- \"prop-types\": \"15.5.10\"\n- }\n- }\n+ \"react-native-tab-view\": \"0.0.67\"\n}\n},\n\"react-proxy\": {\n"
},
{
"change_type": "MODIFY",
"old_path": "native/package.json",
"new_path": "native/package.json",
"diff": "\"react-native-onepassword\": \"^1.0.4\",\n\"react-native-segmented-control-tab\": \"git+https://github.com/ashoat/react-native-segmented-control-tab.git\",\n\"react-native-vector-icons\": \"^4.3.0\",\n- \"react-navigation\": \"git+https://github.com/ashoat/react-navigation.git\",\n+ \"react-navigation\": \"^1.0.0-beta.12\",\n\"react-redux\": \"^5.0.6\",\n\"redux\": \"^3.7.2\",\n\"redux-devtools-extension\": \"^2.13.2\",\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | I'm going to upgrade to the latest react-navigation version, and just suppress the Flow errors |
129,187 | 13.09.2017 11:58:24 | 14,400 | b06b1d2fe3523ff1fbe7252ce3181ed07f49d2a5 | When creating a subthread only shows the users in the superthread | [
{
"change_type": "MODIFY",
"old_path": "lib/selectors/user-selectors.js",
"new_path": "lib/selectors/user-selectors.js",
"diff": "@@ -4,39 +4,60 @@ import type { BaseAppState } from '../types/redux-types';\nimport type { UserInfo } from '../types/user-types';\nimport { createSelector } from 'reselect';\n+import _memoize from 'lodash/memoize';\n+import _keys from 'lodash/keys';\nimport SearchIndex from '../shared/search-index';\n-// other than the logged-in user\n-const otherUserInfos = createSelector(\n+// If threadID is null, then all users except the logged-in user are returned\n+const baseUserInfoSelectorForOtherMembersOfThread = (threadID: ?string) =>\n+ createSelector(\n(state: BaseAppState) => state.userInfos,\n(state: BaseAppState) => state.currentUserInfo && state.currentUserInfo.id,\n+ (state: BaseAppState) => threadID && state.threadInfos[threadID]\n+ ? state.threadInfos[threadID].memberIDs\n+ : null,\n(\nuserInfos: {[id: string]: UserInfo},\n- userID: ?string,\n+ currentUserID: ?string,\n+ memberUserIDs: ?string[],\n): {[id: string]: UserInfo} => {\nconst others = {};\n- for (let id in userInfos) {\n- if (id !== userID) {\n- others[id] = userInfos[id];\n+ if (!memberUserIDs) {\n+ memberUserIDs = _keys(userInfos);\n+ }\n+ for (let memberID of memberUserIDs) {\n+ if (memberID !== currentUserID && userInfos[memberID]) {\n+ others[memberID] = userInfos[memberID];\n}\n}\nreturn others;\n},\n);\n-const userSearchIndex = createSelector(\n- otherUserInfos,\n- (userInfos: {[id: string]: UserInfo}) => {\n+const userInfoSelectorForOtherMembersOfThread = _memoize(\n+ baseUserInfoSelectorForOtherMembersOfThread,\n+);\n+\n+function searchIndexFromUserInfos(userInfos: {[id: string]: UserInfo}) {\nconst searchIndex = new SearchIndex();\nfor (const id in userInfos) {\nsearchIndex.addEntry(id, userInfos[id].username);\n}\nreturn searchIndex;\n- },\n+}\n+\n+const baseUserSearchIndexForOtherMembersOfThread = (threadID: ?string) =>\n+ createSelector(\n+ userInfoSelectorForOtherMembersOfThread(threadID),\n+ searchIndexFromUserInfos,\n+ );\n+\n+const userSearchIndexForOtherMembersOfThread = _memoize(\n+ baseUserSearchIndexForOtherMembersOfThread,\n);\nexport {\n- otherUserInfos,\n- userSearchIndex,\n+ userInfoSelectorForOtherMembersOfThread,\n+ userSearchIndexForOtherMembersOfThread,\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/add-thread.react.js",
"new_path": "native/chat/add-thread.react.js",
"diff": "@@ -35,7 +35,10 @@ import {\nsearchUsers,\n} from 'lib/actions/user-actions';\nimport { createLoadingStatusSelector } from 'lib/selectors/loading-selectors';\n-import { otherUserInfos, userSearchIndex } from 'lib/selectors/user-selectors';\n+import {\n+ userInfoSelectorForOtherMembersOfThread,\n+ userSearchIndexForOtherMembersOfThread,\n+} from 'lib/selectors/user-selectors';\nimport SearchIndex from 'lib/shared/search-index';\nimport { generateRandomColor } from 'lib/shared/thread-utils';\n@@ -482,8 +485,10 @@ const AddThread = connect(\nreturn {\nloadingStatus: loadingStatusSelector(state),\nparentThreadInfo,\n- otherUserInfos: otherUserInfos(state),\n- userSearchIndex: userSearchIndex(state),\n+ otherUserInfos:\n+ userInfoSelectorForOtherMembersOfThread(parentThreadID)(state),\n+ userSearchIndex:\n+ userSearchIndexForOtherMembersOfThread(parentThreadID)(state),\nsecondChatRouteKey: secondChatRoute && secondChatRoute.key,\ncookie: state.cookie,\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "native/components/tag-input.react.js",
"new_path": "native/components/tag-input.react.js",
"diff": "@@ -219,7 +219,7 @@ class TagInput<TagData> extends React.PureComponent<\nreturn (\n<TouchableWithoutFeedback\nonPress={this.focus}\n- style={[styles.container]}\n+ style={styles.container}\nonLayout={this.measureWrapper}\n>\n<View\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | When creating a subthread only shows the users in the superthread |
129,187 | 15.09.2017 16:43:32 | 14,400 | 4d294d45c789e6c80b856e239b26d4df27f599c6 | Working color selection logic! | [
{
"change_type": "MODIFY",
"old_path": "native/chat/add-thread.react.js",
"new_path": "native/chat/add-thread.react.js",
"diff": "@@ -17,10 +17,19 @@ import type { NewThreadResult } from 'lib/actions/thread-actions';\nimport React from 'react';\nimport PropTypes from 'prop-types';\n-import { View, Text, StyleSheet, TextInput, Alert } from 'react-native';\n+import {\n+ View,\n+ Text,\n+ StyleSheet,\n+ TextInput,\n+ Alert,\n+ TouchableWithoutFeedback,\n+ TouchableHighlight,\n+} from 'react-native';\nimport { connect } from 'react-redux';\nimport SegmentedControlTab from 'react-native-segmented-control-tab';\nimport invariant from 'invariant';\n+import Icon from 'react-native-vector-icons/FontAwesome';\nimport {\nincludeDispatchActionProps,\n@@ -251,13 +260,31 @@ class InnerAddThread extends React.PureComponent {\nlet colorPicker = null;\nif (this.state.showColorPicker) {\ncolorPicker = (\n- <View style={styles.colorPickerOverlay}>\n+ <View style={[\n+ styles.colorPickerOverlay,\n+ styles.colorPickerOverlayBackground,\n+ ]}>\n+ <TouchableWithoutFeedback onPress={this.closeColorPicker}>\n+ <View style={styles.colorPickerOverlay} />\n+ </TouchableWithoutFeedback>\n<View style={styles.colorPickerContainer}>\n<ColorPicker\ndefaultColor={this.state.color}\n- onColorSelected={color => alert(`Color selected: ${color}`)}\n+ onColorSelected={this.onColorSelected}\nstyle={styles.colorPicker}\n/>\n+ <TouchableHighlight\n+ onPress={this.closeColorPicker}\n+ style={styles.closeButton}\n+ underlayColor=\"#CCCCCCDD\"\n+ >\n+ <Icon\n+ name=\"close\"\n+ size={16}\n+ color=\"#AAAAAA\"\n+ style={styles.closeButtonIcon}\n+ />\n+ </TouchableHighlight>\n</View>\n</View>\n);\n@@ -395,6 +422,17 @@ class InnerAddThread extends React.PureComponent {\nthis.setState({ showColorPicker: true });\n}\n+ onColorSelected = (color: string) => {\n+ this.setState({\n+ showColorPicker: false,\n+ color: color.substr(1),\n+ });\n+ }\n+\n+ closeColorPicker = () => {\n+ this.setState({ showColorPicker: false });\n+ }\n+\nonPressCreateThread = () => {\nconst name = this.state.nameInputText.trim();\nif (name === '') {\n@@ -519,8 +557,10 @@ const styles = StyleSheet.create({\nsegmentedTextStyle: {\ncolor: '#777',\n},\n- colorPickerOverlay: {\n+ colorPickerOverlayBackground: {\nbackgroundColor: '#CCCCCCAA',\n+ },\n+ colorPickerOverlay: {\nposition: 'absolute',\ntop: 0,\nbottom: 0,\n@@ -533,8 +573,8 @@ const styles = StyleSheet.create({\nmargin: 20,\nmarginLeft: 15,\nmarginRight: 15,\n- marginTop: 15,\n- marginBottom: 180,\n+ marginTop: 100,\n+ marginBottom: 65,\nborderRadius: 5,\n},\ncolorPicker: {\n@@ -554,6 +594,18 @@ const styles = StyleSheet.create({\nchangeColorButton: {\npaddingTop: 2,\n},\n+ closeButton: {\n+ position: 'absolute',\n+ top: 5,\n+ right: 5,\n+ width: 18,\n+ height: 18,\n+ borderRadius: 3,\n+ },\n+ closeButtonIcon: {\n+ position: 'absolute',\n+ left: 3,\n+ },\n});\nconst AddThreadRouteName = 'AddThread';\n"
},
{
"change_type": "MODIFY",
"old_path": "native/components/button.react.js",
"new_path": "native/components/button.react.js",
"diff": "@@ -21,23 +21,35 @@ class Button extends React.PureComponent {\nonSubmit: () => void,\ndisabled?: bool,\nstyle?: StyleObj,\n+ // style and topStyle just get merged in most cases. The separation only\n+ // matters in the case of iOS and defaultFormat = \"highlight\", where the\n+ // topStyle is necessary for layout, and the bottom style is necessary for\n+ // colors etc.\n+ topStyle?: StyleObj,\nunderlayColor?: string,\nchildren?: React.Element<any>,\ndefaultFormat: \"highlight\" | \"opacity\",\n+ androidBorderlessRipple: bool,\n+ iosActiveOpacity: number,\n};\nstatic propTypes = {\nonSubmit: PropTypes.func.isRequired,\ndisabled: PropTypes.bool,\nstyle: ViewPropTypes.style,\n+ topStyle: ViewPropTypes.style,\nunderlayColor: PropTypes.string,\nchildren: PropTypes.object,\ndefaultFormat: PropTypes.oneOf([\n\"highlight\",\n\"opacity\",\n]),\n+ androidBorderlessRipple: PropTypes.bool,\n+ iosActiveOpacity: PropTypes.number,\n};\nstatic defaultProps = {\ndefaultFormat: \"highlight\",\n+ androidBorderlessRipple: true,\n+ iosActiveOpacity: 0.85,\n};\nrender() {\n@@ -48,10 +60,10 @@ class Button extends React.PureComponent {\ndisabled={!!this.props.disabled}\nbackground={TouchableNativeFeedback.Ripple(\n'rgba(0, 0, 0, .32)',\n- true,\n+ this.props.androidBorderlessRipple,\n)}\n>\n- <View style={this.props.style}>\n+ <View style={[this.props.topStyle, this.props.style]}>\n{this.props.children}\n</View>\n</TouchableNativeFeedback>\n@@ -60,21 +72,26 @@ class Button extends React.PureComponent {\nconst underlayColor = this.props.underlayColor\n? this.props.underlayColor\n: \"#CCCCCCDD\";\n+ const child = this.props.children ? this.props.children : <View />;\nreturn (\n<TouchableHighlight\nonPress={this.props.onSubmit}\n- style={this.props.style}\n+ style={this.props.topStyle}\nunderlayColor={underlayColor}\n+ activeOpacity={this.props.iosActiveOpacity}\ndisabled={!!this.props.disabled}\n>\n+ <View style={this.props.style}>\n{this.props.children}\n+ </View>\n</TouchableHighlight>\n);\n} else {\nreturn (\n<TouchableOpacity\nonPress={this.props.onSubmit}\n- style={this.props.style}\n+ style={[this.props.topStyle, this.props.style]}\n+ activeOpacity={this.props.iosActiveOpacity}\ndisabled={!!this.props.disabled}\n>\n{this.props.children}\n"
},
{
"change_type": "MODIFY",
"old_path": "native/components/color-picker.react.js",
"new_path": "native/components/color-picker.react.js",
"diff": "import type {\nStyleObj,\n} from 'react-native/Libraries/StyleSheet/StyleSheetTypes';\n+import type {\n+ NativeMethodsMixinType,\n+} from 'react-native/Libraries/Renderer/shims/ReactNativeTypes';\nimport React from 'react';\nimport PropTypes from 'prop-types';\nimport {\n- TouchableOpacity,\nView,\nImage,\nStyleSheet,\n@@ -15,10 +17,15 @@ import {\nI18nManager,\nPanResponder,\nViewPropTypes,\n+ Text,\n+ Platform,\n+ Keyboard,\n} from 'react-native';\nimport tinycolor from 'tinycolor2';\nimport invariant from 'invariant';\n+import Button from './button.react';\n+\ntype PanEvent = {\nnativeEvent: {\npageX: number,\n@@ -34,6 +41,7 @@ type Props = {\nonColorSelected?: (color: string) => void,\nonOldColorSelected?: (color: string) => void,\nstyle?: StyleObj,\n+ buttonText: string,\n};\ntype State = {\ncolor: HSVColor,\n@@ -57,14 +65,17 @@ class ColorPicker extends React.PureComponent {\nonColorSelected: PropTypes.func,\nonOldColorSelected: PropTypes.func,\nstyle: ViewPropTypes.style,\n+ buttonText: PropTypes.string,\n+ };\n+ static defaultProps = {\n+ buttonText: \"Select\",\n};\nprops: Props;\nstate: State;\n_layout = { width: 0, height: 0 };\n_pageX = 0;\n_pageY = 0;\n- // $FlowFixMe React Native types View as a string? #15955\n- _pickerContainer: ?View = null;\n+ _pickerContainer: ?NativeMethodsMixinType = null;\n_pickerResponder: ?PanResponder = null;\n_changingHColor = false;\n@@ -82,6 +93,7 @@ class ColorPicker extends React.PureComponent {\n}\ncomponentWillMount() {\n+ Keyboard.dismiss();\nconst handleColorChange = ({ x, y }: { x: number, y: number }) => {\nif (this._changingHColor) {\nthis._handleHColorChange({ x, y });\n@@ -153,8 +165,8 @@ class ColorPicker extends React.PureComponent {\n}}}) => {\nthis._layout = l.nativeEvent.layout;\nconst { width, height } = this._layout;\n- const pickerSize = Math.min(width, height);\n- if (this.state.pickerSize !== pickerSize) {\n+ const pickerSize = Math.round(Math.min(width, height));\n+ if (Math.abs(this.state.pickerSize - pickerSize) >= 3) {\nthis.setState({ pickerSize });\n}\n@@ -299,7 +311,9 @@ class ColorPicker extends React.PureComponent {\nconst { pickerSize } = this.state;\nconst { oldColor, style } = this.props;\nconst color = this._getColor();\n- const selectedColor = tinycolor(color).toHexString();\n+ const tc = tinycolor(color);\n+ const selectedColor: string = tc.toHexString();\n+ const isDark: bool = tc.isDark();\nlet picker = null;\nif (pickerSize) {\n@@ -354,10 +368,15 @@ class ColorPicker extends React.PureComponent {\nlet oldColorButton = null;\nif (oldColor) {\noldColorButton = (\n- <TouchableOpacity\n- style={[styles.colorPreview, { backgroundColor: oldColor }]}\n- onPress={this._onOldColorSelected}\n- activeOpacity={0.7}\n+ <Button\n+ topStyle={styles.colorPreview}\n+ style={[\n+ styles.buttonContents,\n+ { backgroundColor: oldColor },\n+ ]}\n+ onSubmit={this._onOldColorSelected}\n+ androidBorderlessRipple={false}\n+ iosActiveOpacity={0.6}\n/>\n);\n}\n@@ -366,6 +385,12 @@ class ColorPicker extends React.PureComponent {\n? this.state.pickerSize * 0.1 // responsive height\n: 20,\n};\n+ const buttonContentsStyle = {\n+ backgroundColor: selectedColor,\n+ };\n+ const buttonTextStyle = {\n+ color: isDark ? 'white' : 'black',\n+ };\nreturn (\n<View style={style}>\n<View\n@@ -375,20 +400,27 @@ class ColorPicker extends React.PureComponent {\n>\n{picker}\n</View>\n+ <View>\n<View style={[styles.colorPreviews, colorPreviewsStyle]}>\n{oldColorButton}\n- <TouchableOpacity\n- style={[styles.colorPreview, { backgroundColor: selectedColor }]}\n- onPress={this._onColorSelected}\n- activeOpacity={0.7}\n- />\n+ <Button\n+ style={[styles.buttonContents, buttonContentsStyle]}\n+ topStyle={styles.colorPreview}\n+ onSubmit={this._onColorSelected}\n+ androidBorderlessRipple={false}\n+ iosActiveOpacity={0.6}\n+ >\n+ <Text style={[styles.buttonText, buttonTextStyle]}>\n+ {this.props.buttonText}\n+ </Text>\n+ </Button>\n+ </View>\n</View>\n</View>\n)\n}\n- // $FlowFixMe React Native types View as a string? #15955\n- pickerContainerRef = (pickerContainer: ?View) => {\n+ pickerContainerRef = (pickerContainer: ?NativeMethodsMixinType) => {\nthis._pickerContainer = pickerContainer;\n}\n@@ -511,9 +543,6 @@ const makeComputedStyles = ({\nborderBottomWidth: triangleHeight,\nborderBottomColor: indicatorColor,\n},\n- colorPreviews: {\n- height: pickerSize * 0.1, // responsive height\n- },\n};\n}\n@@ -586,6 +615,16 @@ const styles = StyleSheet.create({\ncolorPreview: {\nflex: 1,\n},\n+ buttonContents: {\n+ flex: 1,\n+ borderRadius: 3,\n+ padding: Platform.select({ ios: 3, default: 0 }),\n+ },\n+ buttonText: {\n+ flex: 1,\n+ fontSize: 20,\n+ textAlign: 'center',\n+ },\n});\nexport default ColorPicker;\n"
},
{
"change_type": "MODIFY",
"old_path": "native/components/user-list-user.react.js",
"new_path": "native/components/user-list-user.react.js",
"diff": "@@ -25,7 +25,7 @@ class UserListUser extends React.PureComponent {\nrender() {\nreturn (\n- <Button onSubmit={this.onSelect}>\n+ <Button onSubmit={this.onSelect} androidBorderlessRipple={false}>\n<Text style={styles.text}>{this.props.userInfo.username}</Text>\n</Button>\n);\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Working color selection logic! |
129,187 | 18.09.2017 20:54:33 | 14,400 | 7f79c7601ce306872d10504f49f4fab70d3eeedf | In TagInput, make sure to update this.state.wrapperHeight when this.props.maxHeight changes | [
{
"change_type": "MODIFY",
"old_path": "native/components/tag-input.react.js",
"new_path": "native/components/tag-input.react.js",
"diff": "@@ -128,6 +128,13 @@ class TagInput<TagData> extends React.PureComponent<\nif (inputWidth !== this.state.inputWidth) {\nthis.setState({ inputWidth });\n}\n+ const wrapperHeight = Math.min(\n+ nextProps.maxHeight,\n+ this.contentHeight,\n+ );\n+ if (wrapperHeight !== this.state.wrapperHeight) {\n+ this.setState({ wrapperHeight });\n+ }\n}\ncomponentWillUpdate(nextProps: Props<TagData>, nextState: State) {\n@@ -271,9 +278,7 @@ class TagInput<TagData> extends React.PureComponent<\nif (this.contentHeight === h) {\nreturn;\n}\n- const nextWrapperHeight = h > this.props.maxHeight\n- ? this.props.maxHeight\n- : h;\n+ const nextWrapperHeight = Math.min(this.props.maxHeight, h);\nif (nextWrapperHeight !== this.state.wrapperHeight) {\nthis.setState(\n{ wrapperHeight: nextWrapperHeight },\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | In TagInput, make sure to update this.state.wrapperHeight when this.props.maxHeight changes |
129,187 | 19.09.2017 22:51:58 | 14,400 | 4ceb2d6928537f3d1cda6f414d0c02810a65823c | Fix react-navigation Flow types | [
{
"change_type": "MODIFY",
"old_path": "native/.flowconfig",
"new_path": "native/.flowconfig",
"diff": ".*/Libraries/react-native/React.js\n.*/Libraries/react-native/ReactNative.js\n-.*/node_modules/react-navigation/.*\n-\n[include]\n../lib\n"
},
{
"change_type": "MODIFY",
"old_path": "native/package-lock.json",
"new_path": "native/package-lock.json",
"diff": "\"babel-template\": \"6.26.0\"\n}\n},\n+ \"babel-plugin-transform-define\": {\n+ \"version\": \"1.3.0\",\n+ \"resolved\": \"https://registry.npmjs.org/babel-plugin-transform-define/-/babel-plugin-transform-define-1.3.0.tgz\",\n+ \"integrity\": \"sha1-lMX5RZyBDHOMx8UMvUSjGCnW8xk=\",\n+ \"requires\": {\n+ \"lodash\": \"4.17.4\",\n+ \"traverse\": \"0.6.6\"\n+ }\n+ },\n\"babel-plugin-transform-es2015-arrow-functions\": {\n\"version\": \"6.22.0\",\n\"resolved\": \"https://registry.npmjs.org/babel-plugin-transform-es2015-arrow-functions/-/babel-plugin-transform-es2015-arrow-functions-6.22.0.tgz\",\n}\n},\n\"react-native-tab-view\": {\n- \"version\": \"0.0.67\",\n- \"resolved\": \"https://registry.npmjs.org/react-native-tab-view/-/react-native-tab-view-0.0.67.tgz\",\n- \"integrity\": \"sha1-zdFG/l5dS6/2yJ8tXQsV+iPbOdA=\",\n+ \"version\": \"0.0.69\",\n+ \"resolved\": \"https://registry.npmjs.org/react-native-tab-view/-/react-native-tab-view-0.0.69.tgz\",\n+ \"integrity\": \"sha512-0K1wr40cDN90vZWZl3BfwYnUDb2mfRqFHIqkIsJCOlgu6t3vU9/I/afu/whpB3chKgumB925g5qBeC/OdGAODA==\",\n\"requires\": {\n\"prop-types\": \"15.5.10\"\n}\n}\n},\n\"react-navigation\": {\n- \"version\": \"1.0.0-beta.12\",\n- \"resolved\": \"https://registry.npmjs.org/react-navigation/-/react-navigation-1.0.0-beta.12.tgz\",\n- \"integrity\": \"sha1-zw8E/7+f7+QfXFodq5IQa0iinwo=\",\n+ \"version\": \"git+https://git@github.com/ashoat/react-navigation.git#3c544382c993244bd7eb88c73233bb30895bd71e\",\n\"requires\": {\n+ \"babel-plugin-transform-define\": \"1.3.0\",\n\"clamp\": \"1.0.1\",\n\"hoist-non-react-statics\": \"2.3.1\",\n\"path-to-regexp\": \"1.7.0\",\n\"prop-types\": \"15.5.10\",\n\"react-native-drawer-layout-polyfill\": \"1.3.2\",\n- \"react-native-tab-view\": \"0.0.67\"\n+ \"react-native-tab-view\": \"0.0.69\"\n}\n},\n\"react-proxy\": {\n\"integrity\": \"sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o=\",\n\"dev\": true\n},\n+ \"traverse\": {\n+ \"version\": \"0.6.6\",\n+ \"resolved\": \"https://registry.npmjs.org/traverse/-/traverse-0.6.6.tgz\",\n+ \"integrity\": \"sha1-y99WD9e5r2MlAv7UD5GMFX6pcTc=\"\n+ },\n\"trim-newlines\": {\n\"version\": \"1.0.0\",\n\"resolved\": \"https://registry.npmjs.org/trim-newlines/-/trim-newlines-1.0.0.tgz\",\n"
},
{
"change_type": "MODIFY",
"old_path": "native/package.json",
"new_path": "native/package.json",
"diff": "\"react-native-onepassword\": \"^1.0.4\",\n\"react-native-segmented-control-tab\": \"git+https://github.com/ashoat/react-native-segmented-control-tab.git\",\n\"react-native-vector-icons\": \"^4.3.0\",\n- \"react-navigation\": \"^1.0.0-beta.12\",\n+ \"react-navigation\": \"git+https://git@github.com/ashoat/react-navigation.git#fixflow\",\n\"react-redux\": \"^5.0.6\",\n\"redux\": \"^3.7.2\",\n\"redux-devtools-extension\": \"^2.13.2\",\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Fix react-navigation Flow types |
129,187 | 20.09.2017 15:10:31 | 14,400 | c7136910d8e02187e0487fb4d3da0719607c049e | Fix types with my newly typed React Navigation PR! | [
{
"change_type": "MODIFY",
"old_path": "lib/types/redux-types.js",
"new_path": "lib/types/redux-types.js",
"diff": "@@ -405,4 +405,4 @@ export type PromisedAction = (dispatch: Dispatch) => Promise<void>;\nexport type Dispatch =\n((promisedAction: PromisedAction) => Promise<void>) &\n((thunkedAction: ThunkedAction) => void) &\n- ((action: SuperAction) => void);\n+ ((action: SuperAction) => bool);\n"
},
{
"change_type": "MODIFY",
"old_path": "native/account/logged-out-modal.react.js",
"new_path": "native/account/logged-out-modal.react.js",
"diff": "@@ -4,7 +4,7 @@ import type {\nNavigationScreenProp,\nNavigationRoute,\nNavigationAction,\n-} from 'react-navigation';\n+} from 'react-navigation/src/TypeDefinition';\nimport type {\nDispatchActionPayload,\nDispatchActionPromise,\n"
},
{
"change_type": "MODIFY",
"old_path": "native/account/verification-modal.react.js",
"new_path": "native/account/verification-modal.react.js",
"diff": "// @flow\n-import type { NavigationScreenProp } from 'react-navigation';\n+import type {\n+ NavigationScreenProp,\n+ NavigationLeafRoute,\n+} from 'react-navigation/src/TypeDefinition';\nimport type { AppState } from '../redux-setup';\nimport type { HandleVerificationCodeResult } from 'lib/actions/user-actions';\nimport type {\n@@ -48,11 +51,9 @@ import ResetPasswordPanel from './reset-password-panel.react';\nimport { createIsForegroundSelector } from '../selectors/nav-selectors';\ntype VerificationModalMode = \"simple-text\" | \"reset-password\";\n-type VerificationModalNavProps = {\n- verifyCode: string,\n-};\ntype Props = {\n- navigation: NavigationScreenProp<VerificationModalNavProps, *>,\n+ navigation: NavigationScreenProp<NavigationLeafRoute, *>\n+ & { state: { params: { verifyCode: string } } },\n// Redux state\nisForeground: bool,\n// Redux dispatch functions\n"
},
{
"change_type": "MODIFY",
"old_path": "native/app.react.js",
"new_path": "native/app.react.js",
"diff": "// @flow\n-import type { NavigationState } from 'react-navigation';\n+import type {\n+ NavigationState,\n+ NavigationAction,\n+} from 'react-navigation/src/TypeDefinition';\nimport type { Dispatch } from 'lib/types/redux-types';\nimport type { AppState } from './redux-setup';\nimport type { Action } from './navigation-setup';\n@@ -69,6 +72,8 @@ registerConfig({\n// app is active and the user is logged in.\nconst pingFrequency = 3 * 1000;\n+type NativeDispatch = Dispatch & ((action: NavigationAction) => boolean);\n+\nclass AppWithNavigationState extends React.PureComponent {\nprops: {\n@@ -78,7 +83,7 @@ class AppWithNavigationState extends React.PureComponent {\npingStartingPayload: () => PingStartingPayload,\ncurrentAsOf: number,\n// Redux dispatch functions\n- dispatch: Dispatch,\n+ dispatch: NativeDispatch,\ndispatchActionPayload: DispatchActionPayload,\ndispatchActionPromise: DispatchActionPromise,\n// async functions that hit server APIs\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/add-thread-button.react.js",
"new_path": "native/chat/add-thread-button.react.js",
"diff": "// @flow\n-import type { NavigationParams } from 'react-navigation';\n+import type { NavigationParams } from 'react-navigation/src/TypeDefinition';\nimport React from 'react';\nimport { Platform, StyleSheet } from 'react-native';\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/add-thread.react.js",
"new_path": "native/chat/add-thread.react.js",
"diff": "@@ -4,7 +4,7 @@ import type {\nNavigationScreenProp,\nNavigationRoute,\nNavigationAction,\n-} from 'react-navigation';\n+} from 'react-navigation/src/TypeDefinition';\nimport type { AppState } from '../redux-setup';\nimport type { LoadingStatus } from 'lib/types/loading-types';\nimport type { ThreadInfo, VisibilityRules } from 'lib/types/thread-types';\n@@ -57,7 +57,8 @@ import UserList from '../components/user-list.react';\nimport LinkButton from '../components/link-button.react';\nimport { MessageListRouteName } from './message-list.react';\n-type NavProp = NavigationScreenProp<NavigationRoute, NavigationAction>;\n+type NavProp = NavigationScreenProp<NavigationRoute, NavigationAction>\n+ & { state: { params: { parentThreadID: ?string } } };\nconst segmentedPrivacyOptions = ['Public', 'Secret'];\ntype Props = {\n@@ -621,8 +622,16 @@ const AddThread = connect(\nparentThreadInfo = state.threadInfos[parentThreadID];\ninvariant(parentThreadInfo, \"parent thread should exist\");\n}\n- const secondChatRoute =\n- state.navInfo.navigationState.routes[0].routes[1].routes[1];\n+ const appNavState = state.navInfo.navigationState.routes[0];\n+ invariant(\n+ appNavState.routes &&\n+ Array.isArray(appNavState.routes) &&\n+ appNavState.routes[1] &&\n+ appNavState.routes[1].routes &&\n+ Array.isArray(appNavState.routes[1].routes),\n+ \"there's no way in Flow to type the exact shape of our navigationState\",\n+ );\n+ const secondChatRoute = appNavState.routes[1].routes[1];\nreturn {\nloadingStatus: loadingStatusSelector(state),\nparentThreadInfo,\n@@ -630,7 +639,9 @@ const AddThread = connect(\nuserInfoSelectorForOtherMembersOfThread(parentThreadID)(state),\nuserSearchIndex:\nuserSearchIndexForOtherMembersOfThread(parentThreadID)(state),\n- secondChatRouteKey: secondChatRoute && secondChatRoute.key,\n+ secondChatRouteKey: secondChatRoute && secondChatRoute.key\n+ ? secondChatRoute.key\n+ : null,\ncookie: state.cookie,\n};\n},\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/chat-thread-list.react.js",
"new_path": "native/chat/chat-thread-list.react.js",
"diff": "@@ -8,7 +8,7 @@ import type {\nNavigationScreenProp,\nNavigationRoute,\nNavigationAction,\n-} from 'react-navigation';\n+} from 'react-navigation/src/TypeDefinition';\nimport React from 'react';\nimport { View, StyleSheet, FlatList } from 'react-native';\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/chat.react.js",
"new_path": "native/chat/chat.react.js",
"diff": "@@ -12,12 +12,14 @@ import {\nimport { MessageList, MessageListRouteName } from './message-list.react';\nimport { AddThread, AddThreadRouteName } from './add-thread.react';\n-const Chat = StackNavigator({\n+const Chat = StackNavigator(\n+ {\n[ChatThreadListRouteName]: { screen: ChatThreadList },\n[MessageListRouteName]: { screen: MessageList },\n[AddThreadRouteName]: { screen: AddThread },\n-});\n-Chat.navigationOptions = {\n+ },\n+ {\n+ navigationOptions: {\ntabBarLabel: 'Chat',\ntabBarIcon: ({ tintColor }) => (\n<Icon\n@@ -25,7 +27,9 @@ Chat.navigationOptions = {\nstyle={[styles.icon, { color: tintColor }]}\n/>\n),\n-};\n+ },\n+ },\n+);\nconst styles = StyleSheet.create({\nicon: {\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/message-list.react.js",
"new_path": "native/chat/message-list.react.js",
"diff": "@@ -5,7 +5,8 @@ import type {\nNavigationScreenProp,\nNavigationRoute,\nNavigationAction,\n-} from 'react-navigation';\n+} from 'react-navigation/src/TypeDefinition';\n+import type { ThreadInfo } from 'lib/types/thread-types';\nimport { threadInfoPropType } from 'lib/types/thread-types';\nimport type {\nChatMessageItem,\n@@ -56,7 +57,8 @@ import InputBar from './input-bar.react';\nimport ListLoadingIndicator from '../list-loading-indicator.react';\nimport AddThreadButton from './add-thread-button.react';\n-type NavProp = NavigationScreenProp<NavigationRoute, NavigationAction>;\n+type NavProp = NavigationScreenProp<NavigationRoute, NavigationAction>\n+ & { state: { params: { threadInfo: ThreadInfo } } };\nexport type ChatMessageInfoItemWithHeight = {|\nitemType: \"message\",\n"
},
{
"change_type": "MODIFY",
"old_path": "native/more/more.react.js",
"new_path": "native/more/more.react.js",
"diff": "// @flow\n-import type { NavigationScreenProp } from 'react-navigation';\n+import type { NavigationScreenProp } from 'react-navigation/src/TypeDefinition';\nimport type { DispatchActionPromise } from 'lib/utils/action-utils';\nimport type { AppState } from '../redux-setup';\nimport type { ThreadInfo } from 'lib/types/thread-types';\n"
},
{
"change_type": "MODIFY",
"old_path": "native/navigation-setup.js",
"new_path": "native/navigation-setup.js",
"diff": "@@ -6,10 +6,9 @@ import type { ThreadInfo } from 'lib/types/thread-types';\nimport type {\nNavigationState,\nNavigationScreenProp,\n- NavigationRoute,\nNavigationAction,\nNavigationRouter,\n-} from 'react-navigation';\n+} from 'react-navigation/src/TypeDefinition';\nimport type { PingSuccessPayload } from 'lib/types/ping-types';\nimport type { AppState } from './redux-setup';\nimport type { SetCookiePayload } from 'lib/utils/action-utils';\n@@ -52,6 +51,7 @@ export type NavInfo = {|\n|};\nexport type Action = BaseAction |\n+ NavigationAction |\n{| type: \"HANDLE_URL\", payload: string |} |\n{| type: \"NAVIGATE_TO_APP\", payload: null |} |\n{|\n@@ -72,7 +72,7 @@ const AppNavigator = TabNavigator(\n},\n);\ntype WrappedAppNavigatorProps = {|\n- navigation: NavigationScreenProp<NavigationRoute, NavigationAction>,\n+ navigation: NavigationScreenProp<*, NavigationAction>,\nisForeground: bool,\natInitialRoute: bool,\n|};\n@@ -124,10 +124,17 @@ class WrappedAppNavigator extends React.PureComponent {\n}\nconst AppRouteName = 'App';\nconst isForegroundSelector = createIsForegroundSelector(AppRouteName);\n-const ReduxWrappedAppNavigator = connect((state: AppState) => ({\n+const ReduxWrappedAppNavigator = connect((state: AppState) => {\n+ const appNavState = state.navInfo.navigationState.routes[0];\n+ invariant(\n+ appNavState.index && typeof appNavState.index === \"number\",\n+ \"appNavState should have member index that is a number\",\n+ );\n+ return {\n+ atInitialRoute: appNavState.index === 0,\nisForeground: isForegroundSelector(state),\n- atInitialRoute: state.navInfo.navigationState.routes[0].index === 0,\n-}))(WrappedAppNavigator);\n+ };\n+})(WrappedAppNavigator);\n(ReduxWrappedAppNavigator: Object).router = AppNavigator.router;\nconst RootNavigator = StackNavigator(\n"
},
{
"change_type": "MODIFY",
"old_path": "native/package-lock.json",
"new_path": "native/package-lock.json",
"diff": "}\n},\n\"react-navigation\": {\n- \"version\": \"git+https://git@github.com/ashoat/react-navigation.git#3c544382c993244bd7eb88c73233bb30895bd71e\",\n+ \"version\": \"git+https://git@github.com/ashoat/react-navigation.git#d1c9528d2ae669979f156d28aaeae3f1d5476796\",\n\"requires\": {\n\"babel-plugin-transform-define\": \"1.3.0\",\n\"clamp\": \"1.0.1\",\n"
},
{
"change_type": "MODIFY",
"old_path": "native/redux-setup.js",
"new_path": "native/redux-setup.js",
"diff": "@@ -112,13 +112,30 @@ function reducer(state: AppState, action: Action) {\nrehydrateConcluded: true,\n};\n}\n- if (action.type === \"HANDLE_URL\" || action.type === \"NAVIGATE_TO_APP\") {\n+ // These action type are handled by reduceNavInfo above\n+ if (\n+ action.type === \"HANDLE_URL\" ||\n+ action.type === \"NAVIGATE_TO_APP\" ||\n+ action.type === \"Navigation/INIT\" ||\n+ action.type === \"Navigation/NAVIGATE\" ||\n+ action.type === \"Navigation/BACK\" ||\n+ action.type === \"Navigation/SET_PARAMS\" ||\n+ action.type === \"Navigation/RESET\"\n+ ) {\nreturn state;\n}\nif (\naction.type === \"Navigation/NAVIGATE\" &&\naction.routeName === \"MessageList\"\n) {\n+ invariant(\n+ action.params &&\n+ action.params.threadInfo &&\n+ typeof action.params.threadInfo === \"object\" &&\n+ action.params.threadInfo.id &&\n+ typeof action.params.threadInfo.id === \"string\",\n+ \"there's no way in react-navigation/Flow to type this\",\n+ );\nreturn {\nnavInfo: state.navInfo,\ncurrentUserInfo: state.currentUserInfo,\n"
},
{
"change_type": "MODIFY",
"old_path": "native/selectors/nav-selectors.js",
"new_path": "native/selectors/nav-selectors.js",
"diff": "// @flow\nimport type { AppState } from '../redux-setup';\n-import type { NavigationState } from 'react-navigation';\n+import type { NavigationState } from 'react-navigation/src/TypeDefinition';\nimport { createSelector } from 'reselect';\n+import invariant from 'invariant';\nimport { AppRouteName } from '../navigation-setup';\nimport { ChatRouteName } from '../chat/chat.react';\n@@ -22,6 +23,18 @@ const createActiveTabSelector = (routeName: string) => createSelector(\nif (innerState.routeName !== AppRouteName) {\nreturn false;\n}\n+ // We know that if the routeName is AppRouteName, then the NavigationRoute\n+ // is a NavigationStateRoute\n+ invariant(\n+ innerState.routes &&\n+ Array.isArray(innerState.routes) &&\n+ innerState.index &&\n+ typeof innerState.index === \"number\" &&\n+ innerState.routes[innerState.index] &&\n+ innerState.routes[innerState.index].routeName &&\n+ typeof innerState.routes[innerState.index].routeName === \"string\",\n+ \"route with AppRouteName should be NavigationStateRoute\",\n+ );\nreturn innerState.routes[innerState.index].routeName === routeName;\n},\n);\n@@ -33,14 +46,49 @@ const activeThreadSelector = createSelector(\nif (innerState.routeName !== AppRouteName) {\nreturn null;\n}\n+ // We know that if the routeName is AppRouteName, then the NavigationRoute\n+ // is a NavigationStateRoute\n+ invariant(\n+ innerState.routes &&\n+ Array.isArray(innerState.routes) &&\n+ innerState.index &&\n+ typeof innerState.index === \"number\" &&\n+ innerState.routes[innerState.index] &&\n+ innerState.routes[innerState.index].routeName &&\n+ typeof innerState.routes[innerState.index].routeName === \"string\",\n+ \"route with AppRouteName should be NavigationStateRoute\",\n+ );\nconst innerInnerState = innerState.routes[innerState.index];\nif (innerInnerState.routeName !== ChatRouteName) {\nreturn null;\n}\n+ // We know that if the routeName is ChatRouteName, then the NavigationRoute\n+ // is a NavigationStateRoute\n+ invariant(\n+ innerInnerState.routes &&\n+ Array.isArray(innerInnerState.routes) &&\n+ innerInnerState.index &&\n+ typeof innerInnerState.index === \"number\" &&\n+ innerInnerState.routes[innerInnerState.index] &&\n+ innerInnerState.routes[innerInnerState.index].routeName &&\n+ typeof innerInnerState.routes[innerInnerState.index].routeName\n+ === \"string\",\n+ \"route with ChatRouteName should be NavigationStateRoute\",\n+ );\nconst innerInnerInnerState = innerInnerState.routes[innerInnerState.index];\nif (innerInnerInnerState.routeName !== MessageListRouteName) {\nreturn null;\n}\n+ // We know that if the routeName is MessageListRouteName, then the\n+ // NavigationRoute is a NavigationLeafRoute\n+ invariant(\n+ innerInnerInnerState.params &&\n+ innerInnerInnerState.params.threadInfo &&\n+ typeof innerInnerInnerState.params.threadInfo === \"object\" &&\n+ innerInnerInnerState.params.threadInfo.id &&\n+ typeof innerInnerInnerState.params.threadInfo.id === \"string\",\n+ \"there's no way in react-navigation/Flow to type this\",\n+ );\nreturn innerInnerInnerState.params.threadInfo.id;\n},\n);\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Fix types with my newly typed React Navigation PR! |
129,187 | 20.09.2017 19:08:28 | 14,400 | 20006e34db903b3fa6dba4ae55981c50799f4b4e | Forgot that zero is falsey... ugh... | [
{
"change_type": "MODIFY",
"old_path": "native/navigation-setup.js",
"new_path": "native/navigation-setup.js",
"diff": "@@ -127,7 +127,9 @@ const isForegroundSelector = createIsForegroundSelector(AppRouteName);\nconst ReduxWrappedAppNavigator = connect((state: AppState) => {\nconst appNavState = state.navInfo.navigationState.routes[0];\ninvariant(\n- appNavState.index && typeof appNavState.index === \"number\",\n+ appNavState.index !== undefined &&\n+ appNavState.index !== null &&\n+ typeof appNavState.index === \"number\",\n\"appNavState should have member index that is a number\",\n);\nreturn {\n"
},
{
"change_type": "MODIFY",
"old_path": "native/selectors/nav-selectors.js",
"new_path": "native/selectors/nav-selectors.js",
"diff": "@@ -28,7 +28,8 @@ const createActiveTabSelector = (routeName: string) => createSelector(\ninvariant(\ninnerState.routes &&\nArray.isArray(innerState.routes) &&\n- innerState.index &&\n+ innerState.index !== undefined &&\n+ innerState.index !== null &&\ntypeof innerState.index === \"number\" &&\ninnerState.routes[innerState.index] &&\ninnerState.routes[innerState.index].routeName &&\n@@ -51,7 +52,8 @@ const activeThreadSelector = createSelector(\ninvariant(\ninnerState.routes &&\nArray.isArray(innerState.routes) &&\n- innerState.index &&\n+ innerState.index !== undefined &&\n+ innerState.index !== null &&\ntypeof innerState.index === \"number\" &&\ninnerState.routes[innerState.index] &&\ninnerState.routes[innerState.index].routeName &&\n@@ -67,7 +69,8 @@ const activeThreadSelector = createSelector(\ninvariant(\ninnerInnerState.routes &&\nArray.isArray(innerInnerState.routes) &&\n- innerInnerState.index &&\n+ innerInnerState.index !== undefined &&\n+ innerInnerState.index !== null &&\ntypeof innerInnerState.index === \"number\" &&\ninnerInnerState.routes[innerInnerState.index] &&\ninnerInnerState.routes[innerInnerState.index].routeName &&\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Forgot that zero is falsey... ugh... |
129,187 | 20.09.2017 19:32:24 | 14,400 | cae003d1270b45eafe6d2f12643768d861da6726 | Some bugfixes and refinements for the thread creation message payload | [
{
"change_type": "MODIFY",
"old_path": "lib/shared/message-utils.js",
"new_path": "lib/shared/message-utils.js",
"diff": "@@ -29,6 +29,19 @@ function messageID(messageInfo: MessageInfo | RawMessageInfo): string {\nreturn messageInfo.localID;\n}\n+function usernameString(usernames: string[]): string {\n+ if (usernames.length === 1) {\n+ return usernames[0];\n+ } else if (usernames.length === 2) {\n+ return `${usernames[0]} and ${usernames[1]}`;\n+ } else if (usernames.length === 3) {\n+ return `${usernames[0]}, ${usernames[1]}, and ${usernames[2]}`;\n+ } else {\n+ return `${usernames[0]}, ${usernames[1]}, ` +\n+ `and ${usernames.length - 2} others`;\n+ }\n+}\n+\nfunction robotextForMessageInfo(\nmessageInfo: RobotextMessageInfo,\n): [string, string] {\n@@ -45,22 +58,18 @@ function robotextForMessageInfo(\ncreator = \"anonymous\";\n}\nif (messageInfo.type === messageType.CREATE_THREAD) {\n- return [creator, \"created the thread\"];\n+ let text = \"created the thread with the name \" +\n+ `\"${messageInfo.initialThreadState.name}\"`;\n+ const usernames = messageInfo.initialThreadState.otherMemberUsernames;\n+ if (usernames.length !== 0) {\n+ const initialUsersString = usernameString(usernames);\n+ text += ` and added ${initialUsersString}`;\n+ }\n+ return [creator, text];\n} else if (messageInfo.type === messageType.ADD_USER) {\nconst usernames = messageInfo.addedUsernames;\ninvariant(usernames.length !== 0, \"added who??\");\n- let addedUsersString;\n- if (usernames.length === 1) {\n- addedUsersString = usernames[0];\n- } else if (usernames.length === 2) {\n- addedUsersString = `${usernames[0]} and ${usernames[1]}`;\n- } else if (usernames.length === 3) {\n- addedUsersString =\n- `${usernames[0]}, ${usernames[1]}, and ${usernames[2]}`;\n- } else {\n- addedUsersString = `${usernames[0]}, ${usernames[1]}, ` +\n- `and ${usernames.length - 2} others`;\n- }\n+ const addedUsersString = usernameString(usernames);\nreturn [creator, `added ${addedUsersString}`];\n}\ninvariant(false, `${messageInfo.type} is not a messageType!`);\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/types/message-types.js",
"new_path": "lib/types/message-types.js",
"diff": "@@ -78,7 +78,7 @@ type InitialThreadState = {|\nparentThreadInfo: ?ThreadInfo,\nvisibilityRules: VisibilityRules,\ncolor: string,\n- memberIDs: string[],\n+ otherMemberUsernames: string[],\n|};\nexport type RobotextMessageInfo = {|\ntype: 1,\n"
},
{
"change_type": "MODIFY",
"old_path": "native/selectors/chat-selectors.js",
"new_path": "native/selectors/chat-selectors.js",
"diff": "@@ -65,7 +65,11 @@ function createMessageInfo(\n: null,\nvisibilityRules: rawMessageInfo.initialThreadState.visibilityRules,\ncolor: rawMessageInfo.initialThreadState.color,\n- memberIDs: rawMessageInfo.initialThreadState.memberIDs,\n+ otherMemberUsernames: rawMessageInfo.initialThreadState.memberIDs\n+ .filter(\n+ (userID: string) => userID !== rawMessageInfo.creatorID\n+ && !!userInfos[userID],\n+ ).map((userID: string) => userInfos[userID].username),\n},\n};\n} else if (rawMessageInfo.type === messageType.ADD_USER) {\n"
},
{
"change_type": "MODIFY",
"old_path": "server/new_thread.php",
"new_path": "server/new_thread.php",
"diff": "@@ -113,17 +113,18 @@ $initial_member_ids = isset($_POST['initial_member_ids'])\n$conn->query(\"INSERT INTO ids(table_name) VALUES('messages')\");\n$message_id = $conn->insert_id;\n$message_type_create_thread = MESSAGE_TYPE_CREATE_THREAD;\n-$payload = json_encode(array(\n+$payload = array(\n\"name\" => $name,\n\"parentThreadID\" => $parent_thread_id ? (string)$parent_thread_id : null,\n\"visibilityRules\" => $vis_rules,\n\"color\" => $color,\n\"memberIDs\" => array_map(\"strval\", $initial_member_ids),\n-));\n+);\n+$encoded_payload = json_encode($payload);\n$message_insert_query = <<<SQL\nINSERT INTO messages(id, thread, user, type, content, time)\nVALUES ({$message_id}, {$id}, {$creator},\n- {$message_type_create_thread}, '{$payload}', {$time})\n+ {$message_type_create_thread}, '{$encoded_payload}', {$time})\nSQL;\n$conn->query($message_insert_query);\n@@ -185,5 +186,6 @@ async_end(array(\n'threadID' => (string)$id,\n'creatorID' => (string)$creator,\n'time' => $time,\n+ 'initialThreadState' => $payload,\n),\n));\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Some bugfixes and refinements for the thread creation message payload |
129,187 | 20.09.2017 20:20:06 | 14,400 | 2d32aaa4e0336e896c67f62f53db51fb2b4d7cd3 | Wrap AddThread in KeyboardAvoidingView on iOS | [
{
"change_type": "MODIFY",
"old_path": "native/chat/add-thread.react.js",
"new_path": "native/chat/add-thread.react.js",
"diff": "@@ -25,6 +25,8 @@ import {\nAlert,\nTouchableWithoutFeedback,\nTouchableHighlight,\n+ KeyboardAvoidingView,\n+ Platform,\n} from 'react-native';\nimport { connect } from 'react-redux';\nimport SegmentedControlTab from 'react-native-segmented-control-tab';\n@@ -293,8 +295,8 @@ class InnerAddThread extends React.PureComponent {\nconst colorSplotchStyle = {\nbackgroundColor: `#${this.state.color}`,\n};\n- return (\n- <View style={styles.container}>\n+ const content = (\n+ <View style={styles.content}>\n<View style={styles.row}>\n<Text style={styles.label}>Name</Text>\n<View style={styles.input}>\n@@ -346,6 +348,17 @@ class InnerAddThread extends React.PureComponent {\n{colorPicker}\n</View>\n);\n+ if (Platform.OS === \"ios\") {\n+ return (\n+ <KeyboardAvoidingView\n+ style={styles.container}\n+ behavior=\"padding\"\n+ keyboardVerticalOffset={65}\n+ >{content}</KeyboardAvoidingView>\n+ );\n+ } else {\n+ return <View style={styles.container}>{content}</View>;\n+ }\n}\nnameInputRef = (nameInput: ?TextInput) => {\n@@ -512,6 +525,9 @@ const styles = StyleSheet.create({\nflex: 1,\nbackgroundColor: '#FFFFFF',\n},\n+ content: {\n+ flex: 1,\n+ },\nrow: {\nflexDirection: 'row',\nmarginBottom: 10,\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Wrap AddThread in KeyboardAvoidingView on iOS |
129,187 | 20.09.2017 20:47:33 | 14,400 | ec8363961c3266264741eb93f971552d820d2303 | Make sure message preview and thread name don't overflow over the color splotch and the last message time in ChatThreadListItem | [
{
"change_type": "MODIFY",
"old_path": "native/chat/chat-thread-list-item.react.js",
"new_path": "native/chat/chat-thread-list-item.react.js",
"diff": "@@ -78,6 +78,7 @@ const styles = StyleSheet.create({\njustifyContent: 'space-between',\n},\nthreadName: {\n+ flex: 1,\npaddingLeft: 10,\nfontSize: 20,\ncolor: '#333333',\n@@ -88,8 +89,10 @@ const styles = StyleSheet.create({\nmarginTop: 2,\njustifyContent: 'flex-end',\nborderRadius: 5,\n+ marginLeft: 10,\n},\nnoMessages: {\n+ flex: 1,\npaddingLeft: 10,\nfontStyle: 'italic',\nfontSize: 16,\n@@ -98,6 +101,7 @@ const styles = StyleSheet.create({\nlastActivity: {\nfontSize: 16,\ncolor: '#666666',\n+ marginLeft: 10,\n},\n});\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/message-preview.react.js",
"new_path": "native/chat/message-preview.react.js",
"diff": "@@ -47,6 +47,7 @@ class MessagePreview extends React.PureComponent {\nconst styles = StyleSheet.create({\nlastMessage: {\n+ flex: 1,\npaddingLeft: 10,\nfontSize: 16,\ncolor: '#666666',\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Make sure message preview and thread name don't overflow over the color splotch and the last message time in ChatThreadListItem |
129,187 | 21.09.2017 12:43:49 | 14,400 | d8faaad5fa9a396721093805f128b2194246e9d0 | Only show subthread messages if the viewer can see the subthread | [
{
"change_type": "MODIFY",
"old_path": "server/message_lib.php",
"new_path": "server/message_lib.php",
"diff": "@@ -105,7 +105,10 @@ SQL;\n'id' => $row['creatorID'],\n'username' => $row['creator'],\n);\n- $messages[] = message_from_row($row);\n+ $message = message_from_row($row);\n+ if ($message) {\n+ $messages[] = $message;\n+ }\nif (!isset($thread_to_message_count[$row['threadID']])) {\n$thread_to_message_count[$row['threadID']] = 1;\n} else {\n@@ -194,7 +197,10 @@ SQL;\n'id' => $row['creatorID'],\n'username' => $row['creator'],\n);\n- $messages[] = message_from_row($row);\n+ $message = message_from_row($row);\n+ if ($message) {\n+ $messages[] = $message;\n+ }\n} else if ($num_for_thread === $max_number_per_thread + 1) {\n$truncation_status[$thread] = TRUNCATION_TRUNCATED;\n}\n@@ -221,7 +227,11 @@ function message_from_row($row) {\n} else if ($type === MESSAGE_TYPE_ADD_USERS) {\n$message['addedUserIDs'] = json_decode($row['content']);\n} else if ($type === MESSAGE_TYPE_CREATE_SUB_THREAD) {\n- $message['childThreadID'] = $row['content'];\n+ $child_thread_id = $row['content'];\n+ if (!viewer_can_see_thread($child_thread_id)) {\n+ return null;\n+ }\n+ $message['childThreadID'] = $child_thread_id;\n}\nreturn $message;\n}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Only show subthread messages if the viewer can see the subthread |
129,187 | 21.09.2017 12:47:47 | 14,400 | d7868bc31d1b5acccf2caf5bc0f948a6f9117954 | Include userInfos for initialThreadState.memberIDs in MESSAGE_TYPE_CREATE_THREAD | [
{
"change_type": "MODIFY",
"old_path": "server/message_lib.php",
"new_path": "server/message_lib.php",
"diff": "@@ -241,10 +241,13 @@ function get_all_users($messages, $users) {\n$all_added_user_ids = array();\nforeach ($messages as $message) {\n- if ($message['type'] !== MESSAGE_TYPE_ADD_USERS) {\n- continue;\n+ $new_users = array();\n+ if ($message['type'] === MESSAGE_TYPE_ADD_USERS) {\n+ $new_users = $message['addedUserIDs'];\n+ } else if ($message['type'] === MESSAGE_TYPE_CREATE_THREAD) {\n+ $new_users = $message['initialThreadState']['memberIDs'];\n}\n- foreach ($message['addedUserIDs'] as $user_id) {\n+ foreach ($new_users as $user_id) {\nif (!isset($users[$user_id])) {\n$all_added_user_ids[] = $user_id;\n}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Include userInfos for initialThreadState.memberIDs in MESSAGE_TYPE_CREATE_THREAD |
129,187 | 26.09.2017 20:15:27 | 14,400 | 9b975afa853b309a9ca43de6b46a6ae65be915c1 | Use react-navigation master now that my Flow PR has been accepted | [
{
"change_type": "MODIFY",
"old_path": "native/package-lock.json",
"new_path": "native/package-lock.json",
"diff": "}\n},\n\"react-navigation\": {\n- \"version\": \"git+https://git@github.com/ashoat/react-navigation.git#d1c9528d2ae669979f156d28aaeae3f1d5476796\",\n+ \"version\": \"git+https://git@github.com/react-community/react-navigation.git#69397af74d3f36715b6e1a8fbc30a0bfd9c75778\",\n\"requires\": {\n\"babel-plugin-transform-define\": \"1.3.0\",\n\"clamp\": \"1.0.1\",\n"
},
{
"change_type": "MODIFY",
"old_path": "native/package.json",
"new_path": "native/package.json",
"diff": "\"react-native-onepassword\": \"^1.0.4\",\n\"react-native-segmented-control-tab\": \"git+https://github.com/ashoat/react-native-segmented-control-tab.git\",\n\"react-native-vector-icons\": \"^4.3.0\",\n- \"react-navigation\": \"git+https://git@github.com/ashoat/react-navigation.git#fixflow\",\n+ \"react-navigation\": \"git+https://git@github.com/react-community/react-navigation.git\",\n\"react-redux\": \"^5.0.6\",\n\"redux\": \"^3.7.2\",\n\"redux-devtools-extension\": \"^2.13.2\",\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Use react-navigation master now that my Flow PR has been accepted |
129,187 | 26.09.2017 20:24:39 | 14,400 | 8ab92447913cb3db069b95e13324e175d05d707b | Use associative array version of json_decode | [
{
"change_type": "MODIFY",
"old_path": "server/message_lib.php",
"new_path": "server/message_lib.php",
"diff": "@@ -223,9 +223,9 @@ function message_from_row($row) {\nif ($type === MESSAGE_TYPE_TEXT) {\n$message['text'] = $row['content'];\n} else if ($type === MESSAGE_TYPE_CREATE_THREAD) {\n- $message['initialThreadState'] = json_decode($row['content']);\n+ $message['initialThreadState'] = json_decode($row['content'], true);\n} else if ($type === MESSAGE_TYPE_ADD_USERS) {\n- $message['addedUserIDs'] = json_decode($row['content']);\n+ $message['addedUserIDs'] = json_decode($row['content'], true);\n} else if ($type === MESSAGE_TYPE_CREATE_SUB_THREAD) {\n$child_thread_id = $row['content'];\nif (!viewer_can_see_thread($child_thread_id)) {\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Use associative array version of json_decode |
129,187 | 27.09.2017 11:48:55 | 14,400 | 9d0e3601907c72987b45bcdf9327119a50f21076 | Refactor props on Button | [
{
"change_type": "MODIFY",
"old_path": "native/calendar/entry.react.js",
"new_path": "native/calendar/entry.react.js",
"diff": "@@ -207,8 +207,11 @@ class Entry extends React.Component {\n<View style={styles.actionLinks}>\n<View style={styles.leftLinks}>\n<Button\n- onSubmit={this.onPressDelete}\n- underlayColor={actionLinksUnderlayColor}\n+ onPress={this.onPressDelete}\n+ androidBorderlessRipple={true}\n+ iosFormat=\"highlight\"\n+ iosHighlightUnderlayColor={actionLinksUnderlayColor}\n+ iosActiveOpacity={0.85}\nstyle={styles.deleteButton}\n>\n<View style={styles.deleteButtonContents}>\n"
},
{
"change_type": "MODIFY",
"old_path": "native/calendar/section-footer.react.js",
"new_path": "native/calendar/section-footer.react.js",
"diff": "@@ -25,7 +25,13 @@ class SectionFooter extends React.PureComponent {\nrender() {\nreturn (\n<View style={styles.sectionFooter}>\n- <Button onSubmit={this.onSubmit} style={styles.addButton}>\n+ <Button\n+ onPress={this.onSubmit}\n+ androidBorderlessRipple={true}\n+ iosFormat=\"highlight\"\n+ iosActiveOpacity={0.85}\n+ style={styles.addButton}\n+ >\n<View style={styles.addButtonContents}>\n<Icon name=\"plus\" style={styles.addIcon} />\n<Text style={styles.actionLinksText}>Add</Text>\n"
},
{
"change_type": "MODIFY",
"old_path": "native/calendar/thread-picker-thread.react.js",
"new_path": "native/calendar/thread-picker-thread.react.js",
"diff": "@@ -29,7 +29,12 @@ class ThreadPickerThread extends React.PureComponent {\nbackgroundColor: `#${this.props.threadInfo.color}`,\n};\nreturn (\n- <Button onSubmit={this.onPress}>\n+ <Button\n+ onPress={this.onPress}\n+ androidBorderlessRipple={true}\n+ iosFormat=\"highlight\"\n+ iosActiveOpacity={0.85}\n+ >\n<View style={styles.container}>\n<View style={[styles.colorSplotch, colorSplotchStyle]} />\n<Text style={styles.text}>{this.props.threadInfo.name}</Text>\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/add-thread-button.react.js",
"new_path": "native/chat/add-thread-button.react.js",
"diff": "@@ -46,7 +46,11 @@ class AddThreadButton extends React.PureComponent {\n);\n}\nreturn (\n- <Button onSubmit={this.onPress} defaultFormat=\"opacity\">\n+ <Button\n+ onPress={this.onPress}\n+ androidBorderlessRipple={true}\n+ iosActiveOpacity={0.85}\n+ >\n{icon}\n</Button>\n);\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": "@@ -42,7 +42,13 @@ class ChatThreadListItem extends React.PureComponent {\n};\nconst lastActivity = shortAbsoluteDate(this.props.data.lastUpdatedTime);\nreturn (\n- <Button onSubmit={this.onPress} underlayColor=\"#DDDDDDDD\">\n+ <Button\n+ onPress={this.onPress}\n+ androidBorderlessRipple={true}\n+ iosFormat=\"highlight\"\n+ iosHighlightUnderlayColor=\"#DDDDDDDD\"\n+ iosActiveOpacity={0.85}\n+ >\n<View style={styles.container}>\n<View style={styles.row}>\n<Text style={styles.threadName} numberOfLines={1}>\n"
},
{
"change_type": "MODIFY",
"old_path": "native/components/button.react.js",
"new_path": "native/components/button.react.js",
"diff": "@@ -15,48 +15,54 @@ import {\n} from 'react-native';\nimport PropTypes from 'prop-types';\n+const ANDROID_VERSION_LOLLIPOP = 21;\n+\nclass Button extends React.PureComponent {\nprops: {\n- onSubmit: () => void,\n+ onPress: () => void,\ndisabled?: bool,\nstyle?: StyleObj,\n// style and topStyle just get merged in most cases. The separation only\n- // matters in the case of iOS and defaultFormat = \"highlight\", where the\n+ // matters in the case of iOS and iosFormat = \"highlight\", where the\n// topStyle is necessary for layout, and the bottom style is necessary for\n// colors etc.\ntopStyle?: StyleObj,\n- underlayColor?: string,\nchildren?: React.Element<any>,\n- defaultFormat: \"highlight\" | \"opacity\",\nandroidBorderlessRipple: bool,\n+ iosFormat: \"highlight\" | \"opacity\",\n+ iosHighlightUnderlayColor: string,\niosActiveOpacity: number,\n};\nstatic propTypes = {\n- onSubmit: PropTypes.func.isRequired,\n+ onPress: PropTypes.func.isRequired,\ndisabled: PropTypes.bool,\nstyle: ViewPropTypes.style,\ntopStyle: ViewPropTypes.style,\n- underlayColor: PropTypes.string,\nchildren: PropTypes.object,\n- defaultFormat: PropTypes.oneOf([\n+ androidBorderlessRipple: PropTypes.bool,\n+ iosFormat: PropTypes.oneOf([\n\"highlight\",\n\"opacity\",\n]),\n- androidBorderlessRipple: PropTypes.bool,\n+ iosHighlightUnderlayColor: PropTypes.string,\niosActiveOpacity: PropTypes.number,\n};\nstatic defaultProps = {\n- defaultFormat: \"highlight\",\n- androidBorderlessRipple: true,\n- iosActiveOpacity: 0.85,\n+ androidBorderlessRipple: false,\n+ iosFormat: \"opacity\",\n+ iosHighlightUnderlayColor: \"#CCCCCCDD\",\n+ iosActiveOpacity: 0.2,\n};\nrender() {\n- if (Platform.OS === \"android\") {\n+ if (\n+ Platform.OS === \"android\" &&\n+ Platform.Version >= ANDROID_VERSION_LOLLIPOP\n+ ) {\nreturn (\n<TouchableNativeFeedback\n- onPress={this.props.onSubmit}\n+ onPress={this.props.onPress}\ndisabled={!!this.props.disabled}\nbackground={TouchableNativeFeedback.Ripple(\n'rgba(0, 0, 0, .32)',\n@@ -68,14 +74,12 @@ class Button extends React.PureComponent {\n</View>\n</TouchableNativeFeedback>\n);\n- } else if (this.props.defaultFormat === \"highlight\") {\n- const underlayColor = this.props.underlayColor\n- ? this.props.underlayColor\n- : \"#CCCCCCDD\";\n+ } else if (this.props.iosFormat === \"highlight\") {\n+ const underlayColor = this.props.iosHighlightUnderlayColor;\nconst child = this.props.children ? this.props.children : <View />;\nreturn (\n<TouchableHighlight\n- onPress={this.props.onSubmit}\n+ onPress={this.props.onPress}\nstyle={this.props.topStyle}\nunderlayColor={underlayColor}\nactiveOpacity={this.props.iosActiveOpacity}\n@@ -89,7 +93,7 @@ class Button extends React.PureComponent {\n} else {\nreturn (\n<TouchableOpacity\n- onPress={this.props.onSubmit}\n+ onPress={this.props.onPress}\nstyle={[this.props.topStyle, this.props.style]}\nactiveOpacity={this.props.iosActiveOpacity}\ndisabled={!!this.props.disabled}\n"
},
{
"change_type": "MODIFY",
"old_path": "native/components/color-picker.react.js",
"new_path": "native/components/color-picker.react.js",
"diff": "@@ -377,8 +377,8 @@ class ColorPicker extends React.PureComponent {\nstyles.buttonContents,\n{ backgroundColor: oldColor },\n]}\n- onSubmit={this._onOldColorSelected}\n- androidBorderlessRipple={false}\n+ onPress={this._onOldColorSelected}\n+ iosFormat=\"highlight\"\niosActiveOpacity={0.6}\n/>\n);\n@@ -409,8 +409,8 @@ class ColorPicker extends React.PureComponent {\n<Button\nstyle={[styles.buttonContents, buttonContentsStyle]}\ntopStyle={styles.colorPreview}\n- onSubmit={this._onColorSelected}\n- androidBorderlessRipple={false}\n+ onPress={this._onColorSelected}\n+ iosFormat=\"highlight\"\niosActiveOpacity={0.6}\n>\n<Text style={[styles.buttonText, buttonTextStyle]}>\n"
},
{
"change_type": "MODIFY",
"old_path": "native/components/link-button.react.js",
"new_path": "native/components/link-button.react.js",
"diff": "@@ -26,9 +26,10 @@ class LinkButton extends React.PureComponent {\nrender() {\nreturn (\n<Button\n- onSubmit={this.props.onPress}\n+ onPress={this.props.onPress}\n+ androidBorderlessRipple={true}\n+ iosActiveOpacity={0.85}\nstyle={this.props.style}\n- defaultFormat=\"opacity\"\n>\n<Text style={styles.text}>{this.props.text}</Text>\n</Button>\n"
},
{
"change_type": "MODIFY",
"old_path": "native/components/user-list-user.react.js",
"new_path": "native/components/user-list-user.react.js",
"diff": "@@ -25,7 +25,11 @@ class UserListUser extends React.PureComponent {\nrender() {\nreturn (\n- <Button onSubmit={this.onSelect} androidBorderlessRipple={false}>\n+ <Button\n+ onPress={this.onSelect}\n+ iosFormat=\"highlight\"\n+ iosActiveOpacity={0.85}\n+ >\n<Text style={styles.text}>{this.props.userInfo.username}</Text>\n</Button>\n);\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Refactor props on Button |
129,187 | 27.09.2017 14:00:39 | 14,400 | 190431cc4bcf5d7deb75b197171164bb22ee1ed9 | Custom MessageListHeaderTitle that is clickable | [
{
"change_type": "MODIFY",
"old_path": "native/chat/add-thread-button.react.js",
"new_path": "native/chat/add-thread-button.react.js",
"diff": "@@ -46,11 +46,7 @@ class AddThreadButton extends React.PureComponent {\n);\n}\nreturn (\n- <Button\n- onPress={this.onPress}\n- androidBorderlessRipple={true}\n- iosActiveOpacity={0.85}\n- >\n+ <Button onPress={this.onPress} androidBorderlessRipple={true}>\n{icon}\n</Button>\n);\n@@ -67,7 +63,7 @@ class AddThreadButton extends React.PureComponent {\nconst styles = StyleSheet.create({\naddButton: {\n- paddingRight: 10,\n+ paddingHorizontal: 10,\n},\n});\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/chat/message-list-header-title.react.js",
"diff": "+// @flow\n+\n+import type { NavigationParams } from 'react-navigation/src/TypeDefinition';\n+import type { ThreadInfo } from 'lib/types/thread-types';\n+import { threadInfoPropType } from 'lib/types/thread-types';\n+\n+import React from 'react';\n+import { View, Text, StyleSheet, Platform } from 'react-native';\n+import PropTypes from 'prop-types';\n+import Icon from 'react-native-vector-icons/Ionicons';\n+import HeaderTitle from 'react-navigation/src/views/Header/HeaderTitle';\n+\n+import Button from '../components/button.react';\n+\n+class MessageListHeaderTitle extends React.PureComponent {\n+\n+ props: {\n+ threadInfo: ThreadInfo,\n+ navigate: (\n+ routeName: string,\n+ params?: NavigationParams,\n+ ) => boolean,\n+ sceneKey: string,\n+ onWidthChange: (key: string, width: number) => void,\n+ };\n+ static propTypes = {\n+ threadInfo: threadInfoPropType.isRequired,\n+ navigate: PropTypes.func.isRequired,\n+ sceneKey: PropTypes.string.isRequired,\n+ onWidthChange: PropTypes.func.isRequired,\n+ };\n+\n+ render() {\n+ let icon, fakeIcon;\n+ if (Platform.OS === \"ios\") {\n+ icon = (\n+ <Icon\n+ name=\"ios-arrow-forward\"\n+ size={20}\n+ style={styles.forwardIcon}\n+ color=\"#036AFF\"\n+ />\n+ );\n+ fakeIcon = (\n+ <Icon\n+ name=\"ios-arrow-forward\"\n+ size={20}\n+ style={styles.fakeIcon}\n+ />\n+ );\n+ } else {\n+ icon = (\n+ <Icon\n+ name=\"md-arrow-forward\"\n+ size={20}\n+ style={styles.forwardIcon}\n+ color=\"#0077CC\"\n+ />\n+ );\n+ }\n+ return (\n+ <Button\n+ onPress={this.onPress}\n+ style={styles.button}\n+ topStyle={styles.button}\n+ androidBorderlessRipple={true}\n+ >\n+ <View style={styles.container}>\n+ {fakeIcon}\n+ <HeaderTitle onLayout={this.onLayout}>\n+ {this.props.threadInfo.name}\n+ </HeaderTitle>\n+ {icon}\n+ </View>\n+ </Button>\n+ );\n+ }\n+\n+ onLayout = (event: { nativeEvent: { layout: { width: number } } }) => {\n+ this.props.onWidthChange(\n+ this.props.sceneKey,\n+ event.nativeEvent.layout.width,\n+ );\n+ }\n+\n+ onPress = () => {\n+ console.log('test');\n+ }\n+\n+}\n+\n+const styles = StyleSheet.create({\n+ button: {\n+ position: 'absolute',\n+ left: 0,\n+ right: 0,\n+ top: 0,\n+ bottom: 0,\n+ },\n+ container: {\n+ backgroundColor: 'transparent',\n+ position: 'absolute',\n+ left: 0,\n+ right: 0,\n+ top: 0,\n+ bottom: 0,\n+ flexDirection: 'row',\n+ alignItems: 'center',\n+ justifyContent: Platform.select({\n+ android: 'flex-start',\n+ default: 'center',\n+ }),\n+ },\n+ forwardIcon: {\n+ flex: Platform.select({\n+ android: undefined,\n+ default: 1,\n+ }),\n+ minWidth: 25,\n+ },\n+ fakeIcon: {\n+ flex: 1,\n+ minWidth: 25,\n+ opacity: 0,\n+ },\n+});\n+\n+export default MessageListHeaderTitle;\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/chat/message-list-header.react.js",
"diff": "+// @flow\n+\n+import type {\n+ HeaderProps,\n+ NavigationScene,\n+} from 'react-navigation/src/TypeDefinition';\n+\n+import React from 'react';\n+import Header from 'react-navigation/src/views/Header/Header';\n+\n+// The whole reason for overriding header is because when we override\n+// headerTitle, we end up having to implement headerTruncatedBackTitle ourselves\n+class MessageListHeader extends React.PureComponent {\n+\n+ props: HeaderProps & { routeKey: string };\n+ state: {\n+ titleWidths: {[key: string]: number},\n+ } = {\n+ titleWidths: {},\n+ };\n+\n+ setTitleWidth(routeKey: string, width: number) {\n+ this.setState({\n+ titleWidths: {...this.state.titleWidths, [routeKey]: width },\n+ });\n+ }\n+\n+ getScreenDetails = (scene: NavigationScene) => {\n+ const actualResponse = this.props.getScreenDetails(scene);\n+ const width = this.state.titleWidths[this.props.routeKey];\n+ if (\n+ scene.key === this.props.scene.key ||\n+ width === undefined || width === null\n+ ) {\n+ return actualResponse;\n+ }\n+ const spaceLeft = (this.props.layout.initWidth - width) / 2;\n+ if (spaceLeft > 100) {\n+ return actualResponse;\n+ }\n+ return {\n+ ...actualResponse,\n+ options: {\n+ ...actualResponse.options,\n+ headerBackTitle: \"Back\",\n+ },\n+ };\n+ }\n+\n+ render() {\n+ const { getScreenDetails, ...passProps } = this.props;\n+ return (\n+ <Header\n+ getScreenDetails={this.getScreenDetails}\n+ {...passProps}\n+ />\n+ );\n+ }\n+\n+}\n+\n+export default MessageListHeader;\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/message-list.react.js",
"new_path": "native/chat/message-list.react.js",
"diff": "@@ -56,6 +56,8 @@ import TextHeightMeasurer from '../text-height-measurer.react';\nimport InputBar from './input-bar.react';\nimport ListLoadingIndicator from '../list-loading-indicator.react';\nimport AddThreadButton from './add-thread-button.react';\n+import MessageListHeaderTitle from './message-list-header-title.react';\n+import MessageListHeader from './message-list-header.react';\ntype NavProp = NavigationScreenProp<NavigationRoute, NavigationAction>\n& { state: { params: { threadInfo: ThreadInfo } } };\n@@ -83,6 +85,16 @@ type ChatMessageItemWithHeight =\n{| itemType: \"loader\" |} |\nChatMessageInfoItemWithHeight;\n+let messageListHeader = null;\n+function messageListHeaderRef(header: ?MessageListHeader) {\n+ messageListHeader = header;\n+};\n+function onTitleWidthChange(key: string, width: number) {\n+ if (messageListHeader) {\n+ messageListHeader.setTitleWidth(key, width);\n+ }\n+}\n+\ntype Props = {\nnavigation: NavProp,\n// Redux state\n@@ -122,13 +134,27 @@ class InnerMessageList extends React.PureComponent {\nfetchMessages: PropTypes.func.isRequired,\n};\nstatic navigationOptions = ({ navigation }) => ({\n- title: navigation.state.params.threadInfo.name,\n+ headerTitle: (\n+ <MessageListHeaderTitle\n+ threadInfo={navigation.state.params.threadInfo}\n+ navigate={navigation.navigate}\n+ sceneKey={navigation.state.key}\n+ onWidthChange={onTitleWidthChange}\n+ />\n+ ),\nheaderRight: (\n<AddThreadButton\nparentThreadID={navigation.state.params.threadInfo.id}\nnavigate={navigation.navigate}\n/>\n),\n+ header: (props: *) => (\n+ <MessageListHeader\n+ {...props}\n+ routeKey={navigation.state.key}\n+ ref={messageListHeaderRef}\n+ />\n+ ),\n});\ntextHeights: ?Map<string, number> = null;\nloadingFromScroll = false;\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Custom MessageListHeaderTitle that is clickable |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.