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 | 27.09.2017 15:15:21 | 14,400 | 1b47680098e3100d618f6f824ef82c48c9cb69c1 | MySQL escape the json_encode'd blob, and use the raw name in all payloads | [
{
"change_type": "MODIFY",
"old_path": "server/new_thread.php",
"new_path": "server/new_thread.php",
"diff": "@@ -75,7 +75,8 @@ if ($vis_rules === VISIBILITY_NESTED_OPEN) {\n}\n}\n-$name = $conn->real_escape_string($_POST['name']);\n+$raw_name = $_POST['name'];\n+$name = $conn->real_escape_string($raw_name);\n$description = $conn->real_escape_string($_POST['description']);\n$time = round(microtime(true) * 1000); // in milliseconds\n$conn->query(\"INSERT INTO ids(table_name) VALUES('threads')\");\n@@ -114,13 +115,13 @@ $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 = array(\n- \"name\" => $name,\n+ \"name\" => $raw_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-$encoded_payload = json_encode($payload);\n+$encoded_payload = $conn->real_escape_string(json_encode($payload));\n$message_insert_query = <<<SQL\nINSERT INTO messages(id, thread, user, type, content, time)\nVALUES ({$message_id}, {$id}, {$creator},\n@@ -194,7 +195,7 @@ async_end(array(\n'success' => true,\n'new_thread_info' => array(\n'id' => (string)$id,\n- 'name' => $name,\n+ 'name' => $raw_name,\n'description' => $description,\n'authorized' => true,\n'viewerIsMember' => true,\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | MySQL escape the json_encode'd blob, and use the raw name in all payloads |
129,187 | 27.09.2017 15:52:13 | 14,400 | 8274160365841dac0f66f7d7f1ad94f5f7ef0e0e | Simplify MessageListHeaderTitle logic and make sure forward caret always appears on Android | [
{
"change_type": "MODIFY",
"old_path": "native/chat/message-list-header-title.react.js",
"new_path": "native/chat/message-list-header-title.react.js",
"diff": "@@ -98,24 +98,13 @@ const styles = StyleSheet.create({\nbottom: 0,\n},\ncontainer: {\n- backgroundColor: 'transparent',\n- position: 'absolute',\n- left: 0,\n- right: 0,\n- top: 0,\n- bottom: 0,\n+ flex: 1,\nflexDirection: 'row',\nalignItems: 'center',\n- justifyContent: Platform.select({\n- android: 'flex-start',\n- default: 'center',\n- }),\n+ justifyContent: 'center',\n},\nforwardIcon: {\n- flex: Platform.select({\n- android: undefined,\n- default: 1,\n- }),\n+ flex: 1,\nminWidth: 25,\n},\nfakeIcon: {\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Simplify MessageListHeaderTitle logic and make sure forward caret always appears on Android |
129,187 | 27.09.2017 17:34:05 | 14,400 | 57a5cd7577174169284248e55a6b73b87ec66445 | Thread settings panel boilerplate | [
{
"change_type": "MODIFY",
"old_path": "native/chat/chat.react.js",
"new_path": "native/chat/chat.react.js",
"diff": "@@ -11,12 +11,17 @@ import {\n} from './chat-thread-list.react';\nimport { MessageList, MessageListRouteName } from './message-list.react';\nimport { AddThread, AddThreadRouteName } from './add-thread.react';\n+import {\n+ ThreadSettings,\n+ ThreadSettingsRouteName,\n+} from './thread-settings.react';\nconst Chat = StackNavigator(\n{\n[ChatThreadListRouteName]: { screen: ChatThreadList },\n[MessageListRouteName]: { screen: MessageList },\n[AddThreadRouteName]: { screen: AddThread },\n+ [ThreadSettingsRouteName]: { screen: ThreadSettings },\n},\n{\nnavigationOptions: {\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/message-list-header-title.react.js",
"new_path": "native/chat/message-list-header-title.react.js",
"diff": "@@ -11,6 +11,7 @@ import Icon from 'react-native-vector-icons/Ionicons';\nimport HeaderTitle from 'react-navigation/src/views/Header/HeaderTitle';\nimport Button from '../components/button.react';\n+import { ThreadSettingsRouteName } from './thread-settings.react';\nclass MessageListHeaderTitle extends React.PureComponent {\n@@ -84,7 +85,10 @@ class MessageListHeaderTitle extends React.PureComponent {\n}\nonPress = () => {\n- console.log('test');\n+ this.props.navigate(\n+ ThreadSettingsRouteName,\n+ { threadInfo: this.props.threadInfo },\n+ );\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/message-list.react.js",
"new_path": "native/chat/message-list.react.js",
"diff": "@@ -155,6 +155,7 @@ class InnerMessageList extends React.PureComponent {\nref={messageListHeaderRef}\n/>\n),\n+ headerBackTitle: \"Back\",\n});\ntextHeights: ?Map<string, number> = null;\nloadingFromScroll = false;\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/chat/thread-settings.react.js",
"diff": "+// @flow\n+\n+import type {\n+ NavigationScreenProp,\n+ NavigationRoute,\n+ NavigationAction,\n+} from 'react-navigation/src/TypeDefinition';\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 { connect } from 'react-redux';\n+import PropTypes from 'prop-types';\n+\n+type NavProp = NavigationScreenProp<NavigationRoute, NavigationAction>\n+ & { state: { params: { threadInfo: ThreadInfo } } };\n+\n+type Props = {\n+ navigation: NavProp,\n+};\n+type State = {\n+};\n+class InnerThreadSettings extends React.PureComponent {\n+\n+ props: Props;\n+ state: State;\n+ static propTypes = {\n+ navigation: PropTypes.shape({\n+ state: PropTypes.shape({\n+ params: PropTypes.shape({\n+ threadInfo: threadInfoPropType.isRequired,\n+ }).isRequired,\n+ }).isRequired,\n+ goBack: PropTypes.func.isRequired,\n+ }).isRequired,\n+ };\n+ static navigationOptions = ({ navigation }) => ({\n+ title: navigation.state.params.threadInfo.name,\n+ });\n+\n+ render() {\n+ return null;\n+ }\n+\n+}\n+\n+const ThreadSettingsRouteName = 'ThreadSettings';\n+const ThreadSettings = connect(\n+ (state: AppState, ownProps: { navigation: NavProp }) => ({\n+ }),\n+)(InnerThreadSettings);\n+\n+export {\n+ ThreadSettings,\n+ ThreadSettingsRouteName,\n+};\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/react-community/react-navigation.git#69397af74d3f36715b6e1a8fbc30a0bfd9c75778\",\n+ \"version\": \"git+https://git@github.com/react-community/react-navigation.git#e139e83a1af8638df6001c115d59bffddd7a16e3\",\n\"requires\": {\n\"babel-plugin-transform-define\": \"1.3.0\",\n\"clamp\": \"1.0.1\",\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Thread settings panel boilerplate |
129,187 | 27.09.2017 21:19:37 | 14,400 | 0ab9efa067c026ddc790af93351ecac3134d4f53 | ColorSplotch component | [
{
"change_type": "MODIFY",
"old_path": "native/calendar/thread-picker-thread.react.js",
"new_path": "native/calendar/thread-picker-thread.react.js",
"diff": "@@ -8,6 +8,7 @@ import { Text, View, StyleSheet } from 'react-native';\nimport PropTypes from 'prop-types';\nimport Button from '../components/button.react';\n+import ColorSplotch from '../components/color-splotch.react';\nclass ThreadPickerThread extends React.PureComponent {\n@@ -25,9 +26,6 @@ class ThreadPickerThread extends React.PureComponent {\n}\nrender() {\n- const colorSplotchStyle = {\n- backgroundColor: `#${this.props.threadInfo.color}`,\n- };\nreturn (\n<Button\nonPress={this.onPress}\n@@ -36,7 +34,7 @@ class ThreadPickerThread extends React.PureComponent {\niosActiveOpacity={0.85}\n>\n<View style={styles.container}>\n- <View style={[styles.colorSplotch, colorSplotchStyle]} />\n+ <ColorSplotch color={this.props.threadInfo.color} />\n<Text style={styles.text}>{this.props.threadInfo.name}</Text>\n</View>\n</Button>\n@@ -53,13 +51,6 @@ const styles = StyleSheet.create({\npaddingTop: 5,\npaddingBottom: 5,\n},\n- colorSplotch: {\n- height: 25,\n- width: 25,\n- borderRadius: 5,\n- borderWidth: 1,\n- borderColor: '#777777',\n- },\ntext: {\npaddingTop: 2,\npaddingLeft: 10,\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/add-thread.react.js",
"new_path": "native/chat/add-thread.react.js",
"diff": "@@ -53,6 +53,7 @@ import {\nimport SearchIndex from 'lib/shared/search-index';\nimport { generateRandomColor } from 'lib/shared/thread-utils';\nimport ColorPicker from '../components/color-picker.react';\n+import ColorSplotch from '../components/color-splotch.react';\nimport TagInput from '../components/tag-input.react';\nimport UserList from '../components/user-list.react';\n@@ -292,9 +293,6 @@ class InnerAddThread extends React.PureComponent {\n</View>\n);\n}\n- const colorSplotchStyle = {\n- backgroundColor: `#${this.state.color}`,\n- };\nconst content = (\n<View style={styles.content}>\n<View style={styles.row}>\n@@ -320,7 +318,7 @@ class InnerAddThread extends React.PureComponent {\n<View style={styles.row}>\n<Text style={styles.label}>Color</Text>\n<View style={[styles.input, styles.inlineInput]}>\n- <View style={[styles.colorSplotch, colorSplotchStyle]} />\n+ <ColorSplotch color={this.state.color} />\n<LinkButton\ntext=\"Change\"\nonPress={this.onPressChangeColor}\n@@ -601,13 +599,6 @@ const styles = StyleSheet.create({\nright: 10,\nposition: 'absolute',\n},\n- colorSplotch: {\n- height: 25,\n- width: 25,\n- borderRadius: 5,\n- borderWidth: 1,\n- borderColor: '#777777',\n- },\nchangeColorButton: {\npaddingTop: 2,\n},\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/components/color-splotch.react.js",
"diff": "+// @flow\n+\n+import React from 'react';\n+import { View, StyleSheet } from 'react-native';\n+\n+type Props = {\n+ color: string,\n+};\n+function ColorSplotch(props: Props) {\n+ const style = {\n+ backgroundColor: `#${props.color}`,\n+ };\n+ return (\n+ <View style={[styles.colorSplotch, style]} />\n+ );\n+}\n+\n+const styles = StyleSheet.create({\n+ colorSplotch: {\n+ height: 25,\n+ width: 25,\n+ borderRadius: 5,\n+ borderWidth: 1,\n+ borderColor: '#777777',\n+ },\n+});\n+\n+export default ColorSplotch;\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | ColorSplotch component |
129,187 | 27.09.2017 21:22:21 | 14,400 | 4ea5dcc9cdf3d48fdd6846156ad3a84d3819fac5 | Show name and color in thread settings panel | [
{
"change_type": "MODIFY",
"old_path": "native/chat/chat.react.js",
"new_path": "native/chat/chat.react.js",
"diff": "@@ -14,7 +14,7 @@ import { AddThread, AddThreadRouteName } from './add-thread.react';\nimport {\nThreadSettings,\nThreadSettingsRouteName,\n-} from './thread-settings.react';\n+} from './settings/thread-settings.react';\nconst Chat = StackNavigator(\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/message-list-header-title.react.js",
"new_path": "native/chat/message-list-header-title.react.js",
"diff": "@@ -11,7 +11,7 @@ import Icon from 'react-native-vector-icons/Ionicons';\nimport HeaderTitle from 'react-navigation/src/views/Header/HeaderTitle';\nimport Button from '../components/button.react';\n-import { ThreadSettingsRouteName } from './thread-settings.react';\n+import { ThreadSettingsRouteName } from './settings/thread-settings.react';\nclass MessageListHeaderTitle extends React.PureComponent {\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/chat/settings/edit-setting-button.react.js",
"diff": "+// @flow\n+\n+import React from 'react';\n+import { TouchableOpacity, StyleSheet } from 'react-native';\n+import Icon from 'react-native-vector-icons/FontAwesome';\n+\n+type Props = {|\n+ onPress: () => void,\n+ canChangeSettings: bool,\n+|};\n+function EditSettingButton(props: Props) {\n+ if (!props.canChangeSettings) {\n+ return null;\n+ }\n+ return (\n+ <TouchableOpacity onPress={props.onPress}>\n+ <Icon\n+ name=\"pencil\"\n+ size={20}\n+ style={styles.editIcon}\n+ color=\"#0348BB\"\n+ />\n+ </TouchableOpacity>\n+ );\n+}\n+\n+const styles = StyleSheet.create({\n+ editIcon: {\n+ paddingLeft: 10,\n+ textAlign: 'right',\n+ },\n+});\n+\n+export default EditSettingButton;\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/chat/settings/thread-settings-category.react.js",
"diff": "+// @flow\n+\n+import React from 'react';\n+import { View, Text, StyleSheet } from 'react-native';\n+\n+type Props = {|\n+ type: \"full\" | \"outline\",\n+ title: string,\n+ children?: React.Element<*>,\n+|};\n+function ThreadSettingsCategory(props: Props) {\n+ const contentStyle = props.type === \"full\"\n+ ? styles.fullContent\n+ : styles.outlineContent;\n+ return (\n+ <View style={styles.category}>\n+ <Text style={styles.title}>\n+ {props.title.toUpperCase()}\n+ </Text>\n+ <View style={contentStyle}>\n+ {props.children}\n+ </View>\n+ </View>\n+ );\n+}\n+\n+const styles = StyleSheet.create({\n+ category: {\n+ marginVertical: 12,\n+ },\n+ title: {\n+ paddingLeft: 24,\n+ paddingBottom: 3,\n+ fontSize: 12,\n+ fontWeight: \"400\",\n+ color: \"#888888\",\n+ },\n+ fullContent: {\n+ borderTopWidth: 1,\n+ borderBottomWidth: 1,\n+ borderColor: \"#CCCCCC\",\n+ paddingHorizontal: 24,\n+ paddingVertical: 6,\n+ backgroundColor: \"white\",\n+ },\n+ outlineContent: {\n+ },\n+});\n+\n+export default ThreadSettingsCategory;\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/chat/settings/thread-settings.react.js",
"diff": "+// @flow\n+\n+import type {\n+ NavigationScreenProp,\n+ NavigationRoute,\n+ NavigationAction,\n+} from 'react-navigation/src/TypeDefinition';\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 { connect } from 'react-redux';\n+import PropTypes from 'prop-types';\n+import { ScrollView, StyleSheet, Text, View } from 'react-native';\n+\n+import ThreadSettingsCategory from './thread-settings-category.react';\n+import ColorSplotch from '../../components/color-splotch.react';\n+import EditSettingButton from './edit-setting-button.react';\n+\n+type NavProp = NavigationScreenProp<NavigationRoute, NavigationAction>\n+ & { state: { params: { threadInfo: ThreadInfo } } };\n+\n+type Props = {\n+ navigation: NavProp,\n+};\n+type State = {\n+};\n+class InnerThreadSettings extends React.PureComponent {\n+\n+ props: Props;\n+ state: State;\n+ static propTypes = {\n+ navigation: PropTypes.shape({\n+ state: PropTypes.shape({\n+ params: PropTypes.shape({\n+ threadInfo: threadInfoPropType.isRequired,\n+ }).isRequired,\n+ }).isRequired,\n+ goBack: PropTypes.func.isRequired,\n+ }).isRequired,\n+ };\n+ static navigationOptions = ({ navigation }) => ({\n+ title: navigation.state.params.threadInfo.name,\n+ });\n+\n+ render() {\n+ const threadInfo = this.props.navigation.state.params.threadInfo;\n+ return (\n+ <ScrollView styles={styles.scrollView}>\n+ <ThreadSettingsCategory type=\"full\" title=\"Basics\">\n+ <View style={styles.row}>\n+ <Text style={styles.label}>Name</Text>\n+ <Text style={[styles.currentValue, styles.currentValueText]}>\n+ {threadInfo.name}\n+ </Text>\n+ <EditSettingButton\n+ onPress={this.onPressEditName}\n+ canChangeSettings={threadInfo.canChangeSettings}\n+ />\n+ </View>\n+ <View style={styles.row}>\n+ <Text style={styles.label}>Color</Text>\n+ <View style={styles.currentValue}>\n+ <ColorSplotch color={threadInfo.color} />\n+ </View>\n+ <EditSettingButton\n+ onPress={this.onPressEditColor}\n+ canChangeSettings={threadInfo.canChangeSettings}\n+ />\n+ </View>\n+ </ThreadSettingsCategory>\n+ </ScrollView>\n+ );\n+ }\n+\n+ onPressEditName = () => {\n+ }\n+\n+ onPressEditColor = () => {\n+ }\n+\n+}\n+\n+const styles = StyleSheet.create({\n+ scrollView: {\n+ flex: 1,\n+ },\n+ row: {\n+ flexDirection: 'row',\n+ marginVertical: 4,\n+ },\n+ label: {\n+ fontSize: 16,\n+ width: 80,\n+ color: \"#888888\",\n+ },\n+ currentValue: {\n+ flex: 1,\n+ flexDirection: 'row',\n+ },\n+ currentValueText: {\n+ fontSize: 16,\n+ color: \"#333333\",\n+ },\n+});\n+\n+const ThreadSettingsRouteName = 'ThreadSettings';\n+const ThreadSettings = connect(\n+ (state: AppState, ownProps: { navigation: NavProp }) => ({\n+ }),\n+)(InnerThreadSettings);\n+\n+export {\n+ ThreadSettings,\n+ ThreadSettingsRouteName,\n+};\n"
},
{
"change_type": "DELETE",
"old_path": "native/chat/thread-settings.react.js",
"new_path": null,
"diff": "-// @flow\n-\n-import type {\n- NavigationScreenProp,\n- NavigationRoute,\n- NavigationAction,\n-} from 'react-navigation/src/TypeDefinition';\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 { connect } from 'react-redux';\n-import PropTypes from 'prop-types';\n-\n-type NavProp = NavigationScreenProp<NavigationRoute, NavigationAction>\n- & { state: { params: { threadInfo: ThreadInfo } } };\n-\n-type Props = {\n- navigation: NavProp,\n-};\n-type State = {\n-};\n-class InnerThreadSettings extends React.PureComponent {\n-\n- props: Props;\n- state: State;\n- static propTypes = {\n- navigation: PropTypes.shape({\n- state: PropTypes.shape({\n- params: PropTypes.shape({\n- threadInfo: threadInfoPropType.isRequired,\n- }).isRequired,\n- }).isRequired,\n- goBack: PropTypes.func.isRequired,\n- }).isRequired,\n- };\n- static navigationOptions = ({ navigation }) => ({\n- title: navigation.state.params.threadInfo.name,\n- });\n-\n- render() {\n- return null;\n- }\n-\n-}\n-\n-const ThreadSettingsRouteName = 'ThreadSettings';\n-const ThreadSettings = connect(\n- (state: AppState, ownProps: { navigation: NavProp }) => ({\n- }),\n-)(InnerThreadSettings);\n-\n-export {\n- ThreadSettings,\n- ThreadSettingsRouteName,\n-};\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Show name and color in thread settings panel |
129,187 | 28.09.2017 16:13:03 | 14,400 | b7398499dff2e8959b8c13b79a1f5798118f21f7 | Add a bunch of stuff - visibility, members - to thread settings panel, and refine the style a little bit | [
{
"change_type": "MODIFY",
"old_path": "lib/selectors/user-selectors.js",
"new_path": "lib/selectors/user-selectors.js",
"diff": "// @flow\nimport type { BaseAppState } from '../types/redux-types';\n-import type { UserInfo } from '../types/user-types';\n+import type { UserInfo, RelativeUserInfo } from '../types/user-types';\nimport { createSelector } from 'reselect';\nimport _memoize from 'lodash/memoize';\n@@ -9,6 +9,65 @@ import _keys from 'lodash/keys';\nimport SearchIndex from '../shared/search-index';\n+function userIDsToRelativeUserInfos(\n+ userIDs: string[],\n+ viewerID: ?string,\n+ userInfos: {[id: string]: UserInfo},\n+): RelativeUserInfo[] {\n+ const relativeUserInfos = [];\n+ for (let userID of userIDs) {\n+ if (!userInfos[userID]) {\n+ continue;\n+ }\n+ if (userID === viewerID) {\n+ relativeUserInfos.unshift({\n+ id: userID,\n+ username: userInfos[userID].username,\n+ isViewer: true,\n+ });\n+ } else {\n+ relativeUserInfos.push({\n+ id: userID,\n+ username: userInfos[userID].username,\n+ isViewer: false,\n+ });\n+ }\n+ }\n+ return relativeUserInfos;\n+}\n+\n+// Includes current user at the start\n+const baseRelativeUserInfoSelectorForMembersOfThread = (threadID: string) =>\n+ createSelector(\n+ (state: BaseAppState) => state.threadInfos[threadID].memberIDs,\n+ (state: BaseAppState) => state.currentUserInfo && state.currentUserInfo.id,\n+ (state: BaseAppState) => state.userInfos,\n+ (\n+ memberUserIDs: string[],\n+ currentUserID: ?string,\n+ userInfos: {[id: string]: UserInfo},\n+ ): RelativeUserInfo[] => {\n+ const relativeUserInfos = userIDsToRelativeUserInfos(\n+ memberUserIDs,\n+ currentUserID,\n+ userInfos,\n+ );\n+ const orderedRelativeUserInfos = [];\n+ for (let relativeUserInfo of relativeUserInfos) {\n+ if (relativeUserInfo.isViewer) {\n+ orderedRelativeUserInfos.unshift(relativeUserInfo);\n+ } else {\n+ orderedRelativeUserInfos.push(relativeUserInfo);\n+ }\n+ }\n+ return orderedRelativeUserInfos;\n+ },\n+ );\n+\n+const relativeUserInfoSelectorForMembersOfThread = _memoize(\n+ baseRelativeUserInfoSelectorForMembersOfThread,\n+);\n+\n// If threadID is null, then all users except the logged-in user are returned\nconst baseUserInfoSelectorForOtherMembersOfThread = (threadID: ?string) =>\ncreateSelector(\n@@ -58,6 +117,8 @@ const userSearchIndexForOtherMembersOfThread = _memoize(\n);\nexport {\n+ userIDsToRelativeUserInfos,\n+ relativeUserInfoSelectorForMembersOfThread,\nuserInfoSelectorForOtherMembersOfThread,\nuserSearchIndexForOtherMembersOfThread,\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/settings/edit-setting-button.react.js",
"new_path": "native/chat/settings/edit-setting-button.react.js",
"diff": "// @flow\n+import type {\n+ StyleObj,\n+} from 'react-native/Libraries/StyleSheet/StyleSheetTypes';\n+\nimport React from 'react';\nimport { TouchableOpacity, StyleSheet } from 'react-native';\nimport Icon from 'react-native-vector-icons/FontAwesome';\n@@ -7,18 +11,23 @@ import Icon from 'react-native-vector-icons/FontAwesome';\ntype Props = {|\nonPress: () => void,\ncanChangeSettings: bool,\n+ style?: StyleObj,\n|};\nfunction EditSettingButton(props: Props) {\nif (!props.canChangeSettings) {\nreturn null;\n}\n+ const appliedStyles = [styles.editIcon];\n+ if (props.style) {\n+ appliedStyles.push(props.style);\n+ }\nreturn (\n<TouchableOpacity onPress={props.onPress}>\n<Icon\nname=\"pencil\"\n- size={20}\n- style={styles.editIcon}\n- color=\"#0348BB\"\n+ size={16}\n+ style={appliedStyles}\n+ color=\"#036AFF\"\n/>\n</TouchableOpacity>\n);\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/settings/thread-settings-category.react.js",
"new_path": "native/chat/settings/thread-settings-category.react.js",
"diff": "@@ -4,20 +4,17 @@ import React from 'react';\nimport { View, Text, StyleSheet } from 'react-native';\ntype Props = {|\n- type: \"full\" | \"outline\",\n+ type: \"full\" | \"outline\" | \"unpadded\",\ntitle: string,\nchildren?: React.Element<*>,\n|};\nfunction ThreadSettingsCategory(props: Props) {\n- const contentStyle = props.type === \"full\"\n- ? styles.fullContent\n- : styles.outlineContent;\nreturn (\n<View style={styles.category}>\n<Text style={styles.title}>\n{props.title.toUpperCase()}\n</Text>\n- <View style={contentStyle}>\n+ <View style={styles[props.type]}>\n{props.children}\n</View>\n</View>\n@@ -26,7 +23,7 @@ function ThreadSettingsCategory(props: Props) {\nconst styles = StyleSheet.create({\ncategory: {\n- marginVertical: 12,\n+ marginVertical: 16,\n},\ntitle: {\npaddingLeft: 24,\n@@ -35,7 +32,7 @@ const styles = StyleSheet.create({\nfontWeight: \"400\",\ncolor: \"#888888\",\n},\n- fullContent: {\n+ full: {\nborderTopWidth: 1,\nborderBottomWidth: 1,\nborderColor: \"#CCCCCC\",\n@@ -43,7 +40,13 @@ const styles = StyleSheet.create({\npaddingVertical: 6,\nbackgroundColor: \"white\",\n},\n- outlineContent: {\n+ unpadded: {\n+ borderTopWidth: 1,\n+ borderBottomWidth: 1,\n+ borderColor: \"#CCCCCC\",\n+ backgroundColor: \"white\",\n+ },\n+ outline: {\n},\n});\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/chat/settings/thread-settings-members.react.js",
"diff": "+// @flow\n+\n+import type { ThreadInfo } from 'lib/types/thread-types';\n+\n+import React from 'react';\n+import { View, Text, StyleSheet, Platform } from 'react-native';\n+import Icon from 'react-native-vector-icons/Ionicons';\n+\n+import EditSettingButton from './edit-setting-button.react';\n+import Button from '../../components/button.react';\n+\n+type ThreadSettingsUserProps = {\n+ userInfo: {|\n+ id: string,\n+ username: string,\n+ isViewer: bool,\n+ |},\n+ threadInfo: ThreadInfo,\n+};\n+function ThreadSettingsUser(props: ThreadSettingsUserProps) {\n+ const canChange = !props.userInfo.isViewer &&\n+ props.threadInfo.canChangeSettings;\n+ return (\n+ <View style={styles.container}>\n+ <Text style={styles.username}>{props.userInfo.username}</Text>\n+ <EditSettingButton\n+ onPress={() => {}}\n+ canChangeSettings={canChange}\n+ style={styles.editSettingsIcon}\n+ />\n+ </View>\n+ );\n+}\n+\n+type ThreadSettingsAddUserProps = {\n+ onPress: () => void,\n+};\n+function ThreadSettingsAddUser(props: ThreadSettingsAddUserProps) {\n+ return (\n+ <Button\n+ onPress={props.onPress}\n+ >\n+ <View style={[styles.container, styles.addUser]}>\n+ <Text style={styles.addUserText}>Add users</Text>\n+ <Icon\n+ name={\"md-add\"}\n+ size={20}\n+ style={styles.addIcon}\n+ color=\"#009900\"\n+ />\n+ </View>\n+ </Button>\n+ );\n+}\n+\n+const styles = StyleSheet.create({\n+ container: {\n+ flex: 1,\n+ flexDirection: 'row',\n+ paddingVertical: 8,\n+ justifyContent: 'center',\n+ },\n+ addUser: {\n+ paddingHorizontal: 24,\n+ paddingTop: 12,\n+ },\n+ editSettingsIcon: {\n+ lineHeight: 20,\n+ },\n+ addIcon: {\n+ },\n+ username: {\n+ flex: 1,\n+ fontSize: 16,\n+ color: \"#333333\",\n+ },\n+ addUserText: {\n+ flex: 1,\n+ fontSize: 16,\n+ color: \"#036AFF\",\n+ fontStyle: 'italic',\n+ },\n+});\n+\n+export {\n+ ThreadSettingsUser,\n+ ThreadSettingsAddUser,\n+};\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/settings/thread-settings.react.js",
"new_path": "native/chat/settings/thread-settings.react.js",
"diff": "@@ -8,21 +8,38 @@ import type {\nimport type { ThreadInfo } from 'lib/types/thread-types';\nimport { threadInfoPropType } from 'lib/types/thread-types';\nimport type { AppState } from '../../redux-setup';\n+import type { RelativeUserInfo } from 'lib/types/user-types';\n+import { relativeUserInfoPropType } from 'lib/types/user-types';\nimport React from 'react';\nimport { connect } from 'react-redux';\nimport PropTypes from 'prop-types';\nimport { ScrollView, StyleSheet, Text, View } from 'react-native';\n+import { visibilityRules } from 'lib/types/thread-types';\n+import {\n+ relativeUserInfoSelectorForMembersOfThread,\n+} from 'lib/selectors/user-selectors';\n+\nimport ThreadSettingsCategory from './thread-settings-category.react';\nimport ColorSplotch from '../../components/color-splotch.react';\nimport EditSettingButton from './edit-setting-button.react';\n+import Button from '../../components/button.react';\n+import { MessageListRouteName } from '../message-list.react';\n+import {\n+ ThreadSettingsUser,\n+ ThreadSettingsAddUser,\n+} from './thread-settings-members.react';\ntype NavProp = NavigationScreenProp<NavigationRoute, NavigationAction>\n& { state: { params: { threadInfo: ThreadInfo } } };\ntype Props = {\nnavigation: NavProp,\n+ // Redux state\n+ threadInfo: ThreadInfo,\n+ parentThreadInfo: ?ThreadInfo,\n+ threadMembers: RelativeUserInfo[],\n};\ntype State = {\n};\n@@ -37,39 +54,109 @@ class InnerThreadSettings extends React.PureComponent {\nthreadInfo: threadInfoPropType.isRequired,\n}).isRequired,\n}).isRequired,\n+ navigate: PropTypes.func.isRequired,\ngoBack: PropTypes.func.isRequired,\n}).isRequired,\n+ threadInfo: threadInfoPropType.isRequired,\n+ parentThreadInfo: threadInfoPropType,\n+ threadMembers: PropTypes.arrayOf(relativeUserInfoPropType).isRequired,\n};\nstatic navigationOptions = ({ navigation }) => ({\ntitle: navigation.state.params.threadInfo.name,\n});\nrender() {\n- const threadInfo = this.props.navigation.state.params.threadInfo;\n+ let parent;\n+ if (this.props.parentThreadInfo) {\n+ parent = (\n+ <Button\n+ onPress={this.onPressParentThread}\n+ style={[styles.currentValue, styles.padding]}\n+ >\n+ <Text style={[styles.currentValueText, styles.parentThreadLink]}>\n+ {this.props.parentThreadInfo.name}\n+ </Text>\n+ </Button>\n+ );\n+ } else {\n+ parent = (\n+ <Text style={[\n+ styles.currentValue,\n+ styles.currentValueText,\n+ styles.padding,\n+ styles.noParent,\n+ ]}>\n+ No parent\n+ </Text>\n+ );\n+ }\n+ const visRules = this.props.threadInfo.visibilityRules;\n+ const visibility =\n+ visRules === visibilityRules.OPEN ||\n+ visRules === visibilityRules.CHAT_NESTED_OPEN\n+ ? \"Public\"\n+ : \"Secret\";\n+ const members = this.props.threadMembers.map((userInfo) => {\n+ if (!userInfo.username) {\n+ return null;\n+ }\n+ const userInfoWithUsername = {\n+ id: userInfo.id,\n+ username: userInfo.username,\n+ isViewer: userInfo.isViewer,\n+ };\nreturn (\n- <ScrollView styles={styles.scrollView}>\n+ <View style={styles.userRow} key={userInfo.id}>\n+ <ThreadSettingsUser\n+ userInfo={userInfoWithUsername}\n+ threadInfo={this.props.threadInfo}\n+ />\n+ </View>\n+ );\n+ }).filter(x => x);\n+ return (\n+ <ScrollView contentContainerStyle={styles.scrollView}>\n<ThreadSettingsCategory type=\"full\" title=\"Basics\">\n<View style={styles.row}>\n<Text style={styles.label}>Name</Text>\n<Text style={[styles.currentValue, styles.currentValueText]}>\n- {threadInfo.name}\n+ {this.props.threadInfo.name}\n</Text>\n<EditSettingButton\nonPress={this.onPressEditName}\n- canChangeSettings={threadInfo.canChangeSettings}\n+ canChangeSettings={this.props.threadInfo.canChangeSettings}\n/>\n</View>\n- <View style={styles.row}>\n- <Text style={styles.label}>Color</Text>\n+ <View style={styles.colorRow}>\n+ <Text style={[styles.label, styles.colorLine]}>Color</Text>\n<View style={styles.currentValue}>\n- <ColorSplotch color={threadInfo.color} />\n+ <ColorSplotch color={this.props.threadInfo.color} />\n</View>\n<EditSettingButton\nonPress={this.onPressEditColor}\n- canChangeSettings={threadInfo.canChangeSettings}\n+ canChangeSettings={this.props.threadInfo.canChangeSettings}\n+ style={styles.colorLine}\n/>\n</View>\n</ThreadSettingsCategory>\n+ <ThreadSettingsCategory type=\"full\" title=\"Privacy\">\n+ <View style={styles.noPaddingRow}>\n+ <Text style={[styles.label, styles.padding]}>Parent</Text>\n+ {parent}\n+ </View>\n+ <View style={styles.row}>\n+ <Text style={styles.label}>Visibility</Text>\n+ <Text style={[styles.currentValue, styles.currentValueText]}>\n+ {visibility}\n+ </Text>\n+ </View>\n+ </ThreadSettingsCategory>\n+ <ThreadSettingsCategory type=\"unpadded\" title=\"Members\">\n+ <View style={styles.members}>\n+ <ThreadSettingsAddUser onPress={this.onPressAddUser} />\n+ {members}\n+ </View>\n+ </ThreadSettingsCategory>\n</ScrollView>\n);\n}\n@@ -80,35 +167,88 @@ class InnerThreadSettings extends React.PureComponent {\nonPressEditColor = () => {\n}\n+ onPressParentThread = () => {\n+ this.props.navigation.navigate(\n+ MessageListRouteName,\n+ { threadInfo: this.props.parentThreadInfo },\n+ );\n+ }\n+\n+ onPressAddUser = () => {\n+ }\n+\n}\nconst styles = StyleSheet.create({\nscrollView: {\n- flex: 1,\n+ paddingVertical: 16,\n},\nrow: {\nflexDirection: 'row',\n- marginVertical: 4,\n+ paddingVertical: 8,\n+ },\n+ noPaddingRow: {\n+ flexDirection: 'row',\n+ },\n+ padding: {\n+ paddingVertical: 4,\n},\nlabel: {\nfontSize: 16,\n- width: 80,\n+ width: 96,\ncolor: \"#888888\",\n},\n+ colorRow: {\n+ flexDirection: 'row',\n+ paddingTop: 4,\n+ paddingBottom: 8,\n+ },\n+ colorLine: {\n+ lineHeight: 25,\n+ },\ncurrentValue: {\nflex: 1,\nflexDirection: 'row',\n+ paddingLeft: 4,\n+ },\n+ userRow: {\n+ flex: 1,\n+ flexDirection: 'row',\n+ paddingHorizontal: 12,\n+ marginHorizontal: 12,\n+ borderTopWidth: 1,\n+ borderColor: \"#CCCCCC\",\n},\ncurrentValueText: {\nfontSize: 16,\ncolor: \"#333333\",\n},\n+ noParent: {\n+ fontStyle: 'italic',\n+ },\n+ parentThreadLink: {\n+ color: \"#036AFF\",\n+ },\n+ members: {\n+ paddingBottom: 4,\n+ },\n});\nconst ThreadSettingsRouteName = 'ThreadSettings';\nconst ThreadSettings = connect(\n- (state: AppState, ownProps: { navigation: NavProp }) => ({\n- }),\n+ (state: AppState, ownProps: { navigation: NavProp }) => {\n+ const passedThreadInfo = ownProps.navigation.state.params.threadInfo;\n+ // We pull the version from Redux so we get updates once they go through\n+ const threadInfo = state.threadInfos[passedThreadInfo.id];\n+ return {\n+ threadInfo,\n+ parentThreadInfo: threadInfo.parentThreadID\n+ ? state.threadInfos[threadInfo.parentThreadID]\n+ : null,\n+ threadMembers:\n+ relativeUserInfoSelectorForMembersOfThread(threadInfo.id)(state),\n+ };\n+ },\n)(InnerThreadSettings);\nexport {\n"
},
{
"change_type": "MODIFY",
"old_path": "native/selectors/chat-selectors.js",
"new_path": "native/selectors/chat-selectors.js",
"diff": "@@ -11,7 +11,7 @@ import type {\nRobotextMessageInfo,\n} from 'lib/types/message-types';\nimport { messageInfoPropType } from 'lib/types/message-types';\n-import type { UserInfo, RelativeUserInfo } from 'lib/types/user-types';\n+import type { UserInfo } from 'lib/types/user-types';\nimport { createSelector } from 'reselect';\nimport PropTypes from 'prop-types';\n@@ -24,33 +24,7 @@ import _memoize from 'lodash/memoize';\nimport { messageType } from 'lib/types/message-types';\nimport { robotextForMessageInfo } from 'lib/shared/message-utils';\n-\n-function userIDsToRelativeUserInfos(\n- userIDs: string[],\n- viewerID: ?string,\n- userInfos: {[id: string]: UserInfo},\n-): RelativeUserInfo[] {\n- const relativeUserInfos = [];\n- for (let userID of userIDs) {\n- if (!userInfos[userID]) {\n- continue;\n- }\n- if (userID === viewerID) {\n- relativeUserInfos.unshift({\n- id: userID,\n- username: userInfos[userID].username,\n- isViewer: true,\n- });\n- } else {\n- relativeUserInfos.push({\n- id: userID,\n- username: userInfos[userID].username,\n- isViewer: false,\n- });\n- }\n- }\n- return relativeUserInfos;\n-}\n+import { userIDsToRelativeUserInfos } from 'lib/selectors/user-selectors';\nfunction createMessageInfo(\nrawMessageInfo: RawMessageInfo,\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Add a bunch of stuff - visibility, members - to thread settings panel, and refine the style a little bit |
129,187 | 29.09.2017 11:35:14 | 14,400 | d0bef5a233a4e1c5203b3810d113734ce38a4234 | Call Calendar.scrollToToday() when the calendar tab gets clicked when already focused | [
{
"change_type": "MODIFY",
"old_path": "native/calendar/calendar.react.js",
"new_path": "native/calendar/calendar.react.js",
"diff": "@@ -76,6 +76,20 @@ type CalendarItemWithHeight =\nitemType: \"footer\",\ndateString: string,\n};\n+type ExtraData = {\n+ focusedEntries: {[key: string]: bool},\n+ visibleEntries: {[key: string]: bool},\n+};\n+\n+// This is v sad :(\n+// Overall, I have to say, this component is probably filled with more sadness\n+// than any other component in this project. This owes mostly to its complex\n+// infinite-scrolling behavior.\n+// But not this particular piece of sadness, actually. We have to cache the\n+// current InnerCalendar ref here so we can access it from the statically\n+// defined navigationOptions.tabBarOnPress below.\n+const currentCalendarRef: ?InnerCalendar = null;\n+\ntype Props = {\n// Redux state\nlistData: ?$ReadOnlyArray<CalendarItem>,\n@@ -92,10 +106,6 @@ type Props = {\ncalendarQuery: CalendarQuery,\n) => Promise<CalendarResult>,\n};\n-type ExtraData = {\n- focusedEntries: {[key: string]: bool},\n- visibleEntries: {[key: string]: bool},\n-};\ntype State = {\ntextToMeasure: TextToMeasure[],\nlistDataWithHeights: ?$ReadOnlyArray<CalendarItemWithHeight>,\n@@ -144,6 +154,16 @@ class InnerCalendar extends React.PureComponent {\nstyle={[styles.icon, { color: tintColor }]}\n/>\n),\n+ tabBarOnPress: (\n+ scene: { index: number, focused: bool },\n+ jumpToIndex: (index: number) => void,\n+ ) => {\n+ if (scene.focused) {\n+ currentCalendarRef.scrollToToday();\n+ } else {\n+ jumpToIndex(scene.index);\n+ }\n+ },\n};\nflatList: ?FlatList<CalendarItemWithHeight> = null;\ntextHeights: ?Map<string, number> = null;\n@@ -183,6 +203,7 @@ class InnerCalendar extends React.PureComponent {\nextraData: this.latestExtraData,\nscrollToOffsetAfterSuppressingKeyboardDismissal: null,\n};\n+ currentCalendarRef = this;\n}\nstatic textToMeasureFromListData(listData: $ReadOnlyArray<CalendarItem>) {\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Call Calendar.scrollToToday() when the calendar tab gets clicked when already focused |
129,187 | 29.09.2017 11:35:49 | 14,400 | f83b6636cc49f421959c978390dbf2e249b9aaf9 | Default to the chat screen when opening the app | [
{
"change_type": "MODIFY",
"old_path": "native/navigation-setup.js",
"new_path": "native/navigation-setup.js",
"diff": "@@ -157,7 +157,7 @@ const defaultNavigationState = {\n{\nkey: 'App',\nrouteName: AppRouteName,\n- index: 0,\n+ index: 1,\nroutes: [\n{ key: 'Calendar', routeName: CalendarRouteName },\n{\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Default to the chat screen when opening the app |
129,187 | 29.09.2017 14:08:14 | 14,400 | 94692f4ce3f5bc493825499060efc18be5d10838 | Only require personal password for some edit_thread.php calls | [
{
"change_type": "MODIFY",
"old_path": "server/edit_thread.php",
"new_path": "server/edit_thread.php",
"diff": "@@ -14,14 +14,13 @@ if (!user_logged_in()) {\n));\n}\n-if (!isset($_POST['thread']) || !isset($_POST['personal_password'])) {\n+if (!isset($_POST['thread'])) {\nasync_end(array(\n'error' => 'invalid_parameters',\n));\n}\n$user = get_viewer_id();\n$thread = (int)$_POST['thread'];\n-$personal_password = $_POST['personal_password'];\n$changed_sql_fields = array();\nif (isset($_POST['name'])) {\n@@ -122,7 +121,18 @@ if (!$row || $row['visibility_rules'] === null) {\n'error' => 'internal_error',\n));\n}\n-if (!password_verify($personal_password, $row['hash'])) {\n+if (\n+ (\n+ isset($changed_sql_fields['edit_rules']) ||\n+ isset($changed_sql_fields['hash']) ||\n+ isset($changed_sql_fields['parent_thread_id']) ||\n+ isset($changed_sql_fields['visibility_rules'])\n+ ) &&\n+ (\n+ !isset($_POST['personal_password']) ||\n+ !password_verify($_POST['personal_password'], $row['hash'])\n+ )\n+) {\nasync_end(array(\n'error' => 'invalid_credentials',\n));\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Only require personal password for some edit_thread.php calls |
129,187 | 29.09.2017 15:15:53 | 14,400 | 1ff22b419c22d96f41a3fd12f2eabd30dc5a0cb9 | Factor out SQL logic for message info creation into create_message_infos | [
{
"change_type": "MODIFY",
"old_path": "lib/actions/message-actions.js",
"new_path": "lib/actions/message-actions.js",
"diff": "@@ -66,8 +66,8 @@ async function sendMessage(\n'text': text,\n});\nreturn {\n- id: response.result.id,\n- time: response.result.time,\n+ id: response.new_message_infos[0].id,\n+ time: response.new_message_infos[0].time,\n};\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "server/message_lib.php",
"new_path": "server/message_lib.php",
"diff": "@@ -271,3 +271,56 @@ SQL;\n}\nreturn $users;\n}\n+\n+// returns message infos with IDs on success, and null on failure\n+// only fails if passed a message type it doesn't recognize\n+function create_message_infos($new_message_infos) {\n+ global $conn;\n+\n+ if (!$new_message_infos) {\n+ return array();\n+ }\n+\n+ $content_by_index = array();\n+ foreach ($new_message_infos as $index => $new_message_info) {\n+ if ($new_message_info['type'] === MESSAGE_TYPE_CREATE_THREAD) {\n+ $content_by_index[$index] = $conn->real_escape_string(\n+ json_encode($new_message_info['initialThreadState'])\n+ );\n+ } else if ($new_message_info['type'] === MESSAGE_TYPE_CREATE_SUB_THREAD) {\n+ $content_by_index[$index] = $new_message_info['childThreadID'];\n+ } else if ($new_message_info['type'] === MESSAGE_TYPE_TEXT) {\n+ $content_by_index[$index] = $conn->real_escape_string(\n+ $new_message_info['text']\n+ );\n+ } else if ($new_message_info['type'] === MESSAGE_TYPE_ADD_USERS) {\n+ $content_by_index[$index] = $conn->real_escape_string(\n+ json_encode($new_message_info['addedUserIDs'])\n+ );\n+ } else {\n+ return null;\n+ }\n+ }\n+\n+ $values = array();\n+ $return = array();\n+ foreach ($new_message_infos as $index => $new_message_info) {\n+ $conn->query(\"INSERT INTO ids(table_name) VALUES('messages')\");\n+ $new_message_info['id'] = (string)$conn->insert_id;\n+ $values[] = <<<SQL\n+({$new_message_info['id']}, {$new_message_info['threadID']},\n+ {$new_message_info['creatorID']}, {$new_message_info['type']},\n+ '{$content_by_index[$index]}', {$new_message_info['time']})\n+SQL;\n+ $return[$index] = $new_message_info;\n+ }\n+\n+ $all_values = implode(\", \", $values);\n+ $message_insert_query = <<<SQL\n+INSERT INTO messages(id, thread, user, type, content, time)\n+VALUES {$all_values}\n+SQL;\n+ $conn->query($message_insert_query);\n+\n+ return $return;\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "server/new_thread.php",
"new_path": "server/new_thread.php",
"diff": "@@ -111,52 +111,34 @@ $initial_member_ids = isset($_POST['initial_member_ids'])\n? verify_user_ids($_POST['initial_member_ids'])\n: array();\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 = array(\n- \"name\" => $raw_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-$encoded_payload = $conn->real_escape_string(json_encode($payload));\n-$message_insert_query = <<<SQL\n-INSERT INTO messages(id, thread, user, type, content, time)\n-VALUES ({$message_id}, {$id}, {$creator},\n- {$message_type_create_thread}, '{$encoded_payload}', {$time})\n-SQL;\n-$conn->query($message_insert_query);\n-\n-$new_message_infos = array(array(\n+$message_infos = array(array(\n'type' => MESSAGE_TYPE_CREATE_THREAD,\n- 'id' => (string)$message_id,\n'threadID' => (string)$id,\n'creatorID' => (string)$creator,\n'time' => $time,\n- 'initialThreadState' => $payload,\n+ 'initialThreadState' => array(\n+ 'name' => $raw_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-\nif ($parent_thread_id) {\n- $conn->query(\"INSERT INTO ids(table_name) VALUES('messages')\");\n- $parent_message_id = $conn->insert_id;\n- $message_type_create_sub_thread = MESSAGE_TYPE_CREATE_THREAD;\n- $parent_message_insert_query = <<<SQL\n-INSERT INTO messages(id, thread, user, type, content, time)\n-VALUES ({$parent_message_id}, {$parent_thread_id}, {$creator},\n- {$message_type_create_sub_thread}, '{$id}', {$time})\n-SQL;\n- $conn->query($parent_message_insert_query);\n- $new_message_infos[] = array(\n+ $message_infos[] = array(\n'type' => MESSAGE_TYPE_CREATE_SUB_THREAD,\n- 'id' => (string)$parent_message_id,\n'threadID' => (string)$parent_thread_id,\n'creatorID' => (string)$creator,\n'time' => $time,\n'childThreadID' => (string)$id,\n);\n}\n+$new_message_infos = create_message_infos($message_infos);\n+if ($new_message_infos === null) {\n+ async_end(array(\n+ 'error' => 'unknown_error',\n+ ));\n+}\n$roles_to_save = array(array(\n\"user\" => $creator,\n"
},
{
"change_type": "MODIFY",
"old_path": "server/send_message.php",
"new_path": "server/send_message.php",
"diff": "@@ -13,7 +13,6 @@ if (!isset($_POST['thread']) || !isset($_POST['text'])) {\n));\n}\n$thread = (int)$_POST['thread'];\n-$text = $conn->real_escape_string($_POST['text']);\n$can_edit = viewer_can_edit_thread($thread);\nif ($can_edit === null) {\n@@ -27,23 +26,21 @@ if (!$can_edit) {\n));\n}\n-$viewer_id = get_viewer_id();\n-$time = round(microtime(true) * 1000); // in milliseconds\n-\n-$conn->query(\"INSERT INTO ids(table_name) VALUES('messages')\");\n-$id = $conn->insert_id;\n-$message_type_text = MESSAGE_TYPE_TEXT;\n-$insert_query = <<<SQL\n-INSERT INTO messages(id, thread, user, type, content, time)\n-VALUES ({$id}, {$thread}, {$viewer_id},\n- {$message_type_text}, '{$text}', {$time})\n-SQL;\n-$conn->query($insert_query);\n+$message_info = array(\n+ 'type' => MESSAGE_TYPE_TEXT,\n+ 'threadID' => (string)$thread,\n+ 'creatorID' => (string)get_viewer_id(),\n+ 'time' => round(microtime(true) * 1000), // in milliseconds\n+ 'text' => $_POST['text'],\n+);\n+$new_message_infos = create_message_infos(array($message_info));\n+if ($new_message_infos === null) {\n+ async_end(array(\n+ 'error' => 'unknown_error',\n+ ));\n+}\nasync_end(array(\n'success' => true,\n- 'result' => array(\n- 'id' => (string)$id,\n- 'time' => $time,\n- ),\n+ 'new_message_infos' => $new_message_infos,\n));\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Factor out SQL logic for message info creation into create_message_infos |
129,187 | 29.09.2017 16:21:38 | 14,400 | 42fbb3e2d7385a98fe6b5c6468ecdf68f69728f1 | Add MESSAGE_TYPE_CHANGE_SETTINGS | [
{
"change_type": "MODIFY",
"old_path": "lib/types/message-types.js",
"new_path": "lib/types/message-types.js",
"diff": "@@ -8,12 +8,13 @@ import { relativeUserInfoPropType } from './user-types';\nimport invariant from 'invariant';\nimport PropTypes from 'prop-types';\n-export type MessageType = 0 | 1 | 2 | 3;\n+export type MessageType = 0 | 1 | 2 | 3 | 4;\nexport const messageType = {\nTEXT: 0,\nCREATE_THREAD: 1,\nADD_USER: 2,\nCREATE_SUB_THREAD: 3,\n+ CHANGE_SETTINGS: 4,\n};\nexport function assertMessageType(\nourMessageType: number,\n@@ -22,7 +23,8 @@ export function assertMessageType(\nourMessageType === 0 ||\nourMessageType === 1 ||\nourMessageType === 2 ||\n- ourMessageType === 3,\n+ ourMessageType === 3 ||\n+ ourMessageType === 4,\n\"number is not MessageType enum\",\n);\nreturn ourMessageType;\n@@ -73,11 +75,22 @@ export type RawSubThreadCreationInfo = {|\nchildThreadID: string,\n|};\n+export type RawChangeThreadSettingsInfo = {|\n+ type: 4,\n+ id: string,\n+ threadID: string,\n+ creatorID: string,\n+ time: number,\n+ field: string,\n+ value: string | number,\n+|};\n+\nexport type RawMessageInfo =\nRawTextMessageInfo |\nRawThreadCreationInfo |\nRawAddUsersInfo |\n- RawSubThreadCreationInfo;\n+ RawSubThreadCreationInfo |\n+ RawChangeThreadSettingsInfo;\nexport type TextMessageInfo = {|\ntype: 0,\n@@ -117,6 +130,14 @@ export type RobotextMessageInfo = {|\ncreator: RelativeUserInfo,\ntime: number,\nchildThreadInfo: ThreadInfo,\n+|} | {|\n+ type: 4,\n+ id: string,\n+ threadID: string,\n+ creator: RelativeUserInfo,\n+ time: number,\n+ field: string,\n+ value: string | number,\n|};\nexport type MessageInfo = TextMessageInfo | RobotextMessageInfo;\n@@ -161,6 +182,18 @@ export const messageInfoPropType = PropTypes.oneOfType([\ntime: PropTypes.number.isRequired,\nchildThreadInfo: threadInfoPropType.isRequired,\n}),\n+ PropTypes.shape({\n+ type: PropTypes.oneOf([4]).isRequired,\n+ id: PropTypes.string.isRequired,\n+ threadID: PropTypes.string.isRequired,\n+ creator: relativeUserInfoPropType.isRequired,\n+ time: PropTypes.number.isRequired,\n+ field: PropTypes.string.isRequired,\n+ value: PropTypes.oneOfType([\n+ PropTypes.number,\n+ PropTypes.string,\n+ ]).isRequired,\n+ }),\n]);\nexport type ThreadMessageInfo = {|\n"
},
{
"change_type": "MODIFY",
"old_path": "native/selectors/chat-selectors.js",
"new_path": "native/selectors/chat-selectors.js",
"diff": "@@ -112,6 +112,20 @@ function createMessageInfo(\ntime: rawMessageInfo.time,\nchildThreadInfo: threadInfos[rawMessageInfo.childThreadID],\n};\n+ } else if (rawMessageInfo.type === messageType.CHANGE_SETTINGS) {\n+ return {\n+ type: messageType.CHANGE_SETTINGS,\n+ id: rawMessageInfo.id,\n+ threadID: rawMessageInfo.threadID,\n+ creator: {\n+ id: rawMessageInfo.creatorID,\n+ username: creatorInfo.username,\n+ isViewer: rawMessageInfo.creatorID === viewerID,\n+ },\n+ time: rawMessageInfo.time,\n+ field: rawMessageInfo.field,\n+ value: rawMessageInfo.value,\n+ };\n}\ninvariant(false, `${rawMessageInfo.type} is not a messageType!`);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "server/message_lib.php",
"new_path": "server/message_lib.php",
"diff": "@@ -12,6 +12,7 @@ define(\"MESSAGE_TYPE_TEXT\", 0);\ndefine(\"MESSAGE_TYPE_CREATE_THREAD\", 1);\ndefine(\"MESSAGE_TYPE_ADD_USERS\", 2);\ndefine(\"MESSAGE_TYPE_CREATE_SUB_THREAD\", 3);\n+define(\"MESSAGE_TYPE_CHANGE_SETTINGS\", 4);\n// Every time the client asks us for MessageInfos, we need to let them know if\n// the result for a given thread affects startReached. If it's just new messages\n@@ -232,6 +233,10 @@ function message_from_row($row) {\nreturn null;\n}\n$message['childThreadID'] = $child_thread_id;\n+ } else if ($type === MESSAGE_TYPE_CHANGE_SETTINGS) {\n+ $change = json_decode($row['content'], true);\n+ $message['field'] = array_keys($change)[0];\n+ $message['value'] = $change[$message['field']];\n}\nreturn $message;\n}\n@@ -297,6 +302,10 @@ function create_message_infos($new_message_infos) {\n$content_by_index[$index] = $conn->real_escape_string(\njson_encode($new_message_info['addedUserIDs'])\n);\n+ } else if ($new_message_info['type'] === MESSAGE_TYPE_CHANGE_SETTINGS) {\n+ $content_by_index[$index] = $conn->real_escape_string(json_encode(array(\n+ $new_message_info['field'] => $new_message_info['value'],\n+ )));\n} else {\nreturn null;\n}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Add MESSAGE_TYPE_CHANGE_SETTINGS |
129,187 | 29.09.2017 17:53:58 | 14,400 | 8d84c12ebcaf7c1dd6fd4934e56400cfc41f58a8 | Create messages for edit_thread.php calls | [
{
"change_type": "MODIFY",
"old_path": "server/edit_thread.php",
"new_path": "server/edit_thread.php",
"diff": "@@ -5,6 +5,7 @@ require_once('config.php');\nrequire_once('auth.php');\nrequire_once('thread_lib.php');\nrequire_once('user_lib.php');\n+require_once('message_lib.php');\nasync_start();\n@@ -22,12 +23,15 @@ if (!isset($_POST['thread'])) {\n$user = get_viewer_id();\n$thread = (int)$_POST['thread'];\n+$changed_fields = array();\n$changed_sql_fields = array();\nif (isset($_POST['name'])) {\n+ $changed_fields['name'] = $_POST['name'];\n$changed_sql_fields['name'] =\n\"'\" . $conn->real_escape_string($_POST['name']) . \"'\";\n}\nif (isset($_POST['description'])) {\n+ $changed_fields['description'] = $_POST['description'];\n$changed_sql_fields['description'] =\n\"'\" . $conn->real_escape_string($_POST['description']) . \"'\";\n}\n@@ -38,9 +42,13 @@ if (isset($_POST['color'])) {\n'error' => 'invalid_parameters',\n));\n}\n+ $changed_fields['color'] = $color;\n$changed_sql_fields['color'] = \"'\" . $color . \"'\";\n}\nif (isset($_POST['edit_rules'])) {\n+ // We don't update $changed_fields here because we haven't figured out how we\n+ // want roles to work with the app yet, and there's no exposed way to change\n+ // the edit rules from the app yet.\n$changed_sql_fields['edit_rules'] = (int)$_POST['edit_rules'];\n}\n@@ -52,12 +60,19 @@ if (isset($_POST['new_password'])) {\n'error' => 'empty_password',\n));\n}\n+ // We don't update $changed_fields here because we don't have\n+ // password-protected threads in the app yet, and I'm probably gonna remove\n+ // that feature from the website altogether.\n$changed_sql_fields['hash'] =\n\"'\" . password_hash($new_password, PASSWORD_BCRYPT) . \"'\";\n}\n$parent_thread_id = null;\nif (isset($_POST['parent_thread_id'])) {\n+ // We haven't really figured out how to handle this sort of thing well yet\n+ async_end(array(\n+ 'error' => 'invalid_parameters',\n+ ));\n$parent_thread_id = (int)$_POST['parent_thread_id'];\nif (!viewer_can_edit_thread($parent_thread_id)) {\nasync_end(array(\n@@ -90,6 +105,7 @@ if (isset($_POST['visibility_rules'])) {\n$changed_sql_fields['hash'] = \"NULL\";\n}\n$changed_sql_fields['visibility_rules'] = $vis_rules;\n+ $changed_fields['visibility_rules'] = $vis_rules;\n}\n$add_member_ids = isset($_POST['add_member_ids'])\n@@ -216,6 +232,34 @@ if ($changed_sql_fields) {\n$conn->query(\"UPDATE threads SET {$sql_set_string} WHERE id = {$thread}\");\n}\n+$time = round(microtime(true) * 1000); // in milliseconds\n+$message_infos = array();\n+foreach ($changed_fields as $field_name => $new_value) {\n+ $message_infos[] = array(\n+ 'type' => MESSAGE_TYPE_CHANGE_SETTINGS,\n+ 'threadID' => (string)$thread,\n+ 'creatorID' => (string)$user,\n+ 'time' => $time,\n+ 'field' => $field_name,\n+ 'value' => $new_value,\n+ );\n+}\n+if ($add_member_ids) {\n+ $message_infos[] = array(\n+ 'type' => MESSAGE_TYPE_ADD_USERS,\n+ 'threadID' => (string)$thread,\n+ 'creatorID' => (string)$user,\n+ 'time' => $time,\n+ 'addedUserIDs' => array_map(\"strval\", $add_member_ids),\n+ );\n+}\n+$new_message_infos = create_message_infos($message_infos);\n+if ($new_message_infos === null) {\n+ async_end(array(\n+ 'error' => 'unknown_error',\n+ ));\n+}\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\nif (\n@@ -289,4 +333,5 @@ create_user_roles($roles_to_save);\nasync_end(array(\n'success' => true,\n+ 'new_message_infos' => $new_message_infos,\n));\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Create messages for edit_thread.php calls |
129,187 | 29.09.2017 18:03:12 | 14,400 | f36ae51a261d40d2a697d6824fa5df1afc5e4c8e | Don't require ROLE_CREATOR for user adds | [
{
"change_type": "MODIFY",
"old_path": "server/edit_thread.php",
"new_path": "server/edit_thread.php",
"diff": "@@ -22,6 +22,11 @@ if (!isset($_POST['thread'])) {\n}\n$user = get_viewer_id();\n$thread = (int)$_POST['thread'];\n+if (!viewer_can_edit_thread($thread)) {\n+ async_end(array(\n+ 'error' => 'invalid_credentials',\n+ ));\n+}\n$changed_fields = array();\n$changed_sql_fields = array();\n@@ -122,13 +127,12 @@ if (!$changed_sql_fields && !$add_member_ids) {\n// - get hash for viewer password check (users table)\n// - figures out if the thread requires auth (threads table)\n// - makes sure that viewer has the necessary permissions (roles table)\n-$role_creator = ROLE_CREATOR;\n$query = <<<SQL\n-SELECT t.visibility_rules, u.hash, t.parent_thread_id\n-FROM roles r\n-LEFT JOIN users u ON u.id = r.user\n-LEFT JOIN threads t ON t.id = r.thread\n-WHERE r.thread = {$thread} AND r.user = {$user} AND r.role >= {$role_creator}\n+SELECT t.visibility_rules, u.hash, t.parent_thread_id, r.role\n+FROM users u\n+LEFT JOIN threads t ON t.id = {$thread}\n+LEFT JOIN roles r ON r.user = u.id AND t.id\n+WHERE u.id = {$user}\nSQL;\n$result = $conn->query($query);\n$row = $result->fetch_assoc();\n@@ -137,6 +141,22 @@ if (!$row || $row['visibility_rules'] === null) {\n'error' => 'internal_error',\n));\n}\n+if (\n+ (\n+ isset($changed_sql_fields['name']) ||\n+ isset($changed_sql_fields['description']) ||\n+ isset($changed_sql_fields['color']) ||\n+ isset($changed_sql_fields['edit_rules']) ||\n+ isset($changed_sql_fields['hash']) ||\n+ isset($changed_sql_fields['parent_thread_id']) ||\n+ isset($changed_sql_fields['visibility_rules'])\n+ ) &&\n+ (int)$row['role'] < ROLE_CREATOR\n+) {\n+ async_end(array(\n+ 'error' => 'invalid_credentials',\n+ ));\n+}\nif (\n(\nisset($changed_sql_fields['edit_rules']) ||\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Don't require ROLE_CREATOR for user adds |
129,187 | 29.09.2017 18:12:21 | 14,400 | 5f1ca19883f94d9181962e5971d839fee2eade1a | Fix some minor errors (type-related) in my scrollToToday() diff earlier today | [
{
"change_type": "MODIFY",
"old_path": "native/calendar/calendar.react.js",
"new_path": "native/calendar/calendar.react.js",
"diff": "@@ -88,7 +88,7 @@ type ExtraData = {\n// But not this particular piece of sadness, actually. We have to cache the\n// current InnerCalendar ref here so we can access it from the statically\n// defined navigationOptions.tabBarOnPress below.\n-const currentCalendarRef: ?InnerCalendar = null;\n+let currentCalendarRef: ?InnerCalendar = null;\ntype Props = {\n// Redux state\n@@ -158,7 +158,7 @@ class InnerCalendar extends React.PureComponent {\nscene: { index: number, focused: bool },\njumpToIndex: (index: number) => void,\n) => {\n- if (scene.focused) {\n+ if (scene.focused && currentCalendarRef) {\ncurrentCalendarRef.scrollToToday();\n} else {\njumpToIndex(scene.index);\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Fix some minor errors (type-related) in my scrollToToday() diff earlier today |
129,187 | 29.09.2017 19:00:43 | 14,400 | 265fa188fc5856ae5a84d0b588a2344e9391254f | RawMessageInfos Redux for CHANGE_THREAD_SETTINGS type and all Redux for ADD_USERS_TO_THREAD | [
{
"change_type": "MODIFY",
"old_path": "lib/actions/thread-actions.js",
"new_path": "lib/actions/thread-actions.js",
"diff": "@@ -30,6 +30,10 @@ async function deleteThread(\nreturn threadID;\n}\n+export type ChangeThreadSettingsResult = {|\n+ threadInfo: ThreadInfo,\n+ newMessageInfos: RawMessageInfo[],\n+|};\nconst changeThreadSettingsActionTypes = {\nstarted: \"CHANGE_THREAD_SETTINGS_STARTED\",\nsuccess: \"CHANGE_THREAD_SETTINGS_SUCCESS\",\n@@ -40,7 +44,7 @@ async function changeThreadSettings(\ncurrentAccountPassword: string,\nnewThreadInfo: ThreadInfo,\nnewThreadPassword: ?string,\n-): Promise<ThreadInfo> {\n+): Promise<ChangeThreadSettingsResult> {\nconst requestData: Object = {\n'personal_password': currentAccountPassword,\n'name': newThreadInfo.name,\n@@ -53,8 +57,31 @@ async function changeThreadSettings(\nif (newThreadPassword !== null && newThreadPassword !== undefined) {\nrequestData.new_password = newThreadPassword;\n}\n- await fetchJSON('edit_thread.php', requestData);\n- return newThreadInfo;\n+ const response = await fetchJSON('edit_thread.php', requestData);\n+ return {\n+ threadInfo: response.thread_info,\n+ newMessageInfos: response.new_message_infos,\n+ };\n+}\n+\n+const addUsersToThreadActionTypes = {\n+ started: \"ADD_USERS_TO_THREAD_STARTED\",\n+ success: \"ADD_USERS_TO_THREAD_SUCCESS\",\n+ failed: \"ADD_USERS_TO_THREAD_FAILED\",\n+};\n+async function addUsersToThread(\n+ fetchJSON: FetchJSON,\n+ threadID: string,\n+ userIDs: string[],\n+): Promise<ChangeThreadSettingsResult> {\n+ const response = await fetchJSON('edit_thread.php', {\n+ 'thread': threadID,\n+ 'add_member_ids': userIDs,\n+ });\n+ return {\n+ threadInfo: response.thread_info,\n+ newMessageInfos: response.new_message_infos,\n+ };\n}\ntype RawCreationInfo = RawThreadCreationInfo | RawSubThreadCreationInfo;\n@@ -163,6 +190,8 @@ export {\ndeleteThread,\nchangeThreadSettingsActionTypes,\nchangeThreadSettings,\n+ addUsersToThreadActionTypes,\n+ addUsersToThread,\nnewThreadActionTypes,\nnewThread,\nnewChatThread,\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/reducers/message-reducer.js",
"new_path": "lib/reducers/message-reducer.js",
"diff": "@@ -83,7 +83,7 @@ function freshMessageStore(\n}\n// oldMessageStore is from the old state\n-// newMessageInfos, truncationStatus, serverTime come from server\n+// newMessageInfos, truncationStatus come from server\n// replaceUnlessUnchanged refers to how we should treat threads that have a\n// MessageTruncationStatus that isn't unchanged. if it's true, we will\n// completely replace what's in the store with what came from the server, but if\n@@ -316,6 +316,22 @@ function reduceMessageStore(\n},\n},\n};\n+ } else if (action.type === \"CHANGE_THREAD_SETTINGS_SUCCESS\") {\n+ return mergeNewMessages(\n+ messageStore,\n+ action.payload.newMessageInfos,\n+ { [action.payload.threadInfo.id]: messageTruncationStatus.UNCHANGED },\n+ null,\n+ false,\n+ );\n+ } else if (action.type === \"ADD_USERS_TO_THREAD_SUCCESS\") {\n+ return mergeNewMessages(\n+ messageStore,\n+ action.payload.newMessageInfos,\n+ { [action.payload.threadInfo.id]: messageTruncationStatus.UNCHANGED },\n+ null,\n+ false,\n+ );\n} else if (action.type === \"JOIN_THREAD_SUCCESS\") {\nreturn mergeNewMessages(\nmessageStore,\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/reducers/thread-reducer.js",
"new_path": "lib/reducers/thread-reducer.js",
"diff": "@@ -33,13 +33,17 @@ export default function reduceThreadInfos(\nreturn state;\n}\nreturn action.payload.threadInfos;\n- } else if (action.type === \"CHANGE_THREAD_SETTINGS_SUCCESS\") {\n- if (_isEqual(state[action.payload.id])(action.payload)) {\n+ } else if (\n+ action.type === \"CHANGE_THREAD_SETTINGS_SUCCESS\" ||\n+ action.type === \"ADD_USERS_TO_THREAD_SUCCESS\"\n+ ) {\n+ const newThreadInfo = action.payload.threadInfo;\n+ if (_isEqual(state[newThreadInfo.id])(newThreadInfo)) {\nreturn state;\n}\nreturn {\n...state,\n- [action.payload.id]: action.payload,\n+ [newThreadInfo.id]: newThreadInfo,\n};\n} else if (action.type === \"NEW_THREAD_SUCCESS\") {\nconst newThreadInfo = action.payload.newThreadInfo;\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/types/redux-types.js",
"new_path": "lib/types/redux-types.js",
"diff": "@@ -14,6 +14,7 @@ import type {\nimport type {\nJoinThreadResult,\nNewThreadResult,\n+ ChangeThreadSettingsResult,\n} from '../actions/thread-actions';\nimport type {\nPingStartingPayload,\n@@ -228,7 +229,7 @@ export type BaseAction =\nloadingInfo: LoadingInfo,\n|} | {|\ntype: \"CHANGE_THREAD_SETTINGS_SUCCESS\",\n- payload: ThreadInfo,\n+ payload: ChangeThreadSettingsResult,\nloadingInfo: LoadingInfo,\n|} | {|\ntype: \"DELETE_THREAD_STARTED\",\n@@ -254,6 +255,18 @@ export type BaseAction =\ntype: \"NEW_THREAD_SUCCESS\",\npayload: NewThreadResult,\nloadingInfo: LoadingInfo,\n+ |} | {|\n+ type: \"ADD_USERS_TO_THREAD_STARTED\",\n+ loadingInfo: LoadingInfo,\n+ |} | {|\n+ type: \"ADD_USERS_TO_THREAD_FAILED\",\n+ error: true,\n+ payload: Error,\n+ loadingInfo: LoadingInfo,\n+ |} | {|\n+ type: \"ADD_USERS_TO_THREAD_SUCCESS\",\n+ payload: ChangeThreadSettingsResult,\n+ loadingInfo: LoadingInfo,\n|} | {|\ntype: \"FETCH_REVISIONS_FOR_ENTRY_STARTED\",\nloadingInfo: LoadingInfo,\n"
},
{
"change_type": "MODIFY",
"old_path": "server/edit_thread.php",
"new_path": "server/edit_thread.php",
"diff": "@@ -351,7 +351,10 @@ if ($add_member_ids && $next_vis_rules === VISIBILITY_NESTED_OPEN) {\n}\ncreate_user_roles($roles_to_save);\n+$thread_infos = get_thread_infos(\"t.id = {$thread}\");\n+\nasync_end(array(\n'success' => true,\n'new_message_infos' => $new_message_infos,\n+ 'thread_info' => $thread_infos[$thread],\n));\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | RawMessageInfos Redux for CHANGE_THREAD_SETTINGS type and all Redux for ADD_USERS_TO_THREAD |
129,187 | 29.09.2017 20:27:08 | 14,400 | 5b67ffc3365a97f4a30f2cdb3853fc692eb4f061 | Factor out getUserSearchResults | [
{
"change_type": "ADD",
"old_path": null,
"new_path": "lib/shared/search-utils.js",
"diff": "+// @flow\n+\n+import type { UserInfo } from 'lib/types/user-types';\n+import SearchIndex from 'lib/shared/search-index';\n+\n+function getUserSearchResults(\n+ text: string,\n+ userInfos: {[id: string]: UserInfo},\n+ searchIndex: SearchIndex,\n+ excludeUserIDs: $ReadOnlyArray<string>,\n+) {\n+ const results = [];\n+ const appendUserInfo = (userInfo: UserInfo) => {\n+ if (!excludeUserIDs.includes(userInfo.id)) {\n+ results.push(userInfo);\n+ }\n+ };\n+ if (text === \"\") {\n+ for (let id in userInfos) {\n+ appendUserInfo(userInfos[id]);\n+ }\n+ } else {\n+ const ids = searchIndex.getSearchResults(text);\n+ for (let id of ids) {\n+ appendUserInfo(userInfos[id]);\n+ }\n+ }\n+ return results;\n+}\n+\n+export {\n+ getUserSearchResults,\n+};\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/add-thread.react.js",
"new_path": "native/chat/add-thread.react.js",
"diff": "@@ -52,9 +52,10 @@ import {\n} from 'lib/selectors/user-selectors';\nimport SearchIndex from 'lib/shared/search-index';\nimport { generateRandomColor } from 'lib/shared/thread-utils';\n+import { getUserSearchResults } from 'lib/shared/search-utils';\n+\nimport ColorPicker from '../components/color-picker.react';\nimport ColorSplotch from '../components/color-splotch.react';\n-\nimport TagInput from '../components/tag-input.react';\nimport UserList from '../components/user-list.react';\nimport LinkButton from '../components/link-button.react';\n@@ -132,50 +133,9 @@ class InnerAddThread extends React.PureComponent {\nmounted = false;\nnameInput: ?TextInput;\n- static getUserSearchResults(\n- text: string,\n- userInfos: {[id: string]: UserInfo},\n- searchIndex: SearchIndex,\n- userInfoInputArray: $ReadOnlyArray<UserInfo>,\n- ) {\n- const results = [];\n- const appendUserInfo = (userInfo: UserInfo) => {\n- const alreadyExists = InnerAddThread.inputArrayContainsUserID(\n- userInfoInputArray,\n- userInfo.id,\n- );\n- if (!alreadyExists) {\n- results.push(userInfo);\n- }\n- };\n- if (text === \"\") {\n- for (let id in userInfos) {\n- appendUserInfo(userInfos[id]);\n- }\n- } else {\n- const ids = searchIndex.getSearchResults(text);\n- for (let id of ids) {\n- appendUserInfo(userInfos[id]);\n- }\n- }\n- return results;\n- }\n-\n- static inputArrayContainsUserID(\n- userInfoInputArray: $ReadOnlyArray<UserInfo>,\n- userID: string,\n- ) {\n- for (let existingUserInfo of userInfoInputArray) {\n- if (userID === existingUserInfo.id) {\n- return true;\n- }\n- }\n- return false;\n- }\n-\nconstructor(props: Props) {\nsuper(props);\n- const userSearchResults = InnerAddThread.getUserSearchResults(\n+ const userSearchResults = getUserSearchResults(\n\"\",\nprops.otherUserInfos,\nprops.userSearchIndex,\n@@ -215,11 +175,11 @@ class InnerAddThread extends React.PureComponent {\nthis.props.otherUserInfos !== nextProps.otherUserInfos ||\nthis.props.userSearchIndex !== nextProps.userSearchIndex\n) {\n- const userSearchResults = InnerAddThread.getUserSearchResults(\n+ const userSearchResults = getUserSearchResults(\nthis.state.usernameInputText,\nnextProps.otherUserInfos,\nnextProps.userSearchIndex,\n- this.state.userInfoInputArray,\n+ this.state.userInfoInputArray.map(userInfo => userInfo.id),\n);\nthis.setState({ userSearchResults });\n}\n@@ -368,11 +328,11 @@ class InnerAddThread extends React.PureComponent {\n}\nonChangeTagInput = (userInfoInputArray: $ReadOnlyArray<UserInfo>) => {\n- const userSearchResults = InnerAddThread.getUserSearchResults(\n+ const userSearchResults = getUserSearchResults(\nthis.state.usernameInputText,\nthis.props.otherUserInfos,\nthis.props.userSearchIndex,\n- userInfoInputArray,\n+ userInfoInputArray.map(userInfo => userInfo.id),\n);\nthis.setState({ userInfoInputArray, userSearchResults });\n}\n@@ -384,11 +344,11 @@ class InnerAddThread extends React.PureComponent {\n}\nsetUsernameInputText = (text: string) => {\n- const userSearchResults = InnerAddThread.getUserSearchResults(\n+ const userSearchResults = getUserSearchResults(\ntext,\nthis.props.otherUserInfos,\nthis.props.userSearchIndex,\n- this.state.userInfoInputArray,\n+ this.state.userInfoInputArray.map(userInfo => userInfo.id),\n);\nthis.searchUsers(text);\nthis.setState({ usernameInputText: text, userSearchResults });\n@@ -402,22 +362,20 @@ class InnerAddThread extends React.PureComponent {\n}\nonUserSelect = (userID: string) => {\n- const alreadyExists = InnerAddThread.inputArrayContainsUserID(\n- this.state.userInfoInputArray,\n- userID,\n- );\n- if (alreadyExists) {\n+ for (let existingUserInfo of this.state.userInfoInputArray) {\n+ if (userID === existingUserInfo.id) {\nreturn;\n}\n+ }\nconst userInfoInputArray = [\n...this.state.userInfoInputArray,\nthis.props.otherUserInfos[userID],\n];\n- const userSearchResults = InnerAddThread.getUserSearchResults(\n+ const userSearchResults = getUserSearchResults(\n\"\",\nthis.props.otherUserInfos,\nthis.props.userSearchIndex,\n- userInfoInputArray,\n+ userInfoInputArray.map(userInfo => userInfo.id),\n);\nthis.setState({\nuserInfoInputArray,\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Factor out getUserSearchResults |
129,187 | 30.09.2017 13:38:04 | 14,400 | c87c383c9eaa531a244bb0c30dc8c7337f6ba1fa | Add react-native-modal and switch ThreadPicker to using it | [
{
"change_type": "MODIFY",
"old_path": "native/calendar/calendar.react.js",
"new_path": "native/calendar/calendar.react.js",
"diff": "@@ -50,6 +50,7 @@ import {\n} from 'lib/utils/action-utils';\nimport { simpleNavID } from 'lib/selectors/nav-selectors';\nimport { registerFetchKey } from 'lib/reducers/loading-reducer';\n+import Modal from 'react-native-modal';\nimport Entry from './entry.react';\nimport { contentVerticalOffset, windowHeight } from '../dimensions';\n@@ -661,15 +662,6 @@ class InnerCalendar extends React.PureComponent {\n</View>\n);\n}\n- let picker = null;\n- if (this.state.pickerOpenForDateString) {\n- picker = (\n- <ThreadPicker\n- dateString={this.state.pickerOpenForDateString}\n- close={this.closePicker}\n- />\n- );\n- }\nreturn (\n<View style={styles.container}>\n<ConnectedStatusBar />\n@@ -680,7 +672,16 @@ class InnerCalendar extends React.PureComponent {\n/>\n{loadingIndicator}\n{flatList}\n- {picker}\n+ <Modal\n+ isVisible={!!this.state.pickerOpenForDateString}\n+ onBackButtonPress={this.closePicker}\n+ onBackdropPress={this.closePicker}\n+ >\n+ <ThreadPicker\n+ dateString={this.state.pickerOpenForDateString}\n+ close={this.closePicker}\n+ />\n+ </Modal>\n</View>\n);\n}\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,6 @@ class ThreadPickerThread extends React.PureComponent {\nreturn (\n<Button\nonPress={this.onPress}\n- androidBorderlessRipple={true}\niosFormat=\"highlight\"\niosActiveOpacity={0.85}\n>\n"
},
{
"change_type": "MODIFY",
"old_path": "native/calendar/thread-picker.react.js",
"new_path": "native/calendar/thread-picker.react.js",
"diff": "@@ -11,7 +11,6 @@ import {\nView,\nText,\nStyleSheet,\n- TouchableWithoutFeedback,\nFlatList,\nTouchableHighlight,\n} from 'react-native';\n@@ -31,7 +30,7 @@ import ThreadPickerThread from './thread-picker-thread.react';\nclass ThreadPicker extends React.PureComponent {\nprops: {\n- dateString: string,\n+ dateString: ?string,\nclose: () => void,\n// Redux state\nonScreenThreadInfos: $ReadOnlyArray<ThreadInfo>,\n@@ -40,7 +39,7 @@ class ThreadPicker extends React.PureComponent {\ndispatchActionPayload: DispatchActionPayload,\n};\nstatic propTypes = {\n- dateString: PropTypes.string.isRequired,\n+ dateString: PropTypes.string,\nclose: PropTypes.func.isRequired,\nonScreenThreadInfos: PropTypes.arrayOf(threadInfoPropType).isRequired,\nviewerID: PropTypes.string.isRequired,\n@@ -49,10 +48,6 @@ class ThreadPicker extends React.PureComponent {\nrender() {\nreturn (\n- <View style={styles.background}>\n- <TouchableWithoutFeedback onPress={this.props.close}>\n- <View style={styles.container} />\n- </TouchableWithoutFeedback>\n<View style={styles.picker}>\n<View style={styles.header}>\n<Text style={styles.headerText}>\n@@ -80,7 +75,6 @@ class ThreadPicker extends React.PureComponent {\nstyle={styles.contents}\n/>\n</View>\n- </View>\n);\n}\n@@ -107,30 +101,17 @@ class ThreadPicker extends React.PureComponent {\nthreadPicked = (threadID: string) => {\nthis.props.close();\n+ const dateString = this.props.dateString;\n+ invariant(dateString, \"should be set\");\nthis.props.dispatchActionPayload(\ncreateLocalEntryActionType,\n- createLocalEntry(threadID, this.props.dateString, this.props.viewerID),\n+ createLocalEntry(threadID, dateString, this.props.viewerID),\n);\n}\n}\nconst styles = StyleSheet.create({\n- background: {\n- position: 'absolute',\n- top: 0,\n- bottom: 0,\n- left: 0,\n- right: 0,\n- backgroundColor: '#CCCCCCAA',\n- },\n- container: {\n- position: 'absolute',\n- top: 0,\n- bottom: 0,\n- left: 0,\n- right: 0,\n- },\npicker: {\nflex: 1,\nmarginLeft: 15,\n"
},
{
"change_type": "MODIFY",
"old_path": "native/package-lock.json",
"new_path": "native/package-lock.json",
"diff": "}\n}\n},\n+ \"react-native-animatable\": {\n+ \"version\": \"1.2.4\",\n+ \"resolved\": \"https://registry.npmjs.org/react-native-animatable/-/react-native-animatable-1.2.4.tgz\",\n+ \"integrity\": \"sha512-cVTQXa/cp8gfxcl+l6I1rGAI7EeoNZ0ur9vtxb3tD5iGlJbIyUfQK61e6BycnZewdgQ639Mp6OrueXTpZlv76Q==\",\n+ \"requires\": {\n+ \"prop-types\": \"15.5.10\"\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\"resolved\": \"https://registry.npmjs.org/react-native-keychain/-/react-native-keychain-1.2.1.tgz\",\n\"integrity\": \"sha512-EDTKVFHKkNHlHCt+ZISQBP6/fCx711s49iIBqBjYZP0Qryr1skRf+2PL6+YmxmGlP+P3Jf2LD+wSBKdfpuGXfA==\"\n},\n+ \"react-native-modal\": {\n+ \"version\": \"4.0.0\",\n+ \"resolved\": \"https://registry.npmjs.org/react-native-modal/-/react-native-modal-4.0.0.tgz\",\n+ \"integrity\": \"sha512-GadODA8RXR5QOH+pvlMws0uppIoJf1SN2Bw57rYSGMSOnKyT513MzjGXCHOlDOj2aEclT83s4nVam6MZOxhcLg==\",\n+ \"requires\": {\n+ \"prop-types\": \"15.5.10\",\n+ \"react-native-animatable\": \"1.2.4\"\n+ }\n+ },\n\"react-native-onepassword\": {\n\"version\": \"1.0.4\",\n\"resolved\": \"https://registry.npmjs.org/react-native-onepassword/-/react-native-onepassword-1.0.4.tgz\",\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.48.3\",\n\"react-native-keychain\": \"^1.2.1\",\n+ \"react-native-modal\": \"^4.0.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-vector-icons\": \"^4.3.0\",\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Add react-native-modal and switch ThreadPicker to using it |
129,187 | 30.09.2017 13:43:58 | 14,400 | 987db3d3e56161592c2b906155eb1781c28afb71 | ConnectedStatusBar in the whole app (not just Calendar) now | [
{
"change_type": "MODIFY",
"old_path": "native/app.react.js",
"new_path": "native/app.react.js",
"diff": "@@ -22,6 +22,8 @@ import {\nUIManager,\nAppState as NativeAppState,\nLinking,\n+ View,\n+ StyleSheet,\n} from 'react-native';\nimport { addNavigationHelpers } from 'react-navigation';\nimport invariant from 'invariant';\n@@ -39,6 +41,7 @@ import { RootNavigator } from './navigation-setup';\nimport { store } from './redux-setup';\nimport { resolveInvalidatedCookie } from './account/native-credentials';\nimport { pingNativeStartingPayload } from './selectors/ping-selectors';\n+import ConnectedStatusBar from './connected-status-bar.react';\nlet urlPrefix;\nif (!__DEV__) {\n@@ -197,11 +200,22 @@ class AppWithNavigationState extends React.PureComponent {\ndispatch: this.props.dispatch,\nstate: this.props.navigationState,\n});\n- return <RootNavigator navigation={navigation} />;\n+ return (\n+ <View style={styles.app}>\n+ <RootNavigator navigation={navigation} />\n+ <ConnectedStatusBar />\n+ </View>\n+ );\n}\n}\n+const styles = StyleSheet.create({\n+ app: {\n+ flex: 1,\n+ },\n+});\n+\nconst ConnectedAppWithNavigationState = connect(\n(state: AppState) => ({\ncookie: state.cookie,\n"
},
{
"change_type": "MODIFY",
"old_path": "native/calendar/calendar.react.js",
"new_path": "native/calendar/calendar.react.js",
"diff": "@@ -60,7 +60,6 @@ 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@@ -664,7 +663,6 @@ class InnerCalendar extends React.PureComponent {\n}\nreturn (\n<View style={styles.container}>\n- <ConnectedStatusBar />\n<TextHeightMeasurer\ntextToMeasure={this.state.textToMeasure}\nallHeightsMeasuredCallback={this.allHeightsMeasured}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | ConnectedStatusBar in the whole app (not just Calendar) now |
129,187 | 02.10.2017 16:44:02 | 14,400 | fffb24d04d5a281860ea854adf4f224d15dc639a | Fix loading-selector tracking key logic to match loading-reducer | [
{
"change_type": "MODIFY",
"old_path": "lib/selectors/loading-selectors.js",
"new_path": "lib/selectors/loading-selectors.js",
"diff": "@@ -8,6 +8,7 @@ import { createSelector } from 'reselect';\nimport _isEmpty from 'lodash/fp/isEmpty';\nimport _includes from 'lodash/fp/includes';\nimport _memoize from 'lodash/memoize';\n+import invariant from 'invariant';\nimport { registerFetchKey } from '../reducers/loading-reducer';\n@@ -23,14 +24,29 @@ function loadingStatusFromInfo(\n}\n}\n+// This is the key used to store the Promise state in Redux\n+function getTrackingKey(\n+ actionTypes: ActionTypes<*, *, *>,\n+ overrideKey?: string,\n+) {\n+ if (overrideKey) {\n+ return overrideKey;\n+ }\n+ const startMatch = actionTypes.started.match(/(.*)_STARTED/);\n+ invariant(\n+ startMatch && startMatch[1],\n+ \"actionTypes.started should always end with _STARTED\",\n+ );\n+ return startMatch[1];\n+}\n+\nconst baseCreateLoadingStatusSelector = (\nactionTypes: ActionTypes<*, *, *>,\noverrideKey?: string,\n) => {\n// This makes sure that reduceLoadingStatuses tracks this action\nregisterFetchKey(actionTypes);\n- // This is the key used to store the Promise state in Redux\n- const trackingKey = overrideKey ? overrideKey : actionTypes.started;\n+ const trackingKey = getTrackingKey(actionTypes, overrideKey);\nreturn createSelector(\n(state: BaseAppState) => state.loadingStatuses[trackingKey],\n(loadingStatusInfo: {[idx: number]: LoadingStatus}) =>\n@@ -40,8 +56,7 @@ const baseCreateLoadingStatusSelector = (\nconst createLoadingStatusSelector = _memoize(\nbaseCreateLoadingStatusSelector,\n- (actionTypes: ActionTypes<*, *, *>, overrideKey: ?string) =>\n- overrideKey ? overrideKey : actionTypes.started,\n+ getTrackingKey,\n);\nconst globalLoadingStatusSelector = createSelector(\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Fix loading-selector tracking key logic to match loading-reducer |
129,187 | 02.10.2017 16:45:39 | 14,400 | 9d8c15242190e1013a87541acc86a6a6bebcca81 | Lift margin out of UserList, add loadingStatusPropType, and registerFetchKey(searchUsersActionTypes) | [
{
"change_type": "MODIFY",
"old_path": "lib/types/loading-types.js",
"new_path": "lib/types/loading-types.js",
"diff": "// @flow\n+import PropTypes from 'prop-types';\n+\nexport type LoadingStatus = \"inactive\" | \"loading\" | \"error\";\n+export const loadingStatusPropType = PropTypes.oneOf([\n+ \"inactive\",\n+ \"loading\",\n+ \"error\",\n+]);\n+\nexport type LoadingOptions = {|\ntrackMultipleRequests?: bool,\ncustomKeyName?: string,\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/add-thread.react.js",
"new_path": "native/chat/add-thread.react.js",
"diff": "@@ -7,6 +7,7 @@ import type {\n} from 'react-navigation/src/TypeDefinition';\nimport type { AppState } from '../redux-setup';\nimport type { LoadingStatus } from 'lib/types/loading-types';\n+import { loadingStatusPropType } from 'lib/types/loading-types';\nimport type { ThreadInfo, VisibilityRules } from 'lib/types/thread-types';\nimport { threadInfoPropType, visibilityRules } from 'lib/types/thread-types';\nimport type { UserInfo } from 'lib/types/user-types';\n@@ -53,6 +54,7 @@ import {\nimport SearchIndex from 'lib/shared/search-index';\nimport { generateRandomColor } from 'lib/shared/thread-utils';\nimport { getUserSearchResults } from 'lib/shared/search-utils';\n+import { registerFetchKey } from 'lib/reducers/loading-reducer';\nimport ColorPicker from '../components/color-picker.react';\nimport ColorSplotch from '../components/color-splotch.react';\n@@ -110,7 +112,7 @@ class InnerAddThread extends React.PureComponent {\ngoBack: PropTypes.func.isRequired,\nnavigate: PropTypes.func.isRequired,\n}).isRequired,\n- loadingStatus: PropTypes.string.isRequired,\n+ loadingStatus: loadingStatusPropType.isRequired,\nparentThreadInfo: threadInfoPropType,\notherUserInfos: PropTypes.objectOf(userInfoPropType).isRequired,\nuserSearchIndex: PropTypes.instanceOf(SearchIndex).isRequired,\n@@ -299,10 +301,12 @@ class InnerAddThread extends React.PureComponent {\n/>\n</View>\n</View>\n+ <View style={styles.userList}>\n<UserList\nuserInfos={this.state.userSearchResults}\nonSelect={this.onUserSelect}\n/>\n+ </View>\n{colorPicker}\n</View>\n);\n@@ -572,12 +576,17 @@ const styles = StyleSheet.create({\nposition: 'absolute',\nleft: 3,\n},\n+ userList: {\n+ marginLeft: 88,\n+ marginRight: 12,\n+ },\n});\nconst AddThreadRouteName = 'AddThread';\nconst loadingStatusSelector\n= createLoadingStatusSelector(newThreadActionTypes);\n+registerFetchKey(searchUsersActionTypes);\nconst AddThread = connect(\n(state: AppState, ownProps: { navigation: NavProp }) => {\n"
},
{
"change_type": "MODIFY",
"old_path": "native/components/user-list.react.js",
"new_path": "native/components/user-list.react.js",
"diff": "@@ -5,10 +5,7 @@ import { userInfoPropType } from 'lib/types/user-types';\nimport React from 'react';\nimport PropTypes from 'prop-types';\n-import {\n- FlatList,\n- StyleSheet,\n-} from 'react-native';\n+import { FlatList } from 'react-native';\nimport UserListUser from './user-list-user.react';\n@@ -31,7 +28,6 @@ class UserList extends React.PureComponent {\nkeyExtractor={UserList.keyExtractor}\ngetItemLayout={UserList.getItemLayout}\nkeyboardShouldPersistTaps=\"handled\"\n- style={styles.flatList}\n/>\n);\n}\n@@ -55,11 +51,4 @@ class UserList extends React.PureComponent {\n}\n-const styles = StyleSheet.create({\n- flatList: {\n- marginLeft: 88,\n- marginRight: 12,\n- },\n-});\n-\nexport default UserList;\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Lift margin out of UserList, add loadingStatusPropType, and registerFetchKey(searchUsersActionTypes) |
129,187 | 02.10.2017 16:54:59 | 14,400 | 048bd8b8217695938d979c2b9d6f2f378cf9d6e8 | Add minHeight, defaultInputWidth to TagInput | [
{
"change_type": "MODIFY",
"old_path": "native/components/tag-input.react.js",
"new_path": "native/components/tag-input.react.js",
"diff": "@@ -33,7 +33,9 @@ const defaultProps = {\ntagColor: '#dddddd',\ntagTextColor: '#777777',\ninputColor: '#777777',\n+ minHeight: 27,\nmaxHeight: 75,\n+ defaultInputWidth: 90,\n};\nconst tagDataPropType = PropTypes.oneOfType([\n@@ -63,10 +65,16 @@ type Props<TagData> = {\ninputProps?: $PropertyType<Text, 'props'>,\n// path of the label in tags objects\nlabelExtractor?: (tagData: TagData) => string,\n+ // minimum height of this component\n+ minHeight: number,\n// maximum height of this component\nmaxHeight: number,\n// callback that gets triggered when the component height changes\n- onHeightChange: ?(height: number) => void,\n+ onHeightChange?: (height: number) => void,\n+ // inputWidth if text === \"\". we want this number explicitly because if we're\n+ // forced to measure the component, there can be a short jump between the old\n+ // value and the new value, which looks sketchy.\n+ defaultInputWidth: number,\n};\ntype State = {\ninputWidth: number,\n@@ -90,14 +98,13 @@ class TagInput<TagData> extends React.PureComponent<\ninputColor: PropTypes.string,\ninputProps: PropTypes.object,\nlabelExtractor: PropTypes.func,\n+ minHeight: PropTypes.number,\nmaxHeight: PropTypes.number,\nonHeightChange: PropTypes.func,\n+ defaultInputWidth: PropTypes.number,\n};\nprops: Props<TagData>;\n- state: State = {\n- inputWidth: 90,\n- wrapperHeight: 36,\n- };\n+ state: State;\nwrapperWidth = windowWidth;\nspaceLeft = 0;\n// scroll to bottom\n@@ -109,9 +116,14 @@ class TagInput<TagData> extends React.PureComponent<\nstatic defaultProps = defaultProps;\n- static inputWidth(text: string, spaceLeft: number, wrapperWidth: number) {\n+ static inputWidth(\n+ text: string,\n+ spaceLeft: number,\n+ wrapperWidth: number,\n+ defaultInputWidth: number,\n+ ) {\nif (text === \"\") {\n- return 90;\n+ return defaultInputWidth;\n} else if (spaceLeft >= 100) {\nreturn spaceLeft - 10;\n} else {\n@@ -119,18 +131,30 @@ class TagInput<TagData> extends React.PureComponent<\n}\n}\n+ constructor(props: Props<TagData>) {\n+ super(props);\n+ this.state = {\n+ inputWidth: props.defaultInputWidth,\n+ wrapperHeight: 36,\n+ };\n+ }\n+\ncomponentWillReceiveProps(nextProps: Props<TagData>) {\nconst inputWidth = TagInput.inputWidth(\nnextProps.text,\nthis.spaceLeft,\nthis.wrapperWidth,\n+ nextProps.defaultInputWidth,\n);\nif (inputWidth !== this.state.inputWidth) {\nthis.setState({ inputWidth });\n}\n- const wrapperHeight = Math.min(\n+ const wrapperHeight = Math.max(\n+ Math.min(\nnextProps.maxHeight,\nthis.contentHeight,\n+ ),\n+ nextProps.minHeight,\n);\nif (wrapperHeight !== this.state.wrapperHeight) {\nthis.setState({ wrapperHeight });\n@@ -152,6 +176,7 @@ class TagInput<TagData> extends React.PureComponent<\nthis.props.text,\nthis.spaceLeft,\nthis.wrapperWidth,\n+ this.props.defaultInputWidth,\n);\nif (inputWidth !== this.state.inputWidth) {\nthis.setState({ inputWidth });\n@@ -276,7 +301,10 @@ class TagInput<TagData> extends React.PureComponent<\nif (this.contentHeight === h) {\nreturn;\n}\n- const nextWrapperHeight = Math.min(this.props.maxHeight, h);\n+ const nextWrapperHeight = Math.max(\n+ Math.min(this.props.maxHeight, h),\n+ this.props.minHeight,\n+ );\nif (nextWrapperHeight !== this.state.wrapperHeight) {\nthis.setState(\n{ wrapperHeight: nextWrapperHeight },\n@@ -301,6 +329,7 @@ class TagInput<TagData> extends React.PureComponent<\nthis.props.text,\nthis.spaceLeft,\nthis.wrapperWidth,\n+ this.props.defaultInputWidth,\n);\nif (inputWidth !== this.state.inputWidth) {\nthis.setState({ inputWidth });\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Add minHeight, defaultInputWidth to TagInput |
129,187 | 02.10.2017 17:12:07 | 14,400 | 61136d46da1f93a09db6e2fe84f0298fe30b8051 | Make sure edit_thread.php returns ThreadInfo correctly | [
{
"change_type": "MODIFY",
"old_path": "server/edit_thread.php",
"new_path": "server/edit_thread.php",
"diff": "@@ -351,7 +351,7 @@ if ($add_member_ids && $next_vis_rules === VISIBILITY_NESTED_OPEN) {\n}\ncreate_user_roles($roles_to_save);\n-$thread_infos = get_thread_infos(\"t.id = {$thread}\");\n+list($thread_infos, $thread_users) = get_thread_infos(\"t.id = {$thread}\");\nasync_end(array(\n'success' => true,\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Make sure edit_thread.php returns ThreadInfo correctly |
129,187 | 02.10.2017 17:20:31 | 14,400 | 86d19260299f5c3b548696b0bc1e761b6e1050af | Working AddUsersModal for adding users to a thread | [
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/chat/settings/add-users-modal.react.js",
"diff": "+// @flow\n+\n+import type { AppState } from '../../redux-setup';\n+import type { ThreadInfo } from 'lib/types/thread-types';\n+import { threadInfoPropType } from 'lib/types/thread-types';\n+import type { UserInfo } from 'lib/types/user-types';\n+import { userInfoPropType } from 'lib/types/user-types';\n+import type { DispatchActionPromise } from 'lib/utils/action-utils';\n+import type { ChangeThreadSettingsResult } from 'lib/actions/thread-actions';\n+import type { SearchUsersResult } from 'lib/actions/user-actions';\n+import type { LoadingStatus } from 'lib/types/loading-types';\n+import { loadingStatusPropType } from 'lib/types/loading-types';\n+\n+import React from 'react';\n+import {\n+ View,\n+ StyleSheet,\n+ Platform,\n+ KeyboardAvoidingView,\n+ Text,\n+ ActivityIndicator,\n+ Alert,\n+} from 'react-native';\n+import { connect } from 'react-redux';\n+import PropTypes from 'prop-types';\n+import invariant from 'invariant';\n+\n+import {\n+ userInfoSelectorForOtherMembersOfThread,\n+ userSearchIndexForOtherMembersOfThread,\n+} from 'lib/selectors/user-selectors';\n+import SearchIndex from 'lib/shared/search-index';\n+import { getUserSearchResults } from 'lib/shared/search-utils';\n+import {\n+ includeDispatchActionProps,\n+ bindServerCalls,\n+} from 'lib/utils/action-utils';\n+import {\n+ addUsersToThreadActionTypes,\n+ addUsersToThread,\n+} from 'lib/actions/thread-actions';\n+import {\n+ searchUsersActionTypes,\n+ searchUsers,\n+} from 'lib/actions/user-actions';\n+import { createLoadingStatusSelector } from 'lib/selectors/loading-selectors';\n+import { registerFetchKey } from 'lib/reducers/loading-reducer';\n+\n+import UserList from '../../components/user-list.react';\n+import TagInput from '../../components/tag-input.react';\n+import Button from '../../components/button.react';\n+\n+const tagInputProps = {\n+ placeholder: \"Select users to add\",\n+ autoFocus: true,\n+};\n+\n+type Props = {\n+ threadInfo: ThreadInfo,\n+ close: () => void,\n+ // Redux state\n+ otherUserInfos: {[id: string]: UserInfo},\n+ userSearchIndex: SearchIndex,\n+ addUsersLoadingStatus: LoadingStatus,\n+ // Redux dispatch functions\n+ dispatchActionPromise: DispatchActionPromise,\n+ // async functions that hit server APIs\n+ addUsersToThread: (\n+ threadID: string,\n+ userIDs: string[],\n+ ) => Promise<ChangeThreadSettingsResult>,\n+ searchUsers: (usernamePrefix: string) => Promise<SearchUsersResult>,\n+};\n+type State = {|\n+ userSearchResults: $ReadOnlyArray<UserInfo>,\n+ usernameInputText: string,\n+ userInfoInputArray: $ReadOnlyArray<UserInfo>,\n+|};\n+class AddUsersModal extends React.PureComponent {\n+\n+ props: Props;\n+ state: State;\n+ static propTypes = {\n+ threadInfo: threadInfoPropType.isRequired,\n+ close: PropTypes.func.isRequired,\n+ otherUserInfos: PropTypes.objectOf(userInfoPropType).isRequired,\n+ userSearchIndex: PropTypes.instanceOf(SearchIndex).isRequired,\n+ addUsersLoadingStatus: loadingStatusPropType.isRequired,\n+ dispatchActionPromise: PropTypes.func.isRequired,\n+ addUsersToThread: PropTypes.func.isRequired,\n+ searchUsers: PropTypes.func.isRequired,\n+ };\n+ mounted = false;\n+ tagInput: ?TagInput<UserInfo> = null;\n+\n+ constructor(props: Props) {\n+ super(props);\n+ const userSearchResults = AddUsersModal.getSearchResults(\n+ \"\",\n+ props.otherUserInfos,\n+ props.userSearchIndex,\n+ [],\n+ props.threadInfo,\n+ );\n+ this.state = {\n+ userSearchResults,\n+ usernameInputText: \"\",\n+ userInfoInputArray: [],\n+ }\n+ }\n+\n+ static getSearchResults(\n+ text: string,\n+ userInfos: {[id: string]: UserInfo},\n+ searchIndex: SearchIndex,\n+ userInfoInputArray: $ReadOnlyArray<UserInfo>,\n+ threadInfo: ThreadInfo,\n+ ) {\n+ const excludeUserIDs = userInfoInputArray\n+ .map(userInfo => userInfo.id)\n+ .concat(threadInfo.memberIDs);\n+ return getUserSearchResults(\n+ text,\n+ userInfos,\n+ searchIndex,\n+ excludeUserIDs,\n+ );\n+ }\n+\n+ componentDidMount() {\n+ this.mounted = true;\n+ this.searchUsers(\"\");\n+ }\n+\n+ searchUsers(usernamePrefix: string) {\n+ this.props.dispatchActionPromise(\n+ searchUsersActionTypes,\n+ this.props.searchUsers(usernamePrefix),\n+ );\n+ }\n+\n+ componentWillUnmount() {\n+ this.mounted = false;\n+ }\n+\n+ componentWillReceiveProps(nextProps: Props) {\n+ if (!this.mounted) {\n+ return;\n+ }\n+ if (\n+ this.props.otherUserInfos !== nextProps.otherUserInfos ||\n+ this.props.userSearchIndex !== nextProps.userSearchIndex ||\n+ this.props.threadInfo !== nextProps.threadInfo\n+ ) {\n+ const userSearchResults = AddUsersModal.getSearchResults(\n+ this.state.usernameInputText,\n+ nextProps.otherUserInfos,\n+ nextProps.userSearchIndex,\n+ this.state.userInfoInputArray,\n+ nextProps.threadInfo,\n+ );\n+ this.setState({ userSearchResults });\n+ }\n+ }\n+\n+ render() {\n+ let addButton = null;\n+ const inputLength = this.state.userInfoInputArray.length;\n+ if (inputLength > 0) {\n+ let activityIndicator = null;\n+ if (this.props.addUsersLoadingStatus === \"loading\") {\n+ activityIndicator = (\n+ <View style={styles.activityIndicator}>\n+ <ActivityIndicator color=\"#555\" />\n+ </View>\n+ );\n+ }\n+ const addButtonText = `Add (${inputLength})`;\n+ addButton = (\n+ <Button\n+ onPress={this.onPressAdd}\n+ style={styles.addButton}\n+ disabled={this.props.addUsersLoadingStatus === \"loading\"}\n+ >\n+ {activityIndicator}\n+ <Text style={styles.addText}>{addButtonText}</Text>\n+ </Button>\n+ );\n+ }\n+\n+ let cancelButton;\n+ if (this.props.addUsersLoadingStatus !== \"loading\") {\n+ cancelButton = (\n+ <Button onPress={this.props.close} style={styles.cancelButton}>\n+ <Text style={styles.cancelText}>Cancel</Text>\n+ </Button>\n+ );\n+ } else {\n+ cancelButton = (\n+ <View />\n+ );\n+ }\n+\n+ const content = (\n+ <View style={styles.modal}>\n+ <TagInput\n+ onChange={this.onChangeTagInput}\n+ value={this.state.userInfoInputArray}\n+ text={this.state.usernameInputText}\n+ setText={this.setUsernameInputText}\n+ labelExtractor={this.tagDataLabelExtractor}\n+ defaultInputWidth={160}\n+ maxHeight={36}\n+ inputProps={tagInputProps}\n+ ref={this.tagInputRef}\n+ />\n+ <UserList\n+ userInfos={this.state.userSearchResults}\n+ onSelect={this.onUserSelect}\n+ />\n+ <View style={styles.buttons}>\n+ {cancelButton}\n+ {addButton}\n+ </View>\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+ }\n+\n+ tagInputRef = (tagInput: ?TagInput<UserInfo>) => {\n+ this.tagInput = tagInput;\n+ }\n+\n+ onChangeTagInput = (userInfoInputArray: $ReadOnlyArray<UserInfo>) => {\n+ if (this.props.addUsersLoadingStatus === \"loading\") {\n+ return;\n+ }\n+ const userSearchResults = AddUsersModal.getSearchResults(\n+ this.state.usernameInputText,\n+ this.props.otherUserInfos,\n+ this.props.userSearchIndex,\n+ userInfoInputArray,\n+ this.props.threadInfo,\n+ );\n+ this.setState({ userInfoInputArray, userSearchResults });\n+ }\n+\n+ tagDataLabelExtractor = (userInfo: UserInfo) => userInfo.username;\n+\n+ setUsernameInputText = (text: string) => {\n+ if (this.props.addUsersLoadingStatus === \"loading\") {\n+ return;\n+ }\n+ const userSearchResults = AddUsersModal.getSearchResults(\n+ text,\n+ this.props.otherUserInfos,\n+ this.props.userSearchIndex,\n+ this.state.userInfoInputArray,\n+ this.props.threadInfo,\n+ );\n+ this.searchUsers(text);\n+ this.setState({ usernameInputText: text, userSearchResults });\n+ }\n+\n+ onUserSelect = (userID: string) => {\n+ if (this.props.addUsersLoadingStatus === \"loading\") {\n+ return;\n+ }\n+ for (let existingUserInfo of this.state.userInfoInputArray) {\n+ if (userID === existingUserInfo.id) {\n+ return;\n+ }\n+ }\n+ const userInfoInputArray = [\n+ ...this.state.userInfoInputArray,\n+ this.props.otherUserInfos[userID],\n+ ];\n+ const userSearchResults = AddUsersModal.getSearchResults(\n+ \"\",\n+ this.props.otherUserInfos,\n+ this.props.userSearchIndex,\n+ userInfoInputArray,\n+ this.props.threadInfo,\n+ );\n+ this.setState({\n+ userInfoInputArray,\n+ usernameInputText: \"\",\n+ userSearchResults,\n+ });\n+ }\n+\n+ onPressAdd = () => {\n+ this.props.dispatchActionPromise(\n+ addUsersToThreadActionTypes,\n+ this.addUsersToThread(),\n+ );\n+ }\n+\n+ async addUsersToThread() {\n+ try {\n+ const result = await this.props.addUsersToThread(\n+ this.props.threadInfo.id,\n+ this.state.userInfoInputArray.map((userInfo) => userInfo.id),\n+ );\n+ this.props.close();\n+ return result;\n+ } catch (e) {\n+ Alert.alert(\n+ \"Unknown error\",\n+ \"Uhh... try again?\",\n+ [\n+ { text: 'OK', onPress: this.onUnknownErrorAlertAcknowledged },\n+ ],\n+ { cancelable: false },\n+ );\n+ throw e;\n+ }\n+ }\n+\n+ onErrorAcknowledged = () => {\n+ invariant(this.tagInput, \"nameInput should be set\");\n+ this.tagInput.focus();\n+ }\n+\n+ onUnknownErrorAlertAcknowledged = () => {\n+ const usernameInputText = \"\";\n+ const userInfoInputArray = [];\n+ const userSearchResults = AddUsersModal.getSearchResults(\n+ usernameInputText,\n+ this.props.otherUserInfos,\n+ this.props.userSearchIndex,\n+ userInfoInputArray,\n+ this.props.threadInfo,\n+ );\n+ this.setState(\n+ {\n+ userInfoInputArray,\n+ usernameInputText,\n+ userSearchResults,\n+ },\n+ this.onErrorAcknowledged,\n+ );\n+ }\n+\n+}\n+\n+const styles = StyleSheet.create({\n+ container: {\n+ flex: 1,\n+ },\n+ modal: {\n+ flex: 1,\n+ marginLeft: 15,\n+ marginRight: 15,\n+ marginTop: 100,\n+ padding: 12,\n+ borderRadius: 5,\n+ backgroundColor: '#EEEEEE',\n+ },\n+ buttons: {\n+ flexDirection: 'row',\n+ justifyContent: 'space-between',\n+ marginTop: 12,\n+ },\n+ cancelButton: {\n+ paddingHorizontal: 10,\n+ paddingVertical: 4,\n+ borderRadius: 3,\n+ backgroundColor: '#AAAAAA',\n+ },\n+ cancelText: {\n+ fontSize: 18,\n+ color: '#444444',\n+ },\n+ addButton: {\n+ paddingHorizontal: 10,\n+ paddingVertical: 4,\n+ borderRadius: 3,\n+ backgroundColor: '#AACCAA',\n+ flexDirection: 'row',\n+ },\n+ activityIndicator: {\n+ paddingRight: 6,\n+ },\n+ addText: {\n+ fontSize: 18,\n+ color: '#444444',\n+ },\n+});\n+\n+const addUsersToThreadLoadingStatusSelector\n+ = createLoadingStatusSelector(addUsersToThreadActionTypes);\n+registerFetchKey(searchUsersActionTypes);\n+\n+export default connect(\n+ (state: AppState) => ({\n+ otherUserInfos: userInfoSelectorForOtherMembersOfThread(null)(state),\n+ userSearchIndex: userSearchIndexForOtherMembersOfThread(null)(state),\n+ addUsersLoadingStatus: addUsersToThreadLoadingStatusSelector(state),\n+ cookie: state.cookie,\n+ }),\n+ includeDispatchActionProps,\n+ bindServerCalls({ addUsersToThread, searchUsers }),\n+)(AddUsersModal);\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/settings/thread-settings.react.js",
"new_path": "native/chat/settings/thread-settings.react.js",
"diff": "@@ -15,6 +15,7 @@ import React from 'react';\nimport { connect } from 'react-redux';\nimport PropTypes from 'prop-types';\nimport { ScrollView, StyleSheet, Text, View } from 'react-native';\n+import Modal from 'react-native-modal';\nimport { visibilityRules } from 'lib/types/thread-types';\nimport {\n@@ -30,23 +31,27 @@ import {\nThreadSettingsUser,\nThreadSettingsAddUser,\n} from './thread-settings-members.react';\n+import AddUsersModal from './add-users-modal.react';\ntype NavProp = NavigationScreenProp<NavigationRoute, NavigationAction>\n& { state: { params: { threadInfo: ThreadInfo } } };\n-type Props = {\n+type Props = {|\nnavigation: NavProp,\n// Redux state\nthreadInfo: ThreadInfo,\nparentThreadInfo: ?ThreadInfo,\nthreadMembers: RelativeUserInfo[],\n-};\n-type State = {\n-};\n+|};\n+type State = {|\n+ showAddUsersModal: bool,\n+|};\nclass InnerThreadSettings extends React.PureComponent {\nprops: Props;\n- state: State;\n+ state: State = {\n+ showAddUsersModal: false,\n+ };\nstatic propTypes = {\nnavigation: PropTypes.shape({\nstate: PropTypes.shape({\n@@ -115,6 +120,7 @@ class InnerThreadSettings extends React.PureComponent {\n);\n}).filter(x => x);\nreturn (\n+ <View>\n<ScrollView contentContainerStyle={styles.scrollView}>\n<ThreadSettingsCategory type=\"full\" title=\"Basics\">\n<View style={styles.row}>\n@@ -158,6 +164,17 @@ class InnerThreadSettings extends React.PureComponent {\n</View>\n</ThreadSettingsCategory>\n</ScrollView>\n+ <Modal\n+ isVisible={this.state.showAddUsersModal}\n+ onBackButtonPress={this.closeAddUsersModal}\n+ onBackdropPress={this.closeAddUsersModal}\n+ >\n+ <AddUsersModal\n+ threadInfo={this.props.threadInfo}\n+ close={this.closeAddUsersModal}\n+ />\n+ </Modal>\n+ </View>\n);\n}\n@@ -175,6 +192,11 @@ class InnerThreadSettings extends React.PureComponent {\n}\nonPressAddUser = () => {\n+ this.setState({ showAddUsersModal: true });\n+ }\n+\n+ closeAddUsersModal = () => {\n+ this.setState({ showAddUsersModal: false });\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "native/components/button.react.js",
"new_path": "native/components/button.react.js",
"diff": "@@ -39,7 +39,7 @@ class Button extends React.PureComponent {\ndisabled: PropTypes.bool,\nstyle: ViewPropTypes.style,\ntopStyle: ViewPropTypes.style,\n- children: PropTypes.object,\n+ children: PropTypes.node,\nandroidBorderlessRipple: PropTypes.bool,\niosFormat: PropTypes.oneOf([\n\"highlight\",\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Working AddUsersModal for adding users to a thread |
129,187 | 03.10.2017 13:52:43 | 14,400 | bba38cf4432e7723ea988a295edf71a31c1421a5 | Split ThreadSettingsUser and ThreadSettingsAddListItem (previously ThreadSettingsAddUser) | [
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/chat/settings/thread-settings-add-list-item.react.js",
"diff": "+\n+// @flow\n+\n+import React from 'react';\n+import { View, Text, StyleSheet } from 'react-native';\n+import Icon from 'react-native-vector-icons/Ionicons';\n+\n+import Button from '../../components/button.react';\n+\n+type ThreadSettingsAddListItemProps = {\n+ onPress: () => void,\n+ text: string,\n+};\n+function ThreadSettingsAddListItem(props: ThreadSettingsAddListItemProps) {\n+ return (\n+ <Button\n+ onPress={props.onPress}\n+ >\n+ <View style={styles.container}>\n+ <Text style={styles.text}>{props.text}</Text>\n+ <Icon\n+ name={\"md-add\"}\n+ size={20}\n+ color=\"#009900\"\n+ />\n+ </View>\n+ </Button>\n+ );\n+}\n+\n+const styles = StyleSheet.create({\n+ container: {\n+ flex: 1,\n+ flexDirection: 'row',\n+ paddingHorizontal: 24,\n+ paddingTop: 12,\n+ paddingBottom: 8,\n+ justifyContent: 'center',\n+ },\n+ text: {\n+ flex: 1,\n+ fontSize: 16,\n+ color: \"#036AFF\",\n+ fontStyle: 'italic',\n+ },\n+});\n+\n+export default ThreadSettingsAddListItem;\n"
},
{
"change_type": "DELETE",
"old_path": "native/chat/settings/thread-settings-members.react.js",
"new_path": null,
"diff": "-// @flow\n-\n-import type { ThreadInfo } from 'lib/types/thread-types';\n-\n-import React from 'react';\n-import { View, Text, StyleSheet, Platform } from 'react-native';\n-import Icon from 'react-native-vector-icons/Ionicons';\n-\n-import EditSettingButton from './edit-setting-button.react';\n-import Button from '../../components/button.react';\n-\n-type ThreadSettingsUserProps = {\n- userInfo: {|\n- id: string,\n- username: string,\n- isViewer: bool,\n- |},\n- threadInfo: ThreadInfo,\n-};\n-function ThreadSettingsUser(props: ThreadSettingsUserProps) {\n- const canChange = !props.userInfo.isViewer &&\n- props.threadInfo.canChangeSettings;\n- return (\n- <View style={styles.container}>\n- <Text style={styles.username}>{props.userInfo.username}</Text>\n- <EditSettingButton\n- onPress={() => {}}\n- canChangeSettings={canChange}\n- style={styles.editSettingsIcon}\n- />\n- </View>\n- );\n-}\n-\n-type ThreadSettingsAddUserProps = {\n- onPress: () => void,\n-};\n-function ThreadSettingsAddUser(props: ThreadSettingsAddUserProps) {\n- return (\n- <Button\n- onPress={props.onPress}\n- >\n- <View style={[styles.container, styles.addUser]}>\n- <Text style={styles.addUserText}>Add users</Text>\n- <Icon\n- name={\"md-add\"}\n- size={20}\n- style={styles.addIcon}\n- color=\"#009900\"\n- />\n- </View>\n- </Button>\n- );\n-}\n-\n-const styles = StyleSheet.create({\n- container: {\n- flex: 1,\n- flexDirection: 'row',\n- paddingVertical: 8,\n- justifyContent: 'center',\n- },\n- addUser: {\n- paddingHorizontal: 24,\n- paddingTop: 12,\n- },\n- editSettingsIcon: {\n- lineHeight: 20,\n- },\n- addIcon: {\n- },\n- username: {\n- flex: 1,\n- fontSize: 16,\n- color: \"#333333\",\n- },\n- addUserText: {\n- flex: 1,\n- fontSize: 16,\n- color: \"#036AFF\",\n- fontStyle: 'italic',\n- },\n-});\n-\n-export {\n- ThreadSettingsUser,\n- ThreadSettingsAddUser,\n-};\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/chat/settings/thread-settings-user.react.js",
"diff": "+// @flow\n+\n+import type { ThreadInfo } from 'lib/types/thread-types';\n+\n+import React from 'react';\n+import { View, Text, StyleSheet } from 'react-native';\n+\n+import EditSettingButton from './edit-setting-button.react';\n+import Button from '../../components/button.react';\n+\n+type Props = {|\n+ userInfo: {|\n+ id: string,\n+ username: string,\n+ isViewer: bool,\n+ |},\n+ threadInfo: ThreadInfo,\n+|};\n+function ThreadSettingsUser(props: Props) {\n+ const canChange = !props.userInfo.isViewer &&\n+ props.threadInfo.canChangeSettings;\n+ return (\n+ <View style={styles.container}>\n+ <Text style={styles.username} numberOfLines={1}>\n+ {props.userInfo.username}\n+ </Text>\n+ <EditSettingButton\n+ onPress={() => {}}\n+ canChangeSettings={canChange}\n+ style={styles.editSettingsIcon}\n+ />\n+ </View>\n+ );\n+}\n+\n+const styles = StyleSheet.create({\n+ container: {\n+ flex: 1,\n+ flexDirection: 'row',\n+ paddingVertical: 8,\n+ justifyContent: 'center',\n+ },\n+ username: {\n+ flex: 1,\n+ fontSize: 16,\n+ color: \"#333333\",\n+ },\n+ editSettingsIcon: {\n+ lineHeight: 20,\n+ },\n+});\n+\n+export default ThreadSettingsUser;\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/settings/thread-settings.react.js",
"new_path": "native/chat/settings/thread-settings.react.js",
"diff": "@@ -27,10 +27,8 @@ import ColorSplotch from '../../components/color-splotch.react';\nimport EditSettingButton from './edit-setting-button.react';\nimport Button from '../../components/button.react';\nimport { MessageListRouteName } from '../message-list.react';\n-import {\n- ThreadSettingsUser,\n- ThreadSettingsAddUser,\n-} from './thread-settings-members.react';\n+import ThreadSettingsUser from './thread-settings-user.react';\n+import ThreadSettingsAddListItem from './thread-settings-add-list-item.react';\nimport AddUsersModal from './add-users-modal.react';\ntype NavProp = NavigationScreenProp<NavigationRoute, NavigationAction>\n@@ -158,8 +156,11 @@ class InnerThreadSettings extends React.PureComponent {\n</View>\n</ThreadSettingsCategory>\n<ThreadSettingsCategory type=\"unpadded\" title=\"Members\">\n- <View style={styles.members}>\n- <ThreadSettingsAddUser onPress={this.onPressAddUser} />\n+ <View style={styles.itemList}>\n+ <ThreadSettingsAddListItem\n+ onPress={this.onPressAddUser}\n+ text=\"Add users\"\n+ />\n{members}\n</View>\n</ThreadSettingsCategory>\n@@ -251,7 +252,7 @@ const styles = StyleSheet.create({\nparentThreadLink: {\ncolor: \"#036AFF\",\n},\n- members: {\n+ itemList: {\npaddingBottom: 4,\n},\n});\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Split ThreadSettingsUser and ThreadSettingsAddListItem (previously ThreadSettingsAddUser) |
129,187 | 03.10.2017 17:37:59 | 14,400 | 884b4e9a275db041bbd8fb7915645617b87819d4 | chatScreenRegistry to allow resetting the chat stack to the first screen | [
{
"change_type": "MODIFY",
"old_path": "native/chat/add-thread.react.js",
"new_path": "native/chat/add-thread.react.js",
"diff": "@@ -62,6 +62,7 @@ import TagInput from '../components/tag-input.react';\nimport UserList from '../components/user-list.react';\nimport LinkButton from '../components/link-button.react';\nimport { MessageListRouteName } from './message-list.react';\n+import { registerChatScreen } from './chat-screen-registry';\ntype NavProp = NavigationScreenProp<NavigationRoute, NavigationAction>\n& { state: { params: { parentThreadID: ?string } } };\n@@ -104,6 +105,7 @@ class InnerAddThread extends React.PureComponent {\nstatic propTypes = {\nnavigation: PropTypes.shape({\nstate: PropTypes.shape({\n+ key: PropTypes.string.isRequired,\nparams: PropTypes.shape({\nparentThreadID: PropTypes.string,\n}).isRequired,\n@@ -159,6 +161,7 @@ class InnerAddThread extends React.PureComponent {\ncomponentDidMount() {\nthis.mounted = true;\n+ registerChatScreen(this.props.navigation.state.key, this);\nthis.searchUsers(\"\");\nthis.props.navigation.setParams({\nonPressCreateThread: this.onPressCreateThread,\n@@ -167,8 +170,11 @@ class InnerAddThread extends React.PureComponent {\ncomponentWillUnmount() {\nthis.mounted = false;\n+ registerChatScreen(this.props.navigation.state.key, null);\n}\n+ canReset = () => false;\n+\ncomponentWillReceiveProps(nextProps: Props) {\nif (!this.mounted) {\nreturn;\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/chat/chat-screen-registry.js",
"diff": "+// @flow\n+\n+import React from 'react';\n+\n+// In order for Chat's navigationOptions.tabBarOnPress callback to have access\n+// to the components that it needs to call, we have to register those components\n+// (by key) in some state somewhere. This is an ugly hack.\n+\n+const chatSceenRegistry: {[key: string]: ?ChatScreen} = {};\n+\n+export type ChatScreen = React.Component<*, *, *> & { canReset: () => bool };\n+\n+function registerChatScreen(key: string, screen: ?ChatScreen) {\n+ chatSceenRegistry[key] = screen;\n+}\n+\n+function getChatScreen(key: string): ?ChatScreen {\n+ return chatSceenRegistry[key];\n+}\n+\n+export {\n+ registerChatScreen,\n+ getChatScreen,\n+};\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/chat-thread-list.react.js",
"new_path": "native/chat/chat-thread-list.react.js",
"diff": "@@ -21,6 +21,7 @@ import { chatListData } from '../selectors/chat-selectors';\nimport ChatThreadListItem from './chat-thread-list-item.react';\nimport { MessageListRouteName } from './message-list.react';\nimport AddThreadButton from './add-thread-button.react';\n+import { registerChatScreen } from './chat-screen-registry';\nclass InnerChatThreadList extends React.PureComponent {\n@@ -32,6 +33,9 @@ class InnerChatThreadList extends React.PureComponent {\n};\nstatic propTypes = {\nnavigation: PropTypes.shape({\n+ state: PropTypes.shape({\n+ key: PropTypes.string.isRequired,\n+ }).isRequired,\nnavigate: PropTypes.func.isRequired,\n}).isRequired,\nchatListData: PropTypes.arrayOf(chatThreadItemPropType).isRequired,\n@@ -42,6 +46,16 @@ class InnerChatThreadList extends React.PureComponent {\nheaderRight: <AddThreadButton navigate={navigation.navigate} />,\n});\n+ componentDidMount() {\n+ registerChatScreen(this.props.navigation.state.key, this);\n+ }\n+\n+ componentWillUnmount() {\n+ registerChatScreen(this.props.navigation.state.key, null);\n+ }\n+\n+ canReset = () => false;\n+\nrenderItem = (row: { item: ChatThreadItem }) => {\nreturn (\n<ChatThreadListItem data={row.item} onPressItem={this.onPressItem} />\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/chat.react.js",
"new_path": "native/chat/chat.react.js",
"diff": "// @flow\n+import type { NavigationStateRoute } from 'react-navigation/src/TypeDefinition';\n+\nimport React from 'react';\nimport { StyleSheet } from 'react-native';\nimport Icon from 'react-native-vector-icons/FontAwesome';\n@@ -15,6 +17,7 @@ import {\nThreadSettings,\nThreadSettingsRouteName,\n} from './settings/thread-settings.react';\n+import { getChatScreen } from './chat-screen-registry';\nconst Chat = StackNavigator(\n{\n@@ -24,7 +27,7 @@ const Chat = StackNavigator(\n[ThreadSettingsRouteName]: { screen: ThreadSettings },\n},\n{\n- navigationOptions: {\n+ navigationOptions: ({ navigation }) => ({\ntabBarLabel: 'Chat',\ntabBarIcon: ({ tintColor }) => (\n<Icon\n@@ -32,7 +35,27 @@ const Chat = StackNavigator(\nstyle={[styles.icon, { color: tintColor }]}\n/>\n),\n+ tabBarOnPress: (\n+ scene: { index: number, focused: bool, route: NavigationStateRoute },\n+ jumpToIndex: (index: number) => void,\n+ ) => {\n+ if (!scene.focused) {\n+ jumpToIndex(scene.index);\n+ return;\n+ }\n+ if (scene.route.index === 0) {\n+ return;\n+ }\n+ const currentRoute = scene.route.routes[scene.route.index];\n+ const chatScreen = getChatScreen(currentRoute.key);\n+ if (!chatScreen) {\n+ return;\n+ }\n+ if (chatScreen.canReset()) {\n+ navigation.goBack(scene.route.routes[1].key);\n+ }\n},\n+ }),\n},\n);\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/message-list.react.js",
"new_path": "native/chat/message-list.react.js",
"diff": "@@ -58,6 +58,7 @@ import ListLoadingIndicator from '../list-loading-indicator.react';\nimport AddThreadButton from './add-thread-button.react';\nimport MessageListHeaderTitle from './message-list-header-title.react';\nimport MessageListHeader from './message-list-header.react';\n+import { registerChatScreen } from './chat-screen-registry';\ntype NavProp = NavigationScreenProp<NavigationRoute, NavigationAction>\n& { state: { params: { threadInfo: ThreadInfo } } };\n@@ -121,6 +122,7 @@ class InnerMessageList extends React.PureComponent {\nstatic propTypes = {\nnavigation: PropTypes.shape({\nstate: PropTypes.shape({\n+ key: PropTypes.string.isRequired,\nparams: PropTypes.shape({\nthreadInfo: threadInfoPropType.isRequired,\n}).isRequired,\n@@ -172,6 +174,16 @@ class InnerMessageList extends React.PureComponent {\n};\n}\n+ componentDidMount() {\n+ registerChatScreen(this.props.navigation.state.key, this);\n+ }\n+\n+ componentWillUnmount() {\n+ registerChatScreen(this.props.navigation.state.key, null);\n+ }\n+\n+ canReset = () => true;\n+\nstatic textToMeasureFromListData(listData: $ReadOnlyArray<ChatMessageItem>) {\nconst textToMeasure = [];\nfor (let item of listData) {\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/settings/thread-settings.react.js",
"new_path": "native/chat/settings/thread-settings.react.js",
"diff": "@@ -30,6 +30,7 @@ import { MessageListRouteName } from '../message-list.react';\nimport ThreadSettingsUser from './thread-settings-user.react';\nimport ThreadSettingsAddListItem from './thread-settings-add-list-item.react';\nimport AddUsersModal from './add-users-modal.react';\n+import { registerChatScreen } from '../chat-screen-registry';\ntype NavProp = NavigationScreenProp<NavigationRoute, NavigationAction>\n& { state: { params: { threadInfo: ThreadInfo } } };\n@@ -53,6 +54,7 @@ class InnerThreadSettings extends React.PureComponent {\nstatic propTypes = {\nnavigation: PropTypes.shape({\nstate: PropTypes.shape({\n+ key: PropTypes.string.isRequired,\nparams: PropTypes.shape({\nthreadInfo: threadInfoPropType.isRequired,\n}).isRequired,\n@@ -68,6 +70,16 @@ class InnerThreadSettings extends React.PureComponent {\ntitle: navigation.state.params.threadInfo.name,\n});\n+ componentDidMount() {\n+ registerChatScreen(this.props.navigation.state.key, this);\n+ }\n+\n+ componentWillUnmount() {\n+ registerChatScreen(this.props.navigation.state.key, null);\n+ }\n+\n+ canReset = () => false;\n+\nrender() {\nlet parent;\nif (this.props.parentThreadInfo) {\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | chatScreenRegistry to allow resetting the chat stack to the first screen |
129,187 | 03.10.2017 17:39:12 | 14,400 | ba66f69ba59f8352ebbdb17855a4b51e9a578d97 | ColorSplotch updates and support for "small" variant | [
{
"change_type": "MODIFY",
"old_path": "native/chat/chat-thread-list-item.react.js",
"new_path": "native/chat/chat-thread-list-item.react.js",
"diff": "@@ -12,6 +12,7 @@ import PropTypes from 'prop-types';\nimport Button from '../components/button.react';\nimport MessagePreview from './message-preview.react';\n+import ColorSplotch from '../components/color-splotch.react';\nclass ChatThreadListItem extends React.PureComponent {\n@@ -37,9 +38,6 @@ class ChatThreadListItem extends React.PureComponent {\n}\nrender() {\n- const colorSplotchStyle = {\n- backgroundColor: `#${this.props.data.threadInfo.color}`,\n- };\nconst lastActivity = shortAbsoluteDate(this.props.data.lastUpdatedTime);\nreturn (\n<Button\n@@ -54,7 +52,12 @@ class ChatThreadListItem extends React.PureComponent {\n<Text style={styles.threadName} numberOfLines={1}>\n{this.props.data.threadInfo.name}\n</Text>\n- <View style={[styles.colorSplotch, colorSplotchStyle]} />\n+ <View style={styles.colorSplotch}>\n+ <ColorSplotch\n+ color={this.props.data.threadInfo.color}\n+ size=\"small\"\n+ />\n+ </View>\n</View>\n<View style={styles.row}>\n{this.lastMessage()}\n@@ -90,11 +93,7 @@ const styles = StyleSheet.create({\ncolor: '#333333',\n},\ncolorSplotch: {\n- height: 18,\n- width: 18,\nmarginTop: 2,\n- justifyContent: 'flex-end',\n- borderRadius: 5,\nmarginLeft: 10,\n},\nnoMessages: {\n"
},
{
"change_type": "MODIFY",
"old_path": "native/components/color-splotch.react.js",
"new_path": "native/components/color-splotch.react.js",
"diff": "@@ -5,23 +5,30 @@ import { View, StyleSheet } from 'react-native';\ntype Props = {\ncolor: string,\n+ size?: \"large\" | \"small\",\n};\nfunction ColorSplotch(props: Props) {\n- const style = {\n- backgroundColor: `#${props.color}`,\n- };\n- return (\n- <View style={[styles.colorSplotch, style]} />\n- );\n+ const style = [\n+ styles.splotch,\n+ props.size === \"small\"\n+ ? styles.small\n+ : styles.large,\n+ { backgroundColor: `#${props.color}` },\n+ ];\n+ return <View style={style} />;\n}\nconst styles = StyleSheet.create({\n- colorSplotch: {\n+ splotch: {\n+ borderRadius: 5,\n+ },\n+ small: {\n+ height: 18,\n+ width: 18,\n+ },\n+ large: {\nheight: 25,\nwidth: 25,\n- borderRadius: 5,\n- borderWidth: 1,\n- borderColor: '#777777',\n},\n});\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | ColorSplotch updates and support for "small" variant |
129,187 | 03.10.2017 17:41:48 | 14,400 | ef79bd8b92b53d4b642f8e7866eb19498adb0928 | Clickable list of child threads in thread settings | [
{
"change_type": "MODIFY",
"old_path": "lib/selectors/thread-selectors.js",
"new_path": "lib/selectors/thread-selectors.js",
"diff": "@@ -112,8 +112,28 @@ const currentDaysToEntries = createSelector(\n},\n);\n+const childThreadInfos = createSelector(\n+ (state: BaseAppState) => state.threadInfos,\n+ (threadInfos: {[id: string]: ThreadInfo}): {[id: string]: ThreadInfo[]} => {\n+ const result = {};\n+ for (let id in threadInfos) {\n+ const threadInfo = threadInfos[id];\n+ const parentThreadID = threadInfo.parentThreadID;\n+ if (parentThreadID === null || parentThreadID === undefined) {\n+ continue;\n+ }\n+ if (result[parentThreadID] === undefined) {\n+ result[parentThreadID] = [];\n+ }\n+ result[parentThreadID].push(threadInfo);\n+ }\n+ return result;\n+ },\n+);\n+\nexport {\nonScreenThreadInfos,\ntypeaheadSortedThreadInfos,\ncurrentDaysToEntries,\n+ childThreadInfos,\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/add-thread-button.react.js",
"new_path": "native/chat/add-thread-button.react.js",
"diff": "@@ -17,7 +17,7 @@ class AddThreadButton extends React.PureComponent {\nnavigate: (\nrouteName: string,\nparams?: NavigationParams,\n- ) => boolean,\n+ ) => bool,\n};\nstatic propTypes = {\nparentThreadID: PropTypes.string,\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/message-list-header-title.react.js",
"new_path": "native/chat/message-list-header-title.react.js",
"diff": "@@ -20,7 +20,7 @@ class MessageListHeaderTitle extends React.PureComponent {\nnavigate: (\nrouteName: string,\nparams?: NavigationParams,\n- ) => boolean,\n+ ) => bool,\nsceneKey: string,\nonWidthChange: (key: string, width: number) => void,\n};\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/chat/settings/thread-settings-child-thread.react.js",
"diff": "+// @flow\n+\n+import type { ThreadInfo } from 'lib/types/thread-types';\n+import type { NavigationParams } from 'react-navigation/src/TypeDefinition';\n+\n+import React from 'react';\n+import { Text, StyleSheet } from 'react-native';\n+\n+import { MessageListRouteName } from '../message-list.react';\n+import Button from '../../components/button.react';\n+import ColorSplotch from '../../components/color-splotch.react';\n+\n+type Props = {|\n+ threadInfo: ThreadInfo,\n+ navigate: (\n+ routeName: string,\n+ params?: NavigationParams,\n+ ) => bool,\n+|};\n+class ThreadSettingsChildThread extends React.PureComponent {\n+\n+ props: Props;\n+\n+ render() {\n+ return (\n+ <Button\n+ onPress={this.onPress}\n+ style={styles.container}\n+ >\n+ <Text style={styles.text} numberOfLines={1}>\n+ {this.props.threadInfo.name}\n+ </Text>\n+ <ColorSplotch color={this.props.threadInfo.color} />\n+ </Button>\n+ );\n+ }\n+\n+ onPress = () => {\n+ this.props.navigate(\n+ MessageListRouteName,\n+ { threadInfo: this.props.threadInfo },\n+ );\n+ }\n+\n+}\n+\n+const styles = StyleSheet.create({\n+ container: {\n+ flex: 1,\n+ flexDirection: 'row',\n+ paddingVertical: 8,\n+ paddingLeft: 12,\n+ paddingRight: 6,\n+ alignItems: 'center',\n+ },\n+ text: {\n+ flex: 1,\n+ fontSize: 16,\n+ color: \"#036AFF\",\n+ },\n+});\n+\n+export default ThreadSettingsChildThread;\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/settings/thread-settings-user.react.js",
"new_path": "native/chat/settings/thread-settings-user.react.js",
"diff": "@@ -38,7 +38,7 @@ const styles = StyleSheet.create({\nflex: 1,\nflexDirection: 'row',\npaddingVertical: 8,\n- justifyContent: 'center',\n+ paddingHorizontal: 12,\n},\nusername: {\nflex: 1,\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/settings/thread-settings.react.js",
"new_path": "native/chat/settings/thread-settings.react.js",
"diff": "@@ -21,6 +21,7 @@ import { visibilityRules } from 'lib/types/thread-types';\nimport {\nrelativeUserInfoSelectorForMembersOfThread,\n} from 'lib/selectors/user-selectors';\n+import { childThreadInfos } from 'lib/selectors/thread-selectors';\nimport ThreadSettingsCategory from './thread-settings-category.react';\nimport ColorSplotch from '../../components/color-splotch.react';\n@@ -30,6 +31,8 @@ import { MessageListRouteName } from '../message-list.react';\nimport ThreadSettingsUser from './thread-settings-user.react';\nimport ThreadSettingsAddListItem from './thread-settings-add-list-item.react';\nimport AddUsersModal from './add-users-modal.react';\n+import ThreadSettingsChildThread from './thread-settings-child-thread.react';\n+import { AddThreadRouteName } from '../add-thread.react';\nimport { registerChatScreen } from '../chat-screen-registry';\ntype NavProp = NavigationScreenProp<NavigationRoute, NavigationAction>\n@@ -41,6 +44,7 @@ type Props = {|\nthreadInfo: ThreadInfo,\nparentThreadInfo: ?ThreadInfo,\nthreadMembers: RelativeUserInfo[],\n+ childThreadInfos: ?ThreadInfo[],\n|};\ntype State = {|\nshowAddUsersModal: bool,\n@@ -65,6 +69,7 @@ class InnerThreadSettings extends React.PureComponent {\nthreadInfo: threadInfoPropType.isRequired,\nparentThreadInfo: threadInfoPropType,\nthreadMembers: PropTypes.arrayOf(relativeUserInfoPropType).isRequired,\n+ childThreadInfos: PropTypes.arrayOf(threadInfoPropType),\n};\nstatic navigationOptions = ({ navigation }) => ({\ntitle: navigation.state.params.threadInfo.name,\n@@ -88,7 +93,10 @@ class InnerThreadSettings extends React.PureComponent {\nonPress={this.onPressParentThread}\nstyle={[styles.currentValue, styles.padding]}\n>\n- <Text style={[styles.currentValueText, styles.parentThreadLink]}>\n+ <Text\n+ style={[styles.currentValueText, styles.parentThreadLink]}\n+ numberOfLines={1}\n+ >\n{this.props.parentThreadInfo.name}\n</Text>\n</Button>\n@@ -111,7 +119,7 @@ class InnerThreadSettings extends React.PureComponent {\nvisRules === visibilityRules.CHAT_NESTED_OPEN\n? \"Public\"\n: \"Secret\";\n- const members = this.props.threadMembers.map((userInfo) => {\n+ const members = this.props.threadMembers.map(userInfo => {\nif (!userInfo.username) {\nreturn null;\n}\n@@ -121,7 +129,7 @@ class InnerThreadSettings extends React.PureComponent {\nisViewer: userInfo.isViewer,\n};\nreturn (\n- <View style={styles.userRow} key={userInfo.id}>\n+ <View style={styles.itemRow} key={userInfo.id}>\n<ThreadSettingsUser\nuserInfo={userInfoWithUsername}\nthreadInfo={this.props.threadInfo}\n@@ -129,6 +137,19 @@ class InnerThreadSettings extends React.PureComponent {\n</View>\n);\n}).filter(x => x);\n+ let childThreads = null;\n+ if (this.props.childThreadInfos) {\n+ childThreads = this.props.childThreadInfos.map(threadInfo => {\n+ return (\n+ <View style={styles.itemRow} key={threadInfo.id}>\n+ <ThreadSettingsChildThread\n+ threadInfo={threadInfo}\n+ navigate={this.props.navigation.navigate}\n+ />\n+ </View>\n+ );\n+ });\n+ }\nreturn (\n<View>\n<ScrollView contentContainerStyle={styles.scrollView}>\n@@ -167,6 +188,15 @@ class InnerThreadSettings extends React.PureComponent {\n</Text>\n</View>\n</ThreadSettingsCategory>\n+ <ThreadSettingsCategory type=\"unpadded\" title=\"Child threads\">\n+ <View style={styles.itemList}>\n+ <ThreadSettingsAddListItem\n+ onPress={this.onPressAddChildThread}\n+ text=\"Add child thread\"\n+ />\n+ {childThreads}\n+ </View>\n+ </ThreadSettingsCategory>\n<ThreadSettingsCategory type=\"unpadded\" title=\"Members\">\n<View style={styles.itemList}>\n<ThreadSettingsAddListItem\n@@ -208,6 +238,13 @@ class InnerThreadSettings extends React.PureComponent {\nthis.setState({ showAddUsersModal: true });\n}\n+ onPressAddChildThread = () => {\n+ this.props.navigation.navigate(\n+ AddThreadRouteName,\n+ { parentThreadID: this.props.threadInfo.id },\n+ );\n+ }\n+\ncloseAddUsersModal = () => {\nthis.setState({ showAddUsersModal: false });\n}\n@@ -246,10 +283,9 @@ const styles = StyleSheet.create({\nflexDirection: 'row',\npaddingLeft: 4,\n},\n- userRow: {\n+ itemRow: {\nflex: 1,\nflexDirection: 'row',\n- paddingHorizontal: 12,\nmarginHorizontal: 12,\nborderTopWidth: 1,\nborderColor: \"#CCCCCC\",\n@@ -282,6 +318,7 @@ const ThreadSettings = connect(\n: null,\nthreadMembers:\nrelativeUserInfoSelectorForMembersOfThread(threadInfo.id)(state),\n+ childThreadInfos: childThreadInfos(state)[threadInfo.id],\n};\n},\n)(InnerThreadSettings);\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Clickable list of child threads in thread settings |
129,187 | 03.10.2017 18:21:31 | 14,400 | 2f3e57311375d2a52b768cf89bf92fc6a3476490 | Paginate child threads and members in thread settings | [
{
"change_type": "RENAME",
"old_path": "native/chat/settings/thread-settings-add-list-item.react.js",
"new_path": "native/chat/settings/thread-settings-list-action.react.js",
"diff": "-\n// @flow\n+import type {\n+ StyleObj,\n+} from 'react-native/Libraries/StyleSheet/StyleSheetTypes';\n+\nimport React from 'react';\nimport { View, Text, StyleSheet } from 'react-native';\nimport Icon from 'react-native-vector-icons/Ionicons';\nimport Button from '../../components/button.react';\n-type ThreadSettingsAddListItemProps = {\n+type Props = {\nonPress: () => void,\ntext: string,\n+ iconName: string,\n+ iconColor: string,\n+ iconSize: number,\n+ iconStyle?: StyleObj,\n};\n-function ThreadSettingsAddListItem(props: ThreadSettingsAddListItemProps) {\n+function ThreadSettingsListAction(props: Props) {\nreturn (\n- <Button\n- onPress={props.onPress}\n- >\n+ <Button onPress={props.onPress}>\n<View style={styles.container}>\n<Text style={styles.text}>{props.text}</Text>\n<Icon\n- name={\"md-add\"}\n- size={20}\n- color=\"#009900\"\n+ name={props.iconName}\n+ size={props.iconSize}\n+ color={props.iconColor}\n+ style={[styles.icon, props.iconStyle]}\n/>\n</View>\n</Button>\n@@ -32,9 +38,8 @@ const styles = StyleSheet.create({\ncontainer: {\nflex: 1,\nflexDirection: 'row',\n- paddingHorizontal: 24,\n- paddingTop: 12,\n- paddingBottom: 8,\n+ paddingHorizontal: 12,\n+ paddingVertical: 8,\njustifyContent: 'center',\n},\ntext: {\n@@ -43,6 +48,9 @@ const styles = StyleSheet.create({\ncolor: \"#036AFF\",\nfontStyle: 'italic',\n},\n+ icon: {\n+ lineHeight: 20,\n+ },\n});\n-export default ThreadSettingsAddListItem;\n+export default ThreadSettingsListAction;\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/settings/thread-settings.react.js",
"new_path": "native/chat/settings/thread-settings.react.js",
"diff": "@@ -29,12 +29,14 @@ import EditSettingButton from './edit-setting-button.react';\nimport Button from '../../components/button.react';\nimport { MessageListRouteName } from '../message-list.react';\nimport ThreadSettingsUser from './thread-settings-user.react';\n-import ThreadSettingsAddListItem from './thread-settings-add-list-item.react';\n+import ThreadSettingsListAction from './thread-settings-list-action.react';\nimport AddUsersModal from './add-users-modal.react';\nimport ThreadSettingsChildThread from './thread-settings-child-thread.react';\nimport { AddThreadRouteName } from '../add-thread.react';\nimport { registerChatScreen } from '../chat-screen-registry';\n+const itemPageLength = 5;\n+\ntype NavProp = NavigationScreenProp<NavigationRoute, NavigationAction>\n& { state: { params: { threadInfo: ThreadInfo } } };\n@@ -48,12 +50,16 @@ type Props = {|\n|};\ntype State = {|\nshowAddUsersModal: bool,\n+ showMaxMembers: number,\n+ showMaxChildThreads: number,\n|};\nclass InnerThreadSettings extends React.PureComponent {\nprops: Props;\nstate: State = {\nshowAddUsersModal: false,\n+ showMaxMembers: itemPageLength,\n+ showMaxChildThreads: itemPageLength,\n};\nstatic propTypes = {\nnavigation: PropTypes.shape({\n@@ -119,7 +125,28 @@ class InnerThreadSettings extends React.PureComponent {\nvisRules === visibilityRules.CHAT_NESTED_OPEN\n? \"Public\"\n: \"Secret\";\n- const members = this.props.threadMembers.map(userInfo => {\n+\n+ let threadMembers;\n+ let seeMoreMembers = null;\n+ if (this.props.threadMembers.length > this.state.showMaxMembers) {\n+ threadMembers =\n+ this.props.threadMembers.slice(0, this.state.showMaxMembers);\n+ seeMoreMembers = (\n+ <View style={styles.seeMoreRow} key=\"seeMore\">\n+ <ThreadSettingsListAction\n+ onPress={this.onPressSeeMoreMembers}\n+ text=\"See more...\"\n+ iconName=\"ios-more\"\n+ iconColor=\"#036AFF\"\n+ iconSize={36}\n+ iconStyle={styles.seeMoreIcon}\n+ />\n+ </View>\n+ );\n+ } else {\n+ threadMembers = this.props.threadMembers;\n+ }\n+ const members = threadMembers.map(userInfo => {\nif (!userInfo.username) {\nreturn null;\n}\n@@ -137,9 +164,34 @@ class InnerThreadSettings extends React.PureComponent {\n</View>\n);\n}).filter(x => x);\n+ if (seeMoreMembers) {\n+ members.push(seeMoreMembers);\n+ }\n+\nlet childThreads = null;\nif (this.props.childThreadInfos) {\n- childThreads = this.props.childThreadInfos.map(threadInfo => {\n+ let childThreadInfos;\n+ let seeMoreChildThreads = null;\n+ if (this.props.childThreadInfos.length > this.state.showMaxChildThreads) {\n+ childThreadInfos =\n+ this.props.childThreadInfos.slice(0, this.state.showMaxChildThreads);\n+ seeMoreChildThreads = (\n+ <View style={styles.seeMoreRow} key=\"seeMore\">\n+ <ThreadSettingsListAction\n+ onPress={this.onPressSeeMoreChildThreads}\n+ text=\"See more...\"\n+ iconName=\"ios-more\"\n+ iconColor=\"#036AFF\"\n+ iconSize={32}\n+ iconStyle={styles.seeMoreIcon}\n+ key=\"seeMore\"\n+ />\n+ </View>\n+ );\n+ } else {\n+ childThreadInfos = this.props.childThreadInfos;\n+ }\n+ childThreads = childThreadInfos.map(threadInfo => {\nreturn (\n<View style={styles.itemRow} key={threadInfo.id}>\n<ThreadSettingsChildThread\n@@ -149,7 +201,11 @@ class InnerThreadSettings extends React.PureComponent {\n</View>\n);\n});\n+ if (seeMoreChildThreads) {\n+ childThreads.push(seeMoreChildThreads);\n+ }\n}\n+\nreturn (\n<View>\n<ScrollView contentContainerStyle={styles.scrollView}>\n@@ -190,19 +246,29 @@ class InnerThreadSettings extends React.PureComponent {\n</ThreadSettingsCategory>\n<ThreadSettingsCategory type=\"unpadded\" title=\"Child threads\">\n<View style={styles.itemList}>\n- <ThreadSettingsAddListItem\n+ <View style={styles.addItemRow}>\n+ <ThreadSettingsListAction\nonPress={this.onPressAddChildThread}\ntext=\"Add child thread\"\n+ iconName=\"md-add\"\n+ iconColor=\"#009900\"\n+ iconSize={20}\n/>\n+ </View>\n{childThreads}\n</View>\n</ThreadSettingsCategory>\n<ThreadSettingsCategory type=\"unpadded\" title=\"Members\">\n<View style={styles.itemList}>\n- <ThreadSettingsAddListItem\n+ <View style={styles.addItemRow}>\n+ <ThreadSettingsListAction\nonPress={this.onPressAddUser}\ntext=\"Add users\"\n+ iconName=\"md-add\"\n+ iconColor=\"#009900\"\n+ iconSize={20}\n/>\n+ </View>\n{members}\n</View>\n</ThreadSettingsCategory>\n@@ -249,6 +315,18 @@ class InnerThreadSettings extends React.PureComponent {\nthis.setState({ showAddUsersModal: false });\n}\n+ onPressSeeMoreMembers = () => {\n+ this.setState(prevState => ({\n+ showMaxMembers: prevState.showMaxMembers + itemPageLength,\n+ }));\n+ }\n+\n+ onPressSeeMoreChildThreads = () => {\n+ this.setState(prevState => ({\n+ showMaxChildThreads: prevState.showMaxChildThreads + itemPageLength,\n+ }));\n+ }\n+\n}\nconst styles = StyleSheet.create({\n@@ -290,6 +368,16 @@ const styles = StyleSheet.create({\nborderTopWidth: 1,\nborderColor: \"#CCCCCC\",\n},\n+ seeMoreRow: {\n+ borderTopWidth: 1,\n+ borderColor: \"#CCCCCC\",\n+ marginHorizontal: 12,\n+ paddingTop: 2,\n+ },\n+ addItemRow: {\n+ marginHorizontal: 12,\n+ marginTop: 4,\n+ },\ncurrentValueText: {\nfontSize: 16,\ncolor: \"#333333\",\n@@ -303,6 +391,11 @@ const styles = StyleSheet.create({\nitemList: {\npaddingBottom: 4,\n},\n+ seeMoreIcon: {\n+ position: 'absolute',\n+ right: 10,\n+ top: 15,\n+ },\n});\nconst ThreadSettingsRouteName = 'ThreadSettings';\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Paginate child threads and members in thread settings |
129,187 | 03.10.2017 19:48:42 | 14,400 | 70c11db45735a66405dadc41682671ee19f13eaf | Fix close-modal-by-clicking-background for AddUsersModal | [
{
"change_type": "MODIFY",
"old_path": "native/chat/settings/add-users-modal.react.js",
"new_path": "native/chat/settings/add-users-modal.react.js",
"diff": "@@ -357,12 +357,12 @@ class AddUsersModal extends React.PureComponent {\nconst styles = StyleSheet.create({\ncontainer: {\nflex: 1,\n- },\n- modal: {\n- flex: 1,\nmarginLeft: 15,\nmarginRight: 15,\nmarginTop: 100,\n+ },\n+ modal: {\n+ flex: 1,\npadding: 12,\nborderRadius: 5,\nbackgroundColor: '#EEEEEE',\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Fix close-modal-by-clicking-background for AddUsersModal |
129,187 | 04.10.2017 11:45:37 | 14,400 | 81594e1fe7019f72c94541ebd6ca830bfa1f68af | Fix nested scrolling behavior of Entry on iOS (and bump react-native version) | [
{
"change_type": "MODIFY",
"old_path": "native/calendar/entry.react.js",
"new_path": "native/calendar/entry.react.js",
"diff": "@@ -484,10 +484,10 @@ const styles = StyleSheet.create({\ntext: {\nfontSize: 16,\npaddingTop: 5,\n- paddingBottom: 5,\n+ paddingBottom: 4,\npaddingLeft: 10,\npaddingRight: 10,\n- margin: 0,\n+ marginBottom: 1,\ncolor: '#333333',\nfontFamily: 'Arial',\n},\n"
},
{
"change_type": "MODIFY",
"old_path": "native/package-lock.json",
"new_path": "native/package-lock.json",
"diff": "\"finalhandler\": \"0.4.0\",\n\"fresh\": \"0.3.0\",\n\"http-errors\": \"1.3.1\",\n- \"method-override\": \"2.3.9\",\n+ \"method-override\": \"2.3.10\",\n\"morgan\": \"1.6.1\",\n\"multiparty\": \"3.3.2\",\n\"on-headers\": \"1.0.1\",\n}\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+ \"version\": \"2.2.0\",\n+ \"resolved\": \"https://registry.npmjs.org/dateformat/-/dateformat-2.2.0.tgz\",\n+ \"integrity\": \"sha1-QGXiATz5+5Ft39gu+1Bq1MZ2kGI=\"\n},\n\"debug\": {\n\"version\": \"2.6.8\",\n\"array-uniq\": \"1.0.3\",\n\"beeper\": \"1.1.1\",\n\"chalk\": \"1.1.3\",\n- \"dateformat\": \"2.0.0\",\n+ \"dateformat\": \"2.2.0\",\n\"fancy-log\": \"1.3.0\",\n\"gulplog\": \"1.0.0\",\n\"has-gulplog\": \"0.1.0\",\n\"graceful-fs\": \"4.1.11\",\n\"jest-docblock\": \"20.1.0-delta.4\",\n\"micromatch\": \"2.3.11\",\n- \"sane\": \"2.0.0\",\n+ \"sane\": \"2.2.0\",\n\"worker-farm\": \"1.5.0\"\n},\n\"dependencies\": {\n\"sane\": {\n- \"version\": \"2.0.0\",\n- \"resolved\": \"https://registry.npmjs.org/sane/-/sane-2.0.0.tgz\",\n- \"integrity\": \"sha1-mct58h9KU6adTQzZV8LbBAJLjrI=\",\n+ \"version\": \"2.2.0\",\n+ \"resolved\": \"https://registry.npmjs.org/sane/-/sane-2.2.0.tgz\",\n+ \"integrity\": \"sha512-OSJxhHO0CgPUw3lUm3GhfREAfza45smvEI9ozuFrxKG10GHVo0ryW9FK5VYlLvxj0SV7HVKHW0voYJIRu27GWg==\",\n\"requires\": {\n\"anymatch\": \"1.3.2\",\n\"exec-sh\": \"0.2.1\",\n\"minimatch\": \"3.0.4\",\n\"minimist\": \"1.2.0\",\n\"walker\": \"1.0.7\",\n- \"watch\": \"0.10.0\"\n+ \"watch\": \"0.18.0\"\n+ }\n+ },\n+ \"watch\": {\n+ \"version\": \"0.18.0\",\n+ \"resolved\": \"https://registry.npmjs.org/watch/-/watch-0.18.0.tgz\",\n+ \"integrity\": \"sha1-KAlUdsbffJDJYxOJkMClQj60uYY=\",\n+ \"requires\": {\n+ \"exec-sh\": \"0.2.1\",\n+ \"minimist\": \"1.2.0\"\n}\n}\n}\n}\n},\n\"method-override\": {\n- \"version\": \"2.3.9\",\n- \"resolved\": \"https://registry.npmjs.org/method-override/-/method-override-2.3.9.tgz\",\n- \"integrity\": \"sha1-vRUfLONM8Bp2ykAKuVwBKxAtj3E=\",\n+ \"version\": \"2.3.10\",\n+ \"resolved\": \"https://registry.npmjs.org/method-override/-/method-override-2.3.10.tgz\",\n+ \"integrity\": \"sha1-49r41d7hDdLc59SuiNYrvud0drQ=\",\n\"requires\": {\n- \"debug\": \"2.6.8\",\n+ \"debug\": \"2.6.9\",\n\"methods\": \"1.1.2\",\n\"parseurl\": \"1.3.2\",\n- \"vary\": \"1.1.1\"\n+ \"vary\": \"1.1.2\"\n},\n\"dependencies\": {\n+ \"debug\": {\n+ \"version\": \"2.6.9\",\n+ \"resolved\": \"https://registry.npmjs.org/debug/-/debug-2.6.9.tgz\",\n+ \"integrity\": \"sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==\",\n+ \"requires\": {\n+ \"ms\": \"2.0.0\"\n+ }\n+ },\n\"vary\": {\n- \"version\": \"1.1.1\",\n- \"resolved\": \"https://registry.npmjs.org/vary/-/vary-1.1.1.tgz\",\n- \"integrity\": \"sha1-Z1Neu2lMHVIldFeYRmUyP1h+jTc=\"\n+ \"version\": \"1.1.2\",\n+ \"resolved\": \"https://registry.npmjs.org/vary/-/vary-1.1.2.tgz\",\n+ \"integrity\": \"sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=\"\n}\n}\n},\n\"graceful-fs\": \"4.1.11\",\n\"jest-docblock\": \"20.1.0-chi.1\",\n\"micromatch\": \"2.3.11\",\n- \"sane\": \"2.0.0\",\n+ \"sane\": \"2.2.0\",\n\"worker-farm\": \"1.5.0\"\n}\n},\n\"sane\": {\n- \"version\": \"2.0.0\",\n- \"resolved\": \"https://registry.npmjs.org/sane/-/sane-2.0.0.tgz\",\n- \"integrity\": \"sha1-mct58h9KU6adTQzZV8LbBAJLjrI=\",\n+ \"version\": \"2.2.0\",\n+ \"resolved\": \"https://registry.npmjs.org/sane/-/sane-2.2.0.tgz\",\n+ \"integrity\": \"sha512-OSJxhHO0CgPUw3lUm3GhfREAfza45smvEI9ozuFrxKG10GHVo0ryW9FK5VYlLvxj0SV7HVKHW0voYJIRu27GWg==\",\n\"requires\": {\n\"anymatch\": \"1.3.2\",\n\"exec-sh\": \"0.2.1\",\n\"minimatch\": \"3.0.4\",\n\"minimist\": \"1.2.0\",\n\"walker\": \"1.0.7\",\n- \"watch\": \"0.10.0\"\n+ \"watch\": \"0.18.0\"\n+ }\n+ },\n+ \"watch\": {\n+ \"version\": \"0.18.0\",\n+ \"resolved\": \"https://registry.npmjs.org/watch/-/watch-0.18.0.tgz\",\n+ \"integrity\": \"sha1-KAlUdsbffJDJYxOJkMClQj60uYY=\",\n+ \"requires\": {\n+ \"exec-sh\": \"0.2.1\",\n+ \"minimist\": \"1.2.0\"\n}\n}\n}\n}\n},\n\"mime\": {\n- \"version\": \"1.4.0\",\n- \"resolved\": \"https://registry.npmjs.org/mime/-/mime-1.4.0.tgz\",\n- \"integrity\": \"sha512-n9ChLv77+QQEapYz8lV+rIZAW3HhAPW2CXnzb1GN5uMkuczshwvkW7XPsbzU0ZQN3sP47Er2KVkp2p3KyqZKSQ==\"\n+ \"version\": \"1.4.1\",\n+ \"resolved\": \"https://registry.npmjs.org/mime/-/mime-1.4.1.tgz\",\n+ \"integrity\": \"sha512-KI1+qOZu5DcW6wayYHSzR/tXKCDC5Om4s1z2QJjDULzLcmf3DvzS7oluY4HCTrc+9FiKmWUgeNLg7W3uIQvxtQ==\"\n},\n\"mime-db\": {\n\"version\": \"1.29.0\",\n}\n},\n\"react-devtools-core\": {\n- \"version\": \"2.5.1\",\n- \"resolved\": \"https://registry.npmjs.org/react-devtools-core/-/react-devtools-core-2.5.1.tgz\",\n- \"integrity\": \"sha1-ge8w4Kw1xnDZa0NtH3UQ6uvmwIs=\",\n+ \"version\": \"2.5.2\",\n+ \"resolved\": \"https://registry.npmjs.org/react-devtools-core/-/react-devtools-core-2.5.2.tgz\",\n+ \"integrity\": \"sha1-+XvsWvrl2TGNFneAZeDCFMTVcUw=\",\n\"requires\": {\n\"shell-quote\": \"1.6.1\",\n\"ws\": \"2.3.1\"\n}\n},\n\"react-native\": {\n- \"version\": \"0.48.3\",\n- \"resolved\": \"https://registry.npmjs.org/react-native/-/react-native-0.48.3.tgz\",\n- \"integrity\": \"sha1-7BemaSnrKSUSsUwJHPJgsl4vuhg=\",\n+ \"version\": \"0.48.4\",\n+ \"resolved\": \"https://registry.npmjs.org/react-native/-/react-native-0.48.4.tgz\",\n+ \"integrity\": \"sha1-8wXp/vBppbP2pyUN3VD2A88wqy0=\",\n\"requires\": {\n\"absolute-path\": \"0.0.0\",\n\"art\": \"0.10.1\",\n\"lodash\": \"4.17.4\",\n\"merge-stream\": \"1.0.1\",\n\"metro-bundler\": \"0.11.0\",\n- \"mime\": \"1.4.0\",\n+ \"mime\": \"1.4.1\",\n\"mime-types\": \"2.1.11\",\n\"minimist\": \"1.2.0\",\n\"mkdirp\": \"0.5.1\",\n\"promise\": \"7.3.1\",\n\"prop-types\": \"15.5.10\",\n\"react-clone-referenced-element\": \"1.0.1\",\n- \"react-devtools-core\": \"2.5.1\",\n+ \"react-devtools-core\": \"2.5.2\",\n\"react-timer-mixin\": \"0.13.3\",\n\"react-transform-hmr\": \"1.0.4\",\n\"rebound\": \"0.0.13\",\n}\n},\n\"react-native-onepassword\": {\n- \"version\": \"git+https://github.com/ashoat/react-native-onepassword.git#b0f8eed393727f376438800b11e64c9efacc0758\",\n+ \"version\": \"1.0.6\",\n+ \"resolved\": \"https://registry.npmjs.org/react-native-onepassword/-/react-native-onepassword-1.0.6.tgz\",\n+ \"integrity\": \"sha512-kRgWo3H4FTL/7GRFVsfJosr47nDbXGtT+FhEAGlMC39xmuNGr5qa1dkcjIirNu3biEHED/WATMP2tLFCmDLm8g==\",\n\"requires\": {\n\"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+ \"version\": \"3.2.1\",\n+ \"resolved\": \"https://registry.npmjs.org/react-native-segmented-control-tab/-/react-native-segmented-control-tab-3.2.1.tgz\",\n+ \"integrity\": \"sha1-Kdw3AMPZVOW9td1cxI9MQUOpN14=\",\n\"requires\": {\n\"prop-types\": \"15.5.10\"\n}\n}\n},\n\"react-navigation\": {\n- \"version\": \"git+https://git@github.com/react-community/react-navigation.git#a8556b0df2d47b448d8ea095f390691d72b3c629\",\n+ \"version\": \"git+https://git@github.com/react-community/react-navigation.git#c08be7fb43ff3fa0553a30e02fa5a4686591e36e\",\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": "\"invariant\": \"^2.2.2\",\n\"lib\": \"file:../lib\",\n\"react\": \"^16.0.0-alpha.12\",\n- \"react-native\": \"^0.48.3\",\n+ \"react-native\": \"^0.48.4\",\n\"react-native-keychain\": \"^1.2.1\",\n\"react-native-modal\": \"^4.0.0\",\n- \"react-native-onepassword\": \"git+https://github.com/ashoat/react-native-onepassword.git\",\n- \"react-native-segmented-control-tab\": \"git+https://github.com/ashoat/react-native-segmented-control-tab.git\",\n+ \"react-native-onepassword\": \"^1.0.6\",\n+ \"react-native-segmented-control-tab\": \"^3.2.1\",\n\"react-native-vector-icons\": \"^4.3.0\",\n\"react-navigation\": \"git+https://git@github.com/react-community/react-navigation.git\",\n\"react-redux\": \"^5.0.6\",\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Fix nested scrolling behavior of Entry on iOS (and bump react-native version) |
129,187 | 04.10.2017 15:25:12 | 14,400 | 65e0d64c4078fb4ce10cfb26513caba740f8f99e | Stop importing the BaseAppState type in all reducers | [
{
"change_type": "MODIFY",
"old_path": "lib/reducers/cookie-reducer.js",
"new_path": "lib/reducers/cookie-reducer.js",
"diff": "// @flow\n-import type { BaseAppState, BaseAction } from '../types/redux-types';\n+import type { BaseAction } from '../types/redux-types';\nexport default function reduceCookie(state: ?string, action: BaseAction) {\n// If the cookie is undefined, that means we're deferring to the environment\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/reducers/entry-reducer.js",
"new_path": "lib/reducers/entry-reducer.js",
"diff": "// @flow\n-import type {\n- BaseAppState,\n- BaseAction,\n-} from '../types/redux-types';\n+import type { BaseAction } from '../types/redux-types';\nimport type { RawEntryInfo, EntryStore } from '../types/entry-types';\nimport _flow from 'lodash/fp/flow';\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/reducers/loading-reducer.js",
"new_path": "lib/reducers/loading-reducer.js",
"diff": "// @flow\n-import type {\n- BaseAppState,\n- BaseAction,\n-} from '../types/redux-types';\n+import type { BaseAction } from '../types/redux-types';\nimport type { LoadingStatus } from '../types/loading-types';\nimport type { ActionTypes } from '../utils/action-utils';\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/reducers/thread-reducer.js",
"new_path": "lib/reducers/thread-reducer.js",
"diff": "// @flow\n-import type {\n- BaseAppState,\n- BaseAction,\n-} from '../types/redux-types';\n+import type { BaseAction } from '../types/redux-types';\nimport type { ThreadInfo } from '../types/thread-types';\nimport invariant from 'invariant';\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/reducers/user-reducer.js",
"new_path": "lib/reducers/user-reducer.js",
"diff": "// @flow\n-import type {\n- BaseAppState,\n- BaseAction,\n-} from '../types/redux-types';\n+import type { BaseAction } from '../types/redux-types';\nimport type { CurrentUserInfo, UserInfo } from '../types/user-types';\nimport invariant from 'invariant';\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Stop importing the BaseAppState type in all reducers |
129,187 | 04.10.2017 15:26:06 | 14,400 | ddcce57fb248ae64f6e6e55bcfb7114cb78767a5 | Introduce "drafts" to Redux state | [
{
"change_type": "ADD",
"old_path": null,
"new_path": "lib/reducers/draft-reducer.js",
"diff": "+// @flow\n+\n+import type { BaseAction } from '../types/redux-types';\n+\n+function reduceDrafts(\n+ state: ?{[key: string]: string},\n+ action: BaseAction,\n+): {[key: string]: string} {\n+ if (!state) {\n+ state = {};\n+ }\n+ return state;\n+}\n+\n+export default reduceDrafts;\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/reducers/master-reducer.js",
"new_path": "lib/reducers/master-reducer.js",
"diff": "@@ -14,6 +14,7 @@ import reduceCookie from './cookie-reducer';\nimport reduceSessionID from './session-reducer';\nimport { reduceMessageStore } from './message-reducer';\nimport reduceCurrentAsOf from './current-as-of-reducer';\n+import reduceDrafts from './draft-reducer';\nexport default function baseReducer<T: BaseAppState>(\nstate: T,\n@@ -64,6 +65,7 @@ export default function baseReducer<T: BaseAppState>(\nthreadInfos: reduceThreadInfos(state.threadInfos, action),\nuserInfos: reduceUserInfos(state.userInfos, action),\nmessageStore: reduceMessageStore(state.messageStore, action),\n+ drafts: reduceDrafts(state.drafts, action),\ncurrentAsOf: reduceCurrentAsOf(state.currentAsOf, action),\ncookie: reduceCookie(state.cookie, action),\nsessionID,\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/types/redux-types.js",
"new_path": "lib/types/redux-types.js",
"diff": "@@ -42,6 +42,7 @@ export type BaseAppState = {\nthreadInfos: {[id: string]: ThreadInfo},\nuserInfos: {[id: string]: UserInfo},\nmessageStore: MessageStore,\n+ drafts: {[key: string]: string},\ncurrentAsOf: number, // millisecond timestamp\nloadingStatuses: {[key: string]: {[idx: number]: LoadingStatus}},\ncookie: ?string,\n"
},
{
"change_type": "MODIFY",
"old_path": "native/redux-setup.js",
"new_path": "native/redux-setup.js",
"diff": "@@ -35,6 +35,7 @@ export type AppState = {|\nthreadInfos: {[id: string]: ThreadInfo},\nuserInfos: {[id: string]: UserInfo},\nmessageStore: MessageStore,\n+ drafts: {[key: string]: string},\ncurrentAsOf: number,\nloadingStatuses: {[key: string]: {[idx: number]: LoadingStatus}},\ncookie: ?string,\n@@ -57,6 +58,7 @@ const defaultState = ({\nmessages: {},\nthreads: {},\n},\n+ drafts: {},\ncurrentAsOf: 0,\nloadingStatuses: {},\ncookie: null,\n@@ -90,6 +92,7 @@ function reducer(state: AppState, action: Action) {\nthreadInfos: state.threadInfos,\nuserInfos: state.userInfos,\nmessageStore: state.messageStore,\n+ drafts: state.drafts,\ncurrentAsOf: state.currentAsOf,\nloadingStatuses: state.loadingStatuses,\ncookie: state.cookie,\n@@ -106,6 +109,7 @@ function reducer(state: AppState, action: Action) {\nthreadInfos: state.threadInfos,\nuserInfos: state.userInfos,\nmessageStore: state.messageStore,\n+ drafts: state.drafts,\ncurrentAsOf: state.currentAsOf,\nloadingStatuses: state.loadingStatuses,\ncookie: state.cookie,\n@@ -154,6 +158,7 @@ function reducer(state: AppState, action: Action) {\n},\n},\n},\n+ drafts: state.drafts,\ncurrentAsOf: state.currentAsOf,\nloadingStatuses: state.loadingStatuses,\ncookie: state.cookie,\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Introduce "drafts" to Redux state |
129,187 | 04.10.2017 23:52:00 | 14,400 | c9a10ad34efa78d5072455fffe7fb6472ec4a793 | Use Redux-synced ThreadInfo in MessageList | [
{
"change_type": "MODIFY",
"old_path": "native/chat/message-list.react.js",
"new_path": "native/chat/message-list.react.js",
"diff": "@@ -102,6 +102,7 @@ type Props = {\nmessageListData: $ReadOnlyArray<ChatMessageItem>,\nviewerID: ?string,\nstartReached: bool,\n+ threadInfo: ThreadInfo,\n// Redux dispatch functions\ndispatchActionPromise: DispatchActionPromise,\n// async functions that hit server APIs\n@@ -128,10 +129,12 @@ class InnerMessageList extends React.PureComponent {\n}).isRequired,\n}).isRequired,\nnavigate: PropTypes.func.isRequired,\n+ setParams: PropTypes.func.isRequired,\n}).isRequired,\nmessageListData: PropTypes.arrayOf(chatMessageItemPropType).isRequired,\nviewerID: PropTypes.string,\nstartReached: PropTypes.bool.isRequired,\n+ threadInfo: threadInfoPropType.isRequired,\ndispatchActionPromise: PropTypes.func.isRequired,\nfetchMessages: PropTypes.func.isRequired,\n};\n@@ -213,6 +216,15 @@ class InnerMessageList extends React.PureComponent {\n}\ncomponentWillReceiveProps(nextProps: Props) {\n+ if (\n+ !_isEqual(nextProps.threadInfo)\n+ (this.props.navigation.state.params.threadInfo)\n+ ) {\n+ this.props.navigation.setParams({\n+ threadInfo: nextProps.threadInfo,\n+ });\n+ }\n+\nif (nextProps.listData === this.props.messageListData) {\nreturn;\n}\n@@ -400,7 +412,7 @@ class InnerMessageList extends React.PureComponent {\n);\n}\n- const threadID = this.props.navigation.state.params.threadInfo.id;\n+ const threadID = this.props.threadInfo.id;\nconst inputBar = <InputBar threadID={threadID} />;\nconst behavior = Platform.OS === \"android\" ? undefined : \"padding\";\n@@ -461,7 +473,7 @@ class InnerMessageList extends React.PureComponent {\nconst oldestMessageServerID = this.oldestMessageServerID();\nif (oldestMessageServerID) {\nthis.loadingFromScroll = true;\n- const threadID = this.props.navigation.state.params.threadInfo.id;\n+ const threadID = this.props.threadInfo.id;\nthis.props.dispatchActionPromise(\nfetchMessagesActionTypes,\nthis.props.fetchMessages(\n@@ -524,6 +536,7 @@ const MessageList = connect(\nviewerID: state.currentUserInfo && state.currentUserInfo.id,\nstartReached: !!(state.messageStore.threads[threadID] &&\nstate.messageStore.threads[threadID].startReached),\n+ threadInfo: state.threadInfos[threadID],\ncookie: state.cookie,\n};\n},\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Use Redux-synced ThreadInfo in MessageList |
129,187 | 05.10.2017 00:16:37 | 14,400 | bc649d4027e92aa5fe8c7791a0e53897e0fbc826 | Support for editing names | [
{
"change_type": "MODIFY",
"old_path": "lib/actions/thread-actions.js",
"new_path": "lib/actions/thread-actions.js",
"diff": "@@ -64,6 +64,22 @@ async function changeThreadSettings(\n};\n}\n+async function changeSingleThreadSetting(\n+ fetchJSON: FetchJSON,\n+ threadID: string,\n+ field: \"name\" | \"description\" | \"color\",\n+ value: string,\n+): Promise<ChangeThreadSettingsResult> {\n+ const response = await fetchJSON('edit_thread.php', {\n+ 'thread': threadID,\n+ [field]: value,\n+ });\n+ return {\n+ threadInfo: response.thread_info,\n+ newMessageInfos: response.new_message_infos,\n+ };\n+}\n+\nconst addUsersToThreadActionTypes = {\nstarted: \"ADD_USERS_TO_THREAD_STARTED\",\nsuccess: \"ADD_USERS_TO_THREAD_SUCCESS\",\n@@ -190,6 +206,7 @@ export {\ndeleteThread,\nchangeThreadSettingsActionTypes,\nchangeThreadSettings,\n+ changeSingleThreadSetting,\naddUsersToThreadActionTypes,\naddUsersToThread,\nnewThreadActionTypes,\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/chat/settings/save-setting-button.react.js",
"diff": "+// @flow\n+\n+import React from 'react';\n+import { TouchableOpacity, StyleSheet } from 'react-native';\n+import Icon from 'react-native-vector-icons/Ionicons';\n+\n+type Props = {|\n+ onPress: () => void,\n+|};\n+function SaveSettingButton(props: Props) {\n+ return (\n+ <TouchableOpacity onPress={props.onPress} style={styles.container}>\n+ <Icon\n+ name=\"md-checkbox-outline\"\n+ size={24}\n+ style={styles.editIcon}\n+ color=\"#009900\"\n+ />\n+ </TouchableOpacity>\n+ );\n+}\n+\n+const styles = StyleSheet.create({\n+ editIcon: {\n+ paddingLeft: 10,\n+ paddingTop: 6,\n+ textAlign: 'right',\n+ lineHeight: 16,\n+ },\n+ container: {\n+ height: 16,\n+ },\n+});\n+\n+export default SaveSettingButton;\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/settings/thread-settings-user.react.js",
"new_path": "native/chat/settings/thread-settings-user.react.js",
"diff": "@@ -15,20 +15,27 @@ type Props = {|\nisViewer: bool,\n|},\nthreadInfo: ThreadInfo,\n+ canEdit: bool,\n|};\nfunction ThreadSettingsUser(props: Props) {\nconst canChange = !props.userInfo.isViewer &&\nprops.threadInfo.canChangeSettings;\n- return (\n- <View style={styles.container}>\n- <Text style={styles.username} numberOfLines={1}>\n- {props.userInfo.username}\n- </Text>\n+ let editButton = null;\n+ if (props.canEdit) {\n+ editButton = (\n<EditSettingButton\nonPress={() => {}}\ncanChangeSettings={canChange}\nstyle={styles.editSettingsIcon}\n/>\n+ );\n+ }\n+ return (\n+ <View style={styles.container}>\n+ <Text style={styles.username} numberOfLines={1}>\n+ {props.userInfo.username}\n+ </Text>\n+ {editButton}\n</View>\n);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/settings/thread-settings.react.js",
"new_path": "native/chat/settings/thread-settings.react.js",
"diff": "@@ -10,18 +10,41 @@ import { threadInfoPropType } from 'lib/types/thread-types';\nimport type { AppState } from '../../redux-setup';\nimport type { RelativeUserInfo } from 'lib/types/user-types';\nimport { relativeUserInfoPropType } from 'lib/types/user-types';\n+import type { DispatchActionPromise } from 'lib/utils/action-utils';\n+import type { ChangeThreadSettingsResult } from 'lib/actions/thread-actions';\n+import type { LoadingStatus } from 'lib/types/loading-types';\n+import { loadingStatusPropType } from 'lib/types/loading-types';\nimport React from 'react';\nimport { connect } from 'react-redux';\nimport PropTypes from 'prop-types';\n-import { ScrollView, StyleSheet, Text, View } from 'react-native';\n+import {\n+ ScrollView,\n+ StyleSheet,\n+ Text,\n+ View,\n+ TextInput,\n+ Alert,\n+ ActivityIndicator,\n+} from 'react-native';\nimport Modal from 'react-native-modal';\n+import invariant from 'invariant';\n+import _isEqual from 'lodash/fp/isEqual';\nimport { visibilityRules } from 'lib/types/thread-types';\nimport {\nrelativeUserInfoSelectorForMembersOfThread,\n} from 'lib/selectors/user-selectors';\nimport { childThreadInfos } from 'lib/selectors/thread-selectors';\n+import { createLoadingStatusSelector } from 'lib/selectors/loading-selectors';\n+import {\n+ changeThreadSettingsActionTypes,\n+ changeSingleThreadSetting,\n+} from 'lib/actions/thread-actions';\n+import {\n+ includeDispatchActionProps,\n+ bindServerCalls,\n+} from 'lib/utils/action-utils';\nimport ThreadSettingsCategory from './thread-settings-category.react';\nimport ColorSplotch from '../../components/color-splotch.react';\n@@ -34,6 +57,7 @@ import AddUsersModal from './add-users-modal.react';\nimport ThreadSettingsChildThread from './thread-settings-child-thread.react';\nimport { AddThreadRouteName } from '../add-thread.react';\nimport { registerChatScreen } from '../chat-screen-registry';\n+import SaveSettingButton from './save-setting-button.react';\nconst itemPageLength = 5;\n@@ -47,11 +71,22 @@ type Props = {|\nparentThreadInfo: ?ThreadInfo,\nthreadMembers: RelativeUserInfo[],\nchildThreadInfos: ?ThreadInfo[],\n+ loadingStatus: LoadingStatus,\n+ // Redux dispatch functions\n+ dispatchActionPromise: DispatchActionPromise,\n+ // async functions that hit server APIs\n+ changeSingleThreadSetting: (\n+ threadID: string,\n+ field: \"name\" | \"description\" | \"color\",\n+ value: string,\n+ ) => Promise<ChangeThreadSettingsResult>,\n|};\ntype State = {|\nshowAddUsersModal: bool,\nshowMaxMembers: number,\nshowMaxChildThreads: number,\n+ nameEditValue: ?string,\n+ currentlyEditingColor: bool,\n|};\nclass InnerThreadSettings extends React.PureComponent {\n@@ -60,6 +95,8 @@ class InnerThreadSettings extends React.PureComponent {\nshowAddUsersModal: false,\nshowMaxMembers: itemPageLength,\nshowMaxChildThreads: itemPageLength,\n+ nameEditValue: null,\n+ currentlyEditingColor: false,\n};\nstatic propTypes = {\nnavigation: PropTypes.shape({\n@@ -71,15 +108,20 @@ class InnerThreadSettings extends React.PureComponent {\n}).isRequired,\nnavigate: PropTypes.func.isRequired,\ngoBack: PropTypes.func.isRequired,\n+ setParams: PropTypes.func.isRequired,\n}).isRequired,\nthreadInfo: threadInfoPropType.isRequired,\nparentThreadInfo: threadInfoPropType,\nthreadMembers: PropTypes.arrayOf(relativeUserInfoPropType).isRequired,\nchildThreadInfos: PropTypes.arrayOf(threadInfoPropType),\n+ loadingStatus: loadingStatusPropType.isRequired,\n+ dispatchActionPromise: PropTypes.func.isRequired,\n+ changeSingleThreadSetting: PropTypes.func.isRequired,\n};\nstatic navigationOptions = ({ navigation }) => ({\ntitle: navigation.state.params.threadInfo.name,\n});\n+ nameTextInput: ?TextInput;\ncomponentDidMount() {\nregisterChatScreen(this.props.navigation.state.key, this);\n@@ -89,9 +131,76 @@ class InnerThreadSettings extends React.PureComponent {\nregisterChatScreen(this.props.navigation.state.key, null);\n}\n- canReset = () => false;\n+ componentWillReceiveProps(nextProps: Props) {\n+ if (\n+ !_isEqual(nextProps.threadInfo)\n+ (this.props.navigation.state.params.threadInfo)\n+ ) {\n+ this.props.navigation.setParams({\n+ threadInfo: nextProps.threadInfo,\n+ });\n+ }\n+ }\n+\n+ canReset = () => {\n+ return !this.state.showAddUsersModal &&\n+ (this.state.nameEditValue === null ||\n+ this.state.nameEditValue === undefined) &&\n+ !this.state.currentlyEditingColor &&\n+ this.props.loadingStatus !== \"loading\";\n+ }\nrender() {\n+ const canDoAnything = this.props.loadingStatus !== \"loading\";\n+ const canStartEditing = this.canReset();\n+ const canChangeSettings = this.props.threadInfo.canChangeSettings\n+ && canStartEditing;\n+\n+ let name;\n+ if (\n+ this.state.nameEditValue === null ||\n+ this.state.nameEditValue === undefined\n+ ) {\n+ name = [\n+ <Text style={[styles.currentValue, styles.currentValueText]} key=\"text\">\n+ {this.props.threadInfo.name}\n+ </Text>,\n+ <EditSettingButton\n+ onPress={this.onPressEditName}\n+ canChangeSettings={canChangeSettings}\n+ key=\"editButton\"\n+ />,\n+ ];\n+ } else {\n+ let button;\n+ if (canDoAnything) {\n+ button = (\n+ <SaveSettingButton\n+ onPress={this.submitNameEdit}\n+ key=\"saveButton\"\n+ />\n+ );\n+ } else {\n+ button = <ActivityIndicator size=\"small\" key=\"activityIndicator\" />;\n+ }\n+ name = [\n+ <TextInput\n+ style={[styles.currentValue, styles.currentValueText]}\n+ underlineColorAndroid=\"transparent\"\n+ value={this.state.nameEditValue}\n+ onChangeText={this.onChangeNameText}\n+ multiline={true}\n+ autoFocus={true}\n+ selectTextOnFocus={true}\n+ onBlur={this.submitNameEdit}\n+ editable={canDoAnything}\n+ ref={this.nameTextInputRef}\n+ key=\"textInput\"\n+ />,\n+ button,\n+ ];\n+ }\n+\nlet parent;\nif (this.props.parentThreadInfo) {\nparent = (\n@@ -119,6 +228,7 @@ class InnerThreadSettings extends React.PureComponent {\n</Text>\n);\n}\n+\nconst visRules = this.props.threadInfo.visibilityRules;\nconst visibility =\nvisRules === visibilityRules.OPEN ||\n@@ -160,6 +270,7 @@ class InnerThreadSettings extends React.PureComponent {\n<ThreadSettingsUser\nuserInfo={userInfoWithUsername}\nthreadInfo={this.props.threadInfo}\n+ canEdit={canStartEditing}\n/>\n</View>\n);\n@@ -212,13 +323,7 @@ class InnerThreadSettings extends React.PureComponent {\n<ThreadSettingsCategory type=\"full\" title=\"Basics\">\n<View style={styles.row}>\n<Text style={styles.label}>Name</Text>\n- <Text style={[styles.currentValue, styles.currentValueText]}>\n- {this.props.threadInfo.name}\n- </Text>\n- <EditSettingButton\n- onPress={this.onPressEditName}\n- canChangeSettings={this.props.threadInfo.canChangeSettings}\n- />\n+ {name}\n</View>\n<View style={styles.colorRow}>\n<Text style={[styles.label, styles.colorLine]}>Color</Text>\n@@ -227,7 +332,7 @@ class InnerThreadSettings extends React.PureComponent {\n</View>\n<EditSettingButton\nonPress={this.onPressEditColor}\n- canChangeSettings={this.props.threadInfo.canChangeSettings}\n+ canChangeSettings={canChangeSettings}\nstyle={styles.colorLine}\n/>\n</View>\n@@ -287,10 +392,67 @@ class InnerThreadSettings extends React.PureComponent {\n);\n}\n+ nameTextInputRef = (nameTextInput: ?TextInput) => {\n+ this.nameTextInput = nameTextInput;\n+ }\n+\nonPressEditName = () => {\n+ this.setState({ nameEditValue: this.props.threadInfo.name });\n}\nonPressEditColor = () => {\n+ this.setState({ currentlyEditingColor: true });\n+ }\n+\n+ onChangeNameText = (text: string) => {\n+ this.setState({ nameEditValue: text });\n+ }\n+\n+ submitNameEdit = () => {\n+ invariant(\n+ this.state.nameEditValue !== null &&\n+ this.state.nameEditValue !== undefined,\n+ \"should be set\",\n+ );\n+ const name = this.state.nameEditValue.trim();\n+ if (name === '') {\n+ Alert.alert(\n+ \"Empty thread name\",\n+ \"You must specify a thread name!\",\n+ [\n+ { text: 'OK', onPress: this.onNameErrorAcknowledged },\n+ ],\n+ { cancelable: false },\n+ );\n+ return;\n+ }\n+\n+ this.props.dispatchActionPromise(\n+ changeThreadSettingsActionTypes,\n+ this.editName(name),\n+ );\n+ }\n+\n+ async editName(newName: string) {\n+ try {\n+ const result = await this.props.changeSingleThreadSetting(\n+ this.props.threadInfo.id,\n+ \"name\",\n+ newName,\n+ );\n+ this.setState({ nameEditValue: null });\n+ return result;\n+ } catch (e) {\n+ Alert.alert(\n+ \"Unknown error\",\n+ \"Uhh... try again?\",\n+ [\n+ { text: 'OK', onPress: this.onNameErrorAcknowledged },\n+ ],\n+ { cancelable: false },\n+ );\n+ throw e;\n+ }\n}\nonPressParentThread = () => {\n@@ -327,6 +489,11 @@ class InnerThreadSettings extends React.PureComponent {\n}));\n}\n+ onNameErrorAcknowledged = () => {\n+ invariant(this.nameTextInput, \"nameTextInput should be set\");\n+ this.nameTextInput.focus();\n+ }\n+\n}\nconst styles = StyleSheet.create({\n@@ -379,8 +546,10 @@ const styles = StyleSheet.create({\nmarginTop: 4,\n},\ncurrentValueText: {\n+ paddingTop: 0,\nfontSize: 16,\ncolor: \"#333333\",\n+ fontFamily: 'Arial',\n},\nnoParent: {\nfontStyle: 'italic',\n@@ -398,6 +567,9 @@ const styles = StyleSheet.create({\n},\n});\n+const loadingStatusSelector\n+ = createLoadingStatusSelector(changeThreadSettingsActionTypes);\n+\nconst ThreadSettingsRouteName = 'ThreadSettings';\nconst ThreadSettings = connect(\n(state: AppState, ownProps: { navigation: NavProp }) => {\n@@ -412,8 +584,12 @@ const ThreadSettings = connect(\nthreadMembers:\nrelativeUserInfoSelectorForMembersOfThread(threadInfo.id)(state),\nchildThreadInfos: childThreadInfos(state)[threadInfo.id],\n+ loadingStatus: loadingStatusSelector(state),\n+ cookie: state.cookie,\n};\n},\n+ includeDispatchActionProps,\n+ bindServerCalls({ changeSingleThreadSetting }),\n)(InnerThreadSettings);\nexport {\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Support for editing names |
129,187 | 05.10.2017 00:21:18 | 14,400 | e8d8cf0261c940816fc567d6adac10c0fd152f2a | Don't bother saving if the thread name is the same as the current one | [
{
"change_type": "MODIFY",
"old_path": "native/chat/settings/thread-settings.react.js",
"new_path": "native/chat/settings/thread-settings.react.js",
"diff": "@@ -415,7 +415,11 @@ class InnerThreadSettings extends React.PureComponent {\n\"should be set\",\n);\nconst name = this.state.nameEditValue.trim();\n- if (name === '') {\n+\n+ if (name === this.props.threadInfo.name) {\n+ this.setState({ nameEditValue: null });\n+ return;\n+ } else if (name === '') {\nAlert.alert(\n\"Empty thread name\",\n\"You must specify a thread name!\",\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Don't bother saving if the thread name is the same as the current one |
129,187 | 05.10.2017 00:22:17 | 14,400 | eff520e7bc4b79b21f0a582a89cfe8501e3ad9f5 | Update the robotext for messageType.CHANGE_SETTINGS | [
{
"change_type": "MODIFY",
"old_path": "lib/shared/message-utils.js",
"new_path": "lib/shared/message-utils.js",
"diff": "@@ -96,7 +96,7 @@ function robotextForMessageInfo(\nreturn `${creator} created a child thread named ` +\n`\"<${encodeURI(childName)}|t${messageInfo.childThreadInfo.id}>\"`;\n} else if (messageInfo.type === messageType.CHANGE_SETTINGS) {\n- return `${creator} updated \"${messageInfo.field}\" to ` +\n+ return `${creator} updated the thread's ${messageInfo.field} to ` +\n`\"${messageInfo.value}\"`;\n}\ninvariant(false, `${messageInfo.type} is not a messageType!`);\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Update the robotext for messageType.CHANGE_SETTINGS |
129,187 | 05.10.2017 16:07:38 | 14,400 | 5957038930fa75f5047461cac2b590e70436166f | Fix styling of TextInput for name in ThreadSettings | [
{
"change_type": "MODIFY",
"old_path": "native/chat/settings/save-setting-button.react.js",
"new_path": "native/chat/settings/save-setting-button.react.js",
"diff": "@@ -22,13 +22,12 @@ function SaveSettingButton(props: Props) {\nconst styles = StyleSheet.create({\neditIcon: {\n- paddingLeft: 10,\n- paddingTop: 6,\n- textAlign: 'right',\n- lineHeight: 16,\n+ position: 'absolute',\n+ right: 0,\n+ top: -3,\n},\ncontainer: {\n- height: 16,\n+ width: 26,\n},\n});\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/settings/thread-settings.react.js",
"new_path": "native/chat/settings/thread-settings.react.js",
"diff": "@@ -86,6 +86,7 @@ type State = {|\nshowMaxMembers: number,\nshowMaxChildThreads: number,\nnameEditValue: ?string,\n+ nameTextHeight: ?number,\ncurrentlyEditingColor: bool,\n|};\nclass InnerThreadSettings extends React.PureComponent {\n@@ -96,6 +97,7 @@ class InnerThreadSettings extends React.PureComponent {\nshowMaxMembers: itemPageLength,\nshowMaxChildThreads: itemPageLength,\nnameEditValue: null,\n+ nameTextHeight: null,\ncurrentlyEditingColor: false,\n};\nstatic propTypes = {\n@@ -150,6 +152,16 @@ class InnerThreadSettings extends React.PureComponent {\nthis.props.loadingStatus !== \"loading\";\n}\n+ onLayoutNameText = (event: { nativeEvent: { layout: { height: number }}}) => {\n+ this.setState({ nameTextHeight: event.nativeEvent.layout.height });\n+ }\n+\n+ onNameTextInputContentSizeChange = (\n+ event: { nativeEvent: { contentSize: { height: number } } },\n+ ) => {\n+ this.setState({ nameTextHeight: event.nativeEvent.contentSize.height });\n+ }\n+\nrender() {\nconst canDoAnything = this.props.loadingStatus !== \"loading\";\nconst canStartEditing = this.canReset();\n@@ -162,7 +174,11 @@ class InnerThreadSettings extends React.PureComponent {\nthis.state.nameEditValue === undefined\n) {\nname = [\n- <Text style={[styles.currentValue, styles.currentValueText]} key=\"text\">\n+ <Text\n+ style={[styles.currentValue, styles.currentValueText]}\n+ onLayout={this.onLayoutNameText}\n+ key=\"text\"\n+ >\n{this.props.threadInfo.name}\n</Text>,\n<EditSettingButton\n@@ -183,9 +199,16 @@ class InnerThreadSettings extends React.PureComponent {\n} else {\nbutton = <ActivityIndicator size=\"small\" key=\"activityIndicator\" />;\n}\n+ const textInputStyle = {};\n+ if (\n+ this.state.nameTextHeight !== undefined &&\n+ this.state.nameTextHeight !== null\n+ ) {\n+ textInputStyle.height = this.state.nameTextHeight;\n+ }\nname = [\n<TextInput\n- style={[styles.currentValue, styles.currentValueText]}\n+ style={[styles.currentValue, styles.currentValueText, textInputStyle]}\nunderlineColorAndroid=\"transparent\"\nvalue={this.state.nameEditValue}\nonChangeText={this.onChangeNameText}\n@@ -194,6 +217,7 @@ class InnerThreadSettings extends React.PureComponent {\nselectTextOnFocus={true}\nonBlur={this.submitNameEdit}\neditable={canDoAnything}\n+ onContentSizeChange={this.onNameTextInputContentSizeChange}\nref={this.nameTextInputRef}\nkey=\"textInput\"\n/>,\n@@ -529,7 +553,6 @@ const styles = StyleSheet.create({\n},\ncurrentValue: {\nflex: 1,\n- flexDirection: 'row',\npaddingLeft: 4,\n},\nitemRow: {\n@@ -550,7 +573,9 @@ const styles = StyleSheet.create({\nmarginTop: 4,\n},\ncurrentValueText: {\n- paddingTop: 0,\n+ paddingRight: 0,\n+ paddingVertical: 0,\n+ margin: 0,\nfontSize: 16,\ncolor: \"#333333\",\nfontFamily: 'Arial',\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Fix styling of TextInput for name in ThreadSettings |
129,187 | 05.10.2017 18:18:40 | 14,400 | ddc1944dba30b637e8b9bcb7b31bb0bb52a12c44 | Color part of the robotext for a thread-color-changed message | [
{
"change_type": "MODIFY",
"old_path": "lib/shared/message-utils.js",
"new_path": "lib/shared/message-utils.js",
"diff": "@@ -96,8 +96,14 @@ function robotextForMessageInfo(\nreturn `${creator} created a child thread named ` +\n`\"<${encodeURI(childName)}|t${messageInfo.childThreadInfo.id}>\"`;\n} else if (messageInfo.type === messageType.CHANGE_SETTINGS) {\n+ let value;\n+ if (messageInfo.field === \"color\") {\n+ value = `<#${messageInfo.value}|c${messageInfo.threadID}>`;\n+ } else {\n+ value = messageInfo.value;\n+ }\nreturn `${creator} updated the thread's ${messageInfo.field} to ` +\n- `\"${messageInfo.value}\"`;\n+ `\"${value}\"`;\n}\ninvariant(false, `${messageInfo.type} is not a messageType!`);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/robotext-message.react.js",
"new_path": "native/chat/robotext-message.react.js",
"diff": "@@ -98,6 +98,9 @@ class RobotextMessage extends React.PureComponent {\nif (entityType === \"t\") {\ntextParts.push(<ThreadEntity key={id} id={id} name={rawText} />);\ncontinue;\n+ } else if (entityType === \"c\") {\n+ textParts.push(<ColorEntity key={id} color={rawText} />);\n+ continue;\n}\ntextParts.push(rawText);\n@@ -151,6 +154,11 @@ const ThreadEntity = connect(\nincludeDispatchActionProps,\n)(InnerThreadEntity);\n+function ColorEntity(props: {| color: string |}) {\n+ const colorStyle = { color: props.color };\n+ return <Text style={colorStyle}>{props.color}</Text>;\n+}\n+\nconst styles = StyleSheet.create({\nrobotext: {\ntextAlign: 'center',\n"
},
{
"change_type": "MODIFY",
"old_path": "native/package-lock.json",
"new_path": "native/package-lock.json",
"diff": "\"lockfileVersion\": 1,\n\"requires\": true,\n\"dependencies\": {\n- \"1PasswordExtension\": {\n- \"version\": \"git+https://github.com/jjshammas/onepassword-app-extension.git#acf20f71c890e92ee489fc8e7bb0f7df922e855d\"\n- },\n\"@types/node\": {\n\"version\": \"7.0.39\",\n\"resolved\": \"https://registry.npmjs.org/@types/node/-/node-7.0.39.tgz\",\n\"integrity\": \"sha512-KQHAZeVsk4UIT9XaR6cn4WpHZzimK6UBD1UomQKfQQFmTlUHaNBzeuov+TM4+kigLO0IJt4I5OOsshcCyA9gSA==\",\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}\n}\n},\n+ \"string_decoder\": {\n+ \"version\": \"1.0.1\",\n+ \"bundled\": true,\n+ \"requires\": {\n+ \"safe-buffer\": \"5.0.1\"\n+ }\n+ },\n\"string-width\": {\n\"version\": \"1.0.2\",\n\"bundled\": true,\n\"strip-ansi\": \"3.0.1\"\n}\n},\n- \"string_decoder\": {\n- \"version\": \"1.0.1\",\n- \"bundled\": true,\n- \"requires\": {\n- \"safe-buffer\": \"5.0.1\"\n- }\n- },\n\"stringstream\": {\n\"version\": \"0.0.5\",\n\"bundled\": true,\n}\n},\n\"react-navigation\": {\n- \"version\": \"git+https://git@github.com/react-community/react-navigation.git#c08be7fb43ff3fa0553a30e02fa5a4686591e36e\",\n+ \"version\": \"git+https://git@github.com/react-community/react-navigation.git#e4a7b7e073302bf970f1f1112b46a36873f7fc4a\",\n\"requires\": {\n\"babel-plugin-transform-define\": \"1.3.0\",\n\"clamp\": \"1.0.1\",\n}\n}\n},\n+ \"string_decoder\": {\n+ \"version\": \"1.0.3\",\n+ \"resolved\": \"https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz\",\n+ \"integrity\": \"sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==\",\n+ \"requires\": {\n+ \"safe-buffer\": \"5.1.1\"\n+ }\n+ },\n\"string-length\": {\n\"version\": \"1.0.1\",\n\"resolved\": \"https://registry.npmjs.org/string-length/-/string-length-1.0.1.tgz\",\n}\n}\n},\n- \"string_decoder\": {\n- \"version\": \"1.0.3\",\n- \"resolved\": \"https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz\",\n- \"integrity\": \"sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==\",\n- \"requires\": {\n- \"safe-buffer\": \"5.1.1\"\n- }\n- },\n\"stringstream\": {\n\"version\": \"0.0.5\",\n\"resolved\": \"https://registry.npmjs.org/stringstream/-/stringstream-0.0.5.tgz\",\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Color part of the robotext for a thread-color-changed message |
129,187 | 05.10.2017 18:56:20 | 14,400 | 172046739e565da2c32f6b5045a21a0e420be38b | Use "oldColor" functionality on edit thread and add subthread views | [
{
"change_type": "MODIFY",
"old_path": "native/chat/add-thread.react.js",
"new_path": "native/chat/add-thread.react.js",
"diff": "@@ -227,6 +227,9 @@ class InnerAddThread extends React.PureComponent {\n</View>\n);\n}\n+ const oldColor = this.props.parentThreadInfo\n+ ? this.props.parentThreadInfo.color\n+ : null;\nconst content = (\n<View style={styles.content}>\n<View style={styles.row}>\n@@ -283,6 +286,7 @@ class InnerAddThread extends React.PureComponent {\nisVisible={this.state.showColorPicker}\ncloseModal={this.closeColorPicker}\ncolor={this.state.color}\n+ oldColor={oldColor}\nonColorSelected={this.onColorSelected}\n/>\n</View>\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/color-picker-modal.react.js",
"new_path": "native/chat/color-picker-modal.react.js",
"diff": "@@ -14,12 +14,14 @@ class ColorPickerModal extends React.PureComponent {\nisVisible: bool,\ncloseModal: () => void,\ncolor: string,\n+ oldColor?: string,\nonColorSelected: (color: string) => void,\n|};\nstatic propTypes = {\nisVisible: PropTypes.bool.isRequired,\ncloseModal: PropTypes.func.isRequired,\ncolor: PropTypes.string.isRequired,\n+ oldColor: PropTypes.string,\nonColorSelected: PropTypes.func.isRequired,\n};\n@@ -33,6 +35,7 @@ class ColorPickerModal extends React.PureComponent {\n<View style={styles.colorPickerContainer}>\n<ColorPicker\ndefaultColor={this.props.color}\n+ oldColor={this.props.oldColor}\nonColorSelected={this.props.onColorSelected}\nstyle={styles.colorPicker}\n/>\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/settings/thread-settings.react.js",
"new_path": "native/chat/settings/thread-settings.react.js",
"diff": "@@ -441,6 +441,7 @@ class InnerThreadSettings extends React.PureComponent {\nisVisible={this.state.showEditColorModal}\ncloseModal={this.closeColorPicker}\ncolor={this.state.colorEditValue}\n+ oldColor={this.props.threadInfo.color}\nonColorSelected={this.onColorSelected}\n/>\n</View>\n"
},
{
"change_type": "MODIFY",
"old_path": "native/components/color-picker.react.js",
"new_path": "native/components/color-picker.react.js",
"diff": "@@ -42,6 +42,7 @@ type Props = {\nonOldColorSelected?: (color: string) => void,\nstyle?: StyleObj,\nbuttonText: string,\n+ oldButtonText: string,\n};\ntype State = {\ncolor: HSVColor,\n@@ -66,9 +67,11 @@ class ColorPicker extends React.PureComponent {\nonOldColorSelected: PropTypes.func,\nstyle: ViewPropTypes.style,\nbuttonText: PropTypes.string,\n+ oldButtonText: PropTypes.string,\n};\nstatic defaultProps = {\nbuttonText: \"Select\",\n+ oldButtonText: \"Reset\",\n};\nprops: Props;\nstate: State;\n@@ -312,7 +315,7 @@ class ColorPicker extends React.PureComponent {\nrender() {\nconst { pickerSize } = this.state;\n- const { oldColor, style } = this.props;\n+ const { style } = this.props;\nconst color = this._getColor();\nconst tc = tinycolor(color);\nconst selectedColor: string = tc.toHexString();\n@@ -330,7 +333,7 @@ class ColorPicker extends React.PureComponent {\nselectedColor,\nselectedColorHsv: color,\nindicatorColor,\n- oldColor,\n+ oldColor: this.props.oldColor,\nangle,\nisRTL: I18nManager.isRTL,\n});\n@@ -369,18 +372,26 @@ class ColorPicker extends React.PureComponent {\n}\nlet oldColorButton = null;\n- if (oldColor) {\n+ if (this.props.oldColor) {\n+ const oldTinyColor = tinycolor(this.props.oldColor);\n+ const oldButtonTextStyle = {\n+ color: oldTinyColor.isDark() ? 'white' : 'black',\n+ };\noldColorButton = (\n<Button\ntopStyle={styles.colorPreview}\nstyle={[\nstyles.buttonContents,\n- { backgroundColor: oldColor },\n+ { backgroundColor: oldTinyColor.toHexString() },\n]}\nonPress={this._onOldColorSelected}\niosFormat=\"highlight\"\niosActiveOpacity={0.6}\n- />\n+ >\n+ <Text style={[styles.buttonText, oldButtonTextStyle]}>\n+ {this.props.oldButtonText}\n+ </Text>\n+ </Button>\n);\n}\nconst colorPreviewsStyle = {\n@@ -617,6 +628,7 @@ const styles = StyleSheet.create({\n},\ncolorPreview: {\nflex: 1,\n+ marginHorizontal: 5,\n},\nbuttonContents: {\nflex: 1,\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Use "oldColor" functionality on edit thread and add subthread views |
129,187 | 06.10.2017 14:08:41 | 14,400 | b2f35373ef95e6963c96deddd40b5fe669104512 | Refactor PanelButton to use Button | [
{
"change_type": "MODIFY",
"old_path": "native/account/panel-components.react.js",
"new_path": "native/account/panel-components.react.js",
"diff": "// @flow\nimport type { LoadingStatus } from 'lib/types/loading-types';\n+import { loadingStatusPropType } from 'lib/types/loading-types';\nimport type {\nStyleObj,\n} from 'react-native/Libraries/StyleSheet/StyleSheetTypes';\nimport React from 'react';\nimport {\n- Platform,\nView,\nActivityIndicator,\n- TouchableNativeFeedback,\nText,\n- TouchableHighlight,\nStyleSheet,\nTouchableWithoutFeedback,\nImage,\n@@ -21,6 +19,8 @@ import {\nimport Icon from 'react-native-vector-icons/FontAwesome';\nimport PropTypes from 'prop-types';\n+import Button from '../components/button.react';\n+\nclass PanelButton extends React.PureComponent {\nprops: {\n@@ -30,7 +30,7 @@ class PanelButton extends React.PureComponent {\n};\nstatic propTypes = {\ntext: PropTypes.string.isRequired,\n- loadingStatus: PropTypes.string.isRequired,\n+ loadingStatus: loadingStatusPropType.isRequired,\nonSubmit: PropTypes.func.isRequired,\n};\n@@ -49,34 +49,21 @@ class PanelButton extends React.PureComponent {\n</View>\n);\n}\n- if (Platform.OS === \"android\") {\n- return (\n- <TouchableNativeFeedback\n- onPress={this.props.onSubmit}\n- disabled={this.props.loadingStatus === \"loading\"}\n- >\n- <View style={[styles.submitContentContainer, styles.submitButton]}>\n- <Text style={styles.submitContentText}>{this.props.text}</Text>\n- {buttonIcon}\n- </View>\n- </TouchableNativeFeedback>\n- );\n- } else {\nreturn (\n- <TouchableHighlight\n+ <Button\nonPress={this.props.onSubmit}\n- style={styles.submitButton}\n- underlayColor=\"#A0A0A0DD\"\ndisabled={this.props.loadingStatus === \"loading\"}\n+ topStyle={styles.submitButton}\n+ style={styles.submitContentContainer}\n+ iosFormat=\"highlight\"\n+ iosActiveOpacity={0.85}\n+ iosHighlightUnderlayColor=\"#A0A0A0DD\"\n>\n- <View style={styles.submitContentContainer}>\n<Text style={styles.submitContentText}>{this.props.text}</Text>\n{buttonIcon}\n- </View>\n- </TouchableHighlight>\n+ </Button>\n);\n}\n- }\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/color-picker-modal.react.js",
"new_path": "native/chat/color-picker-modal.react.js",
"diff": "@@ -14,7 +14,7 @@ class ColorPickerModal extends React.PureComponent {\nisVisible: bool,\ncloseModal: () => void,\ncolor: string,\n- oldColor?: string,\n+ oldColor?: ?string,\nonColorSelected: (color: string) => void,\n|};\nstatic propTypes = {\n"
},
{
"change_type": "MODIFY",
"old_path": "native/components/color-picker.react.js",
"new_path": "native/components/color-picker.react.js",
"diff": "@@ -36,7 +36,7 @@ type HSVColor = {| h: number, s: number, v: number |};\ntype Props = {\ncolor?: string | HSVColor,\ndefaultColor?: string,\n- oldColor?: string,\n+ oldColor?: ?string,\nonColorChange?: (color: HSVColor) => void,\nonColorSelected?: (color: string) => void,\nonOldColorSelected?: (color: string) => void,\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Refactor PanelButton to use Button |
129,187 | 06.10.2017 16:59:56 | 14,400 | f3d6ef62e16b64ecf38bd8e568723414d76cf66c | Implement assertNavigationRouteNotLeafNode and use it in AddThread's connect call | [
{
"change_type": "MODIFY",
"old_path": "native/chat/add-thread.react.js",
"new_path": "native/chat/add-thread.react.js",
"diff": "@@ -61,6 +61,7 @@ import LinkButton from '../components/link-button.react';\nimport { MessageListRouteName } from './message-list.react';\nimport { registerChatScreen } from './chat-screen-registry';\nimport ColorPickerModal from './color-picker-modal.react';\n+import { assertNavigationRouteNotLeafNode } from '../utils/navigation-utils';\ntype NavProp = NavigationScreenProp<NavigationRoute, NavigationAction>\n& { state: { params: { parentThreadID: ?string } } };\n@@ -73,7 +74,7 @@ type Props = {\nparentThreadInfo: ?ThreadInfo,\notherUserInfos: {[id: string]: UserInfo},\nuserSearchIndex: SearchIndex,\n- secondChatRouteKey: ?string,\n+ secondChatSubrouteKey: ?string,\n// Redux dispatch functions\ndispatchActionPromise: DispatchActionPromise,\n// async functions that hit server APIs\n@@ -116,7 +117,7 @@ class InnerAddThread extends React.PureComponent {\nparentThreadInfo: threadInfoPropType,\notherUserInfos: PropTypes.objectOf(userInfoPropType).isRequired,\nuserSearchIndex: PropTypes.instanceOf(SearchIndex).isRequired,\n- secondChatRouteKey: PropTypes.string,\n+ secondChatSubrouteKey: PropTypes.string,\ndispatchActionPromise: PropTypes.func.isRequired,\nnewChatThread: PropTypes.func.isRequired,\nsearchUsers: PropTypes.func.isRequired,\n@@ -419,9 +420,9 @@ class InnerAddThread extends React.PureComponent {\nthis.state.userInfoInputArray.map((userInfo: UserInfo) => userInfo.id),\nthis.props.parentThreadInfo ? this.props.parentThreadInfo.id : null,\n);\n- const secondChatRouteKey = this.props.secondChatRouteKey;\n- invariant(secondChatRouteKey, \"should be set\");\n- this.props.navigation.goBack(secondChatRouteKey);\n+ const secondChatSubrouteKey = this.props.secondChatSubrouteKey;\n+ invariant(secondChatSubrouteKey, \"should be set\");\n+ this.props.navigation.goBack(secondChatSubrouteKey);\nthis.props.navigation.navigate(\nMessageListRouteName,\n{ threadInfo: response.newThreadInfo },\n@@ -557,16 +558,10 @@ const AddThread = connect(\nparentThreadInfo = state.threadInfos[parentThreadID];\ninvariant(parentThreadInfo, \"parent thread should exist\");\n}\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];\n+ const appRoute =\n+ assertNavigationRouteNotLeafNode(state.navInfo.navigationState.routes[0]);\n+ const chatRoute = assertNavigationRouteNotLeafNode(appRoute.routes[1]);\n+ const secondChatSubroute = chatRoute.routes[1];\nreturn {\nloadingStatus: loadingStatusSelector(state),\nparentThreadInfo,\n@@ -574,8 +569,8 @@ const AddThread = connect(\nuserInfoSelectorForOtherMembersOfThread(parentThreadID)(state),\nuserSearchIndex:\nuserSearchIndexForOtherMembersOfThread(parentThreadID)(state),\n- secondChatRouteKey: secondChatRoute && secondChatRoute.key\n- ? secondChatRoute.key\n+ secondChatSubrouteKey: secondChatSubroute && secondChatSubroute.key\n+ ? secondChatSubroute.key\n: null,\ncookie: state.cookie,\n};\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/utils/navigation-utils.js",
"diff": "+// @flow\n+\n+import type {\n+ NavigationLeafRoute,\n+ NavigationStateRoute,\n+ NavigationRoute,\n+} from 'react-navigation/src/TypeDefinition';\n+\n+import invariant from 'invariant';\n+\n+function assertNavigationRouteNotLeafNode(\n+ route: NavigationRoute,\n+): NavigationStateRoute {\n+ // There's no way in Flow to type the exact shape of our navigationState,\n+ // since arrays types can't be refined to tuples. We thus must rely on runtime\n+ // assertions to satisfy Flow's typesystem.\n+ invariant(\n+ route.routes &&\n+ Array.isArray(route.routes) &&\n+ route.index !== null && route.index !== undefined &&\n+ typeof route.index === \"number\",\n+ \"route should be a NavigationStateRoute\",\n+ );\n+ const index = route.index;\n+ const routes = [];\n+ for (let subroute of route.routes) {\n+ invariant(\n+ subroute &&\n+ typeof subroute === \"object\" &&\n+ typeof subroute.key === \"string\" &&\n+ typeof subroute.routeName === \"string\",\n+ \"subroute should be a NavigationRoute!\",\n+ );\n+ let subrouteCopy: NavigationRoute = {\n+ key: subroute.key,\n+ routeName: subroute.routeName,\n+ };\n+ if (subroute.path) {\n+ invariant(\n+ typeof subroute.path === \"string\",\n+ \"navigation's path should be a string!\",\n+ );\n+ subrouteCopy.path = subroute.path;\n+ }\n+ if (subroute.params) {\n+ invariant(\n+ subroute.params &&\n+ typeof subroute.params === \"object\",\n+ \"navigation's params should be an object!\",\n+ );\n+ subrouteCopy.params = subroute.params;\n+ }\n+ if (subroute.index !== null && subroute.index !== undefined) {\n+ subrouteCopy = assertNavigationRouteNotLeafNode({\n+ ...subroute,\n+ ...subrouteCopy,\n+ });\n+ }\n+ routes.push(subrouteCopy);\n+ }\n+ return {\n+ ...route,\n+ index,\n+ routes,\n+ };\n+}\n+\n+export {\n+ assertNavigationRouteNotLeafNode,\n+};\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Implement assertNavigationRouteNotLeafNode and use it in AddThread's connect call |
129,187 | 06.10.2017 17:00:32 | 14,400 | eed578246ad39a0db602722b7548299361adb2db | Make thread name clickable in Entry | [
{
"change_type": "MODIFY",
"old_path": "native/account/panel-components.react.js",
"new_path": "native/account/panel-components.react.js",
"diff": "@@ -110,10 +110,8 @@ const styles = StyleSheet.create({\nsubmitContentContainer: {\nflexDirection: 'row',\nalignItems: 'flex-end',\n- paddingLeft: 18,\n- paddingTop: 6,\n- paddingRight: 18,\n- paddingBottom: 6,\n+ paddingHorizontal: 18,\n+ paddingVertical: 6,\n},\nsubmitContentText: {\nfontSize: 18,\n"
},
{
"change_type": "MODIFY",
"old_path": "native/calendar/calendar.react.js",
"new_path": "native/calendar/calendar.react.js",
"diff": "@@ -10,6 +10,11 @@ import type { CalendarResult } from 'lib/actions/entry-actions';\nimport type { CalendarQuery } from 'lib/selectors/nav-selectors';\nimport type { KeyboardEvent } from '../keyboard';\nimport type { TextToMeasure } from '../text-height-measurer.react';\n+import type {\n+ NavigationScreenProp,\n+ NavigationRoute,\n+ NavigationAction,\n+} from 'react-navigation/src/TypeDefinition';\nimport React from 'react';\nimport {\n@@ -91,6 +96,7 @@ type ExtraData = {\nlet currentCalendarRef: ?InnerCalendar = null;\ntype Props = {\n+ navigation: NavigationScreenProp<NavigationRoute, NavigationAction>,\n// Redux state\nlistData: ?$ReadOnlyArray<CalendarItem>,\ntabActive: bool,\n@@ -119,6 +125,9 @@ class InnerCalendar extends React.PureComponent {\nprops: Props;\nstate: State;\nstatic propTypes = {\n+ navigation: PropTypes.shape({\n+ navigate: PropTypes.func.isRequired,\n+ }).isRequired,\nlistData: PropTypes.arrayOf(PropTypes.oneOfType([\nPropTypes.shape({\nitemType: PropTypes.oneOf([\"loader\"]),\n@@ -539,6 +548,7 @@ class InnerCalendar extends React.PureComponent {\nfocused={!!this.state.extraData.focusedEntries[key]}\nvisible={!!this.state.extraData.visibleEntries[key]}\nonFocus={this.onEntryFocus}\n+ navigate={this.props.navigation.navigate}\n/>\n);\n} else if (item.itemType === \"footer\") {\n"
},
{
"change_type": "MODIFY",
"old_path": "native/calendar/entry.react.js",
"new_path": "native/calendar/entry.react.js",
"diff": "@@ -11,6 +11,10 @@ import type {\n} from 'lib/utils/action-utils';\nimport type { SaveResult } from 'lib/actions/entry-actions';\nimport type { LoadingStatus } from 'lib/types/loading-types';\n+import type {\n+ NavigationParams,\n+ NavigationAction,\n+} from 'react-navigation/src/TypeDefinition';\nimport React from 'react';\nimport {\n@@ -22,6 +26,7 @@ import {\nTouchableWithoutFeedback,\nAlert,\nLayoutAnimation,\n+ Keyboard,\n} from 'react-native';\nimport { connect } from 'react-redux';\nimport PropTypes from 'prop-types';\n@@ -30,6 +35,7 @@ import shallowequal from 'shallowequal';\nimport _omit from 'lodash/fp/omit';\nimport _isEqual from 'lodash/fp/isEqual';\nimport Icon from 'react-native-vector-icons/FontAwesome';\n+import { NavigationActions } from 'react-navigation';\nimport { colorIsDark } from 'lib/shared/thread-utils';\nimport {\n@@ -53,17 +59,26 @@ import { entryKey } from 'lib/shared/entry-utils';\nimport { registerFetchKey } from 'lib/reducers/loading-reducer';\nimport Button from '../components/button.react';\n+import { ChatRouteName } from '../chat/chat.react';\n+import { MessageListRouteName } from '../chat/message-list.react';\n+import { assertNavigationRouteNotLeafNode } from '../utils/navigation-utils';\ntype Props = {\nentryInfo: EntryInfoWithHeight,\nvisible: bool,\nfocused: bool,\nonFocus: (entryKey: string, focused: bool) => void,\n+ navigate: (\n+ routeName: string,\n+ params?: NavigationParams,\n+ action?: NavigationAction,\n+ ) => bool,\n// Redux state\nthreadInfo: ThreadInfo,\nsessionStartingPayload: () => { newSessionID?: string },\nsessionID: () => string,\nnextSessionID: () => ?string,\n+ currentChatThreadID: ?string,\n// Redux dispatch functions\ndispatchActionPayload: DispatchActionPayload,\ndispatchActionPromise: DispatchActionPromise,\n@@ -100,10 +115,12 @@ class Entry extends React.Component {\nvisible: PropTypes.bool.isRequired,\nfocused: PropTypes.bool.isRequired,\nonFocus: PropTypes.func.isRequired,\n+ navigate: PropTypes.func.isRequired,\nthreadInfo: threadInfoPropType.isRequired,\nsessionStartingPayload: PropTypes.func.isRequired,\nsessionID: PropTypes.func.isRequired,\nnextSessionID: PropTypes.func.isRequired,\n+ currentChatThreadID: PropTypes.string,\ndispatchActionPayload: PropTypes.func.isRequired,\ndispatchActionPromise: PropTypes.func.isRequired,\nsaveEntry: PropTypes.func.isRequired,\n@@ -208,11 +225,10 @@ class Entry extends React.Component {\n<View style={styles.leftLinks}>\n<Button\nonPress={this.onPressDelete}\n- androidBorderlessRipple={true}\niosFormat=\"highlight\"\niosHighlightUnderlayColor={actionLinksUnderlayColor}\niosActiveOpacity={0.85}\n- style={styles.deleteButton}\n+ style={styles.button}\n>\n<View style={styles.deleteButtonContents}>\n<Icon\n@@ -227,12 +243,20 @@ class Entry extends React.Component {\n</Button>\n</View>\n<View style={styles.rightLinks}>\n+ <Button\n+ onPress={this.onPressThreadName}\n+ iosFormat=\"highlight\"\n+ iosHighlightUnderlayColor={actionLinksUnderlayColor}\n+ iosActiveOpacity={0.85}\n+ style={styles.button}\n+ >\n<Text\nstyle={[styles.rightLinksText, actionLinksTextStyle]}\nnumberOfLines={1}\n>\n{this.state.threadInfo.name}\n</Text>\n+ </Button>\n</View>\n</View>\n);\n@@ -470,6 +494,24 @@ class Entry extends React.Component {\n}\n}\n+ onPressThreadName = () => {\n+ Keyboard.dismiss();\n+ if (this.props.currentChatThreadID === this.props.threadInfo.id) {\n+ this.props.navigate(ChatRouteName);\n+ return;\n+ }\n+ this.props.navigate(\n+ ChatRouteName,\n+ {},\n+ NavigationActions.navigate({\n+ routeName: MessageListRouteName,\n+ params: {\n+ threadInfo: this.props.threadInfo,\n+ },\n+ })\n+ );\n+ }\n+\n}\nconst styles = StyleSheet.create({\n@@ -497,12 +539,6 @@ const styles = StyleSheet.create({\njustifyContent: 'space-between',\nmarginTop: -5,\n},\n- deleteButton: {\n- paddingLeft: 10,\n- paddingTop: 5,\n- paddingBottom: 5,\n- paddingRight: 10,\n- },\ndeleteButtonContents: {\nflex: 1,\nflexDirection: 'row',\n@@ -523,24 +559,45 @@ const styles = StyleSheet.create({\njustifyContent: 'flex-end',\n},\nrightLinksText: {\n- paddingTop: 5,\n- paddingRight: 10,\nfontWeight: 'bold',\nfontSize: 12,\n},\n+ button: {\n+ paddingHorizontal: 10,\n+ paddingVertical: 5,\n+ },\n});\nregisterFetchKey(saveEntryActionTypes);\nregisterFetchKey(deleteEntryActionTypes);\nexport default connect(\n- (state: AppState, ownProps: { entryInfo: EntryInfoWithHeight }) => ({\n+ (state: AppState, ownProps: { entryInfo: EntryInfoWithHeight }) => {\n+ const appRoute =\n+ assertNavigationRouteNotLeafNode(state.navInfo.navigationState.routes[0]);\n+ const chatRoute = assertNavigationRouteNotLeafNode(appRoute.routes[1]);\n+ const currentChatSubroute = chatRoute.routes[chatRoute.index];\n+ let currentChatThreadID = null;\n+ if (currentChatSubroute.routeName === MessageListRouteName) {\n+ invariant(\n+ currentChatSubroute.params &&\n+ currentChatSubroute.params.threadInfo &&\n+ typeof currentChatSubroute.params.threadInfo === \"object\" &&\n+ currentChatSubroute.params.threadInfo.id &&\n+ typeof currentChatSubroute.params.threadInfo.id === \"string\",\n+ \"all MessageList routes should have a threadInfo param\",\n+ );\n+ currentChatThreadID = currentChatSubroute.params.threadInfo.id;\n+ }\n+ return {\nthreadInfo: state.threadInfos[ownProps.entryInfo.threadID],\nsessionStartingPayload: sessionStartingPayload(state),\nsessionID: currentSessionID(state),\nnextSessionID: nextSessionID(state),\n+ currentChatThreadID,\ncookie: state.cookie,\n- }),\n+ };\n+ },\nincludeDispatchActionProps,\nbindServerCalls({ saveEntry, deleteEntry }),\n)(Entry);\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/settings/thread-settings.react.js",
"new_path": "native/chat/settings/thread-settings.react.js",
"diff": "@@ -119,6 +119,7 @@ class InnerThreadSettings extends React.PureComponent {\n};\nstatic navigationOptions = ({ navigation }) => ({\ntitle: navigation.state.params.threadInfo.name,\n+ headerBackTitle: \"Back\",\n});\nnameTextInput: ?TextInput;\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Make thread name clickable in Entry |
129,187 | 11.10.2017 10:50:34 | 14,400 | 85390d2dc693b5582aa23126734ad2c5f4f7b18d | Create permissions.php and move all viewer_can_ functions there | [
{
"change_type": "MODIFY",
"old_path": "server/auth.php",
"new_path": "server/auth.php",
"diff": "@@ -327,193 +327,3 @@ function set_cookie($name, $value, $expiration_time) {\ntrue // no JS access\n);\n}\n-\n-// null if thread does not exist\n-function viewer_can_see_thread($thread) {\n- global $conn;\n-\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-SELECT (\n- (\n- t.visibility_rules >= {$visibility_closed} AND\n- t.visibility_rules != {$visibility_nested_open} AND\n- (tr.thread IS NULL OR tr.role < {$role_successful_auth})\n- ) OR (\n- t.visibility_rules = {$visibility_nested_open} AND\n- a.visibility_rules >= {$visibility_closed} AND\n- (ar.thread IS NULL OR ar.role < {$role_successful_auth})\n- )\n-) AS requires_auth\n-FROM threads t\n-LEFT JOIN roles tr ON tr.thread = t.id 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 t.id = {$thread}\n-SQL;\n- $result = $conn->query($query);\n- $thread_row = $result->fetch_assoc();\n- if (!$thread_row) {\n- return null;\n- }\n- return !$thread_row['requires_auth'];\n-}\n-\n-// null if day does not exist\n-function viewer_can_see_day($day) {\n- global $conn;\n-\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-SELECT (\n- (\n- t.visibility_rules >= {$visibility_closed} AND\n- t.visibility_rules != {$visibility_nested_open} AND\n- (tr.thread IS NULL OR tr.role < {$role_successful_auth})\n- ) OR (\n- t.visibility_rules = {$visibility_nested_open} AND\n- a.visibility_rules >= {$visibility_closed} AND\n- (ar.thread IS NULL OR ar.role < {$role_successful_auth})\n- )\n-) AS requires_auth\n-FROM days d\n-LEFT JOIN threads t ON t.id = d.thread\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}\n-WHERE d.id = {$day}\n-SQL;\n- $result = $conn->query($query);\n- $day_row = $result->fetch_assoc();\n- if (!$day_row) {\n- return null;\n- }\n- return !$day_row['requires_auth'];\n-}\n-\n-// null if entry does not exist\n-function viewer_can_see_entry($entry) {\n- global $conn;\n-\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-SELECT (\n- (\n- t.visibility_rules >= {$visibility_closed} AND\n- t.visibility_rules != {$visibility_nested_open} AND\n- (tr.thread IS NULL OR tr.role < {$role_successful_auth})\n- ) OR (\n- t.visibility_rules = {$visibility_nested_open} AND\n- a.visibility_rules >= {$visibility_closed} AND\n- (ar.thread IS NULL OR ar.role < {$role_successful_auth})\n- )\n-) AS requires_auth\n-FROM entries e\n-LEFT JOIN days d ON d.id = e.day\n-LEFT JOIN threads t ON t.id = d.thread\n-LEFT JOIN roles tr ON tr.thread = t.id 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 e.id = {$entry}\n-SQL;\n- $result = $conn->query($query);\n- $entry_row = $result->fetch_assoc();\n- if (!$entry_row) {\n- return null;\n- }\n- return !$entry_row['requires_auth'];\n-}\n-\n-function edit_rules_helper($mysql_row) {\n- if (!$mysql_row) {\n- return null;\n- }\n- if ($mysql_row['requires_auth']) {\n- return false;\n- }\n- if (!user_logged_in() && intval($mysql_row['edit_rules']) === 1) {\n- return false;\n- }\n- return true;\n-}\n-\n-// null if thread does not exist\n-// false if the viewer can't see into the thread, or can't edit it\n-// true if the viewer can see into and edit the thread\n-function viewer_can_edit_thread($thread) {\n- global $conn;\n-\n- $viewer_id = get_viewer_id();\n- $role_successful_auth = ROLE_SUCCESSFUL_AUTH;\n- $visibility_closed = VISIBILITY_CLOSED;\n- $visibility_nested_open = VISIBILITY_NESTED_OPEN;\n- $query = <<<SQL\n-SELECT t.edit_rules, (\n- (\n- t.visibility_rules >= {$visibility_closed} AND\n- t.visibility_rules != {$visibility_nested_open} AND\n- (tr.thread IS NULL OR tr.role < {$role_successful_auth})\n- ) OR (\n- t.visibility_rules = {$visibility_nested_open} AND\n- a.visibility_rules >= {$visibility_closed} AND\n- (ar.thread IS NULL OR ar.role < {$role_successful_auth})\n- )\n-) AS requires_auth\n-FROM threads t\n-LEFT JOIN roles tr ON tr.thread = t.id 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 t.id = {$thread}\n-SQL;\n- $result = $conn->query($query);\n- return edit_rules_helper($result->fetch_assoc());\n-}\n-\n-// null if entry does not exist\n-// false if the viewer can't see into the thread, or can't edit it\n-// true if the viewer can see into and edit the thread\n-// note that this function does not check if the entry is deleted\n-function viewer_can_edit_entry($entry) {\n- global $conn;\n-\n- $viewer_id = get_viewer_id();\n- $role_successful_auth = ROLE_SUCCESSFUL_AUTH;\n- $visibility_closed = VISIBILITY_CLOSED;\n- $visibility_nested_open = VISIBILITY_NESTED_OPEN;\n- $query = <<<SQL\n-SELECT t.edit_rules, (\n- (\n- t.visibility_rules >= {$visibility_closed} AND\n- t.visibility_rules != {$visibility_nested_open} AND\n- (tr.thread IS NULL OR tr.role < {$role_successful_auth})\n- ) OR (\n- t.visibility_rules = {$visibility_nested_open} AND\n- a.visibility_rules >= {$visibility_closed} AND\n- (ar.thread IS NULL OR ar.role < {$role_successful_auth})\n- )\n-) AS requires_auth\n-FROM entries e\n-LEFT JOIN days d ON d.id = e.day\n-LEFT JOIN threads t ON t.id = d.thread\n-LEFT JOIN roles tr ON tr.thread = t.id 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 e.id = {$entry}\n-SQL;\n- $result = $conn->query($query);\n- return edit_rules_helper($result->fetch_assoc());\n-}\n"
},
{
"change_type": "MODIFY",
"old_path": "server/day_lib.php",
"new_path": "server/day_lib.php",
"diff": "<?php\nrequire_once('config.php');\n-require_once('auth.php');\n+require_once('permissions.php');\n// null if invalid parameters\n// false if invalid credentials\n"
},
{
"change_type": "MODIFY",
"old_path": "server/delete_entry.php",
"new_path": "server/delete_entry.php",
"diff": "require_once('async_lib.php');\nrequire_once('config.php');\nrequire_once('auth.php');\n+require_once('permissions.php');\nasync_start();\n"
},
{
"change_type": "MODIFY",
"old_path": "server/edit_thread.php",
"new_path": "server/edit_thread.php",
"diff": "@@ -6,6 +6,7 @@ require_once('auth.php');\nrequire_once('thread_lib.php');\nrequire_once('user_lib.php');\nrequire_once('message_lib.php');\n+require_once('permissions.php');\nasync_start();\n"
},
{
"change_type": "MODIFY",
"old_path": "server/entry_history.php",
"new_path": "server/entry_history.php",
"diff": "<?php\nrequire_once('async_lib.php');\n-require_once('config.php');\n-require_once('auth.php');\n+require_once('permissions.php');\nasync_start();\n"
},
{
"change_type": "MODIFY",
"old_path": "server/join_thread.php",
"new_path": "server/join_thread.php",
"diff": "@@ -6,6 +6,7 @@ require_once('auth.php');\nrequire_once('thread_lib.php');\nrequire_once('message_lib.php');\nrequire_once('user_lib.php');\n+require_once('permissions.php');\nasync_start();\n"
},
{
"change_type": "MODIFY",
"old_path": "server/message_lib.php",
"new_path": "server/message_lib.php",
"diff": "require_once('config.php');\nrequire_once('auth.php');\nrequire_once('thread_lib.php');\n+require_once('permissions.php');\n// keep value in sync with numberPerThread in message_reducer.js\ndefine(\"DEFAULT_NUMBER_PER_THREAD\", 20);\n"
},
{
"change_type": "MODIFY",
"old_path": "server/new_thread.php",
"new_path": "server/new_thread.php",
"diff": "@@ -6,6 +6,7 @@ require_once('auth.php');\nrequire_once('thread_lib.php');\nrequire_once('user_lib.php');\nrequire_once('message_lib.php');\n+require_once('permissions.php');\nasync_start();\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "server/permissions.php",
"diff": "+<?php\n+\n+require_once('config.php');\n+require_once('auth.php');\n+require_once('thread_lib.php');\n+\n+// null if thread does not exist\n+function viewer_can_see_thread($thread) {\n+ global $conn;\n+\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+SELECT (\n+ (\n+ t.visibility_rules >= {$visibility_closed} AND\n+ t.visibility_rules != {$visibility_nested_open} AND\n+ (tr.thread IS NULL OR tr.role < {$role_successful_auth})\n+ ) OR (\n+ t.visibility_rules = {$visibility_nested_open} AND\n+ a.visibility_rules >= {$visibility_closed} AND\n+ (ar.thread IS NULL OR ar.role < {$role_successful_auth})\n+ )\n+) AS requires_auth\n+FROM threads t\n+LEFT JOIN roles tr ON tr.thread = t.id 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 t.id = {$thread}\n+SQL;\n+ $result = $conn->query($query);\n+ $thread_row = $result->fetch_assoc();\n+ if (!$thread_row) {\n+ return null;\n+ }\n+ return !$thread_row['requires_auth'];\n+}\n+\n+// null if day does not exist\n+function viewer_can_see_day($day) {\n+ global $conn;\n+\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+SELECT (\n+ (\n+ t.visibility_rules >= {$visibility_closed} AND\n+ t.visibility_rules != {$visibility_nested_open} AND\n+ (tr.thread IS NULL OR tr.role < {$role_successful_auth})\n+ ) OR (\n+ t.visibility_rules = {$visibility_nested_open} AND\n+ a.visibility_rules >= {$visibility_closed} AND\n+ (ar.thread IS NULL OR ar.role < {$role_successful_auth})\n+ )\n+) AS requires_auth\n+FROM days d\n+LEFT JOIN threads t ON t.id = d.thread\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}\n+WHERE d.id = {$day}\n+SQL;\n+ $result = $conn->query($query);\n+ $day_row = $result->fetch_assoc();\n+ if (!$day_row) {\n+ return null;\n+ }\n+ return !$day_row['requires_auth'];\n+}\n+\n+// null if entry does not exist\n+function viewer_can_see_entry($entry) {\n+ global $conn;\n+\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+SELECT (\n+ (\n+ t.visibility_rules >= {$visibility_closed} AND\n+ t.visibility_rules != {$visibility_nested_open} AND\n+ (tr.thread IS NULL OR tr.role < {$role_successful_auth})\n+ ) OR (\n+ t.visibility_rules = {$visibility_nested_open} AND\n+ a.visibility_rules >= {$visibility_closed} AND\n+ (ar.thread IS NULL OR ar.role < {$role_successful_auth})\n+ )\n+) AS requires_auth\n+FROM entries e\n+LEFT JOIN days d ON d.id = e.day\n+LEFT JOIN threads t ON t.id = d.thread\n+LEFT JOIN roles tr ON tr.thread = t.id 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 e.id = {$entry}\n+SQL;\n+ $result = $conn->query($query);\n+ $entry_row = $result->fetch_assoc();\n+ if (!$entry_row) {\n+ return null;\n+ }\n+ return !$entry_row['requires_auth'];\n+}\n+\n+function edit_rules_helper($mysql_row) {\n+ if (!$mysql_row) {\n+ return null;\n+ }\n+ if ($mysql_row['requires_auth']) {\n+ return false;\n+ }\n+ if (!user_logged_in() && intval($mysql_row['edit_rules']) === 1) {\n+ return false;\n+ }\n+ return true;\n+}\n+\n+// null if thread does not exist\n+// false if the viewer can't see into the thread, or can't edit it\n+// true if the viewer can see into and edit the thread\n+function viewer_can_edit_thread($thread) {\n+ global $conn;\n+\n+ $viewer_id = get_viewer_id();\n+ $role_successful_auth = ROLE_SUCCESSFUL_AUTH;\n+ $visibility_closed = VISIBILITY_CLOSED;\n+ $visibility_nested_open = VISIBILITY_NESTED_OPEN;\n+ $query = <<<SQL\n+SELECT t.edit_rules, (\n+ (\n+ t.visibility_rules >= {$visibility_closed} AND\n+ t.visibility_rules != {$visibility_nested_open} AND\n+ (tr.thread IS NULL OR tr.role < {$role_successful_auth})\n+ ) OR (\n+ t.visibility_rules = {$visibility_nested_open} AND\n+ a.visibility_rules >= {$visibility_closed} AND\n+ (ar.thread IS NULL OR ar.role < {$role_successful_auth})\n+ )\n+) AS requires_auth\n+FROM threads t\n+LEFT JOIN roles tr ON tr.thread = t.id 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 t.id = {$thread}\n+SQL;\n+ $result = $conn->query($query);\n+ return edit_rules_helper($result->fetch_assoc());\n+}\n+\n+// null if entry does not exist\n+// false if the viewer can't see into the thread, or can't edit it\n+// true if the viewer can see into and edit the thread\n+// note that this function does not check if the entry is deleted\n+function viewer_can_edit_entry($entry) {\n+ global $conn;\n+\n+ $viewer_id = get_viewer_id();\n+ $role_successful_auth = ROLE_SUCCESSFUL_AUTH;\n+ $visibility_closed = VISIBILITY_CLOSED;\n+ $visibility_nested_open = VISIBILITY_NESTED_OPEN;\n+ $query = <<<SQL\n+SELECT t.edit_rules, (\n+ (\n+ t.visibility_rules >= {$visibility_closed} AND\n+ t.visibility_rules != {$visibility_nested_open} AND\n+ (tr.thread IS NULL OR tr.role < {$role_successful_auth})\n+ ) OR (\n+ t.visibility_rules = {$visibility_nested_open} AND\n+ a.visibility_rules >= {$visibility_closed} AND\n+ (ar.thread IS NULL OR ar.role < {$role_successful_auth})\n+ )\n+) AS requires_auth\n+FROM entries e\n+LEFT JOIN days d ON d.id = e.day\n+LEFT JOIN threads t ON t.id = d.thread\n+LEFT JOIN roles tr ON tr.thread = t.id 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 e.id = {$entry}\n+SQL;\n+ $result = $conn->query($query);\n+ return edit_rules_helper($result->fetch_assoc());\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "server/restore_entry.php",
"new_path": "server/restore_entry.php",
"diff": "require_once('async_lib.php');\nrequire_once('config.php');\nrequire_once('auth.php');\n+require_once('permissions.php');\nasync_start();\n"
},
{
"change_type": "MODIFY",
"old_path": "server/save.php",
"new_path": "server/save.php",
"diff": "@@ -4,6 +4,7 @@ require_once('async_lib.php');\nrequire_once('config.php');\nrequire_once('auth.php');\nrequire_once('day_lib.php');\n+require_once('permissions.php');\nasync_start();\n"
},
{
"change_type": "MODIFY",
"old_path": "server/send_message.php",
"new_path": "server/send_message.php",
"diff": "@@ -4,6 +4,7 @@ require_once('async_lib.php');\nrequire_once('config.php');\nrequire_once('auth.php');\nrequire_once('message_lib.php');\n+require_once('permissions.php');\nasync_start();\n"
},
{
"change_type": "MODIFY",
"old_path": "server/subscribe.php",
"new_path": "server/subscribe.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('permissions.php');\nasync_start();\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Create permissions.php and move all viewer_can_ functions there |
129,187 | 17.10.2017 20:55:28 | 14,400 | 36d9cd54d6412f3ba8e63ed04c351b1a53207c85 | We can use stock react-navigation now that Flow types are finally fixed up! | [
{
"change_type": "MODIFY",
"old_path": "native/package-lock.json",
"new_path": "native/package-lock.json",
"diff": "\"lockfileVersion\": 1,\n\"requires\": true,\n\"dependencies\": {\n+ \"1PasswordExtension\": {\n+ \"version\": \"git+https://github.com/jjshammas/onepassword-app-extension.git#acf20f71c890e92ee489fc8e7bb0f7df922e855d\"\n+ },\n\"@types/node\": {\n\"version\": \"7.0.39\",\n\"resolved\": \"https://registry.npmjs.org/@types/node/-/node-7.0.39.tgz\",\n\"integrity\": \"sha512-KQHAZeVsk4UIT9XaR6cn4WpHZzimK6UBD1UomQKfQQFmTlUHaNBzeuov+TM4+kigLO0IJt4I5OOsshcCyA9gSA==\",\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}\n}\n},\n- \"string_decoder\": {\n- \"version\": \"1.0.1\",\n- \"bundled\": true,\n- \"requires\": {\n- \"safe-buffer\": \"5.0.1\"\n- }\n- },\n\"string-width\": {\n\"version\": \"1.0.2\",\n\"bundled\": true,\n\"strip-ansi\": \"3.0.1\"\n}\n},\n+ \"string_decoder\": {\n+ \"version\": \"1.0.1\",\n+ \"bundled\": true,\n+ \"requires\": {\n+ \"safe-buffer\": \"5.0.1\"\n+ }\n+ },\n\"stringstream\": {\n\"version\": \"0.0.5\",\n\"bundled\": true,\n}\n},\n\"react-navigation\": {\n- \"version\": \"git+https://git@github.com/react-community/react-navigation.git#e4a7b7e073302bf970f1f1112b46a36873f7fc4a\",\n+ \"version\": \"1.0.0-beta.14\",\n+ \"resolved\": \"https://registry.npmjs.org/react-navigation/-/react-navigation-1.0.0-beta.14.tgz\",\n+ \"integrity\": \"sha512-YekepN/Fipb3XFGZN1o8862wVVXDdbAlX+sfjfnkd+uOvATWYYe+1jMAvuTkNnDlzf9qQUvAXAf6VPMLOPw0LA==\",\n\"requires\": {\n\"babel-plugin-transform-define\": \"1.3.0\",\n\"clamp\": \"1.0.1\",\n}\n}\n},\n- \"string_decoder\": {\n- \"version\": \"1.0.3\",\n- \"resolved\": \"https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz\",\n- \"integrity\": \"sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==\",\n- \"requires\": {\n- \"safe-buffer\": \"5.1.1\"\n- }\n- },\n\"string-length\": {\n\"version\": \"1.0.1\",\n\"resolved\": \"https://registry.npmjs.org/string-length/-/string-length-1.0.1.tgz\",\n}\n}\n},\n+ \"string_decoder\": {\n+ \"version\": \"1.0.3\",\n+ \"resolved\": \"https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz\",\n+ \"integrity\": \"sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==\",\n+ \"requires\": {\n+ \"safe-buffer\": \"5.1.1\"\n+ }\n+ },\n\"stringstream\": {\n\"version\": \"0.0.5\",\n\"resolved\": \"https://registry.npmjs.org/stringstream/-/stringstream-0.0.5.tgz\",\n"
},
{
"change_type": "MODIFY",
"old_path": "native/package.json",
"new_path": "native/package.json",
"diff": "\"react-native-onepassword\": \"^1.0.6\",\n\"react-native-segmented-control-tab\": \"^3.2.1\",\n\"react-native-vector-icons\": \"^4.3.0\",\n- \"react-navigation\": \"git+https://git@github.com/react-community/react-navigation.git\",\n+ \"react-navigation\": \"^1.0.0-beta.14\",\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 | We can use stock react-navigation now that Flow types are finally fixed up! |
129,187 | 18.10.2017 11:28:33 | 14,400 | 3e497360aac52aeb7d991390104fa31dc4ce1891 | Update TagInput to match OSS version more closely | [
{
"change_type": "MODIFY",
"old_path": "native/chat/add-thread.react.js",
"new_path": "native/chat/add-thread.react.js",
"diff": "@@ -63,6 +63,10 @@ import { registerChatScreen } from './chat-screen-registry';\nimport ColorPickerModal from './color-picker-modal.react';\nimport { assertNavigationRouteNotLeafNode } from '../utils/navigation-utils';\n+const tagInputProps = {\n+ placeholder: \"username\",\n+};\n+\ntype NavProp = NavigationScreenProp<NavigationRoute, NavigationAction>\n& { state: { params: { parentThreadID: ?string } } };\nconst segmentedPrivacyOptions = ['Public', 'Secret'];\n@@ -268,12 +272,13 @@ class InnerAddThread extends React.PureComponent {\n<Text style={styles.tagInputLabel}>People</Text>\n<View style={styles.input}>\n<TagInput\n- onChange={this.onChangeTagInput}\nvalue={this.state.userInfoInputArray}\n+ onChange={this.onChangeTagInput}\ntext={this.state.usernameInputText}\n- setText={this.setUsernameInputText}\n+ onChangeText={this.setUsernameInputText}\nonHeightChange={this.onTagInputHeightChange}\nlabelExtractor={this.tagDataLabelExtractor}\n+ inputProps={tagInputProps}\n/>\n</View>\n</View>\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/settings/add-users-modal.react.js",
"new_path": "native/chat/settings/add-users-modal.react.js",
"diff": "@@ -204,10 +204,10 @@ class AddUsersModal extends React.PureComponent {\nconst content = (\n<View style={styles.modal}>\n<TagInput\n- onChange={this.onChangeTagInput}\nvalue={this.state.userInfoInputArray}\n+ onChange={this.onChangeTagInput}\ntext={this.state.usernameInputText}\n- setText={this.setUsernameInputText}\n+ onChangeText={this.setUsernameInputText}\nlabelExtractor={this.tagDataLabelExtractor}\ndefaultInputWidth={160}\nmaxHeight={36}\n"
},
{
"change_type": "MODIFY",
"old_path": "native/components/tag-input.react.js",
"new_path": "native/components/tag-input.react.js",
"diff": "@@ -21,89 +21,105 @@ 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-};\n-const defaultProps = {\n- tagColor: '#dddddd',\n- tagTextColor: '#777777',\n- inputColor: '#777777',\n- minHeight: 27,\n- maxHeight: 75,\n- defaultInputWidth: 90,\n-};\n-const tagDataPropType = PropTypes.oneOfType([\n- PropTypes.string,\n- PropTypes.object,\n-]);\n-type Props<TagData> = {\n- // The text currently being displayed as the user types\n+type RequiredProps<T> = {\n+ /**\n+ * An array of tags, which can be any type, as long as labelExtractor below\n+ * can extract a string from it.\n+ */\n+ value: $ReadOnlyArray<T>,\n+ /**\n+ * A handler to be called when array of tags change.\n+ */\n+ onChange: (items: $ReadOnlyArray<T>) => void,\n+ /**\n+ * Function to extract string value for label from item\n+ */\n+ labelExtractor: (tagData: T) => string,\n+ /**\n+ * The text currently being displayed in the TextInput following the list of\n+ * tags.\n+ */\ntext: 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\n- onChange: (items: $ReadOnlyArray<TagData>) => void,\n- // An array of tags\n- value: $ReadOnlyArray<TagData>,\n- // Background color of tags\n+ /**\n+ * This callback gets called when the user in the TextInput. The caller should\n+ * update the text prop when this is called if they want to access input.\n+ */\n+ onChangeText: (text: string) => void,\n+};\n+type OptionalProps = {\n+ /**\n+ * Background color of tags\n+ */\ntagColor: string,\n- // Text color of tags\n+ /**\n+ * Text color of tags\n+ */\ntagTextColor: string,\n- // Styling override for container surrounding tag text\n+ /**\n+ * Styling override for container surrounding tag text\n+ */\ntagContainerStyle?: StyleObj,\n- // Styling overrride for tag's text component\n+ /**\n+ * Styling override for tag's text component\n+ */\ntagTextStyle?: StyleObj,\n- // Color of text input\n+ /**\n+ * Color of text input\n+ */\ninputColor: string,\n- // TextInput props Text.propTypes\n- inputProps?: $PropertyType<Text, 'props'>,\n- // path of the label in tags objects\n- labelExtractor?: (tagData: TagData) => string,\n- // minimum height of this component\n+ /**\n+ * Any misc. TextInput props (autoFocus, placeholder, returnKeyType, etc.)\n+ */\n+ inputProps?: $PropertyType<TextInput, 'props'>,\n+ /**\n+ * Min height of the tag input on screen\n+ */\nminHeight: number,\n- // maximum height of this component\n+ /**\n+ * Max height of the tag input on screen (will scroll if max height reached)\n+ */\nmaxHeight: number,\n- // callback that gets triggered when the component height changes\n+ /**\n+ * Callback that gets passed the new component height when it changes\n+ */\nonHeightChange?: (height: number) => void,\n- // inputWidth if text === \"\". we want this number explicitly because if we're\n- // forced to measure the component, there can be a short jump between the old\n- // value and the new value, which looks sketchy.\n+ /**\n+ * inputWidth if text === \"\". we want this number explicitly because if we're\n+ * forced to measure the component, there can be a short jump between the old\n+ * value and the new value, which looks sketchy.\n+ */\ndefaultInputWidth: number,\n};\n+type Props<T> = RequiredProps<T> & OptionalProps;\ntype State = {\ninputWidth: number,\nwrapperHeight: number,\n};\n-class TagInput<TagData> extends React.PureComponent<\n- typeof defaultProps,\n- Props<TagData>,\n+class TagInput<T> extends React.PureComponent<\n+ OptionalProps,\n+ Props<T>,\nState,\n> {\nstatic propTypes = {\n- text: PropTypes.string.isRequired,\n- setText: PropTypes.func.isRequired,\n+ value: PropTypes.array.isRequired,\nonChange: PropTypes.func.isRequired,\n- value: PropTypes.arrayOf(tagDataPropType).isRequired,\n+ labelExtractor: PropTypes.func.isRequired,\n+ text: PropTypes.string.isRequired,\n+ onChangeText: PropTypes.func.isRequired,\ntagColor: PropTypes.string,\ntagTextColor: PropTypes.string,\ntagContainerStyle: ViewPropTypes.style,\ntagTextStyle: Text.propTypes.style,\ninputColor: PropTypes.string,\n- inputProps: PropTypes.object,\n- labelExtractor: PropTypes.func,\n+ inputProps: PropTypes.shape(TextInput.propTypes),\nminHeight: PropTypes.number,\nmaxHeight: PropTypes.number,\nonHeightChange: PropTypes.func,\ndefaultInputWidth: PropTypes.number,\n};\n- props: Props<TagData>;\n+ props: Props<T>;\nstate: State;\nwrapperWidth = windowWidth;\nspaceLeft = 0;\n@@ -114,7 +130,14 @@ class TagInput<TagData> extends React.PureComponent<\ntagInput: ?TextInput = null;\nscrollView: ?ScrollView = null;\n- static defaultProps = defaultProps;\n+ static defaultProps = {\n+ tagColor: '#dddddd',\n+ tagTextColor: '#777777',\n+ inputColor: '#777777',\n+ minHeight: 27,\n+ maxHeight: 75,\n+ defaultInputWidth: 90,\n+ };\nstatic inputWidth(\ntext: string,\n@@ -131,7 +154,7 @@ class TagInput<TagData> extends React.PureComponent<\n}\n}\n- constructor(props: Props<TagData>) {\n+ constructor(props: Props<T>) {\nsuper(props);\nthis.state = {\ninputWidth: props.defaultInputWidth,\n@@ -139,7 +162,7 @@ class TagInput<TagData> extends React.PureComponent<\n};\n}\n- componentWillReceiveProps(nextProps: Props<TagData>) {\n+ componentWillReceiveProps(nextProps: Props<T>) {\nconst inputWidth = TagInput.inputWidth(\nnextProps.text,\nthis.spaceLeft,\n@@ -161,7 +184,7 @@ class TagInput<TagData> extends React.PureComponent<\n}\n}\n- componentWillUpdate(nextProps: Props<TagData>, nextState: State) {\n+ componentWillUpdate(nextProps: Props<T>, nextState: State) {\nif (\nthis.props.onHeightChange &&\nnextState.wrapperHeight !== this.state.wrapperHeight\n@@ -183,13 +206,9 @@ class TagInput<TagData> extends React.PureComponent<\n}\n}\n- onChangeText = (text: string) => {\n- this.props.setText(text);\n- }\n-\nonBlur = (event: { nativeEvent: { text: string } }) => {\ninvariant(Platform.OS === \"ios\", \"only iOS gets text on TextInput.onBlur\");\n- this.props.setText(event.nativeEvent.text);\n+ this.props.onChangeText(event.nativeEvent.text);\n}\nonKeyPress = (event: { nativeEvent: { key: string } }) => {\n@@ -203,10 +222,9 @@ class TagInput<TagData> extends React.PureComponent<\n}\nfocus = () => {\n- if (this.tagInput) {\n+ invariant(this.tagInput, \"should be set\");\nthis.tagInput.focus();\n}\n- }\nremoveIndex = (index: number) => {\nconst tags = [...this.props.value];\n@@ -228,18 +246,13 @@ class TagInput<TagData> extends React.PureComponent<\n}\nrender() {\n- const inputProps = { ...defaultInputProps, ...this.props.inputProps };\n-\n- const inputWidth = this.state.inputWidth;\n-\nconst tags = this.props.value.map((tag, index) => (\n<Tag\nindex={index}\n- tag={tag}\n+ label={this.props.labelExtractor(tag)}\nisLastTag={this.props.value.length === index + 1}\nonLayoutLastTag={this.onLayoutLastTag}\nremoveIndex={this.removeIndex}\n- labelExtractor={this.props.labelExtractor}\ntagColor={this.props.tagColor}\ntagTextColor={this.props.tagTextColor}\ntagContainerStyle={this.props.tagContainerStyle}\n@@ -266,20 +279,26 @@ class TagInput<TagData> extends React.PureComponent<\n{tags}\n<View style={[\nstyles.textInputContainer,\n- { width: inputWidth },\n+ { width: this.state.inputWidth },\n]}>\n<TextInput\nref={this.tagInputRef}\nblurOnSubmit={false}\nonKeyPress={this.onKeyPress}\nvalue={this.props.text}\n- style={[\n- styles.textInput,\n- { width: inputWidth, color: this.props.inputColor },\n- ]}\n+ style={[styles.textInput, {\n+ width: this.state.inputWidth,\n+ color: this.props.inputColor,\n+ }]}\nonBlur={Platform.OS === \"ios\" ? this.onBlur : undefined}\n- onChangeText={this.onChangeText}\n- {...inputProps}\n+ onChangeText={this.props.onChangeText}\n+ autoCapitalize=\"none\"\n+ autoCorrect={false}\n+ placeholder=\"Start typing\"\n+ returnKeyType=\"done\"\n+ keyboardType=\"default\"\n+ underlineColorAndroid=\"rgba(0,0,0,0)\"\n+ {...this.props.inputProps}\n/>\n</View>\n</View>\n@@ -338,28 +357,26 @@ class TagInput<TagData> extends React.PureComponent<\n}\n-type TagProps<TagData> = {\n+type TagProps = {\nindex: number,\n- tag: TagData,\n+ label: string,\nisLastTag: bool,\nonLayoutLastTag: (endPosOfTag: number) => void,\nremoveIndex: (index: number) => void,\n- labelExtractor?: (tagData: TagData) => string,\ntagColor: string,\ntagTextColor: string,\ntagContainerStyle?: StyleObj,\ntagTextStyle?: StyleObj,\n};\n-class Tag<TagData> extends React.PureComponent<void, TagProps<TagData>, void> {\n+class Tag extends React.PureComponent<void, TagProps, void> {\n- props: TagProps<TagData>;\n+ props: TagProps;\nstatic propTypes = {\nindex: PropTypes.number.isRequired,\n- tag: tagDataPropType.isRequired,\n+ label: PropTypes.string.isRequired,\nisLastTag: PropTypes.bool.isRequired,\nonLayoutLastTag: PropTypes.func.isRequired,\nremoveIndex: PropTypes.func.isRequired,\n- labelExtractor: PropTypes.func,\ntagColor: PropTypes.string.isRequired,\ntagTextColor: PropTypes.string.isRequired,\ntagContainerStyle: ViewPropTypes.style,\n@@ -367,7 +384,7 @@ class Tag<TagData> extends React.PureComponent<void, TagProps<TagData>, void> {\n};\ncurPos: ?number = null;\n- componentWillReceiveProps(nextProps: TagProps<TagData>) {\n+ componentWillReceiveProps(nextProps: TagProps) {\nif (\n!this.props.isLastTag &&\nnextProps.isLastTag &&\n@@ -394,7 +411,7 @@ class Tag<TagData> extends React.PureComponent<void, TagProps<TagData>, void> {\n{ color: this.props.tagTextColor },\nthis.props.tagTextStyle,\n]}>\n- {this.getLabelValue()}\n+ {this.props.label}\n ×\n</Text>\n</TouchableOpacity>\n@@ -415,13 +432,6 @@ class Tag<TagData> extends React.PureComponent<void, TagProps<TagData>, void> {\n}\n}\n- getLabelValue = () => {\n- const { tag, labelExtractor } = this.props;\n- return labelExtractor && typeof tag !== \"string\"\n- ? labelExtractor(tag)\n- : tag;\n- }\n-\n}\nconst styles = StyleSheet.create({\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Update TagInput to match OSS version more closely |
129,187 | 30.10.2017 14:46:59 | 14,400 | 88ea6db905f0024da1b99fc5f35fbc8982141247 | Infer type of Action in reducer and reduceNavInfo
Gets rid of a Flow error | [
{
"change_type": "MODIFY",
"old_path": "native/navigation-setup.js",
"new_path": "native/navigation-setup.js",
"diff": "@@ -183,7 +183,7 @@ const defaultNavInfo: NavInfo = {\nnavigationState: defaultNavigationState,\n};\n-function reduceNavInfo(state: NavInfo, action: Action): NavInfo {\n+function reduceNavInfo(state: NavInfo, action: *): NavInfo {\n// React Navigation actions\nconst navigationState = RootNavigator.router.getStateForAction(\naction,\n"
},
{
"change_type": "MODIFY",
"old_path": "native/package-lock.json",
"new_path": "native/package-lock.json",
"diff": "}\n},\n\"react-navigation\": {\n- \"version\": \"git://github.com/react-community/react-navigation.git#d93d698a92e7cc26d2d90a93c51b664a35a23088\",\n+ \"version\": \"git://github.com/react-community/react-navigation.git#1a2270d374580882180f7d0c8540f419c49ccf13\",\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": "@@ -80,7 +80,7 @@ const blacklist = __DEV__\n'navInfo',\n];\n-function reducer(state: AppState, action: Action) {\n+function reducer(state: AppState, action: *) {\nconst navInfo = reduceNavInfo(state && state.navInfo, action);\nif (navInfo && navInfo !== state.navInfo) {\nstate = {\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Infer type of Action in reducer and reduceNavInfo
Gets rid of a Flow error |
129,187 | 30.10.2017 17:25:47 | 14,400 | 12f2d45d4a61a929063a639763111e471650d148 | Add a temporary "any" for the ref type of View in ColorPicker
Should be fixed in RN 0.50 | [
{
"change_type": "MODIFY",
"old_path": "native/components/color-picker.react.js",
"new_path": "native/components/color-picker.react.js",
"diff": "@@ -76,7 +76,8 @@ class ColorPicker extends React.PureComponent<Props, State> {\n_layout = { width: 0, height: 0 };\n_pageX = 0;\n_pageY = 0;\n- _pickerContainer: ?React.ElementRef<typeof View & typeof NativeMethodsMixinType> = null;\n+ _pickerContainer: ?(React.ElementRef<typeof View> & NativeMethodsMixinType)\n+ = null;\n_pickerResponder: ?PanResponder = null;\n_changingHColor = false;\n@@ -432,9 +433,8 @@ class ColorPicker extends React.PureComponent<Props, State> {\n)\n}\n- pickerContainerRef = (\n- pickerContainer: ?React.ElementRef<typeof View & typeof NativeMethodsMixinType>,\n- ) => {\n+ pickerContainerRef = (pickerContainer: any) => {\n+ // TODO fix pickerContainer type, should be better in RN 0.50\nthis._pickerContainer = pickerContainer;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "native/package-lock.json",
"new_path": "native/package-lock.json",
"diff": "}\n},\n\"react-navigation\": {\n- \"version\": \"git://github.com/react-community/react-navigation.git#1a2270d374580882180f7d0c8540f419c49ccf13\",\n+ \"version\": \"git://github.com/react-community/react-navigation.git#6fa39e2f4daca844b3952bd9854f91b3d95d4c94\",\n\"requires\": {\n\"babel-plugin-transform-define\": \"1.3.0\",\n\"clamp\": \"1.0.1\",\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Add a temporary "any" for the ref type of View in ColorPicker
Should be fixed in RN 0.50 |
129,187 | 31.10.2017 12:03:50 | 14,400 | c597b5defbb0e2fe5b8892c769ce08a42495980f | Only json_decode a permissions blob once | [
{
"change_type": "MODIFY",
"old_path": "server/permissions.php",
"new_path": "server/permissions.php",
"diff": "@@ -4,6 +4,8 @@ require_once('config.php');\nrequire_once('auth.php');\nrequire_once('thread_lib.php');\n+// Keep in sync with lib/types/thread-types.js\n+\n// If the user can see the thread name, description, and color\ndefine(\"PERMISSION_KNOW_OF\", \"know_of\");\n// If the user can see messages, entries, and the thread info\n@@ -45,24 +47,23 @@ SQL;\nreturn (int)$row['roletype'] !== 0;\n}\n-function permission_lookup($permissions_string, $permission) {\n- if (!$permissions_string) {\n- return false;\n- }\n- $blob = json_decode($permissions_string, true);\n- if (gettype($blob) !== \"array\" || !isset($blob[$permission])) {\n+function permission_lookup($blob, $permission) {\n+ if (!$blob || !isset($blob[$permission])) {\nreturn false;\n}\nreturn (bool)$blob[$permission]['value'];\n}\n-// $row should include permissions, visibility_rules, and edit_rules\n-function permission_helper($row, $permission) {\n- if (!$row) {\n+// $info should include:\n+// - permissions: ?array\n+// - visibility_rules: int\n+// - edit_rules: int\n+function permission_helper($info, $permission) {\n+ if (!$info) {\nreturn null;\n}\n- $vis_rules = (int)$row['visibility_rules'];\n+ $vis_rules = $info['visibility_rules'];\nif (\n($permission === PERMISSION_KNOW_OF && $vis_rules === VISIBILITY_OPEN) ||\n($permission === PERMISSION_KNOW_OF && $vis_rules === VISIBILITY_CLOSED) ||\n@@ -86,25 +87,39 @@ function permission_helper($row, $permission) {\n// that passes a visibility check to edit the calendar entries of a thread,\n// regardless of membership in that thread. Depending on edit_rules, the\n// ability may be restricted to only logged in users.\n- $lookup = permission_lookup($row['permissions'], $permission);\n+ $lookup = permission_lookup($info['permissions'], $permission);\nif ($lookup) {\nreturn true;\n}\n- $can_view = permission_helper($row, PERMISSION_VISIBLE);\n+ $can_view = permission_helper($info, PERMISSION_VISIBLE);\nif (!$can_view) {\nreturn false;\n}\n- $edit_rules = (int)$row['edit_rules'];\n- if ($edit_rules === EDIT_LOGGED_IN) {\n+ if ($info['edit_rules'] === EDIT_LOGGED_IN) {\nreturn user_logged_in();\n}\nreturn true;\n}\n- return permission_lookup($row['permissions'], $permission);\n+ return permission_lookup($info['permissions'], $permission);\n+}\n+\n+function get_info_from_permissions_row($row) {\n+ $blob = null;\n+ if ($row['permissions']) {\n+ $decoded = json_decode($row['permissions'], true);\n+ if (gettype($decoded) === \"array\") {\n+ $blob = $decoded;\n+ }\n+ }\n+ return array(\n+ \"permissions\" => $blob,\n+ \"visibility_rules\" => (int)$row['visibility_rules'],\n+ \"edit_rules\" => (int)$row['edit_rules'],\n+ );\n}\n-// can be null if no permissions\n+// null if thread does not exist\nfunction fetch_thread_permission_info($thread) {\nglobal $conn;\n@@ -116,13 +131,15 @@ LEFT JOIN roles tr ON tr.thread = t.id AND tr.user = {$viewer_id}\nWHERE t.id = {$thread}\nSQL;\n$result = $conn->query($query);\n- return $result->fetch_assoc();\n+ $row = $result->fetch_assoc();\n+ if (!$row) {\n+ return null;\n+ }\n+ return get_info_from_permissions_row($row);\n}\n// null if thread does not exist\nfunction check_thread_permission($thread, $permission) {\n- global $conn;\n-\n$info = fetch_thread_permission_info($thread);\nreturn permission_helper($info, $permission);\n}\n@@ -142,7 +159,11 @@ WHERE e.id = {$entry}\nSQL;\n$result = $conn->query($query);\n$row = $result->fetch_assoc();\n- return permission_helper($row, $permission);\n+ if (!$row || $row['visibility_rules'] === null) {\n+ return null;\n+ }\n+ $info = get_info_from_permissions_row($row);\n+ return permission_helper($info, $permission);\n}\n// $roletype_permissions: ?array<permission: int, value: bool>\n"
},
{
"change_type": "MODIFY",
"old_path": "server/thread_lib.php",
"new_path": "server/thread_lib.php",
"diff": "@@ -34,11 +34,12 @@ SQL;\n$thread_infos = array();\n$thread_ids = array();\nwhile ($row = $result->fetch_assoc()) {\n- if (!permission_helper($row, PERMISSION_KNOW_OF)) {\n+ $permission_info = get_info_from_permissions_row($row);\n+ if (!permission_helper($permission_info, PERMISSION_KNOW_OF)) {\ncontinue;\n}\n$thread_ids[] = $row['id'];\n- $authorized = permission_helper($row, PERMISSION_VISIBLE);\n+ $authorized = permission_helper($permission_info, PERMISSION_VISIBLE);\n$subscribed_authorized = $authorized && $row['subscribed'];\n$thread_infos[$row['id']] = array(\n'id' => $row['id'],\n@@ -47,12 +48,13 @@ SQL;\n'authorized' => $authorized,\n'viewerIsMember' => (int)$row['roletype'] !== 0,\n'subscribed' => $subscribed_authorized,\n- 'parentThreadID' => $row['parent_thread_id'],\n- 'canChangeSettings' => permission_helper($row, PERMISSION_EDIT_THREAD),\n+ 'canChangeSettings' =>\n+ permission_helper($permission_info, PERMISSION_EDIT_THREAD),\n'visibilityRules' => (int)$row['visibility_rules'],\n'color' => $row['color'],\n'editRules' => (int)$row['edit_rules'],\n'creationTime' => (int)$row['creation_time'],\n+ 'parentThreadID' => $row['parent_thread_id'],\n'memberIDs' => array(),\n);\n}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Only json_decode a permissions blob once |
129,187 | 01.11.2017 11:14:07 | 14,400 | 90a31079d696fdee2d4d1fb10440fdc17ddf73be | Join thread on subscribe
If the user tries to subscribe to a thread that they aren't a member of, but they have permission to join, then add them to the thread first. | [
{
"change_type": "MODIFY",
"old_path": "server/new_thread.php",
"new_path": "server/new_thread.php",
"diff": "@@ -156,7 +156,9 @@ if ($initial_member_ids) {\n}\n$to_save_with_subscribed = array();\nforeach ($to_save as $row_to_save) {\n+ if ($row_to_save['thread_id'] === $id) {\n$row_to_save['subscribed'] = true;\n+ }\n$to_save_with_subscribed[] = $row_to_save;\n}\nsave_user_roles($to_save_with_subscribed);\n"
},
{
"change_type": "MODIFY",
"old_path": "server/subscribe.php",
"new_path": "server/subscribe.php",
"diff": "@@ -14,20 +14,37 @@ if (!isset($_POST['thread']) || !isset($_POST['subscribe'])) {\n}\n$thread = (int)$_POST['thread'];\n$new_subscribed = $_POST['subscribe'] ? 1 : 0;\n-\n-if (!viewer_is_member($thread)) {\n- async_end(array(\n- 'error' => 'invalid_parameters',\n- ));\n-}\n-\n$viewer_id = get_viewer_id();\n+\n+if (viewer_is_member($thread)) {\n$query = <<<SQL\nUPDATE roles\nSET subscribed = {$new_subscribed}\nWHERE thread = {$thread} AND user = {$viewer_id}\nSQL;\n$conn->query($query);\n+} else {\n+ if (!check_thread_permission($thread, PERMISSION_JOIN_THREAD)) {\n+ async_end(array(\n+ 'error' => 'invalid_parameters',\n+ ));\n+ }\n+\n+ $roletype_results = change_roletype($thread, array($viewer_id), null);\n+ $to_save = $roletype_results['to_save'];\n+ $to_delete = $roletype_results['to_delete'];\n+\n+ $to_save_with_subscribed = array();\n+ foreach ($to_save as $row_to_save) {\n+ if ($row_to_save['thread_id'] === $thread) {\n+ $row_to_save['subscribed'] = true;\n+ }\n+ $to_save_with_subscribed[] = $row_to_save;\n+ }\n+\n+ save_user_roles($to_save_with_subscribed);\n+ delete_user_roles($to_delete);\n+}\nasync_end(array(\n'success' => true,\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Join thread on subscribe
If the user tries to subscribe to a thread that they aren't a member of, but they have permission to join, then add them to the thread first. |
129,187 | 01.11.2017 11:27:01 | 14,400 | 76764f90953de74da4067cc0dc581b0e14223689 | Two things I forgot from earlier commits
(1) Forgot to update the ThreadInfo accesses in index.php when changing the shape of ThreadInfo
(2) Forgot to update edit_thread.php to only set subscribed if it's the right thread ID | [
{
"change_type": "MODIFY",
"old_path": "server/edit_thread.php",
"new_path": "server/edit_thread.php",
"diff": "@@ -277,7 +277,9 @@ if ($add_member_ids) {\n));\n}\nforeach ($roletype_results['to_save'] as $row_to_save) {\n+ if ($row_to_save['thread_id'] === $thread) {\n$row_to_save['subscribed'] = true;\n+ }\n$to_save[] = $row_to_save;\n}\n$to_delete = array_merge($to_delete, $roletype_results['to_delete']);\n"
},
{
"change_type": "MODIFY",
"old_path": "server/index.php",
"new_path": "server/index.php",
"diff": "@@ -7,6 +7,7 @@ require_once('thread_lib.php');\nrequire_once('message_lib.php');\nrequire_once('entry_lib.php');\nrequire_once('user_lib.php');\n+require_once('permissions.php');\nif ($https && !isset($_SERVER['HTTPS'])) {\n// We're using mod_rewrite .htaccess for HTTPS redirect; this shouldn't happen\n@@ -56,14 +57,16 @@ $null_state = null;\nif ($home) {\n$null_state = true;\nforeach ($thread_infos as $thread_info) {\n- if ($thread_info['subscribed']) {\n+ if ($thread_info['currentUserRole']['subscribed']) {\n$null_state = false;\nbreak;\n}\n}\n+} else if (!isset($thread_infos[$thread])) {\n+ $null_state = true;\n} else {\n- $null_state = !isset($thread_infos[$thread])\n- || !$thread_infos[$thread]['authorized'];\n+ $permissions = $thread_infos[$thread]['currentUserRole']['permissions'];\n+ $null_state = !$permissions[PERMISSION_VISIBLE];\n}\n$verify_rewrite_matched = preg_match(\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Two things I forgot from earlier commits
(1) Forgot to update the ThreadInfo accesses in index.php when changing the shape of ThreadInfo
(2) Forgot to update edit_thread.php to only set subscribed if it's the right thread ID |
129,187 | 01.11.2017 13:20:05 | 14,400 | 64d8be5ed5bb58d9005fd16ee3b7420c81a65026 | Show description in thread settings and support editing it
Also updated react-navigation to master since there's an Android fix in there, and make the add-child-thread and add-members buttons look at the right permission checks. | [
{
"change_type": "MODIFY",
"old_path": "native/chat/settings/edit-setting-button.react.js",
"new_path": "native/chat/settings/edit-setting-button.react.js",
"diff": "@@ -5,7 +5,7 @@ import type {\n} from 'react-native/Libraries/StyleSheet/StyleSheetTypes';\nimport React from 'react';\n-import { TouchableOpacity, StyleSheet } from 'react-native';\n+import { TouchableOpacity, StyleSheet, Platform } from 'react-native';\nimport Icon from 'react-native-vector-icons/FontAwesome';\ntype Props = {|\n@@ -36,6 +36,7 @@ function EditSettingButton(props: Props) {\nconst styles = StyleSheet.create({\neditIcon: {\npaddingLeft: 10,\n+ paddingTop: Platform.select({ android: 1, default: 0 }),\ntextAlign: 'right',\n},\n});\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/settings/thread-settings-category.react.js",
"new_path": "native/chat/settings/thread-settings-category.react.js",
"diff": "@@ -47,6 +47,13 @@ const styles = StyleSheet.create({\nbackgroundColor: \"white\",\n},\noutline: {\n+ borderWidth: 1,\n+ borderStyle: 'dashed',\n+ borderColor: \"#CCCCCC\",\n+ backgroundColor: \"#F5F5F5FF\",\n+ marginLeft: -1,\n+ marginRight: -1,\n+ borderRadius: 1,\n},\n});\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/settings/thread-settings.react.js",
"new_path": "native/chat/settings/thread-settings.react.js",
"diff": "@@ -25,10 +25,12 @@ import {\nTextInput,\nAlert,\nActivityIndicator,\n+ Platform,\n} from 'react-native';\nimport Modal from 'react-native-modal';\nimport invariant from 'invariant';\nimport _isEqual from 'lodash/fp/isEqual';\n+import Icon from 'react-native-vector-icons/FontAwesome';\nimport { visibilityRules } from 'lib/types/thread-types';\nimport {\n@@ -73,6 +75,7 @@ type Props = {|\nchildThreadInfos: ?ThreadInfo[],\nnameEditLoadingStatus: LoadingStatus,\ncolorEditLoadingStatus: LoadingStatus,\n+ descriptionEditLoadingStatus: LoadingStatus,\n// Redux dispatch functions\ndispatchActionPromise: DispatchActionPromise,\n// async functions that hit server APIs\n@@ -87,7 +90,9 @@ type State = {|\nshowMaxMembers: number,\nshowMaxChildThreads: number,\nnameEditValue: ?string,\n+ descriptionEditValue: ?string,\nnameTextHeight: ?number,\n+ descriptionTextHeight: ?number,\nshowEditColorModal: bool,\ncolorEditValue: string,\n|};\n@@ -111,6 +116,7 @@ class InnerThreadSettings extends React.PureComponent<Props, State> {\nchildThreadInfos: PropTypes.arrayOf(threadInfoPropType),\nnameEditLoadingStatus: loadingStatusPropType.isRequired,\ncolorEditLoadingStatus: loadingStatusPropType.isRequired,\n+ descriptionEditLoadingStatus: loadingStatusPropType.isRequired,\ndispatchActionPromise: PropTypes.func.isRequired,\nchangeSingleThreadSetting: PropTypes.func.isRequired,\n};\n@@ -119,6 +125,7 @@ class InnerThreadSettings extends React.PureComponent<Props, State> {\nheaderBackTitle: \"Back\",\n});\nnameTextInput: ?TextInput;\n+ descriptionTextInput: ?TextInput;\nconstructor(props: Props) {\nsuper(props);\n@@ -127,7 +134,9 @@ class InnerThreadSettings extends React.PureComponent<Props, State> {\nshowMaxMembers: itemPageLength,\nshowMaxChildThreads: itemPageLength,\nnameEditValue: null,\n+ descriptionEditValue: null,\nnameTextHeight: null,\n+ descriptionTextHeight: null,\nshowEditColorModal: false,\ncolorEditValue: props.threadInfo.color,\n};\n@@ -164,24 +173,15 @@ class InnerThreadSettings extends React.PureComponent<Props, State> {\nthis.state.nameEditValue === undefined) &&\n!this.state.showEditColorModal &&\nthis.props.nameEditLoadingStatus !== \"loading\" &&\n- this.props.colorEditLoadingStatus !== \"loading\";\n- }\n-\n- onLayoutNameText = (event: { nativeEvent: { layout: { height: number }}}) => {\n- this.setState({ nameTextHeight: event.nativeEvent.layout.height });\n- }\n-\n- onNameTextInputContentSizeChange = (\n- event: { nativeEvent: { contentSize: { height: number } } },\n- ) => {\n- this.setState({ nameTextHeight: event.nativeEvent.contentSize.height });\n+ this.props.colorEditLoadingStatus !== \"loading\" &&\n+ this.props.descriptionEditLoadingStatus !== \"loading\";\n}\nrender() {\nconst canStartEditing = this.canReset();\nconst permissions = this.props.threadInfo.currentUserRole.permissions;\n- const canChangeSettings = permissions[threadPermissions.EDIT_THREAD]\n- && canStartEditing;\n+ const canEditThread = permissions[threadPermissions.EDIT_THREAD];\n+ const canChangeSettings = canEditThread && canStartEditing;\nlet name;\nif (\n@@ -253,6 +253,86 @@ class InnerThreadSettings extends React.PureComponent<Props, State> {\ncolorButton = <ActivityIndicator size=\"small\" key=\"activityIndicator\" />;\n}\n+ let descriptionPanel = null;\n+ if (\n+ this.state.descriptionEditValue !== null &&\n+ this.state.descriptionEditValue !== undefined\n+ ) {\n+ const button = this.props.descriptionEditLoadingStatus !== \"loading\"\n+ ? <SaveSettingButton onPress={this.submitDescriptionEdit} />\n+ : <ActivityIndicator size=\"small\" />;\n+ const textInputStyle = {};\n+ if (\n+ this.state.descriptionTextHeight !== undefined &&\n+ this.state.descriptionTextHeight !== null\n+ ) {\n+ textInputStyle.height = this.state.descriptionTextHeight;\n+ }\n+ descriptionPanel = (\n+ <ThreadSettingsCategory type=\"full\" title=\"Description\">\n+ <View style={[styles.noPaddingRow, styles.padding]}>\n+ <TextInput\n+ style={[\n+ styles.descriptionText,\n+ styles.currentValueText,\n+ textInputStyle,\n+ ]}\n+ underlineColorAndroid=\"transparent\"\n+ value={this.state.descriptionEditValue}\n+ onChangeText={this.onChangeDescriptionText}\n+ multiline={true}\n+ autoFocus={true}\n+ selectTextOnFocus={true}\n+ onBlur={this.submitDescriptionEdit}\n+ editable={this.props.descriptionEditLoadingStatus !== \"loading\"}\n+ onContentSizeChange={this.onDescriptionTextInputContentSizeChange}\n+ ref={this.descriptionTextInputRef}\n+ />\n+ {button}\n+ </View>\n+ </ThreadSettingsCategory>\n+ );\n+ } else if (this.props.threadInfo.description) {\n+ descriptionPanel = (\n+ <ThreadSettingsCategory type=\"full\" title=\"Description\">\n+ <View style={[styles.noPaddingRow, styles.padding]}>\n+ <Text\n+ style={[styles.descriptionText, styles.currentValueText]}\n+ onLayout={this.onLayoutDescriptionText}\n+ >\n+ {this.props.threadInfo.description}\n+ </Text>\n+ <EditSettingButton\n+ onPress={this.onPressEditDescription}\n+ canChangeSettings={canChangeSettings}\n+ key=\"editButton\"\n+ />\n+ </View>\n+ </ThreadSettingsCategory>\n+ );\n+ } else if (canEditThread) {\n+ descriptionPanel = (\n+ <ThreadSettingsCategory type=\"outline\" title=\"Description\">\n+ <Button\n+ onPress={this.onPressEditDescription}\n+ style={styles.addDescriptionButton}\n+ iosFormat=\"highlight\"\n+ iosHighlightUnderlayColor=\"#EEEEEEDD\"\n+ >\n+ <Text style={styles.addDescriptionText}>\n+ Add a description...\n+ </Text>\n+ <Icon\n+ name=\"pencil\"\n+ size={16}\n+ style={styles.editIcon}\n+ color=\"#888888\"\n+ />\n+ </Button>\n+ </ThreadSettingsCategory>\n+ );\n+ }\n+\nlet parent;\nif (this.props.parentThreadInfo) {\nparent = (\n@@ -331,6 +411,33 @@ class InnerThreadSettings extends React.PureComponent<Props, State> {\nmembers.push(seeMoreMembers);\n}\n+ let addMembers = null;\n+ if (permissions[threadPermissions.ADD_MEMBERS]) {\n+ addMembers = (\n+ <View style={styles.addItemRow}>\n+ <ThreadSettingsListAction\n+ onPress={this.onPressAddUser}\n+ text=\"Add users\"\n+ iconName=\"md-add\"\n+ iconColor=\"#009900\"\n+ iconSize={20}\n+ />\n+ </View>\n+ );\n+ }\n+\n+ let membersPanel = null;\n+ if (addMembers || members) {\n+ membersPanel = (\n+ <ThreadSettingsCategory type=\"unpadded\" title=\"Members\">\n+ <View style={styles.itemList}>\n+ {addMembers}\n+ {members}\n+ </View>\n+ </ThreadSettingsCategory>\n+ );\n+ }\n+\nlet childThreads = null;\nif (this.props.childThreadInfos) {\nlet childThreadInfos;\n@@ -369,6 +476,33 @@ class InnerThreadSettings extends React.PureComponent<Props, State> {\n}\n}\n+ let addChildThread = null;\n+ if (permissions[threadPermissions.CREATE_SUBTHREADS]) {\n+ addChildThread = (\n+ <View style={styles.addItemRow}>\n+ <ThreadSettingsListAction\n+ onPress={this.onPressAddChildThread}\n+ text=\"Add child thread\"\n+ iconName=\"md-add\"\n+ iconColor=\"#009900\"\n+ iconSize={20}\n+ />\n+ </View>\n+ );\n+ }\n+\n+ let childThreadPanel = null;\n+ if (addChildThread || childThreads) {\n+ childThreadPanel = (\n+ <ThreadSettingsCategory type=\"unpadded\" title=\"Child threads\">\n+ <View style={styles.itemList}>\n+ {addChildThread}\n+ {childThreads}\n+ </View>\n+ </ThreadSettingsCategory>\n+ );\n+ }\n+\nreturn (\n<View>\n<ScrollView contentContainerStyle={styles.scrollView}>\n@@ -385,6 +519,7 @@ class InnerThreadSettings extends React.PureComponent<Props, State> {\n{colorButton}\n</View>\n</ThreadSettingsCategory>\n+ {descriptionPanel}\n<ThreadSettingsCategory type=\"full\" title=\"Privacy\">\n<View style={styles.noPaddingRow}>\n<Text style={[styles.label, styles.padding]}>Parent</Text>\n@@ -397,34 +532,8 @@ class InnerThreadSettings extends React.PureComponent<Props, State> {\n</Text>\n</View>\n</ThreadSettingsCategory>\n- <ThreadSettingsCategory type=\"unpadded\" title=\"Child threads\">\n- <View style={styles.itemList}>\n- <View style={styles.addItemRow}>\n- <ThreadSettingsListAction\n- onPress={this.onPressAddChildThread}\n- text=\"Add child thread\"\n- iconName=\"md-add\"\n- iconColor=\"#009900\"\n- iconSize={20}\n- />\n- </View>\n- {childThreads}\n- </View>\n- </ThreadSettingsCategory>\n- <ThreadSettingsCategory type=\"unpadded\" title=\"Members\">\n- <View style={styles.itemList}>\n- <View style={styles.addItemRow}>\n- <ThreadSettingsListAction\n- onPress={this.onPressAddUser}\n- text=\"Add users\"\n- iconName=\"md-add\"\n- iconColor=\"#009900\"\n- iconSize={20}\n- />\n- </View>\n- {members}\n- </View>\n- </ThreadSettingsCategory>\n+ {childThreadPanel}\n+ {membersPanel}\n</ScrollView>\n<Modal\nisVisible={this.state.showAddUsersModal}\n@@ -451,6 +560,18 @@ class InnerThreadSettings extends React.PureComponent<Props, State> {\nthis.nameTextInput = nameTextInput;\n}\n+ onLayoutNameText = (\n+ event: { nativeEvent: { layout: { height: number } } },\n+ ) => {\n+ this.setState({ nameTextHeight: event.nativeEvent.layout.height });\n+ }\n+\n+ onNameTextInputContentSizeChange = (\n+ event: { nativeEvent: { contentSize: { height: number } } },\n+ ) => {\n+ this.setState({ nameTextHeight: event.nativeEvent.contentSize.height });\n+ }\n+\nonPressEditName = () => {\nthis.setState({ nameEditValue: this.props.threadInfo.name });\n}\n@@ -563,6 +684,89 @@ class InnerThreadSettings extends React.PureComponent<Props, State> {\nthis.setState({ colorEditValue: this.props.threadInfo.color });\n}\n+ descriptionTextInputRef = (descriptionTextInput: ?TextInput) => {\n+ this.descriptionTextInput = descriptionTextInput;\n+ }\n+\n+ onLayoutDescriptionText = (\n+ event: { nativeEvent: { layout: { height: number } } },\n+ ) => {\n+ this.setState({ descriptionTextHeight: event.nativeEvent.layout.height });\n+ }\n+\n+ onDescriptionTextInputContentSizeChange = (\n+ event: { nativeEvent: { contentSize: { height: number } } },\n+ ) => {\n+ this.setState({\n+ descriptionTextHeight: event.nativeEvent.contentSize.height,\n+ });\n+ }\n+\n+ onPressEditDescription = () => {\n+ this.setState({ descriptionEditValue: this.props.threadInfo.description });\n+ }\n+\n+ onChangeDescriptionText = (text: string) => {\n+ this.setState({ descriptionEditValue: text });\n+ }\n+\n+ submitDescriptionEdit = () => {\n+ invariant(\n+ this.state.descriptionEditValue !== null &&\n+ this.state.descriptionEditValue !== undefined,\n+ \"should be set\",\n+ );\n+ const description = this.state.descriptionEditValue.trim();\n+\n+ if (description === this.props.threadInfo.description) {\n+ this.setState({ descriptionEditValue: null });\n+ return;\n+ }\n+\n+ this.props.dispatchActionPromise(\n+ changeThreadSettingsActionTypes,\n+ this.editDescription(description),\n+ {\n+ customKeyName: `${changeThreadSettingsActionTypes.started}:description`,\n+ },\n+ );\n+ }\n+\n+ async editDescription(newDescription: string) {\n+ try {\n+ const result = await this.props.changeSingleThreadSetting(\n+ this.props.threadInfo.id,\n+ \"description\",\n+ newDescription,\n+ );\n+ this.setState({ descriptionEditValue: null });\n+ return result;\n+ } catch (e) {\n+ Alert.alert(\n+ \"Unknown error\",\n+ \"Uhh... try again?\",\n+ [\n+ { text: 'OK', onPress: this.onDescriptionErrorAcknowledged },\n+ ],\n+ { cancelable: false },\n+ );\n+ throw e;\n+ }\n+ }\n+\n+ onDescriptionErrorAcknowledged = () => {\n+ this.setState(\n+ { descriptionEditValue: this.props.threadInfo.description },\n+ () => {\n+ invariant(\n+ this.descriptionTextInput,\n+ \"descriptionTextInput should be set\",\n+ );\n+ this.descriptionTextInput.focus();\n+ },\n+ );\n+ }\n+\nonPressParentThread = () => {\nthis.props.navigation.navigate(\nMessageListRouteName,\n@@ -624,7 +828,7 @@ const styles = StyleSheet.create({\npaddingBottom: 8,\n},\ncolorLine: {\n- lineHeight: 25,\n+ lineHeight: Platform.select({ android: 22, default: 25 }),\n},\ncurrentValue: {\nflex: 1,\n@@ -669,6 +873,24 @@ const styles = StyleSheet.create({\nright: 10,\ntop: 15,\n},\n+ addDescriptionText: {\n+ fontSize: 16,\n+ color: \"#888888\",\n+ flex: 1,\n+ },\n+ addDescriptionButton: {\n+ flexDirection: 'row',\n+ paddingHorizontal: 24,\n+ paddingVertical: 10,\n+ },\n+ editIcon: {\n+ textAlign: 'right',\n+ paddingLeft: 10,\n+ },\n+ descriptionText: {\n+ flex: 1,\n+ paddingLeft: 0,\n+ },\n});\nconst ThreadSettingsRouteName = 'ThreadSettings';\n@@ -693,6 +915,10 @@ const ThreadSettings = connect(\nchangeThreadSettingsActionTypes,\n`${changeThreadSettingsActionTypes.started}:color`,\n)(state),\n+ descriptionEditLoadingStatus: createLoadingStatusSelector(\n+ changeThreadSettingsActionTypes,\n+ `${changeThreadSettingsActionTypes.started}:description`,\n+ )(state),\ncookie: state.cookie,\n};\n},\n"
},
{
"change_type": "MODIFY",
"old_path": "native/package-lock.json",
"new_path": "native/package-lock.json",
"diff": "}\n},\n\"react-navigation\": {\n- \"version\": \"git://github.com/react-community/react-navigation.git#6fa39e2f4daca844b3952bd9854f91b3d95d4c94\",\n+ \"version\": \"git://github.com/react-community/react-navigation.git#ed2fc9a09e2f562ae9d3fc7f5df17c593989db0a\",\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.6\",\n\"react-native-segmented-control-tab\": \"^3.2.1\",\n\"react-native-vector-icons\": \"^4.3.0\",\n- \"react-navigation\": \"git://github.com/react-community/react-navigation.git#fixflow\",\n+ \"react-navigation\": \"git://github.com/react-community/react-navigation.git#master\",\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 | Show description in thread settings and support editing it
Also updated react-navigation to master since there's an Android fix in there, and make the add-child-thread and add-members buttons look at the right permission checks. |
129,187 | 03.11.2017 12:23:04 | 14,400 | 96068e60ec004e8a4f2a2294822e61d70268d597 | Couple bugfixes for ThreadInfo permissions update in last commit
1. `source` can (and will) be `null` if `value` is `false`
2. Server should make sure `source` is cast to a string | [
{
"change_type": "MODIFY",
"old_path": "lib/types/thread-types.js",
"new_path": "lib/types/thread-types.js",
"diff": "@@ -84,18 +84,24 @@ export function assertThreadPermissions(\nreturn ourThreadPermissions;\n}\n+type ThreadPermissionInfo =\n+ | {| value: true, source: string |}\n+ | {| value: false, source: null |};\nexport type ThreadPermissionsBlob = {|\n- [permission: ThreadPermission]: {|\n- value: bool,\n- source: string, // thread ID\n- |},\n+ [permission: ThreadPermission]: ThreadPermissionInfo,\n|};\nexport const threadPermissionsBlobPropType = PropTypes.objectOf(\n+ PropTypes.oneOfType([\nPropTypes.shape({\n- value: PropTypes.bool.isRequired,\n+ value: PropTypes.oneOf([ true ]),\nsource: PropTypes.string.isRequired,\n}),\n+ PropTypes.shape({\n+ value: PropTypes.oneOf([ false ]),\n+ source: PropTypes.oneOf([ null ]),\n+ }),\n+ ]),\n);\nexport type MemberInfo = {|\n"
},
{
"change_type": "MODIFY",
"old_path": "server/permissions.php",
"new_path": "server/permissions.php",
"diff": "@@ -166,7 +166,7 @@ function get_all_thread_permissions($info, $thread_id) {\n$source = null;\nif ($result) {\nif ($info && $info['permissions'] && $info['permissions'][$permission]) {\n- $source = $info['permissions'][$permission]['source'];\n+ $source = (string)$info['permissions'][$permission]['source'];\n} else {\n$source = (string)$thread_id;\n}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Couple bugfixes for ThreadInfo permissions update in last commit
1. `source` can (and will) be `null` if `value` is `false`
2. Server should make sure `source` is cast to a string |
129,187 | 03.11.2017 17:08:23 | 14,400 | 47530e9191a3f6b9a3e384fe47153eac61b60f8d | Update to latest react-navigation | [
{
"change_type": "MODIFY",
"old_path": "native/package-lock.json",
"new_path": "native/package-lock.json",
"diff": "}\n},\n\"react-navigation\": {\n- \"version\": \"git://github.com/react-community/react-navigation.git#ed2fc9a09e2f562ae9d3fc7f5df17c593989db0a\",\n+ \"version\": \"1.0.0-beta.18\",\n+ \"resolved\": \"https://registry.npmjs.org/react-navigation/-/react-navigation-1.0.0-beta.18.tgz\",\n+ \"integrity\": \"sha512-JLPA93WJvrgGv94Hk6D1vaE1/LsUHUuCuZafh9lbd9dPU/iYknbe/oX+XSTdgCs7luya2pPOh+feY8YqKNu2rA==\",\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.6\",\n\"react-native-segmented-control-tab\": \"^3.2.1\",\n\"react-native-vector-icons\": \"^4.3.0\",\n- \"react-navigation\": \"git://github.com/react-community/react-navigation.git#master\",\n+ \"react-navigation\": \"^1.0.0-beta.18\",\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 | Update to latest react-navigation |
129,187 | 03.11.2017 17:15:30 | 14,400 | a77f9892028127ad7729ec92dbd12c38a81f5f3b | Minor bugfix for last commit | [
{
"change_type": "MODIFY",
"old_path": "server/thread_lib.php",
"new_path": "server/thread_lib.php",
"diff": "@@ -82,7 +82,7 @@ SQL;\nif ((int)$user_id === $viewer_id) {\n$thread_infos[$thread_id]['currentUser'] = array(\n\"permissions\" => $member['permissions'],\n- \"role\" => $member['roletype'],\n+ \"role\" => $member['role'],\n\"subscribed\" => !!$row['subscribed'],\n);\n}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Minor bugfix for last commit |
129,187 | 06.11.2017 23:14:21 | 18,000 | abb3f53518fe2036d15cbe37d828f4746e705884 | Working simple popover tooltip derived from open source component | [
{
"change_type": "MODIFY",
"old_path": "native/chat/settings/thread-settings-user.react.js",
"new_path": "native/chat/settings/thread-settings-user.react.js",
"diff": "@@ -4,12 +4,14 @@ import type { ThreadInfo } from 'lib/types/thread-types';\nimport { threadPermissions } from 'lib/types/thread-types';\nimport React from 'react';\n-import { View, Text, StyleSheet } from 'react-native';\n+import { View, Text, StyleSheet, Platform } from 'react-native';\n+import Icon from 'react-native-vector-icons/FontAwesome';\nimport { threadHasPermission } from 'lib/shared/thread-utils';\nimport EditSettingButton from './edit-setting-button.react';\nimport Button from '../../components/button.react';\n+import PopoverTooltip from '../../components/popover-tooltip.react';\ntype Props = {|\nuserInfo: {|\n@@ -20,32 +22,52 @@ type Props = {|\nthreadInfo: ThreadInfo,\ncanEdit: bool,\n|};\n-function ThreadSettingsUser(props: Props) {\n+class ThreadSettingsUser extends React.PureComponent<Props> {\n+\n+ popoverConfig: $ReadOnlyArray<{ label: string, onPress: () => void }>;\n+\n+ constructor(props: Props) {\n+ super(props);\n+ this.popoverConfig = [\n+ { label: \"Remove user\", onPress: this.onPressRemoveUser },\n+ { label: \"Make admin\", onPress: this.onPressMakeAdmin },\n+ ];\n+ }\n+\n+ render() {\nconst canEditThread = threadHasPermission(\n- props.threadInfo,\n+ this.props.threadInfo,\nthreadPermissions.EDIT_THREAD,\n);\n- const canChange = !props.userInfo.isViewer && canEditThread;\n+ const canChange = !this.props.userInfo.isViewer && canEditThread;\nlet editButton = null;\n- if (props.canEdit) {\n+ if (canChange && this.props.canEdit) {\neditButton = (\n- <EditSettingButton\n- onPress={() => {}}\n- canChangeSettings={canChange}\n- style={styles.editSettingsIcon}\n+ <PopoverTooltip\n+ buttonComponent={icon}\n+ items={this.popoverConfig}\n+ labelStyle={styles.popoverLabelStyle}\n/>\n);\n}\nreturn (\n<View style={styles.container}>\n<Text style={styles.username} numberOfLines={1}>\n- {props.userInfo.username}\n+ {this.props.userInfo.username}\n</Text>\n{editButton}\n</View>\n);\n}\n+ onPressRemoveUser = () => {\n+ }\n+\n+ onPressMakeAdmin = () => {\n+ }\n+\n+}\n+\nconst styles = StyleSheet.create({\ncontainer: {\nflex: 1,\n@@ -58,9 +80,25 @@ const styles = StyleSheet.create({\nfontSize: 16,\ncolor: \"#333333\",\n},\n- editSettingsIcon: {\n+ editIcon: {\nlineHeight: 20,\n+ paddingLeft: 10,\n+ paddingTop: Platform.select({ android: 1, default: 0 }),\n+ textAlign: 'right',\n+ },\n+ popoverLabelStyle: {\n+ textAlign: 'center',\n+ color: '#444',\n},\n});\n+const icon = (\n+ <Icon\n+ name=\"pencil\"\n+ size={16}\n+ style={styles.editIcon}\n+ color=\"#036AFF\"\n+ />\n+);\n+\nexport default ThreadSettingsUser;\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/components/popover-tooltip.react.js",
"diff": "+// @flow\n+\n+import type {\n+ StyleObj,\n+} from 'react-native/Libraries/StyleSheet/StyleSheetTypes';\n+\n+import * as React from 'react';\n+import {\n+ View,\n+ Modal,\n+ Animated,\n+ TouchableOpacity,\n+ StyleSheet,\n+ Dimensions,\n+ Text,\n+ Easing,\n+ ViewPropTypes,\n+} from 'react-native';\n+import PropTypes from 'prop-types';\n+import invariant from 'invariant';\n+\n+const window = Dimensions.get('window');\n+\n+type Label = string | () => React.Node;\n+const labelPropType = PropTypes.oneOfType([\n+ PropTypes.string,\n+ PropTypes.func,\n+]);\n+\n+type Props = {\n+ buttonComponent: React.Node,\n+ buttonComponentExpandRatio: number,\n+ items: $ReadOnlyArray<{ +label: Label, onPress: () => void }>,\n+ componentWrapperStyle?: StyleObj,\n+ overlayStyle?: StyleObj,\n+ tooltipContainerStyle?: StyleObj,\n+ labelContainerStyle?: StyleObj,\n+ labelSeparatorColor: string,\n+ labelStyle?: StyleObj,\n+ setBelow: bool,\n+ animationType?: \"timing\" | \"spring\",\n+ onRequestClose: () => void,\n+ triangleOffset: number,\n+ onOpenTooltipMenu?: () => void,\n+ onCloseTooltipMenu?: () => void,\n+ componentContainerStyle?: StyleObj,\n+ timingConfig?: { duration?: number },\n+ springConfig?: { tension?: number, friction?: number },\n+ opacityChangeDuration?: number,\n+};\n+type State = {\n+ isModalOpen: bool,\n+ x: number,\n+ y: number,\n+ width: number,\n+ height: number,\n+ opacity: Animated.Value,\n+ tooltipContainerScale: Animated.Value,\n+ buttonComponentContainerScale: number | Animated.Interpolation,\n+ tooltipTriangleDown: bool,\n+ tooltipTriangleLeftMargin: number,\n+ triangleOffset: number,\n+ willPopUp: bool,\n+ oppositeOpacity: ?Animated.Interpolation,\n+ tooltipContainerX: ?Animated.Interpolation,\n+ tooltipContainerY: ?Animated.Interpolation,\n+};\n+class PopoverTooltip extends React.PureComponent<Props, State> {\n+\n+ static propTypes = {\n+ buttonComponent: PropTypes.node.isRequired,\n+ buttonComponentExpandRatio: PropTypes.number,\n+ items: PropTypes.arrayOf(PropTypes.shape({\n+ label: labelPropType.isRequired,\n+ onPress: PropTypes.func.isRequired,\n+ })).isRequired,\n+ componentWrapperStyle: ViewPropTypes.style,\n+ overlayStyle: ViewPropTypes.style,\n+ tooltipContainerStyle: ViewPropTypes.style,\n+ labelContainerStyle: ViewPropTypes.style,\n+ labelSeparatorColor: PropTypes.string,\n+ labelStyle: Text.propTypes.style,\n+ setBelow: PropTypes.bool,\n+ animationType: PropTypes.oneOf([ \"timing\", \"spring\" ]),\n+ onRequestClose: PropTypes.func,\n+ triangleOffset: PropTypes.number,\n+ onOpenTooltipMenu: PropTypes.func,\n+ onCloseTooltipMenu: PropTypes.func,\n+ componentContainerStyle: ViewPropTypes.style,\n+ timingConfig: PropTypes.object,\n+ springConfig: PropTypes.object,\n+ opacityChangeDuration: PropTypes.number,\n+ };\n+ static defaultProps = {\n+ buttonComponentExpandRatio: 1.0,\n+ labelSeparatorColor: \"#E1E1E1\",\n+ onRequestClose: () => {},\n+ setBelow: false,\n+ triangleOffset: 0,\n+ };\n+ wrapperComponent: ?TouchableOpacity;\n+\n+ constructor(props: Props) {\n+ super(props);\n+ this.state = {\n+ isModalOpen: false,\n+ x: 0,\n+ y: 0,\n+ width: 0,\n+ height: 0,\n+ opacity: new Animated.Value(0),\n+ tooltipContainerScale: new Animated.Value(0),\n+ buttonComponentContainerScale: 1,\n+ tooltipTriangleDown: !props.setBelow,\n+ tooltipTriangleLeftMargin: 0,\n+ triangleOffset: props.triangleOffset,\n+ willPopUp: false,\n+ oppositeOpacity: undefined,\n+ tooltipContainerX: undefined,\n+ tooltipContainerY: undefined,\n+ };\n+ }\n+\n+ componentWillMount() {\n+ const newOppositeOpacity = this.state.opacity.interpolate({\n+ inputRange: [0, 1],\n+ outputRange: [1, 0],\n+ });\n+ this.setState({ oppositeOpacity: newOppositeOpacity });\n+ }\n+\n+ toggleModal = () => {\n+ this.setState({ isModalOpen: !this.state.isModalOpen });\n+ }\n+\n+ openModal = () => {\n+ this.setState({ willPopUp: true });\n+ this.toggleModal();\n+ this.props.onOpenTooltipMenu && this.props.onOpenTooltipMenu();\n+ }\n+\n+ hideModal = () => {\n+ this.setState({ willPopUp: false });\n+ this.showZoomingOutAnimation();\n+ this.props.onCloseTooltipMenu && this.props.onCloseTooltipMenu();\n+ }\n+\n+ onPressItem = (userCallback: () => void) => {\n+ this.toggle();\n+ userCallback();\n+ }\n+\n+ onInnerContainerLayout = (\n+ event: { nativeEvent: { layout: { height: number, width: number } } },\n+ ) => {\n+ const tooltipContainerWidth = event.nativeEvent.layout.width;\n+ const tooltipContainerHeight = event.nativeEvent.layout.height;\n+ if (\n+ !this.state.willPopUp ||\n+ tooltipContainerWidth === 0 ||\n+ tooltipContainerHeight === 0\n+ ) {\n+ return;\n+ }\n+\n+ const componentWrapper = this.wrapperComponent;\n+ invariant(componentWrapper, \"should be set\");\n+ componentWrapper.measure((x, y, width, height, pageX, pageY) => {\n+ const fullWidth = pageX + tooltipContainerWidth\n+ + (width - tooltipContainerWidth) / 2;\n+ const tooltipContainerX_final = fullWidth > window.width\n+ ? window.width - tooltipContainerWidth - 10\n+ : pageX + (width - tooltipContainerWidth) / 2;\n+ let tooltipContainerY_final = this.state.tooltipTriangleDown\n+ ? pageY - tooltipContainerHeight - 10\n+ : pageY + tooltipContainerHeight - 10;\n+ let tooltipTriangleDown = this.state.tooltipTriangleDown;\n+ if (pageY - tooltipContainerHeight - 10 < 0) {\n+ tooltipContainerY_final = pageY + height + 10;\n+ tooltipTriangleDown = false;\n+ }\n+ if (pageY + tooltipContainerHeight + 80 > window.height) {\n+ tooltipContainerY_final = pageY - tooltipContainerHeight - 10;\n+ tooltipTriangleDown = true;\n+ }\n+ const tooltipContainerX = this.state.tooltipContainerScale.interpolate({\n+ inputRange: [0, 1],\n+ outputRange: [tooltipContainerX_final, tooltipContainerX_final],\n+ });\n+ const tooltipContainerY = this.state.tooltipContainerScale.interpolate({\n+ inputRange: [0, 1],\n+ outputRange: [\n+ tooltipContainerY_final + tooltipContainerHeight / 2 + 10,\n+ tooltipContainerY_final,\n+ ],\n+ });\n+ const buttonComponentContainerScale =\n+ this.state.tooltipContainerScale.interpolate({\n+ inputRange: [0, 1],\n+ outputRange: [1, this.props.buttonComponentExpandRatio],\n+ });\n+ const tooltipTriangleLeftMargin =\n+ pageX + width / 2 - tooltipContainerX_final - 6;\n+ this.setState(\n+ {\n+ x: pageX,\n+ y: pageY,\n+ width,\n+ height,\n+ tooltipContainerX,\n+ tooltipContainerY,\n+ tooltipTriangleDown,\n+ tooltipTriangleLeftMargin,\n+ buttonComponentContainerScale,\n+ },\n+ this.showZoomingInAnimation,\n+ );\n+ });\n+ this.setState({ willPopUp: false });\n+ }\n+\n+ render() {\n+ const tooltipContainerStyle = {\n+ left: this.state.tooltipContainerX,\n+ top: this.state.tooltipContainerY,\n+ transform: [\n+ { scale: this.state.tooltipContainerScale },\n+ ],\n+ };\n+\n+ const items = this.props.items.map((item, index) => {\n+ const classes = [ this.props.labelContainerStyle ];\n+\n+ if (index !== this.props.items.length - 1) {\n+ classes.push([\n+ styles.tooltipMargin,\n+ { borderBottomColor: this.props.labelSeparatorColor },\n+ ]);\n+ }\n+\n+ return (\n+ <PopoverTooltipItem\n+ key={index}\n+ label={item.label}\n+ onPressUserCallback={item.onPress}\n+ onPress={this.onPressItem}\n+ containerStyle={classes}\n+ labelStyle={this.props.labelStyle}\n+ />\n+ );\n+ });\n+\n+ const labelContainerStyle = this.props.labelContainerStyle;\n+ const borderStyle =\n+ labelContainerStyle && labelContainerStyle.backgroundColor\n+ ? { borderTopColor: labelContainerStyle.backgroundColor }\n+ : null;\n+ let triangleDown = null;\n+ let triangleUp = null;\n+ if (this.state.tooltipTriangleDown) {\n+ triangleDown = (\n+ <View style={[\n+ styles.triangleDown,\n+ {\n+ marginLeft: this.state.tooltipTriangleLeftMargin,\n+ left: this.state.triangleOffset,\n+ },\n+ borderStyle,\n+ ]} />\n+ );\n+ } else {\n+ triangleUp = (\n+ <View style={[\n+ styles.triangleUp,\n+ {\n+ marginLeft: this.state.tooltipTriangleLeftMargin,\n+ left: this.state.triangleOffset,\n+ },\n+ borderStyle,\n+ ]} />\n+ );\n+ }\n+\n+ return (\n+ <TouchableOpacity\n+ ref={this.wrapperRef}\n+ style={this.props.componentWrapperStyle}\n+ onPress={this.toggle}\n+ >\n+ <Animated.View style={[\n+ { opacity: this.state.oppositeOpacity },\n+ this.props.componentContainerStyle,\n+ ]}>\n+ {this.props.buttonComponent}\n+ </Animated.View>\n+ <Modal\n+ visible={this.state.isModalOpen}\n+ onRequestClose={this.props.onRequestClose}\n+ transparent\n+ >\n+ <Animated.View style={[\n+ styles.overlay,\n+ this.props.overlayStyle,\n+ { opacity: this.state.opacity },\n+ ]}>\n+ <TouchableOpacity\n+ activeOpacity={1}\n+ focusedOpacity={1}\n+ style={styles.button}\n+ onPress={this.toggle}\n+ >\n+ <Animated.View\n+ style={[\n+ styles.tooltipContainer,\n+ this.props.tooltipContainerStyle,\n+ tooltipContainerStyle,\n+ ]}\n+ >\n+ <View\n+ onLayout={this.onInnerContainerLayout}\n+ style={styles.innerContainer}\n+ >\n+ {triangleUp}\n+ <View style={[\n+ styles.allItemContainer,\n+ this.props.tooltipContainerStyle,\n+ ]}>\n+ {items}\n+ </View>\n+ {triangleDown}\n+ </View>\n+ </Animated.View>\n+ </TouchableOpacity>\n+ </Animated.View>\n+ <Animated.View style={{\n+ position: 'absolute',\n+ left: this.state.x,\n+ top: this.state.y,\n+ width: this.state.width,\n+ height: this.state.height,\n+ backgroundColor: 'transparent',\n+ opacity: 1,\n+ transform: [\n+ { scale: this.state.buttonComponentContainerScale },\n+ ],\n+ }}>\n+ <TouchableOpacity\n+ onPress={this.toggle}\n+ activeOpacity={1.0}\n+ >\n+ {this.props.buttonComponent}\n+ </TouchableOpacity>\n+ </Animated.View>\n+ </Modal>\n+ </TouchableOpacity>\n+ );\n+ }\n+\n+ wrapperRef = (wrapperComponent: ?TouchableOpacity) => {\n+ this.wrapperComponent = wrapperComponent;\n+ }\n+\n+ showZoomingInAnimation = () => {\n+ let tooltipAnimation = Animated.timing(\n+ this.state.tooltipContainerScale,\n+ {\n+ toValue: 1,\n+ duration: this.props.timingConfig && this.props.timingConfig.duration\n+ ? this.props.timingConfig.duration\n+ : 200,\n+ }\n+ );\n+ if (this.props.animationType == 'spring') {\n+ tooltipAnimation = Animated.spring(\n+ this.state.tooltipContainerScale,\n+ {\n+ toValue: 1,\n+ tension: this.props.springConfig && this.props.springConfig.tension\n+ ? this.props.springConfig.tension\n+ : 100,\n+ friction: this.props.springConfig && this.props.springConfig.friction\n+ ? this.props.springConfig.friction\n+ : 7,\n+ },\n+ );\n+ }\n+ Animated.parallel([\n+ tooltipAnimation,\n+ Animated.timing(\n+ this.state.opacity,\n+ {\n+ toValue: 1,\n+ duration: this.props.opacityChangeDuration\n+ ? this.props.opacityChangeDuration\n+ : 200,\n+ },\n+ ),\n+ ]).start();\n+ }\n+\n+ showZoomingOutAnimation() {\n+ Animated.parallel([\n+ Animated.timing(\n+ this.state.tooltipContainerScale,\n+ {\n+ toValue: 0,\n+ duration: this.props.opacityChangeDuration\n+ ? this.props.opacityChangeDuration\n+ : 200,\n+ },\n+ ),\n+ Animated.timing(\n+ this.state.opacity,\n+ {\n+ toValue: 0,\n+ duration: this.props.opacityChangeDuration\n+ ? this.props.opacityChangeDuration\n+ : 200,\n+ },\n+ ),\n+ ]).start(this.toggleModal);\n+ }\n+\n+ toggle = () => {\n+ if (this.state.isModalOpen) {\n+ this.hideModal();\n+ } else {\n+ this.openModal();\n+ }\n+ }\n+\n+}\n+\n+type ItemProps = {\n+ onPress: (userCallback: () => void) => void,\n+ onPressUserCallback: () => void,\n+ label: Label,\n+ containerStyle: ?StyleObj,\n+ labelStyle: ?StyleObj,\n+};\n+class PopoverTooltipItem extends React.PureComponent<ItemProps> {\n+\n+ static propTypes = {\n+ onPress: PropTypes.func.isRequired,\n+ onPressUserCallback: PropTypes.func.isRequired,\n+ label: labelPropType.isRequired,\n+ containerStyle: ViewPropTypes.style,\n+ labelStyle: Text.propTypes.style,\n+ };\n+ static defaultProps = {\n+ labelStyle: null,\n+ containerStyle: null,\n+ };\n+\n+ render() {\n+ const label = typeof this.props.label === 'string'\n+ ? <Text style={this.props.labelStyle}>{this.props.label}</Text>\n+ : this.props.label();\n+ return (\n+ <View style={[styles.itemContainer, this.props.containerStyle]}>\n+ <TouchableOpacity onPress={this.onPress}>\n+ {label}\n+ </TouchableOpacity>\n+ </View>\n+ );\n+ }\n+\n+ onPress = () => {\n+ this.props.onPress(this.props.onPressUserCallback);\n+ }\n+\n+}\n+\n+const styles = StyleSheet.create({\n+ overlay: {\n+ backgroundColor: 'rgba(0,0,0,0.5)',\n+ flex: 1,\n+ },\n+ innerContainer: {\n+ backgroundColor: 'transparent',\n+ alignItems: 'flex-start'\n+ },\n+ tooltipMargin: {\n+ borderBottomWidth: 1,\n+ },\n+ tooltipContainer: {\n+ backgroundColor: 'transparent',\n+ position: 'absolute',\n+ },\n+ triangleDown: {\n+ width: 10,\n+ height: 10,\n+ backgroundColor: 'transparent',\n+ borderStyle: 'solid',\n+ borderTopWidth: 10,\n+ borderRightWidth: 10,\n+ borderBottomWidth: 0,\n+ borderLeftWidth: 10,\n+ borderTopColor: 'white',\n+ borderRightColor: 'transparent',\n+ borderBottomColor: 'transparent',\n+ borderLeftColor: 'transparent',\n+ },\n+ triangleUp: {\n+ width: 10,\n+ height: 10,\n+ backgroundColor: 'transparent',\n+ borderStyle: 'solid',\n+ borderTopWidth: 0,\n+ borderRightWidth: 10,\n+ borderBottomWidth: 10,\n+ borderLeftWidth: 10,\n+ borderBottomColor: 'white',\n+ borderTopColor: 'transparent',\n+ borderRightColor: 'transparent',\n+ borderLeftColor: 'transparent',\n+ },\n+ itemContainer: {\n+ padding: 10,\n+ },\n+ button: {\n+ flex: 1,\n+ },\n+ allItemContainer: {\n+ borderRadius: 5,\n+ backgroundColor: 'white',\n+ alignSelf: 'stretch',\n+ overflow: 'hidden',\n+ },\n+});\n+\n+export default PopoverTooltip;\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Working simple popover tooltip derived from open source component |
129,187 | 07.11.2017 12:02:56 | 18,000 | 578141fffe664d791b86aac979da28cf9ddbb2b0 | Fix three server bugs
1. subscribe.php wasn't getting the new roletype, so it was returning a `CurrentUserInfo` that didn't indicate membership
2. `get_thread_infos` was checking an array key's existence without using `isset`
3. `get_thread_infos` was filtering out any anonymous users from the member list | [
{
"change_type": "MODIFY",
"old_path": "server/permissions.php",
"new_path": "server/permissions.php",
"diff": "@@ -129,6 +129,9 @@ function get_info_from_permissions_row($row) {\n\"permissions\" => $blob,\n\"visibility_rules\" => (int)$row['visibility_rules'],\n\"edit_rules\" => (int)$row['edit_rules'],\n+ \"roletype\" => $row['roletype'] !== null\n+ ? (int)$row['roletype']\n+ : null,\n);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "server/thread_lib.php",
"new_path": "server/thread_lib.php",
"diff": "@@ -42,7 +42,7 @@ SQL;\n$user_infos = array();\nwhile ($row = $result->fetch_assoc()) {\n$thread_id = $row['id'];\n- if (!$thread_infos[$thread_id]) {\n+ if (!isset($thread_infos[$thread_id])) {\n$thread_infos[$thread_id] = array(\n\"id\" => $thread_id,\n\"name\" => $row['name'],\n@@ -68,7 +68,7 @@ SQL;\n\"permissions\" => $roletype_permissions,\n);\n}\n- if ($row['user'] !== null && $row['username'] !== null) {\n+ if ($row['user'] !== null) {\n$user_id = $row['user'];\n$permission_info = get_info_from_permissions_row($row);\n$all_permissions =\n@@ -86,12 +86,14 @@ SQL;\n\"subscribed\" => !!$row['subscribed'],\n);\n}\n+ if ($row['username']) {\n$user_infos[$user_id] = array(\n\"id\" => $user_id,\n\"username\" => $row['username'],\n);\n}\n}\n+ }\n$final_thread_infos = array();\nforeach ($thread_infos as $thread_id => $thread_info) {\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Fix three server bugs
1. subscribe.php wasn't getting the new roletype, so it was returning a `CurrentUserInfo` that didn't indicate membership
2. `get_thread_infos` was checking an array key's existence without using `isset`
3. `get_thread_infos` was filtering out any anonymous users from the member list |
129,187 | 07.11.2017 12:15:37 | 18,000 | b0f42221bffe48d252b205ea699a1cf1089eb0c2 | Create RelativeMemberInfo and pipe it through to ThreadSettingsUser
Also include anonymous users in `userIDsToRelativeUserInfos`, and add PropTypes to `ThreadSettingsUser`. | [
{
"change_type": "MODIFY",
"old_path": "lib/selectors/user-selectors.js",
"new_path": "lib/selectors/user-selectors.js",
"diff": "import type { BaseAppState } from '../types/redux-types';\nimport type { UserInfo, RelativeUserInfo } from '../types/user-types';\n-import type { MemberInfo } from '../types/thread-types';\n+import type { MemberInfo, RelativeMemberInfo } from '../types/thread-types';\nimport { createSelector } from 'reselect';\nimport _memoize from 'lodash/memoize';\n@@ -10,6 +10,8 @@ import _keys from 'lodash/keys';\nimport SearchIndex from '../shared/search-index';\n+// Used for specific message payloads that include an array of user IDs, ie.\n+// array of initial users, array of added users\nfunction userIDsToRelativeUserInfos(\nuserIDs: string[],\nviewerID: ?string,\n@@ -17,19 +19,19 @@ function userIDsToRelativeUserInfos(\n): RelativeUserInfo[] {\nconst relativeUserInfos = [];\nfor (let userID of userIDs) {\n- if (!userInfos[userID]) {\n- continue;\n- }\n+ const username = userInfos[userID]\n+ ? userInfos[userID].username\n+ : null;\nif (userID === viewerID) {\nrelativeUserInfos.unshift({\nid: userID,\n- username: userInfos[userID].username,\n+ username,\nisViewer: true,\n});\n} else {\nrelativeUserInfos.push({\nid: userID,\n- username: userInfos[userID].username,\n+ username,\nisViewer: false,\n});\n}\n@@ -38,35 +40,45 @@ function userIDsToRelativeUserInfos(\n}\n// Includes current user at the start\n-const baseRelativeUserInfoSelectorForMembersOfThread = (threadID: string) =>\n+const baseRelativeMemberInfoSelectorForMembersOfThread = (threadID: string) =>\ncreateSelector(\n(state: BaseAppState) => state.threadInfos[threadID].members,\n(state: BaseAppState) => state.currentUserInfo && state.currentUserInfo.id,\n(state: BaseAppState) => state.userInfos,\n(\n- members: MemberInfo[],\n+ memberInfos: MemberInfo[],\ncurrentUserID: ?string,\nuserInfos: {[id: string]: UserInfo},\n- ): RelativeUserInfo[] => {\n- const relativeUserInfos = userIDsToRelativeUserInfos(\n- members.map(memberInfo => memberInfo.id),\n- currentUserID,\n- userInfos,\n- );\n- const orderedRelativeUserInfos = [];\n- for (let relativeUserInfo of relativeUserInfos) {\n- if (relativeUserInfo.isViewer) {\n- orderedRelativeUserInfos.unshift(relativeUserInfo);\n+ ): RelativeMemberInfo[] => {\n+ const relativeMemberInfos = [];\n+ for (let memberInfo of memberInfos) {\n+ const username = userInfos[memberInfo.id]\n+ ? userInfos[memberInfo.id].username\n+ : null;\n+ if (memberInfo.id === currentUserID) {\n+ relativeMemberInfos.unshift({\n+ id: memberInfo.id,\n+ role: memberInfo.role,\n+ permissions: memberInfo.permissions,\n+ username,\n+ isViewer: true,\n+ });\n} else {\n- orderedRelativeUserInfos.push(relativeUserInfo);\n+ relativeMemberInfos.push({\n+ id: memberInfo.id,\n+ role: memberInfo.role,\n+ permissions: memberInfo.permissions,\n+ username,\n+ isViewer: false,\n+ });\n}\n}\n- return orderedRelativeUserInfos;\n+ return relativeMemberInfos;\n},\n);\n-const relativeUserInfoSelectorForMembersOfThread = _memoize(\n- baseRelativeUserInfoSelectorForMembersOfThread,\n+const relativeMemberInfoSelectorForMembersOfThread = _memoize(\n+ baseRelativeMemberInfoSelectorForMembersOfThread,\n);\n// If threadID is null, then all users except the logged-in user are returned\n@@ -119,7 +131,7 @@ const userSearchIndexForOtherMembersOfThread = _memoize(\nexport {\nuserIDsToRelativeUserInfos,\n- relativeUserInfoSelectorForMembersOfThread,\n+ relativeMemberInfoSelectorForMembersOfThread,\nuserInfoSelectorForOtherMembersOfThread,\nuserSearchIndexForOtherMembersOfThread,\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/types/thread-types.js",
"new_path": "lib/types/thread-types.js",
"diff": "@@ -114,6 +114,19 @@ export const memberInfoPropType = PropTypes.shape({\npermissions: threadPermissionsBlobPropType.isRequired,\n});\n+export type RelativeMemberInfo = {|\n+ ...MemberInfo,\n+ username: ?string,\n+ isViewer: bool,\n+|};\n+export const relativeMemberInfoPropType = PropTypes.shape({\n+ id: PropTypes.string.isRequired,\n+ role: PropTypes.string,\n+ permissions: threadPermissionsBlobPropType.isRequired,\n+ username: PropTypes.string,\n+ isViewer: PropTypes.bool.isRequired,\n+});\n+\nexport type RoleInfo = {|\nid: string,\nname: string,\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/settings/thread-settings-user.react.js",
"new_path": "native/chat/settings/thread-settings-user.react.js",
"diff": "// @flow\n-import type { ThreadInfo } from 'lib/types/thread-types';\n-import { threadPermissions } from 'lib/types/thread-types';\n+import type { ThreadInfo, RelativeMemberInfo } from 'lib/types/thread-types';\n+import {\n+ threadInfoPropType,\n+ threadPermissions,\n+ relativeMemberInfoPropType,\n+} from 'lib/types/thread-types';\nimport React from 'react';\nimport { View, Text, StyleSheet, Platform } from 'react-native';\nimport Icon from 'react-native-vector-icons/FontAwesome';\n+import PropTypes from 'prop-types';\nimport { threadHasPermission } from 'lib/shared/thread-utils';\n@@ -14,16 +19,17 @@ import Button from '../../components/button.react';\nimport PopoverTooltip from '../../components/popover-tooltip.react';\ntype Props = {|\n- userInfo: {|\n- id: string,\n- username: string,\n- isViewer: bool,\n- |},\n+ memberInfo: RelativeMemberInfo,\nthreadInfo: ThreadInfo,\ncanEdit: bool,\n|};\nclass ThreadSettingsUser extends React.PureComponent<Props> {\n+ static propTypes = {\n+ memberInfo: relativeMemberInfoPropType.isRequired,\n+ threadInfo: threadInfoPropType.isRequired,\n+ canEdit: PropTypes.bool.isRequired,\n+ };\npopoverConfig: $ReadOnlyArray<{ label: string, onPress: () => void }>;\nconstructor(props: Props) {\n@@ -39,7 +45,7 @@ class ThreadSettingsUser extends React.PureComponent<Props> {\nthis.props.threadInfo,\nthreadPermissions.EDIT_THREAD,\n);\n- const canChange = !this.props.userInfo.isViewer && canEditThread;\n+ const canChange = !this.props.memberInfo.isViewer && canEditThread;\nlet editButton = null;\nif (canChange && this.props.canEdit) {\neditButton = (\n@@ -53,7 +59,7 @@ class ThreadSettingsUser extends React.PureComponent<Props> {\nreturn (\n<View style={styles.container}>\n<Text style={styles.username} numberOfLines={1}>\n- {this.props.userInfo.username}\n+ {this.props.memberInfo.username}\n</Text>\n{editButton}\n</View>\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/settings/thread-settings.react.js",
"new_path": "native/chat/settings/thread-settings.react.js",
"diff": "@@ -4,11 +4,13 @@ import type {\nNavigationScreenProp,\nNavigationRoute,\n} from 'react-navigation/src/TypeDefinition';\n-import type { ThreadInfo } from 'lib/types/thread-types';\n-import { threadInfoPropType, threadPermissions } from 'lib/types/thread-types';\n+import type { ThreadInfo, RelativeMemberInfo } from 'lib/types/thread-types';\n+import {\n+ threadInfoPropType,\n+ threadPermissions,\n+ relativeMemberInfoPropType,\n+} from 'lib/types/thread-types';\nimport type { AppState } from '../../redux-setup';\n-import type { RelativeUserInfo } from 'lib/types/user-types';\n-import { relativeUserInfoPropType } from 'lib/types/user-types';\nimport type { DispatchActionPromise } from 'lib/utils/action-utils';\nimport type { ChangeThreadSettingsResult } from 'lib/actions/thread-actions';\nimport type { LoadingStatus } from 'lib/types/loading-types';\n@@ -34,7 +36,7 @@ import Icon from 'react-native-vector-icons/FontAwesome';\nimport { visibilityRules } from 'lib/types/thread-types';\nimport {\n- relativeUserInfoSelectorForMembersOfThread,\n+ relativeMemberInfoSelectorForMembersOfThread,\n} from 'lib/selectors/user-selectors';\nimport { childThreadInfos } from 'lib/selectors/thread-selectors';\nimport { createLoadingStatusSelector } from 'lib/selectors/loading-selectors';\n@@ -72,7 +74,7 @@ type Props = {|\n// Redux state\nthreadInfo: ThreadInfo,\nparentThreadInfo: ?ThreadInfo,\n- threadMembers: RelativeUserInfo[],\n+ threadMembers: RelativeMemberInfo[],\nchildThreadInfos: ?ThreadInfo[],\nnameEditLoadingStatus: LoadingStatus,\ncolorEditLoadingStatus: LoadingStatus,\n@@ -113,7 +115,7 @@ class InnerThreadSettings extends React.PureComponent<Props, State> {\n}).isRequired,\nthreadInfo: threadInfoPropType.isRequired,\nparentThreadInfo: threadInfoPropType,\n- threadMembers: PropTypes.arrayOf(relativeUserInfoPropType).isRequired,\n+ threadMembers: PropTypes.arrayOf(relativeMemberInfoPropType).isRequired,\nchildThreadInfos: PropTypes.arrayOf(threadInfoPropType),\nnameEditLoadingStatus: loadingStatusPropType.isRequired,\ncolorEditLoadingStatus: loadingStatusPropType.isRequired,\n@@ -391,25 +393,15 @@ class InnerThreadSettings extends React.PureComponent<Props, State> {\n} else {\nthreadMembers = this.props.threadMembers;\n}\n- const members = threadMembers.map(userInfo => {\n- if (!userInfo.username) {\n- return null;\n- }\n- const userInfoWithUsername = {\n- id: userInfo.id,\n- username: userInfo.username,\n- isViewer: userInfo.isViewer,\n- };\n- return (\n- <View style={styles.itemRow} key={userInfo.id}>\n+ const members = threadMembers.map(memberInfo => (\n+ <View style={styles.itemRow} key={memberInfo.id}>\n<ThreadSettingsUser\n- userInfo={userInfoWithUsername}\n+ memberInfo={memberInfo}\nthreadInfo={this.props.threadInfo}\ncanEdit={canStartEditing}\n/>\n</View>\n- );\n- }).filter(x => x);\n+ ));\nif (seeMoreMembers) {\nmembers.push(seeMoreMembers);\n}\n@@ -916,7 +908,7 @@ const ThreadSettings = connect(\n? state.threadInfos[threadInfo.parentThreadID]\n: null,\nthreadMembers:\n- relativeUserInfoSelectorForMembersOfThread(threadInfo.id)(state),\n+ relativeMemberInfoSelectorForMembersOfThread(threadInfo.id)(state),\nchildThreadInfos: childThreadInfos(state)[threadInfo.id],\nnameEditLoadingStatus: createLoadingStatusSelector(\nchangeThreadSettingsActionTypes,\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Create RelativeMemberInfo and pipe it through to ThreadSettingsUser
Also include anonymous users in `userIDsToRelativeUserInfos`, and add PropTypes to `ThreadSettingsUser`. |
129,187 | 07.11.2017 12:17:26 | 18,000 | 9631023545b7afa3d13535292b4b0cdff58431da | Show anonymous users correctly in ThreadSettingsUser
Also moved `stringForUser` to new file message-utils.js | [
{
"change_type": "MODIFY",
"old_path": "lib/shared/message-utils.js",
"new_path": "lib/shared/message-utils.js",
"diff": "@@ -30,16 +30,6 @@ function messageID(messageInfo: MessageInfo | RawMessageInfo): string {\nreturn messageInfo.localID;\n}\n-function stringForUser(user: RelativeUserInfo): string {\n- if (user.isViewer) {\n- return \"you\";\n- } else if (user.username) {\n- return user.username;\n- } else {\n- return \"anonymous\";\n- }\n-}\n-\nfunction robotextForUser(user: RelativeUserInfo): string {\nif (user.isViewer) {\nreturn \"you\";\n@@ -115,7 +105,6 @@ function robotextToRawString(robotext: string): string {\nexport {\nmessageKey,\nmessageID,\n- stringForUser,\nrobotextForMessageInfo,\nrobotextToRawString,\n};\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "lib/shared/user-utils.js",
"diff": "+// @flow\n+\n+import type { RelativeUserInfo } from '../types/user-types';\n+import type { RelativeMemberInfo } from '../types/thread-types';\n+\n+function stringForUser(user: RelativeUserInfo | RelativeMemberInfo): string {\n+ if (user.isViewer) {\n+ return \"you\";\n+ } else if (user.username) {\n+ return user.username;\n+ } else {\n+ return \"anonymous\";\n+ }\n+}\n+\n+export {\n+ stringForUser,\n+};\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/settings/thread-settings-user.react.js",
"new_path": "native/chat/settings/thread-settings-user.react.js",
"diff": "@@ -13,6 +13,7 @@ import Icon from 'react-native-vector-icons/FontAwesome';\nimport PropTypes from 'prop-types';\nimport { threadHasPermission } from 'lib/shared/thread-utils';\n+import { stringForUser } from 'lib/shared/user-utils';\nimport EditSettingButton from './edit-setting-button.react';\nimport Button from '../../components/button.react';\n@@ -41,6 +42,20 @@ class ThreadSettingsUser extends React.PureComponent<Props> {\n}\nrender() {\n+ const userText = stringForUser(this.props.memberInfo);\n+ let userInfo = null;\n+ if (this.props.memberInfo.username) {\n+ userInfo = (\n+ <Text style={styles.username} numberOfLines={1}>{userText}</Text>\n+ );\n+ } else {\n+ userInfo = (\n+ <Text style={[styles.username, styles.anonymous]} numberOfLines={1}>\n+ {userText}\n+ </Text>\n+ );\n+ }\n+\nconst canEditThread = threadHasPermission(\nthis.props.threadInfo,\nthreadPermissions.EDIT_THREAD,\n@@ -56,11 +71,10 @@ class ThreadSettingsUser extends React.PureComponent<Props> {\n/>\n);\n}\n+\nreturn (\n<View style={styles.container}>\n- <Text style={styles.username} numberOfLines={1}>\n- {this.props.memberInfo.username}\n- </Text>\n+ {userInfo}\n{editButton}\n</View>\n);\n@@ -86,6 +100,10 @@ const styles = StyleSheet.create({\nfontSize: 16,\ncolor: \"#333333\",\n},\n+ anonymous: {\n+ fontStyle: 'italic',\n+ color: \"#888888\",\n+ },\neditIcon: {\nlineHeight: 20,\npaddingLeft: 10,\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/text-message.react.js",
"new_path": "native/chat/text-message.react.js",
"diff": "@@ -18,7 +18,8 @@ import PropTypes from 'prop-types';\nimport Color from 'color';\nimport { colorIsDark } from 'lib/shared/thread-utils';\n-import { messageKey, stringForUser } from 'lib/shared/message-utils';\n+import { messageKey } from 'lib/shared/message-utils';\n+import { stringForUser } from 'lib/shared/user-utils';\nimport { messageType } from 'lib/types/message-types';\nfunction textMessageItemHeight(\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Show anonymous users correctly in ThreadSettingsUser
Also moved `stringForUser` to new file message-utils.js |
129,187 | 07.11.2017 12:45:05 | 18,000 | 00a63134ec0cc1f3a46f824f986a0a85236f51dc | Fix three bugs in new_thead.php
1. Extraneous comma at end of function args causing syntax error
2. Order of users inconsistent with `get_thread_infos` result
3. Incorrect definition of `$current_user_info['role']` led to it always being `null` | [
{
"change_type": "MODIFY",
"old_path": "server/new_thread.php",
"new_path": "server/new_thread.php",
"diff": "@@ -136,7 +136,7 @@ if ($new_message_infos === null) {\n$creator_results = change_roletype(\n$id,\narray($creator),\n- (int)$roletypes['admins']['id'],\n+ (int)$roletypes['admins']['id']\n);\nif (!$creator_results) {\nasync_end(array(\n@@ -174,11 +174,11 @@ foreach ($to_save as $row_to_save) {\n),\n\"role\" => (string)$row_to_save['roletype'],\n);\n- $members[] = $member;\n+ array_unshift($members, $member);\nif ($row_to_save['user_id'] === $creator) {\n$current_user_info = array(\n\"permissions\" => $member['permissions'],\n- \"role\" => $member['roletype'],\n+ \"role\" => $member['role'],\n\"subscribed\" => true,\n);\n}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Fix three bugs in new_thead.php
1. Extraneous comma at end of function args causing syntax error
2. Order of users inconsistent with `get_thread_infos` result
3. Incorrect definition of `$current_user_info['role']` led to it always being `null` |
129,187 | 07.11.2017 12:46:19 | 18,000 | c93e220edde960c8a85240c3ab6d8f50c9b332fd | Use keyed object for roles in ThreadInfo instead of array | [
{
"change_type": "MODIFY",
"old_path": "lib/types/thread-types.js",
"new_path": "lib/types/thread-types.js",
"diff": "@@ -151,7 +151,7 @@ export type ThreadInfo = {|\ncreationTime: number, // millisecond timestamp\nparentThreadID: ?string,\nmembers: MemberInfo[],\n- roles: RoleInfo[],\n+ roles: {[id: string]: RoleInfo},\ncurrentUser: ThreadCurrentUserInfo,\n|};\n@@ -171,7 +171,7 @@ export const threadInfoPropType = PropTypes.shape({\ncreationTime: PropTypes.number.isRequired,\nparentThreadID: PropTypes.string,\nmembers: PropTypes.arrayOf(memberInfoPropType).isRequired,\n- roles: PropTypes.arrayOf(PropTypes.shape({\n+ roles: PropTypes.objectOf(PropTypes.shape({\nid: PropTypes.string.isRequired,\nname: PropTypes.string.isRequired,\npermissions: PropTypes.objectOf(PropTypes.bool).isRequired,\n"
},
{
"change_type": "MODIFY",
"old_path": "server/new_thread.php",
"new_path": "server/new_thread.php",
"diff": "@@ -202,7 +202,10 @@ async_end(array(\n? (string)$parent_thread_id\n: null,\n'members' => $members,\n- 'roles' => array_values($roletypes),\n+ 'roles' => array(\n+ $roletypes['members']['id'] => $roletypes['members'],\n+ $roletypes['admins']['id'] => $roletypes['admins'],\n+ ),\n'currentUser' => $current_user_info,\n),\n'new_message_infos' => $new_message_infos,\n"
},
{
"change_type": "MODIFY",
"old_path": "server/thread_lib.php",
"new_path": "server/thread_lib.php",
"diff": "@@ -97,7 +97,6 @@ SQL;\n$final_thread_infos = array();\nforeach ($thread_infos as $thread_id => $thread_info) {\n- $thread_info['roles'] = array_values($thread_info['roles']);\nif ($thread_info['currentUser'] === null) {\n$all_permissions = get_all_thread_permissions(\narray(\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Use keyed object for roles in ThreadInfo instead of array |
129,187 | 07.11.2017 12:52:48 | 18,000 | 1f68022accc02d5f5bd63a47b1d07c7e9edd226e | Show which users are admins in ThreadSettings | [
{
"change_type": "MODIFY",
"old_path": "native/chat/settings/thread-settings-user.react.js",
"new_path": "native/chat/settings/thread-settings-user.react.js",
"diff": "@@ -72,11 +72,25 @@ class ThreadSettingsUser extends React.PureComponent<Props> {\n);\n}\n+ let roleInfo = null;\n+ const role = this.props.memberInfo.role &&\n+ this.props.threadInfo.roles[this.props.memberInfo.role];\n+ if (role && role.name === \"Admins\") {\n+ roleInfo = (\n+ <View style={styles.row}>\n+ <Text style={styles.role}>admin</Text>\n+ </View>\n+ );\n+ }\n+\nreturn (\n<View style={styles.container}>\n+ <View style={styles.row}>\n{userInfo}\n{editButton}\n</View>\n+ {roleInfo}\n+ </View>\n);\n}\n@@ -91,10 +105,13 @@ class ThreadSettingsUser extends React.PureComponent<Props> {\nconst styles = StyleSheet.create({\ncontainer: {\nflex: 1,\n- flexDirection: 'row',\npaddingVertical: 8,\npaddingHorizontal: 12,\n},\n+ row: {\n+ flex: 1,\n+ flexDirection: 'row',\n+ },\nusername: {\nflex: 1,\nfontSize: 16,\n@@ -114,6 +131,12 @@ const styles = StyleSheet.create({\ntextAlign: 'center',\ncolor: '#444',\n},\n+ role: {\n+ flex: 1,\n+ fontSize: 14,\n+ color: \"#888888\",\n+ paddingTop: 4,\n+ },\n});\nconst icon = (\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Show which users are admins in ThreadSettings |
129,187 | 07.11.2017 13:07:27 | 18,000 | 8e877deee30f29c4f4859d8a43c32ee36d6f1aa8 | Generate popoverConfig for ThreadSettingsUser based on props | [
{
"change_type": "MODIFY",
"old_path": "native/chat/settings/thread-settings-user.react.js",
"new_path": "native/chat/settings/thread-settings-user.react.js",
"diff": "@@ -11,6 +11,7 @@ import React from 'react';\nimport { View, Text, StyleSheet, Platform } from 'react-native';\nimport Icon from 'react-native-vector-icons/FontAwesome';\nimport PropTypes from 'prop-types';\n+import _isEqual from 'lodash/fp/isEqual';\nimport { threadHasPermission } from 'lib/shared/thread-utils';\nimport { stringForUser } from 'lib/shared/user-utils';\n@@ -24,21 +25,55 @@ type Props = {|\nthreadInfo: ThreadInfo,\ncanEdit: bool,\n|};\n-class ThreadSettingsUser extends React.PureComponent<Props> {\n+type State = {|\n+ popoverConfig: $ReadOnlyArray<{ label: string, onPress: () => void }>,\n+|};\n+class ThreadSettingsUser extends React.PureComponent<Props, State> {\nstatic propTypes = {\nmemberInfo: relativeMemberInfoPropType.isRequired,\nthreadInfo: threadInfoPropType.isRequired,\ncanEdit: PropTypes.bool.isRequired,\n};\n- popoverConfig: $ReadOnlyArray<{ label: string, onPress: () => void }>;\n+\n+ static memberIsAdmin(props: Props) {\n+ const role = props.memberInfo.role &&\n+ props.threadInfo.roles[props.memberInfo.role];\n+ return role && role.name === \"Admins\";\n+ }\n+\n+ generatePopoverConfig(props: Props) {\n+ // TODO check correct permissions\n+ const canEditThread = threadHasPermission(\n+ props.threadInfo,\n+ threadPermissions.EDIT_THREAD,\n+ );\n+ if (!canEditThread || !props.canEdit) {\n+ return [];\n+ }\n+ const result = [];\n+ if (!props.memberInfo.isViewer) {\n+ result.push({ label: \"Remove user\", onPress: this.onPressRemoveUser });\n+ }\n+ const adminText = ThreadSettingsUser.memberIsAdmin(props)\n+ ? \"Remove admin\"\n+ : \"Make admin\";\n+ result.push({ label: adminText, onPress: this.onPressMakeAdmin });\n+ return result;\n+ }\nconstructor(props: Props) {\nsuper(props);\n- this.popoverConfig = [\n- { label: \"Remove user\", onPress: this.onPressRemoveUser },\n- { label: \"Make admin\", onPress: this.onPressMakeAdmin },\n- ];\n+ this.state = {\n+ popoverConfig: this.generatePopoverConfig(props),\n+ };\n+ }\n+\n+ componentWillReceiveProps(nextProps: Props) {\n+ const nextPopoverConfig = this.generatePopoverConfig(nextProps);\n+ if (!_isEqual(this.state.popoverConfig)(nextPopoverConfig)) {\n+ this.setState({ popoverConfig: nextPopoverConfig });\n+ }\n}\nrender() {\n@@ -56,26 +91,19 @@ class ThreadSettingsUser extends React.PureComponent<Props> {\n);\n}\n- const canEditThread = threadHasPermission(\n- this.props.threadInfo,\n- threadPermissions.EDIT_THREAD,\n- );\n- const canChange = !this.props.memberInfo.isViewer && canEditThread;\nlet editButton = null;\n- if (canChange && this.props.canEdit) {\n+ if (this.state.popoverConfig.length !== 0) {\neditButton = (\n<PopoverTooltip\nbuttonComponent={icon}\n- items={this.popoverConfig}\n+ items={this.state.popoverConfig}\nlabelStyle={styles.popoverLabelStyle}\n/>\n);\n}\nlet roleInfo = null;\n- const role = this.props.memberInfo.role &&\n- this.props.threadInfo.roles[this.props.memberInfo.role];\n- if (role && role.name === \"Admins\") {\n+ if (ThreadSettingsUser.memberIsAdmin(this.props)) {\nroleInfo = (\n<View style={styles.row}>\n<Text style={styles.role}>admin</Text>\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Generate popoverConfig for ThreadSettingsUser based on props |
129,187 | 07.11.2017 14:31:42 | 18,000 | 9e828a0bb72f200d961080a0a9ca2f99ea0bc964 | Include isDefault in RoleInfo | [
{
"change_type": "MODIFY",
"old_path": "lib/types/thread-types.js",
"new_path": "lib/types/thread-types.js",
"diff": "@@ -133,6 +133,7 @@ export type RoleInfo = {|\n// This is not a ThreadPermissionsBlob. It can include keys with prefixes, and\n// no sources are listed, as this blob is itself a self-contained source.\npermissions: {| [permission: string]: bool |},\n+ isDefault: bool,\n|};\nexport type ThreadCurrentUserInfo = {|\n@@ -175,6 +176,7 @@ export const threadInfoPropType = PropTypes.shape({\nid: PropTypes.string.isRequired,\nname: PropTypes.string.isRequired,\npermissions: PropTypes.objectOf(PropTypes.bool).isRequired,\n+ isDefault: PropTypes.bool.isRequired,\n})),\ncurrentUser: PropTypes.shape({\nrole: PropTypes.string,\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/settings/thread-settings-user.react.js",
"new_path": "native/chat/settings/thread-settings-user.react.js",
"diff": "@@ -39,7 +39,7 @@ class ThreadSettingsUser extends React.PureComponent<Props, State> {\nstatic memberIsAdmin(props: Props) {\nconst role = props.memberInfo.role &&\nprops.threadInfo.roles[props.memberInfo.role];\n- return role && role.name === \"Admins\";\n+ return role && !role.isDefault && role.name === \"Admins\";\n}\ngeneratePopoverConfig(props: Props) {\n"
},
{
"change_type": "MODIFY",
"old_path": "server/permissions.php",
"new_path": "server/permissions.php",
"diff": "@@ -824,11 +824,13 @@ SQL;\n\"id\" => (string)$member_roletype_id,\n\"name\" => \"Members\",\n\"permissions\" => $member_permissions,\n+ \"isDefault\" => true,\n),\n\"admins\" => array(\n\"id\" => (string)$admin_roletype_id,\n\"name\" => \"Admins\",\n\"permissions\" => $admin_permissions,\n+ \"isDefault\" => false,\n),\n);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "server/thread_lib.php",
"new_path": "server/thread_lib.php",
"diff": "@@ -24,7 +24,7 @@ function get_thread_infos($specific_condition=\"\") {\n$query = <<<SQL\nSELECT t.id, t.name, t.parent_thread_id, t.color, t.description, t.edit_rules,\n- t.visibility_rules, t.creation_time, rt.id AS roletype,\n+ t.visibility_rules, t.creation_time, t.default_roletype, rt.id AS roletype,\nrt.name AS roletype_name, rt.permissions AS roletype_permissions, r.user,\nr.permissions, r.subscribed, u.username\nFROM threads t\n@@ -66,6 +66,7 @@ SQL;\n\"id\" => $row['roletype'],\n\"name\" => $row['roletype_name'],\n\"permissions\" => $roletype_permissions,\n+ \"isDefault\" => $row['roletype'] === $row['default_roletype'],\n);\n}\nif ($row['user'] !== null) {\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Include isDefault in RoleInfo |
129,187 | 07.11.2017 15:51:01 | 18,000 | 35423222513b5368d3a034af3598ab76bfd5417b | Add REMOVE_MEMBERS and CHANGE_ROLE permissions | [
{
"change_type": "MODIFY",
"old_path": "lib/types/thread-types.js",
"new_path": "lib/types/thread-types.js",
"diff": "@@ -52,7 +52,9 @@ export type ThreadPermission =\n| \"create_subthreads\"\n| \"join_thread\"\n| \"edit_permissions\"\n- | \"add_members\";\n+ | \"add_members\"\n+ | \"remove_members\"\n+ | \"change_role\";\nexport const threadPermissions = {\nKNOW_OF: \"know_of\",\nVISIBLE: \"visible\",\n@@ -64,6 +66,8 @@ export const threadPermissions = {\nJOIN_THREAD: \"join_thread\",\nEDIT_PERMISSIONS: \"edit_permissions\",\nADD_MEMBERS: \"add_members\",\n+ REMOVE_MEMBERS: \"remove_members\",\n+ CHANGE_ROLE: \"change_role\",\n};\nexport function assertThreadPermissions(\nourThreadPermissions: string,\n@@ -78,7 +82,9 @@ export function assertThreadPermissions(\nourThreadPermissions === \"create_subthreads\" ||\nourThreadPermissions === \"join_thread\" ||\nourThreadPermissions === \"edit_permissions\" ||\n- ourThreadPermissions === \"add_members\",\n+ ourThreadPermissions === \"add_members\" ||\n+ ourThreadPermissions === \"remove_members\" ||\n+ ourThreadPermissions === \"change_role\",\n\"string is not threadPermissions enum\",\n);\nreturn ourThreadPermissions;\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/settings/thread-settings-user.react.js",
"new_path": "native/chat/settings/thread-settings-user.react.js",
"diff": "@@ -43,22 +43,42 @@ class ThreadSettingsUser extends React.PureComponent<Props, State> {\n}\ngeneratePopoverConfig(props: Props) {\n- // TODO check correct permissions\n- const canEditThread = threadHasPermission(\n- props.threadInfo,\n- threadPermissions.EDIT_THREAD,\n- );\n- if (!canEditThread || !props.canEdit) {\n+ const role = props.memberInfo.role;\n+ if (!props.canEdit || !role) {\nreturn [];\n}\n+\n+ const canRemoveMembers = threadHasPermission(\n+ props.threadInfo,\n+ threadPermissions.REMOVE_MEMBERS,\n+ );\n+ const canChangeRoles = threadHasPermission(\n+ props.threadInfo,\n+ threadPermissions.CHANGE_ROLE,\n+ );\n+\nconst result = [];\n- if (!props.memberInfo.isViewer) {\n+ if (\n+ canRemoveMembers &&\n+ !props.memberInfo.isViewer &&\n+ (\n+ canChangeRoles ||\n+ (\n+ props.threadInfo.roles[role] &&\n+ props.threadInfo.roles[role].isDefault\n+ )\n+ )\n+ ) {\nresult.push({ label: \"Remove user\", onPress: this.onPressRemoveUser });\n}\n+\n+ if (canChangeRoles) {\nconst adminText = ThreadSettingsUser.memberIsAdmin(props)\n? \"Remove admin\"\n: \"Make admin\";\nresult.push({ label: adminText, onPress: this.onPressMakeAdmin });\n+ }\n+\nreturn result;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "server/permissions.php",
"new_path": "server/permissions.php",
"diff": "@@ -26,6 +26,12 @@ define(\"PERMISSION_JOIN_THREAD\", \"join_thread\");\ndefine(\"PERMISSION_EDIT_PERMISSIONS\", \"edit_permissions\");\n// If the user can add new members to this thread\ndefine(\"PERMISSION_ADD_MEMBERS\", \"add_members\");\n+// If the user can remove members from this thread. If the members in question\n+// have a non-default roletype, PERMISSION_CHANGE_ROLE is also needed.\n+define(\"PERMISSION_REMOVE_MEMBERS\", \"remove_members\");\n+// If the user can change the role of any other member in the thread. This is\n+// probably the most powerful permission.\n+define(\"PERMISSION_CHANGE_ROLE\", \"change_role\");\n$all_thread_permissions = array(\nPERMISSION_KNOW_OF,\n@@ -38,6 +44,8 @@ $all_thread_permissions = array(\nPERMISSION_JOIN_THREAD,\nPERMISSION_EDIT_PERMISSIONS,\nPERMISSION_ADD_MEMBERS,\n+ PERMISSION_REMOVE_MEMBERS,\n+ PERMISSION_CHANGE_ROLE,\n);\ndefine(\"PERMISSION_PREFIX_DESCENDANT\", \"descendant_\");\n@@ -790,6 +798,8 @@ function create_initial_roletypes_for_new_thread($thread_id) {\nPERMISSION_ADD_MEMBERS => true,\nPERMISSION_DELETE_THREAD => true,\nPERMISSION_EDIT_PERMISSIONS => true,\n+ PERMISSION_REMOVE_MEMBERS => true,\n+ PERMISSION_CHANGE_ROLE => true,\nPERMISSION_PREFIX_DESCENDANT . PERMISSION_KNOW_OF => true,\nPERMISSION_PREFIX_DESCENDANT . PERMISSION_VISIBLE => true,\nPERMISSION_PREFIX_DESCENDANT . PERMISSION_JOIN_THREAD => true,\n@@ -800,6 +810,8 @@ function create_initial_roletypes_for_new_thread($thread_id) {\nPERMISSION_PREFIX_DESCENDANT . PERMISSION_ADD_MEMBERS => true,\nPERMISSION_PREFIX_DESCENDANT . PERMISSION_DELETE_THREAD => true,\nPERMISSION_PREFIX_DESCENDANT . PERMISSION_EDIT_PERMISSIONS => true,\n+ PERMISSION_PREFIX_DESCENDANT . PERMISSION_REMOVE_MEMBERS => true,\n+ PERMISSION_PREFIX_DESCENDANT . PERMISSION_CHANGE_ROLE => true,\n);\n$encoded_member_permissions = $conn->real_escape_string(json_encode(\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Add REMOVE_MEMBERS and CHANGE_ROLE permissions |
129,187 | 07.11.2017 15:57:23 | 18,000 | 8211e868a90e0cd517eb1aa443b812cfc5065728 | List parent admins in ThreadSettings | [
{
"change_type": "MODIFY",
"old_path": "native/chat/settings/thread-settings-user.react.js",
"new_path": "native/chat/settings/thread-settings-user.react.js",
"diff": "@@ -129,6 +129,22 @@ class ThreadSettingsUser extends React.PureComponent<Props, State> {\n<Text style={styles.role}>admin</Text>\n</View>\n);\n+ } else {\n+ // In the future, when we might have more than two roles per threads, we\n+ // will need something more sophisticated here. For now, if the user isn't\n+ // an admin and yet has the CHANGE_ROLE permissions, we know that they are\n+ // an admin of an ancestor of this thread.\n+ const canChangeRoles = threadHasPermission(\n+ this.props.threadInfo,\n+ threadPermissions.CHANGE_ROLE,\n+ );\n+ if (canChangeRoles) {\n+ roleInfo = (\n+ <View style={styles.row}>\n+ <Text style={styles.role}>parent admin</Text>\n+ </View>\n+ );\n+ }\n}\nreturn (\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | List parent admins in ThreadSettings |
129,187 | 08.11.2017 14:10:42 | 18,000 | 198ac14498ddb4104275bf2af8066701bfaf9aec | edit_roletype_permissions and script to add new permission types | [
{
"change_type": "MODIFY",
"old_path": "server/permissions.php",
"new_path": "server/permissions.php",
"diff": "@@ -525,7 +525,10 @@ SQL;\n// to_save => array<array(\n// user_id: int,\n// thread_id: int,\n-// permissions: array<permission: string, array(value => bool, source => int)>\n+// permissions: array<\n+// permission: string,\n+// array(value => bool, source => int),\n+// >,\n// permissions_for_children:\n// ?array<permission: string, array(value => bool, source => int)>\n// roletype: int,\n@@ -669,6 +672,126 @@ SQL;\nreturn array(\"to_save\" => $to_save, \"to_delete\" => $to_delete);\n}\n+// $roletype: int\n+// cannot be zero or null!\n+// $changed_roletype_permissions:\n+// array<permission: string, bool>\n+// returns: (null if failed)\n+// ?array(\n+// to_save => array<array(\n+// user_id: int,\n+// thread_id: int,\n+// permissions: array<\n+// permission: string,\n+// array(value => bool, source => int),\n+// >,\n+// permissions_for_children:\n+// ?array<permission: string, array(value => bool, source => int)>\n+// roletype: int,\n+// )>,\n+// to_delete: array<array(user_id: int, thread_id: int)>,\n+// )\n+function edit_roletype_permissions($roletype, $changed_roletype_permissions) {\n+ global $conn;\n+\n+ $roletype = (int)$roletype;\n+ if ($roletype === 0) {\n+ return null;\n+ }\n+\n+ $query = <<<SQL\n+SELECT rt.thread, rt.permissions, t.visibility_rules\n+FROM roletypes rt\n+LEFT JOIN threads t ON t.id = rt.thread\n+WHERE rt.id = {$roletype}\n+SQL;\n+ $result = $conn->query($query);\n+ $row = $result->fetch_assoc();\n+ if (!$row) {\n+ return null;\n+ }\n+ $thread_id = (int)$row['thread'];\n+ $vis_rules = (int)$row['visibility_rules'];\n+ $new_roletype_permissions = array_filter(array_merge(\n+ json_decode($row['permissions'], true),\n+ $changed_roletype_permissions\n+ ));\n+\n+ $encoded_roletype_permissions =\n+ $conn->real_escape_string(json_encode($new_roletype_permissions));\n+ $query = <<<SQL\n+UPDATE roletypes\n+SET permissions = '{$encoded_roletype_permissions}'\n+WHERE id = {$roletype}\n+SQL;\n+ $conn->query($query);\n+\n+ $query = <<<SQL\n+SELECT r.user, r.permissions, r.permissions_for_children,\n+ pr.permissions_for_children AS permissions_from_parent\n+FROM roles r\n+LEFT JOIN threads t ON t.id = r.thread\n+LEFT JOIN roles pr ON pr.thread = t.parent_thread_id AND pr.user = r.user\n+WHERE r.roletype = {$roletype}\n+SQL;\n+ $result = $conn->query($query);\n+\n+ $to_save = array();\n+ $to_delete = array();\n+ $to_update_descendants = array();\n+ while ($row = $result->fetch_assoc()) {\n+ $user_id = (int)$row['user'];\n+ $permissions_from_parent = $row['permissions_from_parent']\n+ ? json_decode($row['permissions_from_parent'], true)\n+ : null;\n+ $old_permissions = json_decode($row['permissions'], true);\n+ $old_permissions_for_children = $row['permissions_for_children']\n+ ? json_decode($row['permissions_for_children'], true)\n+ : null;\n+\n+ $permissions = make_permissions_blob(\n+ $new_roletype_permissions,\n+ $permissions_from_parent,\n+ $thread_id,\n+ $vis_rules\n+ );\n+ if ($permissions == $old_permissions) {\n+ // This thread and all of its children need no updates, since its\n+ // permissions are unchanged by this operation\n+ continue;\n+ }\n+\n+ $permissions_for_children = permissions_for_children($permissions);\n+ if ($permissions !== null) {\n+ $to_save[] = array(\n+ \"user_id\" => $user_id,\n+ \"thread_id\" => $thread_id,\n+ \"permissions\" => $permissions,\n+ \"permissions_for_children\" => $permissions_for_children,\n+ \"roletype\" => $roletype,\n+ );\n+ } else {\n+ $to_delete[] = array(\n+ \"user_id\" => $user_id,\n+ \"thread_id\" => $thread_id,\n+ );\n+ }\n+\n+ if ($permissions_for_children != $old_permissions_for_children) {\n+ $to_update_descendants[$user_id] = $permissions_for_children;\n+ }\n+ }\n+\n+ if ($to_update_descendants) {\n+ $descendant_results =\n+ update_descendant_permissions($thread_id, $to_update_descendants);\n+ $to_save = array_merge($to_save, $descendant_results['to_save']);\n+ $to_delete = array_merge($to_delete, $descendant_results['to_delete']);\n+ }\n+\n+ return array(\"to_save\" => $to_save, \"to_delete\" => $to_delete);\n+}\n+\n// $thread_id: int\n// $new_vis_rules: int\n// note: doesn't check if the new value is different from the old value\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "server/scripts/add_permission_types.php",
"diff": "+<?php\n+\n+require_once('../config.php');\n+require_once('../permissions.php');\n+\n+echo \"Querying for thread family tree...\\n\";\n+\n+$query = <<<SQL\n+SELECT rt.id, rt.thread, t.parent_thread_id\n+FROM roletypes rt\n+LEFT JOIN threads t ON t.id = rt.thread\n+WHERE rt.name = 'Admins'\n+SQL;\n+$results = $conn->query($query);\n+\n+$parents_to_children = array();\n+$children_to_parents = array();\n+$threads_to_admin_roletype = array();\n+while ($row = $results->fetch_assoc()) {\n+ $roletype = (int)$row['id'];\n+ $thread_id = (int)$row['thread'];\n+ $threads_to_admin_roletype[$thread_id] = $roletype;\n+\n+ if ($row['parent_thread_id']) {\n+ $parent_thread_id = (int)$row['parent_thread_id'];\n+ $children_to_parents[$thread_id] = $parent_thread_id;\n+ if (!isset($parents_to_children[$parent_thread_id])) {\n+ $parents_to_children[$parent_thread_id] = array();\n+ }\n+ $parents_to_children[$parent_thread_id][$thread_id] = $thread_id;\n+ }\n+\n+ if (!isset($parents_to_children[$thread_id])) {\n+ $parents_to_children[$thread_id] = array();\n+ }\n+}\n+echo \"Total thread count: \" . count($parents_to_children) . \"\\n\";\n+\n+$new_permissions = array(\n+ PERMISSION_REMOVE_MEMBERS => true,\n+ PERMISSION_CHANGE_ROLE => true,\n+ PERMISSION_PREFIX_DESCENDANT . PERMISSION_REMOVE_MEMBERS => true,\n+ PERMISSION_PREFIX_DESCENDANT . PERMISSION_CHANGE_ROLE => true,\n+);\n+\n+while ($parents_to_children) {\n+ // Select just the threads whose children have already been processed\n+ $current_threads = array_keys(array_filter(\n+ $parents_to_children,\n+ function($children) { return !$children; }\n+ ));\n+ echo \"This round's leaf nodes: \" . print_r($current_threads, true);\n+\n+ $to_save = array();\n+ $to_delete = array();\n+ foreach ($current_threads as $thread_id) {\n+ $admin_roletype = $threads_to_admin_roletype[$thread_id];\n+ $results = edit_roletype_permissions($admin_roletype, $new_permissions);\n+ $to_save = array_merge($to_save, $results['to_save']);\n+ $to_delete = array_merge($to_delete, $results['to_delete']);\n+ }\n+ save_user_roles($to_save);\n+ delete_user_roles($to_delete);\n+\n+ $parents_to_children = array_filter($parents_to_children);\n+ foreach ($current_threads as $thread_id) {\n+ if (!isset($children_to_parents[$thread_id])) {\n+ continue;\n+ }\n+ $parent_id = $children_to_parents[$thread_id];\n+ unset($parents_to_children[$parent_id][$thread_id]);\n+ }\n+}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | edit_roletype_permissions and script to add new permission types |
129,187 | 08.11.2017 14:27:27 | 18,000 | 020bdd0d8d870a2a19c949c270036bd6679a27fb | Two bugfixes for ThreadSettingsUser
1. Parent admin check was checking current user's permissions instead of listed user
2. It should be impossible to make an anonymous user the admin of a thread | [
{
"change_type": "MODIFY",
"old_path": "native/chat/settings/thread-settings-user.react.js",
"new_path": "native/chat/settings/thread-settings-user.react.js",
"diff": "@@ -72,7 +72,7 @@ class ThreadSettingsUser extends React.PureComponent<Props, State> {\nresult.push({ label: \"Remove user\", onPress: this.onPressRemoveUser });\n}\n- if (canChangeRoles) {\n+ if (canChangeRoles && this.props.memberInfo.username) {\nconst adminText = ThreadSettingsUser.memberIsAdmin(props)\n? \"Remove admin\"\n: \"Make admin\";\n@@ -134,10 +134,9 @@ class ThreadSettingsUser extends React.PureComponent<Props, State> {\n// will need something more sophisticated here. For now, if the user isn't\n// an admin and yet has the CHANGE_ROLE permissions, we know that they are\n// an admin of an ancestor of this thread.\n- const canChangeRoles = threadHasPermission(\n- this.props.threadInfo,\n- threadPermissions.CHANGE_ROLE,\n- );\n+ const canChangeRoles =\n+ this.props.memberInfo.permissions[threadPermissions.CHANGE_ROLE] &&\n+ this.props.memberInfo.permissions[threadPermissions.CHANGE_ROLE].value;\nif (canChangeRoles) {\nroleInfo = (\n<View style={styles.row}>\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Two bugfixes for ThreadSettingsUser
1. Parent admin check was checking current user's permissions instead of listed user
2. It should be impossible to make an anonymous user the admin of a thread |
129,187 | 09.11.2017 14:53:26 | 18,000 | c3977e03c14b757c8091377c46638aa4bd56e379 | Hook up native code for changing users' roles | [
{
"change_type": "MODIFY",
"old_path": "native/chat/settings/thread-settings-user.react.js",
"new_path": "native/chat/settings/thread-settings-user.react.js",
"diff": "@@ -18,6 +18,7 @@ import Icon from 'react-native-vector-icons/FontAwesome';\nimport PropTypes from 'prop-types';\nimport _isEqual from 'lodash/fp/isEqual';\nimport { connect } from 'react-redux';\n+import invariant from 'invariant';\nimport { threadHasPermission } from 'lib/shared/thread-utils';\nimport { stringForUser } from 'lib/shared/user-utils';\n@@ -28,6 +29,8 @@ import {\nimport {\nremoveUsersFromThreadActionTypes,\nremoveUsersFromThread,\n+ changeThreadMemberRolesActionTypes,\n+ changeThreadMemberRoles,\n} from 'lib/actions/thread-actions';\nimport { createLoadingStatusSelector } from 'lib/selectors/loading-selectors';\n@@ -41,6 +44,7 @@ type Props = {|\ncanEdit: bool,\n// Redux state\nremoveUsersLoadingStatus: LoadingStatus,\n+ changeRolesLoadingStatus: LoadingStatus,\n// Redux dispatch functions\ndispatchActionPromise: DispatchActionPromise,\n// async functions that hit server APIs\n@@ -48,6 +52,11 @@ type Props = {|\nthreadID: string,\nuserIDs: string[],\n) => Promise<ChangeThreadSettingsResult>,\n+ changeThreadMemberRoles: (\n+ threadID: string,\n+ userIDs: string[],\n+ newRole: string,\n+ ) => Promise<ChangeThreadSettingsResult>,\n|};\ntype State = {|\npopoverConfig: $ReadOnlyArray<{ label: string, onPress: () => void }>,\n@@ -217,6 +226,55 @@ class ThreadSettingsUser extends React.PureComponent<Props, State> {\n}\nonPressMakeAdmin = () => {\n+ if (Platform.OS === \"ios\") {\n+ // https://github.com/facebook/react-native/issues/10471\n+ setTimeout(this.showMakeAdminConfirmation, 300);\n+ } else {\n+ this.showMakeAdminConfirmation();\n+ }\n+ }\n+\n+ showMakeAdminConfirmation = () => {\n+ const userText = stringForUser(this.props.memberInfo);\n+ const actionClause = ThreadSettingsUser.memberIsAdmin(this.props)\n+ ? `remove ${userText} as an admin`\n+ : `make ${userText} an admin`;\n+ Alert.alert(\n+ \"Confirm action\",\n+ `Are you sure you want to ${actionClause} of this thread?`,\n+ [\n+ { text: 'Cancel', style: 'cancel' },\n+ { text: 'OK', onPress: this.onConfirmMakeAdmin },\n+ ],\n+ );\n+ }\n+\n+ onConfirmMakeAdmin = () => {\n+ const isCurrentlyAdmin = ThreadSettingsUser.memberIsAdmin(this.props);\n+ let newRole = null;\n+ for (let roleID in this.props.threadInfo.roles) {\n+ const role = this.props.threadInfo.roles[roleID];\n+ if (isCurrentlyAdmin && role.isDefault) {\n+ newRole = role.id;\n+ break;\n+ } else if (!isCurrentlyAdmin && role.name === \"Admins\") {\n+ newRole = role.id;\n+ break;\n+ }\n+ }\n+ invariant(newRole !== null, \"Could not find new role\");\n+ this.props.dispatchActionPromise(\n+ changeThreadMemberRolesActionTypes,\n+ this.makeAdmin(newRole),\n+ );\n+ }\n+\n+ async makeAdmin(newRole: string) {\n+ return await this.props.changeThreadMemberRoles(\n+ this.props.threadInfo.id,\n+ [ this.props.memberInfo.id ],\n+ newRole,\n+ );\n}\n}\n@@ -269,12 +327,15 @@ const icon = (\nconst removeUsersLoadingStatusSelector\n= createLoadingStatusSelector(removeUsersFromThreadActionTypes);\n+const changeRolesLoadingStatusSelector\n+ = createLoadingStatusSelector(changeThreadMemberRolesActionTypes);\nexport default connect(\n(state: AppState) => ({\nremoveUsersLoadingStatus: removeUsersLoadingStatusSelector(state),\n+ changeRolesLoadingStatus: changeRolesLoadingStatusSelector(state),\ncookie: state.cookie,\n}),\nincludeDispatchActionProps,\n- bindServerCalls({ removeUsersFromThread }),\n+ bindServerCalls({ removeUsersFromThread, changeThreadMemberRoles }),\n)(ThreadSettingsUser);\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Hook up native code for changing users' roles |
129,187 | 09.11.2017 15:05:09 | 18,000 | b0acf02b613776dff98cb11dd4553353bb9d1d8d | Show loading spinner when removing users and changing their role | [
{
"change_type": "MODIFY",
"old_path": "native/chat/settings/thread-settings-user.react.js",
"new_path": "native/chat/settings/thread-settings-user.react.js",
"diff": "@@ -13,7 +13,14 @@ import type { DispatchActionPromise } from 'lib/utils/action-utils';\nimport type { ChangeThreadSettingsResult } from 'lib/actions/thread-actions';\nimport React from 'react';\n-import { View, Text, StyleSheet, Platform, Alert } from 'react-native';\n+import {\n+ View,\n+ Text,\n+ StyleSheet,\n+ Platform,\n+ Alert,\n+ ActivityIndicator,\n+} from 'react-native';\nimport Icon from 'react-native-vector-icons/FontAwesome';\nimport PropTypes from 'prop-types';\nimport _isEqual from 'lodash/fp/isEqual';\n@@ -145,7 +152,12 @@ class ThreadSettingsUser extends React.PureComponent<Props, State> {\n}\nlet editButton = null;\n- if (this.state.popoverConfig.length !== 0) {\n+ if (\n+ this.props.removeUsersLoadingStatus === \"loading\" ||\n+ this.props.changeRolesLoadingStatus === \"loading\"\n+ ) {\n+ editButton = <ActivityIndicator size=\"small\" />;\n+ } else if (this.state.popoverConfig.length !== 0) {\neditButton = (\n<PopoverTooltip\nbuttonComponent={icon}\n@@ -193,7 +205,7 @@ class ThreadSettingsUser extends React.PureComponent<Props, State> {\nonPressRemoveUser = () => {\nif (Platform.OS === \"ios\") {\n// https://github.com/facebook/react-native/issues/10471\n- setTimeout(this.showRemoveUserConfirmation, 300);\n+ setTimeout(this.showRemoveUserConfirmation, 400);\n} else {\nthis.showRemoveUserConfirmation();\n}\n@@ -212,9 +224,12 @@ class ThreadSettingsUser extends React.PureComponent<Props, State> {\n}\nonConfirmRemoveUser = () => {\n+ const customKeyName = removeUsersFromThreadActionTypes.started +\n+ `:${this.props.memberInfo.id}`;\nthis.props.dispatchActionPromise(\nremoveUsersFromThreadActionTypes,\nthis.removeUser(),\n+ { customKeyName },\n);\n}\n@@ -228,7 +243,7 @@ class ThreadSettingsUser extends React.PureComponent<Props, State> {\nonPressMakeAdmin = () => {\nif (Platform.OS === \"ios\") {\n// https://github.com/facebook/react-native/issues/10471\n- setTimeout(this.showMakeAdminConfirmation, 300);\n+ setTimeout(this.showMakeAdminConfirmation, 400);\n} else {\nthis.showMakeAdminConfirmation();\n}\n@@ -263,9 +278,12 @@ class ThreadSettingsUser extends React.PureComponent<Props, State> {\n}\n}\ninvariant(newRole !== null, \"Could not find new role\");\n+ const customKeyName = changeThreadMemberRolesActionTypes.started +\n+ `:${this.props.memberInfo.id}`;\nthis.props.dispatchActionPromise(\nchangeThreadMemberRolesActionTypes,\nthis.makeAdmin(newRole),\n+ { customKeyName },\n);\n}\n@@ -325,15 +343,16 @@ const icon = (\n/>\n);\n-const removeUsersLoadingStatusSelector\n- = createLoadingStatusSelector(removeUsersFromThreadActionTypes);\n-const changeRolesLoadingStatusSelector\n- = createLoadingStatusSelector(changeThreadMemberRolesActionTypes);\n-\nexport default connect(\n- (state: AppState) => ({\n- removeUsersLoadingStatus: removeUsersLoadingStatusSelector(state),\n- changeRolesLoadingStatus: changeRolesLoadingStatusSelector(state),\n+ (state: AppState, ownProps: { memberInfo: RelativeMemberInfo }) => ({\n+ removeUsersLoadingStatus: createLoadingStatusSelector(\n+ removeUsersFromThreadActionTypes,\n+ `${removeUsersFromThreadActionTypes.started}:${ownProps.memberInfo.id}`,\n+ )(state),\n+ changeRolesLoadingStatus: createLoadingStatusSelector(\n+ changeThreadMemberRolesActionTypes,\n+ `${changeThreadMemberRolesActionTypes.started}:${ownProps.memberInfo.id}`,\n+ )(state),\ncookie: state.cookie,\n}),\nincludeDispatchActionProps,\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Show loading spinner when removing users and changing their role |
129,187 | 10.11.2017 10:49:40 | 18,000 | 1fbdeb85443c521c74c0e34081b142d7f1d70d58 | Handle messages with null content correctly on backend side | [
{
"change_type": "MODIFY",
"old_path": "server/change_role.php",
"new_path": "server/change_role.php",
"diff": "@@ -71,11 +71,6 @@ $message_info = array(\n'newRole' => (string)$role,\n);\n$new_message_infos = create_message_infos(array($message_info));\n-if ($new_message_infos === null) {\n- async_end(array(\n- 'error' => 'unknown_error',\n- ));\n-}\nlist($thread_infos) = get_thread_infos(\"t.id = {$thread}\");\nasync_end(array(\n"
},
{
"change_type": "MODIFY",
"old_path": "server/edit_thread.php",
"new_path": "server/edit_thread.php",
"diff": "@@ -253,11 +253,6 @@ if ($add_member_ids) {\n);\n}\n$new_message_infos = create_message_infos($message_infos);\n-if ($new_message_infos === null) {\n- async_end(array(\n- 'error' => 'unknown_error',\n- ));\n-}\n$to_save = array();\n$to_delete = array();\n"
},
{
"change_type": "MODIFY",
"old_path": "server/message_lib.php",
"new_path": "server/message_lib.php",
"diff": "@@ -264,8 +264,7 @@ SQL;\nreturn $users;\n}\n-// returns message infos with IDs on success, and null on failure\n-// only fails if passed a message type it doesn't recognize\n+// returns message infos with IDs\nfunction create_message_infos($new_message_infos) {\nglobal $conn;\n@@ -305,8 +304,6 @@ function create_message_infos($new_message_infos) {\n$content_by_index[$index] = $conn->real_escape_string(\njson_encode($content)\n);\n- } else {\n- return null;\n}\n}\n@@ -315,10 +312,13 @@ function create_message_infos($new_message_infos) {\nforeach ($new_message_infos as $index => $new_message_info) {\n$conn->query(\"INSERT INTO ids(table_name) VALUES('messages')\");\n$new_message_info['id'] = (string)$conn->insert_id;\n+ $content = isset($content_by_index[$index])\n+ ? \"'{$content_by_index[$index]}'\"\n+ : \"NULL\";\n$values[] = <<<SQL\n({$new_message_info['id']}, {$new_message_info['threadID']},\n{$new_message_info['creatorID']}, {$new_message_info['type']},\n- '{$content_by_index[$index]}', {$new_message_info['time']})\n+ {$content}, {$new_message_info['time']})\nSQL;\n$return[$index] = $new_message_info;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "server/new_thread.php",
"new_path": "server/new_thread.php",
"diff": "@@ -127,11 +127,6 @@ if ($parent_thread_id) {\n);\n}\n$new_message_infos = create_message_infos($message_infos);\n-if ($new_message_infos === null) {\n- async_end(array(\n- 'error' => 'unknown_error',\n- ));\n-}\n$creator_results = change_roletype(\n$id,\n"
},
{
"change_type": "MODIFY",
"old_path": "server/remove_members.php",
"new_path": "server/remove_members.php",
"diff": "@@ -69,11 +69,6 @@ $message_info = array(\n'removedUserIDs' => array_map(\"strval\", $actual_member_ids),\n);\n$new_message_infos = create_message_infos(array($message_info));\n-if ($new_message_infos === null) {\n- async_end(array(\n- 'error' => 'unknown_error',\n- ));\n-}\nlist($thread_infos) = get_thread_infos(\"t.id = {$thread}\");\nasync_end(array(\n"
},
{
"change_type": "MODIFY",
"old_path": "server/send_message.php",
"new_path": "server/send_message.php",
"diff": "@@ -28,11 +28,6 @@ $message_info = array(\n'text' => $_POST['text'],\n);\n$new_message_infos = create_message_infos(array($message_info));\n-if ($new_message_infos === null) {\n- async_end(array(\n- 'error' => 'unknown_error',\n- ));\n-}\nasync_end(array(\n'success' => true,\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Handle messages with null content correctly on backend side |
129,187 | 10.11.2017 14:24:39 | 18,000 | c224d4b1c349e0542218ac5a542ee1352c6353fa | Three random bugfixes in regards to ThreadSettingsUser
1. Wait 500ms instead of 400ms to avoid React Native `Modal`/`Alert` iOS issue
2. Use a consistent order for member list (order by user ID, ascending)
3. Don't return users in the member list that aren't actually members and aren't parent admins | [
{
"change_type": "MODIFY",
"old_path": "native/chat/settings/thread-settings-user.react.js",
"new_path": "native/chat/settings/thread-settings-user.react.js",
"diff": "@@ -205,7 +205,7 @@ class ThreadSettingsUser extends React.PureComponent<Props, State> {\nonPressRemoveUser = () => {\nif (Platform.OS === \"ios\") {\n// https://github.com/facebook/react-native/issues/10471\n- setTimeout(this.showRemoveUserConfirmation, 400);\n+ setTimeout(this.showRemoveUserConfirmation, 500);\n} else {\nthis.showRemoveUserConfirmation();\n}\n@@ -243,7 +243,7 @@ class ThreadSettingsUser extends React.PureComponent<Props, State> {\nonPressMakeAdmin = () => {\nif (Platform.OS === \"ios\") {\n// https://github.com/facebook/react-native/issues/10471\n- setTimeout(this.showMakeAdminConfirmation, 400);\n+ setTimeout(this.showMakeAdminConfirmation, 500);\n} else {\nthis.showMakeAdminConfirmation();\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "server/thread_lib.php",
"new_path": "server/thread_lib.php",
"diff": "@@ -35,6 +35,7 @@ LEFT JOIN (\nLEFT JOIN roles r ON r.roletype = rt.id AND r.thread = t.id\nLEFT JOIN users u ON u.id = r.user\n{$where_clause}\n+ORDER BY r.user ASC\nSQL;\n$result = $conn->query($query);\n@@ -74,6 +75,14 @@ SQL;\n$permission_info = get_info_from_permissions_row($row);\n$all_permissions =\nget_all_thread_permissions($permission_info, $thread_id);\n+ // This is a hack, similar to what we have in ThreadSettingsUser.\n+ // Basically we only want to return users that are either a member of this\n+ // thread, or are a \"parent admin\". We approximate \"parent admin\" by\n+ // looking for the PERMISSION_CHANGE_ROLE permission.\n+ if (\n+ (int)$row['roletype'] !== 0 ||\n+ $all_permissions[PERMISSION_CHANGE_ROLE]['value']\n+ ) {\n$member = array(\n\"id\" => $user_id,\n\"permissions\" => $all_permissions,\n@@ -95,6 +104,7 @@ SQL;\n}\n}\n}\n+ }\n$final_thread_infos = array();\nforeach ($thread_infos as $thread_id => $thread_info) {\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Three random bugfixes in regards to ThreadSettingsUser
1. Wait 500ms instead of 400ms to avoid React Native `Modal`/`Alert` iOS issue
2. Use a consistent order for member list (order by user ID, ascending)
3. Don't return users in the member list that aren't actually members and aren't parent admins |
129,187 | 11.11.2017 13:27:21 | 18,000 | cd3527e7f3d4671fdcf483ddd83f8d1830dbd8f3 | Make sure server endpoints prevent a thread from becoming admin-less | [
{
"change_type": "MODIFY",
"old_path": "server/leave_thread.php",
"new_path": "server/leave_thread.php",
"diff": "@@ -21,7 +21,27 @@ if (!viewer_is_member($thread)) {\n));\n}\n-$leave_results = change_roletype($thread, array(get_viewer_id()), 0);\n+$viewer_id = get_viewer_id();\n+$other_users_exist = false;\n+$other_admins_exist = false;\n+list($thread_infos) = get_thread_infos(\"t.id = {$thread}\");\n+foreach ($thread_infos[$thread]['members'] as $member) {\n+ if ($member['role'] === null || (int)$member['id'] === $viewer_id) {\n+ continue;\n+ }\n+ $other_users_exist = true;\n+ if ($thread_infos[$thread]['roles'][$member['role']]['name'] === \"Admins\") {\n+ $other_admins_exist = true;\n+ break;\n+ }\n+}\n+if ($other_users_exist && !$other_admins_exist) {\n+ async_end(array(\n+ 'error' => 'invalid_parameters',\n+ ));\n+}\n+\n+$leave_results = change_roletype($thread, array($viewer_id), 0);\nif (!$leave_results) {\nasync_end(array(\n'error' => 'unknown_error',\n@@ -38,7 +58,7 @@ delete_user_roles($leave_results['to_delete']);\n$message_info = array(\n'type' => MESSAGE_TYPE_LEAVE_THREAD,\n'threadID' => (string)$thread,\n- 'creatorID' => (string)get_viewer_id(),\n+ 'creatorID' => (string)$viewer_id,\n'time' => round(microtime(true) * 1000), // in milliseconds\n);\ncreate_message_infos(array($message_info));\n"
},
{
"change_type": "MODIFY",
"old_path": "server/remove_members.php",
"new_path": "server/remove_members.php",
"diff": "@@ -27,6 +27,13 @@ if (\n));\n}\n+$viewer_id = get_viewer_id();\n+if (in_array($viewer_id, $member_ids)) {\n+ async_end(array(\n+ 'error' => 'invalid_parameters',\n+ ));\n+}\n+\n$member_sql_string = implode(\", \", $member_ids);\n$query = <<<SQL\nSELECT r.user, r.roletype, t.default_roletype\n@@ -64,7 +71,7 @@ delete_user_roles($results['to_delete']);\n$message_info = array(\n'type' => MESSAGE_TYPE_REMOVE_MEMBERS,\n'threadID' => (string)$thread,\n- 'creatorID' => (string)get_viewer_id(),\n+ 'creatorID' => (string)$viewer_id,\n'time' => round(microtime(true) * 1000), // in milliseconds\n'removedUserIDs' => array_map(\"strval\", $actual_member_ids),\n);\n"
},
{
"change_type": "MODIFY",
"old_path": "server/thread_lib.php",
"new_path": "server/thread_lib.php",
"diff": "@@ -29,8 +29,10 @@ SELECT t.id, t.name, t.parent_thread_id, t.color, t.description, t.edit_rules,\nr.permissions, r.subscribed, u.username\nFROM threads t\nLEFT JOIN (\n- SELECT thread, id, name, permissions FROM roletypes\n- UNION SELECT id AS thread, 0 AS id, NULL AS name, NULL AS permissions FROM threads\n+ SELECT thread, id, name, permissions\n+ FROM roletypes\n+ UNION SELECT id AS thread, 0 AS id, NULL AS name, NULL AS permissions\n+ FROM threads\n) rt ON rt.thread = t.id\nLEFT JOIN roles r ON r.roletype = rt.id AND r.thread = t.id\nLEFT JOIN users u ON u.id = r.user\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Make sure server endpoints prevent a thread from becoming admin-less |
129,187 | 11.11.2017 23:32:09 | 18,000 | 00f0d32559dcc00c46aba816f74e2f3a81070841 | Lift member LoadingStatuses so we can consider them in ThreadSettings.canReset | [
{
"change_type": "MODIFY",
"old_path": "native/chat/settings/thread-settings-user.react.js",
"new_path": "native/chat/settings/thread-settings-user.react.js",
"diff": "@@ -39,7 +39,6 @@ import {\nchangeThreadMemberRolesActionTypes,\nchangeThreadMemberRoles,\n} from 'lib/actions/thread-actions';\n-import { createLoadingStatusSelector } from 'lib/selectors/loading-selectors';\nimport EditSettingButton from './edit-setting-button.react';\nimport Button from '../../components/button.react';\n@@ -49,7 +48,6 @@ type Props = {|\nmemberInfo: RelativeMemberInfo,\nthreadInfo: ThreadInfo,\ncanEdit: bool,\n- // Redux state\nremoveUsersLoadingStatus: LoadingStatus,\nchangeRolesLoadingStatus: LoadingStatus,\n// Redux dispatch functions\n@@ -344,17 +342,7 @@ const icon = (\n);\nexport default connect(\n- (state: AppState, ownProps: { memberInfo: RelativeMemberInfo }) => ({\n- removeUsersLoadingStatus: createLoadingStatusSelector(\n- removeUsersFromThreadActionTypes,\n- `${removeUsersFromThreadActionTypes.started}:${ownProps.memberInfo.id}`,\n- )(state),\n- changeRolesLoadingStatus: createLoadingStatusSelector(\n- changeThreadMemberRolesActionTypes,\n- `${changeThreadMemberRolesActionTypes.started}:${ownProps.memberInfo.id}`,\n- )(state),\n- cookie: state.cookie,\n- }),\n+ (state: AppState) => ({ cookie: state.cookie }),\nincludeDispatchActionProps,\nbindServerCalls({ removeUsersFromThread, changeThreadMemberRoles }),\n)(ThreadSettingsUser);\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/settings/thread-settings.react.js",
"new_path": "native/chat/settings/thread-settings.react.js",
"diff": "@@ -36,6 +36,9 @@ import Modal from 'react-native-modal';\nimport invariant from 'invariant';\nimport _isEqual from 'lodash/fp/isEqual';\nimport Icon from 'react-native-vector-icons/FontAwesome';\n+import _every from 'lodash/fp/every';\n+import _omit from 'lodash/fp/omit';\n+import shallowequal from 'shallowequal';\nimport { visibilityRules } from 'lib/types/thread-types';\nimport {\n@@ -48,6 +51,8 @@ import {\nchangeSingleThreadSetting,\nleaveThreadActionTypes,\nleaveThread,\n+ removeUsersFromThreadActionTypes,\n+ changeThreadMemberRolesActionTypes,\n} from 'lib/actions/thread-actions';\nimport {\nincludeDispatchActionProps,\n@@ -74,9 +79,7 @@ const itemPageLength = 5;\ntype NavProp = NavigationScreenProp<NavigationRoute>\n& { state: { params: { threadInfo: ThreadInfo, messageListKey: string } } };\n-type Props = {|\n- navigation: NavProp,\n- // Redux state\n+type StateProps = {|\nthreadInfo: ThreadInfo,\nparentThreadInfo: ?ThreadInfo,\nthreadMembers: RelativeMemberInfo[],\n@@ -85,6 +88,13 @@ type Props = {|\ncolorEditLoadingStatus: LoadingStatus,\ndescriptionEditLoadingStatus: LoadingStatus,\nleaveThreadLoadingStatus: LoadingStatus,\n+ removeUsersLoadingStatuses: {[id: string]: LoadingStatus},\n+ changeRolesLoadingStatuses: {[id: string]: LoadingStatus},\n+|};\n+type Props = {|\n+ navigation: NavProp,\n+ // Redux state\n+ ...StateProps,\n// Redux dispatch functions\ndispatchActionPromise: DispatchActionPromise,\n// async functions that hit server APIs\n@@ -179,6 +189,9 @@ class InnerThreadSettings extends React.PureComponent<Props, State> {\n}\n}\n+ static notLoading =\n+ (loadingStatus: LoadingStatus) => loadingStatus !== \"loading\";\n+\ncanReset = () => {\nreturn !this.state.showAddUsersModal &&\n(this.state.nameEditValue === null ||\n@@ -187,7 +200,11 @@ class InnerThreadSettings extends React.PureComponent<Props, State> {\nthis.props.nameEditLoadingStatus !== \"loading\" &&\nthis.props.colorEditLoadingStatus !== \"loading\" &&\nthis.props.descriptionEditLoadingStatus !== \"loading\" &&\n- this.props.leaveThreadLoadingStatus !== \"loading\";\n+ this.props.leaveThreadLoadingStatus !== \"loading\" &&\n+ _every(InnerThreadSettings.notLoading)\n+ (this.props.removeUsersLoadingStatuses) &&\n+ _every(InnerThreadSettings.notLoading)\n+ (this.props.changeRolesLoadingStatuses);\n}\nrender() {\n@@ -403,15 +420,23 @@ class InnerThreadSettings extends React.PureComponent<Props, State> {\n} else {\nthreadMembers = this.props.threadMembers;\n}\n- const members = threadMembers.map(memberInfo => (\n+ const members = threadMembers.map(memberInfo => {\n+ const removeUsersLoadingStatus =\n+ this.props.removeUsersLoadingStatuses[memberInfo.id];\n+ const changeRolesLoadingStatus =\n+ this.props.changeRolesLoadingStatuses[memberInfo.id];\n+ return (\n<View style={styles.itemRow} key={memberInfo.id}>\n<ThreadSettingsUser\nmemberInfo={memberInfo}\nthreadInfo={this.props.threadInfo}\ncanEdit={canStartEditing}\n+ removeUsersLoadingStatus={removeUsersLoadingStatus}\n+ changeRolesLoadingStatus={changeRolesLoadingStatus}\n/>\n</View>\n- ));\n+ );\n+ });\nif (seeMoreMembers) {\nmembers.push(seeMoreMembers);\n}\n@@ -1007,13 +1032,27 @@ const ThreadSettings = connect(\nconst passedThreadInfo = ownProps.navigation.state.params.threadInfo;\n// We pull the version from Redux so we get updates once they go through\nconst threadInfo = state.threadInfos[passedThreadInfo.id];\n+ // We need two LoadingStatuses for each member\n+ const threadMembers =\n+ relativeMemberInfoSelectorForMembersOfThread(threadInfo.id)(state);\n+ const removeUsersLoadingStatuses = {};\n+ const changeRolesLoadingStatuses = {};\n+ for (let threadMember of threadMembers) {\n+ removeUsersLoadingStatuses[threadMember.id] = createLoadingStatusSelector(\n+ removeUsersFromThreadActionTypes,\n+ `${removeUsersFromThreadActionTypes.started}:${threadMember.id}`,\n+ )(state);\n+ changeRolesLoadingStatuses[threadMember.id] = createLoadingStatusSelector(\n+ changeThreadMemberRolesActionTypes,\n+ `${changeThreadMemberRolesActionTypes.started}:${threadMember.id}`,\n+ )(state);\n+ }\nreturn {\nthreadInfo,\nparentThreadInfo: threadInfo.parentThreadID\n? state.threadInfos[threadInfo.parentThreadID]\n: null,\n- threadMembers:\n- relativeMemberInfoSelectorForMembersOfThread(threadInfo.id)(state),\n+ threadMembers,\nchildThreadInfos: childThreadInfos(state)[threadInfo.id],\nnameEditLoadingStatus: createLoadingStatusSelector(\nchangeThreadSettingsActionTypes,\n@@ -1028,11 +1067,28 @@ const ThreadSettings = connect(\n`${changeThreadSettingsActionTypes.started}:description`,\n)(state),\nleaveThreadLoadingStatus: leaveThreadLoadingStatusSelector(state),\n+ removeUsersLoadingStatuses,\n+ changeRolesLoadingStatuses,\ncookie: state.cookie,\n};\n},\nincludeDispatchActionProps,\nbindServerCalls({ changeSingleThreadSetting, leaveThread }),\n+ {\n+ areStatePropsEqual: (oldProps: StateProps, nextProps: StateProps) => {\n+ const omitObjects =\n+ _omit([\"removeUsersLoadingStatuses\", \"changeRolesLoadingStatuses\"]);\n+ return shallowequal(omitObjects(oldProps), omitObjects(nextProps)) &&\n+ shallowequal(\n+ oldProps.removeUsersLoadingStatuses,\n+ nextProps.removeUsersLoadingStatuses,\n+ ) &&\n+ shallowequal(\n+ oldProps.changeRolesLoadingStatuses,\n+ nextProps.changeRolesLoadingStatuses,\n+ );\n+ },\n+ },\n)(InnerThreadSettings);\nexport {\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Lift member LoadingStatuses so we can consider them in ThreadSettings.canReset |
129,187 | 12.11.2017 00:04:00 | 18,000 | d39b529a721d9986cbd25d9e3bb1838a340c6d9f | Use upstream react-native-popover-tooltip now since my PR has been merged | [
{
"change_type": "MODIFY",
"old_path": "native/chat/settings/thread-settings-user.react.js",
"new_path": "native/chat/settings/thread-settings-user.react.js",
"diff": "@@ -26,6 +26,7 @@ import PropTypes from 'prop-types';\nimport _isEqual from 'lodash/fp/isEqual';\nimport { connect } from 'react-redux';\nimport invariant from 'invariant';\n+import PopoverTooltip from 'react-native-popover-tooltip';\nimport { threadHasPermission } from 'lib/shared/thread-utils';\nimport { stringForUser } from 'lib/shared/user-utils';\n@@ -42,7 +43,6 @@ import {\nimport EditSettingButton from './edit-setting-button.react';\nimport Button from '../../components/button.react';\n-import PopoverTooltip from '../../components/popover-tooltip.react';\ntype Props = {|\nmemberInfo: RelativeMemberInfo,\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/settings/thread-settings.react.js",
"new_path": "native/chat/settings/thread-settings.react.js",
"diff": "@@ -39,6 +39,7 @@ import Icon from 'react-native-vector-icons/FontAwesome';\nimport _every from 'lodash/fp/every';\nimport _omit from 'lodash/fp/omit';\nimport shallowequal from 'shallowequal';\n+import 'react-native-popover-tooltip';\nimport { visibilityRules } from 'lib/types/thread-types';\nimport {\n"
},
{
"change_type": "DELETE",
"old_path": "native/components/popover-tooltip.react.js",
"new_path": null,
"diff": "-// @flow\n-\n-import type {\n- StyleObj,\n-} from 'react-native/Libraries/StyleSheet/StyleSheetTypes';\n-\n-import * as React from 'react';\n-import {\n- View,\n- Modal,\n- Animated,\n- TouchableOpacity,\n- StyleSheet,\n- Dimensions,\n- Text,\n- Easing,\n- ViewPropTypes,\n-} from 'react-native';\n-import PropTypes from 'prop-types';\n-import invariant from 'invariant';\n-\n-const window = Dimensions.get('window');\n-\n-type Label = string | () => React.Node;\n-const labelPropType = PropTypes.oneOfType([\n- PropTypes.string,\n- PropTypes.func,\n-]);\n-\n-type Props = {\n- buttonComponent: React.Node,\n- buttonComponentExpandRatio: number,\n- items: $ReadOnlyArray<{ +label: Label, onPress: () => void }>,\n- componentWrapperStyle?: StyleObj,\n- overlayStyle?: StyleObj,\n- tooltipContainerStyle?: StyleObj,\n- labelContainerStyle?: StyleObj,\n- labelSeparatorColor: string,\n- labelStyle?: StyleObj,\n- setBelow: bool,\n- animationType?: \"timing\" | \"spring\",\n- onRequestClose: () => void,\n- triangleOffset: number,\n- onOpenTooltipMenu?: () => void,\n- onCloseTooltipMenu?: () => void,\n- componentContainerStyle?: StyleObj,\n- timingConfig?: { duration?: number },\n- springConfig?: { tension?: number, friction?: number },\n- opacityChangeDuration?: number,\n-};\n-type State = {\n- isModalOpen: bool,\n- x: number,\n- y: number,\n- width: number,\n- height: number,\n- opacity: Animated.Value,\n- tooltipContainerScale: Animated.Value,\n- buttonComponentContainerScale: number | Animated.Interpolation,\n- tooltipTriangleDown: bool,\n- tooltipTriangleLeftMargin: number,\n- triangleOffset: number,\n- willPopUp: bool,\n- oppositeOpacity: ?Animated.Interpolation,\n- tooltipContainerX: ?Animated.Interpolation,\n- tooltipContainerY: ?Animated.Interpolation,\n-};\n-class PopoverTooltip extends React.PureComponent<Props, State> {\n-\n- static propTypes = {\n- buttonComponent: PropTypes.node.isRequired,\n- buttonComponentExpandRatio: PropTypes.number,\n- items: PropTypes.arrayOf(PropTypes.shape({\n- label: labelPropType.isRequired,\n- onPress: PropTypes.func.isRequired,\n- })).isRequired,\n- componentWrapperStyle: ViewPropTypes.style,\n- overlayStyle: ViewPropTypes.style,\n- tooltipContainerStyle: ViewPropTypes.style,\n- labelContainerStyle: ViewPropTypes.style,\n- labelSeparatorColor: PropTypes.string,\n- labelStyle: Text.propTypes.style,\n- setBelow: PropTypes.bool,\n- animationType: PropTypes.oneOf([ \"timing\", \"spring\" ]),\n- onRequestClose: PropTypes.func,\n- triangleOffset: PropTypes.number,\n- onOpenTooltipMenu: PropTypes.func,\n- onCloseTooltipMenu: PropTypes.func,\n- componentContainerStyle: ViewPropTypes.style,\n- timingConfig: PropTypes.object,\n- springConfig: PropTypes.object,\n- opacityChangeDuration: PropTypes.number,\n- };\n- static defaultProps = {\n- buttonComponentExpandRatio: 1.0,\n- labelSeparatorColor: \"#E1E1E1\",\n- onRequestClose: () => {},\n- setBelow: false,\n- triangleOffset: 0,\n- };\n- wrapperComponent: ?TouchableOpacity;\n-\n- constructor(props: Props) {\n- super(props);\n- this.state = {\n- isModalOpen: false,\n- x: 0,\n- y: 0,\n- width: 0,\n- height: 0,\n- opacity: new Animated.Value(0),\n- tooltipContainerScale: new Animated.Value(0),\n- buttonComponentContainerScale: 1,\n- tooltipTriangleDown: !props.setBelow,\n- tooltipTriangleLeftMargin: 0,\n- triangleOffset: props.triangleOffset,\n- willPopUp: false,\n- oppositeOpacity: undefined,\n- tooltipContainerX: undefined,\n- tooltipContainerY: undefined,\n- };\n- }\n-\n- componentWillMount() {\n- const newOppositeOpacity = this.state.opacity.interpolate({\n- inputRange: [0, 1],\n- outputRange: [1, 0],\n- });\n- this.setState({ oppositeOpacity: newOppositeOpacity });\n- }\n-\n- toggleModal = () => {\n- this.setState({ isModalOpen: !this.state.isModalOpen });\n- }\n-\n- openModal = () => {\n- this.setState({ willPopUp: true });\n- this.toggleModal();\n- this.props.onOpenTooltipMenu && this.props.onOpenTooltipMenu();\n- }\n-\n- hideModal = () => {\n- this.setState({ willPopUp: false });\n- this.showZoomingOutAnimation();\n- this.props.onCloseTooltipMenu && this.props.onCloseTooltipMenu();\n- }\n-\n- onPressItem = (userCallback: () => void) => {\n- this.toggle();\n- userCallback();\n- }\n-\n- onInnerContainerLayout = (\n- event: { nativeEvent: { layout: { height: number, width: number } } },\n- ) => {\n- const tooltipContainerWidth = event.nativeEvent.layout.width;\n- const tooltipContainerHeight = event.nativeEvent.layout.height;\n- if (\n- !this.state.willPopUp ||\n- tooltipContainerWidth === 0 ||\n- tooltipContainerHeight === 0\n- ) {\n- return;\n- }\n-\n- const componentWrapper = this.wrapperComponent;\n- invariant(componentWrapper, \"should be set\");\n- componentWrapper.measure((x, y, width, height, pageX, pageY) => {\n- const fullWidth = pageX + tooltipContainerWidth\n- + (width - tooltipContainerWidth) / 2;\n- const tooltipContainerX_final = fullWidth > window.width\n- ? window.width - tooltipContainerWidth - 10\n- : pageX + (width - tooltipContainerWidth) / 2;\n- let tooltipContainerY_final = this.state.tooltipTriangleDown\n- ? pageY - tooltipContainerHeight - 10\n- : pageY + tooltipContainerHeight - 10;\n- let tooltipTriangleDown = this.state.tooltipTriangleDown;\n- if (pageY - tooltipContainerHeight - 10 < 0) {\n- tooltipContainerY_final = pageY + height + 10;\n- tooltipTriangleDown = false;\n- }\n- if (pageY + tooltipContainerHeight + 80 > window.height) {\n- tooltipContainerY_final = pageY - tooltipContainerHeight - 10;\n- tooltipTriangleDown = true;\n- }\n- const tooltipContainerX = this.state.tooltipContainerScale.interpolate({\n- inputRange: [0, 1],\n- outputRange: [tooltipContainerX_final, tooltipContainerX_final],\n- });\n- const tooltipContainerY = this.state.tooltipContainerScale.interpolate({\n- inputRange: [0, 1],\n- outputRange: [\n- tooltipContainerY_final + tooltipContainerHeight / 2 + 10,\n- tooltipContainerY_final,\n- ],\n- });\n- const buttonComponentContainerScale =\n- this.state.tooltipContainerScale.interpolate({\n- inputRange: [0, 1],\n- outputRange: [1, this.props.buttonComponentExpandRatio],\n- });\n- const tooltipTriangleLeftMargin =\n- pageX + width / 2 - tooltipContainerX_final - 6;\n- this.setState(\n- {\n- x: pageX,\n- y: pageY,\n- width,\n- height,\n- tooltipContainerX,\n- tooltipContainerY,\n- tooltipTriangleDown,\n- tooltipTriangleLeftMargin,\n- buttonComponentContainerScale,\n- },\n- this.showZoomingInAnimation,\n- );\n- });\n- this.setState({ willPopUp: false });\n- }\n-\n- render() {\n- const tooltipContainerStyle = {\n- left: this.state.tooltipContainerX,\n- top: this.state.tooltipContainerY,\n- transform: [\n- { scale: this.state.tooltipContainerScale },\n- ],\n- };\n-\n- const items = this.props.items.map((item, index) => {\n- const classes = [ this.props.labelContainerStyle ];\n-\n- if (index !== this.props.items.length - 1) {\n- classes.push([\n- styles.tooltipMargin,\n- { borderBottomColor: this.props.labelSeparatorColor },\n- ]);\n- }\n-\n- return (\n- <PopoverTooltipItem\n- key={index}\n- label={item.label}\n- onPressUserCallback={item.onPress}\n- onPress={this.onPressItem}\n- containerStyle={classes}\n- labelStyle={this.props.labelStyle}\n- />\n- );\n- });\n-\n- const labelContainerStyle = this.props.labelContainerStyle;\n- const borderStyle =\n- labelContainerStyle && labelContainerStyle.backgroundColor\n- ? { borderTopColor: labelContainerStyle.backgroundColor }\n- : null;\n- let triangleDown = null;\n- let triangleUp = null;\n- if (this.state.tooltipTriangleDown) {\n- triangleDown = (\n- <View style={[\n- styles.triangleDown,\n- {\n- marginLeft: this.state.tooltipTriangleLeftMargin,\n- left: this.state.triangleOffset,\n- },\n- borderStyle,\n- ]} />\n- );\n- } else {\n- triangleUp = (\n- <View style={[\n- styles.triangleUp,\n- {\n- marginLeft: this.state.tooltipTriangleLeftMargin,\n- left: this.state.triangleOffset,\n- },\n- borderStyle,\n- ]} />\n- );\n- }\n-\n- return (\n- <TouchableOpacity\n- ref={this.wrapperRef}\n- style={this.props.componentWrapperStyle}\n- onPress={this.toggle}\n- >\n- <Animated.View style={[\n- { opacity: this.state.oppositeOpacity },\n- this.props.componentContainerStyle,\n- ]}>\n- {this.props.buttonComponent}\n- </Animated.View>\n- <Modal\n- visible={this.state.isModalOpen}\n- onRequestClose={this.props.onRequestClose}\n- transparent\n- >\n- <Animated.View style={[\n- styles.overlay,\n- this.props.overlayStyle,\n- { opacity: this.state.opacity },\n- ]}>\n- <TouchableOpacity\n- activeOpacity={1}\n- focusedOpacity={1}\n- style={styles.button}\n- onPress={this.toggle}\n- >\n- <Animated.View\n- style={[\n- styles.tooltipContainer,\n- this.props.tooltipContainerStyle,\n- tooltipContainerStyle,\n- ]}\n- >\n- <View\n- onLayout={this.onInnerContainerLayout}\n- style={styles.innerContainer}\n- >\n- {triangleUp}\n- <View style={[\n- styles.allItemContainer,\n- this.props.tooltipContainerStyle,\n- ]}>\n- {items}\n- </View>\n- {triangleDown}\n- </View>\n- </Animated.View>\n- </TouchableOpacity>\n- </Animated.View>\n- <Animated.View style={{\n- position: 'absolute',\n- left: this.state.x,\n- top: this.state.y,\n- width: this.state.width,\n- height: this.state.height,\n- backgroundColor: 'transparent',\n- opacity: 1,\n- transform: [\n- { scale: this.state.buttonComponentContainerScale },\n- ],\n- }}>\n- <TouchableOpacity\n- onPress={this.toggle}\n- activeOpacity={1.0}\n- >\n- {this.props.buttonComponent}\n- </TouchableOpacity>\n- </Animated.View>\n- </Modal>\n- </TouchableOpacity>\n- );\n- }\n-\n- wrapperRef = (wrapperComponent: ?TouchableOpacity) => {\n- this.wrapperComponent = wrapperComponent;\n- }\n-\n- showZoomingInAnimation = () => {\n- let tooltipAnimation = Animated.timing(\n- this.state.tooltipContainerScale,\n- {\n- toValue: 1,\n- duration: this.props.timingConfig && this.props.timingConfig.duration\n- ? this.props.timingConfig.duration\n- : 200,\n- }\n- );\n- if (this.props.animationType == 'spring') {\n- tooltipAnimation = Animated.spring(\n- this.state.tooltipContainerScale,\n- {\n- toValue: 1,\n- tension: this.props.springConfig && this.props.springConfig.tension\n- ? this.props.springConfig.tension\n- : 100,\n- friction: this.props.springConfig && this.props.springConfig.friction\n- ? this.props.springConfig.friction\n- : 7,\n- },\n- );\n- }\n- Animated.parallel([\n- tooltipAnimation,\n- Animated.timing(\n- this.state.opacity,\n- {\n- toValue: 1,\n- duration: this.props.opacityChangeDuration\n- ? this.props.opacityChangeDuration\n- : 200,\n- },\n- ),\n- ]).start();\n- }\n-\n- showZoomingOutAnimation() {\n- Animated.parallel([\n- Animated.timing(\n- this.state.tooltipContainerScale,\n- {\n- toValue: 0,\n- duration: this.props.opacityChangeDuration\n- ? this.props.opacityChangeDuration\n- : 200,\n- },\n- ),\n- Animated.timing(\n- this.state.opacity,\n- {\n- toValue: 0,\n- duration: this.props.opacityChangeDuration\n- ? this.props.opacityChangeDuration\n- : 200,\n- },\n- ),\n- ]).start(this.toggleModal);\n- }\n-\n- toggle = () => {\n- if (this.state.isModalOpen) {\n- this.hideModal();\n- } else {\n- this.openModal();\n- }\n- }\n-\n-}\n-\n-type ItemProps = {\n- onPress: (userCallback: () => void) => void,\n- onPressUserCallback: () => void,\n- label: Label,\n- containerStyle: ?StyleObj,\n- labelStyle: ?StyleObj,\n-};\n-class PopoverTooltipItem extends React.PureComponent<ItemProps> {\n-\n- static propTypes = {\n- onPress: PropTypes.func.isRequired,\n- onPressUserCallback: PropTypes.func.isRequired,\n- label: labelPropType.isRequired,\n- containerStyle: ViewPropTypes.style,\n- labelStyle: Text.propTypes.style,\n- };\n- static defaultProps = {\n- labelStyle: null,\n- containerStyle: null,\n- };\n-\n- render() {\n- const label = typeof this.props.label === 'string'\n- ? <Text style={this.props.labelStyle}>{this.props.label}</Text>\n- : this.props.label();\n- return (\n- <View style={[styles.itemContainer, this.props.containerStyle]}>\n- <TouchableOpacity onPress={this.onPress}>\n- {label}\n- </TouchableOpacity>\n- </View>\n- );\n- }\n-\n- onPress = () => {\n- this.props.onPress(this.props.onPressUserCallback);\n- }\n-\n-}\n-\n-const styles = StyleSheet.create({\n- overlay: {\n- backgroundColor: 'rgba(0,0,0,0.5)',\n- flex: 1,\n- },\n- innerContainer: {\n- backgroundColor: 'transparent',\n- alignItems: 'flex-start'\n- },\n- tooltipMargin: {\n- borderBottomWidth: 1,\n- },\n- tooltipContainer: {\n- backgroundColor: 'transparent',\n- position: 'absolute',\n- },\n- triangleDown: {\n- width: 10,\n- height: 10,\n- backgroundColor: 'transparent',\n- borderStyle: 'solid',\n- borderTopWidth: 10,\n- borderRightWidth: 10,\n- borderBottomWidth: 0,\n- borderLeftWidth: 10,\n- borderTopColor: 'white',\n- borderRightColor: 'transparent',\n- borderBottomColor: 'transparent',\n- borderLeftColor: 'transparent',\n- },\n- triangleUp: {\n- width: 10,\n- height: 10,\n- backgroundColor: 'transparent',\n- borderStyle: 'solid',\n- borderTopWidth: 0,\n- borderRightWidth: 10,\n- borderBottomWidth: 10,\n- borderLeftWidth: 10,\n- borderBottomColor: 'white',\n- borderTopColor: 'transparent',\n- borderRightColor: 'transparent',\n- borderLeftColor: 'transparent',\n- },\n- itemContainer: {\n- padding: 10,\n- },\n- button: {\n- flex: 1,\n- },\n- allItemContainer: {\n- borderRadius: 5,\n- backgroundColor: 'white',\n- alignSelf: 'stretch',\n- overflow: 'hidden',\n- },\n-});\n-\n-export default PopoverTooltip;\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-popover-tooltip\": {\n+ \"version\": \"1.1.4\",\n+ \"resolved\": \"https://registry.npmjs.org/react-native-popover-tooltip/-/react-native-popover-tooltip-1.1.4.tgz\",\n+ \"integrity\": \"sha1-9vISHmcl6dosAUozuUYWLBl6TrQ=\",\n+ \"requires\": {\n+ \"invariant\": \"2.2.2\",\n+ \"prop-types\": \"15.6.0\"\n+ },\n+ \"dependencies\": {\n+ \"fbjs\": {\n+ \"version\": \"0.8.16\",\n+ \"resolved\": \"https://registry.npmjs.org/fbjs/-/fbjs-0.8.16.tgz\",\n+ \"integrity\": \"sha1-XmdDL1UNxBtXK/VYR7ispk5TN9s=\",\n+ \"requires\": {\n+ \"core-js\": \"1.2.7\",\n+ \"isomorphic-fetch\": \"2.2.1\",\n+ \"loose-envify\": \"1.3.1\",\n+ \"object-assign\": \"4.1.1\",\n+ \"promise\": \"7.3.1\",\n+ \"setimmediate\": \"1.0.5\",\n+ \"ua-parser-js\": \"0.7.14\"\n+ }\n+ },\n+ \"prop-types\": {\n+ \"version\": \"15.6.0\",\n+ \"resolved\": \"https://registry.npmjs.org/prop-types/-/prop-types-15.6.0.tgz\",\n+ \"integrity\": \"sha1-zq8IMCL8RrSjX2nhPvda7Q1jmFY=\",\n+ \"requires\": {\n+ \"fbjs\": \"0.8.16\",\n+ \"loose-envify\": \"1.3.1\",\n+ \"object-assign\": \"4.1.1\"\n+ }\n+ }\n+ }\n+ },\n\"react-native-segmented-control-tab\": {\n\"version\": \"3.2.1\",\n\"resolved\": \"https://registry.npmjs.org/react-native-segmented-control-tab/-/react-native-segmented-control-tab-3.2.1.tgz\",\n"
},
{
"change_type": "MODIFY",
"old_path": "native/package.json",
"new_path": "native/package.json",
"diff": "\"react-native-keychain\": \"^1.2.1\",\n\"react-native-modal\": \"^4.0.0\",\n\"react-native-onepassword\": \"^1.0.6\",\n+ \"react-native-popover-tooltip\": \"^1.1.4\",\n\"react-native-segmented-control-tab\": \"^3.2.1\",\n\"react-native-vector-icons\": \"^4.3.0\",\n\"react-navigation\": \"^1.0.0-beta.18\",\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Use upstream react-native-popover-tooltip now since my PR has been merged |
129,187 | 13.11.2017 11:07:02 | 18,000 | 6e701611ff1b5744c7b2e8e21158d38d0d823c98 | Use `messageType` constant instead of literals in message-types.js | [
{
"change_type": "MODIFY",
"old_path": "lib/types/message-types.js",
"new_path": "lib/types/message-types.js",
"diff": "@@ -8,7 +8,6 @@ import { relativeUserInfoPropType } from './user-types';\nimport invariant from 'invariant';\nimport PropTypes from 'prop-types';\n-export type MessageType = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10;\nexport const messageType = {\nTEXT: 0,\nCREATE_THREAD: 1,\n@@ -22,28 +21,40 @@ export const messageType = {\nCREATE_ENTRY: 9,\nEDIT_ENTRY: 10,\n};\n+export type MessageType =\n+ | typeof messageType.TEXT\n+ | typeof messageType.CREATE_THREAD\n+ | typeof messageType.ADD_MEMBERS\n+ | typeof messageType.CREATE_SUB_THREAD\n+ | typeof messageType.CHANGE_SETTINGS\n+ | typeof messageType.REMOVE_MEMBERS\n+ | typeof messageType.CHANGE_ROLE\n+ | typeof messageType.LEAVE_THREAD\n+ | typeof messageType.JOIN_THREAD\n+ | typeof messageType.CREATE_ENTRY\n+ | typeof messageType.EDIT_ENTRY;\nexport function assertMessageType(\nourMessageType: number,\n): MessageType {\ninvariant(\n- ourMessageType === 0 ||\n- ourMessageType === 1 ||\n- ourMessageType === 2 ||\n- ourMessageType === 3 ||\n- ourMessageType === 4 ||\n- ourMessageType === 5 ||\n- ourMessageType === 6 ||\n- ourMessageType === 7 ||\n- ourMessageType === 8 ||\n- ourMessageType === 9 ||\n- ourMessageType === 10,\n+ ourMessageType === messageType.TEXT ||\n+ ourMessageType === messageType.CREATE_THREAD ||\n+ ourMessageType === messageType.ADD_MEMBERS ||\n+ ourMessageType === messageType.CREATE_SUB_THREAD ||\n+ ourMessageType === messageType.CHANGE_SETTINGS ||\n+ ourMessageType === messageType.REMOVE_MEMBERS ||\n+ ourMessageType === messageType.CHANGE_ROLE ||\n+ ourMessageType === messageType.LEAVE_THREAD ||\n+ ourMessageType === messageType.JOIN_THREAD ||\n+ ourMessageType === messageType.CREATE_ENTRY ||\n+ ourMessageType === messageType.EDIT_ENTRY,\n\"number is not MessageType enum\",\n);\nreturn ourMessageType;\n}\nexport type RawTextMessageInfo = {|\n- type: 0,\n+ type: typeof messageType.TEXT,\nid?: string, // null if local copy without ID yet\nlocalID?: string, // for optimistic creations\nthreadID: string,\n@@ -61,7 +72,7 @@ type RawInitialThreadState = {|\n|};\nexport type RawThreadCreationInfo = {|\n- type: 1,\n+ type: typeof messageType.CREATE_THREAD,\nid: string,\nthreadID: string,\ncreatorID: string,\n@@ -70,7 +81,7 @@ export type RawThreadCreationInfo = {|\n|};\nexport type RawAddMembersInfo = {|\n- type: 2,\n+ type: typeof messageType.ADD_MEMBERS,\nid: string,\nthreadID: string,\ncreatorID: string,\n@@ -79,7 +90,7 @@ export type RawAddMembersInfo = {|\n|};\nexport type RawSubThreadCreationInfo = {|\n- type: 3,\n+ type: typeof messageType.CREATE_SUB_THREAD,\nid: string,\nthreadID: string,\ncreatorID: string,\n@@ -88,7 +99,7 @@ export type RawSubThreadCreationInfo = {|\n|};\nexport type RawChangeThreadSettingsInfo = {|\n- type: 4,\n+ type: typeof messageType.CHANGE_SETTINGS,\nid: string,\nthreadID: string,\ncreatorID: string,\n@@ -98,7 +109,7 @@ export type RawChangeThreadSettingsInfo = {|\n|};\nexport type RawRemoveMembersInfo = {|\n- type: 5,\n+ type: typeof messageType.REMOVE_MEMBERS,\nid: string,\nthreadID: string,\ncreatorID: string,\n@@ -107,7 +118,7 @@ export type RawRemoveMembersInfo = {|\n|};\nexport type RawChangeRoleInfo = {|\n- type: 6,\n+ type: typeof messageType.CHANGE_ROLE,\nid: string,\nthreadID: string,\ncreatorID: string,\n@@ -117,7 +128,7 @@ export type RawChangeRoleInfo = {|\n|};\nexport type RawLeaveThreadInfo = {|\n- type: 7,\n+ type: typeof messageType.LEAVE_THREAD,\nid: string,\nthreadID: string,\ncreatorID: string,\n@@ -125,7 +136,7 @@ export type RawLeaveThreadInfo = {|\n|};\nexport type RawJoinThreadInfo = {|\n- type: 8,\n+ type: typeof messageType.JOIN_THREAD,\nid: string,\nthreadID: string,\ncreatorID: string,\n@@ -133,7 +144,7 @@ export type RawJoinThreadInfo = {|\n|};\nexport type RawCreateEntryInfo = {|\n- type: 9,\n+ type: typeof messageType.CREATE_ENTRY,\nid: string,\nthreadID: string,\ncreatorID: string,\n@@ -144,7 +155,7 @@ export type RawCreateEntryInfo = {|\n|};\nexport type RawEditEntryInfo = {|\n- type: 10,\n+ type: typeof messageType.EDIT_ENTRY,\nid: string,\nthreadID: string,\ncreatorID: string,\n@@ -168,7 +179,7 @@ export type RawMessageInfo =\nRawEditEntryInfo;\nexport type TextMessageInfo = {|\n- type: 0,\n+ type: typeof messageType.TEXT,\nid?: string, // null if local copy without ID yet\nlocalID?: string, // for optimistic creations\nthreadID: string,\n@@ -185,28 +196,28 @@ type InitialThreadState = {|\notherMembers: RelativeUserInfo[],\n|};\nexport type RobotextMessageInfo = {|\n- type: 1,\n+ type: typeof messageType.CREATE_THREAD,\nid: string,\nthreadID: string,\ncreator: RelativeUserInfo,\ntime: number,\ninitialThreadState: InitialThreadState,\n|} | {|\n- type: 2,\n+ type: typeof messageType.ADD_MEMBERS,\nid: string,\nthreadID: string,\ncreator: RelativeUserInfo,\ntime: number,\naddedMembers: RelativeUserInfo[],\n|} | {|\n- type: 3,\n+ type: typeof messageType.CREATE_SUB_THREAD,\nid: string,\nthreadID: string,\ncreator: RelativeUserInfo,\ntime: number,\nchildThreadInfo: ThreadInfo,\n|} | {|\n- type: 4,\n+ type: typeof messageType.CHANGE_SETTINGS,\nid: string,\nthreadID: string,\ncreator: RelativeUserInfo,\n@@ -214,14 +225,14 @@ export type RobotextMessageInfo = {|\nfield: string,\nvalue: string | number,\n|} | {|\n- type: 5,\n+ type: typeof messageType.REMOVE_MEMBERS,\nid: string,\nthreadID: string,\ncreator: RelativeUserInfo,\ntime: number,\nremovedMembers: RelativeUserInfo[],\n|} | {|\n- type: 6,\n+ type: typeof messageType.CHANGE_ROLE,\nid: string,\nthreadID: string,\ncreator: RelativeUserInfo,\n@@ -229,19 +240,19 @@ export type RobotextMessageInfo = {|\nmembers: RelativeUserInfo[],\nnewRole: string,\n|} | {|\n- type: 7,\n+ type: typeof messageType.LEAVE_THREAD,\nid: string,\nthreadID: string,\ncreator: RelativeUserInfo,\ntime: number,\n|} | {|\n- type: 8,\n+ type: typeof messageType.JOIN_THREAD,\nid: string,\nthreadID: string,\ncreator: RelativeUserInfo,\ntime: number,\n|} | {|\n- type: 9,\n+ type: typeof messageType.CREATE_ENTRY,\nid: string,\nthreadID: string,\ncreator: RelativeUserInfo,\n@@ -250,7 +261,7 @@ export type RobotextMessageInfo = {|\ndate: string,\ntext: string,\n|} | {|\n- type: 10,\n+ type: typeof messageType.EDIT_ENTRY,\nid: string,\nthreadID: string,\ncreator: RelativeUserInfo,\n@@ -264,7 +275,7 @@ export type MessageInfo = TextMessageInfo | RobotextMessageInfo;\nexport const messageInfoPropType = PropTypes.oneOfType([\nPropTypes.shape({\n- type: PropTypes.oneOf([0]).isRequired,\n+ type: PropTypes.oneOf([ messageType.TEXT ]).isRequired,\nid: PropTypes.string,\nlocalID: PropTypes.string,\nthreadID: PropTypes.string.isRequired,\n@@ -273,7 +284,7 @@ export const messageInfoPropType = PropTypes.oneOfType([\ntext: PropTypes.string.isRequired,\n}),\nPropTypes.shape({\n- type: PropTypes.oneOf([1]).isRequired,\n+ type: PropTypes.oneOf([ messageType.CREATE_THREAD ]).isRequired,\nid: PropTypes.string.isRequired,\nthreadID: PropTypes.string.isRequired,\ncreator: relativeUserInfoPropType.isRequired,\n@@ -287,7 +298,7 @@ export const messageInfoPropType = PropTypes.oneOfType([\n}).isRequired,\n}),\nPropTypes.shape({\n- type: PropTypes.oneOf([2]).isRequired,\n+ type: PropTypes.oneOf([ messageType.ADD_MEMBERS ]).isRequired,\nid: PropTypes.string.isRequired,\nthreadID: PropTypes.string.isRequired,\ncreator: relativeUserInfoPropType.isRequired,\n@@ -295,7 +306,7 @@ export const messageInfoPropType = PropTypes.oneOfType([\naddedMembers: PropTypes.arrayOf(relativeUserInfoPropType).isRequired,\n}),\nPropTypes.shape({\n- type: PropTypes.oneOf([3]).isRequired,\n+ type: PropTypes.oneOf([ messageType.CREATE_SUB_THREAD ]).isRequired,\nid: PropTypes.string.isRequired,\nthreadID: PropTypes.string.isRequired,\ncreator: relativeUserInfoPropType.isRequired,\n@@ -303,7 +314,7 @@ export const messageInfoPropType = PropTypes.oneOfType([\nchildThreadInfo: threadInfoPropType.isRequired,\n}),\nPropTypes.shape({\n- type: PropTypes.oneOf([4]).isRequired,\n+ type: PropTypes.oneOf([ messageType.CHANGE_SETTINGS ]).isRequired,\nid: PropTypes.string.isRequired,\nthreadID: PropTypes.string.isRequired,\ncreator: relativeUserInfoPropType.isRequired,\n@@ -315,7 +326,7 @@ export const messageInfoPropType = PropTypes.oneOfType([\n]).isRequired,\n}),\nPropTypes.shape({\n- type: PropTypes.oneOf([5]).isRequired,\n+ type: PropTypes.oneOf([ messageType.REMOVE_MEMBERS ]).isRequired,\nid: PropTypes.string.isRequired,\nthreadID: PropTypes.string.isRequired,\ncreator: relativeUserInfoPropType.isRequired,\n@@ -323,7 +334,7 @@ export const messageInfoPropType = PropTypes.oneOfType([\nremovedMembers: PropTypes.arrayOf(relativeUserInfoPropType).isRequired,\n}),\nPropTypes.shape({\n- type: PropTypes.oneOf([6]).isRequired,\n+ type: PropTypes.oneOf([ messageType.CHANGE_ROLE ]).isRequired,\nid: PropTypes.string.isRequired,\nthreadID: PropTypes.string.isRequired,\ncreator: relativeUserInfoPropType.isRequired,\n@@ -332,21 +343,21 @@ export const messageInfoPropType = PropTypes.oneOfType([\nnewRole: PropTypes.string.isRequired,\n}),\nPropTypes.shape({\n- type: PropTypes.oneOf([7]).isRequired,\n+ type: PropTypes.oneOf([ messageType.LEAVE_THREAD ]).isRequired,\nid: PropTypes.string.isRequired,\nthreadID: PropTypes.string.isRequired,\ncreator: relativeUserInfoPropType.isRequired,\ntime: PropTypes.number.isRequired,\n}),\nPropTypes.shape({\n- type: PropTypes.oneOf([8]).isRequired,\n+ type: PropTypes.oneOf([ messageType.JOIN_THREAD ]).isRequired,\nid: PropTypes.string.isRequired,\nthreadID: PropTypes.string.isRequired,\ncreator: relativeUserInfoPropType.isRequired,\ntime: PropTypes.number.isRequired,\n}),\nPropTypes.shape({\n- type: PropTypes.oneOf([9]).isRequired,\n+ type: PropTypes.oneOf([ messageType.CREATE_ENTRY ]).isRequired,\nid: PropTypes.string.isRequired,\nthreadID: PropTypes.string.isRequired,\ncreator: relativeUserInfoPropType.isRequired,\n@@ -356,7 +367,7 @@ export const messageInfoPropType = PropTypes.oneOfType([\ntext: PropTypes.string.isRequired,\n}),\nPropTypes.shape({\n- type: PropTypes.oneOf([10]).isRequired,\n+ type: PropTypes.oneOf([ messageType.EDIT_ENTRY ]).isRequired,\nid: PropTypes.string.isRequired,\nthreadID: PropTypes.string.isRequired,\ncreator: relativeUserInfoPropType.isRequired,\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Use `messageType` constant instead of literals in message-types.js |
129,187 | 13.11.2017 11:19:57 | 18,000 | efabf8d83d5ef8219573b54a54dffd7b25185a6c | Use constants instead of literals in thread-types.js | [
{
"change_type": "MODIFY",
"old_path": "lib/types/thread-types.js",
"new_path": "lib/types/thread-types.js",
"diff": "import PropTypes from 'prop-types';\nimport invariant from 'invariant';\n-export type VisibilityRules = 0 | 1 | 2 | 3 | 4;\nexport const visibilityRules = {\nOPEN: 0,\nCLOSED: 1,\n@@ -11,50 +10,45 @@ export const visibilityRules = {\nCHAT_NESTED_OPEN: 3,\nCHAT_SECRET: 4,\n};\n+export type VisibilityRules =\n+ | typeof visibilityRules.OPEN\n+ | typeof visibilityRules.CLOSED\n+ | typeof visibilityRules.SECRET\n+ | typeof visibilityRules.CHAT_NESTED_OPEN\n+ | typeof visibilityRules.CHAT_SECRET;\nexport function assertVisibilityRules(\nourVisibilityRules: number,\n): VisibilityRules {\ninvariant(\n- ourVisibilityRules === 0 ||\n- ourVisibilityRules === 1 ||\n- ourVisibilityRules === 2 ||\n- ourVisibilityRules === 3 ||\n- ourVisibilityRules === 4,\n+ ourVisibilityRules === visibilityRules.OPEN ||\n+ ourVisibilityRules === visibilityRules.CLOSED ||\n+ ourVisibilityRules === visibilityRules.SECRET ||\n+ ourVisibilityRules === visibilityRules.CHAT_NESTED_OPEN ||\n+ ourVisibilityRules === visibilityRules.CHAT_SECRET,\n\"number is not visibilityRules enum\",\n);\nreturn ourVisibilityRules;\n}\n-export type EditRules = 0 | 1;\nexport const editRules = {\nANYBODY: 0,\nLOGGED_IN: 1,\n};\n+export type EditRules =\n+ | typeof editRules.ANYBODY\n+ | typeof editRules.LOGGED_IN;\nexport function assertEditRules(\nourEditRules: number,\n): EditRules {\ninvariant(\n- ourEditRules === 0 ||\n- ourEditRules === 1,\n+ ourEditRules === editRules.ANYBODY ||\n+ ourEditRules === editRules.LOGGED_IN,\n\"number is not editRules enum\",\n);\nreturn ourEditRules;\n}\n// Keep in sync with server/permissions.php\n-export type ThreadPermission =\n- | \"know_of\"\n- | \"visible\"\n- | \"voiced\"\n- | \"edit_entries\"\n- | \"edit_thread\"\n- | \"delete_thread\"\n- | \"create_subthreads\"\n- | \"join_thread\"\n- | \"edit_permissions\"\n- | \"add_members\"\n- | \"remove_members\"\n- | \"change_role\";\nexport const threadPermissions = {\nKNOW_OF: \"know_of\",\nVISIBLE: \"visible\",\n@@ -69,22 +63,35 @@ export const threadPermissions = {\nREMOVE_MEMBERS: \"remove_members\",\nCHANGE_ROLE: \"change_role\",\n};\n+export type ThreadPermission =\n+ | typeof threadPermissions.KNOW_OF\n+ | typeof threadPermissions.VISIBLE\n+ | typeof threadPermissions.VOICED\n+ | typeof threadPermissions.EDIT_ENTRIES\n+ | typeof threadPermissions.EDIT_THREAD\n+ | typeof threadPermissions.DELETE_THREAD\n+ | typeof threadPermissions.CREATE_SUBTHREADS\n+ | typeof threadPermissions.JOIN_THREAD\n+ | typeof threadPermissions.EDIT_PERMISSIONS\n+ | typeof threadPermissions.ADD_MEMBERS\n+ | typeof threadPermissions.REMOVE_MEMBERS\n+ | typeof threadPermissions.CHANGE_ROLE;\nexport function assertThreadPermissions(\nourThreadPermissions: string,\n): ThreadPermission {\ninvariant(\n- ourThreadPermissions === \"know_of\" ||\n- ourThreadPermissions === \"visible\" ||\n- ourThreadPermissions === \"voiced\" ||\n- ourThreadPermissions === \"edit_entries\" ||\n- ourThreadPermissions === \"edit_thread\" ||\n- ourThreadPermissions === \"delete_thread\" ||\n- ourThreadPermissions === \"create_subthreads\" ||\n- ourThreadPermissions === \"join_thread\" ||\n- ourThreadPermissions === \"edit_permissions\" ||\n- ourThreadPermissions === \"add_members\" ||\n- ourThreadPermissions === \"remove_members\" ||\n- ourThreadPermissions === \"change_role\",\n+ ourThreadPermissions === threadPermissions.KNOW_OF ||\n+ ourThreadPermissions === threadPermissions.VISIBLE ||\n+ ourThreadPermissions === threadPermissions.VOICED ||\n+ ourThreadPermissions === threadPermissions.EDIT_ENTRIES ||\n+ ourThreadPermissions === threadPermissions.EDIT_THREAD ||\n+ ourThreadPermissions === threadPermissions.DELETE_THREAD ||\n+ ourThreadPermissions === threadPermissions.CREATE_SUBTHREADS ||\n+ ourThreadPermissions === threadPermissions.JOIN_THREAD ||\n+ ourThreadPermissions === threadPermissions.EDIT_PERMISSIONS ||\n+ ourThreadPermissions === threadPermissions.ADD_MEMBERS ||\n+ ourThreadPermissions === threadPermissions.REMOVE_MEMBERS ||\n+ ourThreadPermissions === threadPermissions.CHANGE_ROLE,\n\"string is not threadPermissions enum\",\n);\nreturn ourThreadPermissions;\n@@ -163,7 +170,11 @@ export type ThreadInfo = {|\n|};\nexport const visibilityRulesPropType = PropTypes.oneOf([\n- 0, 1, 2, 3, 4,\n+ visibilityRules.OPEN,\n+ visibilityRules.CLOSED,\n+ visibilityRules.SECRET,\n+ visibilityRules.CHAT_NESTED_OPEN,\n+ visibilityRules.CHAT_SECRET,\n]);\nexport const threadInfoPropType = PropTypes.shape({\n@@ -173,7 +184,8 @@ export const threadInfoPropType = PropTypes.shape({\nvisibilityRules: visibilityRulesPropType.isRequired,\ncolor: PropTypes.string.isRequired,\neditRules: PropTypes.oneOf([\n- 0, 1,\n+ editRules.ANYBODY,\n+ editRules.LOGGED_IN,\n]).isRequired,\ncreationTime: PropTypes.number.isRequired,\nparentThreadID: PropTypes.string,\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Use constants instead of literals in thread-types.js |
129,187 | 14.11.2017 09:34:18 | 18,000 | 7a1ee9609977fae076282a60a71e5c5c660d65c0 | get_message_infos should return all threads the viewer is a member of when $input is null | [
{
"change_type": "MODIFY",
"old_path": "server/message_lib.php",
"new_path": "server/message_lib.php",
"diff": "@@ -40,7 +40,7 @@ define(\"TRUNCATION_EXHAUSTIVE\", \"exhaustive\");\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. This\n+// is null, we will fetch from every thread that the user is a member of. This\n// function returns:\n// - An array of MessageInfos\n// - An array that points from threadID to truncation status (see definition of\n@@ -49,7 +49,7 @@ define(\"TRUNCATION_EXHAUSTIVE\", \"exhaustive\");\nfunction get_message_infos($input, $number_per_thread) {\nglobal $conn;\n- if (is_array($input)) {\n+ if (is_array($input) && $input) {\n$conditions = array();\nforeach ($input as $thread => $cursor) {\n$int_thread = (int)$thread;\n@@ -62,7 +62,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 = \"r.roletype != 0\";\n}\n$viewer_id = get_viewer_id();\n@@ -119,10 +119,11 @@ SQL;\n? TRUNCATION_EXHAUSTIVE\n: TRUNCATION_TRUNCATED;\n}\n- if (is_array($input)) {\n+ if (is_array($input) && $input) {\nforeach ($input as $thread => $cursor) {\n- if (!isset($truncation_status[$thread])) {\n- $truncation_status[$thread] = TRUNCATION_EXHAUSTIVE;\n+ $int_thread = (int)$thread;\n+ if (!isset($truncation_status[(string)$int_thread])) {\n+ $truncation_status[(string)$int_thread] = TRUNCATION_EXHAUSTIVE;\n}\n}\n}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | get_message_infos should return all threads the viewer is a member of when $input is null |
129,187 | 14.11.2017 09:46:12 | 18,000 | bec4171496f8e580edbc7d5173af8f6168ee70c2 | Update threads that get_messages_since fetches messages from
By default it will now be threads that the viewer is a member of. There is also a `$watch_ids` parameter that can add additional threads to follow. | [
{
"change_type": "MODIFY",
"old_path": "server/message_lib.php",
"new_path": "server/message_lib.php",
"diff": "@@ -137,14 +137,34 @@ SQL;\n// this one is used to keep a session updated. You give it a timestamp, and it\n// fetches all of the messages with a newer timestamp. If for a given thread\n// more than $max_number_per_thread messages have been sent since $current_as_of\n-// then the most recent $current_as_of will be returned. This function returns:\n+// then the most recent $current_as_of will be returned. If $watch_ids is falsey\n+// we'll only return messages from the threads the viewer is a member of. If\n+// specified, we'll also return messages from the specified threads. Note that\n+// this behavior is additive, whereas get_message_infos will only return\n+// messages from the thread IDs that key $input if it is specified. This\n+// function returns:\n// - An array of MessageInfos\n// - An array that points from threadID to truncation status (see definition of\n// TRUNCATION_ constants)\n// - An array of user IDs pointing to UserInfo objects for all referenced users\n-function get_messages_since($current_as_of, $max_number_per_thread) {\n+function get_messages_since(\n+ $current_as_of,\n+ $max_number_per_thread,\n+ $watch_ids\n+) {\nglobal $conn;\n+ if (is_array($watch_ids) && $watch_ids) {\n+ $conditions = array(\"r.roletype != 0\");\n+ foreach ($watch_ids as $watch_id) {\n+ $thread_id = (int)$watch_id;\n+ $conditions[] = \"m.thread = $thread_id\";\n+ }\n+ $additional_condition = \"(\".implode(\" OR \", $conditions).\")\";\n+ } else {\n+ $additional_condition = \"r.roletype != 0\";\n+ }\n+\n$viewer_id = get_viewer_id();\n$visibility_open = VISIBILITY_OPEN;\n$visibility_nested_open = VISIBILITY_NESTED_OPEN;\n@@ -157,6 +177,7 @@ LEFT JOIN roles r ON r.thread = m.thread AND r.user = {$viewer_id}\nLEFT JOIN users u ON u.id = m.user\nWHERE (r.visible = 1 OR t.visibility_rules = {$visibility_open})\nAND m.time > {$current_as_of}\n+ AND {$additional_condition}\nORDER BY m.thread, m.time DESC\nSQL;\n$result = $conn->query($query);\n@@ -193,6 +214,15 @@ SQL;\n}\n}\n+ if (is_array($watch_ids) && $watch_ids) {\n+ foreach ($watch_ids as $watch_id) {\n+ $thread_id = (int)$watch_id;\n+ if (!isset($truncation_status[(string)$thread_id])) {\n+ $truncation_status[(string)$thread_id] = TRUNCATION_UNCHANGED;\n+ }\n+ }\n+ }\n+\n$all_users = get_all_users($messages, $users);\nreturn array($messages, $truncation_status, $all_users);\n"
},
{
"change_type": "MODIFY",
"old_path": "server/ping.php",
"new_path": "server/ping.php",
"diff": "@@ -31,7 +31,7 @@ $message_users = array();\nif (isset($_POST['last_ping']) && $_POST['last_ping']) {\n$last_ping = (int)$_POST['last_ping'];\nlist($message_infos, $truncation_status, $message_users) =\n- get_messages_since($last_ping, DEFAULT_NUMBER_PER_THREAD);\n+ get_messages_since($last_ping, DEFAULT_NUMBER_PER_THREAD, null);\n} else {\nlist($message_infos, $truncation_status, $message_users) =\nget_message_infos(null, DEFAULT_NUMBER_PER_THREAD);\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Update threads that get_messages_since fetches messages from
By default it will now be threads that the viewer is a member of. There is also a `$watch_ids` parameter that can add additional threads to follow. |
129,187 | 14.11.2017 10:03:01 | 18,000 | adcbe8bf4af158c6e741a4d2ffb70e845d4523e0 | Update ping.php to handle `watch_ids` request param | [
{
"change_type": "MODIFY",
"old_path": "server/ping.php",
"new_path": "server/ping.php",
"diff": "@@ -26,19 +26,29 @@ if (\n));\n}\n+list($thread_infos, $thread_users) = get_thread_infos();\n+$watch_ids = isset($_POST['watch_ids']) ? $_POST['watch_ids'] : null;\n+\n$time = round(microtime(true) * 1000); // in milliseconds\n$message_users = array();\nif (isset($_POST['last_ping']) && $_POST['last_ping']) {\n$last_ping = (int)$_POST['last_ping'];\nlist($message_infos, $truncation_status, $message_users) =\n- get_messages_since($last_ping, DEFAULT_NUMBER_PER_THREAD, null);\n+ get_messages_since($last_ping, DEFAULT_NUMBER_PER_THREAD, $watch_ids);\n} else {\n+ $input = null;\n+ if (is_array($watch_ids) && $watch_ids) {\n+ $input = array_fill_keys($watch_ids, false);\n+ foreach ($thread_infos as $thread_info) {\n+ if ($thread_info['currentUser']['role'] !== null) {\n+ $input[$thread_info['id']] = false;\n+ }\n+ }\n+ }\nlist($message_infos, $truncation_status, $message_users) =\n- get_message_infos(null, DEFAULT_NUMBER_PER_THREAD);\n+ get_message_infos($input, DEFAULT_NUMBER_PER_THREAD);\n}\n-list($thread_infos, $thread_users) = get_thread_infos();\n-\n$return = array(\n'success' => true,\n'current_user_info' => $user_info,\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Update ping.php to handle `watch_ids` request param |
129,187 | 14.11.2017 11:54:04 | 18,000 | e309cc252e474c128cb437bf017ffb99f32a7930 | Have MessageList and ThreadSettings keep threadWatcher updated | [
{
"change_type": "MODIFY",
"old_path": "lib/shared/thread-watcher.js",
"new_path": "lib/shared/thread-watcher.js",
"diff": "@@ -7,10 +7,6 @@ class ThreadWatcher {\nwatchedIDs: Map<string, number> = new Map();\npendingRemovals: Map<string, number> = new Map();\n- initialize(watchedIDs: Map<string, number>) {\n- this.watchedIDs = watchedIDs;\n- }\n-\nwatchID(id: string) {\nthis.pendingRemovals.delete(id);\nconst currentCount = this.watchedIDs.get(id);\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/message-list.react.js",
"new_path": "native/chat/message-list.react.js",
"diff": "@@ -48,6 +48,8 @@ import {\nfetchMessages,\n} from 'lib/actions/message-actions';\nimport { messageType } from 'lib/types/message-types';\n+import threadWatcher from 'lib/shared/thread-watcher';\n+import { viewerIsMember } from 'lib/shared/thread-utils';\nimport { messageListData } from '../selectors/chat-selectors';\nimport { Message, messageItemHeight } from './message.react';\n@@ -176,10 +178,16 @@ class InnerMessageList extends React.PureComponent<Props, State> {\ncomponentDidMount() {\nregisterChatScreen(this.props.navigation.state.key, this);\n+ if (!viewerIsMember(this.props.threadInfo)) {\n+ threadWatcher.watchID(this.props.threadInfo.id);\n+ }\n}\ncomponentWillUnmount() {\nregisterChatScreen(this.props.navigation.state.key, null);\n+ if (!viewerIsMember(this.props.threadInfo)) {\n+ threadWatcher.removeID(this.props.threadInfo.id);\n+ }\n}\ncanReset = () => true;\n@@ -222,6 +230,18 @@ class InnerMessageList extends React.PureComponent<Props, State> {\n});\n}\n+ if (\n+ viewerIsMember(this.props.threadInfo) &&\n+ !viewerIsMember(nextProps.threadInfo)\n+ ) {\n+ threadWatcher.watchID(nextProps.threadInfo.id);\n+ } else if (\n+ !viewerIsMember(this.props.threadInfo) &&\n+ viewerIsMember(nextProps.threadInfo)\n+ ) {\n+ threadWatcher.removeID(nextProps.threadInfo.id);\n+ }\n+\nif (nextProps.listData === this.props.messageListData) {\nreturn;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/settings/thread-settings.react.js",
"new_path": "native/chat/settings/thread-settings.react.js",
"diff": "@@ -59,6 +59,7 @@ import {\nbindServerCalls,\n} from 'lib/utils/action-utils';\nimport { threadHasPermission, viewerIsMember } from 'lib/shared/thread-utils';\n+import threadWatcher from 'lib/shared/thread-watcher';\nimport ThreadSettingsCategory from './thread-settings-category.react';\nimport ColorSplotch from '../../components/color-splotch.react';\n@@ -166,13 +167,31 @@ class InnerThreadSettings extends React.PureComponent<Props, State> {\ncomponentDidMount() {\nregisterChatScreen(this.props.navigation.state.key, this);\n+ if (!viewerIsMember(this.props.threadInfo)) {\n+ threadWatcher.watchID(this.props.threadInfo.id);\n+ }\n}\ncomponentWillUnmount() {\nregisterChatScreen(this.props.navigation.state.key, null);\n+ if (!viewerIsMember(this.props.threadInfo)) {\n+ threadWatcher.removeID(this.props.threadInfo.id);\n+ }\n}\ncomponentWillReceiveProps(nextProps: Props) {\n+ if (\n+ viewerIsMember(this.props.threadInfo) &&\n+ !viewerIsMember(nextProps.threadInfo)\n+ ) {\n+ threadWatcher.watchID(nextProps.threadInfo.id);\n+ } else if (\n+ !viewerIsMember(this.props.threadInfo) &&\n+ viewerIsMember(nextProps.threadInfo)\n+ ) {\n+ threadWatcher.removeID(nextProps.threadInfo.id);\n+ }\n+\nif (\n!_isEqual(nextProps.threadInfo)\n(this.props.navigation.state.params.threadInfo)\n"
},
{
"change_type": "MODIFY",
"old_path": "native/navigation-setup.js",
"new_path": "native/navigation-setup.js",
"diff": "@@ -69,12 +69,7 @@ const navigateToAppActionType = \"NAVIGATE_TO_APP\";\nexport type Action = BaseAction |\nNavigationAction |\n{| type: typeof handleURLActionType, payload: string |} |\n- {| type: typeof navigateToAppActionType, payload: null |} |\n- {|\n- type: typeof NavigationActions.NAVIGATE,\n- routeName: typeof MessageListRouteName,\n- params: { threadInfo: ThreadInfo },\n- |};\n+ {| type: typeof navigateToAppActionType, payload: null |};\nconst AppNavigator = TabNavigator(\n{\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Have MessageList and ThreadSettings keep threadWatcher updated |
129,187 | 14.11.2017 21:49:54 | 18,000 | c2c729001acef75bd5a3b4dd27ab35806910a6ab | Introduce `$thread_selection_criteria` as a standard interface to message functions on backend | [
{
"change_type": "MODIFY",
"old_path": "server/fetch_messages.php",
"new_path": "server/fetch_messages.php",
"diff": "@@ -10,8 +10,17 @@ $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, $users) =\n- get_message_infos($input, $number_per_thread);\n+$thread_selection_criteria = array(\"thread_ids\" => $input);\n+$message_result = get_message_infos(\n+ $thread_selection_criteria,\n+ $number_per_thread\n+);\n+if (!$message_result) {\n+ async_end(array(\n+ 'error' => 'internal_error',\n+ ));\n+}\n+list($message_infos, $truncation_status, $users) = $message_result;\nasync_end(array(\n'success' => true,\n"
},
{
"change_type": "MODIFY",
"old_path": "server/index.php",
"new_path": "server/index.php",
"diff": "@@ -121,9 +121,16 @@ if (!$entry_result) {\nlist($entries, $entry_users) = $entry_result;\n$current_as_of = round(microtime(true) * 1000); // in milliseconds\n-list($message_infos, $truncation_status, $message_users) =\n- get_message_infos(null, DEFAULT_NUMBER_PER_THREAD);\n-\n+$thread_selection_criteria = array(\"joined_threads\" => true);\n+$message_result = get_message_infos(\n+ $thread_selection_criteria,\n+ DEFAULT_NUMBER_PER_THREAD\n+);\n+if (!$message_result) {\n+ header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error', true, 500);\n+ exit;\n+}\n+list($message_infos, $truncation_status, $message_users) = $message_result;\n$users = array_merge(\n$message_users,\n"
},
{
"change_type": "MODIFY",
"old_path": "server/join_thread.php",
"new_path": "server/join_thread.php",
"diff": "@@ -78,8 +78,17 @@ $message_info = array(\n);\ncreate_message_infos(array($message_info));\n-list($message_infos, $truncation_status, $message_users) =\n- get_message_infos(array($thread => false), DEFAULT_NUMBER_PER_THREAD);\n+$thread_selection_criteria = array(\"thread_ids\" => array($thread => false));\n+$message_result = get_message_infos(\n+ $thread_selection_criteria,\n+ DEFAULT_NUMBER_PER_THREAD\n+);\n+if (!$message_result) {\n+ async_end(array(\n+ 'error' => 'internal_error',\n+ ));\n+}\n+list($message_infos, $truncation_status, $message_users) = $message_result;\nlist($thread_infos, $thread_users) = get_thread_infos();\n"
},
{
"change_type": "MODIFY",
"old_path": "server/login.php",
"new_path": "server/login.php",
"diff": "@@ -46,8 +46,17 @@ $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, $message_users) =\n- get_message_infos(null, DEFAULT_NUMBER_PER_THREAD);\n+$thread_selection_criteria = array(\"joined_threads\" => true);\n+$message_result = get_message_infos(\n+ $thread_selection_criteria,\n+ DEFAULT_NUMBER_PER_THREAD\n+);\n+if (!$message_result) {\n+ async_end(array(\n+ 'error' => 'internal_error',\n+ ));\n+}\n+list($message_infos, $truncation_status, $message_users) = $message_result;\n$return = array(\n'success' => true,\n"
},
{
"change_type": "MODIFY",
"old_path": "server/message_lib.php",
"new_path": "server/message_lib.php",
"diff": "@@ -34,24 +34,31 @@ define(\"TRUNCATION_TRUNCATED\", \"truncated\");\ndefine(\"TRUNCATION_UNCHANGED\", \"unchanged\");\ndefine(\"TRUNCATION_EXHAUSTIVE\", \"exhaustive\");\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+// WARNING: input not sanitized!\n+// Parses raw input from the client specifying which threads we want messages\n+// from, and returns a SQL clause for querying on those threads.\n+// Two keys:\n+// - joined_threads: bool\n+// whether to include all the threads that the viewer is a member of\n+// - thread_ids: array<string, false | string>\n+// the keys of this array are thread IDs. the values are the IDs of the\n+// 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 a member of. This\n-// function returns:\n-// - An array of MessageInfos\n-// - An array that points from threadID to truncation status (see definition of\n-// TRUNCATION_ constants)\n-// - An array of user IDs pointing to UserInfo objects for all referenced users\n-function get_message_infos($input, $number_per_thread) {\n- global $conn;\n-\n- if (is_array($input) && $input) {\n+// message ID as the \"cursor\" for paging. if the value is falsey, we will\n+// simply fetch the very newest $number_per_thread from that thread.\n+function thread_selection_criteria_to_sql_clause($thread_selection_criteria) {\n+ if (!is_array($thread_selection_criteria) || !$thread_selection_criteria) {\n+ return null;\n+ }\n$conditions = array();\n- foreach ($input as $thread => $cursor) {\n+ if (!empty($thread_selection_criteria['joined_threads'])) {\n+ $conditions[] = \"r.roletype != 0\";\n+ }\n+ if (\n+ !empty($thread_selection_criteria['thread_ids']) &&\n+ is_array($thread_selection_criteria['thread_ids'])\n+ ) {\n+ foreach ($thread_selection_criteria['thread_ids'] as $thread => $cursor) {\n$int_thread = (int)$thread;\nif ($cursor) {\n$int_cursor = (int)$cursor;\n@@ -60,11 +67,53 @@ function get_message_infos($input, $number_per_thread) {\n$conditions[] = \"m.thread = $int_thread\";\n}\n}\n- $additional_condition = \"(\".implode(\" OR \", $conditions).\")\";\n- } else {\n- $additional_condition = \"r.roletype != 0\";\n+ }\n+ if (!$conditions) {\n+ return null;\n+ }\n+ return \"(\".implode(\" OR \", $conditions).\")\";\n+}\n+\n+// Same input as above. Returns initial truncation status\n+function thread_selection_criteria_to_initial_truncation_status(\n+ $thread_selection_criteria,\n+ $default_truncation_status\n+) {\n+ $truncation_status = array();\n+ if (\n+ !empty($thread_selection_criteria['thread_ids']) &&\n+ is_array($thread_selection_criteria['thread_ids'])\n+ ) {\n+ $thread_ids = array_keys($thread_selection_criteria['thread_ids']);\n+ foreach ($thread_ids as $thread_id) {\n+ $cast_thread_id = strval((int)$thread_id);\n+ $truncation_status[$cast_thread_id] = $default_truncation_status;\n+ }\n+ }\n+ return $truncation_status;\n}\n+// This function will fetch the newest $number_per_thread messages from each of\n+// the threads specified by $thread_selection_criteria.\n+// This function returns:\n+// - An array of MessageInfos\n+// - An array that points from threadID to truncation status (see definition of\n+// TRUNCATION_ constants)\n+// - An array of user IDs pointing to UserInfo objects for all referenced users\n+function get_message_infos($thread_selection_criteria, $number_per_thread) {\n+ global $conn;\n+\n+ $thread_selection = thread_selection_criteria_to_sql_clause(\n+ $thread_selection_criteria\n+ );\n+ if (!$thread_selection) {\n+ return null;\n+ }\n+ $truncation_status = thread_selection_criteria_to_initial_truncation_status(\n+ $thread_selection_criteria,\n+ TRUNCATION_EXHAUSTIVE\n+ );\n+\n$viewer_id = get_viewer_id();\n$visibility_open = VISIBILITY_OPEN;\n$visibility_nested_open = VISIBILITY_NESTED_OPEN;\n@@ -81,7 +130,7 @@ FROM (\nLEFT JOIN threads t ON t.id = m.thread\nLEFT JOIN roles r ON r.thread = m.thread AND r.user = {$viewer_id}\nWHERE (r.visible = 1 OR t.visibility_rules = {$visibility_open})\n- AND {$additional_condition}\n+ AND {$thread_selection}\nORDER BY m.thread, m.time DESC\n) x\nLEFT JOIN users u ON u.id = x.user\n@@ -113,20 +162,11 @@ SQL;\n}\n}\n- $truncation_status = array();\nforeach ($thread_to_message_count as $thread_id => $message_count) {\n$truncation_status[$thread_id] = $message_count < $int_number_per_thread\n? TRUNCATION_EXHAUSTIVE\n: TRUNCATION_TRUNCATED;\n}\n- if (is_array($input) && $input) {\n- foreach ($input as $thread => $cursor) {\n- $int_thread = (int)$thread;\n- if (!isset($truncation_status[(string)$int_thread])) {\n- $truncation_status[(string)$int_thread] = TRUNCATION_EXHAUSTIVE;\n- }\n- }\n- }\n$all_users = get_all_users($messages, $users);\n@@ -137,33 +177,29 @@ SQL;\n// this one is used to keep a session updated. You give it a timestamp, and it\n// fetches all of the messages with a newer timestamp. If for a given thread\n// more than $max_number_per_thread messages have been sent since $current_as_of\n-// then the most recent $current_as_of will be returned. If $watched_ids is\n-// falsey we'll only return messages from the threads the viewer is a member of.\n-// If specified, we'll also return messages from the specified threads. Note\n-// that this behavior is additive, whereas get_message_infos will only return\n-// messages from the thread IDs that key $input if it is specified. This\n-// function returns:\n+// then the most recent $current_as_of will be returned.\n+// This function returns:\n// - An array of MessageInfos\n// - An array that points from threadID to truncation status (see definition of\n// TRUNCATION_ constants)\n// - An array of user IDs pointing to UserInfo objects for all referenced users\nfunction get_messages_since(\n+ $thread_selection_criteria,\n$current_as_of,\n- $max_number_per_thread,\n- $watched_ids\n+ $max_number_per_thread\n) {\nglobal $conn;\n- if (is_array($watched_ids) && $watched_ids) {\n- $conditions = array(\"r.roletype != 0\");\n- foreach ($watched_ids as $watched_id) {\n- $thread_id = (int)$watched_id;\n- $conditions[] = \"m.thread = $thread_id\";\n- }\n- $additional_condition = \"(\".implode(\" OR \", $conditions).\")\";\n- } else {\n- $additional_condition = \"r.roletype != 0\";\n+ $thread_selection = thread_selection_criteria_to_sql_clause(\n+ $thread_selection_criteria\n+ );\n+ if (!$thread_selection) {\n+ return null;\n}\n+ $truncation_status = thread_selection_criteria_to_initial_truncation_status(\n+ $thread_selection_criteria,\n+ TRUNCATION_UNCHANGED\n+ );\n$viewer_id = get_viewer_id();\n$visibility_open = VISIBILITY_OPEN;\n@@ -177,7 +213,7 @@ LEFT JOIN roles r ON r.thread = m.thread AND r.user = {$viewer_id}\nLEFT JOIN users u ON u.id = m.user\nWHERE (r.visible = 1 OR t.visibility_rules = {$visibility_open})\nAND m.time > {$current_as_of}\n- AND {$additional_condition}\n+ AND {$thread_selection}\nORDER BY m.thread, m.time DESC\nSQL;\n$result = $conn->query($query);\n@@ -186,7 +222,6 @@ SQL;\n$num_for_thread = 0;\n$messages = array();\n$users = array();\n- $truncation_status = array();\nwhile ($row = $result->fetch_assoc()) {\n$thread = $row[\"threadID\"];\nif ($thread !== $current_thread) {\n@@ -214,15 +249,6 @@ SQL;\n}\n}\n- if (is_array($watched_ids) && $watched_ids) {\n- foreach ($watched_ids as $watched_id) {\n- $thread_id = (int)$watched_id;\n- if (!isset($truncation_status[(string)$thread_id])) {\n- $truncation_status[(string)$thread_id] = TRUNCATION_UNCHANGED;\n- }\n- }\n- }\n-\n$all_users = get_all_users($messages, $users);\nreturn array($messages, $truncation_status, $all_users);\n"
},
{
"change_type": "MODIFY",
"old_path": "server/ping.php",
"new_path": "server/ping.php",
"diff": "@@ -26,28 +26,35 @@ if (\n));\n}\n-list($thread_infos, $thread_users) = get_thread_infos();\n+$current_as_of = round(microtime(true) * 1000); // in milliseconds\n$watched_ids = isset($_POST['watched_ids']) ? $_POST['watched_ids'] : null;\n+$thread_selection_criteria = array(\n+ \"joined_threads\" => true,\n+ \"thread_ids\" => array_fill_keys($watched_ids, false),\n+);\n-$time = round(microtime(true) * 1000); // in milliseconds\n$message_users = array();\nif (isset($_POST['last_ping']) && $_POST['last_ping']) {\n$last_ping = (int)$_POST['last_ping'];\n- list($message_infos, $truncation_status, $message_users) =\n- get_messages_since($last_ping, DEFAULT_NUMBER_PER_THREAD, $watched_ids);\n+ $result = get_messages_since(\n+ $thread_selection_criteria,\n+ $last_ping,\n+ DEFAULT_NUMBER_PER_THREAD\n+ );\n} else {\n- $input = null;\n- if (is_array($watched_ids) && $watched_ids) {\n- $input = array_fill_keys($watched_ids, false);\n- foreach ($thread_infos as $thread_info) {\n- if ($thread_info['currentUser']['role'] !== null) {\n- $input[$thread_info['id']] = false;\n- }\n- }\n+ $result = get_message_infos(\n+ $thread_selection_criteria,\n+ DEFAULT_NUMBER_PER_THREAD\n+ );\n}\n- list($message_infos, $truncation_status, $message_users) =\n- get_message_infos($input, DEFAULT_NUMBER_PER_THREAD);\n+if (!$result) {\n+ async_end(array(\n+ 'error' => 'internal_error',\n+ ));\n}\n+list($message_infos, $truncation_status, $message_users) = $result;\n+\n+list($thread_infos, $thread_users) = get_thread_infos();\n$return = array(\n'success' => true,\n@@ -58,7 +65,7 @@ $return = array(\n);\nif (isset($_POST['last_ping'])) {\n- $return['server_time'] = $time;\n+ $return['server_time'] = $current_as_of;\n}\n$entry_users = array();\n"
},
{
"change_type": "MODIFY",
"old_path": "server/reset_password.php",
"new_path": "server/reset_password.php",
"diff": "@@ -65,8 +65,17 @@ 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, $message_users) =\n- get_message_infos(null, DEFAULT_NUMBER_PER_THREAD);\n+$thread_selection_criteria = array(\"joined_threads\" => true);\n+$message_result = get_message_infos(\n+ $thread_selection_criteria,\n+ DEFAULT_NUMBER_PER_THREAD\n+);\n+if (!$message_result) {\n+ async_end(array(\n+ 'error' => 'internal_error',\n+ ));\n+}\n+list($message_infos, $truncation_status, $message_users) = $message_result;\n$return = array(\n'success' => true,\n"
},
{
"change_type": "MODIFY",
"old_path": "server/subscribe.php",
"new_path": "server/subscribe.php",
"diff": "@@ -59,8 +59,17 @@ SQL;\n);\ncreate_message_infos(array($message_info));\n- list($message_infos, $truncation_status, $message_users) =\n- get_message_infos(array($thread => false), DEFAULT_NUMBER_PER_THREAD);\n+ $thread_selection_criteria = array(\"thread_ids\" => array($thread => false));\n+ $message_result = get_message_infos(\n+ $thread_selection_criteria,\n+ DEFAULT_NUMBER_PER_THREAD\n+ );\n+ if (!$message_result) {\n+ async_end(array(\n+ 'error' => 'internal_error',\n+ ));\n+ }\n+ list($message_infos, $truncation_status, $message_users) = $message_result;\n}\nlist($thread_infos, $thread_users) = get_thread_infos();\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Introduce `$thread_selection_criteria` as a standard interface to message functions on backend |
129,187 | 15.11.2017 18:10:20 | 18,000 | 843ca054552b6a67c5fc714a64070f2e255b7dbd | Extract removeScreensFromStack from removeModals for use in other places | [
{
"change_type": "MODIFY",
"old_path": "native/navigation-setup.js",
"new_path": "native/navigation-setup.js",
"diff": "@@ -8,6 +8,7 @@ import type {\nNavigationScreenProp,\nNavigationAction,\nNavigationRouter,\n+ NavigationRoute,\n} from 'react-navigation/src/TypeDefinition';\nimport type { PingSuccessPayload } from 'lib/types/ping-types';\nimport type { AppState } from './redux-setup';\n@@ -194,6 +195,7 @@ const defaultNavInfo: NavInfo = {\nnavigationState: defaultNavigationState,\n};\n+const accountModals = [ LoggedOutModalRouteName, VerificationModalRouteName ];\nfunction reduceNavInfo(state: NavInfo, action: *): NavInfo {\n// React Navigation actions\nconst navigationState = RootNavigator.router.getStateForAction(\n@@ -228,7 +230,7 @@ function reduceNavInfo(state: NavInfo, action: *): NavInfo {\nendDate: state.endDate,\nhome: state.home,\nthreadID: state.threadID,\n- navigationState: removeModals(state.navigationState),\n+ navigationState: removeModals(state.navigationState, accountModals),\n};\n} else if (\naction.type === logOutActionTypes.started ||\n@@ -294,29 +296,60 @@ function handleURL(\n};\n}\n-function removeModals(\n- state: NavigationState,\n- modalRouteNames: string[]\n- = [LoggedOutModalRouteName, VerificationModalRouteName],\n-): NavigationState {\n+// This function walks from the back of the stack and calls filterFunc on each\n+// screen until the stack is exhausted or filterFunc returns \"break\". A screen\n+// will be removed if and only if filterFunc returns \"remove\" (not \"break\").\n+function removeScreensFromStack<S: NavigationState>(\n+ state: S,\n+ filterFunc: (route: NavigationRoute) => \"keep\" | \"remove\" | \"break\",\n+): S {\nconst newRoutes = [];\n- let index = state.index;\n- for (let i = 0; i < state.routes.length; i++) {\n+ let newIndex = state.index;\n+ let screenRemoved = false;\n+ let breakActivated = false;\n+ for (let i = state.routes.length - 1; i >= 0; i--) {\nconst route = state.routes[i];\n- if (_includes(route.routeName)(modalRouteNames)) {\n- if (i <= state.index) {\n- invariant(index !== 0, 'Attempting to remove only route');\n- index--;\n+ if (breakActivated) {\n+ newRoutes.unshift(route);\n+ continue;\n+ }\n+ const result = filterFunc(route);\n+ if (result === \"break\") {\n+ breakActivated = true;\n}\n- } else {\n- newRoutes.push(route);\n+ if (breakActivated || result === \"keep\") {\n+ newRoutes.unshift(route);\n+ continue;\n}\n+ screenRemoved = true;\n+ if (newIndex >= i) {\n+ invariant(\n+ newIndex !== 0,\n+ 'Attempting to remove current route and all before it',\n+ );\n+ newIndex--;\n}\n- if (newRoutes.length === state.routes.length) {\n+ }\n+ if (!screenRemoved) {\nreturn state;\n- } else {\n- return { index, routes: newRoutes };\n}\n+ return {\n+ ...state,\n+ index: newIndex,\n+ routes: newRoutes,\n+ };\n+}\n+\n+function removeModals(\n+ state: NavigationState,\n+ modalRouteNames: string[],\n+): NavigationState {\n+ return removeScreensFromStack(\n+ state,\n+ (route: NavigationRoute) => _includes(route.routeName)(modalRouteNames)\n+ ? \"remove\"\n+ : \"keep\",\n+ );\n}\nfunction resetNavInfoAndEnsureLoggedOutModalPresence(state: NavInfo): NavInfo {\n@@ -383,6 +416,7 @@ function logOutIfCookieInvalidated(\nreturn state;\n}\n+const justLoggedOutModal = [ LoggedOutModalRouteName ];\nfunction removeModalsIfPingIndicatesLoggedIn(\nstate: NavigationState,\npayload: PingSuccessPayload,\n@@ -393,7 +427,7 @@ function removeModalsIfPingIndicatesLoggedIn(\n// handling specific log ins that occur from LoggedOutModal.\nreturn state;\n}\n- return removeModals(state, [LoggedOutModalRouteName]);\n+ return removeModals(state, justLoggedOutModal);\n}\nexport {\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Extract removeScreensFromStack from removeModals for use in other places |
129,187 | 15.11.2017 19:26:22 | 18,000 | 7ead88a620be8cf8aff66255a4faa4de9f794484 | Fix bug where height for robotext messages was undefined
This was causing a lot of weirdness, took a bit of time to track down... | [
{
"change_type": "MODIFY",
"old_path": "native/chat/message-list.react.js",
"new_path": "native/chat/message-list.react.js",
"diff": "@@ -414,8 +414,6 @@ class InnerMessageList extends React.PureComponent<Props, State> {\nconst listDataWithHeights = this.state.listDataWithHeights;\nlet flatList = null;\nif (listDataWithHeights) {\n- // We add a small padding at the top of the list if the loading spinner\n- // isn't there\nconst footer = this.props.startReached\n? InnerMessageList.ListFooterComponent\n: undefined;\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/robotext-message.react.js",
"new_path": "native/chat/robotext-message.react.js",
"diff": "@@ -27,7 +27,7 @@ function robotextMessageItemHeight(\nitem: ChatMessageInfoItemWithHeight,\nviewerID: ?string,\n) {\n- let height = 17 + item.textHeight; // for padding, margin, and text\n+ return 17 + item.textHeight; // for padding, margin, and text\n}\ntype Props = {\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Fix bug where height for robotext messages was undefined
This was causing a lot of weirdness, took a bit of time to track down... |
129,187 | 15.11.2017 19:39:19 | 18,000 | 0947678fe5a1caa7d689f07137888273b5d5f34a | Call filterChatScreensForThreadInfos whenever threadInfos might get smaller
The only except is `deleteThreadActionTypes`, which isn't actually used in native yet. | [
{
"change_type": "MODIFY",
"old_path": "lib/reducers/thread-reducer.js",
"new_path": "lib/reducers/thread-reducer.js",
"diff": "@@ -33,13 +33,7 @@ export default function reduceThreadInfos(\n): {[id: string]: ThreadInfo} {\nif (\naction.type === logOutActionTypes.success ||\n- action.type === deleteAccountActionTypes.success\n- ) {\n- if (_isEqual(state)(action.payload.threadInfos)) {\n- return state;\n- }\n- return action.payload.threadInfos;\n- } else if (\n+ action.type === deleteAccountActionTypes.success ||\naction.type === logInActionTypes.success ||\naction.type === resetPasswordActionTypes.success ||\naction.type === pingActionTypes.success ||\n"
},
{
"change_type": "MODIFY",
"old_path": "native/navigation-setup.js",
"new_path": "native/navigation-setup.js",
"diff": "@@ -35,9 +35,14 @@ import {\ndeleteAccountActionTypes,\nlogInActionTypes,\nregisterActionTypes,\n+ resetPasswordActionTypes,\n} from 'lib/actions/user-actions';\nimport { pingActionTypes } from 'lib/actions/ping-actions';\n-import { leaveThreadActionTypes } from 'lib/actions/thread-actions';\n+import {\n+ leaveThreadActionTypes,\n+ joinThreadActionTypes,\n+ subscribeActionTypes,\n+} from 'lib/actions/thread-actions';\nimport {\nCalendar,\n@@ -214,6 +219,32 @@ function reduceNavInfo(state: NavInfo, action: *): NavInfo {\nnavigationState,\n};\n}\n+ // Filtering out screens corresponding to deauthorized threads\n+ if (\n+ action.type === logOutActionTypes.success ||\n+ action.type === deleteAccountActionTypes.success ||\n+ action.type === logInActionTypes.success ||\n+ action.type === resetPasswordActionTypes.success ||\n+ action.type === pingActionTypes.success ||\n+ action.type === joinThreadActionTypes.success ||\n+ action.type === leaveThreadActionTypes.success ||\n+ action.type === subscribeActionTypes.success ||\n+ action.type === setCookieActionType\n+ ) {\n+ const filteredNavigationState = filterChatScreensForThreadInfos(\n+ state.navigationState,\n+ action.payload.threadInfos,\n+ );\n+ if (state.navigationState !== filteredNavigationState) {\n+ state = {\n+ startDate: state.startDate,\n+ endDate: state.endDate,\n+ home: state.home,\n+ threadID: state.threadID,\n+ navigationState: filteredNavigationState,\n+ };\n+ }\n+ }\n// Deep linking\nif (action.type === handleURLActionType) {\nreturn {\n@@ -260,10 +291,7 @@ function reduceNavInfo(state: NavInfo, action: *): NavInfo {\nhome: state.home,\nthreadID: state.threadID,\nnavigationState: popChatScreensForThreadID(\n- filterChatScreensForThreadInfos(\nstate.navigationState,\n- action.payload.threadInfos,\n- ),\naction.payload.threadID,\n),\n};\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Call filterChatScreensForThreadInfos whenever threadInfos might get smaller
The only except is `deleteThreadActionTypes`, which isn't actually used in native yet. |
129,187 | 15.11.2017 19:54:13 | 18,000 | f3c0db1b43b42a2eb33520f21f4ad389b7511710 | Make sure to set MessageList's loadingFromScroll to false after new results are rendered
Apparently I missed a lot of bugs when I originally built chat... | [
{
"change_type": "MODIFY",
"old_path": "native/chat/message-list.react.js",
"new_path": "native/chat/message-list.react.js",
"diff": "@@ -368,6 +368,19 @@ class InnerMessageList extends React.PureComponent<Props, State> {\n}\n}\n+ componentDidUpdate(prevProps: Props, prevState: State) {\n+ if (!this.state.listDataWithHeights) {\n+ return;\n+ }\n+ if (\n+ !prevState.listDataWithHeights ||\n+ this.state.listDataWithHeights.length >\n+ prevState.listDataWithHeights.length\n+ ) {\n+ this.loadingFromScroll = false;\n+ }\n+ }\n+\nstatic keyExtractor(item: ChatMessageItemWithHeight) {\nif (item.itemType === \"loader\") {\nreturn \"loader\";\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Make sure to set MessageList's loadingFromScroll to false after new results are rendered
Apparently I missed a lot of bugs when I originally built chat... |
129,187 | 15.11.2017 20:44:07 | 18,000 | d9fdcfca63424439974dbb957b523fa3cd02c7ea | Delay autofocus for new entries
For some weird af reason, `TextInput` is blurring immediately after an autofocus. I can't figure out why. This "fixes" the problem. | [
{
"change_type": "MODIFY",
"old_path": "native/calendar/entry.react.js",
"new_path": "native/calendar/entry.react.js",
"diff": "@@ -276,7 +276,6 @@ class Entry extends React.Component<Props, State> {\nonBlur={this.onBlur}\nonFocus={this.onFocus}\nonContentSizeChange={this.onContentSizeChange}\n- autoFocus={focused}\nref={this.textInputRef}\n/>\n);\n@@ -320,6 +319,9 @@ class Entry extends React.Component<Props, State> {\ntextInputRef = (textInput: ?TextInput) => {\nthis.textInput = textInput;\n+ if (textInput && Entry.isFocused(this.props)) {\n+ setTimeout(textInput.focus, 400);\n+ }\n}\nonFocus = () => this.props.onFocus(entryKey(this.props.entryInfo), true);\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Delay autofocus for new entries
For some weird af reason, `TextInput` is blurring immediately after an autofocus. I can't figure out why. This "fixes" the problem. |
129,187 | 16.11.2017 11:36:06 | 28,800 | 6c76d3918287e54be57aa2c494e1aae4a7bd5f7b | Set MessageList.loadingFromScroll to false when startReached = true | [
{
"change_type": "MODIFY",
"old_path": "native/chat/message-list.react.js",
"new_path": "native/chat/message-list.react.js",
"diff": "@@ -369,13 +369,14 @@ class InnerMessageList extends React.PureComponent<Props, State> {\n}\ncomponentDidUpdate(prevProps: Props, prevState: State) {\n- if (!this.state.listDataWithHeights) {\n+ if (!this.loadingFromScroll || !this.state.listDataWithHeights) {\nreturn;\n}\nif (\n!prevState.listDataWithHeights ||\nthis.state.listDataWithHeights.length >\n- prevState.listDataWithHeights.length\n+ prevState.listDataWithHeights.length ||\n+ this.props.startReached\n) {\nthis.loadingFromScroll = false;\n}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Set MessageList.loadingFromScroll to false when startReached = true |
129,187 | 16.11.2017 15:47:38 | 28,800 | 44f2d46700714dc190c4f6d5f10885184fe2b2f6 | Only pop the settings panel when leaving a thread you can still see | [
{
"change_type": "MODIFY",
"old_path": "native/navigation-setup.js",
"new_path": "native/navigation-setup.js",
"diff": "@@ -13,6 +13,7 @@ import type {\nimport type { PingSuccessPayload } from 'lib/types/ping-types';\nimport type { AppState } from './redux-setup';\nimport type { SetCookiePayload } from 'lib/utils/action-utils';\n+import type { LeaveThreadResult } from 'lib/actions/thread-actions';\nimport {\nTabNavigator,\n@@ -292,7 +293,7 @@ function reduceNavInfo(state: NavInfo, action: *): NavInfo {\nthreadID: state.threadID,\nnavigationState: popChatScreensForThreadID(\nstate.navigationState,\n- action.payload.threadID,\n+ action.payload,\n),\n};\n}\n@@ -477,7 +478,7 @@ function removeModalsIfPingIndicatesLoggedIn(\nfunction popChatScreensForThreadID(\nstate: NavigationState,\n- threadID: string,\n+ actionPayload: LeaveThreadResult,\n): NavigationState {\nconst appRoute = assertNavigationRouteNotLeafNode(state.routes[0]);\nconst chatRoute = assertNavigationRouteNotLeafNode(appRoute.routes[1]);\n@@ -486,8 +487,10 @@ function popChatScreensForThreadID(\nchatRoute,\n(route: NavigationRoute) => {\nif (\n- route.routeName !== MessageListRouteName &&\n- route.routeName !== ThreadSettingsRouteName\n+ (route.routeName !== MessageListRouteName &&\n+ route.routeName !== ThreadSettingsRouteName) ||\n+ (route.routeName === MessageListRouteName &&\n+ !!actionPayload.threadInfos[actionPayload.threadID])\n) {\nreturn \"break\";\n}\n@@ -496,7 +499,7 @@ function popChatScreensForThreadID(\nparams && params.threadInfo && typeof params.threadInfo.id === \"string\",\n\"params should have ThreadInfo\",\n);\n- if (params.threadInfo.id !== threadID) {\n+ if (params.threadInfo.id !== actionPayload.threadID) {\nreturn \"break\";\n}\nreturn \"remove\";\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Only pop the settings panel when leaving a thread you can still see |
129,187 | 16.11.2017 15:49:55 | 28,800 | 32769bea291b08a7ccf8ef47e6f74ffdbaa35942 | Prepare for an attempt to remove descendant_voiced from admins | [
{
"change_type": "MODIFY",
"old_path": "server/scripts/add_permission_types.php",
"new_path": "server/scripts/add_permission_types.php",
"diff": "@@ -37,10 +37,7 @@ while ($row = $results->fetch_assoc()) {\necho \"Total thread count: \" . count($parents_to_children) . \"\\n\";\n$new_permissions = array(\n- PERMISSION_REMOVE_MEMBERS => true,\n- PERMISSION_CHANGE_ROLE => true,\n- PERMISSION_PREFIX_DESCENDANT . PERMISSION_REMOVE_MEMBERS => true,\n- PERMISSION_PREFIX_DESCENDANT . PERMISSION_CHANGE_ROLE => true,\n+ PERMISSION_PREFIX_DESCENDANT . PERMISSION_VOICED => false,\n);\nwhile ($parents_to_children) {\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Prepare for an attempt to remove descendant_voiced from admins |
129,187 | 20.11.2017 17:41:18 | 28,800 | 9ffee26a1e9af4c563516b2e38a2807417e1e0d6 | Avoid PHP warning when watched_ids is null | [
{
"change_type": "MODIFY",
"old_path": "server/login.php",
"new_path": "server/login.php",
"diff": "@@ -46,7 +46,9 @@ $id = intval($user_row['id']);\ncreate_user_cookie($id);\n$current_as_of = round(microtime(true) * 1000); // in milliseconds\n-$watched_ids = isset($_POST['watched_ids']) ? $_POST['watched_ids'] : null;\n+$watched_ids = !empty($_POST['watched_ids']) && is_array($_POST['watched_ids'])\n+ ? $_POST['watched_ids']\n+ : array();\n$thread_selection_criteria = array(\n\"joined_threads\" => true,\n\"thread_ids\" => array_fill_keys($watched_ids, false),\n"
},
{
"change_type": "MODIFY",
"old_path": "server/ping.php",
"new_path": "server/ping.php",
"diff": "@@ -27,7 +27,9 @@ if (\n}\n$current_as_of = round(microtime(true) * 1000); // in milliseconds\n-$watched_ids = isset($_POST['watched_ids']) ? $_POST['watched_ids'] : null;\n+$watched_ids = !empty($_POST['watched_ids']) && is_array($_POST['watched_ids'])\n+ ? $_POST['watched_ids']\n+ : array();\n$thread_selection_criteria = array(\n\"joined_threads\" => true,\n\"thread_ids\" => array_fill_keys($watched_ids, false),\n"
},
{
"change_type": "MODIFY",
"old_path": "server/reset_password.php",
"new_path": "server/reset_password.php",
"diff": "@@ -65,7 +65,9 @@ create_user_cookie($user);\nclear_verify_codes($user, VERIFY_FIELD_RESET_PASSWORD);\n$current_as_of = round(microtime(true) * 1000); // in milliseconds\n-$watched_ids = isset($_POST['watched_ids']) ? $_POST['watched_ids'] : null;\n+$watched_ids = !empty($_POST['watched_ids']) && is_array($_POST['watched_ids'])\n+ ? $_POST['watched_ids']\n+ : array();\n$thread_selection_criteria = array(\n\"joined_threads\" => true,\n\"thread_ids\" => array_fill_keys($watched_ids, false),\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Avoid PHP warning when watched_ids is null |
129,187 | 22.11.2017 00:27:41 | 28,800 | 573abc91511997acf9e1130e5998b55d82dc614c | Silence react-navigation Redux integration Flow error with NavigationScreenProp<any> | [
{
"change_type": "MODIFY",
"old_path": "native/app.react.js",
"new_path": "native/app.react.js",
"diff": "import type {\nNavigationState,\nPossiblyDeprecatedNavigationAction,\n+ NavigationScreenProp,\n} from 'react-navigation/src/TypeDefinition';\nimport type { Dispatch } from 'lib/types/redux-types';\nimport type { AppState } from './redux-setup';\n@@ -198,7 +199,7 @@ class AppWithNavigationState extends React.PureComponent<Props> {\n}\nrender() {\n- const navigation = addNavigationHelpers({\n+ const navigation: NavigationScreenProp<any> = addNavigationHelpers({\ndispatch: this.props.dispatch,\nstate: this.props.navigationState,\n});\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Silence react-navigation Redux integration Flow error with NavigationScreenProp<any> |
129,187 | 22.11.2017 00:28:12 | 28,800 | 6a2e207897461a63c5556adb97cb825c9dce6332 | Update to latest redux-persist 4 to get rid of Flow error
Tried redux-persist 5 but it has all these weird Flow errors... | [
{
"change_type": "MODIFY",
"old_path": "native/package-lock.json",
"new_path": "native/package-lock.json",
"diff": "\"integrity\": \"sha1-4Pmo6N/KfBe+kscSSVijuU6ykR0=\"\n},\n\"redux-persist\": {\n- \"version\": \"4.9.1\",\n- \"resolved\": \"https://registry.npmjs.org/redux-persist/-/redux-persist-4.9.1.tgz\",\n- \"integrity\": \"sha512-XoOmfPyo9GEU/WLH9FgB47dNIN9l5ArjHes4o7vUWx9nxZoPxnVodhuHdyc4Ot+fMkdj3L2LTqSHhwrkr0QFUg==\",\n+ \"version\": \"4.10.2\",\n+ \"resolved\": \"https://registry.npmjs.org/redux-persist/-/redux-persist-4.10.2.tgz\",\n+ \"integrity\": \"sha512-U+e0ieMGC69Zr72929iJW40dEld7Mflh6mu0eJtVMLGfMq/aJqjxUM1hzyUWMR1VUyAEEdPHuQmeq5ti9krIgg==\",\n\"requires\": {\n\"json-stringify-safe\": \"5.0.1\",\n\"lodash\": \"4.17.4\",\n"
},
{
"change_type": "MODIFY",
"old_path": "native/package.json",
"new_path": "native/package.json",
"diff": "\"react-redux\": \"^5.0.6\",\n\"redux\": \"^3.7.2\",\n\"redux-devtools-extension\": \"^2.13.2\",\n- \"redux-persist\": \"^4.9.1\",\n+ \"redux-persist\": \"^4.10.2\",\n\"redux-thunk\": \"^2.2.0\",\n\"reselect\": \"^3.0.1\",\n\"shallowequal\": \"^1.0.2\",\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Update to latest redux-persist 4 to get rid of Flow error
Tried redux-persist 5 but it has all these weird Flow errors... |
129,187 | 22.11.2017 23:11:06 | -32,400 | 71d253291a418c6be01f40aff7e20e7c9747e162 | Update to latest react-navigation fixflow branch | [
{
"change_type": "MODIFY",
"old_path": "native/package-lock.json",
"new_path": "native/package-lock.json",
"diff": "}\n},\n\"react-navigation\": {\n- \"version\": \"1.0.0-beta.20\",\n- \"resolved\": \"https://registry.npmjs.org/react-navigation/-/react-navigation-1.0.0-beta.20.tgz\",\n- \"integrity\": \"sha512-7oLq+3M0lCNUmrJK7gMAgmdM+ojK20P9djxlKROxn7xIF7KwZUsaeI8ANED7obvy0opS4t+b7hRx31WE2eZVCQ==\",\n+ \"version\": \"git://github.com/react-community/react-navigation.git#24631e300eb0c41f37f91d7d28003e7674cb5b48\",\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-popover-tooltip\": \"^1.1.4\",\n\"react-native-segmented-control-tab\": \"^3.2.1\",\n\"react-native-vector-icons\": \"^4.3.0\",\n- \"react-navigation\": \"^1.0.0-beta.20\",\n+ \"react-navigation\": \"git://github.com/react-community/react-navigation.git#fixflow\",\n\"react-redux\": \"^5.0.6\",\n\"redux\": \"^3.7.2\",\n\"redux-devtools-extension\": \"^2.13.2\",\n"
},
{
"change_type": "MODIFY",
"old_path": "native/redux-setup.js",
"new_path": "native/redux-setup.js",
"diff": "@@ -25,7 +25,6 @@ import { MessageListRouteName } from './chat/message-list.react';\nimport {\nhandleURLActionType,\nnavigateToAppActionType,\n- RootNavigator,\ndefaultNavInfo,\nreduceNavInfo,\n} from './navigation-setup';\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Update to latest react-navigation fixflow branch |
129,187 | 23.11.2017 16:59:42 | -32,400 | f79aa941b14c54c8a8fb58807de2ff22e1fc5686 | Forgot to convert a couple "r"s to "m"s in thread_lib.php | [
{
"change_type": "MODIFY",
"old_path": "server/thread_lib.php",
"new_path": "server/thread_lib.php",
"diff": "@@ -35,9 +35,9 @@ LEFT JOIN (\nFROM threads\n) r ON r.thread = t.id\nLEFT JOIN memberships m ON m.role = r.id AND m.thread = t.id\n-LEFT JOIN users u ON u.id = r.user\n+LEFT JOIN users u ON u.id = m.user\n{$where_clause}\n-ORDER BY r.user ASC\n+ORDER BY m.user ASC\nSQL;\n$result = $conn->query($query);\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Forgot to convert a couple "r"s to "m"s in thread_lib.php |
129,187 | 23.11.2017 17:05:38 | -32,400 | e98412e88d475b85967157634b1f4ea86216e383 | By default return entries from joined threads instead of subscribed threads | [
{
"change_type": "MODIFY",
"old_path": "server/entry_lib.php",
"new_path": "server/entry_lib.php",
"diff": "@@ -52,7 +52,7 @@ function get_entry_infos($input) {\n$home = false;\n$thread = intval($input['nav']);\n}\n- $additional_condition = $home ? \"m.subscribed = 1\" : \"d.thread = $thread\";\n+ $additional_condition = $home ? \"m.role != 0\" : \"d.thread = $thread\";\n$viewer_id = get_viewer_id();\n$visibility_open = VISIBILITY_OPEN;\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | By default return entries from joined threads instead of subscribed threads |
129,187 | 30.11.2017 13:58:34 | -32,400 | 512541af522ef5edd4a6e37dd22ffd6d95f125c6 | get_message_infos and get_messages_since now return associative array | [
{
"change_type": "MODIFY",
"old_path": "native/package-lock.json",
"new_path": "native/package-lock.json",
"diff": "}\n},\n\"react-navigation\": {\n- \"version\": \"git://github.com/react-community/react-navigation.git#24631e300eb0c41f37f91d7d28003e7674cb5b48\",\n+ \"version\": \"git://github.com/react-community/react-navigation.git#f332b6bdf7286584f7b03aba3bc9c4fd0e218ab6\",\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-popover-tooltip\": \"^1.1.4\",\n\"react-native-segmented-control-tab\": \"^3.2.1\",\n\"react-native-vector-icons\": \"^4.3.0\",\n- \"react-navigation\": \"git://github.com/react-community/react-navigation.git#fixflow\",\n+ \"react-navigation\": \"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"
},
{
"change_type": "MODIFY",
"old_path": "server/fetch_messages.php",
"new_path": "server/fetch_messages.php",
"diff": "@@ -20,11 +20,13 @@ if (!$message_result) {\n'error' => 'internal_error',\n));\n}\n-list($message_infos, $truncation_status, $users) = $message_result;\n+$message_infos = $message_result['message_infos'];\n+$truncation_statuses = $message_result['truncation_statuses'];\n+$users = $message_result['user_infos'];\nasync_end(array(\n'success' => true,\n'message_infos' => $message_infos,\n- 'truncation_status' => $truncation_status,\n+ 'truncation_status' => $truncation_statuses,\n'user_infos' => array_values($users),\n));\n"
},
{
"change_type": "MODIFY",
"old_path": "server/index.php",
"new_path": "server/index.php",
"diff": "@@ -130,7 +130,9 @@ if (!$message_result) {\nheader($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error', true, 500);\nexit;\n}\n-list($message_infos, $truncation_status, $message_users) = $message_result;\n+$message_infos = $message_result['message_infos'];\n+$truncation_statuses = $message_result['truncation_statuses'];\n+$message_users = $message_result['user_infos'];\n$users = array_merge(\n$message_users,\n@@ -179,7 +181,7 @@ HTML;\nvar thread_id = <?=$thread ? \"'$thread'\" : \"null\"?>;\nvar current_as_of = <?=$current_as_of?>;\nvar message_infos = <?=json_encode($message_infos)?>;\n- var truncation_status = <?=json_encode($truncation_status)?>;\n+ var truncation_status = <?=json_encode($truncation_statuses)?>;\nvar user_infos = <?=json_encode($users, JSON_FORCE_OBJECT)?>;\n</script>\n</head>\n"
},
{
"change_type": "MODIFY",
"old_path": "server/join_thread.php",
"new_path": "server/join_thread.php",
"diff": "@@ -88,7 +88,9 @@ if (!$message_result) {\n'error' => 'internal_error',\n));\n}\n-list($message_infos, $truncation_status, $message_users) = $message_result;\n+$message_infos = $message_result['message_infos'];\n+$truncation_statuses = $message_result['truncation_statuses'];\n+$message_users = $message_result['user_infos'];\nlist($thread_infos, $thread_users) = get_thread_infos();\n@@ -101,6 +103,6 @@ async_end(array(\n'success' => true,\n'thread_infos' => $thread_infos,\n'message_infos' => $message_infos,\n- 'truncation_status' => $truncation_status,\n+ 'truncation_status' => $truncation_statuses,\n'user_infos' => $user_infos,\n));\n"
},
{
"change_type": "MODIFY",
"old_path": "server/login.php",
"new_path": "server/login.php",
"diff": "@@ -63,7 +63,9 @@ if (!$message_result) {\n'error' => 'internal_error',\n));\n}\n-list($message_infos, $truncation_status, $message_users) = $message_result;\n+$message_infos = $message_result['message_infos'];\n+$truncation_statuses = $message_result['truncation_statuses'];\n+$message_users = $message_result['user_infos'];\n$return = array(\n'success' => true,\n@@ -74,7 +76,7 @@ $return = array(\n'email_verified' => (bool)$user_row['email_verified'],\n),\n'message_infos' => $message_infos,\n- 'truncation_status' => $truncation_status,\n+ 'truncation_status' => $truncation_statuses,\n'server_time' => $current_as_of,\n);\n"
},
{
"change_type": "MODIFY",
"old_path": "server/message_lib.php",
"new_path": "server/message_lib.php",
"diff": "@@ -170,7 +170,11 @@ SQL;\n$all_users = get_all_users($messages, $users);\n- return array($messages, $truncation_status, $all_users);\n+ return array(\n+ \"message_infos\" => $messages,\n+ \"truncation_statuses\" => $truncation_status,\n+ \"user_infos\" => $all_users,\n+ );\n}\n// In contrast with the above function, which is used at the start of a session,\n@@ -251,7 +255,11 @@ SQL;\n$all_users = get_all_users($messages, $users);\n- return array($messages, $truncation_status, $all_users);\n+ return array(\n+ \"message_infos\" => $messages,\n+ \"truncation_statuses\" => $truncation_status,\n+ \"user_infos\" => $all_users,\n+ );\n}\nfunction message_from_row($row) {\n"
},
{
"change_type": "MODIFY",
"old_path": "server/ping.php",
"new_path": "server/ping.php",
"diff": "@@ -54,7 +54,9 @@ if (!$result) {\n'error' => 'internal_error',\n));\n}\n-list($message_infos, $truncation_status, $message_users) = $result;\n+$message_infos = $result['message_infos'];\n+$truncation_statuses = $result['truncation_statuses'];\n+$message_users = $result['user_infos'];\nlist($thread_infos, $thread_users) = get_thread_infos();\n@@ -63,7 +65,7 @@ $return = array(\n'current_user_info' => $user_info,\n'thread_infos' => $thread_infos,\n'message_infos' => $message_infos,\n- 'truncation_status' => $truncation_status,\n+ 'truncation_status' => $truncation_statuses,\n);\nif (isset($_POST['last_ping'])) {\n"
},
{
"change_type": "MODIFY",
"old_path": "server/reset_password.php",
"new_path": "server/reset_password.php",
"diff": "@@ -82,7 +82,9 @@ if (!$message_result) {\n'error' => 'internal_error',\n));\n}\n-list($message_infos, $truncation_status, $message_users) = $message_result;\n+$message_infos = $message_result['message_infos'];\n+$truncation_statuses = $message_result['truncation_statuses'];\n+$message_users = $message_result['user_infos'];\n$return = array(\n'success' => true,\n@@ -93,7 +95,7 @@ $return = array(\n'email_verified' => (bool)$user_row['email_verified'],\n),\n'message_infos' => $message_infos,\n- 'truncation_status' => $truncation_status,\n+ 'truncation_status' => $truncation_statuses,\n'server_time' => $current_as_of,\n);\n"
},
{
"change_type": "MODIFY",
"old_path": "server/subscribe.php",
"new_path": "server/subscribe.php",
"diff": "@@ -20,7 +20,7 @@ $new_subscribed = $_POST['subscribe'] ? 1 : 0;\n$viewer_id = get_viewer_id();\n$message_infos = array();\n-$truncation_status = array();\n+$truncation_statuses = array();\n$message_users = array();\nif (viewer_is_member($thread)) {\n$query = <<<SQL\n@@ -69,7 +69,9 @@ SQL;\n'error' => 'internal_error',\n));\n}\n- list($message_infos, $truncation_status, $message_users) = $message_result;\n+ $message_infos = $message_result['message_infos'];\n+ $truncation_statuses = $message_result['truncation_statuses'];\n+ $message_users = $message_result['user_infos'];\n}\nlist($thread_infos, $thread_users) = get_thread_infos();\n@@ -83,6 +85,6 @@ async_end(array(\n'success' => true,\n'thread_infos' => $thread_infos,\n'message_infos' => $message_infos,\n- 'truncation_status' => $truncation_status,\n+ 'truncation_status' => $truncation_statuses,\n'user_infos' => $user_infos,\n));\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | get_message_infos and get_messages_since now return associative array |
129,187 | 30.11.2017 16:26:43 | -32,400 | 638325ecc0bdf742bd2c28b478161afb9bbba6d8 | getThreadIDFromParams
Also increases use of `assertNavigationRouteNotLeafNode` in a couple places | [
{
"change_type": "MODIFY",
"old_path": "native/calendar/entry.react.js",
"new_path": "native/calendar/entry.react.js",
"diff": "@@ -61,7 +61,10 @@ import { registerFetchKey } from 'lib/reducers/loading-reducer';\nimport Button from '../components/button.react';\nimport { ChatRouteName } from '../chat/chat.react';\nimport { MessageListRouteName } from '../chat/message-list.react';\n-import { assertNavigationRouteNotLeafNode } from '../utils/navigation-utils';\n+import {\n+ assertNavigationRouteNotLeafNode,\n+ getThreadIDFromParams,\n+} from '../utils/navigation-utils';\ntype Props = {\nentryInfo: EntryInfoWithHeight,\n@@ -579,18 +582,10 @@ export default connect(\nassertNavigationRouteNotLeafNode(state.navInfo.navigationState.routes[0]);\nconst chatRoute = assertNavigationRouteNotLeafNode(appRoute.routes[1]);\nconst currentChatSubroute = chatRoute.routes[chatRoute.index];\n- let currentChatThreadID = null;\n- if (currentChatSubroute.routeName === MessageListRouteName) {\n- invariant(\n- currentChatSubroute.params &&\n- currentChatSubroute.params.threadInfo &&\n- typeof currentChatSubroute.params.threadInfo === \"object\" &&\n- currentChatSubroute.params.threadInfo.id &&\n- typeof currentChatSubroute.params.threadInfo.id === \"string\",\n- \"all MessageList routes should have a threadInfo param\",\n- );\n- currentChatThreadID = currentChatSubroute.params.threadInfo.id;\n- }\n+ const currentChatThreadID =\n+ currentChatSubroute.routeName === MessageListRouteName\n+ ? getThreadIDFromParams(currentChatSubroute)\n+ : null;\nreturn {\nthreadInfo: state.threadInfos[ownProps.entryInfo.threadID],\nsessionStartingPayload: sessionStartingPayload(state),\n"
},
{
"change_type": "MODIFY",
"old_path": "native/navigation-setup.js",
"new_path": "native/navigation-setup.js",
"diff": "@@ -66,7 +66,10 @@ import {\nimport { createIsForegroundSelector } from './selectors/nav-selectors';\nimport { MessageListRouteName } from './chat/message-list.react';\nimport { ThreadSettingsRouteName } from './chat/settings/thread-settings.react';\n-import { assertNavigationRouteNotLeafNode } from './utils/navigation-utils';\n+import {\n+ assertNavigationRouteNotLeafNode,\n+ getThreadIDFromParams,\n+} from './utils/navigation-utils';\nexport type NavInfo = {|\n...$Exact<BaseNavInfo>,\n@@ -494,12 +497,8 @@ function popChatScreensForThreadID(\n) {\nreturn \"break\";\n}\n- const params = route.params;\n- invariant(\n- params && params.threadInfo && typeof params.threadInfo.id === \"string\",\n- \"params should have ThreadInfo\",\n- );\n- if (params.threadInfo.id !== actionPayload.threadID) {\n+ const threadID = getThreadIDFromParams(route);\n+ if (threadID !== actionPayload.threadID) {\nreturn \"break\";\n}\nreturn \"remove\";\n@@ -532,12 +531,8 @@ function filterChatScreensForThreadInfos(\n) {\nreturn \"keep\";\n}\n- const params = route.params;\n- invariant(\n- params && params.threadInfo && typeof params.threadInfo.id === \"string\",\n- \"params should have ThreadInfo\",\n- );\n- if (params.threadInfo.id in threadInfos) {\n+ const threadID = getThreadIDFromParams(route);\n+ if (threadID in threadInfos) {\nreturn \"keep\";\n}\nreturn \"remove\";\n"
},
{
"change_type": "MODIFY",
"old_path": "native/redux-setup.js",
"new_path": "native/redux-setup.js",
"diff": "@@ -21,6 +21,7 @@ import { NavigationActions } from 'react-navigation';\nimport baseReducer from 'lib/reducers/master-reducer';\nimport { newSessionID } from 'lib/selectors/session-selectors';\nimport { MessageListRouteName } from './chat/message-list.react';\n+import { getThreadIDFromParams } from './utils/navigation-utils';\nimport {\nhandleURLActionType,\n@@ -135,14 +136,7 @@ function reducer(state: AppState, action: *) {\naction.type === NavigationActions.NAVIGATE &&\naction.routeName === MessageListRouteName\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- );\n+ const threadID = getThreadIDFromParams(action);\nreturn {\nnavInfo: state.navInfo,\ncurrentUserInfo: state.currentUserInfo,\n@@ -155,8 +149,8 @@ function reducer(state: AppState, action: *) {\nmessages: state.messageStore.messages,\nthreads: {\n...state.messageStore.threads,\n- [action.params.threadInfo.id]: {\n- ...state.messageStore.threads[action.params.threadInfo.id],\n+ [threadID]: {\n+ ...state.messageStore.threads[threadID],\nlastNavigatedTo: Date.now(),\n},\n},\n"
},
{
"change_type": "MODIFY",
"old_path": "native/selectors/nav-selectors.js",
"new_path": "native/selectors/nav-selectors.js",
"diff": "@@ -9,6 +9,10 @@ import invariant from 'invariant';\nimport { AppRouteName } from '../navigation-setup';\nimport { ChatRouteName } from '../chat/chat.react';\nimport { MessageListRouteName } from '../chat/message-list.react';\n+import {\n+ assertNavigationRouteNotLeafNode,\n+ getThreadIDFromParams,\n+} from '../utils/navigation-utils';\nconst createIsForegroundSelector = (routeName: string) => createSelector(\n(state: AppState) => state.navInfo.navigationState,\n@@ -23,20 +27,8 @@ 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 !== undefined &&\n- innerState.index !== null &&\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- );\n- return innerState.routes[innerState.index].routeName === routeName;\n+ const appRoute = assertNavigationRouteNotLeafNode(innerState);\n+ return appRoute.routes[appRoute.index].routeName === routeName;\n},\n);\n@@ -47,52 +39,17 @@ 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 !== undefined &&\n- innerState.index !== null &&\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- );\n- const innerInnerState = innerState.routes[innerState.index];\n+ const appRoute = assertNavigationRouteNotLeafNode(innerState);\n+ const innerInnerState = appRoute.routes[appRoute.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 !== undefined &&\n- innerInnerState.index !== null &&\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- );\n- const innerInnerInnerState = innerInnerState.routes[innerInnerState.index];\n+ const chatRoute = assertNavigationRouteNotLeafNode(innerInnerState);\n+ const innerInnerInnerState = chatRoute.routes[chatRoute.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- );\n- return innerInnerInnerState.params.threadInfo.id;\n+ return getThreadIDFromParams(innerInnerInnerState);\n},\n);\n"
},
{
"change_type": "MODIFY",
"old_path": "native/utils/navigation-utils.js",
"new_path": "native/utils/navigation-utils.js",
"diff": "@@ -4,6 +4,7 @@ import type {\nNavigationLeafRoute,\nNavigationStateRoute,\nNavigationRoute,\n+ NavigationParams,\n} from 'react-navigation/src/TypeDefinition';\nimport invariant from 'invariant';\n@@ -65,6 +66,19 @@ function assertNavigationRouteNotLeafNode(\n};\n}\n+function getThreadIDFromParams(object: { params?: NavigationParams }): string {\n+ invariant(\n+ object.params &&\n+ object.params.threadInfo &&\n+ typeof object.params.threadInfo === \"object\" &&\n+ object.params.threadInfo.id &&\n+ typeof object.params.threadInfo.id === \"string\",\n+ \"there's no way in react-navigation/Flow to type this\",\n+ );\n+ return object.params.threadInfo.id;\n+}\n+\nexport {\nassertNavigationRouteNotLeafNode,\n+ getThreadIDFromParams,\n};\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | getThreadIDFromParams
Also increases use of `assertNavigationRouteNotLeafNode` in a couple places |
129,187 | 02.12.2017 17:45:21 | -28,800 | d6f9a421d53ef8c3daa0c23200bbb2190db89807 | Include cookie ID in get_viewer_info | [
{
"change_type": "MODIFY",
"old_path": "server/async_lib.php",
"new_path": "server/async_lib.php",
"diff": "@@ -42,7 +42,7 @@ function async_end($payload) {\n$viewer_info = get_viewer_info();\n// Only include in the raw response since on web we want it to be httponly\nif (isset($_POST['cookie'])) {\n- $payload['cookie_change']['cookie'] = $viewer_info[2];\n+ $payload['cookie_change']['cookie'] = $viewer_info[3];\n}\nif ($cookie_invalidated) {\n$payload['cookie_change']['current_user_info'] = array(\n"
},
{
"change_type": "MODIFY",
"old_path": "server/auth.php",
"new_path": "server/auth.php",
"diff": "@@ -10,7 +10,7 @@ define(\"ROLE_CREATOR\", 50);\n// Returns either a user ID or a cookie ID (for anonymous)\nfunction get_viewer_id() {\n- list($id, $is_user) = get_viewer_info();\n+ list($id) = get_viewer_info();\nreturn $id;\n}\n@@ -59,7 +59,7 @@ function cookie_has_changed() {\nif ($original_viewer_info === null && $current_viewer_info === null) {\nreturn false;\n}\n- return $original_viewer_info[2] !== $current_viewer_info[2];\n+ return $original_viewer_info[3] !== $current_viewer_info[3];\n}\nfunction get_input_user_cookie() {\n@@ -136,6 +136,7 @@ function init_cookie() {\n$current_viewer_info = array(\n(int)$cookie_row['user'],\ntrue,\n+ $cookie_id,\n\"user=$cookie_id:$cookie_password\",\n);\n}\n@@ -167,6 +168,7 @@ function init_anonymous_cookie($initial_run = false) {\n$current_viewer_info = array(\n(int)$cookie_id,\nfalse,\n+ $cookie_id,\n\"anonymous=$cookie_id:$cookie_password\",\n);\nif (!$initial_run) {\n@@ -193,6 +195,7 @@ function create_user_cookie($user_id) {\n$current_viewer_info = array(\n$user_id,\ntrue,\n+ $cookie_id,\n\"user=$cookie_id:$cookie_password\",\n);\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Include cookie ID in get_viewer_info |
129,187 | 02.12.2017 18:44:22 | -28,800 | 3e00b18cfcfeec6e906a4b31117eb8af0b6af65c | Don't filter out cookie param in bindServerCalls | [
{
"change_type": "MODIFY",
"old_path": "lib/utils/action-utils.js",
"new_path": "lib/utils/action-utils.js",
"diff": "@@ -378,14 +378,14 @@ function bindServerCalls(\n) => {\nconst dispatch = dispatchProps.dispatch;\ninvariant(dispatch, \"should be defined\");\n- const { cookie, ...restStateProps } = stateProps;\n+ const { cookie } = stateProps;\nconst boundServerCalls = _mapValues(\n(serverCall: (fetchJSON: FetchJSON, ...rest: any) => Promise<any>) =>\nbindCookieAndUtilsIntoServerCall(serverCall, dispatch, cookie),\n)(serverCalls);\nreturn {\n...ownProps,\n- ...restStateProps,\n+ ...stateProps,\n...dispatchProps,\n...boundServerCalls,\n};\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Don't filter out cookie param in bindServerCalls |
129,187 | 02.12.2017 18:45:59 | -28,800 | c2a71a9280d7fef9860c7e5a8b67ec1dde310d68 | Only call appLoggedIn if appLoggedIn | [
{
"change_type": "MODIFY",
"old_path": "native/app.react.js",
"new_path": "native/app.react.js",
"diff": "@@ -43,12 +43,19 @@ import {\nupdateFocusedThreads,\n} from 'lib/actions/thread-actions';\n-import { handleURLActionType, RootNavigator } from './navigation-setup';\n+import {\n+ handleURLActionType,\n+ RootNavigator,\n+ AppRouteName,\n+} from './navigation-setup';\nimport { store } from './redux-setup';\nimport { resolveInvalidatedCookie } from './account/native-credentials';\nimport { pingNativeStartingPayload } from './selectors/ping-selectors';\nimport ConnectedStatusBar from './connected-status-bar.react';\n-import { activeThreadSelector } from './selectors/nav-selectors';\n+import {\n+ activeThreadSelector,\n+ createIsForegroundSelector,\n+} from './selectors/nav-selectors';\nlet urlPrefix;\nif (!__DEV__) {\n@@ -92,6 +99,7 @@ type Props = {\npingStartingPayload: () => PingStartingPayload,\ncurrentAsOf: number,\nactiveThread: ?string,\n+ appLoggedIn: bool,\n// Redux dispatch functions\ndispatch: NativeDispatch,\ndispatchActionPayload: DispatchActionPayload,\n@@ -110,6 +118,7 @@ class AppWithNavigationState extends React.PureComponent<Props> {\npingStartingPayload: PropTypes.func.isRequired,\ncurrentAsOf: PropTypes.number.isRequired,\nactiveThread: PropTypes.string,\n+ appLoggedIn: PropTypes.bool.isRequired,\ndispatch: PropTypes.func.isRequired,\ndispatchActionPayload: PropTypes.func.isRequired,\ndispatchActionPromise: PropTypes.func.isRequired,\n@@ -124,8 +133,10 @@ class AppWithNavigationState extends React.PureComponent<Props> {\nthis.handleInitialURL().then();\nLinking.addEventListener('url', this.handleURLChange);\nthis.activePingSubscription = setInterval(this.ping, pingFrequency);\n+ if (this.props.appLoggedIn) {\nthis.updateFocusedThreads(this.props.activeThread);\n}\n+ }\nasync handleInitialURL() {\nconst url = await Linking.getInitialURL();\n@@ -141,15 +152,26 @@ class AppWithNavigationState extends React.PureComponent<Props> {\nclearInterval(this.activePingSubscription);\nthis.activePingSubscription = null;\n}\n+ if (this.props.appLoggedIn) {\nthis.updateFocusedThreads(null);\n}\n+ }\ncomponentWillReceiveProps(nextProps: Props) {\n- if (nextProps.activeThread !== this.props.activeThread) {\n+ if (\n+ nextProps.appLoggedIn &&\n+ nextProps.activeThread !== this.props.activeThread\n+ ) {\nthis.updateFocusedThreads(nextProps.activeThread);\n}\n}\n+ componentDidUpdate(prevProps: Props) {\n+ if (this.props.appLoggedIn && !prevProps.appLoggedIn) {\n+ this.updateFocusedThreads(this.props.activeThread);\n+ }\n+ }\n+\nhandleURLChange = (event: { url: string }) => {\nthis.dispatchActionForURL(event.url);\n}\n@@ -185,8 +207,8 @@ class AppWithNavigationState extends React.PureComponent<Props> {\nping = () => {\nconst startingPayload = this.props.pingStartingPayload();\nif (\n- (startingPayload.loggedIn ||\n- (this.props.cookie && this.props.cookie.startsWith(\"user=\")))\n+ startingPayload.loggedIn ||\n+ (this.props.cookie && this.props.cookie.startsWith(\"user=\"))\n) {\nthis.props.dispatchActionPromise(\npingActionTypes,\n@@ -245,6 +267,7 @@ const styles = StyleSheet.create({\n},\n});\n+const isForegroundSelector = createIsForegroundSelector(AppRouteName);\nconst ConnectedAppWithNavigationState = connect(\n(state: AppState) => ({\ncookie: state.cookie,\n@@ -252,6 +275,7 @@ const ConnectedAppWithNavigationState = connect(\npingStartingPayload: pingNativeStartingPayload(state),\ncurrentAsOf: state.currentAsOf,\nactiveThread: activeThreadSelector(state),\n+ appLoggedIn: isForegroundSelector(state),\n}),\nincludeDispatchActionProps,\nbindServerCalls({ ping, updateFocusedThreads }),\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Only call appLoggedIn if appLoggedIn |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.