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
02.12.2017 18:46:38
-28,800
660bdeeb8e087a424dcd5ec73305711f902a04f6
Update tabBarOnPress callbacks to conform to new react-navigation spec
[ { "change_type": "MODIFY", "old_path": "native/calendar/calendar.react.js", "new_path": "native/calendar/calendar.react.js", "diff": "@@ -157,10 +157,10 @@ class InnerCalendar extends React.PureComponent<Props, State> {\nstyle={[styles.icon, { color: tintColor }]}\n/>\n),\n- tabBarOnPress: (\n+ tabBarOnPress: ({ scene, jumpToIndex}: {\nscene: { index: number, focused: bool },\njumpToIndex: (index: number) => void,\n- ) => {\n+ }) => {\nif (scene.focused && currentCalendarRef) {\ncurrentCalendarRef.scrollToToday();\n} else {\n" }, { "change_type": "MODIFY", "old_path": "native/chat/chat.react.js", "new_path": "native/chat/chat.react.js", "diff": "@@ -35,10 +35,10 @@ const Chat = StackNavigator(\nstyle={[styles.icon, { color: tintColor }]}\n/>\n),\n- tabBarOnPress: (\n+ tabBarOnPress: ({ scene, jumpToIndex}: {\nscene: { index: number, focused: bool, route: NavigationStateRoute },\njumpToIndex: (index: number) => void,\n- ) => {\n+ }) => {\nif (!scene.focused) {\njumpToIndex(scene.index);\nreturn;\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Update tabBarOnPress callbacks to conform to new react-navigation spec
129,187
05.12.2017 17:15:11
-28,800
91764c632b8c24582618ace4d5f1f86d20739e51
Make sure we always use updateFocusedThreads that has the new cookie bound
[ { "change_type": "MODIFY", "old_path": "native/app.react.js", "new_path": "native/app.react.js", "diff": "@@ -133,9 +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) {\n- this.updateFocusedThreads(this.props.activeThread);\n- }\n+ AppWithNavigationState.updateFocusedThreads(\n+ this.props,\n+ this.props.activeThread,\n+ );\n}\nasync handleInitialURL() {\n@@ -152,23 +153,18 @@ class AppWithNavigationState extends React.PureComponent<Props> {\nclearInterval(this.activePingSubscription);\nthis.activePingSubscription = null;\n}\n- if (this.props.appLoggedIn) {\n- this.updateFocusedThreads(null);\n- }\n+ AppWithNavigationState.updateFocusedThreads(this.props, null);\n}\ncomponentWillReceiveProps(nextProps: Props) {\nif (\n- nextProps.appLoggedIn &&\n+ !this.props.appLoggedIn ||\nnextProps.activeThread !== this.props.activeThread\n) {\n- this.updateFocusedThreads(nextProps.activeThread);\n- }\n- }\n-\n- componentDidUpdate(prevProps: Props) {\n- if (this.props.appLoggedIn && !prevProps.appLoggedIn) {\n- this.updateFocusedThreads(this.props.activeThread);\n+ AppWithNavigationState.updateFocusedThreads(\n+ nextProps,\n+ nextProps.activeThread,\n+ );\n}\n}\n@@ -238,11 +234,14 @@ class AppWithNavigationState extends React.PureComponent<Props> {\n};\n}\n- updateFocusedThreads(activeThread: ?string) {\n+ static updateFocusedThreads(props: Props, activeThread: ?string) {\n+ if (!props.appLoggedIn) {\n+ return;\n+ }\nconst focusedThreads = activeThread ? [ activeThread ] : [];\n- this.props.dispatchActionPromise(\n+ props.dispatchActionPromise(\nupdateFocusedThreadsActionTypes,\n- this.props.updateFocusedThreads(focusedThreads),\n+ props.updateFocusedThreads(focusedThreads),\n);\n}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Make sure we always use updateFocusedThreads that has the new cookie bound
129,187
05.12.2017 21:11:42
-28,800
5fd617457b862fa5ecc1c21d377f88caa51f69a1
Have ping.php keep focused time updated
[ { "change_type": "MODIFY", "old_path": "server/ping.php", "new_path": "server/ping.php", "diff": "@@ -60,6 +60,8 @@ $message_users = $result['user_infos'];\nlist($thread_infos, $thread_users) = get_thread_infos();\n+update_focused_thread_time($current_as_of);\n+\n$return = array(\n'success' => true,\n'current_user_info' => $user_info,\n" }, { "change_type": "MODIFY", "old_path": "server/thread_lib.php", "new_path": "server/thread_lib.php", "diff": "@@ -186,3 +186,19 @@ SQL;\nreturn true;\n}\n+\n+function update_focused_thread_time($time) {\n+ global $conn;\n+\n+ list($viewer_id, $is_user, $cookie_id) = get_viewer_info();\n+ if (!$is_user) {\n+ return;\n+ }\n+\n+ $query = <<<SQL\n+UPDATE focused\n+SET time = {$time}\n+WHERE user = {$viewer_id} AND cookie = {$cookie_id}\n+SQL;\n+ $conn->query($query);\n+}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Have ping.php keep focused time updated
129,187
05.12.2017 21:18:28
-28,800
beb16a410f02037e2e261d1c10a03507f7860278
Memoize native nav selectors
[ { "change_type": "MODIFY", "old_path": "native/selectors/nav-selectors.js", "new_path": "native/selectors/nav-selectors.js", "diff": "@@ -5,6 +5,7 @@ import type { NavigationState } from 'react-navigation';\nimport { createSelector } from 'reselect';\nimport invariant from 'invariant';\n+import _memoize from 'lodash/memoize';\nimport { AppRouteName } from '../navigation-setup';\nimport { ChatRouteName } from '../chat/chat.react';\n@@ -17,13 +18,14 @@ import {\ngetThreadIDFromParams,\n} from '../utils/navigation-utils';\n-const createIsForegroundSelector = (routeName: string) => createSelector(\n+const baseCreateIsForegroundSelector = (routeName: string) => createSelector(\n(state: AppState) => state.navInfo.navigationState,\n(navigationState: NavigationState) =>\nnavigationState.routes[navigationState.index].routeName === routeName,\n);\n+const createIsForegroundSelector = _memoize(baseCreateIsForegroundSelector);\n-const createActiveTabSelector = (routeName: string) => createSelector(\n+const baseCreateActiveTabSelector = (routeName: string) => createSelector(\n(state: AppState) => state.navInfo.navigationState,\n(navigationState: NavigationState) => {\nconst innerState = navigationState.routes[navigationState.index];\n@@ -34,6 +36,7 @@ const createActiveTabSelector = (routeName: string) => createSelector(\nreturn appRoute.routes[appRoute.index].routeName === routeName;\n},\n);\n+const createActiveTabSelector = _memoize(baseCreateActiveTabSelector);\nconst activeThreadSelector = createSelector(\n(state: AppState) => state.navInfo.navigationState,\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Memoize native nav selectors
129,187
06.12.2017 13:09:51
28,800
2f5bdf73d4d603605fb9f6340a488731a98efb38
unread field on memberships table
[ { "change_type": "MODIFY", "old_path": "server/edit_thread.php", "new_path": "server/edit_thread.php", "diff": "@@ -271,6 +271,9 @@ if ($add_member_ids) {\n));\n}\nforeach ($role_results['to_save'] as $row_to_save) {\n+ if ($row_to_save['role'] !== 0) {\n+ $row_to_save['unread'] = true;\n+ }\nif ($row_to_save['thread_id'] === $thread) {\n$row_to_save['subscribed'] = true;\n}\n" }, { "change_type": "MODIFY", "old_path": "server/new_thread.php", "new_path": "server/new_thread.php", "diff": "@@ -155,6 +155,13 @@ $processed_to_save = array();\n$members = array();\n$current_user_info = null;\nforeach ($to_save as $row_to_save) {\n+ if (\n+ $row_to_save['role'] !== 0 &&\n+ ($row_to_save['user_id'] !== $creator ||\n+ $row_to_save['thread_id'] !== $id)\n+ ) {\n+ $row_to_save['unread'] = true;\n+ }\nif ($row_to_save['thread_id'] === $id && $row_to_save['role'] !== 0) {\n$row_to_save['subscribed'] = true;\n$member = array(\n" }, { "change_type": "MODIFY", "old_path": "server/permissions.php", "new_path": "server/permissions.php", "diff": "@@ -297,6 +297,7 @@ function permissions_for_children($permissions) {\n// ?array<permission: string, array(value => bool, source => int)>\n// role: int,\n// subscribed?: bool,\n+// unread?: bool,\n// )>\nfunction save_memberships($to_save) {\nglobal $conn;\n@@ -325,6 +326,9 @@ function save_memberships($to_save) {\n$subscribed = isset($role_info['subscribed'])\n? ($role_info['subscribed'] ? \"1\" : \"0\")\n: \"0\";\n+ $unread = isset($role_info['unread'])\n+ ? ($role_info['unread'] ? \"1\" : \"0\")\n+ : \"0\";\n$new_row_sql_strings[] = \"(\" . implode(\", \", array(\n$role_info['user_id'],\n@@ -335,6 +339,7 @@ function save_memberships($to_save) {\n$permissions,\n$permissions_for_children,\n$visible,\n+ $unread,\n)) . \")\";\n}\n$new_rows_sql_string = implode(\", \", $new_row_sql_strings);\n@@ -344,7 +349,7 @@ function save_memberships($to_save) {\n// joining means you subscribe and leaving means you unsubscribe.\n$query = <<<SQL\nINSERT INTO memberships (user, thread, role, creation_time, subscribed,\n- permissions, permissions_for_children, visible)\n+ permissions, permissions_for_children, visible, unread)\nVALUES {$new_rows_sql_string}\nON DUPLICATE KEY UPDATE\nsubscribed = IF(\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
unread field on memberships table
129,187
06.12.2017 14:06:28
28,800
4b892c955e48c27edade5dfa5907b1fe2bf53efd
update_focused_threads.php updates unread column now
[ { "change_type": "MODIFY", "old_path": "server/thread_lib.php", "new_path": "server/thread_lib.php", "diff": "@@ -12,6 +12,8 @@ define(\"VISIBILITY_THREAD_SECRET\", 4);\ndefine(\"EDIT_ANYBODY\", 0);\ndefine(\"EDIT_LOGGED_IN\", 1);\n+define(\"PING_INTERVAL\", 3000); // in milliseconds\n+\nfunction vis_rules_are_open($vis_rules) {\nreturn $vis_rules === VISIBILITY_OPEN || $vis_rules === VISIBILITY_NESTED_OPEN;\n}\n@@ -170,35 +172,113 @@ SQL;\n$conn->query($query);\n$unverified_thread_ids = array();\n+ $focus_commands_by_thread_id = array();\nforeach ($focus_commands as $focus_command) {\n- if ($focus_command['focus'] !== \"true\") {\n- continue;\n- }\n$thread_id = (int)$focus_command['threadID'];\n$unverified_thread_ids[$thread_id] = $thread_id;\n+ $focus_commands_by_thread_id[$thread_id] = $focus_command;\n}\n- $thread_ids = verify_thread_ids($unverified_thread_ids);\n+ $verified_thread_ids = verify_thread_ids($unverified_thread_ids);\n+ $focused_thread_ids = array();\n+ $unfocused_thread_ids = array();\n+ $unfocused_thread_latest_messages = array();\n+ foreach ($verified_thread_ids as $verified_thread_id) {\n+ $focus_command = $focus_commands_by_thread_id[$verified_thread_id];\n+ if ($focus_command['focus'] === \"true\") {\n+ $focused_thread_ids[] = $verified_thread_id;\n+ } else if ($focus_command['focus'] === \"false\") {\n+ $unfocused_thread_ids[] = $verified_thread_id;\n+ $unfocused_thread_latest_messages[$verified_thread_id] =\n+ (int)$focus_command['latestMessage'];\n+ }\n+ }\n+\n+ if ($focused_thread_ids) {\n$time = round(microtime(true) * 1000); // in milliseconds\n$values_sql_strings = array();\n- foreach ($thread_ids as $thread_id) {\n+ foreach ($focused_thread_ids as $thread_id) {\n$values_sql_strings[] = \"(\" . implode(\n\", \",\narray($viewer_id, $cookie_id, $thread_id, $time)\n) . \")\";\n}\n- if ($values_sql_strings) {\n$values_sql_string = implode(\", \", $values_sql_strings);\n$query = <<<SQL\nINSERT INTO focused (user, cookie, thread, time) VALUES {$values_sql_string}\n+SQL;\n+ $conn->query($query);\n+\n+ $thread_ids_sql_string = implode(\", \", $focused_thread_ids);\n+ $query = <<<SQL\n+UPDATE memberships\n+SET unread = 0\n+WHERE thread IN ({$thread_ids_sql_string}) AND user = {$viewer_id}\nSQL;\n$conn->query($query);\n}\n+ // To protect against a possible race condition, we reset the thread to unread\n+ // if the latest message ID on the client at the time that focus was dropped\n+ // is no longer the latest message ID\n+ possibly_reset_thread_to_unread(\n+ $unfocused_thread_ids,\n+ $unfocused_thread_latest_messages\n+ );\n+\nreturn true;\n}\n+function possibly_reset_thread_to_unread(\n+ $unfocused_thread_ids,\n+ $unfocused_thread_latest_messages\n+) {\n+ global $conn;\n+\n+ if (!$unfocused_thread_ids) {\n+ return;\n+ }\n+\n+ $focused_elsewhere = check_threads_focused($unfocused_thread_ids);\n+ $unread_candidates =\n+ array_values(array_diff($unfocused_thread_ids, $focused_elsewhere));\n+ if (!$unread_candidates) {\n+ return;\n+ }\n+\n+ $thread_ids_sql_string = implode(\", \", $unread_candidates);\n+ $query = <<<SQL\n+SELECT thread, MAX(id) AS latest_message\n+FROM messages\n+WHERE thread IN ({$thread_ids_sql_string})\n+GROUP BY thread\n+SQL;\n+ $result = $conn->query($query);\n+\n+ $to_reset = array();\n+ while ($row = $result->fetch_assoc()) {\n+ $thread_id = (int)$row['thread'];\n+ $server_latest_message = (int)$row['latest_message'];\n+ $client_latest_message = $unfocused_thread_latest_messages[$thread_id];\n+ if ($client_latest_message !== $server_latest_message) {\n+ $to_reset[] = $thread_id;\n+ }\n+ }\n+ if (!$to_reset) {\n+ return;\n+ }\n+\n+ $thread_ids_sql_string = implode(\", \", $to_reset);\n+ $viewer_id = get_viewer_id();\n+ $query = <<<SQL\n+UPDATE memberships\n+SET unread = 1\n+WHERE thread IN ({$thread_ids_sql_string}) AND user = {$viewer_id}\n+SQL;\n+ $conn->query($query);\n+}\n+\nfunction update_focused_thread_time($time) {\nglobal $conn;\n@@ -214,3 +294,31 @@ WHERE user = {$viewer_id} AND cookie = {$cookie_id}\nSQL;\n$conn->query($query);\n}\n+\n+// does not verify $thread_ids!\n+function check_threads_focused($thread_ids) {\n+ global $conn;\n+\n+ list($viewer_id, $is_user) = get_viewer_info();\n+ if (!$is_user) {\n+ return array();\n+ }\n+\n+ $thread_ids_sql_string = implode(\", \", $thread_ids);\n+ $time = round(microtime(true) * 1000) - PING_INTERVAL; // in milliseconds\n+ $query = <<<SQL\n+SELECT thread\n+FROM focused\n+WHERE user = {$viewer_id}\n+ AND thread IN ({$thread_ids_sql_string})\n+ AND time > {$time}\n+SQL;\n+ $result = $conn->query($query);\n+\n+ $focused_thread_ids = array();\n+ while ($row = $result->fetch_assoc()) {\n+ $thread_id = (int)$row['thread'];\n+ $focused_thread_ids[$thread_id] = $thread_id;\n+ }\n+ return array_values($focused_thread_ids);\n+}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
update_focused_threads.php updates unread column now
129,187
19.12.2017 10:18:24
18,000
74266408183ef7b99308aa2d02f0aa0bab24c3d1
Fix small SQL bug `update_focused_threads` with no focused threads would cause a bug since `verify_thread_ids` did not support empty array
[ { "change_type": "MODIFY", "old_path": "server/index.php", "new_path": "server/index.php", "diff": "@@ -35,7 +35,7 @@ $thread_rewrite_matched = preg_match(\n$home_rewrite_matched = preg_match('#/home(/|$)#i', $_SERVER['REQUEST_URI']);\nif (!$home_rewrite_matched && $thread_rewrite_matched) {\n$home = false;\n- $thread = (int)$thread_matches[1];;\n+ $thread = (int)$thread_matches[1];\n} else {\n$home = true;\n$thread = null;\n" }, { "change_type": "MODIFY", "old_path": "server/thread_lib.php", "new_path": "server/thread_lib.php", "diff": "@@ -140,6 +140,10 @@ SQL;\nfunction verify_thread_ids($thread_ids) {\nglobal $conn;\n+ if (!$thread_ids) {\n+ return array();\n+ }\n+\n$int_thread_ids = array_map('intval', $thread_ids);\n$thread_ids_string = implode(\", \", $int_thread_ids);\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Fix small SQL bug `update_focused_threads` with no focused threads would cause a bug since `verify_thread_ids` did not support empty array
129,187
19.12.2017 11:40:56
18,000
6a7181002cfcaf2613f7108bc1fb8e3701982d6b
Get rid of visible column in memberships table Now that we have MySQL 5.7 we can do JSON extraction within the query!
[ { "change_type": "MODIFY", "old_path": "server/entry_lib.php", "new_path": "server/entry_lib.php", "diff": "require_once('config.php');\nrequire_once('auth.php');\nrequire_once('thread_lib.php');\n+require_once('permissions.php');\n// Doesn't verify $input['nav'] is actually a thread, if not \"home\"\n// Use verify_entry_info_query\n@@ -57,6 +58,7 @@ function get_entry_infos($input) {\n$viewer_id = get_viewer_id();\n$visibility_open = VISIBILITY_OPEN;\n$visibility_nested_open = VISIBILITY_NESTED_OPEN;\n+ $vis_permission_extract_string = \"$.\" . PERMISSION_VISIBLE . \".value\";\n$select_query = <<<SQL\nSELECT DAY(d.date) AS day, MONTH(d.date) AS month, YEAR(d.date) AS year,\ne.id, e.text, e.creation_time AS creationTime, d.thread AS threadID,\n@@ -66,7 +68,11 @@ LEFT JOIN days d ON d.id = e.day\nLEFT JOIN threads t ON t.id = d.thread\nLEFT JOIN memberships m ON m.thread = d.thread AND m.user = {$viewer_id}\nLEFT JOIN users u ON u.id = e.creator\n-WHERE (m.visible = 1 OR t.visibility_rules = {$visibility_open})\n+WHERE\n+ (\n+ JSON_EXTRACT(m.permissions, '{$vis_permission_extract_string}') IS TRUE\n+ OR t.visibility_rules = {$visibility_open}\n+ )\nAND d.date BETWEEN '{$start_date}' AND '{$end_date}'\nAND {$additional_condition} {$deleted_condition}\nORDER BY e.creation_time DESC\n" }, { "change_type": "MODIFY", "old_path": "server/message_lib.php", "new_path": "server/message_lib.php", "diff": "@@ -117,6 +117,7 @@ function get_message_infos($thread_selection_criteria, $number_per_thread) {\n$viewer_id = get_viewer_id();\n$visibility_open = VISIBILITY_OPEN;\n$visibility_nested_open = VISIBILITY_NESTED_OPEN;\n+ $vis_permission_extract_string = \"$.\" . PERMISSION_VISIBLE . \".value\";\n$int_number_per_thread = (int)$number_per_thread;\n$query = <<<SQL\nSET @num := 0, @thread := '';\n@@ -129,7 +130,11 @@ FROM (\nFROM messages m\nLEFT JOIN threads t ON t.id = m.thread\nLEFT JOIN memberships mm ON mm.thread = m.thread AND mm.user = {$viewer_id}\n- WHERE (mm.visible = 1 OR t.visibility_rules = {$visibility_open})\n+ WHERE\n+ (\n+ JSON_EXTRACT(mm.permissions, '{$vis_permission_extract_string}') IS TRUE\n+ OR t.visibility_rules = {$visibility_open}\n+ )\nAND {$thread_selection}\nORDER BY m.thread, m.time DESC\n) x\n@@ -208,6 +213,7 @@ function get_messages_since(\n$viewer_id = get_viewer_id();\n$visibility_open = VISIBILITY_OPEN;\n$visibility_nested_open = VISIBILITY_NESTED_OPEN;\n+ $vis_permission_extract_string = \"$.\" . PERMISSION_VISIBLE . \".value\";\n$query = <<<SQL\nSELECT m.id, m.thread AS threadID, m.content, m.time, m.type,\nu.username AS creator, m.user AS creatorID\n@@ -215,7 +221,11 @@ FROM messages m\nLEFT JOIN threads t ON t.id = m.thread\nLEFT JOIN memberships mm ON mm.thread = m.thread AND mm.user = {$viewer_id}\nLEFT JOIN users u ON u.id = m.user\n-WHERE (mm.visible = 1 OR t.visibility_rules = {$visibility_open})\n+WHERE\n+ (\n+ JSON_EXTRACT(mm.permissions, '{$vis_permission_extract_string}') IS TRUE\n+ OR t.visibility_rules = {$visibility_open}\n+ )\nAND m.time > {$current_as_of}\nAND {$thread_selection}\nORDER BY m.thread, m.time DESC\n" }, { "change_type": "MODIFY", "old_path": "server/permissions.php", "new_path": "server/permissions.php", "diff": "@@ -320,9 +320,6 @@ function save_memberships($to_save) {\n$role_info['permissions_for_children']\n)) . \"'\";\n}\n- $visible = isset($role_info['permissions'][PERMISSION_VISIBLE]['value'])\n- ? ($role_info['permissions'][PERMISSION_VISIBLE]['value'] ? \"1\" : \"0\")\n- : \"0\";\n$subscribed = isset($role_info['subscribed'])\n? ($role_info['subscribed'] ? \"1\" : \"0\")\n: \"0\";\n@@ -338,7 +335,6 @@ function save_memberships($to_save) {\n$subscribed,\n$permissions,\n$permissions_for_children,\n- $visible,\n$unread,\n)) . \")\";\n}\n@@ -349,7 +345,7 @@ function save_memberships($to_save) {\n// joining means you subscribe and leaving means you unsubscribe.\n$query = <<<SQL\nINSERT INTO memberships (user, thread, role, creation_time, subscribed,\n- permissions, permissions_for_children, visible, unread)\n+ permissions, permissions_for_children, unread)\nVALUES {$new_rows_sql_string}\nON DUPLICATE KEY UPDATE\nsubscribed = IF(\n@@ -360,8 +356,7 @@ ON DUPLICATE KEY UPDATE\n),\nrole = VALUES(role),\npermissions = VALUES(permissions),\n- permissions_for_children = VALUES(permissions_for_children),\n- visible = VALUES(visible)\n+ permissions_for_children = VALUES(permissions_for_children)\nSQL;\n$conn->query($query);\n}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Get rid of visible column in memberships table Now that we have MySQL 5.7 we can do JSON extraction within the query!
129,187
19.12.2017 22:33:53
18,000
4aff4e00e23555344bc859d6d2ef6653f1281f7f
Mark threads as unread when new messages are created Exceptions are when a user is the creator of the message and when a user is currently viewing the thread
[ { "change_type": "MODIFY", "old_path": "server/message_lib.php", "new_path": "server/message_lib.php", "diff": "@@ -362,6 +362,7 @@ function create_message_infos($new_message_infos) {\n}\n$content_by_index = array();\n+ $thread_creator_pairs = array();\nforeach ($new_message_infos as $index => $new_message_info) {\nif ($new_message_info['type'] === MESSAGE_TYPE_CREATE_THREAD) {\n$content_by_index[$index] = $conn->real_escape_string(\n@@ -412,13 +413,26 @@ function create_message_infos($new_message_infos) {\njson_encode($content)\n);\n}\n+ $thread_id = $new_message_info['threadID'];\n+ $creator_id = $new_message_info['creatorID'];\n+ $thread_creator_pairs[] =\n+ \"(m.thread = {$thread_id} AND m.user != {$creator_id})\";\n}\n+ $thread_creator_fragment = \"(\" . implode(\" OR \", $thread_creator_pairs) . \")\";\n+\n+ $num_new_messages = count($new_message_infos);\n+ $id_inserts = array_fill(0, $num_new_messages, \"('messages')\");\n+ $id_insert_clause = implode(\", \", $id_inserts);\n+ $id_insert_query = <<<SQL\n+INSERT INTO ids(table_name) VALUES {$id_insert_clause}\n+SQL;\n+ $conn->query($id_insert_query);\n+ $id = $conn->insert_id - $num_new_messages + 1;\n$values = array();\n$return = array();\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+ $new_message_info['id'] = (string)($id++);\n$content = isset($content_by_index[$index])\n? \"'{$content_by_index[$index]}'\"\n: \"NULL\";\n@@ -437,5 +451,15 @@ VALUES {$all_values}\nSQL;\n$conn->query($message_insert_query);\n+ $time = earliest_time_considered_current();\n+ $unread_query = <<<SQL\n+UPDATE memberships m\n+LEFT JOIN focused f ON f.user = m.user AND f.thread = m.thread\n+ AND f.time > {$time}\n+SET m.unread = 1\n+WHERE f.user IS NULL AND {$thread_creator_fragment}\n+SQL;\n+ $conn->query($unread_query);\n+\nreturn $return;\n}\n" }, { "change_type": "MODIFY", "old_path": "server/thread_lib.php", "new_path": "server/thread_lib.php", "diff": "@@ -244,7 +244,24 @@ function possibly_reset_thread_to_unread(\nreturn;\n}\n- $focused_elsewhere = check_threads_focused($unfocused_thread_ids);\n+ list($viewer_id, $is_user) = get_viewer_info();\n+ if (!$is_user) {\n+ return array();\n+ }\n+\n+ $unfocused_thread_ids = array_map(\n+ $unfocused_pairs = array();\n+ foreach ($unfocused_thread_ids as $unfocused_thread_id) {\n+ $unfocused_pairs[] = array($viewer_id, $unfocused_thread_id);\n+ }\n+ $focused_elsewhere_pairs = check_threads_focused($unfocused_pairs);\n+\n+ $focused_elsewhere = array();\n+ foreach ($focused_elsewhere_pairs as $focused_elsewhere_pair) {\n+ list($viewer_id, $focused_elsewhere_id) = $focused_elsewhere_pair;\n+ $focused_elsewhere[] = $focused_elsewhere_id;\n+ }\n+\n$unread_candidates =\narray_values(array_diff($unfocused_thread_ids, $focused_elsewhere));\nif (!$unread_candidates) {\n@@ -274,7 +291,6 @@ SQL;\n}\n$thread_ids_sql_string = implode(\", \", $to_reset);\n- $viewer_id = get_viewer_id();\n$query = <<<SQL\nUPDATE memberships\nSET unread = 1\n@@ -299,30 +315,38 @@ SQL;\n$conn->query($query);\n}\n-// does not verify $thread_ids!\n-function check_threads_focused($thread_ids) {\n+// $thread_user_pairs is an array of thread, user pairs\n+function check_threads_focused($thread_user_pairs) {\nglobal $conn;\n- list($viewer_id, $is_user) = get_viewer_info();\n- if (!$is_user) {\n- return array();\n+ $sql_fragments = array();\n+ foreach ($thread_user_pairs as $thread_user_pair) {\n+ list($user_id, $thread_id) = $thread_user_pair;\n+ $user_id = (int)$user_id;\n+ $thread_id = (int)$thread_id;\n+ $sql_fragments[] = \"(user = {$user_id} AND thread = {$thread_id})\";\n}\n+ $user_thread_clause = \"(\" . implode(\" OR \", $sql_fragments) . \")\";\n- $thread_ids_sql_string = implode(\", \", $thread_ids);\n- $time = round(microtime(true) * 1000) - PING_INTERVAL; // in milliseconds\n+ $time = earliest_time_considered_current();\n$query = <<<SQL\n-SELECT thread\n+SELECT user, thread\nFROM focused\n-WHERE user = {$viewer_id}\n- AND thread IN ({$thread_ids_sql_string})\n- AND time > {$time}\n+WHERE {$user_thread_clause} AND time > {$time}\n+GROUP BY user, thread\nSQL;\n$result = $conn->query($query);\n$focused_thread_ids = array();\nwhile ($row = $result->fetch_assoc()) {\n+ $user_id = (int)$row['user'];\n$thread_id = (int)$row['thread'];\n- $focused_thread_ids[$thread_id] = $thread_id;\n+ $focused_thread_ids[] = array($user_id, $thread_id);\n+ }\n+ return $focused_thread_ids;\n}\n- return array_values($focused_thread_ids);\n+\n+function earliest_time_considered_current() {\n+ // in milliseconds\n+ return round(microtime(true) * 1000) - PING_INTERVAL - 1500;\n}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Mark threads as unread when new messages are created Exceptions are when a user is the creator of the message and when a user is currently viewing the thread
129,187
20.12.2017 14:37:32
18,000
57a73460ca9d1fa254d94e02c5ba7fea37cbf04c
Nav changes as a result of thread creation done in NEW_THREAD_SUCCESS action Doing this in separate actions caused nav changes to propagate before Redux actually had the new thread which caused errors.
[ { "change_type": "MODIFY", "old_path": "native/chat/add-thread.react.js", "new_path": "native/chat/add-thread.react.js", "diff": "@@ -57,7 +57,6 @@ 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';\nconst tagInputProps = {\nplaceholder: \"username\",\n@@ -74,7 +73,6 @@ type Props = {\nparentThreadInfo: ?ThreadInfo,\notherUserInfos: {[id: string]: UserInfo},\nuserSearchIndex: SearchIndex,\n- secondChatSubrouteKey: ?string,\n// Redux dispatch functions\ndispatchActionPromise: DispatchActionPromise,\n// async functions that hit server APIs\n@@ -115,7 +113,6 @@ class InnerAddThread extends React.PureComponent<Props, State> {\nparentThreadInfo: threadInfoPropType,\notherUserInfos: PropTypes.objectOf(userInfoPropType).isRequired,\nuserSearchIndex: PropTypes.instanceOf(SearchIndex).isRequired,\n- secondChatSubrouteKey: PropTypes.string,\ndispatchActionPromise: PropTypes.func.isRequired,\nnewChatThread: PropTypes.func.isRequired,\nsearchUsers: PropTypes.func.isRequired,\n@@ -410,7 +407,7 @@ class InnerAddThread extends React.PureComponent<Props, State> {\nasync newChatThreadAction(name: string) {\ntry {\n- const response = await this.props.newChatThread(\n+ return await this.props.newChatThread(\nname,\nthis.state.selectedPrivacyIndex === 0\n? visibilityRules.CHAT_NESTED_OPEN\n@@ -419,14 +416,6 @@ class InnerAddThread extends React.PureComponent<Props, State> {\nthis.state.userInfoInputArray.map((userInfo: UserInfo) => userInfo.id),\nthis.props.parentThreadInfo ? this.props.parentThreadInfo.id : null,\n);\n- const secondChatSubrouteKey = this.props.secondChatSubrouteKey;\n- invariant(secondChatSubrouteKey, \"should be set\");\n- this.props.navigation.goBack(secondChatSubrouteKey);\n- this.props.navigation.navigate(\n- MessageListRouteName,\n- { threadInfo: response.newThreadInfo },\n- );\n- return response;\n} catch (e) {\nAlert.alert(\n\"Unknown error\",\n@@ -557,10 +546,6 @@ const AddThread = connect(\nparentThreadInfo = state.threadInfos[parentThreadID];\ninvariant(parentThreadInfo, \"parent thread should exist\");\n}\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@@ -568,9 +553,6 @@ const AddThread = connect(\nuserInfoSelectorForOtherMembersOfThread(parentThreadID)(state),\nuserSearchIndex:\nuserSearchIndexForOtherMembersOfThread(parentThreadID)(state),\n- secondChatSubrouteKey: secondChatSubroute && secondChatSubroute.key\n- ? secondChatSubroute.key\n- : null,\ncookie: state.cookie,\n};\n},\n" }, { "change_type": "MODIFY", "old_path": "native/navigation-setup.js", "new_path": "native/navigation-setup.js", "diff": "@@ -13,7 +13,10 @@ 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';\n+import type {\n+ LeaveThreadResult,\n+ NewThreadResult,\n+} from 'lib/actions/thread-actions';\nimport {\nTabNavigator,\n@@ -43,6 +46,7 @@ import {\nleaveThreadActionTypes,\njoinThreadActionTypes,\nsubscribeActionTypes,\n+ newThreadActionTypes,\n} from 'lib/actions/thread-actions';\nimport {\n@@ -299,6 +303,17 @@ function reduceNavInfo(state: NavInfo, action: *): NavInfo {\naction.payload,\n),\n};\n+ } else if (action.type === newThreadActionTypes.success) {\n+ return {\n+ startDate: state.startDate,\n+ endDate: state.endDate,\n+ home: state.home,\n+ threadID: state.threadID,\n+ navigationState: replaceChatStackWithNewThread(\n+ state.navigationState,\n+ action.payload,\n+ ),\n+ };\n}\nreturn state;\n}\n@@ -549,6 +564,33 @@ function filterChatScreensForThreadInfos(\nreturn { ...state, routes: newRootSubRoutes };\n}\n+function replaceChatStackWithNewThread(\n+ state: NavigationState,\n+ payload: NewThreadResult,\n+): NavigationState {\n+ const appRoute = assertNavigationRouteNotLeafNode(state.routes[0]);\n+ const chatRoute = assertNavigationRouteNotLeafNode(appRoute.routes[1]);\n+\n+ const newChatRoute = removeScreensFromStack(\n+ chatRoute,\n+ (route: NavigationRoute) => route.routeName === ChatThreadListRouteName\n+ ? \"break\"\n+ : \"remove\",\n+ );\n+ newChatRoute.routes.push({\n+ key: 'NewThreadMessageList',\n+ routeName: MessageListRouteName,\n+ params: { threadInfo: payload.newThreadInfo },\n+ });\n+ newChatRoute.index = 1;\n+\n+ const newAppSubRoutes = [ ...appRoute.routes ];\n+ newAppSubRoutes[1] = newChatRoute;\n+ const newRootSubRoutes = [ ...state.routes ];\n+ newRootSubRoutes[0] = { ...appRoute, routes: newAppSubRoutes };\n+ return { ...state, routes: newRootSubRoutes };\n+}\n+\nexport {\nhandleURLActionType,\nnavigateToAppActionType,\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Nav changes as a result of thread creation done in NEW_THREAD_SUCCESS action Doing this in separate actions caused nav changes to propagate before Redux actually had the new thread which caused errors.
129,187
20.12.2017 17:17:03
18,000
a777e6c2b4c956192f3b76b7700bfe853b7491d8
Make sure new thread messages get assigned to the right threads when a new thread is created Right now all of them are attributed to the new thread, but if a child thread is created then a new message for its parent thread is created.
[ { "change_type": "MODIFY", "old_path": "lib/actions/thread-actions.js", "new_path": "lib/actions/thread-actions.js", "diff": "@@ -4,8 +4,6 @@ import type { ThreadInfo, ThreadCurrentUserInfo } from '../types/thread-types';\nimport type { VisibilityRules } from '../types/thread-types';\nimport type { FetchJSON } from '../utils/fetch-json';\nimport type {\n- RawThreadCreationInfo,\n- RawSubThreadCreationInfo,\nRawMessageInfo,\nMessageTruncationStatus,\n} from '../types/message-types';\n@@ -142,10 +140,9 @@ async function changeThreadMemberRoles(\n};\n}\n-type RawCreationInfo = RawThreadCreationInfo | RawSubThreadCreationInfo;\nexport type NewThreadResult = {|\nnewThreadInfo: ThreadInfo,\n- newMessageInfos: RawCreationInfo[],\n+ newMessageInfos: RawMessageInfo[],\n|};\nconst newThreadActionTypes = {\nstarted: \"NEW_THREAD_STARTED\",\n" }, { "change_type": "MODIFY", "old_path": "lib/reducers/message-reducer.js", "new_path": "lib/reducers/message-reducer.js", "diff": "@@ -340,25 +340,21 @@ function reduceMessageStore(\nthreads: _omit([ threadID ])(messageStore.threads),\n};\n} else if (action.type === newThreadActionTypes.success) {\n- const threadID = action.payload.newThreadInfo.id;\n- const newMessages = { ...messageStore.messages };\n- const messageIDs = [];\n- for (let rawMessageInfo of action.payload.newMessageInfos) {\n- newMessages[rawMessageInfo.id] = rawMessageInfo;\n- messageIDs.push(rawMessageInfo.id);\n+ const newThreadID = action.payload.newThreadInfo.id;\n+ const truncationStatuses = {};\n+ for (let messageInfo of action.payload.newMessageInfos) {\n+ truncationStatuses[messageInfo.threadID] =\n+ messageInfo.threadID === newThreadID\n+ ? messageTruncationStatus.EXHAUSTIVE\n+ : messageTruncationStatus.UNCHANGED;\n}\n- return {\n- messages: newMessages,\n- threads: {\n- ...messageStore.threads,\n- [threadID]: {\n- messageIDs,\n- startReached: true,\n- lastNavigatedTo: 0,\n- lastPruned: Date.now(),\n- },\n- },\n- };\n+ return mergeNewMessages(\n+ messageStore,\n+ action.payload.newMessageInfos,\n+ truncationStatuses,\n+ null,\n+ false,\n+ );\n} else if (\naction.type === changeThreadSettingsActionTypes.success ||\naction.type === addUsersToThreadActionTypes.success ||\n" }, { "change_type": "MODIFY", "old_path": "lib/types/message-types.js", "new_path": "lib/types/message-types.js", "diff": "@@ -71,7 +71,7 @@ type RawInitialThreadState = {|\nmemberIDs: string[],\n|};\n-export type RawThreadCreationInfo = {|\n+type RawThreadCreationInfo = {|\ntype: typeof messageType.CREATE_THREAD,\nid: string,\nthreadID: string,\n@@ -80,7 +80,7 @@ export type RawThreadCreationInfo = {|\ninitialThreadState: RawInitialThreadState,\n|};\n-export type RawAddMembersInfo = {|\n+type RawAddMembersInfo = {|\ntype: typeof messageType.ADD_MEMBERS,\nid: string,\nthreadID: string,\n@@ -89,7 +89,7 @@ export type RawAddMembersInfo = {|\naddedUserIDs: string[],\n|};\n-export type RawSubThreadCreationInfo = {|\n+type RawSubThreadCreationInfo = {|\ntype: typeof messageType.CREATE_SUB_THREAD,\nid: string,\nthreadID: string,\n@@ -98,7 +98,7 @@ export type RawSubThreadCreationInfo = {|\nchildThreadID: string,\n|};\n-export type RawChangeThreadSettingsInfo = {|\n+type RawChangeThreadSettingsInfo = {|\ntype: typeof messageType.CHANGE_SETTINGS,\nid: string,\nthreadID: string,\n@@ -108,7 +108,7 @@ export type RawChangeThreadSettingsInfo = {|\nvalue: string | number,\n|};\n-export type RawRemoveMembersInfo = {|\n+type RawRemoveMembersInfo = {|\ntype: typeof messageType.REMOVE_MEMBERS,\nid: string,\nthreadID: string,\n@@ -117,7 +117,7 @@ export type RawRemoveMembersInfo = {|\nremovedUserIDs: string[],\n|};\n-export type RawChangeRoleInfo = {|\n+type RawChangeRoleInfo = {|\ntype: typeof messageType.CHANGE_ROLE,\nid: string,\nthreadID: string,\n@@ -127,7 +127,7 @@ export type RawChangeRoleInfo = {|\nnewRole: string,\n|};\n-export type RawLeaveThreadInfo = {|\n+type RawLeaveThreadInfo = {|\ntype: typeof messageType.LEAVE_THREAD,\nid: string,\nthreadID: string,\n@@ -135,7 +135,7 @@ export type RawLeaveThreadInfo = {|\ntime: number,\n|};\n-export type RawJoinThreadInfo = {|\n+type RawJoinThreadInfo = {|\ntype: typeof messageType.JOIN_THREAD,\nid: string,\nthreadID: string,\n@@ -143,7 +143,7 @@ export type RawJoinThreadInfo = {|\ntime: number,\n|};\n-export type RawCreateEntryInfo = {|\n+type RawCreateEntryInfo = {|\ntype: typeof messageType.CREATE_ENTRY,\nid: string,\nthreadID: string,\n@@ -154,7 +154,7 @@ export type RawCreateEntryInfo = {|\ntext: string,\n|};\n-export type RawEditEntryInfo = {|\n+type RawEditEntryInfo = {|\ntype: typeof messageType.EDIT_ENTRY,\nid: string,\nthreadID: string,\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Make sure new thread messages get assigned to the right threads when a new thread is created Right now all of them are attributed to the new thread, but if a child thread is created then a new message for its parent thread is created.
129,187
20.12.2017 19:15:01
18,000
bed0da3e2f3e15059635974c2e40e667103dd857
Stop doing individual permission checks for each subthread creation message we get Instead, we're embedding the information we need in the results of the message query.
[ { "change_type": "MODIFY", "old_path": "server/message_lib.php", "new_path": "server/message_lib.php", "diff": "@@ -119,17 +119,24 @@ function get_message_infos($thread_selection_criteria, $number_per_thread) {\n$visibility_nested_open = VISIBILITY_NESTED_OPEN;\n$vis_permission_extract_string = \"$.\" . PERMISSION_VISIBLE . \".value\";\n$int_number_per_thread = (int)$number_per_thread;\n+ $create_sub_thread = MESSAGE_TYPE_CREATE_SUB_THREAD;\n$query = <<<SQL\nSET @num := 0, @thread := '';\nSELECT x.id, x.thread AS threadID, x.content, x.time, x.type,\n- u.username AS creator, x.user AS creatorID\n+ u.username AS creator, x.user AS creatorID, x.subthread_permissions,\n+ x.subthread_visibility_rules, x.subthread_edit_rules\nFROM (\nSELECT m.id, m.user, m.content, m.time, m.type,\n@num := if(@thread = m.thread, @num + 1, 1) AS number,\n- @thread := m.thread AS thread\n+ @thread := m.thread AS thread, stm.permissions AS subthread_permissions,\n+ st.visibility_rules AS subthread_visibility_rules,\n+ st.edit_rules AS subthread_edit_rules\nFROM messages m\nLEFT JOIN threads t ON t.id = m.thread\nLEFT JOIN memberships mm ON mm.thread = m.thread AND mm.user = {$viewer_id}\n+ LEFT JOIN threads st ON m.type = {$create_sub_thread} AND st.id = m.content\n+ LEFT JOIN memberships stm ON m.type = {$create_sub_thread}\n+ AND stm.thread = m.content AND stm.user = {$viewer_id}\nWHERE\n(\nJSON_EXTRACT(mm.permissions, '{$vis_permission_extract_string}') IS TRUE\n@@ -214,12 +221,19 @@ function get_messages_since(\n$visibility_open = VISIBILITY_OPEN;\n$visibility_nested_open = VISIBILITY_NESTED_OPEN;\n$vis_permission_extract_string = \"$.\" . PERMISSION_VISIBLE . \".value\";\n+ $create_sub_thread = MESSAGE_TYPE_CREATE_SUB_THREAD;\n$query = <<<SQL\nSELECT m.id, m.thread AS threadID, m.content, m.time, m.type,\n- u.username AS creator, m.user AS creatorID\n+ u.username AS creator, m.user AS creatorID,\n+ stm.permissions AS subthread_permissions,\n+ st.visibility_rules AS subthread_visibility_rules,\n+ st.edit_rules AS subthread_edit_rules\nFROM messages m\nLEFT JOIN threads t ON t.id = m.thread\nLEFT JOIN memberships mm ON mm.thread = m.thread AND mm.user = {$viewer_id}\n+LEFT JOIN threads st ON m.type = {$create_sub_thread} AND st.id = m.content\n+LEFT JOIN memberships stm ON m.type = {$create_sub_thread}\n+ AND stm.thread = m.content AND stm.user = {$viewer_id}\nLEFT JOIN users u ON u.id = m.user\nWHERE\n(\n@@ -289,7 +303,12 @@ function message_from_row($row) {\n$message['addedUserIDs'] = json_decode($row['content'], true);\n} else if ($type === MESSAGE_TYPE_CREATE_SUB_THREAD) {\n$child_thread_id = $row['content'];\n- if (!check_thread_permission((int)$child_thread_id, PERMISSION_KNOW_OF)) {\n+ $subthread_permission_info = get_info_from_permissions_row(array(\n+ \"permissions\" => $row['subthread_permissions'],\n+ \"visibility_rules\" => $row['subthread_visibility_rules'],\n+ \"edit_rules\" => $row['subthread_edit_rules'],\n+ ));\n+ if (!permission_helper($subthread_permission_info, PERMISSION_KNOW_OF)) {\nreturn null;\n}\n$message['childThreadID'] = $child_thread_id;\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Stop doing individual permission checks for each subthread creation message we get Instead, we're embedding the information we need in the results of the message query.
129,187
20.12.2017 21:54:16
18,000
c464d453fef4aee2c00bc4a3942612c765e59021
Make sure possibly_reset_thread_to_unread compares latest visible message We shouldn't consider messages the client can't see when verifying that their most recent message is correct.
[ { "change_type": "MODIFY", "old_path": "server/thread_lib.php", "new_path": "server/thread_lib.php", "diff": "require_once('config.php');\nrequire_once('auth.php');\nrequire_once('permissions.php');\n+require_once('message_lib.php');\ndefine(\"VISIBILITY_OPEN\", 0);\ndefine(\"VISIBILITY_CLOSED\", 1);\n@@ -257,7 +258,7 @@ function possibly_reset_thread_to_unread(\n$focused_elsewhere = array();\nforeach ($focused_elsewhere_pairs as $focused_elsewhere_pair) {\n- list($viewer_id, $focused_elsewhere_id) = $focused_elsewhere_pair;\n+ list($_, $focused_elsewhere_id) = $focused_elsewhere_pair;\n$focused_elsewhere[] = $focused_elsewhere_id;\n}\n@@ -268,11 +269,20 @@ function possibly_reset_thread_to_unread(\n}\n$thread_ids_sql_string = implode(\", \", $unread_candidates);\n+ $create_sub_thread = MESSAGE_TYPE_CREATE_SUB_THREAD;\n+ $permission_extract_string = \"$.\" . PERMISSION_KNOW_OF . \".value\";\n$query = <<<SQL\n-SELECT thread, MAX(id) AS latest_message\n-FROM messages\n-WHERE thread IN ({$thread_ids_sql_string})\n-GROUP BY thread\n+SELECT m.thread, MAX(m.id) AS latest_message\n+FROM messages m\n+LEFT JOIN threads st ON m.type = {$create_sub_thread} AND st.id = m.content\n+LEFT JOIN memberships stm ON m.type = {$create_sub_thread}\n+ AND stm.thread = m.content AND stm.user = {$viewer_id}\n+WHERE m.thread IN ({$thread_ids_sql_string}) AND\n+ (\n+ m.type != {$create_sub_thread} OR\n+ JSON_EXTRACT(stm.permissions, '{$permission_extract_string}') IS TRUE\n+ )\n+GROUP BY m.thread\nSQL;\n$result = $conn->query($query);\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Make sure possibly_reset_thread_to_unread compares latest visible message We shouldn't consider messages the client can't see when verifying that their most recent message is correct.
129,187
20.12.2017 22:25:59
18,000
e54232bbb6beca7c848c95234b62d09943a21929
Forgot to import a type
[ { "change_type": "MODIFY", "old_path": "lib/shared/thread-utils.js", "new_path": "lib/shared/thread-utils.js", "diff": "// @flow\n-import type { ThreadInfo, ThreadPermission } from '../types/thread-types';\n+import type {\n+ ThreadInfo,\n+ ThreadPermission,\n+ MemberInfo,\n+} from '../types/thread-types';\nimport Color from 'color';\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Forgot to import a type
129,187
20.12.2017 22:37:52
18,000
f37169cf11ce8309e2f1bd76d1001b15536017ac
Upgrade react-native to 0.51.0 Easiest upgrade ever. Should I be concerned?
[ { "change_type": "MODIFY", "old_path": "native/.flowconfig", "new_path": "native/.flowconfig", "diff": "@@ -45,12 +45,12 @@ suppress_type=$FlowFixMeProps\nsuppress_type=$FlowFixMeState\nsuppress_type=$FixMe\n-suppress_comment=\\\\(.\\\\|\\n\\\\)*\\\\$FlowFixMe\\\\($\\\\|[^(]\\\\|(\\\\(>=0\\\\.\\\\(5[0-6]\\\\|[1-4][0-9]\\\\|[0-9]\\\\).[0-9]\\\\)? *\\\\(site=[a-z,_]*react_native[a-z,_]*\\\\)?)\\\\)\n-suppress_comment=\\\\(.\\\\|\\n\\\\)*\\\\$FlowIssue\\\\((\\\\(>=0\\\\.\\\\(5[0-6]\\\\|[1-4][0-9]\\\\|[0-9]\\\\).[0-9]\\\\)? *\\\\(site=[a-z,_]*react_native[a-z,_]*\\\\)?)\\\\)?:? #[0-9]+\n+suppress_comment=\\\\(.\\\\|\\n\\\\)*\\\\$FlowFixMe\\\\($\\\\|[^(]\\\\|(\\\\(>=0\\\\.\\\\(5[0-7]\\\\|[1-4][0-9]\\\\|[0-9]\\\\).[0-9]\\\\)? *\\\\(site=[a-z,_]*react_native[a-z,_]*\\\\)?)\\\\)\n+suppress_comment=\\\\(.\\\\|\\n\\\\)*\\\\$FlowIssue\\\\((\\\\(>=0\\\\.\\\\(5[0-7]\\\\|[1-4][0-9]\\\\|[0-9]\\\\).[0-9]\\\\)? *\\\\(site=[a-z,_]*react_native[a-z,_]*\\\\)?)\\\\)?:? #[0-9]+\nsuppress_comment=\\\\(.\\\\|\\n\\\\)*\\\\$FlowFixedInNextDeploy\nsuppress_comment=\\\\(.\\\\|\\n\\\\)*\\\\$FlowExpectedError\nunsafe.enable_getters_and_setters=true\n[version]\n-^0.56.0\n+^0.57.0\n" }, { "change_type": "MODIFY", "old_path": "native/package-lock.json", "new_path": "native/package-lock.json", "diff": "\"resolved\": \"https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-3.0.0.tgz\",\n\"integrity\": \"sha512-O/klc27mWNUigtv0F8NJWbLF00OcegQalkqKURWdosW08YZKi4m6CnSUSvIZG1otNJbTWhN01Hhz389DW7mvDQ==\"\n},\n+ \"ansi-gray\": {\n+ \"version\": \"0.1.1\",\n+ \"resolved\": \"https://registry.npmjs.org/ansi-gray/-/ansi-gray-0.1.1.tgz\",\n+ \"integrity\": \"sha1-KWLPVOyXksSFEKPetSRDaGHvclE=\",\n+ \"requires\": {\n+ \"ansi-wrap\": \"0.1.0\"\n+ }\n+ },\n\"ansi-regex\": {\n\"version\": \"2.1.1\",\n\"resolved\": \"https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz\",\n\"resolved\": \"https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz\",\n\"integrity\": \"sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=\"\n},\n+ \"ansi-wrap\": {\n+ \"version\": \"0.1.0\",\n+ \"resolved\": \"https://registry.npmjs.org/ansi-wrap/-/ansi-wrap-0.1.0.tgz\",\n+ \"integrity\": \"sha1-qCJQ3bABXponyoLoLqYDu/pF768=\"\n+ },\n\"anymatch\": {\n\"version\": \"1.3.2\",\n\"resolved\": \"https://registry.npmjs.org/anymatch/-/anymatch-1.3.2.tgz\",\n\"trim-right\": \"1.0.1\"\n}\n},\n+ \"babel-helper-builder-binary-assignment-operator-visitor\": {\n+ \"version\": \"6.24.1\",\n+ \"resolved\": \"https://registry.npmjs.org/babel-helper-builder-binary-assignment-operator-visitor/-/babel-helper-builder-binary-assignment-operator-visitor-6.24.1.tgz\",\n+ \"integrity\": \"sha1-zORReto1b0IgvK6KAsKzRvmlZmQ=\",\n+ \"requires\": {\n+ \"babel-helper-explode-assignable-expression\": \"6.24.1\",\n+ \"babel-runtime\": \"6.26.0\",\n+ \"babel-types\": \"6.26.0\"\n+ }\n+ },\n\"babel-helper-builder-react-jsx\": {\n\"version\": \"6.26.0\",\n\"resolved\": \"https://registry.npmjs.org/babel-helper-builder-react-jsx/-/babel-helper-builder-react-jsx-6.26.0.tgz\",\n\"lodash\": \"4.17.4\"\n}\n},\n+ \"babel-helper-explode-assignable-expression\": {\n+ \"version\": \"6.24.1\",\n+ \"resolved\": \"https://registry.npmjs.org/babel-helper-explode-assignable-expression/-/babel-helper-explode-assignable-expression-6.24.1.tgz\",\n+ \"integrity\": \"sha1-8luCz33BBDPFX3BZLVdGQArCLKo=\",\n+ \"requires\": {\n+ \"babel-runtime\": \"6.26.0\",\n+ \"babel-traverse\": \"6.26.0\",\n+ \"babel-types\": \"6.26.0\"\n+ }\n+ },\n\"babel-helper-function-name\": {\n\"version\": \"6.24.1\",\n\"resolved\": \"https://registry.npmjs.org/babel-helper-function-name/-/babel-helper-function-name-6.24.1.tgz\",\n\"resolved\": \"https://registry.npmjs.org/babel-plugin-syntax-dynamic-import/-/babel-plugin-syntax-dynamic-import-6.18.0.tgz\",\n\"integrity\": \"sha1-jWomIpyDdFqZgqRBBRVyyqF5sdo=\"\n},\n+ \"babel-plugin-syntax-exponentiation-operator\": {\n+ \"version\": \"6.13.0\",\n+ \"resolved\": \"https://registry.npmjs.org/babel-plugin-syntax-exponentiation-operator/-/babel-plugin-syntax-exponentiation-operator-6.13.0.tgz\",\n+ \"integrity\": \"sha1-nufoM3KQ2pUoggGmpX9BcDF4MN4=\"\n+ },\n\"babel-plugin-syntax-flow\": {\n\"version\": \"6.18.0\",\n\"resolved\": \"https://registry.npmjs.org/babel-plugin-syntax-flow/-/babel-plugin-syntax-flow-6.18.0.tgz\",\n\"babel-runtime\": \"6.26.0\"\n}\n},\n+ \"babel-plugin-transform-exponentiation-operator\": {\n+ \"version\": \"6.24.1\",\n+ \"resolved\": \"https://registry.npmjs.org/babel-plugin-transform-exponentiation-operator/-/babel-plugin-transform-exponentiation-operator-6.24.1.tgz\",\n+ \"integrity\": \"sha1-KrDJx/MJj6SJB3cruBP+QejeOg4=\",\n+ \"requires\": {\n+ \"babel-helper-builder-binary-assignment-operator-visitor\": \"6.24.1\",\n+ \"babel-plugin-syntax-exponentiation-operator\": \"6.13.0\",\n+ \"babel-runtime\": \"6.26.0\"\n+ }\n+ },\n\"babel-plugin-transform-flow-strip-types\": {\n\"version\": \"6.22.0\",\n\"resolved\": \"https://registry.npmjs.org/babel-plugin-transform-flow-strip-types/-/babel-plugin-transform-flow-strip-types-6.22.0.tgz\",\n}\n},\n\"chardet\": {\n- \"version\": \"0.4.0\",\n- \"resolved\": \"https://registry.npmjs.org/chardet/-/chardet-0.4.0.tgz\",\n- \"integrity\": \"sha1-C74TVaxE16PtSpJXB8TvcPgZD2w=\"\n+ \"version\": \"0.4.2\",\n+ \"resolved\": \"https://registry.npmjs.org/chardet/-/chardet-0.4.2.tgz\",\n+ \"integrity\": \"sha1-tUc7M9yXxCTl2Y3IfVXU2KKci/I=\"\n},\n\"ci-info\": {\n\"version\": \"1.1.1\",\n\"simple-swizzle\": \"0.2.2\"\n}\n},\n+ \"color-support\": {\n+ \"version\": \"1.1.3\",\n+ \"resolved\": \"https://registry.npmjs.org/color-support/-/color-support-1.1.3.tgz\",\n+ \"integrity\": \"sha512-qiBjkpbMLO/HL68y+lh4q0/O1MZFj2RX6X/KmMa3+gJD3z+WwI1ZzDHysvqHGS3mP6mznPckpXmw1nI9cJjyRg==\"\n+ },\n\"combined-stream\": {\n\"version\": \"1.0.5\",\n\"resolved\": \"https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.5.tgz\",\n}\n},\n\"commander\": {\n- \"version\": \"2.11.0\",\n- \"resolved\": \"https://registry.npmjs.org/commander/-/commander-2.11.0.tgz\",\n- \"integrity\": \"sha512-b0553uYA5YAEGgyYIGYROzKQ7X5RAqedkfjiZxwi0kL1g3bOaBNNZfYkzt/CL0umgD5wc9Jec2FbB98CjkMRvQ==\"\n+ \"version\": \"2.12.2\",\n+ \"resolved\": \"https://registry.npmjs.org/commander/-/commander-2.12.2.tgz\",\n+ \"integrity\": \"sha512-BFnaq5ZOGcDN7FlrtBT4xxkgIToalIIxwjxLWVJ8bGTpe1LroqMiqQXdA7ygc7CRvaYS+9zfPGFnJqFSayx+AA==\"\n},\n\"compressible\": {\n\"version\": \"2.0.12\",\n\"resolved\": \"https://registry.npmjs.org/compressible/-/compressible-2.0.12.tgz\",\n\"integrity\": \"sha1-xZpcmdt2dn6YdlAOJx72OzSTvWY=\",\n\"requires\": {\n- \"mime-db\": \"1.31.0\"\n+ \"mime-db\": \"1.32.0\"\n},\n\"dependencies\": {\n\"mime-db\": {\n- \"version\": \"1.31.0\",\n- \"resolved\": \"https://registry.npmjs.org/mime-db/-/mime-db-1.31.0.tgz\",\n- \"integrity\": \"sha512-oB3w9lx50CMd6nfonoV5rBRUbJtjMifUHaFb5MfzjC8ksAIfVjT0BsX46SjjqBz7n9JGTrTX3paIeLSK+rS5fQ==\"\n+ \"version\": \"1.32.0\",\n+ \"resolved\": \"https://registry.npmjs.org/mime-db/-/mime-db-1.32.0.tgz\",\n+ \"integrity\": \"sha512-+ZWo/xZN40Tt6S+HyakUxnSOgff+JEdaneLWIm0Z6LmpCn5DMcZntLyUY5c/rTDog28LhXLKOUZKoTxTCAdBVw==\"\n}\n}\n},\n\"resolved\": \"https://registry.npmjs.org/external-editor/-/external-editor-2.1.0.tgz\",\n\"integrity\": \"sha512-E44iT5QVOUJBKij4IIV3uvxuNlbKS38Tw1HiupxEIHPv9qtC2PrDYohbXV5U+1jnfIXttny8gUhj+oZvflFlzA==\",\n\"requires\": {\n- \"chardet\": \"0.4.0\",\n+ \"chardet\": \"0.4.2\",\n\"iconv-lite\": \"0.4.18\",\n\"tmp\": \"0.0.33\"\n}\n\"integrity\": \"sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=\"\n},\n\"fancy-log\": {\n- \"version\": \"1.3.0\",\n- \"resolved\": \"https://registry.npmjs.org/fancy-log/-/fancy-log-1.3.0.tgz\",\n- \"integrity\": \"sha1-Rb4X0Cu5kX1gzP/UmVyZnmyMmUg=\",\n+ \"version\": \"1.3.2\",\n+ \"resolved\": \"https://registry.npmjs.org/fancy-log/-/fancy-log-1.3.2.tgz\",\n+ \"integrity\": \"sha1-9BEl49hPLn2JpD0G2VjI94vha+E=\",\n\"requires\": {\n- \"chalk\": \"1.1.3\",\n+ \"ansi-gray\": \"0.1.1\",\n+ \"color-support\": \"1.1.3\",\n\"time-stamp\": \"1.1.0\"\n}\n},\n\"requires\": {\n\"babel-core\": \"6.26.0\",\n\"babel-preset-fbjs\": \"2.1.4\",\n- \"core-js\": \"2.5.1\",\n+ \"core-js\": \"2.5.3\",\n\"cross-spawn\": \"5.1.0\",\n\"gulp-util\": \"3.0.8\",\n\"object-assign\": \"4.1.1\",\n},\n\"dependencies\": {\n\"core-js\": {\n- \"version\": \"2.5.1\",\n- \"resolved\": \"https://registry.npmjs.org/core-js/-/core-js-2.5.1.tgz\",\n- \"integrity\": \"sha1-rmh03GaTd4m4B1T/VCjfZoGcpQs=\"\n+ \"version\": \"2.5.3\",\n+ \"resolved\": \"https://registry.npmjs.org/core-js/-/core-js-2.5.3.tgz\",\n+ \"integrity\": \"sha1-isw4NFgk8W2DZbfJtCWRaOjtYD4=\"\n}\n}\n},\n}\n},\n\"flow-bin\": {\n- \"version\": \"0.56.0\",\n- \"resolved\": \"https://registry.npmjs.org/flow-bin/-/flow-bin-0.56.0.tgz\",\n- \"integrity\": \"sha1-zkMJIgOjRLqb9jwMq+ldlRRfbK0=\",\n+ \"version\": \"0.57.3\",\n+ \"resolved\": \"https://registry.npmjs.org/flow-bin/-/flow-bin-0.57.3.tgz\",\n+ \"integrity\": \"sha512-bbB7KLR1bLS0CvHSsKseOGFF6iI2N9ocL14EQv8Hng28ZksD0gNRzR2JopqA3WGrQYJukDU1W4ZuKoBaRuElFA==\",\n\"dev\": true\n},\n\"for-in\": {\n\"beeper\": \"1.1.1\",\n\"chalk\": \"1.1.3\",\n\"dateformat\": \"2.2.0\",\n- \"fancy-log\": \"1.3.0\",\n+ \"fancy-log\": \"1.3.2\",\n\"gulplog\": \"1.0.0\",\n\"has-gulplog\": \"0.1.0\",\n\"lodash._reescape\": \"3.0.0\",\n\"integrity\": \"sha512-sr1ZQph3UwHTR0XftSbK85OvBbxe/abLGzEnPENCQwmHf7sck8Oyu4ob3LgBxWWxRoM+QszeUyl7jbqapu2TqA==\"\n},\n\"image-size\": {\n- \"version\": \"0.6.1\",\n- \"resolved\": \"https://registry.npmjs.org/image-size/-/image-size-0.6.1.tgz\",\n- \"integrity\": \"sha512-lHMlI2MykfeHAQdtydQh4fTcBQVf4zLTA91w1euBe9rbmAfJ/iyzMh8H3KD9u1RldlHaMS3tmMV5TEe9BkmW9g==\"\n+ \"version\": \"0.6.2\",\n+ \"resolved\": \"https://registry.npmjs.org/image-size/-/image-size-0.6.2.tgz\",\n+ \"integrity\": \"sha512-pH3vDzpczdsKHdZ9xxR3O46unSjisgVx0IImay7Zz2EdhRVbCkj+nthx9OuuWEhakx9FAO+fNVGrF0rZ2oMOvw==\"\n},\n\"import-lazy\": {\n\"version\": \"2.1.0\",\n\"babylon\": \"6.18.0\",\n\"chalk\": \"1.1.3\",\n\"concat-stream\": \"1.6.0\",\n- \"core-js\": \"2.5.1\",\n+ \"core-js\": \"2.5.3\",\n\"debug\": \"2.6.8\",\n\"denodeify\": \"1.2.1\",\n\"fbjs\": \"0.8.14\",\n\"graceful-fs\": \"4.1.11\",\n- \"image-size\": \"0.6.1\",\n+ \"image-size\": \"0.6.2\",\n\"jest-docblock\": \"21.2.0\",\n\"jest-haste-map\": \"21.2.0\",\n\"json-stable-stringify\": \"1.0.1\",\n\"source-map\": \"0.5.7\",\n\"temp\": \"0.8.3\",\n\"throat\": \"4.1.0\",\n- \"uglify-es\": \"3.1.10\",\n+ \"uglify-es\": \"3.2.2\",\n\"wordwrap\": \"1.0.0\",\n\"write-file-atomic\": \"1.3.4\",\n\"xpipe\": \"1.0.5\"\n}\n},\n\"core-js\": {\n- \"version\": \"2.5.1\",\n- \"resolved\": \"https://registry.npmjs.org/core-js/-/core-js-2.5.1.tgz\",\n- \"integrity\": \"sha1-rmh03GaTd4m4B1T/VCjfZoGcpQs=\"\n+ \"version\": \"2.5.3\",\n+ \"resolved\": \"https://registry.npmjs.org/core-js/-/core-js-2.5.3.tgz\",\n+ \"integrity\": \"sha1-isw4NFgk8W2DZbfJtCWRaOjtYD4=\"\n},\n\"uglify-es\": {\n- \"version\": \"3.1.10\",\n- \"resolved\": \"https://registry.npmjs.org/uglify-es/-/uglify-es-3.1.10.tgz\",\n- \"integrity\": \"sha512-RwBX0aOeHvO8MKKUeLCArQGb9OZ6xA+EqfVxsE9wqK0saFYFVLIFvHeeCOg61C6NO6KCuSiG9OjNjCA+OB4nzg==\",\n+ \"version\": \"3.2.2\",\n+ \"resolved\": \"https://registry.npmjs.org/uglify-es/-/uglify-es-3.2.2.tgz\",\n+ \"integrity\": \"sha512-l+s5VLzFwGJfS+fbqaGf/Dfwo1MF13jLOF2ekL0PytzqEqQ6cVppvHf4jquqFok+35USMpKjqkYxy6pQyUcuug==\",\n\"requires\": {\n- \"commander\": \"2.11.0\",\n+ \"commander\": \"2.12.2\",\n\"source-map\": \"0.6.1\"\n},\n\"dependencies\": {\n}\n},\n\"mime\": {\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+ \"version\": \"1.6.0\",\n+ \"resolved\": \"https://registry.npmjs.org/mime/-/mime-1.6.0.tgz\",\n+ \"integrity\": \"sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==\"\n},\n\"mime-db\": {\n\"version\": \"1.29.0\",\n}\n},\n\"react-native\": {\n- \"version\": \"0.50.3\",\n- \"resolved\": \"https://registry.npmjs.org/react-native/-/react-native-0.50.3.tgz\",\n- \"integrity\": \"sha1-kSgr1TVsx9eUlpzcRDzHZDibmvQ=\",\n+ \"version\": \"0.51.0\",\n+ \"resolved\": \"https://registry.npmjs.org/react-native/-/react-native-0.51.0.tgz\",\n+ \"integrity\": \"sha512-XpLmz3C7DOds5TUwIOpQBEXqoFDtU2/HmMBzVItGlHtowXpcHoQxJYSxL4Z9u8B4EeDfSvGfU2TFHq0sV3xd3Q==\",\n\"requires\": {\n\"absolute-path\": \"0.0.0\",\n\"art\": \"0.10.1\",\n\"babel-plugin-syntax-trailing-function-commas\": \"6.22.0\",\n\"babel-plugin-transform-async-to-generator\": \"6.16.0\",\n\"babel-plugin-transform-class-properties\": \"6.24.1\",\n+ \"babel-plugin-transform-exponentiation-operator\": \"6.24.1\",\n\"babel-plugin-transform-flow-strip-types\": \"6.22.0\",\n\"babel-plugin-transform-object-rest-spread\": \"6.26.0\",\n\"babel-register\": \"6.26.0\",\n\"babel-runtime\": \"6.26.0\",\n\"base64-js\": \"1.2.1\",\n\"chalk\": \"1.1.3\",\n- \"commander\": \"2.11.0\",\n+ \"commander\": \"2.12.2\",\n\"connect\": \"2.30.2\",\n\"create-react-class\": \"15.6.2\",\n\"debug\": \"2.6.8\",\n\"inquirer\": \"3.3.0\",\n\"lodash\": \"4.17.4\",\n\"metro-bundler\": \"0.20.3\",\n- \"mime\": \"1.4.1\",\n+ \"mime\": \"1.6.0\",\n\"minimist\": \"1.2.0\",\n\"mkdirp\": \"0.5.1\",\n\"node-fetch\": \"1.7.1\",\n\"react-clone-referenced-element\": \"1.0.1\",\n\"react-devtools-core\": \"2.5.2\",\n\"react-timer-mixin\": \"0.13.3\",\n- \"regenerator-runtime\": \"0.9.6\",\n+ \"regenerator-runtime\": \"0.11.1\",\n\"rimraf\": \"2.6.1\",\n\"semver\": \"5.4.1\",\n\"shell-quote\": \"1.6.1\",\n\"integrity\": \"sha512-jVpo1GadrDAK59t/0jRx5VxYWQEDkkEKi6+HjE3joFVLfDOh9Xrdh0dF1eSq+BI/SwvTQ44gSscJ8N5zYL61sg==\"\n},\n\"regenerator-runtime\": {\n- \"version\": \"0.9.6\",\n- \"resolved\": \"https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.9.6.tgz\",\n- \"integrity\": \"sha1-0z65XQ0gAaS+OWWXB8UbDLcc4Ck=\"\n+ \"version\": \"0.11.1\",\n+ \"resolved\": \"https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz\",\n+ \"integrity\": \"sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg==\"\n},\n\"regenerator-transform\": {\n\"version\": \"0.10.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\",\n- \"react-native\": \"^0.50.3\",\n+ \"react-native\": \"^0.51.0\",\n\"react-native-keychain\": \"^1.2.1\",\n\"react-native-modal\": \"^4.0.0\",\n\"react-native-onepassword\": \"^1.0.6\",\n\"babel-jest\": \"^20.0.3\",\n\"babel-plugin-transform-remove-console\": \"^6.8.5\",\n\"babel-preset-react-native\": \"3.0.2\",\n- \"flow-bin\": \"^0.56.0\",\n+ \"flow-bin\": \"^0.57.3\",\n\"jest\": \"^20.0.4\",\n\"react-devtools\": \"^2.5.0\",\n\"react-test-renderer\": \"^15.6.1\"\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Upgrade react-native to 0.51.0 Easiest upgrade ever. Should I be concerned?
129,187
20.12.2017 23:40:50
18,000
0631995e26d64bb840094e10ebb07c81b8d7bc05
Don't set unread status on non-members
[ { "change_type": "MODIFY", "old_path": "server/message_lib.php", "new_path": "server/message_lib.php", "diff": "@@ -476,7 +476,7 @@ UPDATE memberships m\nLEFT JOIN focused f ON f.user = m.user AND f.thread = m.thread\nAND f.time > {$time}\nSET m.unread = 1\n-WHERE f.user IS NULL AND {$thread_creator_fragment}\n+WHERE m.role IS NOT NULL AND f.user IS NULL AND {$thread_creator_fragment}\nSQL;\n$conn->query($unread_query);\n" }, { "change_type": "MODIFY", "old_path": "server/thread_lib.php", "new_path": "server/thread_lib.php", "diff": "@@ -219,7 +219,9 @@ SQL;\n$query = <<<SQL\nUPDATE memberships\nSET unread = 0\n-WHERE thread IN ({$thread_ids_sql_string}) AND user = {$viewer_id}\n+WHERE m.role IS NOT NULL\n+ AND thread IN ({$thread_ids_sql_string})\n+ AND user = {$viewer_id}\nSQL;\n$conn->query($query);\n}\n@@ -303,7 +305,9 @@ SQL;\n$query = <<<SQL\nUPDATE memberships\nSET unread = 1\n-WHERE thread IN ({$thread_ids_sql_string}) AND user = {$viewer_id}\n+WHERE m.role IS NOT NULL\n+ AND thread IN ({$thread_ids_sql_string})\n+ AND user = {$viewer_id}\nSQL;\n$conn->query($query);\n}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Don't set unread status on non-members
129,187
21.12.2017 14:37:42
18,000
a8ef928e436a87db1a171b8dfde7699e764b028c
Actually show unread status in thread list on native
[ { "change_type": "MODIFY", "old_path": "native/chat/chat-thread-list-item.react.js", "new_path": "native/chat/chat-thread-list-item.react.js", "diff": "@@ -44,6 +44,9 @@ class ChatThreadListItem extends React.PureComponent<Props> {\nrender() {\nconst lastActivity = shortAbsoluteDate(this.props.data.lastUpdatedTime);\n+ const unreadStyle = this.props.data.threadInfo.currentUser.unread\n+ ? styles.unread\n+ : null;\nreturn (\n<Button\nonPress={this.onPress}\n@@ -53,7 +56,7 @@ class ChatThreadListItem extends React.PureComponent<Props> {\n>\n<View style={styles.container}>\n<View style={styles.row}>\n- <Text style={styles.threadName} numberOfLines={1}>\n+ <Text style={[styles.threadName, unreadStyle]} numberOfLines={1}>\n{this.props.data.threadInfo.name}\n</Text>\n<View style={styles.colorSplotch}>\n@@ -65,7 +68,9 @@ class ChatThreadListItem extends React.PureComponent<Props> {\n</View>\n<View style={styles.row}>\n{this.lastMessage()}\n- <Text style={styles.lastActivity}>{lastActivity}</Text>\n+ <Text style={[styles.lastActivity, unreadStyle]}>\n+ {lastActivity}\n+ </Text>\n</View>\n</View>\n</Button>\n@@ -112,6 +117,10 @@ const styles = StyleSheet.create({\ncolor: '#666666',\nmarginLeft: 10,\n},\n+ unread: {\n+ color: 'black',\n+ fontWeight: 'bold',\n+ },\n});\nexport default ChatThreadListItem;\n" }, { "change_type": "MODIFY", "old_path": "native/chat/message-preview.react.js", "new_path": "native/chat/message-preview.react.js", "diff": "@@ -30,10 +30,13 @@ class MessagePreview extends React.PureComponent<Props> {\nconst username = messageInfo.creator.isViewer\n? \"you: \"\n: `${messageInfo.creator.username || \"\"}: `;\n+ const unreadStyle = this.props.threadInfo.currentUser.unread\n+ ? styles.unread\n+ : null;\nif (messageInfo.type === messageType.TEXT) {\nreturn (\n- <Text style={styles.lastMessage} numberOfLines={1}>\n- <Text style={styles.username}>{username}</Text>\n+ <Text style={[styles.lastMessage, unreadStyle]} numberOfLines={1}>\n+ <Text style={[styles.username, unreadStyle]}>{username}</Text>\n{messageInfo.text}\n</Text>\n);\n@@ -43,7 +46,10 @@ class MessagePreview extends React.PureComponent<Props> {\nthis.props.threadInfo,\n));\nreturn (\n- <Text style={[styles.lastMessage, styles.robotext]} numberOfLines={1}>\n+ <Text\n+ style={[styles.lastMessage, styles.robotext, unreadStyle]}\n+ numberOfLines={1}\n+ >\n{robotext}\n</Text>\n);\n@@ -65,6 +71,9 @@ const styles = StyleSheet.create({\nrobotext: {\ncolor: '#AAAAAA',\n},\n+ unread: {\n+ color: 'black',\n+ },\n});\nexport default MessagePreview;\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Actually show unread status in thread list on native
129,187
21.12.2017 14:38:02
18,000
e3ea44c5bccefd6e1ef7a08149bd6016f19a9505
Make sure a currently focused thread is never unread on native
[ { "change_type": "MODIFY", "old_path": "native/redux-setup.js", "new_path": "native/redux-setup.js", "diff": "@@ -20,9 +20,10 @@ import { NavigationActions } from 'react-navigation';\nimport baseReducer from 'lib/reducers/master-reducer';\nimport { newSessionID } from 'lib/selectors/session-selectors';\n+\nimport { MessageListRouteName } from './chat/message-list.react';\nimport { getThreadIDFromParams } from './utils/navigation-utils';\n-\n+import { activeThreadSelector } from './selectors/nav-selectors';\nimport {\nhandleURLActionType,\nnavigateToAppActionType,\n@@ -130,14 +131,14 @@ function reducer(state: AppState, action: *) {\naction.type === NavigationActions.SET_PARAMS ||\naction.type === NavigationActions.RESET\n) {\n- return state;\n+ return validateUnreadStatus(state);\n}\nif (\naction.type === NavigationActions.NAVIGATE &&\naction.routeName === MessageListRouteName\n) {\nconst threadID = getThreadIDFromParams(action);\n- return {\n+ return validateUnreadStatus({\nnavInfo: state.navInfo,\ncurrentUserInfo: state.currentUserInfo,\nsessionID: state.sessionID,\n@@ -160,9 +161,41 @@ function reducer(state: AppState, action: *) {\nloadingStatuses: state.loadingStatuses,\ncookie: state.cookie,\nrehydrateConcluded: state.rehydrateConcluded,\n+ });\n+ }\n+ return validateUnreadStatus(baseReducer(state, action));\n+}\n+\n+// Makes sure a currently focused thread is never unread\n+function validateUnreadStatus(state: AppState): AppState {\n+ const activeThread = activeThreadSelector(state);\n+ if (activeThread && state.threadInfos[activeThread].currentUser.unread) {\n+ state = {\n+ navInfo: state.navInfo,\n+ currentUserInfo: state.currentUserInfo,\n+ sessionID: state.sessionID,\n+ entryStore: state.entryStore,\n+ lastUserInteraction: state.lastUserInteraction,\n+ threadInfos: {\n+ ...state.threadInfos,\n+ [activeThread]: {\n+ ...state.threadInfos[activeThread],\n+ currentUser: {\n+ ...state.threadInfos[activeThread].currentUser,\n+ unread: false,\n+ },\n+ },\n+ },\n+ userInfos: state.userInfos,\n+ messageStore: state.messageStore,\n+ drafts: state.drafts,\n+ currentAsOf: state.currentAsOf,\n+ loadingStatuses: state.loadingStatuses,\n+ cookie: state.cookie,\n+ rehydrateConcluded: state.rehydrateConcluded,\n};\n}\n- return baseReducer(state, action);\n+ return state;\n}\nconst store = createStore(\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Make sure a currently focused thread is never unread on native
129,187
21.12.2017 14:38:30
18,000
e65c3f2d2cff21c5b5fd164f8a6a96eb1b8fa9e6
Fix typo in unread SQL queries
[ { "change_type": "MODIFY", "old_path": "server/thread_lib.php", "new_path": "server/thread_lib.php", "diff": "@@ -220,7 +220,7 @@ SQL;\n$query = <<<SQL\nUPDATE memberships\nSET unread = 0\n-WHERE m.role IS NOT NULL\n+WHERE role IS NOT NULL\nAND thread IN ({$thread_ids_sql_string})\nAND user = {$viewer_id}\nSQL;\n@@ -306,7 +306,7 @@ SQL;\n$query = <<<SQL\nUPDATE memberships\nSET unread = 1\n-WHERE m.role IS NOT NULL\n+WHERE role IS NOT NULL\nAND thread IN ({$thread_ids_sql_string})\nAND user = {$viewer_id}\nSQL;\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Fix typo in unread SQL queries
129,187
21.12.2017 15:39:44
18,000
6ad6a514142a491897b737bf602e818e5cb99cdc
Hit update_focused_threads.php on backgrounding and foregrounding Also don't hit it if there is no change.
[ { "change_type": "MODIFY", "old_path": "native/app.react.js", "new_path": "native/app.react.js", "diff": "@@ -207,6 +207,12 @@ class AppWithNavigationState extends React.PureComponent<Props> {\n!this.activePingSubscription\n) {\nthis.activePingSubscription = setInterval(this.ping, pingFrequency);\n+ AppWithNavigationState.updateFocusedThreads(\n+ this.props,\n+ this.props.activeThread,\n+ null,\n+ null,\n+ );\n} else if (\nlastState === \"active\" &&\nthis.currentState &&\n@@ -215,6 +221,12 @@ class AppWithNavigationState extends React.PureComponent<Props> {\n) {\nclearInterval(this.activePingSubscription);\nthis.activePingSubscription = null;\n+ AppWithNavigationState.updateFocusedThreads(\n+ this.props,\n+ null,\n+ this.props.activeThread,\n+ this.props.activeThreadLatestMessage,\n+ );\n}\n}\n@@ -275,6 +287,9 @@ class AppWithNavigationState extends React.PureComponent<Props> {\nlatestMessage: oldActiveThreadLatestMessage,\n});\n}\n+ if (commands.length === 0) {\n+ return;\n+ }\nprops.dispatchActionPromise(\nupdateFocusedThreadsActionTypes,\nprops.updateFocusedThreads(commands),\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Hit update_focused_threads.php on backgrounding and foregrounding Also don't hit it if there is no change.
129,187
25.12.2017 15:24:16
18,000
b079391519041c40bc16a3421a46b672891a5675
Fix issue with order of get_message_infos SQL query MySQL 5.7 seems to have changed things such that the `SELECT` in the inner query gets executed before the `ORDER BY`. I think the `ORDER BY` is being lifted into the parent query or something? Anyways, this should fix it.
[ { "change_type": "MODIFY", "old_path": "server/message_lib.php", "new_path": "server/message_lib.php", "diff": "@@ -121,14 +121,16 @@ function get_message_infos($thread_selection_criteria, $number_per_thread) {\n$int_number_per_thread = (int)$number_per_thread;\n$create_sub_thread = MESSAGE_TYPE_CREATE_SUB_THREAD;\n$query = <<<SQL\n-SET @num := 0, @thread := '';\n-SELECT x.id, x.thread AS threadID, x.content, x.time, x.type,\n- u.username AS creator, x.user AS creatorID, x.subthread_permissions,\n- x.subthread_visibility_rules, x.subthread_edit_rules\n-FROM (\n- SELECT m.id, m.user, m.content, m.time, m.type,\n- @num := if(@thread = m.thread, @num + 1, 1) AS number,\n- @thread := m.thread AS thread, stm.permissions AS subthread_permissions,\n+SELECT * FROM (\n+ SELECT x.id, x.content, x.time, x.type, x.user AS creatorID,\n+ u.username AS creator, x.subthread_permissions,\n+ x.subthread_visibility_rules, x.subthread_edit_rules,\n+ @num := if(@thread = x.thread, @num + 1, 1) AS number,\n+ @thread := x.thread AS threadID\n+ FROM (SELECT @num := 0, @thread := '') init\n+ JOIN (\n+ SELECT m.id, m.thread, m.user, m.content, m.time, m.type,\n+ stm.permissions AS subthread_permissions,\nst.visibility_rules AS subthread_visibility_rules,\nst.edit_rules AS subthread_edit_rules\nFROM messages m\n@@ -146,19 +148,15 @@ FROM (\nORDER BY m.thread, m.time DESC\n) x\nLEFT JOIN users u ON u.id = x.user\n-WHERE x.number <= {$int_number_per_thread};\n+) y\n+WHERE y.number <= {$int_number_per_thread}\nSQL;\n- $query_result = $conn->multi_query($query);\n- if (!$query_result) {\n- return null;\n- }\n- $conn->next_result();\n- $row_result = $conn->store_result();\n+ $result = $conn->query($query);\n$messages = array();\n$users = array();\n$thread_to_message_count = array();\n- while ($row = $row_result->fetch_assoc()) {\n+ while ($row = $result->fetch_assoc()) {\n$users[$row['creatorID']] = array(\n'id' => $row['creatorID'],\n'username' => $row['creator'],\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Fix issue with order of get_message_infos SQL query MySQL 5.7 seems to have changed things such that the `SELECT` in the inner query gets executed before the `ORDER BY`. I think the `ORDER BY` is being lifted into the parent query or something? Anyways, this should fix it.
129,187
25.12.2017 16:06:19
18,000
e0759726fb53c0c4bd6542ec6fce3c26a76f1e49
Further iPhone X fixes
[ { "change_type": "MODIFY", "old_path": "native/calendar/calendar.react.js", "new_path": "native/calendar/calendar.react.js", "diff": "@@ -23,8 +23,8 @@ import {\nActivityIndicator,\nKeyboard,\nLayoutAnimation,\n- SafeAreaView,\n} from 'react-native';\n+import { SafeAreaView } from 'react-navigation';\nimport Icon from 'react-native-vector-icons/FontAwesome';\nimport { connect } from 'react-redux';\nimport PropTypes from 'prop-types';\n@@ -670,7 +670,10 @@ class InnerCalendar extends React.PureComponent<Props, State> {\n);\n}\nreturn (\n- <SafeAreaView style={styles.container}>\n+ <SafeAreaView\n+ forceInset={{ top: 'always', bottom: 'never' }}\n+ style={styles.container}\n+ >\n<TextHeightMeasurer\ntextToMeasure={this.state.textToMeasure}\nallHeightsMeasuredCallback={this.allHeightsMeasured}\n" }, { "change_type": "MODIFY", "old_path": "native/dimensions.js", "new_path": "native/dimensions.js", "diff": "@@ -7,6 +7,9 @@ if (Platform.OS === \"android\") {\n// Android's Dimensions.get doesn't include the status bar\nheight -= 24;\n}\n+if (Platform.OS === \"ios\" && DeviceInfo.isIPhoneX_deprecated) {\n+ height -= 34;\n+}\nconst windowHeight = height;\nconst windowWidth = width;\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Further iPhone X fixes
129,187
25.12.2017 16:47:53
18,000
88db89b184ec2d5e091811db73560383766b4bc4
Entry padding is 21 on iOS, not 20
[ { "change_type": "MODIFY", "old_path": "native/calendar/calendar.react.js", "new_path": "native/calendar/calendar.react.js", "diff": "@@ -614,7 +614,8 @@ class InnerCalendar extends React.PureComponent<Props, State> {\n} else if (item.itemType === \"header\") {\nreturn 31;\n} else if (item.itemType === \"entryInfo\") {\n- return 20 + item.entryInfo.textHeight;\n+ const verticalPadding = Platform.OS === \"ios\" ? 21 : 20;\n+ return verticalPadding + item.entryInfo.textHeight;\n} else if (item.itemType === \"footer\") {\nreturn 40;\n}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Entry padding is 21 on iOS, not 20
129,187
25.12.2017 23:12:28
18,000
fed01c2357f9802fd9649429adc68003377bd433
SQL typo in last commit
[ { "change_type": "MODIFY", "old_path": "server/set_device_token.php", "new_path": "server/set_device_token.php", "diff": "@@ -16,7 +16,7 @@ $device_token = $conn->real_escape_string($_POST['device_token']);\nlist($viewer_id, $is_user, $cookie_id) = get_viewer_info();\n$query = <<<SQL\n-UPDATE cookies SET device_token = {$device_token} WHERE id = {$cookie_id}\n+UPDATE cookies SET device_token = '{$device_token}' WHERE id = {$cookie_id}\nSQL;\n$conn->query($query);\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
SQL typo in last commit
129,187
26.12.2017 14:32:07
18,000
9d3ed2390fad2e0555aca5123c7a83863cd2685d
role is not a nullable field Check whether it's 0, not whether it's null
[ { "change_type": "MODIFY", "old_path": "native/redux-setup.js", "new_path": "native/redux-setup.js", "diff": "@@ -172,7 +172,7 @@ function validateState(oldState: AppState, state: AppState): AppState {\n};\n}\nif (activeThread && oldActiveThread !== activeThread) {\n- // Update messageStore.threads.[activeThread].lastNavigatedTo\n+ // Update messageStore.threads[activeThread].lastNavigatedTo\nstate = {\nnavInfo: state.navInfo,\ncurrentUserInfo: state.currentUserInfo,\n" }, { "change_type": "MODIFY", "old_path": "server/message_lib.php", "new_path": "server/message_lib.php", "diff": "@@ -378,9 +378,13 @@ function create_message_infos($new_message_infos) {\nreturn array();\n}\n- $content_by_index = array();\n$thread_creator_pairs = array();\n+ $content_by_index = array();\nforeach ($new_message_infos as $index => $new_message_info) {\n+ $thread_id = $new_message_info['threadID'];\n+ $creator_id = $new_message_info['creatorID'];\n+ $thread_creator_pairs[] =\n+ \"(m.thread = {$thread_id} AND m.user != {$creator_id})\";\nif ($new_message_info['type'] === MESSAGE_TYPE_CREATE_THREAD) {\n$content_by_index[$index] = $conn->real_escape_string(\njson_encode($new_message_info['initialThreadState'])\n@@ -430,10 +434,6 @@ function create_message_infos($new_message_infos) {\njson_encode($content)\n);\n}\n- $thread_id = $new_message_info['threadID'];\n- $creator_id = $new_message_info['creatorID'];\n- $thread_creator_pairs[] =\n- \"(m.thread = {$thread_id} AND m.user != {$creator_id})\";\n}\n$thread_creator_fragment = \"(\" . implode(\" OR \", $thread_creator_pairs) . \")\";\n@@ -474,7 +474,7 @@ UPDATE memberships m\nLEFT JOIN focused f ON f.user = m.user AND f.thread = m.thread\nAND f.time > {$time}\nSET m.unread = 1\n-WHERE m.role IS NOT NULL AND f.user IS NULL AND {$thread_creator_fragment}\n+WHERE m.role != 0 AND f.user IS NULL AND {$thread_creator_fragment}\nSQL;\n$conn->query($unread_query);\n" }, { "change_type": "MODIFY", "old_path": "server/thread_lib.php", "new_path": "server/thread_lib.php", "diff": "@@ -222,7 +222,7 @@ SQL;\n$query = <<<SQL\nUPDATE memberships\nSET unread = 0\n-WHERE role IS NOT NULL\n+WHERE role != 0\nAND thread IN ({$thread_ids_sql_string})\nAND user = {$viewer_id}\nSQL;\n@@ -308,7 +308,7 @@ SQL;\n$query = <<<SQL\nUPDATE memberships\nSET unread = 1\n-WHERE role IS NOT NULL\n+WHERE role != 0\nAND thread IN ({$thread_ids_sql_string})\nAND user = {$viewer_id}\nSQL;\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
role is not a nullable field Check whether it's 0, not whether it's null
129,187
27.12.2017 02:03:24
18,000
d3f4efa7f6846d751abb89a128b4af1e716d45c8
Call node.js from PHP
[ { "change_type": "MODIFY", "old_path": "jserver/package.json", "new_path": "jserver/package.json", "diff": "\"nodemon\": \"^1.14.3\"\n},\n\"dependencies\": {\n- \"lib\": \"file:../lib\",\n- \"express\": \"^4.16.2\"\n+ \"body-parser\": \"^1.18.2\",\n+ \"express\": \"^4.16.2\",\n+ \"lib\": \"file:../lib\"\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "jserver/src/app.js", "new_path": "jserver/src/app.js", "diff": "// @flow\n-import type { $Response, $Request } from 'express';\n-\nimport express from 'express';\n+import bodyParser from 'body-parser';\n-import { pluralize } from 'lib/utils/text-utils';\n+import errorHandler from './error_handler';\n+import { sendIOSPushNotifs } from './push/ios_notifs';\nconst app = express();\n-\n-app.get('/', function(req: $Request, res: $Response) {\n- res.send(pluralize(['one', 'two', 'three']));\n-});\n-\n-app.listen(process.env.PORT || 3000);\n+app.use(bodyParser.json());\n+app.post('/ios_push_notifs', errorHandler(sendIOSPushNotifs));\n+app.listen(parseInt(process.env.PORT) || 3000, 'localhost');\n" }, { "change_type": "ADD", "old_path": null, "new_path": "jserver/src/error_handler.js", "diff": "+// @flow\n+\n+import type { $Response, $Request } from 'express';\n+\n+type NodeHandler = (req: $Request, res: $Response) => Promise<void>;\n+type OurHandler = (req: $Request, res: $Response) => Promise<Object | string>;\n+\n+export default function errorHandler(handler: OurHandler): NodeHandler {\n+ return async (req: $Request, res: $Response) => {\n+ try {\n+ const result = await handler(req, res);\n+ const stringResult = typeof result === \"object\"\n+ ? JSON.stringify(result)\n+ : result;\n+ res.send(stringResult);\n+ } catch (error) {\n+ res.status(500).send(error.message);\n+ }\n+ };\n+}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "jserver/src/push/ios_notifs.js", "diff": "+// @flow\n+\n+import type { $Response, $Request } from 'express';\n+import type { RawMessageInfo } from 'lib/types/message-types';\n+\n+type IOSPushUserInfo = {\n+ deviceTokens: string[],\n+ messageInfos: RawMessageInfo[],\n+};\n+type IOSPushInfo = { [userID: string]: IOSPushUserInfo };\n+\n+async function sendIOSPushNotifs(req: $Request, res: $Response) {\n+ const pushInfo: IOSPushInfo = req.body;\n+ return pushInfo;\n+}\n+\n+export {\n+ sendIOSPushNotifs,\n+};\n" }, { "change_type": "ADD", "old_path": null, "new_path": "server/call_node.php", "diff": "+<?php\n+\n+function call_node($path, $blob) {\n+ $url = \"http://localhost:3000/\" . $path;\n+ $json = json_encode($blob);\n+\n+ $ch = curl_init($url);\n+ curl_setopt($ch, CURLOPT_HEADER, 1);\n+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);\n+ curl_setopt($ch, CURLOPT_POST, 1);\n+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);\n+ curl_setopt($ch, CURLOPT_POSTFIELDS, $json);\n+ curl_setopt($ch, CURLOPT_HTTPHEADER, array(\n+ 'Content-Type: application/json',\n+ 'Content-Length: ' . strlen($json),\n+ ));\n+\n+ $result = curl_exec($ch);\n+ $header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);\n+ $body = substr($result, $header_size);\n+ return json_decode($body, true);\n+}\n" }, { "change_type": "MODIFY", "old_path": "server/message_lib.php", "new_path": "server/message_lib.php", "diff": "@@ -5,6 +5,7 @@ require_once('auth.php');\nrequire_once('thread_lib.php');\nrequire_once('permissions.php');\nrequire_once('activity_lib.php');\n+require_once('call_node.php');\n// keep value in sync with numberPerThread in message_reducer.js\ndefine(\"DEFAULT_NUMBER_PER_THREAD\", 20);\n@@ -380,12 +381,19 @@ function create_message_infos($new_message_infos) {\n}\n$thread_creator_pairs = array();\n+ $threads_to_message_indices = array();\n$content_by_index = array();\nforeach ($new_message_infos as $index => $new_message_info) {\n$thread_id = $new_message_info['threadID'];\n$creator_id = $new_message_info['creatorID'];\n- $thread_creator_pairs[] =\n+ $thread_creator_pairs[$thread_id . $creator_id] =\n\"(m.thread = {$thread_id} AND m.user != {$creator_id})\";\n+\n+ if (!isset($threads_to_message_indices[$thread_id])) {\n+ $threads_to_message_indices[$thread_id] = array();\n+ }\n+ $threads_to_message_indices[$thread_id][] = $index;\n+\nif ($new_message_info['type'] === MESSAGE_TYPE_CREATE_THREAD) {\n$content_by_index[$index] = $conn->real_escape_string(\njson_encode($new_message_info['initialThreadState'])\n@@ -479,5 +487,44 @@ WHERE m.role != 0 AND f.user IS NULL AND {$thread_creator_fragment}\nSQL;\n$conn->query($unread_query);\n+ $notif_query = <<<SQL\n+SELECT m.user, m.thread, c2.ios_device_token\n+FROM memberships m\n+LEFT JOIN cookies c1 ON c1.user = m.user AND c1.last_ping > {$time}\n+LEFT JOIN cookies c2 ON c2.user = m.user AND c2.ios_device_token IS NOT NULL\n+WHERE c1.user IS NULL AND c2.user IS NOT NULL AND {$thread_creator_fragment}\n+SQL;\n+ $notif_query_result = $conn->query($notif_query);\n+\n+ $ios_pre_push_info = array();\n+ while ($row = $notif_query_result->fetch_assoc()) {\n+ $user_id = (int)$row['user'];\n+ $thread_id = (int)$row['thread'];\n+ $ios_device_token = $row['ios_device_token'];\n+ if (!isset($ios_pre_push_info[$user_id])) {\n+ $ios_pre_push_info[$user_id] = array(\n+ \"device_tokens\" => array(),\n+ \"thread_ids\" => array(),\n+ );\n+ }\n+ $ios_pre_push_info[$user_id][\"device_tokens\"][$ios_device_token] =\n+ $ios_device_token;\n+ $ios_pre_push_info[$user_id][\"thread_ids\"][$thread_id] = $thread_id;\n+ }\n+\n+ $ios_push_info = array();\n+ foreach ($ios_pre_push_info as $user_id => $user_push_info) {\n+ $ios_push_info[$user_id] = array(\n+ \"deviceTokens\" => array_values($user_push_info[\"device_tokens\"]),\n+ \"messageInfos\" => array(),\n+ );\n+ foreach ($user_push_info[\"thread_ids\"] as $thread_id) {\n+ foreach ($threads_to_message_indices[$thread_id] as $message_index) {\n+ $ios_push_info[$user_id][\"messageInfos\"][] = $return[$message_index];\n+ }\n+ }\n+ }\n+ call_node('ios_push_notifs', $ios_push_info);\n+\nreturn $return;\n}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Call node.js from PHP
129,187
27.12.2017 03:17:21
18,000
82cb11151ce96c72274de5326d1f2e59c66d810d
Push notifs from node.js!
[ { "change_type": "MODIFY", "old_path": ".gitignore", "new_path": ".gitignore", "diff": "@@ -8,3 +8,4 @@ web/node_modules\nweb/dist/dev.build.js\njserver/dist\njserver/node_modules\n+jserver/keys\n" }, { "change_type": "MODIFY", "old_path": "jserver/loader.mjs", "new_path": "jserver/loader.mjs", "diff": "import url from 'url';\nimport Module from 'module';\n+import fs from 'fs';\n+import Promise from 'promise';\nconst builtins = Module.builtinModules;\n+const extensions = { js: 'esm', json: \"json\" };\n+const access = Promise.denodeify(fs.access);\nexport async function resolve(specifier, parentModuleURL, defaultResolve) {\nif (builtins.includes(specifier)) {\n@@ -23,9 +27,20 @@ export async function resolve(specifier, parentModuleURL, defaultResolve) {\n) {\nreturn defaultResolve(specifier, parentModuleURL);\n}\n- const resolved = new url.URL(specifier + \".js\", parentModuleURL);\n+ let error;\n+ for (let extension in extensions) {\n+ const candidate = `${specifier}.${extension}`;\n+ try {\n+ const candidateURL = new url.URL(candidate, parentModuleURL);\n+ await access(candidateURL.pathname);\nreturn {\n- url: resolved.href,\n- format: 'esm',\n+ url: candidateURL.href,\n+ format: extensions[extension],\n};\n+ } catch (err) {\n+ error = err;\n+ }\n+ }\n+ throw error;\n+\n}\n" }, { "change_type": "MODIFY", "old_path": "jserver/package-lock.json", "new_path": "jserver/package-lock.json", "diff": "\"normalize-path\": \"2.1.1\"\n}\n},\n+ \"apn\": {\n+ \"version\": \"2.2.0\",\n+ \"resolved\": \"https://registry.npmjs.org/apn/-/apn-2.2.0.tgz\",\n+ \"integrity\": \"sha512-YIypYzPVJA9wzNBLKZ/mq2l1IZX/2FadPvwmSv4ZeR0VH7xdNITQ6Pucgh0Uw6ZZKC+XwheaJ57DFZAhJ0FvPg==\",\n+ \"requires\": {\n+ \"debug\": \"3.1.0\",\n+ \"http2\": \"https://github.com/node-apn/node-http2/archive/apn-2.1.4.tar.gz\",\n+ \"jsonwebtoken\": \"8.1.0\",\n+ \"node-forge\": \"0.7.1\",\n+ \"verror\": \"1.10.0\"\n+ },\n+ \"dependencies\": {\n+ \"debug\": {\n+ \"version\": \"3.1.0\",\n+ \"resolved\": \"https://registry.npmjs.org/debug/-/debug-3.1.0.tgz\",\n+ \"integrity\": \"sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==\",\n+ \"requires\": {\n+ \"ms\": \"2.0.0\"\n+ }\n+ }\n+ }\n+ },\n\"arr-diff\": {\n\"version\": \"2.0.0\",\n\"resolved\": \"https://registry.npmjs.org/arr-diff/-/arr-diff-2.0.0.tgz\",\n\"integrity\": \"sha1-odl8yvy8JiXMcPrc6zalDFiwGlM=\",\n\"dev\": true\n},\n+ \"asap\": {\n+ \"version\": \"2.0.6\",\n+ \"resolved\": \"https://registry.npmjs.org/asap/-/asap-2.0.6.tgz\",\n+ \"integrity\": \"sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY=\"\n+ },\n\"asn1\": {\n\"version\": \"0.2.3\",\n\"resolved\": \"https://registry.npmjs.org/asn1/-/asn1-0.2.3.tgz\",\n\"assert-plus\": {\n\"version\": \"1.0.0\",\n\"resolved\": \"https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz\",\n- \"integrity\": \"sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=\",\n- \"dev\": true\n+ \"integrity\": \"sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=\"\n},\n\"async-each\": {\n\"version\": \"1.0.1\",\n\"integrity\": \"sha1-ibTRmasr7kneFk6gK4nORi1xt2c=\",\n\"dev\": true\n},\n+ \"base64url\": {\n+ \"version\": \"2.0.0\",\n+ \"resolved\": \"https://registry.npmjs.org/base64url/-/base64url-2.0.0.tgz\",\n+ \"integrity\": \"sha1-6sFuA+oUOO/5Qj1puqNiYu0fcLs=\"\n+ },\n\"bcrypt-pbkdf\": {\n\"version\": \"1.0.1\",\n\"resolved\": \"https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.1.tgz\",\n\"repeat-element\": \"1.1.2\"\n}\n},\n+ \"buffer-equal-constant-time\": {\n+ \"version\": \"1.0.1\",\n+ \"resolved\": \"https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz\",\n+ \"integrity\": \"sha1-+OcRMvf/5uAaXJaXpMbz5I1cyBk=\"\n+ },\n\"buffers\": {\n\"version\": \"0.1.1\",\n\"resolved\": \"https://registry.npmjs.org/buffers/-/buffers-0.1.1.tgz\",\n\"core-util-is\": {\n\"version\": \"1.0.2\",\n\"resolved\": \"https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz\",\n- \"integrity\": \"sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=\",\n- \"dev\": true\n+ \"integrity\": \"sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=\"\n},\n\"create-error-class\": {\n\"version\": \"3.0.2\",\n\"jsbn\": \"0.1.1\"\n}\n},\n+ \"ecdsa-sig-formatter\": {\n+ \"version\": \"1.0.9\",\n+ \"resolved\": \"https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.9.tgz\",\n+ \"integrity\": \"sha1-S8kmJ07Dtau1AW5+HWCSGsJisqE=\",\n+ \"requires\": {\n+ \"base64url\": \"2.0.0\",\n+ \"safe-buffer\": \"5.1.1\"\n+ }\n+ },\n\"ee-first\": {\n\"version\": \"1.1.1\",\n\"resolved\": \"https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz\",\n\"extsprintf\": {\n\"version\": \"1.3.0\",\n\"resolved\": \"https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz\",\n- \"integrity\": \"sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=\",\n- \"dev\": true\n+ \"integrity\": \"sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=\"\n},\n\"fast-deep-equal\": {\n\"version\": \"1.0.0\",\n\"sshpk\": \"1.13.1\"\n}\n},\n+ \"http2\": {\n+ \"version\": \"https://github.com/node-apn/node-http2/archive/apn-2.1.4.tar.gz\",\n+ \"integrity\": \"sha512-ad4u4I88X9AcUgxCRW3RLnbh7xHWQ1f5HbrXa7gEy2x4Xgq+rq+auGx5I+nUDE2YYuqteGIlbxrwQXkIaYTfnQ==\"\n+ },\n\"iconv-lite\": {\n\"version\": \"0.4.19\",\n\"resolved\": \"https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.19.tgz\",\n\"graceful-fs\": \"4.1.11\"\n}\n},\n+ \"jsonwebtoken\": {\n+ \"version\": \"8.1.0\",\n+ \"resolved\": \"https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-8.1.0.tgz\",\n+ \"integrity\": \"sha1-xjl80uX9WD1lwAeoPce7eOaYK4M=\",\n+ \"requires\": {\n+ \"jws\": \"3.1.4\",\n+ \"lodash.includes\": \"4.3.0\",\n+ \"lodash.isboolean\": \"3.0.3\",\n+ \"lodash.isinteger\": \"4.0.4\",\n+ \"lodash.isnumber\": \"3.0.3\",\n+ \"lodash.isplainobject\": \"4.0.6\",\n+ \"lodash.isstring\": \"4.0.1\",\n+ \"lodash.once\": \"4.1.1\",\n+ \"ms\": \"2.0.0\",\n+ \"xtend\": \"4.0.1\"\n+ }\n+ },\n\"jsprim\": {\n\"version\": \"1.4.1\",\n\"resolved\": \"https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz\",\n\"verror\": \"1.10.0\"\n}\n},\n+ \"jwa\": {\n+ \"version\": \"1.1.5\",\n+ \"resolved\": \"https://registry.npmjs.org/jwa/-/jwa-1.1.5.tgz\",\n+ \"integrity\": \"sha1-oFUs4CIHQs1S4VN3SjKQXDDnVuU=\",\n+ \"requires\": {\n+ \"base64url\": \"2.0.0\",\n+ \"buffer-equal-constant-time\": \"1.0.1\",\n+ \"ecdsa-sig-formatter\": \"1.0.9\",\n+ \"safe-buffer\": \"5.1.1\"\n+ }\n+ },\n+ \"jws\": {\n+ \"version\": \"3.1.4\",\n+ \"resolved\": \"https://registry.npmjs.org/jws/-/jws-3.1.4.tgz\",\n+ \"integrity\": \"sha1-+ei5M46KhHJ31kRLFGT2GIDgUKI=\",\n+ \"requires\": {\n+ \"base64url\": \"2.0.0\",\n+ \"jwa\": \"1.1.5\",\n+ \"safe-buffer\": \"5.1.1\"\n+ }\n+ },\n\"kind-of\": {\n\"version\": \"3.2.2\",\n\"resolved\": \"https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz\",\n\"integrity\": \"sha1-DZnzzNem0mHRm9rrkkUAXShYCOc=\",\n\"dev\": true\n},\n+ \"lodash.includes\": {\n+ \"version\": \"4.3.0\",\n+ \"resolved\": \"https://registry.npmjs.org/lodash.includes/-/lodash.includes-4.3.0.tgz\",\n+ \"integrity\": \"sha1-YLuYqHy5I8aMoeUTJUgzFISfVT8=\"\n+ },\n+ \"lodash.isboolean\": {\n+ \"version\": \"3.0.3\",\n+ \"resolved\": \"https://registry.npmjs.org/lodash.isboolean/-/lodash.isboolean-3.0.3.tgz\",\n+ \"integrity\": \"sha1-bC4XHbKiV82WgC/UOwGyDV9YcPY=\"\n+ },\n+ \"lodash.isinteger\": {\n+ \"version\": \"4.0.4\",\n+ \"resolved\": \"https://registry.npmjs.org/lodash.isinteger/-/lodash.isinteger-4.0.4.tgz\",\n+ \"integrity\": \"sha1-YZwK89A/iwTDH1iChAt3sRzWg0M=\"\n+ },\n+ \"lodash.isnumber\": {\n+ \"version\": \"3.0.3\",\n+ \"resolved\": \"https://registry.npmjs.org/lodash.isnumber/-/lodash.isnumber-3.0.3.tgz\",\n+ \"integrity\": \"sha1-POdoEMWSjQM1IwGsKHMX8RwLH/w=\"\n+ },\n+ \"lodash.isplainobject\": {\n+ \"version\": \"4.0.6\",\n+ \"resolved\": \"https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz\",\n+ \"integrity\": \"sha1-fFJqUtibRcRcxpC4gWO+BJf1UMs=\"\n+ },\n+ \"lodash.isstring\": {\n+ \"version\": \"4.0.1\",\n+ \"resolved\": \"https://registry.npmjs.org/lodash.isstring/-/lodash.isstring-4.0.1.tgz\",\n+ \"integrity\": \"sha1-1SfftUVuynzJu5XV2ur4i6VKVFE=\"\n+ },\n+ \"lodash.once\": {\n+ \"version\": \"4.1.1\",\n+ \"resolved\": \"https://registry.npmjs.org/lodash.once/-/lodash.once-4.1.1.tgz\",\n+ \"integrity\": \"sha1-DdOXEhPHxW34gJd9UEyI+0cal6w=\"\n+ },\n\"loose-envify\": {\n\"version\": \"1.3.1\",\n\"resolved\": \"https://registry.npmjs.org/loose-envify/-/loose-envify-1.3.1.tgz\",\n\"resolved\": \"https://registry.npmjs.org/negotiator/-/negotiator-0.6.1.tgz\",\n\"integrity\": \"sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk=\"\n},\n+ \"node-forge\": {\n+ \"version\": \"0.7.1\",\n+ \"resolved\": \"https://registry.npmjs.org/node-forge/-/node-forge-0.7.1.tgz\",\n+ \"integrity\": \"sha1-naYR6giYL0uUIGs760zJZl8gwwA=\"\n+ },\n\"nodemon\": {\n\"version\": \"1.14.3\",\n\"resolved\": \"https://registry.npmjs.org/nodemon/-/nodemon-1.14.3.tgz\",\n\"integrity\": \"sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=\",\n\"dev\": true\n},\n+ \"promise\": {\n+ \"version\": \"8.0.1\",\n+ \"resolved\": \"https://registry.npmjs.org/promise/-/promise-8.0.1.tgz\",\n+ \"integrity\": \"sha1-5F1osAoXZHttpxG/he1u1HII9FA=\",\n+ \"requires\": {\n+ \"asap\": \"2.0.6\"\n+ }\n+ },\n\"proxy-addr\": {\n\"version\": \"2.0.2\",\n\"resolved\": \"https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.2.tgz\",\n\"version\": \"1.10.0\",\n\"resolved\": \"https://registry.npmjs.org/verror/-/verror-1.10.0.tgz\",\n\"integrity\": \"sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=\",\n- \"dev\": true,\n\"requires\": {\n\"assert-plus\": \"1.0.0\",\n\"core-util-is\": \"1.0.2\",\n\"integrity\": \"sha1-SWsswQnsqNus/i3HK2A8F8WHCtQ=\",\n\"dev\": true\n},\n+ \"xtend\": {\n+ \"version\": \"4.0.1\",\n+ \"resolved\": \"https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz\",\n+ \"integrity\": \"sha1-pcbVMr5lbiPbgg77lDofBJmNY68=\"\n+ },\n\"y18n\": {\n\"version\": \"3.2.1\",\n\"resolved\": \"https://registry.npmjs.org/y18n/-/y18n-3.2.1.tgz\",\n" }, { "change_type": "MODIFY", "old_path": "jserver/package.json", "new_path": "jserver/package.json", "diff": "\"description\": \"\",\n\"main\": \"dist/app\",\n\"scripts\": {\n- \"babel\": \"babel src/ --out-dir dist/ --ignore 'lib/flow-typed','lib/node_modules'\",\n+ \"babel\": \"babel src/ --out-dir dist/ --ignore 'lib/flow-typed','lib/node_modules','lib/package.json','lib/package-lock.json' --copy-files\",\n\"prod\": \"node --experimental-modules --loader ./loader.mjs dist/app\",\n- \"dev\": \"concurrently \\\"npm run babel -- --watch\\\" \\\"nodemon -e js --watch dist --experimental-modules --loader ./loader.mjs dist/app\\\"\"\n+ \"dev\": \"concurrently \\\"npm run babel -- --watch\\\" \\\"nodemon -e js,json --watch dist --experimental-modules --loader ./loader.mjs dist/app\\\"\"\n},\n\"author\": \"\",\n\"license\": \"ISC\",\n\"nodemon\": \"^1.14.3\"\n},\n\"dependencies\": {\n+ \"apn\": \"^2.2.0\",\n\"body-parser\": \"^1.18.2\",\n\"express\": \"^4.16.2\",\n- \"lib\": \"file:../lib\"\n+ \"lib\": \"file:../lib\",\n+ \"promise\": \"^8.0.1\"\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "jserver/src/error_handler.js", "new_path": "jserver/src/error_handler.js", "diff": "import type { $Response, $Request } from 'express';\n-type NodeHandler = (req: $Request, res: $Response) => Promise<void>;\n-type OurHandler = (req: $Request, res: $Response) => Promise<Object | string>;\n+type OurHandler = (req: $Request, res: $Response) => Promise<*>;\n-export default function errorHandler(handler: OurHandler): NodeHandler {\n+export default function errorHandler(handler: OurHandler) {\nreturn async (req: $Request, res: $Response) => {\ntry {\nconst result = await handler(req, res);\n" }, { "change_type": "MODIFY", "old_path": "jserver/src/push/ios_notifs.js", "new_path": "jserver/src/push/ios_notifs.js", "diff": "import type { $Response, $Request } from 'express';\nimport type { RawMessageInfo } from 'lib/types/message-types';\n+import apn from 'apn';\n+\n+import apnConfig from '../../keys/apn_config';\n+\ntype IOSPushUserInfo = {\ndeviceTokens: string[],\nmessageInfos: RawMessageInfo[],\n};\ntype IOSPushInfo = { [userID: string]: IOSPushUserInfo };\n+const apnProvider = new apn.Provider(apnConfig);\n+\nasync function sendIOSPushNotifs(req: $Request, res: $Response) {\nconst pushInfo: IOSPushInfo = req.body;\n- return pushInfo;\n+ const promises = [];\n+ for (let userID in pushInfo) {\n+ for (let messageInfo of pushInfo[userID].messageInfos) {\n+ const notification = new apn.Notification();\n+ notification.alert = \"Hello, world!\";\n+ notification.topic = \"org.squadcal.app\";\n+ notification.badge = 0;\n+ promises.push(apnProvider.send(\n+ notification,\n+ pushInfo[userID].deviceTokens,\n+ ));\n+ }\n+ }\n+ return await Promise.all(promises);\n}\nexport {\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Push notifs from node.js!
129,187
27.12.2017 14:15:37
18,000
412e68d5bad9c7d73fd7ba52343a8371dc5710c9
Fetch unread counts from MySQL in node.js notifs logic
[ { "change_type": "MODIFY", "old_path": ".gitignore", "new_path": ".gitignore", "diff": "@@ -8,4 +8,4 @@ web/node_modules\nweb/dist/dev.build.js\njserver/dist\njserver/node_modules\n-jserver/keys\n+jserver/secrets\n" }, { "change_type": "ADD", "old_path": null, "new_path": "jserver/flow-typed/npm/apn_vx.x.x.js", "diff": "+// flow-typed signature: f79ab0e7185cc174d542fa6d878d63a3\n+// flow-typed version: <<STUB>>/apn_v^2.2.0/flow_v0.61.0\n+\n+/**\n+ * This is an autogenerated libdef stub for:\n+ *\n+ * 'apn'\n+ *\n+ * Fill this stub out by replacing all the `any` types.\n+ *\n+ * Once filled out, we encourage you to share your work with the\n+ * community by sending a pull request to:\n+ * https://github.com/flowtype/flow-typed\n+ */\n+\n+declare module 'apn' {\n+ declare module.exports: any;\n+}\n+\n+/**\n+ * We include stubs for each file inside this npm package in case you need to\n+ * require those files directly. Feel free to delete any files that aren't\n+ * needed.\n+ */\n+declare module 'apn/examples/sending-multiple-notifications' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'apn/examples/sending-to-multiple-devices' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'apn/lib/client' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'apn/lib/config' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'apn/lib/credentials/ca/prepare' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'apn/lib/credentials/certificate/APNCertificate' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'apn/lib/credentials/certificate/APNKey' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'apn/lib/credentials/certificate/load' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'apn/lib/credentials/certificate/oids' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'apn/lib/credentials/certificate/parse' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'apn/lib/credentials/certificate/parsePemCertificate' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'apn/lib/credentials/certificate/parsePemKey' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'apn/lib/credentials/certificate/parsePkcs12' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'apn/lib/credentials/certificate/prepare' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'apn/lib/credentials/certificate/validate' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'apn/lib/credentials/index' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'apn/lib/credentials/resolve' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'apn/lib/credentials/token/prepare' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'apn/lib/notification/apsProperties' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'apn/lib/notification/index' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'apn/lib/protocol/endpoint' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'apn/lib/protocol/endpointManager' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'apn/lib/provider' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'apn/lib/token' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'apn/lib/util/extend' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'apn/mock/client' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'apn/mock/index' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'apn/test/client' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'apn/test/config' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'apn/test/credentials/ca/prepare' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'apn/test/credentials/certificate/APNCertificate' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'apn/test/credentials/certificate/APNKey' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'apn/test/credentials/certificate/load' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'apn/test/credentials/certificate/parse' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'apn/test/credentials/certificate/parsePemCertificate' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'apn/test/credentials/certificate/parsePemKey' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'apn/test/credentials/certificate/parsePkcs12' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'apn/test/credentials/certificate/prepare' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'apn/test/credentials/certificate/validate' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'apn/test/credentials/resolve' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'apn/test/credentials/token/prepare' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'apn/test/notification/apsProperties' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'apn/test/notification/index' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'apn/test/protocol/endpoint' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'apn/test/protocol/endpointManager' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'apn/test/provider' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'apn/test/support' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'apn/test/token' {\n+ declare module.exports: any;\n+}\n+\n+// Filename aliases\n+declare module 'apn/examples/sending-multiple-notifications.js' {\n+ declare module.exports: $Exports<'apn/examples/sending-multiple-notifications'>;\n+}\n+declare module 'apn/examples/sending-to-multiple-devices.js' {\n+ declare module.exports: $Exports<'apn/examples/sending-to-multiple-devices'>;\n+}\n+declare module 'apn/index' {\n+ declare module.exports: $Exports<'apn'>;\n+}\n+declare module 'apn/index.js' {\n+ declare module.exports: $Exports<'apn'>;\n+}\n+declare module 'apn/lib/client.js' {\n+ declare module.exports: $Exports<'apn/lib/client'>;\n+}\n+declare module 'apn/lib/config.js' {\n+ declare module.exports: $Exports<'apn/lib/config'>;\n+}\n+declare module 'apn/lib/credentials/ca/prepare.js' {\n+ declare module.exports: $Exports<'apn/lib/credentials/ca/prepare'>;\n+}\n+declare module 'apn/lib/credentials/certificate/APNCertificate.js' {\n+ declare module.exports: $Exports<'apn/lib/credentials/certificate/APNCertificate'>;\n+}\n+declare module 'apn/lib/credentials/certificate/APNKey.js' {\n+ declare module.exports: $Exports<'apn/lib/credentials/certificate/APNKey'>;\n+}\n+declare module 'apn/lib/credentials/certificate/load.js' {\n+ declare module.exports: $Exports<'apn/lib/credentials/certificate/load'>;\n+}\n+declare module 'apn/lib/credentials/certificate/oids.js' {\n+ declare module.exports: $Exports<'apn/lib/credentials/certificate/oids'>;\n+}\n+declare module 'apn/lib/credentials/certificate/parse.js' {\n+ declare module.exports: $Exports<'apn/lib/credentials/certificate/parse'>;\n+}\n+declare module 'apn/lib/credentials/certificate/parsePemCertificate.js' {\n+ declare module.exports: $Exports<'apn/lib/credentials/certificate/parsePemCertificate'>;\n+}\n+declare module 'apn/lib/credentials/certificate/parsePemKey.js' {\n+ declare module.exports: $Exports<'apn/lib/credentials/certificate/parsePemKey'>;\n+}\n+declare module 'apn/lib/credentials/certificate/parsePkcs12.js' {\n+ declare module.exports: $Exports<'apn/lib/credentials/certificate/parsePkcs12'>;\n+}\n+declare module 'apn/lib/credentials/certificate/prepare.js' {\n+ declare module.exports: $Exports<'apn/lib/credentials/certificate/prepare'>;\n+}\n+declare module 'apn/lib/credentials/certificate/validate.js' {\n+ declare module.exports: $Exports<'apn/lib/credentials/certificate/validate'>;\n+}\n+declare module 'apn/lib/credentials/index.js' {\n+ declare module.exports: $Exports<'apn/lib/credentials/index'>;\n+}\n+declare module 'apn/lib/credentials/resolve.js' {\n+ declare module.exports: $Exports<'apn/lib/credentials/resolve'>;\n+}\n+declare module 'apn/lib/credentials/token/prepare.js' {\n+ declare module.exports: $Exports<'apn/lib/credentials/token/prepare'>;\n+}\n+declare module 'apn/lib/notification/apsProperties.js' {\n+ declare module.exports: $Exports<'apn/lib/notification/apsProperties'>;\n+}\n+declare module 'apn/lib/notification/index.js' {\n+ declare module.exports: $Exports<'apn/lib/notification/index'>;\n+}\n+declare module 'apn/lib/protocol/endpoint.js' {\n+ declare module.exports: $Exports<'apn/lib/protocol/endpoint'>;\n+}\n+declare module 'apn/lib/protocol/endpointManager.js' {\n+ declare module.exports: $Exports<'apn/lib/protocol/endpointManager'>;\n+}\n+declare module 'apn/lib/provider.js' {\n+ declare module.exports: $Exports<'apn/lib/provider'>;\n+}\n+declare module 'apn/lib/token.js' {\n+ declare module.exports: $Exports<'apn/lib/token'>;\n+}\n+declare module 'apn/lib/util/extend.js' {\n+ declare module.exports: $Exports<'apn/lib/util/extend'>;\n+}\n+declare module 'apn/mock/client.js' {\n+ declare module.exports: $Exports<'apn/mock/client'>;\n+}\n+declare module 'apn/mock/index.js' {\n+ declare module.exports: $Exports<'apn/mock/index'>;\n+}\n+declare module 'apn/test/client.js' {\n+ declare module.exports: $Exports<'apn/test/client'>;\n+}\n+declare module 'apn/test/config.js' {\n+ declare module.exports: $Exports<'apn/test/config'>;\n+}\n+declare module 'apn/test/credentials/ca/prepare.js' {\n+ declare module.exports: $Exports<'apn/test/credentials/ca/prepare'>;\n+}\n+declare module 'apn/test/credentials/certificate/APNCertificate.js' {\n+ declare module.exports: $Exports<'apn/test/credentials/certificate/APNCertificate'>;\n+}\n+declare module 'apn/test/credentials/certificate/APNKey.js' {\n+ declare module.exports: $Exports<'apn/test/credentials/certificate/APNKey'>;\n+}\n+declare module 'apn/test/credentials/certificate/load.js' {\n+ declare module.exports: $Exports<'apn/test/credentials/certificate/load'>;\n+}\n+declare module 'apn/test/credentials/certificate/parse.js' {\n+ declare module.exports: $Exports<'apn/test/credentials/certificate/parse'>;\n+}\n+declare module 'apn/test/credentials/certificate/parsePemCertificate.js' {\n+ declare module.exports: $Exports<'apn/test/credentials/certificate/parsePemCertificate'>;\n+}\n+declare module 'apn/test/credentials/certificate/parsePemKey.js' {\n+ declare module.exports: $Exports<'apn/test/credentials/certificate/parsePemKey'>;\n+}\n+declare module 'apn/test/credentials/certificate/parsePkcs12.js' {\n+ declare module.exports: $Exports<'apn/test/credentials/certificate/parsePkcs12'>;\n+}\n+declare module 'apn/test/credentials/certificate/prepare.js' {\n+ declare module.exports: $Exports<'apn/test/credentials/certificate/prepare'>;\n+}\n+declare module 'apn/test/credentials/certificate/validate.js' {\n+ declare module.exports: $Exports<'apn/test/credentials/certificate/validate'>;\n+}\n+declare module 'apn/test/credentials/resolve.js' {\n+ declare module.exports: $Exports<'apn/test/credentials/resolve'>;\n+}\n+declare module 'apn/test/credentials/token/prepare.js' {\n+ declare module.exports: $Exports<'apn/test/credentials/token/prepare'>;\n+}\n+declare module 'apn/test/notification/apsProperties.js' {\n+ declare module.exports: $Exports<'apn/test/notification/apsProperties'>;\n+}\n+declare module 'apn/test/notification/index.js' {\n+ declare module.exports: $Exports<'apn/test/notification/index'>;\n+}\n+declare module 'apn/test/protocol/endpoint.js' {\n+ declare module.exports: $Exports<'apn/test/protocol/endpoint'>;\n+}\n+declare module 'apn/test/protocol/endpointManager.js' {\n+ declare module.exports: $Exports<'apn/test/protocol/endpointManager'>;\n+}\n+declare module 'apn/test/provider.js' {\n+ declare module.exports: $Exports<'apn/test/provider'>;\n+}\n+declare module 'apn/test/support.js' {\n+ declare module.exports: $Exports<'apn/test/support'>;\n+}\n+declare module 'apn/test/token.js' {\n+ declare module.exports: $Exports<'apn/test/token'>;\n+}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "jserver/flow-typed/npm/body-parser_v1.x.x.js", "diff": "+// flow-typed signature: bac0ee66e0653772d037dc47b51a5e1f\n+// flow-typed version: da30fe6876/body-parser_v1.x.x/flow_>=v0.25.x\n+\n+import type { Middleware, $Request, $Response } from \"express\";\n+\n+declare type bodyParser$Options = {\n+ inflate?: boolean,\n+ limit?: number | string,\n+ type?: string | string[] | ((req: $Request) => any),\n+ verify?: (\n+ req: $Request,\n+ res: $Response,\n+ buf: Buffer,\n+ encoding: string\n+ ) => void\n+};\n+\n+declare type bodyParser$OptionsText = bodyParser$Options & {\n+ reviver?: (key: string, value: any) => any,\n+ strict?: boolean\n+};\n+\n+declare type bodyParser$OptionsJson = bodyParser$Options & {\n+ reviver?: (key: string, value: any) => any,\n+ strict?: boolean\n+};\n+\n+declare type bodyParser$OptionsUrlencoded = bodyParser$Options & {\n+ extended?: boolean,\n+ parameterLimit?: number\n+};\n+\n+declare module \"body-parser\" {\n+ declare type Options = bodyParser$Options;\n+ declare type OptionsText = bodyParser$OptionsText;\n+ declare type OptionsJson = bodyParser$OptionsJson;\n+ declare type OptionsUrlencoded = bodyParser$OptionsUrlencoded;\n+\n+ declare function json(options?: OptionsJson): Middleware;\n+\n+ declare function raw(options?: Options): Middleware;\n+\n+ declare function text(options?: OptionsText): Middleware;\n+\n+ declare function urlencoded(options?: OptionsUrlencoded): Middleware;\n+}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "jserver/flow-typed/npm/mysql2_vx.x.x.js", "diff": "+// flow-typed signature: 77650ab7403057507b84bcd10f90097c\n+// flow-typed version: <<STUB>>/mysql2_v^1.5.1/flow_v0.61.0\n+\n+/**\n+ * This is an autogenerated libdef stub for:\n+ *\n+ * 'mysql2'\n+ *\n+ * Fill this stub out by replacing all the `any` types.\n+ *\n+ * Once filled out, we encourage you to share your work with the\n+ * community by sending a pull request to:\n+ * https://github.com/flowtype/flow-typed\n+ */\n+\n+declare module 'mysql2' {\n+ declare module.exports: any;\n+}\n+\n+/**\n+ * We include stubs for each file inside this npm package in case you need to\n+ * require those files directly. Feel free to delete any files that aren't\n+ * needed.\n+ */\n+declare module 'mysql2/lib/auth_41' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'mysql2/lib/commands/binlog_dump' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'mysql2/lib/commands/change_user' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'mysql2/lib/commands/client_handshake' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'mysql2/lib/commands/close_statement' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'mysql2/lib/commands/command' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'mysql2/lib/commands/execute' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'mysql2/lib/commands/index' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'mysql2/lib/commands/ping' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'mysql2/lib/commands/prepare' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'mysql2/lib/commands/query' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'mysql2/lib/commands/quit' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'mysql2/lib/commands/register_slave' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'mysql2/lib/commands/server_handshake' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'mysql2/lib/compile_binary_parser' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'mysql2/lib/compile_text_parser' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'mysql2/lib/compressed_protocol' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'mysql2/lib/connection_config' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'mysql2/lib/connection' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'mysql2/lib/constants/charset_encodings' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'mysql2/lib/constants/charsets' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'mysql2/lib/constants/client' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'mysql2/lib/constants/commands' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'mysql2/lib/constants/cursor' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'mysql2/lib/constants/encoding_charset' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'mysql2/lib/constants/errors' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'mysql2/lib/constants/field_flags' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'mysql2/lib/constants/server_status' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'mysql2/lib/constants/ssl_profiles' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'mysql2/lib/constants/types' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'mysql2/lib/helpers' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'mysql2/lib/packet_parser' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'mysql2/lib/packets/auth_switch_request_more_data' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'mysql2/lib/packets/auth_switch_request' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'mysql2/lib/packets/auth_switch_response' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'mysql2/lib/packets/binary_row' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'mysql2/lib/packets/binlog_dump' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'mysql2/lib/packets/binlog_query_statusvars' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'mysql2/lib/packets/change_user' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'mysql2/lib/packets/close_statement' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'mysql2/lib/packets/column_definition' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'mysql2/lib/packets/execute' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'mysql2/lib/packets/handshake_response' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'mysql2/lib/packets/handshake' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'mysql2/lib/packets/index' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'mysql2/lib/packets/packet' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'mysql2/lib/packets/prepare_statement' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'mysql2/lib/packets/prepared_statement_header' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'mysql2/lib/packets/query' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'mysql2/lib/packets/register_slave' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'mysql2/lib/packets/resultset_header' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'mysql2/lib/packets/ssl_request' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'mysql2/lib/packets/text_row' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'mysql2/lib/parsers/string' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'mysql2/lib/pool_cluster' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'mysql2/lib/pool_config' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'mysql2/lib/pool_connection' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'mysql2/lib/pool' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'mysql2/lib/results_stream' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'mysql2/lib/server' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'mysql2/promise' {\n+ declare module.exports: any;\n+}\n+\n+// Filename aliases\n+declare module 'mysql2/index' {\n+ declare module.exports: $Exports<'mysql2'>;\n+}\n+declare module 'mysql2/index.js' {\n+ declare module.exports: $Exports<'mysql2'>;\n+}\n+declare module 'mysql2/lib/auth_41.js' {\n+ declare module.exports: $Exports<'mysql2/lib/auth_41'>;\n+}\n+declare module 'mysql2/lib/commands/binlog_dump.js' {\n+ declare module.exports: $Exports<'mysql2/lib/commands/binlog_dump'>;\n+}\n+declare module 'mysql2/lib/commands/change_user.js' {\n+ declare module.exports: $Exports<'mysql2/lib/commands/change_user'>;\n+}\n+declare module 'mysql2/lib/commands/client_handshake.js' {\n+ declare module.exports: $Exports<'mysql2/lib/commands/client_handshake'>;\n+}\n+declare module 'mysql2/lib/commands/close_statement.js' {\n+ declare module.exports: $Exports<'mysql2/lib/commands/close_statement'>;\n+}\n+declare module 'mysql2/lib/commands/command.js' {\n+ declare module.exports: $Exports<'mysql2/lib/commands/command'>;\n+}\n+declare module 'mysql2/lib/commands/execute.js' {\n+ declare module.exports: $Exports<'mysql2/lib/commands/execute'>;\n+}\n+declare module 'mysql2/lib/commands/index.js' {\n+ declare module.exports: $Exports<'mysql2/lib/commands/index'>;\n+}\n+declare module 'mysql2/lib/commands/ping.js' {\n+ declare module.exports: $Exports<'mysql2/lib/commands/ping'>;\n+}\n+declare module 'mysql2/lib/commands/prepare.js' {\n+ declare module.exports: $Exports<'mysql2/lib/commands/prepare'>;\n+}\n+declare module 'mysql2/lib/commands/query.js' {\n+ declare module.exports: $Exports<'mysql2/lib/commands/query'>;\n+}\n+declare module 'mysql2/lib/commands/quit.js' {\n+ declare module.exports: $Exports<'mysql2/lib/commands/quit'>;\n+}\n+declare module 'mysql2/lib/commands/register_slave.js' {\n+ declare module.exports: $Exports<'mysql2/lib/commands/register_slave'>;\n+}\n+declare module 'mysql2/lib/commands/server_handshake.js' {\n+ declare module.exports: $Exports<'mysql2/lib/commands/server_handshake'>;\n+}\n+declare module 'mysql2/lib/compile_binary_parser.js' {\n+ declare module.exports: $Exports<'mysql2/lib/compile_binary_parser'>;\n+}\n+declare module 'mysql2/lib/compile_text_parser.js' {\n+ declare module.exports: $Exports<'mysql2/lib/compile_text_parser'>;\n+}\n+declare module 'mysql2/lib/compressed_protocol.js' {\n+ declare module.exports: $Exports<'mysql2/lib/compressed_protocol'>;\n+}\n+declare module 'mysql2/lib/connection_config.js' {\n+ declare module.exports: $Exports<'mysql2/lib/connection_config'>;\n+}\n+declare module 'mysql2/lib/connection.js' {\n+ declare module.exports: $Exports<'mysql2/lib/connection'>;\n+}\n+declare module 'mysql2/lib/constants/charset_encodings.js' {\n+ declare module.exports: $Exports<'mysql2/lib/constants/charset_encodings'>;\n+}\n+declare module 'mysql2/lib/constants/charsets.js' {\n+ declare module.exports: $Exports<'mysql2/lib/constants/charsets'>;\n+}\n+declare module 'mysql2/lib/constants/client.js' {\n+ declare module.exports: $Exports<'mysql2/lib/constants/client'>;\n+}\n+declare module 'mysql2/lib/constants/commands.js' {\n+ declare module.exports: $Exports<'mysql2/lib/constants/commands'>;\n+}\n+declare module 'mysql2/lib/constants/cursor.js' {\n+ declare module.exports: $Exports<'mysql2/lib/constants/cursor'>;\n+}\n+declare module 'mysql2/lib/constants/encoding_charset.js' {\n+ declare module.exports: $Exports<'mysql2/lib/constants/encoding_charset'>;\n+}\n+declare module 'mysql2/lib/constants/errors.js' {\n+ declare module.exports: $Exports<'mysql2/lib/constants/errors'>;\n+}\n+declare module 'mysql2/lib/constants/field_flags.js' {\n+ declare module.exports: $Exports<'mysql2/lib/constants/field_flags'>;\n+}\n+declare module 'mysql2/lib/constants/server_status.js' {\n+ declare module.exports: $Exports<'mysql2/lib/constants/server_status'>;\n+}\n+declare module 'mysql2/lib/constants/ssl_profiles.js' {\n+ declare module.exports: $Exports<'mysql2/lib/constants/ssl_profiles'>;\n+}\n+declare module 'mysql2/lib/constants/types.js' {\n+ declare module.exports: $Exports<'mysql2/lib/constants/types'>;\n+}\n+declare module 'mysql2/lib/helpers.js' {\n+ declare module.exports: $Exports<'mysql2/lib/helpers'>;\n+}\n+declare module 'mysql2/lib/packet_parser.js' {\n+ declare module.exports: $Exports<'mysql2/lib/packet_parser'>;\n+}\n+declare module 'mysql2/lib/packets/auth_switch_request_more_data.js' {\n+ declare module.exports: $Exports<'mysql2/lib/packets/auth_switch_request_more_data'>;\n+}\n+declare module 'mysql2/lib/packets/auth_switch_request.js' {\n+ declare module.exports: $Exports<'mysql2/lib/packets/auth_switch_request'>;\n+}\n+declare module 'mysql2/lib/packets/auth_switch_response.js' {\n+ declare module.exports: $Exports<'mysql2/lib/packets/auth_switch_response'>;\n+}\n+declare module 'mysql2/lib/packets/binary_row.js' {\n+ declare module.exports: $Exports<'mysql2/lib/packets/binary_row'>;\n+}\n+declare module 'mysql2/lib/packets/binlog_dump.js' {\n+ declare module.exports: $Exports<'mysql2/lib/packets/binlog_dump'>;\n+}\n+declare module 'mysql2/lib/packets/binlog_query_statusvars.js' {\n+ declare module.exports: $Exports<'mysql2/lib/packets/binlog_query_statusvars'>;\n+}\n+declare module 'mysql2/lib/packets/change_user.js' {\n+ declare module.exports: $Exports<'mysql2/lib/packets/change_user'>;\n+}\n+declare module 'mysql2/lib/packets/close_statement.js' {\n+ declare module.exports: $Exports<'mysql2/lib/packets/close_statement'>;\n+}\n+declare module 'mysql2/lib/packets/column_definition.js' {\n+ declare module.exports: $Exports<'mysql2/lib/packets/column_definition'>;\n+}\n+declare module 'mysql2/lib/packets/execute.js' {\n+ declare module.exports: $Exports<'mysql2/lib/packets/execute'>;\n+}\n+declare module 'mysql2/lib/packets/handshake_response.js' {\n+ declare module.exports: $Exports<'mysql2/lib/packets/handshake_response'>;\n+}\n+declare module 'mysql2/lib/packets/handshake.js' {\n+ declare module.exports: $Exports<'mysql2/lib/packets/handshake'>;\n+}\n+declare module 'mysql2/lib/packets/index.js' {\n+ declare module.exports: $Exports<'mysql2/lib/packets/index'>;\n+}\n+declare module 'mysql2/lib/packets/packet.js' {\n+ declare module.exports: $Exports<'mysql2/lib/packets/packet'>;\n+}\n+declare module 'mysql2/lib/packets/prepare_statement.js' {\n+ declare module.exports: $Exports<'mysql2/lib/packets/prepare_statement'>;\n+}\n+declare module 'mysql2/lib/packets/prepared_statement_header.js' {\n+ declare module.exports: $Exports<'mysql2/lib/packets/prepared_statement_header'>;\n+}\n+declare module 'mysql2/lib/packets/query.js' {\n+ declare module.exports: $Exports<'mysql2/lib/packets/query'>;\n+}\n+declare module 'mysql2/lib/packets/register_slave.js' {\n+ declare module.exports: $Exports<'mysql2/lib/packets/register_slave'>;\n+}\n+declare module 'mysql2/lib/packets/resultset_header.js' {\n+ declare module.exports: $Exports<'mysql2/lib/packets/resultset_header'>;\n+}\n+declare module 'mysql2/lib/packets/ssl_request.js' {\n+ declare module.exports: $Exports<'mysql2/lib/packets/ssl_request'>;\n+}\n+declare module 'mysql2/lib/packets/text_row.js' {\n+ declare module.exports: $Exports<'mysql2/lib/packets/text_row'>;\n+}\n+declare module 'mysql2/lib/parsers/string.js' {\n+ declare module.exports: $Exports<'mysql2/lib/parsers/string'>;\n+}\n+declare module 'mysql2/lib/pool_cluster.js' {\n+ declare module.exports: $Exports<'mysql2/lib/pool_cluster'>;\n+}\n+declare module 'mysql2/lib/pool_config.js' {\n+ declare module.exports: $Exports<'mysql2/lib/pool_config'>;\n+}\n+declare module 'mysql2/lib/pool_connection.js' {\n+ declare module.exports: $Exports<'mysql2/lib/pool_connection'>;\n+}\n+declare module 'mysql2/lib/pool.js' {\n+ declare module.exports: $Exports<'mysql2/lib/pool'>;\n+}\n+declare module 'mysql2/lib/results_stream.js' {\n+ declare module.exports: $Exports<'mysql2/lib/results_stream'>;\n+}\n+declare module 'mysql2/lib/server.js' {\n+ declare module.exports: $Exports<'mysql2/lib/server'>;\n+}\n+declare module 'mysql2/promise.js' {\n+ declare module.exports: $Exports<'mysql2/promise'>;\n+}\n" }, { "change_type": "MODIFY", "old_path": "jserver/package-lock.json", "new_path": "jserver/package-lock.json", "diff": "\"color-convert\": \"1.9.1\"\n}\n},\n+ \"ansicolors\": {\n+ \"version\": \"0.2.1\",\n+ \"resolved\": \"https://registry.npmjs.org/ansicolors/-/ansicolors-0.2.1.tgz\",\n+ \"integrity\": \"sha1-vgiVmQl7dKXJxKhKDNvNtivYeu8=\"\n+ },\n\"anymatch\": {\n\"version\": \"1.3.2\",\n\"resolved\": \"https://registry.npmjs.org/anymatch/-/anymatch-1.3.2.tgz\",\n\"integrity\": \"sha1-Sm+gc5nCa7pH8LJJa00PtAjFVQ0=\",\n\"dev\": true\n},\n+ \"cardinal\": {\n+ \"version\": \"1.0.0\",\n+ \"resolved\": \"https://registry.npmjs.org/cardinal/-/cardinal-1.0.0.tgz\",\n+ \"integrity\": \"sha1-UOIcGwqjdyn5N33vGWtanOyTLuk=\",\n+ \"requires\": {\n+ \"ansicolors\": \"0.2.1\",\n+ \"redeyed\": \"1.0.1\"\n+ }\n+ },\n\"caseless\": {\n\"version\": \"0.12.0\",\n\"resolved\": \"https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz\",\n\"integrity\": \"sha1-3zrhmayt+31ECqrgsp4icrJOxhk=\",\n\"dev\": true\n},\n+ \"denque\": {\n+ \"version\": \"1.2.2\",\n+ \"resolved\": \"https://registry.npmjs.org/denque/-/denque-1.2.2.tgz\",\n+ \"integrity\": \"sha512-x92Ql74lcTbGylXILO9Xf9S0cMpEPP04zVp2bB9e2C7G/n/Q1SgLl78RaSYEPSgpDX9uLgQXCEGAS5BI5dP3yA==\"\n+ },\n\"depd\": {\n\"version\": \"1.1.1\",\n\"resolved\": \"https://registry.npmjs.org/depd/-/depd-1.1.1.tgz\",\n\"integrity\": \"sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=\",\n\"dev\": true\n},\n+ \"esprima\": {\n+ \"version\": \"3.0.0\",\n+ \"resolved\": \"https://registry.npmjs.org/esprima/-/esprima-3.0.0.tgz\",\n+ \"integrity\": \"sha1-U88kes2ncxPlUcOqLnM0LT+099k=\"\n+ },\n\"esutils\": {\n\"version\": \"2.0.2\",\n\"resolved\": \"https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz\",\n}\n}\n},\n+ \"generate-function\": {\n+ \"version\": \"2.0.0\",\n+ \"resolved\": \"https://registry.npmjs.org/generate-function/-/generate-function-2.0.0.tgz\",\n+ \"integrity\": \"sha1-aFj+fAlpt9TpCTM3ZHrHn2DfvnQ=\"\n+ },\n\"get-caller-file\": {\n\"version\": \"1.0.2\",\n\"resolved\": \"https://registry.npmjs.org/get-caller-file/-/get-caller-file-1.0.2.tgz\",\n\"resolved\": \"https://registry.npmjs.org/lodash.once/-/lodash.once-4.1.1.tgz\",\n\"integrity\": \"sha1-DdOXEhPHxW34gJd9UEyI+0cal6w=\"\n},\n+ \"long\": {\n+ \"version\": \"3.2.0\",\n+ \"resolved\": \"https://registry.npmjs.org/long/-/long-3.2.0.tgz\",\n+ \"integrity\": \"sha1-2CG3E4yhy1gcFymQ7xTbIAtcR0s=\"\n+ },\n\"loose-envify\": {\n\"version\": \"1.3.1\",\n\"resolved\": \"https://registry.npmjs.org/loose-envify/-/loose-envify-1.3.1.tgz\",\n\"version\": \"4.1.1\",\n\"resolved\": \"https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.1.tgz\",\n\"integrity\": \"sha512-q4spe4KTfsAS1SUHLO0wz8Qiyf1+vMIAgpRYioFYDMNqKfHQbg+AVDH3i4fvpl71/P1L0dBl+fQi+P37UYf0ew==\",\n- \"dev\": true,\n\"requires\": {\n\"pseudomap\": \"1.0.2\",\n\"yallist\": \"2.1.2\"\n\"resolved\": \"https://registry.npmjs.org/ms/-/ms-2.0.0.tgz\",\n\"integrity\": \"sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=\"\n},\n+ \"mysql2\": {\n+ \"version\": \"1.5.1\",\n+ \"resolved\": \"https://registry.npmjs.org/mysql2/-/mysql2-1.5.1.tgz\",\n+ \"integrity\": \"sha1-JBHW+5WK+GsjBLelO8VLJud+aCs=\",\n+ \"requires\": {\n+ \"cardinal\": \"1.0.0\",\n+ \"denque\": \"1.2.2\",\n+ \"generate-function\": \"2.0.0\",\n+ \"iconv-lite\": \"0.4.19\",\n+ \"long\": \"3.2.0\",\n+ \"lru-cache\": \"4.1.1\",\n+ \"named-placeholders\": \"1.1.1\",\n+ \"object-assign\": \"4.1.1\",\n+ \"readable-stream\": \"2.3.2\",\n+ \"safe-buffer\": \"5.1.1\",\n+ \"seq-queue\": \"0.0.5\",\n+ \"sqlstring\": \"2.3.0\"\n+ },\n+ \"dependencies\": {\n+ \"isarray\": {\n+ \"version\": \"1.0.0\",\n+ \"resolved\": \"https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz\",\n+ \"integrity\": \"sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=\"\n+ },\n+ \"readable-stream\": {\n+ \"version\": \"2.3.2\",\n+ \"resolved\": \"https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.2.tgz\",\n+ \"integrity\": \"sha1-WgTfBeT1f+Pw3Gj90R3FyXx+b00=\",\n+ \"requires\": {\n+ \"core-util-is\": \"1.0.2\",\n+ \"inherits\": \"2.0.3\",\n+ \"isarray\": \"1.0.0\",\n+ \"process-nextick-args\": \"1.0.7\",\n+ \"safe-buffer\": \"5.1.1\",\n+ \"string_decoder\": \"1.0.3\",\n+ \"util-deprecate\": \"1.0.2\"\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+ }\n+ },\n+ \"named-placeholders\": {\n+ \"version\": \"1.1.1\",\n+ \"resolved\": \"https://registry.npmjs.org/named-placeholders/-/named-placeholders-1.1.1.tgz\",\n+ \"integrity\": \"sha1-O3oNJiA910s6nfTJz7gnsvuQfmQ=\",\n+ \"requires\": {\n+ \"lru-cache\": \"2.5.0\"\n+ },\n+ \"dependencies\": {\n+ \"lru-cache\": {\n+ \"version\": \"2.5.0\",\n+ \"resolved\": \"https://registry.npmjs.org/lru-cache/-/lru-cache-2.5.0.tgz\",\n+ \"integrity\": \"sha1-2COIrpyWC+y+oMc7uet5tsbOmus=\"\n+ }\n+ }\n+ },\n\"nan\": {\n\"version\": \"2.8.0\",\n\"resolved\": \"https://registry.npmjs.org/nan/-/nan-2.8.0.tgz\",\n\"object-assign\": {\n\"version\": \"4.1.1\",\n\"resolved\": \"https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz\",\n- \"integrity\": \"sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=\",\n- \"dev\": true\n+ \"integrity\": \"sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=\"\n},\n\"object.omit\": {\n\"version\": \"2.0.1\",\n\"process-nextick-args\": {\n\"version\": \"1.0.7\",\n\"resolved\": \"https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz\",\n- \"integrity\": \"sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=\",\n- \"dev\": true\n+ \"integrity\": \"sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=\"\n},\n\"promise\": {\n\"version\": \"8.0.1\",\n\"pseudomap\": {\n\"version\": \"1.0.2\",\n\"resolved\": \"https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz\",\n- \"integrity\": \"sha1-8FKijacOYYkX7wqKw0wa5aaChrM=\",\n- \"dev\": true\n+ \"integrity\": \"sha1-8FKijacOYYkX7wqKw0wa5aaChrM=\"\n},\n\"pstree.remy\": {\n\"version\": \"1.1.0\",\n}\n}\n},\n+ \"redeyed\": {\n+ \"version\": \"1.0.1\",\n+ \"resolved\": \"https://registry.npmjs.org/redeyed/-/redeyed-1.0.1.tgz\",\n+ \"integrity\": \"sha1-6WwZO0DAgWsArshCaY5hGF5VSYo=\",\n+ \"requires\": {\n+ \"esprima\": \"3.0.0\"\n+ }\n+ },\n\"regenerator-runtime\": {\n\"version\": \"0.10.5\",\n\"resolved\": \"https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.10.5.tgz\",\n}\n}\n},\n+ \"seq-queue\": {\n+ \"version\": \"0.0.5\",\n+ \"resolved\": \"https://registry.npmjs.org/seq-queue/-/seq-queue-0.0.5.tgz\",\n+ \"integrity\": \"sha1-1WgS4cAXpuTnw+Ojeh2m143TyT4=\"\n+ },\n\"serve-static\": {\n\"version\": \"1.13.1\",\n\"resolved\": \"https://registry.npmjs.org/serve-static/-/serve-static-1.13.1.tgz\",\n\"through\": \"2.3.8\"\n}\n},\n+ \"sql-template-strings\": {\n+ \"version\": \"2.2.2\",\n+ \"resolved\": \"https://registry.npmjs.org/sql-template-strings/-/sql-template-strings-2.2.2.tgz\",\n+ \"integrity\": \"sha1-PxFQiiWt384hejBCqdMAwxk7lv8=\"\n+ },\n+ \"sqlstring\": {\n+ \"version\": \"2.3.0\",\n+ \"resolved\": \"https://registry.npmjs.org/sqlstring/-/sqlstring-2.3.0.tgz\",\n+ \"integrity\": \"sha1-UluKT9Jtb3GqYegipsr5dtMa0qg=\"\n+ },\n\"sshpk\": {\n\"version\": \"1.13.1\",\n\"resolved\": \"https://registry.npmjs.org/sshpk/-/sshpk-1.13.1.tgz\",\n\"util-deprecate\": {\n\"version\": \"1.0.2\",\n\"resolved\": \"https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz\",\n- \"integrity\": \"sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=\",\n- \"dev\": true\n+ \"integrity\": \"sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=\"\n},\n\"utils-merge\": {\n\"version\": \"1.0.1\",\n\"yallist\": {\n\"version\": \"2.1.2\",\n\"resolved\": \"https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz\",\n- \"integrity\": \"sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=\",\n- \"dev\": true\n+ \"integrity\": \"sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=\"\n},\n\"yargs\": {\n\"version\": \"4.8.1\",\n" }, { "change_type": "MODIFY", "old_path": "jserver/package.json", "new_path": "jserver/package.json", "diff": "\"body-parser\": \"^1.18.2\",\n\"express\": \"^4.16.2\",\n\"lib\": \"file:../lib\",\n- \"promise\": \"^8.0.1\"\n+ \"mysql2\": \"^1.5.1\",\n+ \"promise\": \"^8.0.1\",\n+ \"sql-template-strings\": \"^2.2.2\"\n}\n}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "jserver/src/database.js", "diff": "+// @flow\n+\n+import mysql from 'mysql2/promise';\n+import SQL from 'sql-template-strings';\n+\n+import dbConfig from '../secrets/db_config';\n+\n+export type QueryResult = [\n+ any[],\n+ any[],\n+];\n+\n+export type Connection = {\n+ query(query: string): Promise<QueryResult>;\n+ end(): Promise<void>;\n+};\n+\n+async function connect(): Promise<Connection> {\n+ return await mysql.createConnection(dbConfig);\n+}\n+\n+export {\n+ connect,\n+ SQL,\n+};\n" }, { "change_type": "MODIFY", "old_path": "jserver/src/push/ios_notifs.js", "new_path": "jserver/src/push/ios_notifs.js", "diff": "@@ -5,7 +5,8 @@ import type { RawMessageInfo } from 'lib/types/message-types';\nimport apn from 'apn';\n-import apnConfig from '../../keys/apn_config';\n+import apnConfig from '../../secrets/apn_config';\n+import { connect, SQL } from '../database';\ntype IOSPushUserInfo = {\ndeviceTokens: string[],\n@@ -17,22 +18,50 @@ const apnProvider = new apn.Provider(apnConfig);\nasync function sendIOSPushNotifs(req: $Request, res: $Response) {\nconst pushInfo: IOSPushInfo = req.body;\n+ const unreadCounts = await getUnreadCounts(Object.keys(pushInfo));\n+\nconst promises = [];\nfor (let userID in pushInfo) {\nfor (let messageInfo of pushInfo[userID].messageInfos) {\nconst notification = new apn.Notification();\nnotification.alert = \"Hello, world!\";\nnotification.topic = \"org.squadcal.app\";\n- notification.badge = 0;\n+ notification.badge = unreadCounts[userID];\npromises.push(apnProvider.send(\nnotification,\npushInfo[userID].deviceTokens,\n));\n}\n}\n+\nreturn await Promise.all(promises);\n}\n+async function getUnreadCounts(\n+ userIDs: string[],\n+): Promise<{ [userID: string]: number }> {\n+ const conn = await connect();\n+ const intUserIDs = userIDs.map(parseInt);\n+ const query = SQL`\n+ SELECT user, COUNT(thread) AS unread_count\n+ FROM memberships\n+ WHERE user IN (${intUserIDs}) AND unread = 1 AND role != 0\n+ GROUP BY user\n+ `;\n+ const [ result ] = await conn.query(query);\n+ conn.end();\n+ const usersToUnreadCounts = {};\n+ for (let row of result) {\n+ usersToUnreadCounts[row.user.toString()] = row.unread_count;\n+ }\n+ for (let userID of userIDs) {\n+ if (usersToUnreadCounts[userID] === undefined) {\n+ usersToUnreadCounts[userID] = 0;\n+ }\n+ }\n+ return usersToUnreadCounts;\n+}\n+\nexport {\nsendIOSPushNotifs,\n};\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Fetch unread counts from MySQL in node.js notifs logic
129,187
27.12.2017 23:10:07
18,000
08ec76d1692d964cc1482084f00a08ce2a3f2100
Don't wait for push notifs to response to send message request
[ { "change_type": "MODIFY", "old_path": "jserver/src/error_handler.js", "new_path": "jserver/src/error_handler.js", "diff": "@@ -8,10 +8,13 @@ export default function errorHandler(handler: OurHandler) {\nreturn async (req: $Request, res: $Response) => {\ntry {\nconst result = await handler(req, res);\n- const stringResult = typeof result === \"object\"\n- ? JSON.stringify(result)\n- : result;\n- res.send(stringResult);\n+ if (res.headersSent) {\n+ return;\n+ } else if (typeof result === \"object\") {\n+ res.json(result);\n+ } else {\n+ res.send(result);\n+ }\n} catch (error) {\nres.status(500).send(error.message);\n}\n" }, { "change_type": "MODIFY", "old_path": "jserver/src/push/ios_notifs.js", "new_path": "jserver/src/push/ios_notifs.js", "diff": "@@ -17,6 +17,8 @@ type IOSPushInfo = { [userID: string]: IOSPushUserInfo };\nconst apnProvider = new apn.Provider(apnConfig);\nasync function sendIOSPushNotifs(req: $Request, res: $Response) {\n+ res.json({ success: true });\n+\nconst pushInfo: IOSPushInfo = req.body;\nconst unreadCounts = await getUnreadCounts(Object.keys(pushInfo));\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Don't wait for push notifs to response to send message request
129,187
27.12.2017 23:10:39
18,000
ef01602d98345f8bf673103596a4441bea055a51
Race condition where ping returns before send message completes leads to duplicate messageIDs
[ { "change_type": "MODIFY", "old_path": "lib/reducers/message-reducer.js", "new_path": "lib/reducers/message-reducer.js", "diff": "@@ -23,9 +23,10 @@ import _pick from 'lodash/fp/pick';\nimport _pickBy from 'lodash/fp/pickBy';\nimport _omitBy from 'lodash/fp/omitBy';\nimport _mapKeys from 'lodash/fp/mapKeys';\n+import _uniq from 'lodash/fp/uniq';\nimport { messageID } from '../shared/message-utils';\n-import { messageTruncationStatus } from '../types/message-types';\n+import { messageTruncationStatus, messageType } from '../types/message-types';\nimport { setHighestLocalID } from '../utils/local-ids';\nimport { viewerIsMember } from '../shared/thread-utils';\nimport { setCookieActionType } from '../utils/action-utils';\n@@ -142,13 +143,13 @@ function mergeNewMessages(\ntypeof currentMessageInfo.localID === \"string\"\n) {\ninvariant(\n- inputMessageInfo.type === 0,\n+ inputMessageInfo.type === messageType.TEXT,\n\"only MessageType.TEXT has localID\",\n);\n// Try to preserve localIDs. This is because we use them as React\n// keys and changing React keys leads to loss of component state.\nmessageInfo = {\n- type: 0,\n+ type: messageType.TEXT,\nid: inputMessageInfo.id,\nlocalID: currentMessageInfo.localID,\nthreadID: inputMessageInfo.threadID,\n@@ -454,8 +455,9 @@ function reduceMessageStore(\ntime: payload.time,\n};\nconst threadID = payload.threadID;\n- const newMessageIDs =\n- messageStore.threads[threadID].messageIDs.map(replaceMessageKey);\n+ const newMessageIDs = _uniq(\n+ messageStore.threads[threadID].messageIDs.map(replaceMessageKey),\n+ );\nreturn {\nmessages: newMessages,\nthreads: {\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Race condition where ping returns before send message completes leads to duplicate messageIDs
129,187
27.12.2017 23:11:13
18,000
8c20ed41d0f2aab65b41557429a1c9df64340f6e
Keep text state local to InputBar Only use `draft` from Redux when constructing
[ { "change_type": "MODIFY", "old_path": "native/chat/input-bar.react.js", "new_path": "native/chat/input-bar.react.js", "diff": "@@ -71,13 +71,11 @@ type Props = {\n) => Promise<JoinThreadResult>,\n};\ntype State = {\n+ text: string,\nheight: number,\n};\nclass InputBar extends React.PureComponent<Props, State> {\n- state = {\n- height: 0,\n- };\nstatic propTypes = {\nthreadID: PropTypes.string.isRequired,\nusername: PropTypes.string,\n@@ -92,10 +90,18 @@ class InputBar extends React.PureComponent<Props, State> {\n};\ntextInput: ?TextInput;\n+ constructor(props: Props) {\n+ super(props);\n+ this.state = {\n+ text: props.draft,\n+ height: 0,\n+ };\n+ }\n+\ncomponentWillUpdate(nextProps: Props, nextState: State) {\nif (\n- this.props.draft === \"\" && nextProps.draft !== \"\" ||\n- this.props.draft !== \"\" && nextProps.draft === \"\"\n+ this.state.text === \"\" && nextState.text !== \"\" ||\n+ this.state.text !== \"\" && nextState.text === \"\"\n) {\nLayoutAnimation.easeInEaseOut();\n}\n@@ -142,7 +148,7 @@ class InputBar extends React.PureComponent<Props, State> {\n};\nconst textInput = (\n<TextInput\n- value={this.props.draft}\n+ value={this.state.text}\nonChangeText={this.updateText}\nunderlineColorAndroid=\"transparent\"\nplaceholder=\"Send a message...\"\n@@ -154,7 +160,7 @@ class InputBar extends React.PureComponent<Props, State> {\n/>\n);\nlet button = null;\n- if (this.props.draft) {\n+ if (this.state.text) {\nbutton = (\n<TouchableOpacity\nonPress={this.onSend}\n@@ -222,6 +228,7 @@ class InputBar extends React.PureComponent<Props, State> {\n}\nupdateText = (text: string) => {\n+ this.setState({ text });\nthis.props.dispatchActionPayload(\nsaveDraftActionType,\n{ key: draftKeyFromThreadID(this.props.threadID), draft: text },\n@@ -236,6 +243,7 @@ class InputBar extends React.PureComponent<Props, State> {\n}\nonSend = () => {\n+ this.updateText(\"\");\nconst localID = `local${getNewLocalID()}`;\nconst creatorID = this.props.viewerID;\ninvariant(creatorID, \"should have viewer ID in order to send a message\");\n@@ -243,7 +251,7 @@ class InputBar extends React.PureComponent<Props, State> {\ntype: messageType.TEXT,\nlocalID,\nthreadID: this.props.threadID,\n- text: this.props.draft,\n+ text: this.state.text,\ncreatorID,\ntime: Date.now(),\n}: RawTextMessageInfo);\n@@ -253,7 +261,6 @@ class InputBar extends React.PureComponent<Props, State> {\nundefined,\nmessageInfo,\n);\n- this.updateText(\"\");\n}\nasync sendMessageAction(messageInfo: RawTextMessageInfo) {\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Keep text state local to InputBar Only use `draft` from Redux when constructing
129,187
28.12.2017 00:38:19
18,000
b0260f006acbbca34b85a66b02db3b879afa610d
server config for node.js
[ { "change_type": "ADD", "old_path": null, "new_path": "jserver/.nvmrc", "diff": "+default\n" }, { "change_type": "MODIFY", "old_path": "jserver/package-lock.json", "new_path": "jserver/package-lock.json", "diff": "}\n},\n\"ansi-regex\": {\n- \"version\": \"3.0.0\",\n- \"resolved\": \"https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz\",\n- \"integrity\": \"sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=\",\n+ \"version\": \"2.1.1\",\n+ \"resolved\": \"https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz\",\n+ \"integrity\": \"sha1-w7M6te42DYbg5ijwRorn7yfWVN8=\",\n\"dev\": true\n},\n\"ansi-styles\": {\n- \"version\": \"3.2.0\",\n- \"resolved\": \"https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.0.tgz\",\n- \"integrity\": \"sha512-NnSOmMEYtVR2JVMIGTzynRkkaxtiq1xnFBcdQD/DnNCYPoEPsVJhM98BDyaoNOQIi7p4okdi3E27eN7GQbsUug==\",\n- \"dev\": true,\n- \"requires\": {\n- \"color-convert\": \"1.9.1\"\n- }\n+ \"version\": \"2.2.1\",\n+ \"resolved\": \"https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz\",\n+ \"integrity\": \"sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=\",\n+ \"dev\": true\n},\n\"ansicolors\": {\n\"version\": \"0.2.1\",\n\"jsonwebtoken\": \"8.1.0\",\n\"node-forge\": \"0.7.1\",\n\"verror\": \"1.10.0\"\n- },\n- \"dependencies\": {\n- \"debug\": {\n- \"version\": \"3.1.0\",\n- \"resolved\": \"https://registry.npmjs.org/debug/-/debug-3.1.0.tgz\",\n- \"integrity\": \"sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==\",\n- \"requires\": {\n- \"ms\": \"2.0.0\"\n- }\n- }\n}\n},\n\"arr-diff\": {\n\"chalk\": \"1.1.3\",\n\"esutils\": \"2.0.2\",\n\"js-tokens\": \"3.0.2\"\n- },\n- \"dependencies\": {\n- \"ansi-regex\": {\n- \"version\": \"2.1.1\",\n- \"resolved\": \"https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz\",\n- \"integrity\": \"sha1-w7M6te42DYbg5ijwRorn7yfWVN8=\",\n- \"dev\": true\n- },\n- \"ansi-styles\": {\n- \"version\": \"2.2.1\",\n- \"resolved\": \"https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz\",\n- \"integrity\": \"sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=\",\n- \"dev\": true\n- },\n- \"chalk\": {\n- \"version\": \"1.1.3\",\n- \"resolved\": \"https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz\",\n- \"integrity\": \"sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=\",\n- \"dev\": true,\n- \"requires\": {\n- \"ansi-styles\": \"2.2.1\",\n- \"escape-string-regexp\": \"1.0.5\",\n- \"has-ansi\": \"2.0.0\",\n- \"strip-ansi\": \"3.0.1\",\n- \"supports-color\": \"2.0.0\"\n- }\n- },\n- \"strip-ansi\": {\n- \"version\": \"3.0.1\",\n- \"resolved\": \"https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz\",\n- \"integrity\": \"sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=\",\n- \"dev\": true,\n- \"requires\": {\n- \"ansi-regex\": \"2.1.1\"\n- }\n- },\n- \"supports-color\": {\n- \"version\": \"2.0.0\",\n- \"resolved\": \"https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz\",\n- \"integrity\": \"sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=\",\n- \"dev\": true\n- }\n}\n},\n\"babel-core\": {\n\"private\": \"0.1.8\",\n\"slash\": \"1.0.0\",\n\"source-map\": \"0.5.7\"\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+ \"dev\": true,\n+ \"requires\": {\n+ \"ms\": \"2.0.0\"\n+ }\n+ }\n}\n},\n\"babel-generator\": {\n\"babel-runtime\": \"6.26.0\",\n\"core-js\": \"2.5.3\",\n\"regenerator-runtime\": \"0.10.5\"\n+ },\n+ \"dependencies\": {\n+ \"regenerator-runtime\": {\n+ \"version\": \"0.10.5\",\n+ \"resolved\": \"https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.10.5.tgz\",\n+ \"integrity\": \"sha1-M2w+/BIgrc7dosn6tntaeVWjNlg=\",\n+ \"dev\": true\n+ }\n}\n},\n\"babel-preset-flow\": {\n\"requires\": {\n\"core-js\": \"2.5.3\",\n\"regenerator-runtime\": \"0.11.1\"\n- },\n- \"dependencies\": {\n- \"regenerator-runtime\": {\n- \"version\": \"0.11.1\",\n- \"resolved\": \"https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz\",\n- \"integrity\": \"sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg==\",\n- \"dev\": true\n- }\n}\n},\n\"babel-template\": {\n\"globals\": \"9.18.0\",\n\"invariant\": \"2.2.2\",\n\"lodash\": \"4.17.4\"\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+ \"dev\": true,\n+ \"requires\": {\n+ \"ms\": \"2.0.0\"\n+ }\n+ }\n}\n},\n\"babel-types\": {\n\"qs\": \"6.5.1\",\n\"raw-body\": \"2.3.2\",\n\"type-is\": \"1.6.15\"\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}\n},\n\"boom\": {\n\"widest-line\": \"2.0.0\"\n},\n\"dependencies\": {\n+ \"ansi-styles\": {\n+ \"version\": \"3.2.0\",\n+ \"resolved\": \"https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.0.tgz\",\n+ \"integrity\": \"sha512-NnSOmMEYtVR2JVMIGTzynRkkaxtiq1xnFBcdQD/DnNCYPoEPsVJhM98BDyaoNOQIi7p4okdi3E27eN7GQbsUug==\",\n+ \"dev\": true,\n+ \"requires\": {\n+ \"color-convert\": \"1.9.1\"\n+ }\n+ },\n\"camelcase\": {\n\"version\": \"4.1.0\",\n\"resolved\": \"https://registry.npmjs.org/camelcase/-/camelcase-4.1.0.tgz\",\n\"integrity\": \"sha1-1UVjW+HjPFQmScaRc+Xeas+uNN0=\",\n\"dev\": true\n+ },\n+ \"chalk\": {\n+ \"version\": \"2.3.0\",\n+ \"resolved\": \"https://registry.npmjs.org/chalk/-/chalk-2.3.0.tgz\",\n+ \"integrity\": \"sha512-Az5zJR2CBujap2rqXGaJKaPHyJ0IrUimvYNX+ncCy8PJP4ltOGTrHUIo097ZaL2zMeKYpiCdqDvS6zdrTFok3Q==\",\n+ \"dev\": true,\n+ \"requires\": {\n+ \"ansi-styles\": \"3.2.0\",\n+ \"escape-string-regexp\": \"1.0.5\",\n+ \"supports-color\": \"4.5.0\"\n+ }\n+ },\n+ \"has-flag\": {\n+ \"version\": \"2.0.0\",\n+ \"resolved\": \"https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz\",\n+ \"integrity\": \"sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=\",\n+ \"dev\": true\n+ },\n+ \"supports-color\": {\n+ \"version\": \"4.5.0\",\n+ \"resolved\": \"https://registry.npmjs.org/supports-color/-/supports-color-4.5.0.tgz\",\n+ \"integrity\": \"sha1-vnoN5ITexcXN34s9WRJQRJEvY1s=\",\n+ \"dev\": true,\n+ \"requires\": {\n+ \"has-flag\": \"2.0.0\"\n+ }\n}\n}\n},\n}\n},\n\"chalk\": {\n- \"version\": \"2.3.0\",\n- \"resolved\": \"https://registry.npmjs.org/chalk/-/chalk-2.3.0.tgz\",\n- \"integrity\": \"sha512-Az5zJR2CBujap2rqXGaJKaPHyJ0IrUimvYNX+ncCy8PJP4ltOGTrHUIo097ZaL2zMeKYpiCdqDvS6zdrTFok3Q==\",\n+ \"version\": \"1.1.3\",\n+ \"resolved\": \"https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz\",\n+ \"integrity\": \"sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=\",\n\"dev\": true,\n\"requires\": {\n- \"ansi-styles\": \"3.2.0\",\n+ \"ansi-styles\": \"2.2.1\",\n\"escape-string-regexp\": \"1.0.5\",\n- \"supports-color\": \"4.5.0\"\n+ \"has-ansi\": \"2.0.0\",\n+ \"strip-ansi\": \"3.0.1\",\n+ \"supports-color\": \"2.0.0\"\n}\n},\n\"charenc\": {\n\"wrap-ansi\": \"2.1.0\"\n},\n\"dependencies\": {\n- \"ansi-regex\": {\n- \"version\": \"2.1.1\",\n- \"resolved\": \"https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz\",\n- \"integrity\": \"sha1-w7M6te42DYbg5ijwRorn7yfWVN8=\",\n- \"dev\": true\n- },\n\"is-fullwidth-code-point\": {\n\"version\": \"1.0.0\",\n\"resolved\": \"https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz\",\n\"is-fullwidth-code-point\": \"1.0.0\",\n\"strip-ansi\": \"3.0.1\"\n}\n- },\n- \"strip-ansi\": {\n- \"version\": \"3.0.1\",\n- \"resolved\": \"https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz\",\n- \"integrity\": \"sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=\",\n- \"dev\": true,\n- \"requires\": {\n- \"ansi-regex\": \"2.1.1\"\n- }\n}\n}\n},\n\"ansi-regex\": \"0.2.1\"\n}\n},\n- \"has-flag\": {\n- \"version\": \"1.0.0\",\n- \"resolved\": \"https://registry.npmjs.org/has-flag/-/has-flag-1.0.0.tgz\",\n- \"integrity\": \"sha1-nZ55MWXOAXoA8AQYxD+UKnsdEfo=\",\n- \"dev\": true\n- },\n\"strip-ansi\": {\n\"version\": \"0.3.0\",\n\"resolved\": \"https://registry.npmjs.org/strip-ansi/-/strip-ansi-0.3.0.tgz\",\n\"dev\": true\n},\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+ \"version\": \"3.1.0\",\n+ \"resolved\": \"https://registry.npmjs.org/debug/-/debug-3.1.0.tgz\",\n+ \"integrity\": \"sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==\",\n\"requires\": {\n\"ms\": \"2.0.0\"\n}\n\"type-is\": \"1.6.15\",\n\"utils-merge\": \"1.0.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+ \"setprototypeof\": {\n+ \"version\": \"1.1.0\",\n+ \"resolved\": \"https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.0.tgz\",\n+ \"integrity\": \"sha512-BvE/TwpZX4FXExxOxZyRGQQv651MSwmWKZGqvmPcRIjDqWub67kTKuIMx43cZZrS/cBBzwBcNDWoFxt2XEFIpQ==\"\n+ },\n+ \"statuses\": {\n+ \"version\": \"1.3.1\",\n+ \"resolved\": \"https://registry.npmjs.org/statuses/-/statuses-1.3.1.tgz\",\n+ \"integrity\": \"sha1-+vUbnrdKrvOzrPStX2Gr8ky3uT4=\"\n+ }\n}\n},\n\"extend\": {\n}\n},\n\"extsprintf\": {\n- \"version\": \"1.3.0\",\n- \"resolved\": \"https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz\",\n- \"integrity\": \"sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=\"\n+ \"version\": \"1.4.0\",\n+ \"resolved\": \"https://registry.npmjs.org/extsprintf/-/extsprintf-1.4.0.tgz\",\n+ \"integrity\": \"sha1-4mifjzVvrWLMplo6kcXfX5VRaS8=\"\n},\n\"fast-deep-equal\": {\n\"version\": \"1.0.0\",\n\"parseurl\": \"1.3.2\",\n\"statuses\": \"1.3.1\",\n\"unpipe\": \"1.0.0\"\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+ \"statuses\": {\n+ \"version\": \"1.3.1\",\n+ \"resolved\": \"https://registry.npmjs.org/statuses/-/statuses-1.3.1.tgz\",\n+ \"integrity\": \"sha1-+vUbnrdKrvOzrPStX2Gr8ky3uT4=\"\n+ }\n}\n},\n\"find-up\": {\n\"integrity\": \"sha1-JPp/DhP6EblGr5ETTFGYKpHOU4s=\",\n\"dev\": true,\n\"requires\": {\n- \"mime\": \"1.6.0\"\n+ \"mime\": \"1.4.1\"\n}\n},\n\"glob\": {\n\"dev\": true,\n\"requires\": {\n\"ansi-regex\": \"2.1.1\"\n- },\n- \"dependencies\": {\n- \"ansi-regex\": {\n- \"version\": \"2.1.1\",\n- \"resolved\": \"https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz\",\n- \"integrity\": \"sha1-w7M6te42DYbg5ijwRorn7yfWVN8=\",\n- \"dev\": true\n- }\n}\n},\n\"has-flag\": {\n- \"version\": \"2.0.0\",\n- \"resolved\": \"https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz\",\n- \"integrity\": \"sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=\",\n+ \"version\": \"1.0.0\",\n+ \"resolved\": \"https://registry.npmjs.org/has-flag/-/has-flag-1.0.0.tgz\",\n+ \"integrity\": \"sha1-nZ55MWXOAXoA8AQYxD+UKnsdEfo=\",\n\"dev\": true\n},\n\"has-symbol-support-x\": {\n\"depd\": \"1.1.1\",\n\"inherits\": \"2.0.3\",\n\"setprototypeof\": \"1.0.3\",\n- \"statuses\": \"1.3.1\"\n- },\n- \"dependencies\": {\n- \"setprototypeof\": {\n- \"version\": \"1.0.3\",\n- \"resolved\": \"https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.0.3.tgz\",\n- \"integrity\": \"sha1-ZlZ+NwQ+608E2RvWWMDL77VbjgQ=\"\n- }\n+ \"statuses\": \"1.4.0\"\n}\n},\n\"http-signature\": {\n\"dev\": true\n},\n\"isarray\": {\n- \"version\": \"0.0.1\",\n- \"resolved\": \"https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz\",\n- \"integrity\": \"sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=\",\n- \"dev\": true\n- },\n+ \"version\": \"1.0.0\",\n+ \"resolved\": \"https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz\",\n+ \"integrity\": \"sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=\"\n+ },\n\"isexe\": {\n\"version\": \"2.0.0\",\n\"resolved\": \"https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz\",\n\"dev\": true,\n\"requires\": {\n\"isarray\": \"1.0.0\"\n- },\n- \"dependencies\": {\n- \"isarray\": {\n- \"version\": \"1.0.0\",\n- \"resolved\": \"https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz\",\n- \"integrity\": \"sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=\",\n- \"dev\": true\n- }\n}\n},\n\"isstream\": {\n\"extsprintf\": \"1.3.0\",\n\"json-schema\": \"0.2.3\",\n\"verror\": \"1.10.0\"\n+ },\n+ \"dependencies\": {\n+ \"extsprintf\": {\n+ \"version\": \"1.3.0\",\n+ \"resolved\": \"https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz\",\n+ \"integrity\": \"sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=\",\n+ \"dev\": true\n+ }\n}\n},\n\"jwa\": {\n\"requires\": {\n\"buffers\": \"0.1.1\",\n\"readable-stream\": \"1.0.34\"\n+ },\n+ \"dependencies\": {\n+ \"isarray\": {\n+ \"version\": \"0.0.1\",\n+ \"resolved\": \"https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz\",\n+ \"integrity\": \"sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=\",\n+ \"dev\": true\n+ },\n+ \"readable-stream\": {\n+ \"version\": \"1.0.34\",\n+ \"resolved\": \"https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz\",\n+ \"integrity\": \"sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=\",\n+ \"dev\": true,\n+ \"requires\": {\n+ \"core-util-is\": \"1.0.2\",\n+ \"inherits\": \"2.0.3\",\n+ \"isarray\": \"0.0.1\",\n+ \"string_decoder\": \"0.10.31\"\n+ }\n+ },\n+ \"string_decoder\": {\n+ \"version\": \"0.10.31\",\n+ \"resolved\": \"https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz\",\n+ \"integrity\": \"sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=\",\n+ \"dev\": true\n+ }\n}\n},\n\"md5\": {\n}\n},\n\"mime\": {\n- \"version\": \"1.6.0\",\n- \"resolved\": \"https://registry.npmjs.org/mime/-/mime-1.6.0.tgz\",\n- \"integrity\": \"sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==\",\n- \"dev\": true\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.30.0\",\n\"safe-buffer\": \"5.1.1\",\n\"seq-queue\": \"0.0.5\",\n\"sqlstring\": \"2.3.0\"\n- },\n- \"dependencies\": {\n- \"isarray\": {\n- \"version\": \"1.0.0\",\n- \"resolved\": \"https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz\",\n- \"integrity\": \"sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=\"\n- },\n- \"readable-stream\": {\n- \"version\": \"2.3.2\",\n- \"resolved\": \"https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.2.tgz\",\n- \"integrity\": \"sha1-WgTfBeT1f+Pw3Gj90R3FyXx+b00=\",\n- \"requires\": {\n- \"core-util-is\": \"1.0.2\",\n- \"inherits\": \"2.0.3\",\n- \"isarray\": \"1.0.0\",\n- \"process-nextick-args\": \"1.0.7\",\n- \"safe-buffer\": \"5.1.1\",\n- \"string_decoder\": \"1.0.3\",\n- \"util-deprecate\": \"1.0.2\"\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}\n},\n\"named-placeholders\": {\n\"touch\": \"3.1.0\",\n\"undefsafe\": \"0.0.3\",\n\"update-notifier\": \"2.3.0\"\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+ \"dev\": true,\n+ \"requires\": {\n+ \"ms\": \"2.0.0\"\n+ }\n+ }\n}\n},\n\"nopt\": {\n\"readable-stream\": \"1.0.34\",\n\"setimmediate\": \"1.0.5\",\n\"slice-stream\": \"1.0.0\"\n+ },\n+ \"dependencies\": {\n+ \"isarray\": {\n+ \"version\": \"0.0.1\",\n+ \"resolved\": \"https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz\",\n+ \"integrity\": \"sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=\",\n+ \"dev\": true\n+ },\n+ \"readable-stream\": {\n+ \"version\": \"1.0.34\",\n+ \"resolved\": \"https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz\",\n+ \"integrity\": \"sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=\",\n+ \"dev\": true,\n+ \"requires\": {\n+ \"core-util-is\": \"1.0.2\",\n+ \"inherits\": \"2.0.3\",\n+ \"isarray\": \"0.0.1\",\n+ \"string_decoder\": \"0.10.31\"\n+ }\n+ },\n+ \"string_decoder\": {\n+ \"version\": \"0.10.31\",\n+ \"resolved\": \"https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz\",\n+ \"integrity\": \"sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=\",\n+ \"dev\": true\n+ }\n}\n},\n\"punycode\": {\n}\n},\n\"readable-stream\": {\n- \"version\": \"1.0.34\",\n- \"resolved\": \"https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz\",\n- \"integrity\": \"sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=\",\n- \"dev\": true,\n+ \"version\": \"2.3.2\",\n+ \"resolved\": \"https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.2.tgz\",\n+ \"integrity\": \"sha1-WgTfBeT1f+Pw3Gj90R3FyXx+b00=\",\n\"requires\": {\n\"core-util-is\": \"1.0.2\",\n\"inherits\": \"2.0.3\",\n- \"isarray\": \"0.0.1\",\n- \"string_decoder\": \"0.10.31\"\n+ \"isarray\": \"1.0.0\",\n+ \"process-nextick-args\": \"1.0.7\",\n+ \"safe-buffer\": \"5.1.1\",\n+ \"string_decoder\": \"1.0.3\",\n+ \"util-deprecate\": \"1.0.2\"\n}\n},\n\"readdirp\": {\n\"requires\": {\n\"graceful-fs\": \"4.1.11\",\n\"minimatch\": \"3.0.4\",\n- \"readable-stream\": \"2.3.3\",\n+ \"readable-stream\": \"2.3.2\",\n\"set-immediate-shim\": \"1.0.1\"\n- },\n- \"dependencies\": {\n- \"isarray\": {\n- \"version\": \"1.0.0\",\n- \"resolved\": \"https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz\",\n- \"integrity\": \"sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=\",\n- \"dev\": true\n- },\n- \"readable-stream\": {\n- \"version\": \"2.3.3\",\n- \"resolved\": \"https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.3.tgz\",\n- \"integrity\": \"sha512-m+qzzcn7KUxEmd1gMbchF+Y2eIUbieUaxkWtptyHywrX0rE8QEYqPC07Vuy4Wm32/xE16NcdBctb8S0Xe/5IeQ==\",\n- \"dev\": true,\n- \"requires\": {\n- \"core-util-is\": \"1.0.2\",\n- \"inherits\": \"2.0.3\",\n- \"isarray\": \"1.0.0\",\n- \"process-nextick-args\": \"1.0.7\",\n- \"safe-buffer\": \"5.1.1\",\n- \"string_decoder\": \"1.0.3\",\n- \"util-deprecate\": \"1.0.2\"\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- \"dev\": true,\n- \"requires\": {\n- \"safe-buffer\": \"5.1.1\"\n- }\n- }\n}\n},\n\"redeyed\": {\n}\n},\n\"regenerator-runtime\": {\n- \"version\": \"0.10.5\",\n- \"resolved\": \"https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.10.5.tgz\",\n- \"integrity\": \"sha1-M2w+/BIgrc7dosn6tntaeVWjNlg=\",\n+ \"version\": \"0.11.1\",\n+ \"resolved\": \"https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz\",\n+ \"integrity\": \"sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg==\",\n\"dev\": true\n},\n\"regex-cache\": {\n\"statuses\": \"1.3.1\"\n},\n\"dependencies\": {\n- \"mime\": {\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+ \"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+ \"statuses\": {\n+ \"version\": \"1.3.1\",\n+ \"resolved\": \"https://registry.npmjs.org/statuses/-/statuses-1.3.1.tgz\",\n+ \"integrity\": \"sha1-+vUbnrdKrvOzrPStX2Gr8ky3uT4=\"\n}\n}\n},\n\"dev\": true\n},\n\"setprototypeof\": {\n- \"version\": \"1.1.0\",\n- \"resolved\": \"https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.0.tgz\",\n- \"integrity\": \"sha512-BvE/TwpZX4FXExxOxZyRGQQv651MSwmWKZGqvmPcRIjDqWub67kTKuIMx43cZZrS/cBBzwBcNDWoFxt2XEFIpQ==\"\n+ \"version\": \"1.0.3\",\n+ \"resolved\": \"https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.0.3.tgz\",\n+ \"integrity\": \"sha1-ZlZ+NwQ+608E2RvWWMDL77VbjgQ=\"\n},\n\"shebang-command\": {\n\"version\": \"1.2.0\",\n\"dev\": true,\n\"requires\": {\n\"readable-stream\": \"1.0.34\"\n+ },\n+ \"dependencies\": {\n+ \"isarray\": {\n+ \"version\": \"0.0.1\",\n+ \"resolved\": \"https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz\",\n+ \"integrity\": \"sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=\",\n+ \"dev\": true\n+ },\n+ \"readable-stream\": {\n+ \"version\": \"1.0.34\",\n+ \"resolved\": \"https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz\",\n+ \"integrity\": \"sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=\",\n+ \"dev\": true,\n+ \"requires\": {\n+ \"core-util-is\": \"1.0.2\",\n+ \"inherits\": \"2.0.3\",\n+ \"isarray\": \"0.0.1\",\n+ \"string_decoder\": \"0.10.31\"\n+ }\n+ },\n+ \"string_decoder\": {\n+ \"version\": \"0.10.31\",\n+ \"resolved\": \"https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz\",\n+ \"integrity\": \"sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=\",\n+ \"dev\": true\n+ }\n}\n},\n\"sntp\": {\n}\n},\n\"statuses\": {\n- \"version\": \"1.3.1\",\n- \"resolved\": \"https://registry.npmjs.org/statuses/-/statuses-1.3.1.tgz\",\n- \"integrity\": \"sha1-+vUbnrdKrvOzrPStX2Gr8ky3uT4=\"\n+ \"version\": \"1.4.0\",\n+ \"resolved\": \"https://registry.npmjs.org/statuses/-/statuses-1.4.0.tgz\",\n+ \"integrity\": \"sha512-zhSCtt8v2NDrRlPQpCNtw/heZLtfUDqxBM1udqikb/Hbk52LK4nQSwr10u77iopCW5LsyHpuXS0GnEc48mLeew==\"\n},\n\"stream-combiner\": {\n\"version\": \"0.0.4\",\n\"requires\": {\n\"is-fullwidth-code-point\": \"2.0.0\",\n\"strip-ansi\": \"4.0.0\"\n+ },\n+ \"dependencies\": {\n+ \"ansi-regex\": {\n+ \"version\": \"3.0.0\",\n+ \"resolved\": \"https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz\",\n+ \"integrity\": \"sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=\",\n+ \"dev\": true\n+ },\n+ \"strip-ansi\": {\n+ \"version\": \"4.0.0\",\n+ \"resolved\": \"https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz\",\n+ \"integrity\": \"sha1-qEeQIusaw2iocTibY1JixQXuNo8=\",\n+ \"dev\": true,\n+ \"requires\": {\n+ \"ansi-regex\": \"3.0.0\"\n+ }\n+ }\n}\n},\n\"string_decoder\": {\n- \"version\": \"0.10.31\",\n- \"resolved\": \"https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz\",\n- \"integrity\": \"sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=\",\n- \"dev\": true\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\"dev\": true\n},\n\"strip-ansi\": {\n- \"version\": \"4.0.0\",\n- \"resolved\": \"https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz\",\n- \"integrity\": \"sha1-qEeQIusaw2iocTibY1JixQXuNo8=\",\n+ \"version\": \"3.0.1\",\n+ \"resolved\": \"https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz\",\n+ \"integrity\": \"sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=\",\n\"dev\": true,\n\"requires\": {\n- \"ansi-regex\": \"3.0.0\"\n+ \"ansi-regex\": \"2.1.1\"\n}\n},\n\"strip-bom\": {\n\"dev\": true\n},\n\"supports-color\": {\n- \"version\": \"4.5.0\",\n- \"resolved\": \"https://registry.npmjs.org/supports-color/-/supports-color-4.5.0.tgz\",\n- \"integrity\": \"sha1-vnoN5ITexcXN34s9WRJQRJEvY1s=\",\n- \"dev\": true,\n- \"requires\": {\n- \"has-flag\": \"2.0.0\"\n- }\n+ \"version\": \"2.0.0\",\n+ \"resolved\": \"https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz\",\n+ \"integrity\": \"sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=\",\n+ \"dev\": true\n},\n\"table\": {\n\"version\": \"4.0.2\",\n\"lodash\": \"4.17.4\",\n\"slice-ansi\": \"1.0.0\",\n\"string-width\": \"2.1.1\"\n+ },\n+ \"dependencies\": {\n+ \"ansi-styles\": {\n+ \"version\": \"3.2.0\",\n+ \"resolved\": \"https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.0.tgz\",\n+ \"integrity\": \"sha512-NnSOmMEYtVR2JVMIGTzynRkkaxtiq1xnFBcdQD/DnNCYPoEPsVJhM98BDyaoNOQIi7p4okdi3E27eN7GQbsUug==\",\n+ \"dev\": true,\n+ \"requires\": {\n+ \"color-convert\": \"1.9.1\"\n+ }\n+ },\n+ \"chalk\": {\n+ \"version\": \"2.3.0\",\n+ \"resolved\": \"https://registry.npmjs.org/chalk/-/chalk-2.3.0.tgz\",\n+ \"integrity\": \"sha512-Az5zJR2CBujap2rqXGaJKaPHyJ0IrUimvYNX+ncCy8PJP4ltOGTrHUIo097ZaL2zMeKYpiCdqDvS6zdrTFok3Q==\",\n+ \"dev\": true,\n+ \"requires\": {\n+ \"ansi-styles\": \"3.2.0\",\n+ \"escape-string-regexp\": \"1.0.5\",\n+ \"supports-color\": \"4.5.0\"\n+ }\n+ },\n+ \"has-flag\": {\n+ \"version\": \"2.0.0\",\n+ \"resolved\": \"https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz\",\n+ \"integrity\": \"sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=\",\n+ \"dev\": true\n+ },\n+ \"supports-color\": {\n+ \"version\": \"4.5.0\",\n+ \"resolved\": \"https://registry.npmjs.org/supports-color/-/supports-color-4.5.0.tgz\",\n+ \"integrity\": \"sha1-vnoN5ITexcXN34s9WRJQRJEvY1s=\",\n+ \"dev\": true,\n+ \"requires\": {\n+ \"has-flag\": \"2.0.0\"\n+ }\n+ }\n}\n},\n\"term-size\": {\n\"pullstream\": \"0.4.1\",\n\"readable-stream\": \"1.0.34\",\n\"setimmediate\": \"1.0.5\"\n+ },\n+ \"dependencies\": {\n+ \"isarray\": {\n+ \"version\": \"0.0.1\",\n+ \"resolved\": \"https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz\",\n+ \"integrity\": \"sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=\",\n+ \"dev\": true\n+ },\n+ \"readable-stream\": {\n+ \"version\": \"1.0.34\",\n+ \"resolved\": \"https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz\",\n+ \"integrity\": \"sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=\",\n+ \"dev\": true,\n+ \"requires\": {\n+ \"core-util-is\": \"1.0.2\",\n+ \"inherits\": \"2.0.3\",\n+ \"isarray\": \"0.0.1\",\n+ \"string_decoder\": \"0.10.31\"\n+ }\n+ },\n+ \"string_decoder\": {\n+ \"version\": \"0.10.31\",\n+ \"resolved\": \"https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz\",\n+ \"integrity\": \"sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=\",\n+ \"dev\": true\n+ }\n}\n},\n\"unzip-response\": {\n\"latest-version\": \"3.1.0\",\n\"semver-diff\": \"2.1.0\",\n\"xdg-basedir\": \"3.0.0\"\n+ },\n+ \"dependencies\": {\n+ \"ansi-styles\": {\n+ \"version\": \"3.2.0\",\n+ \"resolved\": \"https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.0.tgz\",\n+ \"integrity\": \"sha512-NnSOmMEYtVR2JVMIGTzynRkkaxtiq1xnFBcdQD/DnNCYPoEPsVJhM98BDyaoNOQIi7p4okdi3E27eN7GQbsUug==\",\n+ \"dev\": true,\n+ \"requires\": {\n+ \"color-convert\": \"1.9.1\"\n+ }\n+ },\n+ \"chalk\": {\n+ \"version\": \"2.3.0\",\n+ \"resolved\": \"https://registry.npmjs.org/chalk/-/chalk-2.3.0.tgz\",\n+ \"integrity\": \"sha512-Az5zJR2CBujap2rqXGaJKaPHyJ0IrUimvYNX+ncCy8PJP4ltOGTrHUIo097ZaL2zMeKYpiCdqDvS6zdrTFok3Q==\",\n+ \"dev\": true,\n+ \"requires\": {\n+ \"ansi-styles\": \"3.2.0\",\n+ \"escape-string-regexp\": \"1.0.5\",\n+ \"supports-color\": \"4.5.0\"\n+ }\n+ },\n+ \"has-flag\": {\n+ \"version\": \"2.0.0\",\n+ \"resolved\": \"https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz\",\n+ \"integrity\": \"sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=\",\n+ \"dev\": true\n+ },\n+ \"supports-color\": {\n+ \"version\": \"4.5.0\",\n+ \"resolved\": \"https://registry.npmjs.org/supports-color/-/supports-color-4.5.0.tgz\",\n+ \"integrity\": \"sha1-vnoN5ITexcXN34s9WRJQRJEvY1s=\",\n+ \"dev\": true,\n+ \"requires\": {\n+ \"has-flag\": \"2.0.0\"\n+ }\n+ }\n}\n},\n\"url-parse-lax\": {\n\"requires\": {\n\"assert-plus\": \"1.0.0\",\n\"core-util-is\": \"1.0.2\",\n- \"extsprintf\": \"1.3.0\"\n+ \"extsprintf\": \"1.4.0\"\n}\n},\n\"which\": {\n\"strip-ansi\": \"3.0.1\"\n},\n\"dependencies\": {\n- \"ansi-regex\": {\n- \"version\": \"2.1.1\",\n- \"resolved\": \"https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz\",\n- \"integrity\": \"sha1-w7M6te42DYbg5ijwRorn7yfWVN8=\",\n- \"dev\": true\n- },\n\"is-fullwidth-code-point\": {\n\"version\": \"1.0.0\",\n\"resolved\": \"https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz\",\n\"is-fullwidth-code-point\": \"1.0.0\",\n\"strip-ansi\": \"3.0.1\"\n}\n- },\n- \"strip-ansi\": {\n- \"version\": \"3.0.1\",\n- \"resolved\": \"https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz\",\n- \"integrity\": \"sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=\",\n- \"dev\": true,\n- \"requires\": {\n- \"ansi-regex\": \"2.1.1\"\n- }\n}\n}\n},\n\"yargs-parser\": \"2.4.1\"\n},\n\"dependencies\": {\n- \"ansi-regex\": {\n- \"version\": \"2.1.1\",\n- \"resolved\": \"https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz\",\n- \"integrity\": \"sha1-w7M6te42DYbg5ijwRorn7yfWVN8=\",\n- \"dev\": true\n- },\n\"is-fullwidth-code-point\": {\n\"version\": \"1.0.0\",\n\"resolved\": \"https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz\",\n\"is-fullwidth-code-point\": \"1.0.0\",\n\"strip-ansi\": \"3.0.1\"\n}\n- },\n- \"strip-ansi\": {\n- \"version\": \"3.0.1\",\n- \"resolved\": \"https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz\",\n- \"integrity\": \"sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=\",\n- \"dev\": true,\n- \"requires\": {\n- \"ansi-regex\": \"2.1.1\"\n- }\n}\n}\n},\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
server config for node.js
129,187
28.12.2017 00:45:15
18,000
5661f4638f7c34e7703874fc3ec709200ece5ecf
Commit jserver/node_modules/lib symlink
[ { "change_type": "MODIFY", "old_path": ".gitignore", "new_path": ".gitignore", "diff": "@@ -3,10 +3,10 @@ server/config.php\nserver/.htaccess\nserver/fonts\nlib/node_modules\n-web/node_modules\n+web/node_modules/*\n!web/node_modules/lib\nweb/dist/dev.build.js\njserver/dist\n-jserver/node_modules\n+jserver/node_modules/*\n!jserver/node_modules/lib\njserver/secrets\n" }, { "change_type": "ADD", "old_path": null, "new_path": "jserver/node_modules/lib", "diff": "+../../lib/\n\\ No newline at end of file\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Commit jserver/node_modules/lib symlink
129,187
28.12.2017 18:20:10
18,000
d3fdbef32156fceb73f553b016df187bbd4ae389
Stop crashing native on log out
[ { "change_type": "MODIFY", "old_path": "lib/shared/thread-utils.js", "new_path": "lib/shared/thread-utils.js", "diff": "@@ -23,17 +23,20 @@ function generateRandomColor() {\n}\nfunction threadHasPermission(\n- threadInfo: ThreadInfo,\n+ threadInfo: ?ThreadInfo,\npermission: ThreadPermission,\n) {\n- if (!threadInfo.currentUser.permissions[permission]) {\n+ if (\n+ !threadInfo ||\n+ !threadInfo.currentUser.permissions[permission]\n+ ) {\nreturn false;\n}\nreturn threadInfo.currentUser.permissions[permission].value;\n}\n-function viewerIsMember(threadInfo: ThreadInfo) {\n- return threadInfo.currentUser &&\n+function viewerIsMember(threadInfo: ?ThreadInfo) {\n+ return threadInfo &&\nthreadInfo.currentUser.role !== null &&\nthreadInfo.currentUser.role !== undefined;\n}\n" }, { "change_type": "MODIFY", "old_path": "native/chat/message-list.react.js", "new_path": "native/chat/message-list.react.js", "diff": "@@ -104,7 +104,7 @@ type Props = {\nmessageListData: $ReadOnlyArray<ChatMessageItem>,\nviewerID: ?string,\nstartReached: bool,\n- threadInfo: ThreadInfo,\n+ threadInfo: ?ThreadInfo,\n// Redux dispatch functions\ndispatchActionPromise: DispatchActionPromise,\n// async functions that hit server APIs\n@@ -137,7 +137,7 @@ class InnerMessageList extends React.PureComponent<Props, State> {\nmessageListData: PropTypes.arrayOf(chatMessageItemPropType).isRequired,\nviewerID: PropTypes.string,\nstartReached: PropTypes.bool.isRequired,\n- threadInfo: threadInfoPropType.isRequired,\n+ threadInfo: threadInfoPropType,\ndispatchActionPromise: PropTypes.func.isRequired,\nfetchMessagesBeforeCursor: PropTypes.func.isRequired,\nfetchMostRecentMessages: PropTypes.func.isRequired,\n@@ -181,21 +181,27 @@ class InnerMessageList extends React.PureComponent<Props, State> {\n};\n}\n+ static getThreadInfo(props: Props): ThreadInfo {\n+ return props.navigation.state.params.threadInfo;\n+ }\n+\ncomponentDidMount() {\nregisterChatScreen(this.props.navigation.state.key, this);\n- if (!viewerIsMember(this.props.threadInfo)) {\n- threadWatcher.watchID(this.props.threadInfo.id);\n+ if (!viewerIsMember(InnerMessageList.getThreadInfo(this.props))) {\n+ threadWatcher.watchID(InnerMessageList.getThreadInfo(this.props).id);\nthis.props.dispatchActionPromise(\nfetchMostRecentMessagesActionTypes,\n- this.props.fetchMostRecentMessages(this.props.threadInfo.id),\n+ this.props.fetchMostRecentMessages(\n+ InnerMessageList.getThreadInfo(this.props).id,\n+ ),\n);\n}\n}\ncomponentWillUnmount() {\nregisterChatScreen(this.props.navigation.state.key, null);\n- if (!viewerIsMember(this.props.threadInfo)) {\n- threadWatcher.removeID(this.props.threadInfo.id);\n+ if (!viewerIsMember(InnerMessageList.getThreadInfo(this.props))) {\n+ threadWatcher.removeID(InnerMessageList.getThreadInfo(this.props).id);\n}\n}\n@@ -231,6 +237,7 @@ class InnerMessageList extends React.PureComponent<Props, State> {\ncomponentWillReceiveProps(nextProps: Props) {\nif (\n+ nextProps.threadInfo &&\n!_isEqual(nextProps.threadInfo)\n(this.props.navigation.state.params.threadInfo)\n) {\n@@ -240,15 +247,15 @@ class InnerMessageList extends React.PureComponent<Props, State> {\n}\nif (\n- viewerIsMember(this.props.threadInfo) &&\n- !viewerIsMember(nextProps.threadInfo)\n+ viewerIsMember(InnerMessageList.getThreadInfo(this.props)) &&\n+ !viewerIsMember(InnerMessageList.getThreadInfo(nextProps))\n) {\n- threadWatcher.watchID(nextProps.threadInfo.id);\n+ threadWatcher.watchID(InnerMessageList.getThreadInfo(nextProps).id);\n} else if (\n- !viewerIsMember(this.props.threadInfo) &&\n- viewerIsMember(nextProps.threadInfo)\n+ !viewerIsMember(InnerMessageList.getThreadInfo(this.props)) &&\n+ viewerIsMember(InnerMessageList.getThreadInfo(nextProps))\n) {\n- threadWatcher.removeID(nextProps.threadInfo.id);\n+ threadWatcher.removeID(InnerMessageList.getThreadInfo(nextProps).id);\n}\nif (nextProps.listData === this.props.messageListData) {\n@@ -453,7 +460,7 @@ class InnerMessageList extends React.PureComponent<Props, State> {\n);\n}\n- const threadID = this.props.threadInfo.id;\n+ const threadID = InnerMessageList.getThreadInfo(this.props).id;\nconst inputBar = <InputBar threadID={threadID} />;\nlet behavior;\n@@ -518,7 +525,7 @@ class InnerMessageList extends React.PureComponent<Props, State> {\nconst oldestMessageServerID = this.oldestMessageServerID();\nif (oldestMessageServerID) {\nthis.loadingFromScroll = true;\n- const threadID = this.props.threadInfo.id;\n+ const threadID = InnerMessageList.getThreadInfo(this.props).id;\nthis.props.dispatchActionPromise(\nfetchMessagesBeforeCursorActionTypes,\nthis.props.fetchMessagesBeforeCursor(\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Stop crashing native on log out
129,187
28.12.2017 18:23:19
18,000
e3e623b477d9b56dffed1c247bdc4e73e180e4c4
Stop calling .then() on Promises as it's a no-op
[ { "change_type": "MODIFY", "old_path": "native/account/log-in-panel-container.react.js", "new_path": "native/account/log-in-panel-container.react.js", "diff": "@@ -246,7 +246,7 @@ class LogInPanelContainer extends React.PureComponent<Props, State> {\n},\n).start();\n- this.inCoupleSecondsNavigateToLogIn().then();\n+ this.inCoupleSecondsNavigateToLogIn();\n}\nasync inCoupleSecondsNavigateToLogIn() {\n" }, { "change_type": "MODIFY", "old_path": "native/account/log-in-panel.react.js", "new_path": "native/account/log-in-panel.react.js", "diff": "@@ -88,7 +88,7 @@ class LogInPanel extends React.PureComponent<Props, State> {\ncomponentDidMount() {\nthis.props.innerRef(this);\n- this.attemptToFetchCredentials().then();\n+ this.attemptToFetchCredentials();\n}\nasync attemptToFetchCredentials() {\n" }, { "change_type": "MODIFY", "old_path": "native/account/logged-out-modal.react.js", "new_path": "native/account/logged-out-modal.react.js", "diff": "@@ -134,7 +134,7 @@ class InnerLoggedOutModal extends React.PureComponent<Props, State> {\nthis.state.buttonOpacity = new Animated.Value(1);\nthis.nextMode = \"prompt\";\n}\n- this.determineOnePasswordSupport().then();\n+ this.determineOnePasswordSupport();\n}\nasync determineOnePasswordSupport() {\n@@ -162,7 +162,7 @@ class InnerLoggedOutModal extends React.PureComponent<Props, State> {\ncomponentWillReceiveProps(nextProps: Props) {\nif (!this.props.rehydrateConcluded && nextProps.rehydrateConcluded) {\n- this.onInitialAppLoad(nextProps).then();\n+ this.onInitialAppLoad(nextProps);\n}\nif (!this.props.isForeground && nextProps.isForeground) {\nthis.onForeground();\n" }, { "change_type": "MODIFY", "old_path": "native/account/verification-modal.react.js", "new_path": "native/account/verification-modal.react.js", "diff": "@@ -110,7 +110,7 @@ class InnerVerificationModal extends React.PureComponent<Props, State> {\nconstructor(props: Props) {\nsuper(props);\n- this.determineOnePasswordSupport().then();\n+ this.determineOnePasswordSupport();\n}\nasync determineOnePasswordSupport() {\n@@ -224,7 +224,7 @@ class InnerVerificationModal extends React.PureComponent<Props, State> {\nthis.animateKeyboardDownOrBackToSimpleText(null);\n}\n- this.inCoupleSecondsNavigateToApp().then();\n+ this.inCoupleSecondsNavigateToApp();\n}\nasync inCoupleSecondsNavigateToApp() {\n" }, { "change_type": "MODIFY", "old_path": "native/app.react.js", "new_path": "native/app.react.js", "diff": "@@ -151,7 +151,7 @@ class AppWithNavigationState extends React.PureComponent<Props> {\ncomponentDidMount() {\nNativeAppState.addEventListener('change', this.handleAppStateChange);\n- this.handleInitialURL().then();\n+ this.handleInitialURL();\nLinking.addEventListener('url', this.handleURLChange);\nthis.activePingSubscription = setInterval(this.ping, pingFrequency);\nAppWithNavigationState.updateFocusedThreads(\n@@ -267,7 +267,7 @@ class AppWithNavigationState extends React.PureComponent<Props> {\n}\n}\nif (permissionNeeded) {\n- requestIOSPushPermissions().then();\n+ requestIOSPushPermissions();\n}\n}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Stop calling .then() on Promises as it's a no-op
129,187
05.01.2018 12:34:35
18,000
e571bd4635d53857c4b71a8c167e91b5888843b5
Require visibility for unread status and notifs (And a bugfix of an earlier commit)
[ { "change_type": "MODIFY", "old_path": "jserver/src/push/ios_notifs.js", "new_path": "jserver/src/push/ios_notifs.js", "diff": "@@ -28,7 +28,7 @@ async function sendIOSPushNotifs(req: $Request, res: $Response) {\nres.json({ success: true });\nconst pushInfo: IOSPushInfo = req.body;\n- if (Object.keys(push).length === 0) {\n+ if (Object.keys(pushInfo).length === 0) {\nreturn [];\n}\n" }, { "change_type": "MODIFY", "old_path": "server/message_lib.php", "new_path": "server/message_lib.php", "diff": "@@ -479,12 +479,19 @@ SQL;\n$conn->next_result();\n$time = earliest_time_considered_current();\n+ $vis_permission_extract_string = \"$.\" . PERMISSION_VISIBLE . \".value\";\n+ $visibility_open = VISIBILITY_OPEN;\n$unread_query = <<<SQL\nUPDATE memberships m\n+LEFT JOIN threads t ON t.id = m.thread\nLEFT JOIN focused f ON f.user = m.user AND f.thread = m.thread\nAND f.time > {$time}\nSET m.unread = 1\n-WHERE m.role != 0 AND f.user IS NULL AND {$thread_creator_fragment}\n+WHERE m.role != 0 AND f.user IS NULL AND {$thread_creator_fragment} AND\n+ (\n+ JSON_EXTRACT(m.permissions, '{$vis_permission_extract_string}') IS TRUE\n+ OR t.visibility_rules = {$visibility_open}\n+ )\nSQL;\n$conn->query($unread_query);\n$conn->next_result();\n@@ -492,9 +499,14 @@ SQL;\n$notif_query = <<<SQL\nSELECT m.user, m.thread, c2.ios_device_token\nFROM memberships m\n+LEFT JOIN threads t ON t.id = m.thread\nLEFT JOIN cookies c1 ON c1.user = m.user AND c1.last_ping > {$time}\nLEFT JOIN cookies c2 ON c2.user = m.user AND c2.ios_device_token IS NOT NULL\n-WHERE c1.user IS NULL AND c2.user IS NOT NULL AND {$thread_creator_fragment}\n+WHERE c1.user IS NULL AND c2.user IS NOT NULL AND {$thread_creator_fragment} AND\n+ (\n+ JSON_EXTRACT(m.permissions, '{$vis_permission_extract_string}') IS TRUE\n+ OR t.visibility_rules = {$visibility_open}\n+ )\nSQL;\n$notif_query_result = $conn->query($notif_query);\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Require visibility for unread status and notifs (And a bugfix of an earlier commit)
129,187
05.01.2018 23:29:28
18,000
cf8401ea5f51bb0c4d38932a7528e4fe66329eda
Try sending remote notifs even when app foregrounded
[ { "change_type": "MODIFY", "old_path": "server/message_lib.php", "new_path": "server/message_lib.php", "diff": "@@ -497,12 +497,13 @@ SQL;\n$conn->next_result();\n$notif_query = <<<SQL\n-SELECT m.user, m.thread, c2.ios_device_token\n+SELECT m.user, m.thread, c.ios_device_token\nFROM memberships m\nLEFT JOIN threads t ON t.id = m.thread\n-LEFT JOIN cookies c1 ON c1.user = m.user AND c1.last_ping > {$time}\n-LEFT JOIN cookies c2 ON c2.user = m.user AND c2.ios_device_token IS NOT NULL\n-WHERE c1.user IS NULL AND c2.user IS NOT NULL AND {$thread_creator_fragment} AND\n+LEFT JOIN cookies c ON c.user = m.user AND c.ios_device_token IS NOT NULL\n+LEFT JOIN focused f ON f.user = m.user AND f.thread = m.thread\n+ AND f.time > {$time}\n+WHERE c.user IS NOT NULL AND f.user IS NULL AND {$thread_creator_fragment} AND\n(\nJSON_EXTRACT(m.permissions, '{$vis_permission_extract_string}') IS TRUE\nOR t.visibility_rules = {$visibility_open}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Try sending remote notifs even when app foregrounded
129,187
06.01.2018 12:25:54
18,000
29d9a8ee09da66cbb8c819de89e9a33d40225690
Make sure all notif text explicitly mentions threads
[ { "change_type": "MODIFY", "old_path": "lib/shared/message-utils.js", "new_path": "lib/shared/message-utils.js", "diff": "@@ -59,6 +59,10 @@ function robotextForUsers(users: RelativeUserInfo[]): string {\n}\n}\n+function encodedThreadEntity(threadID: string, text: string): string {\n+ return `<${text}|t${threadID}>`;\n+}\n+\nfunction robotextForMessageInfo(\nmessageInfo: RobotextMessageInfo,\nthreadInfo: ThreadInfo,\n@@ -69,11 +73,12 @@ function robotextForMessageInfo(\n);\nconst creator = robotextForUser(messageInfo.creator);\nif (messageInfo.type === messageType.CREATE_THREAD) {\n- let text = \"created this thread \";\n+ let text =\n+ `created ${encodedThreadEntity(messageInfo.threadID, 'this thread')} `;\nconst parentThread = messageInfo.initialThreadState.parentThreadInfo;\nif (parentThread) {\ntext += \"as a child of \" +\n- `\"<${encodeURI(parentThread.name)}|t${parentThread.id}>\" `;\n+ `<${encodeURI(parentThread.name)}|t${parentThread.id}> `;\n}\ntext += `with the name \"${encodeURI(messageInfo.initialThreadState.name)}\"`;\nconst users = messageInfo.initialThreadState.otherMembers;\n@@ -98,8 +103,9 @@ function robotextForMessageInfo(\n} else {\nvalue = messageInfo.value;\n}\n- return `${creator} updated the thread's ${messageInfo.field} to ` +\n- `\"${value}\"`;\n+ return `${creator} updated ` +\n+ `${encodedThreadEntity(messageInfo.threadID, 'the thread')}'s ` +\n+ `${messageInfo.field} to \"${value}\"`;\n} else if (messageInfo.type === messageType.REMOVE_MEMBERS) {\nconst users = messageInfo.removedMembers;\ninvariant(users.length !== 0, \"removed who??\");\n@@ -115,16 +121,17 @@ function robotextForMessageInfo(\nconst noun = users.length === 1 ? \"an admin\" : \"admins\";\nreturn `${creator} ${verb} ${usersString} as ${noun}`;\n} else if (messageInfo.type === messageType.LEAVE_THREAD) {\n- return `${creator} left this thread`;\n+ return `${creator} left ` +\n+ encodedThreadEntity(messageInfo.threadID, 'this thread');\n} else if (messageInfo.type === messageType.JOIN_THREAD) {\n- return `${creator} joined this thread`;\n+ return `${creator} joined ` +\n+ encodedThreadEntity(messageInfo.threadID, 'this thread');\n} else if (messageInfo.type === messageType.CREATE_ENTRY) {\nconst date = prettyDate(messageInfo.date);\n- return `${creator} created an entry in the calendar for ${date}: ` +\n- `\"${messageInfo.text}\"`;\n+ return `${creator} created an event for ${date}: \"${messageInfo.text}\"`;\n} else if (messageInfo.type === messageType.EDIT_ENTRY) {\nconst date = prettyDate(messageInfo.date);\n- return `${creator} updated the text of an entry in the calendar for ` +\n+ return `${creator} updated the text of an event for ` +\n`${date}: \"${messageInfo.text}\"`;\n}\ninvariant(false, `${messageInfo.type} is not a messageType!`);\n" }, { "change_type": "MODIFY", "old_path": "lib/shared/notif-utils.js", "new_path": "lib/shared/notif-utils.js", "diff": "// @flow\n-import type { MessageInfo } from '../types/message-types';\n+import type { MessageInfo, RobotextMessageInfo } from '../types/message-types';\nimport type { ThreadInfo } from '../types/thread-types';\n+import type { RelativeUserInfo } from '../types/user-types';\n+\n+import invariant from 'invariant';\nimport { messageType } from '../types/message-types';\nimport {\n@@ -10,6 +13,7 @@ import {\n} from './message-utils';\nimport { threadIsTwoPersonChat, threadIsNamed } from './thread-utils';\nimport { stringForUser } from './user-utils';\n+import { prettyDate } from '../utils/date-utils';\nfunction notifTextForMessageInfo(\nmessageInfo: MessageInfo,\n@@ -26,12 +30,7 @@ function fullNotifTextForMessageInfo(\nmessageInfo: MessageInfo,\nthreadInfo: ThreadInfo,\n): string {\n- if (messageInfo.type !== messageType.TEXT) {\n- return robotextToRawString(robotextForMessageInfo(\n- messageInfo,\n- threadInfo,\n- ));\n- }\n+ if (messageInfo.type === messageType.TEXT) {\nconst userString = stringForUser(messageInfo.creator);\nif (threadIsNamed(threadInfo)) {\nreturn `${userString} to ${threadInfo.name}: ${messageInfo.text}`;\n@@ -40,6 +39,47 @@ function fullNotifTextForMessageInfo(\n} else {\nreturn `${userString} to your thread: ${messageInfo.text}`;\n}\n+ } else if (messageInfo.type === messageType.CREATE_THREAD) {\n+ let text = `${stringForUser(messageInfo.creator)} created a new thread `;\n+ const parentThread = messageInfo.initialThreadState.parentThreadInfo;\n+ if (parentThread) {\n+ text += `in ${parentThread.name} `;\n+ }\n+ text += `called \"${messageInfo.initialThreadState.name}\"`;\n+ return text;\n+ } else if (messageInfo.type === messageType.ADD_MEMBERS) {\n+ const robotext = strippedRobotextForMessageInfo(messageInfo, threadInfo);\n+ return `${robotext} to ${threadInfo.name}`;\n+ } else if (messageInfo.type === messageType.CREATE_SUB_THREAD) {\n+ invariant(false, \"no notifs should correspond to CREATE_SUB_THREAD\");\n+ } else if (messageInfo.type === messageType.REMOVE_MEMBERS) {\n+ const robotext = strippedRobotextForMessageInfo(messageInfo, threadInfo);\n+ return `${robotext} from ${threadInfo.name}`;\n+ } else if (messageInfo.type === messageType.CHANGE_ROLE) {\n+ const robotext = strippedRobotextForMessageInfo(messageInfo, threadInfo);\n+ return `${robotext} in ${threadInfo.name}`;\n+ } else if (messageInfo.type === messageType.CREATE_ENTRY) {\n+ return `${stringForUser(messageInfo.creator)} created an event for ` +\n+ `${prettyDate(messageInfo.date)}: \"${messageInfo.text}\"`;\n+ } else if (messageInfo.type === messageType.EDIT_ENTRY) {\n+ return `${stringForUser(messageInfo.creator)} updated the text of an ` +\n+ `event for ${prettyDate(messageInfo.date)}: \"${messageInfo.text}\"`;\n+ } else {\n+ return strippedRobotextForMessageInfo(messageInfo, threadInfo);\n+ }\n+}\n+\n+function strippedRobotextForMessageInfo(\n+ messageInfo: RobotextMessageInfo,\n+ threadInfo: ThreadInfo,\n+): string {\n+ const robotext = robotextForMessageInfo(messageInfo, threadInfo);\n+ const threadEntityRegex = new RegExp(`<[^<>\\\\|]+\\\\|t${threadInfo.id}>`);\n+ const threadMadeExplicit = robotext.replace(\n+ threadEntityRegex,\n+ threadInfo.name,\n+ );\n+ return robotextToRawString(threadMadeExplicit);\n}\nexport {\n" }, { "change_type": "MODIFY", "old_path": "native/chat/robotext-message.react.js", "new_path": "native/chat/robotext-message.react.js", "diff": "@@ -94,7 +94,7 @@ class RobotextMessage extends React.PureComponent<Props> {\nconst entityType = entityParts[2].charAt(0);\nconst id = entityParts[2].substr(1);\n- if (entityType === \"t\") {\n+ if (entityType === \"t\" && id !== this.props.item.messageInfo.threadID) {\ntextParts.push(<ThreadEntity key={id} id={id} name={rawText} />);\ncontinue;\n} else if (entityType === \"c\") {\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Make sure all notif text explicitly mentions threads
129,187
06.01.2018 12:39:53
18,000
cdf6088b45c6b1b2b8a5a9dd9d4e940a1bc1482b
Don't send notifs about CREATE_SUB_THREAD Since these would be duplicate with `CREATE_THREAD`. Also, we're now only sending notifs to actual members where `subscribed` in the DB is 1 (soon to be changed).
[ { "change_type": "MODIFY", "old_path": "server/message_lib.php", "new_path": "server/message_lib.php", "diff": "@@ -372,6 +372,10 @@ SQL;\nreturn $users;\n}\n+function message_type_gets_notif($message_type) {\n+ return $message_type !== MESSAGE_TYPE_CREATE_SUB_THREAD;\n+}\n+\n// returns message infos with IDs\nfunction create_message_infos($new_message_infos) {\nglobal $conn;\n@@ -381,6 +385,7 @@ function create_message_infos($new_message_infos) {\n}\n$thread_creator_pairs = array();\n+ $notif_thread_creator_pairs = array();\n$threads_to_message_indices = array();\n$content_by_index = array();\nforeach ($new_message_infos as $index => $new_message_info) {\n@@ -388,11 +393,14 @@ function create_message_infos($new_message_infos) {\n$creator_id = $new_message_info['creatorID'];\n$thread_creator_pairs[$thread_id . $creator_id] =\n\"(m.thread = {$thread_id} AND m.user != {$creator_id})\";\n-\n+ if (message_type_gets_notif($new_message_info['type'])) {\n+ $notif_thread_creator_pairs[$thread_id . $creator_id] =\n+ \"(m.thread = {$thread_id} AND m.user != {$creator_id})\";\nif (!isset($threads_to_message_indices[$thread_id])) {\n$threads_to_message_indices[$thread_id] = array();\n}\n$threads_to_message_indices[$thread_id][] = $index;\n+ }\nif ($new_message_info['type'] === MESSAGE_TYPE_CREATE_THREAD) {\n$content_by_index[$index] = $conn->real_escape_string(\n@@ -445,6 +453,8 @@ function create_message_infos($new_message_infos) {\n}\n}\n$thread_creator_fragment = \"(\" . implode(\" OR \", $thread_creator_pairs) . \")\";\n+ $notif_thread_creator_fragment =\n+ \"(\" . implode(\" OR \", $notif_thread_creator_pairs) . \")\";\n$num_new_messages = count($new_message_infos);\n$id_inserts = array_fill(0, $num_new_messages, \"('messages')\");\n@@ -503,8 +513,9 @@ LEFT JOIN threads t ON t.id = m.thread\nLEFT JOIN cookies c ON c.user = m.user AND c.ios_device_token IS NOT NULL\nLEFT JOIN focused f ON f.user = m.user AND f.thread = m.thread\nAND f.time > {$time}\n-WHERE c.user IS NOT NULL AND f.user IS NULL AND {$thread_creator_fragment} AND\n- (\n+WHERE m.role != 0 AND c.user IS NOT NULL AND f.user IS NULL AND m.subscribed = 1\n+ AND {$notif_thread_creator_fragment}\n+ AND (\nJSON_EXTRACT(m.permissions, '{$vis_permission_extract_string}') IS TRUE\nOR t.visibility_rules = {$visibility_open}\n)\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Don't send notifs about CREATE_SUB_THREAD Since these would be duplicate with `CREATE_THREAD`. Also, we're now only sending notifs to actual members where `subscribed` in the DB is 1 (soon to be changed).
129,187
06.01.2018 19:47:52
18,000
7741e13d2b05adc0ea9d32cd7ad76d6dd4a09bf8
Implement in-app notifications and make external notif presses navigate you to the correct thread
[ { "change_type": "MODIFY", "old_path": "lib/shared/notif-utils.js", "new_path": "lib/shared/notif-utils.js", "diff": "@@ -15,6 +15,13 @@ import { threadIsTwoPersonChat, threadIsNamed } from './thread-utils';\nimport { stringForUser } from './user-utils';\nimport { prettyDate } from '../utils/date-utils';\n+const notificationPressActionType = \"NOTIFICATION_PRESS\";\n+\n+export type NotificationPressPayload = {\n+ threadInfo: ThreadInfo,\n+ clearChatRoutes: bool,\n+};\n+\nfunction notifTextForMessageInfo(\nmessageInfo: MessageInfo,\nthreadInfo: ThreadInfo,\n@@ -83,5 +90,6 @@ function strippedRobotextForMessageInfo(\n}\nexport {\n+ notificationPressActionType,\nnotifTextForMessageInfo,\n};\n" }, { "change_type": "MODIFY", "old_path": "native/.flowconfig", "new_path": "native/.flowconfig", "diff": "@@ -38,6 +38,7 @@ module.file_ext=.js\nmodule.file_ext=.jsx\nmodule.file_ext=.json\nmodule.file_ext=.native.js\n+module.file_ext=.ios.js\nsuppress_type=$FlowIssue\nsuppress_type=$FlowFixMe\n" }, { "change_type": "MODIFY", "old_path": "native/app.react.js", "new_path": "native/app.react.js", "diff": "@@ -18,7 +18,9 @@ import type {\nActivityUpdate,\nUpdateActivityResult,\n} from 'lib/actions/ping-actions';\n-import type { PushPermissions } from './push';\n+import type { PushPermissions } from './push/ios';\n+import type { ThreadInfo } from 'lib/types/thread-types';\n+import { threadInfoPropType } from 'lib/types/thread-types';\nimport React from 'react';\nimport { Provider, connect } from 'react-redux';\n@@ -31,11 +33,13 @@ import {\nView,\nStyleSheet,\nAlert,\n+ DeviceInfo,\n} from 'react-native';\nimport { addNavigationHelpers } from 'react-navigation';\nimport invariant from 'invariant';\nimport PropTypes from 'prop-types';\nimport NotificationsIOS from 'react-native-notifications';\n+import InAppNotification from 'react-native-in-app-notification';\nimport { registerConfig } from 'lib/utils/config';\nimport {\n@@ -54,6 +58,7 @@ import {\nsetIOSDeviceToken,\n} from 'lib/actions/device-actions';\nimport { unreadCount } from 'lib/selectors/thread-selectors';\n+import { notificationPressActionType } from 'lib/shared/notif-utils';\nimport {\nhandleURLActionType,\n@@ -68,7 +73,8 @@ import {\nactiveThreadSelector,\ncreateIsForegroundSelector,\n} from './selectors/nav-selectors';\n-import { requestIOSPushPermissions } from './push';\n+import { requestIOSPushPermissions } from './push/ios';\n+import NotificationBody from './push/notification-body.react';\nlet urlPrefix;\nif (!__DEV__) {\n@@ -117,6 +123,7 @@ type Props = {\nactiveThreadLatestMessage: ?string,\ndeviceToken: ?string,\nunreadCount: number,\n+ threadInfos: {[id: string]: ThreadInfo},\n// Redux dispatch functions\ndispatch: NativeDispatch,\ndispatchActionPayload: DispatchActionPayload,\n@@ -143,6 +150,7 @@ class AppWithNavigationState extends React.PureComponent<Props> {\nactiveThreadLatestMessage: PropTypes.string,\ndeviceToken: PropTypes.string,\nunreadCount: PropTypes.number.isRequired,\n+ threadInfos: PropTypes.objectOf(threadInfoPropType).isRequired,\ndispatch: PropTypes.func.isRequired,\ndispatchActionPayload: PropTypes.func.isRequired,\ndispatchActionPromise: PropTypes.func.isRequired,\n@@ -152,6 +160,7 @@ class AppWithNavigationState extends React.PureComponent<Props> {\n};\ncurrentState: ?string = NativeAppState.currentState;\nactivePingSubscription: ?number = null;\n+ inAppNotification: ?InAppNotification = null;\ncomponentDidMount() {\nNativeAppState.addEventListener('change', this.handleAppStateChange);\n@@ -176,6 +185,10 @@ class AppWithNavigationState extends React.PureComponent<Props> {\n\"notificationReceivedForeground\",\nthis.iosForegroundNotificationReceived,\n);\n+ NotificationsIOS.addEventListener(\n+ \"notificationOpened\",\n+ this.iosNotificationOpened,\n+ );\nAppWithNavigationState.updateBadgeCount(this.props.unreadCount);\n}\n@@ -204,14 +217,18 @@ class AppWithNavigationState extends React.PureComponent<Props> {\n\"remoteNotificationsRegistered\",\nthis.registerIOSPushPermissions,\n);\n- NotificationsIOS.remoteEventListener(\n+ NotificationsIOS.removeEventListener(\n\"remoteNotificationsRegistrationFailed\",\nthis.failedToRegisterIOSPushPermissions,\n);\n- NotificationsIOS.remoteEventListener(\n+ NotificationsIOS.removeEventListener(\n\"notificationReceivedForeground\",\nthis.iosForegroundNotificationReceived,\n);\n+ NotificationsIOS.removeEventListener(\n+ \"notificationOpened\",\n+ this.iosNotificationOpened,\n+ );\n}\nhandleURLChange = (event: { url: string }) => {\n@@ -316,6 +333,30 @@ class AppWithNavigationState extends React.PureComponent<Props> {\niosForegroundNotificationReceived = (notification) => {\nconst threadID = notification.getThread();\n+ invariant(this.inAppNotification, \"should be set\");\n+ this.inAppNotification.show({\n+ message: notification.getMessage(),\n+ onPress: () => {\n+ this.props.dispatchActionPayload(\n+ notificationPressActionType,\n+ {\n+ threadInfo: this.props.threadInfos[threadID],\n+ clearChatRoutes: false,\n+ },\n+ );\n+ },\n+ });\n+ }\n+\n+ iosNotificationOpened = (notification) => {\n+ const threadID = notification.getThread();\n+ this.props.dispatchActionPayload(\n+ notificationPressActionType,\n+ {\n+ threadInfo: this.props.threadInfos[threadID],\n+ clearChatRoutes: true,\n+ },\n+ );\n}\nping = () => {\n@@ -410,14 +451,24 @@ class AppWithNavigationState extends React.PureComponent<Props> {\ndispatch: this.props.dispatch,\nstate: this.props.navigationState,\n});\n+ const inAppNotificationHeight = DeviceInfo.isIPhoneX_deprecated ? 104 : 80;\nreturn (\n<View style={styles.app}>\n<RootNavigator navigation={navigation} />\n<ConnectedStatusBar />\n+ <InAppNotification\n+ height={inAppNotificationHeight}\n+ notificationBodyComponent={NotificationBody}\n+ ref={this.inAppNotificationRef}\n+ />\n</View>\n);\n}\n+ inAppNotificationRef = (inAppNotification: InAppNotification) => {\n+ this.inAppNotification = inAppNotification;\n+ }\n+\n}\nconst styles = StyleSheet.create({\n@@ -443,6 +494,7 @@ const ConnectedAppWithNavigationState = connect(\n: null,\ndeviceToken: state.deviceToken,\nunreadCount: unreadCount(state),\n+ threadInfos: state.threadInfos,\n};\n},\nincludeDispatchActionProps,\n" }, { "change_type": "MODIFY", "old_path": "native/connected-status-bar.react.js", "new_path": "native/connected-status-bar.react.js", "diff": "@@ -10,7 +10,14 @@ import PropTypes from 'prop-types';\nimport { globalLoadingStatusSelector } from 'lib/selectors/loading-selectors';\n-class ConnectedStatusBar extends React.PureComponent<*> {\n+type InjectedProps = {\n+ globalLoadingStatus: LoadingStatus,\n+};\n+type OwnProps = {\n+ barStyle?: \"light-content\" | \"dark-content\",\n+ animated?: bool,\n+};\n+class ConnectedStatusBar extends React.PureComponent<InjectedProps & OwnProps> {\nstatic propTypes = {\nglobalLoadingStatus: PropTypes.string.isRequired,\n@@ -28,6 +35,6 @@ class ConnectedStatusBar extends React.PureComponent<*> {\n}\n-export default connect((state: AppState): * => ({\n+export default connect((state: AppState): InjectedProps => ({\nglobalLoadingStatus: globalLoadingStatusSelector(state),\n}))(ConnectedStatusBar);\n" }, { "change_type": "MODIFY", "old_path": "native/more/more.react.js", "new_path": "native/more/more.react.js", "diff": "@@ -23,7 +23,6 @@ import {\nimport { logOutActionTypes, logOut } from 'lib/actions/user-actions';\nimport { pingActionTypes, ping } from 'lib/actions/ping-actions';\n-import ConnectedStatusBar from '../connected-status-bar.react';\nimport {\ngetNativeSharedWebCredentials,\ndeleteNativeCredentialsFor,\n@@ -82,7 +81,6 @@ class More extends React.PureComponent<Props> {\nonPress={this.onPressPing}\ntitle=\"Ping\"\n/>\n- <ConnectedStatusBar />\n</View>\n);\n}\n" }, { "change_type": "MODIFY", "old_path": "native/navigation-setup.js", "new_path": "native/navigation-setup.js", "diff": "@@ -13,10 +13,8 @@ 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 {\n- LeaveThreadResult,\n- NewThreadResult,\n-} from 'lib/actions/thread-actions';\n+import type { LeaveThreadResult } from 'lib/actions/thread-actions';\n+import type { NotificationPressPayload } from 'lib/shared/notif-utils';\nimport {\nTabNavigator,\n@@ -48,6 +46,7 @@ import {\nsubscribeActionTypes,\nnewThreadActionTypes,\n} from 'lib/actions/thread-actions';\n+import { notificationPressActionType } from 'lib/shared/notif-utils';\nimport {\nCalendar,\n@@ -83,6 +82,12 @@ export type NavInfo = {|\nconst handleURLActionType = \"HANDLE_URL\";\nconst navigateToAppActionType = \"NAVIGATE_TO_APP\";\n+const uniqueBaseId = `id-${Date.now()}`;\n+let uuidCount = 0;\n+function _getUuid() {\n+ return `${uniqueBaseId}-${uuidCount++}`;\n+}\n+\nexport type Action = BaseAction |\nNavigationAction |\n{| type: typeof handleURLActionType, payload: string |} |\n@@ -309,7 +314,18 @@ function reduceNavInfo(state: NavInfo, action: *): NavInfo {\nendDate: state.endDate,\nhome: state.home,\nthreadID: state.threadID,\n- navigationState: replaceChatStackWithNewThread(\n+ navigationState: replaceChatStackWithThread(\n+ state.navigationState,\n+ action.payload.newThreadInfo,\n+ ),\n+ };\n+ } else if (action.type === notificationPressActionType) {\n+ return {\n+ startDate: state.startDate,\n+ endDate: state.endDate,\n+ home: state.home,\n+ threadID: state.threadID,\n+ navigationState: handleNotificationPress(\nstate.navigationState,\naction.payload,\n),\n@@ -564,9 +580,9 @@ function filterChatScreensForThreadInfos(\nreturn { ...state, routes: newRootSubRoutes };\n}\n-function replaceChatStackWithNewThread(\n+function replaceChatStackWithThread(\nstate: NavigationState,\n- payload: NewThreadResult,\n+ threadInfo: ThreadInfo,\n): NavigationState {\nconst appRoute = assertNavigationRouteNotLeafNode(state.routes[0]);\nconst chatRoute = assertNavigationRouteNotLeafNode(appRoute.routes[1]);\n@@ -580,7 +596,7 @@ function replaceChatStackWithNewThread(\nnewChatRoute.routes.push({\nkey: 'NewThreadMessageList',\nrouteName: MessageListRouteName,\n- params: { threadInfo: payload.newThreadInfo },\n+ params: { threadInfo },\n});\nnewChatRoute.index = 1;\n@@ -591,6 +607,38 @@ function replaceChatStackWithNewThread(\nreturn { ...state, routes: newRootSubRoutes };\n}\n+function handleNotificationPress(\n+ state: NavigationState,\n+ payload: NotificationPressPayload,\n+): NavigationState {\n+ if (payload.clearChatRoutes) {\n+ return replaceChatStackWithThread(\n+ state,\n+ payload.threadInfo,\n+ );\n+ } else {\n+ const appRoute = assertNavigationRouteNotLeafNode(state.routes[0]);\n+ const chatRoute = assertNavigationRouteNotLeafNode(appRoute.routes[1]);\n+ const newChatRoute = {\n+ ...chatRoute,\n+ routes: [\n+ ...chatRoute.routes,\n+ {\n+ key: `Notif-${_getUuid()}`,\n+ routeName: MessageListRouteName,\n+ params: { threadInfo: payload.threadInfo },\n+ }\n+ ],\n+ index: chatRoute.routes.length,\n+ };\n+ const newAppSubRoutes = [ ...appRoute.routes ];\n+ newAppSubRoutes[1] = newChatRoute;\n+ const newRootSubRoutes = [ ...state.routes ];\n+ newRootSubRoutes[0] = { ...appRoute, routes: newAppSubRoutes };\n+ return { ...state, routes: newRootSubRoutes };\n+ }\n+}\n+\nexport {\nhandleURLActionType,\nnavigateToAppActionType,\n" }, { "change_type": "MODIFY", "old_path": "native/package-lock.json", "new_path": "native/package-lock.json", "diff": "\"react-native-drawer-layout\": \"1.3.2\"\n}\n},\n+ \"react-native-in-app-notification\": {\n+ \"version\": \"2.1.0\",\n+ \"resolved\": \"https://registry.npmjs.org/react-native-in-app-notification/-/react-native-in-app-notification-2.1.0.tgz\",\n+ \"integrity\": \"sha512-+1yUSvz/xiikUMzNV0r2maFAZ4zpi2etg1ZPvoY7pKBtAVlUyawAPjuVNC/XgbIsdK6GdKJhHKd3otYnJ23tLQ==\",\n+ \"requires\": {\n+ \"react-native-swipe-gestures\": \"1.0.2\"\n+ }\n+ },\n\"react-native-keychain\": {\n\"version\": \"1.2.1\",\n\"resolved\": \"https://registry.npmjs.org/react-native-keychain/-/react-native-keychain-1.2.1.tgz\",\n\"prop-types\": \"15.5.10\"\n}\n},\n+ \"react-native-swipe-gestures\": {\n+ \"version\": \"1.0.2\",\n+ \"resolved\": \"https://registry.npmjs.org/react-native-swipe-gestures/-/react-native-swipe-gestures-1.0.2.tgz\",\n+ \"integrity\": \"sha1-kU4acqlLxVsyK0YioBEDq4eSlt0=\"\n+ },\n\"react-native-tab-view\": {\n\"version\": \"0.0.70\",\n\"resolved\": \"https://registry.npmjs.org/react-native-tab-view/-/react-native-tab-view-0.0.70.tgz\",\n" }, { "change_type": "MODIFY", "old_path": "native/package.json", "new_path": "native/package.json", "diff": "\"lib\": \"file:../lib\",\n\"react\": \"16.0.0\",\n\"react-native\": \"^0.51.0\",\n+ \"react-native-in-app-notification\": \"^2.1.0\",\n\"react-native-keychain\": \"^1.2.1\",\n\"react-native-modal\": \"^4.0.0\",\n\"react-native-notifications\": \"^1.1.17\",\n" }, { "change_type": "RENAME", "old_path": "native/push.js", "new_path": "native/push/ios.js", "diff": "@@ -11,7 +11,7 @@ async function requestIOSPushPermissions() {\nreturn;\n}\ncurrentlyActive = true;\n- await NotificationsIOS.requestPermissions();\n+ await NotificationsIOS.requestPermissions([]);\ncurrentlyActive = false;\n}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "native/push/notification-body.react.js", "diff": "+// @flow\n+\n+import type { ImageSource } from 'react-native/Libraries/Image/ImageSource';\n+\n+import React from 'react';\n+import { View, StyleSheet, DeviceInfo } from 'react-native';\n+import DefaultNotificationBody\n+ from 'react-native-in-app-notification/DefaultNotificationBody';\n+\n+type Props = {\n+ title: string,\n+ message: string,\n+ onPress: () => void,\n+ isOpen: bool,\n+ iconApp: ImageSource,\n+ icon: ImageSource,\n+ vibrate: bool,\n+ onClose: () => void,\n+};\n+function NotificationBody(props: Props) {\n+ return (\n+ <View style={styles.notificationBodyContainer}>\n+ <DefaultNotificationBody\n+ title={props.title}\n+ message={props.message}\n+ onPress={props.onPress}\n+ isOpen={props.isOpen}\n+ iconApp={props.iconApp}\n+ icon={props.icon}\n+ vibrate={props.vibrate}\n+ onClose={props.onClose}\n+ />\n+ </View>\n+ );\n+}\n+\n+const styles = StyleSheet.create({\n+ notificationBodyContainer: {\n+ flex: 1,\n+ paddingTop: DeviceInfo.isIPhoneX_deprecated ? 24 : 0,\n+ backgroundColor: '#050505',\n+ },\n+});\n+\n+export default NotificationBody;\n" }, { "change_type": "MODIFY", "old_path": "native/redux-setup.js", "new_path": "native/redux-setup.js", "diff": "@@ -20,6 +20,7 @@ import { NavigationActions } from 'react-navigation';\nimport baseReducer from 'lib/reducers/master-reducer';\nimport { newSessionID } from 'lib/selectors/session-selectors';\n+import { notificationPressActionType } from 'lib/shared/notif-utils';\nimport { MessageListRouteName } from './chat/message-list.react';\nimport { activeThreadSelector } from './selectors/nav-selectors';\n@@ -129,6 +130,7 @@ function reducer(state: AppState, action: *) {\nif (\naction.type === handleURLActionType ||\naction.type === navigateToAppActionType ||\n+ action.type === notificationPressActionType ||\naction.type === NavigationActions.INIT ||\naction.type === NavigationActions.NAVIGATE ||\naction.type === NavigationActions.BACK ||\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Implement in-app notifications and make external notif presses navigate you to the correct thread
129,187
06.01.2018 23:03:40
18,000
00f7f79049b7defc1008186ad849b83bf3b08a03
Locally clear notifs once the corresponding thread is viewed
[ { "change_type": "MODIFY", "old_path": "native/app.react.js", "new_path": "native/app.react.js", "diff": "@@ -198,6 +198,31 @@ class AppWithNavigationState extends React.PureComponent<Props> {\n}\n}\n+ static clearIOSNotifsOfThread(threadID: string) {\n+ NotificationsIOS.getDeliveredNotifications(\n+ (notifications) =>\n+ AppWithNavigationState.clearDeliveredIOSNotificationsForThread(\n+ threadID,\n+ notifications,\n+ ),\n+ );\n+ }\n+\n+ static clearDeliveredIOSNotificationsForThread(\n+ threadID: string,\n+ notifications: Object[],\n+ ) {\n+ const identifiersToClear = [];\n+ for (let notification of notifications) {\n+ if (notification[\"thread-id\"] === threadID) {\n+ identifiersToClear.push(notification.identifier);\n+ }\n+ }\n+ if (identifiersToClear) {\n+ NotificationsIOS.removeDeliveredNotifications(identifiersToClear);\n+ }\n+ }\n+\nasync handleInitialURL() {\nconst url = await Linking.getInitialURL();\nif (url) {\n@@ -260,6 +285,9 @@ class AppWithNavigationState extends React.PureComponent<Props> {\n);\nthis.ensurePushNotifsEnabled();\nAppWithNavigationState.updateBadgeCount(this.props.unreadCount);\n+ if (this.props.activeThread) {\n+ AppWithNavigationState.clearIOSNotifsOfThread(this.props.activeThread);\n+ }\n} else if (\nlastState === \"active\" &&\nthis.currentState &&\n@@ -285,6 +313,10 @@ class AppWithNavigationState extends React.PureComponent<Props> {\nthis.props.activeThreadLatestMessage,\n);\n}\n+ const nextActiveThread = nextProps.activeThread;\n+ if (nextActiveThread && nextActiveThread !== this.props.activeThread) {\n+ AppWithNavigationState.clearIOSNotifsOfThread(nextActiveThread);\n+ }\nif (justLoggedIn) {\nthis.ensurePushNotifsEnabled();\n}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Locally clear notifs once the corresponding thread is viewed
129,187
07.01.2018 16:31:52
18,000
0ea3d6dffbd457dabbcc3edcb87ac1000437ab12
Support notification IDs so we can rescind them later
[ { "change_type": "MODIFY", "old_path": "jserver/src/database.js", "new_path": "jserver/src/database.js", "diff": "@@ -6,7 +6,7 @@ import SQL from 'sql-template-strings';\nimport dbConfig from '../secrets/db_config';\nexport type QueryResult = [\n- any[],\n+ any[] & { insertId?: number },\nany[],\n];\n" }, { "change_type": "MODIFY", "old_path": "jserver/src/push/ios_notifs.js", "new_path": "jserver/src/push/ios_notifs.js", "diff": "// @flow\nimport type { $Response, $Request } from 'express';\n-import type { RawMessageInfo } from 'lib/types/message-types';\n+import type { RawMessageInfo, MessageInfo } from 'lib/types/message-types';\nimport type { UserInfo } from 'lib/types/user-types';\n+import type { ThreadInfo } from 'lib/types/thread-types';\nimport type { Connection } from '../database';\nimport apn from 'apn';\n+import invariant from 'invariant';\nimport { notifTextForMessageInfo } from 'lib/shared/notif-utils';\nimport { messageType } from 'lib/types/message-types';\n@@ -33,13 +35,18 @@ async function sendIOSPushNotifs(req: $Request, res: $Response) {\n}\nconst conn = await connect();\n- const [ unreadCounts, { threadInfos, userInfos } ] = await Promise.all([\n+ const [\n+ unreadCounts,\n+ { threadInfos, userInfos },\n+ uniqueIDs,\n+ ] = await Promise.all([\ngetUnreadCounts(conn, Object.keys(pushInfo)),\nfetchInfos(conn, pushInfo),\n+ createUniqueIDs(conn, pushInfo),\n]);\n- conn.end();\nconst promises = [];\n+ const notifications = [];\nfor (let userID in pushInfo) {\nfor (let rawMessageInfo of pushInfo[userID].messageInfos) {\nconst messageInfo = createMessageInfo(\n@@ -52,22 +59,42 @@ async function sendIOSPushNotifs(req: $Request, res: $Response) {\ncontinue;\n}\nconst threadInfo = threadInfos[messageInfo.threadID];\n- const notification = new apn.Notification();\n- notification.alert = notifTextForMessageInfo(\n+ const uniqueID = uniqueIDs.shift();\n+ invariant(uniqueID, \"should have sufficient unique IDs\");\n+ const notification = prepareNotification(\nmessageInfo,\nthreadInfo,\n+ unreadCounts[userID],\n+ uniqueID,\n);\n- notification.topic = \"org.squadcal.app\";\n- notification.badge = unreadCounts[userID];\n- notification.threadId = messageInfo.threadID;\npromises.push(apnProvider.send(\nnotification,\npushInfo[userID].deviceTokens,\n));\n+ notifications.push([\n+ uniqueID,\n+ userID,\n+ messageInfo.threadID,\n+ messageInfo.id,\n+ JSON.stringify({ iosDeviceTokens: pushInfo[userID].deviceTokens }),\n+ ]);\n}\n}\n+ if (notifications.length > 0) {\n+ const query = SQL`\n+ INSERT INTO notifications (id, user, thread, message, delivery)\n+ VALUES ${notifications}\n+ `;\n+ promises.push(conn.query(query));\n+ }\n+ if (uniqueIDs.length > 0) {\n+ const query = SQL`DELETE FROM ids WHERE id IN (${uniqueIDs})`;\n+ promises.push(conn.query(query));\n+ }\n- return await Promise.all(promises);\n+ const result = await Promise.all(promises);\n+ conn.end();\n+ return result;\n}\nasync function getUnreadCounts(\n@@ -158,6 +185,44 @@ async function fetchMissingUserInfos(\nreturn finalUserInfos;\n}\n+async function createUniqueIDs(\n+ conn: Connection,\n+ pushInfo: IOSPushInfo,\n+): Promise<string[]> {\n+ let numIDsNeeded = 0;\n+ for (let userID in pushInfo) {\n+ numIDsNeeded += pushInfo[userID].messageInfos.length;\n+ }\n+ if (!numIDsNeeded) {\n+ return [];\n+ }\n+ const tableNames = Array(numIDsNeeded).fill([\"notifications\"]);\n+ const query = SQL`INSERT INTO ids (table_name) VALUES ${tableNames}`;\n+ const [ result ] = await conn.query(query);\n+ const lastNewID = result.insertId;\n+ invariant(lastNewID !== null && lastNewID !== undefined, \"should be set\");\n+ const firstNewID = lastNewID - numIDsNeeded + 1;\n+ return Array.from(\n+ new Array(numIDsNeeded),\n+ (val, index) => (index + firstNewID).toString(),\n+ );\n+}\n+\n+function prepareNotification(\n+ messageInfo: MessageInfo,\n+ threadInfo: ThreadInfo,\n+ unreadCount: number,\n+ uniqueID: string,\n+): apn.Notification {\n+ const notifText = notifTextForMessageInfo(messageInfo, threadInfo);\n+ const notification = new apn.Notification();\n+ notification.alert = notifText;\n+ notification.topic = \"org.squadcal.app\";\n+ notification.badge = unreadCount;\n+ notification.threadId = messageInfo.threadID;\n+ return notification;\n+}\n+\nexport {\nsendIOSPushNotifs,\n};\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Support notification IDs so we can rescind them later
129,187
07.01.2018 16:59:19
18,000
cea3adcbfd8b28bf4f4308d6436bbca1d58cc0f3
Use specific kind of remote notification that wix's react-native-notifications can rescind
[ { "change_type": "MODIFY", "old_path": "jserver/src/push/ios_notifs.js", "new_path": "jserver/src/push/ios_notifs.js", "diff": "@@ -216,10 +216,19 @@ function prepareNotification(\n): apn.Notification {\nconst notifText = notifTextForMessageInfo(messageInfo, threadInfo);\nconst notification = new apn.Notification();\n- notification.alert = notifText;\n- notification.topic = \"org.squadcal.app\";\n+ notification.contentAvailable = true;\nnotification.badge = unreadCount;\n+ notification.topic = \"org.squadcal.app\";\nnotification.threadId = messageInfo.threadID;\n+ notification.payload = {\n+ managedAps: {\n+ action: \"CREATE\",\n+ notificationId: uniqueID,\n+ alert: {\n+ body: notifText,\n+ }\n+ },\n+ };\nreturn notification;\n}\n" }, { "change_type": "MODIFY", "old_path": "native/app.react.js", "new_path": "native/app.react.js", "diff": "@@ -367,7 +367,7 @@ class AppWithNavigationState extends React.PureComponent<Props> {\nconst threadID = notification.getThread();\ninvariant(this.inAppNotification, \"should be set\");\nthis.inAppNotification.show({\n- message: notification.getMessage(),\n+ message: notification.getMessage().body,\nonPress: () => {\nthis.props.dispatchActionPayload(\nnotificationPressActionType,\n" }, { "change_type": "MODIFY", "old_path": "native/ios/SquadCal.xcodeproj/project.pbxproj", "new_path": "native/ios/SquadCal.xcodeproj/project.pbxproj", "diff": "DevelopmentTeam = 6BF4H9TU5U;\nProvisioningStyle = Automatic;\nSystemCapabilities = {\n+ com.apple.BackgroundModes = {\n+ enabled = 1;\n+ };\ncom.apple.GameCenter = {\nenabled = 0;\n};\n" }, { "change_type": "MODIFY", "old_path": "native/ios/SquadCal/Info.plist", "new_path": "native/ios/SquadCal/Info.plist", "diff": "</dict>\n</dict>\n<key>NSLocationWhenInUseUsageDescription</key>\n- <string/>\n+ <string></string>\n<key>UIAppFonts</key>\n<array>\n<string>OpenSans-Semibold.ttf</string>\n<string>SimpleLineIcons.ttf</string>\n<string>Zocial.ttf</string>\n</array>\n+ <key>UIBackgroundModes</key>\n+ <array>\n+ <string>remote-notification</string>\n+ </array>\n<key>UILaunchStoryboardName</key>\n<string>LaunchScreen</string>\n<key>UIRequiredDeviceCapabilities</key>\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Use specific kind of remote notification that wix's react-native-notifications can rescind
129,187
07.01.2018 18:19:10
18,000
caad8ed7847e445373e6deffe1cf7ece63fa592b
Add support for rescinding iOS notifications to the server
[ { "change_type": "MODIFY", "old_path": "jserver/src/app.js", "new_path": "jserver/src/app.js", "diff": "@@ -5,8 +5,10 @@ import bodyParser from 'body-parser';\nimport errorHandler from './error_handler';\nimport { sendIOSPushNotifs } from './push/ios_notifs';\n+import { rescindPushNotifs } from './push/rescind';\nconst app = express();\napp.use(bodyParser.json());\napp.post('/ios_push_notifs', errorHandler(sendIOSPushNotifs));\n+app.post('/rescind_push_notifs', errorHandler(rescindPushNotifs));\napp.listen(parseInt(process.env.PORT) || 3000, 'localhost');\n" }, { "change_type": "MODIFY", "old_path": "jserver/src/push/ios_notifs.js", "new_path": "jserver/src/push/ios_notifs.js", "diff": "@@ -15,6 +15,7 @@ import { createMessageInfo } from 'lib/shared/message-utils';\nimport apnConfig from '../../secrets/apn_config';\nimport { connect, SQL } from '../database';\n+import { getUnreadCounts } from './utils';\nimport { fetchThreadInfos } from '../fetchers/thread-fetcher';\nimport { fetchUserInfos } from '../fetchers/user-fetcher';\n@@ -97,29 +98,6 @@ async function sendIOSPushNotifs(req: $Request, res: $Response) {\nreturn result;\n}\n-async function getUnreadCounts(\n- conn: Connection,\n- userIDs: string[],\n-): Promise<{ [userID: string]: number }> {\n- const query = SQL`\n- SELECT user, COUNT(thread) AS unread_count\n- FROM memberships\n- WHERE user IN (${userIDs}) AND unread = 1 AND role != 0\n- GROUP BY user\n- `;\n- const [ result ] = await conn.query(query);\n- const usersToUnreadCounts = {};\n- for (let row of result) {\n- usersToUnreadCounts[row.user.toString()] = row.unread_count;\n- }\n- for (let userID of userIDs) {\n- if (usersToUnreadCounts[userID] === undefined) {\n- usersToUnreadCounts[userID] = 0;\n- }\n- }\n- return usersToUnreadCounts;\n-}\n-\nasync function fetchInfos(\nconn: Connection,\npushInfo: IOSPushInfo,\n@@ -234,4 +212,5 @@ function prepareNotification(\nexport {\nsendIOSPushNotifs,\n+ getUnreadCounts,\n};\n" }, { "change_type": "ADD", "old_path": null, "new_path": "jserver/src/push/rescind.js", "diff": "+// @flow\n+\n+import type { $Response, $Request } from 'express';\n+\n+import apn from 'apn';\n+\n+import apnConfig from '../../secrets/apn_config';\n+import { connect, SQL } from '../database';\n+import { getUnreadCounts } from './utils';\n+\n+type PushRescindInfo = {\n+ userID: string,\n+ threadIDs: string[],\n+};\n+\n+const apnProvider = new apn.Provider(apnConfig);\n+\n+async function rescindPushNotifs(req: $Request, res: $Response) {\n+ res.json({ success: true });\n+ const pushRescindInfo: PushRescindInfo = req.body;\n+ const userID = pushRescindInfo.userID;\n+\n+ const conn = await connect();\n+ const query = SQL`\n+ SELECT id, delivery\n+ FROM notifications\n+ WHERE user = ${userID} AND thread IN (${pushRescindInfo.threadIDs})\n+ `;\n+ const [ [ result ], unreadCounts ] = await Promise.all([\n+ conn.query(query),\n+ getUnreadCounts(conn, [ userID ]),\n+ ]);\n+ conn.end();\n+\n+ const promises = [];\n+ for (let row of result) {\n+ const notification = new apn.Notification();\n+ notification.contentAvailable = true;\n+ notification.badge = unreadCounts[userID];\n+ notification.topic = \"org.squadcal.app\";\n+ notification.payload = {\n+ managedAps: {\n+ action: \"CLEAR\",\n+ notificationId: row.id,\n+ },\n+ };\n+ promises.push(apnProvider.send(\n+ notification,\n+ row.delivery.iosDeviceTokens,\n+ ));\n+ }\n+ return await Promise.all(promises);\n+}\n+\n+export {\n+ rescindPushNotifs,\n+};\n" }, { "change_type": "ADD", "old_path": null, "new_path": "jserver/src/push/utils.js", "diff": "+// @flow\n+\n+import type { Connection } from '../database';\n+import { SQL } from '../database';\n+\n+async function getUnreadCounts(\n+ conn: Connection,\n+ userIDs: string[],\n+): Promise<{ [userID: string]: number }> {\n+ const query = SQL`\n+ SELECT user, COUNT(thread) AS unread_count\n+ FROM memberships\n+ WHERE user IN (${userIDs}) AND unread = 1 AND role != 0\n+ GROUP BY user\n+ `;\n+ const [ result ] = await conn.query(query);\n+ const usersToUnreadCounts = {};\n+ for (let row of result) {\n+ usersToUnreadCounts[row.user.toString()] = row.unread_count;\n+ }\n+ for (let userID of userIDs) {\n+ if (usersToUnreadCounts[userID] === undefined) {\n+ usersToUnreadCounts[userID] = 0;\n+ }\n+ }\n+ return usersToUnreadCounts;\n+}\n+\n+export {\n+ getUnreadCounts,\n+}\n" }, { "change_type": "MODIFY", "old_path": "native/app.react.js", "new_path": "native/app.react.js", "diff": "@@ -86,7 +86,7 @@ if (!__DEV__) {\n// Since iOS is simulated and not emulated, we can use localhost\nurlPrefix = \"http://localhost/~ashoat/squadcal/\";\n// Uncomment below and update IP address if testing on physical device\n- //urlPrefix = \"http://192.168.1.3/~ashoat/squadcal/\";\n+ //urlPrefix = \"http://192.168.1.7/~ashoat/squadcal/\";\n} else {\ninvariant(false, \"unsupported platform\");\n}\n" }, { "change_type": "MODIFY", "old_path": "server/activity_lib.php", "new_path": "server/activity_lib.php", "diff": "@@ -5,6 +5,7 @@ require_once('auth.php');\nrequire_once('permissions.php');\nrequire_once('message_lib.php');\nrequire_once('thread_lib.php');\n+require_once('call_node.php');\n// Returns the set of unfocused threads that should be set to unread on\n// the client because a new message arrived since they were unfocused\n@@ -81,6 +82,12 @@ WHERE role != 0\nAND user = {$viewer_id}\nSQL;\n$conn->query($query);\n+\n+ $push_rescind_info = array(\n+ \"userID\" => (string)$viewer_id,\n+ \"threadIDs\" => array_map('strval', $focused_thread_ids),\n+ );\n+ call_node('rescind_push_notifs', $push_rescind_info);\n}\n// To protect against a possible race condition, we reset the thread to unread\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Add support for rescinding iOS notifications to the server
129,187
07.01.2018 18:29:32
18,000
93a4fce7b9b8d1a6d372a381d0614ca9d29388ba
Fix some Android stuff with the new wix notification package
[ { "change_type": "MODIFY", "old_path": "native/android/app/src/main/java/org/squadcal/MainApplication.java", "new_path": "native/android/app/src/main/java/org/squadcal/MainApplication.java", "diff": "@@ -26,7 +26,7 @@ public class MainApplication extends Application implements ReactApplication {\nprotected List<ReactPackage> getPackages() {\nreturn Arrays.<ReactPackage>asList(\nnew MainReactPackage(),\n- new RNNotificationsPackage(),\n+ new RNNotificationsPackage(MainApplication.this),\nnew VectorIconsPackage(),\nnew KeychainPackage()\n);\n" }, { "change_type": "MODIFY", "old_path": "native/app.react.js", "new_path": "native/app.react.js", "diff": "@@ -173,6 +173,7 @@ class AppWithNavigationState extends React.PureComponent<Props> {\nnull,\nnull,\n);\n+ if (Platform.OS === \"ios\") {\nNotificationsIOS.addEventListener(\n\"remoteNotificationsRegistered\",\nthis.registerIOSPushPermissions,\n@@ -191,6 +192,7 @@ class AppWithNavigationState extends React.PureComponent<Props> {\n);\nAppWithNavigationState.updateBadgeCount(this.props.unreadCount);\n}\n+ }\nstatic updateBadgeCount(unreadCount: number) {\nif (Platform.OS === \"ios\") {\n@@ -238,6 +240,7 @@ class AppWithNavigationState extends React.PureComponent<Props> {\nthis.activePingSubscription = null;\n}\nthis.closingApp();\n+ if (Platform.OS === \"ios\") {\nNotificationsIOS.removeEventListener(\n\"remoteNotificationsRegistered\",\nthis.registerIOSPushPermissions,\n@@ -284,9 +287,13 @@ class AppWithNavigationState extends React.PureComponent<Props> {\nnull,\n);\nthis.ensurePushNotifsEnabled();\n+ if (Platform.OS === \"ios\") {\nAppWithNavigationState.updateBadgeCount(this.props.unreadCount);\nif (this.props.activeThread) {\n- AppWithNavigationState.clearIOSNotifsOfThread(this.props.activeThread);\n+ AppWithNavigationState.clearIOSNotifsOfThread(\n+ this.props.activeThread,\n+ );\n+ }\n}\n} else if (\nlastState === \"active\" &&\n@@ -313,17 +320,19 @@ class AppWithNavigationState extends React.PureComponent<Props> {\nthis.props.activeThreadLatestMessage,\n);\n}\n+ if (justLoggedIn) {\n+ this.ensurePushNotifsEnabled();\n+ }\n+ if (Platform.OS === \"ios\") {\nconst nextActiveThread = nextProps.activeThread;\nif (nextActiveThread && nextActiveThread !== this.props.activeThread) {\nAppWithNavigationState.clearIOSNotifsOfThread(nextActiveThread);\n}\n- if (justLoggedIn) {\n- this.ensurePushNotifsEnabled();\n- }\nif (nextProps.unreadCount !== this.props.unreadCount) {\nAppWithNavigationState.updateBadgeCount(nextProps.unreadCount);\n}\n}\n+ }\nasync ensurePushNotifsEnabled() {\nconst missingDeviceToken = this.props.deviceToken === null\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Fix some Android stuff with the new wix notification package
129,187
07.01.2018 18:32:08
18,000
89e101933253545a7bc651bf8ce2c01d6f5eebb1
Minor typo in last commit ugh
[ { "change_type": "MODIFY", "old_path": "native/app.react.js", "new_path": "native/app.react.js", "diff": "@@ -258,6 +258,7 @@ class AppWithNavigationState extends React.PureComponent<Props> {\nthis.iosNotificationOpened,\n);\n}\n+ }\nhandleURLChange = (event: { url: string }) => {\nthis.dispatchActionForURL(event.url);\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Minor typo in last commit ugh
129,187
08.01.2018 16:11:38
18,000
52bb7c14c57dac8c6bc387f6ac7ed98082e1944e
Move message creation to after thread creation/editing In particular, creating a thread's permission rows only after message creation breaks the permission checks that occur in the notification code.
[ { "change_type": "MODIFY", "old_path": "server/edit_thread.php", "new_path": "server/edit_thread.php", "diff": "@@ -230,29 +230,6 @@ 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_MEMBERS,\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-\n$to_save = array();\n$to_delete = array();\nif (\n@@ -284,6 +261,29 @@ if ($add_member_ids) {\nsave_memberships($to_save);\ndelete_memberships($to_delete);\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_MEMBERS,\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+\nlist($thread_infos) = get_thread_infos(\"t.id = {$thread}\");\nasync_end(array(\n" }, { "change_type": "MODIFY", "old_path": "server/new_thread.php", "new_path": "server/new_thread.php", "diff": "@@ -104,30 +104,6 @@ $initial_member_ids = isset($_POST['initial_member_ids'])\n? verify_user_ids($_POST['initial_member_ids'])\n: array();\n-$message_infos = array(array(\n- 'type' => MESSAGE_TYPE_CREATE_THREAD,\n- 'threadID' => (string)$id,\n- 'creatorID' => (string)$creator,\n- 'time' => $time,\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-if ($parent_thread_id) {\n- $message_infos[] = array(\n- 'type' => MESSAGE_TYPE_CREATE_SUB_THREAD,\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-\n$creator_results = change_role(\n$id,\narray($creator),\n@@ -191,6 +167,30 @@ foreach ($to_save as $row_to_save) {\nsave_memberships($processed_to_save);\ndelete_memberships($to_delete);\n+$message_infos = array(array(\n+ 'type' => MESSAGE_TYPE_CREATE_THREAD,\n+ 'threadID' => (string)$id,\n+ 'creatorID' => (string)$creator,\n+ 'time' => $time,\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+if ($parent_thread_id) {\n+ $message_infos[] = array(\n+ 'type' => MESSAGE_TYPE_CREATE_SUB_THREAD,\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+\nasync_end(array(\n'success' => true,\n'new_thread_info' => array(\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Move message creation to after thread creation/editing In particular, creating a thread's permission rows only after message creation breaks the permission checks that occur in the notification code.
129,187
08.01.2018 17:31:22
18,000
3696cdbdcafc37ed694ec3128554e987ab2e90ec
Make sure all role rows are populated on thread creation We weren't checking any rows on the parent that might translate to the child.
[ { "change_type": "MODIFY", "old_path": "server/new_thread.php", "new_path": "server/new_thread.php", "diff": "@@ -103,10 +103,15 @@ $conn->query($thread_insert_sql);\n$initial_member_ids = isset($_POST['initial_member_ids'])\n? verify_user_ids($_POST['initial_member_ids'])\n: array();\n+$creator_member_ids = array($creator);\n+$initial_member_and_creator_ids = array_merge(\n+ $initial_member_ids,\n+ $creator_member_ids\n+);\n$creator_results = change_role(\n$id,\n- array($creator),\n+ $creator_member_ids,\n(int)$roles['admins']['id']\n);\nif (!$creator_results) {\n@@ -127,6 +132,28 @@ if ($initial_member_ids) {\n$to_delete = array_merge($to_delete, $initial_member_results['to_delete']);\n}\n+$recalc_results = recalculate_all_permissions($id, $vis_rules);\n+$recalc_to_save = $recalc_results['to_save'];\n+$recalc_to_delete = $recalc_results['to_delete'];\n+foreach ($recalc_to_save as $recalc_row_to_save) {\n+ $user_id = $recalc_row_to_save['user_id'];\n+ foreach ($initial_member_and_creator_ids as $member_id) {\n+ if ($user_id === $member_id) {\n+ continue 2;\n+ }\n+ }\n+ $to_save[] = $recalc_row_to_save;\n+}\n+foreach ($recalc_to_delete as $recalc_row_to_delete) {\n+ $user_id = $recalc_row_to_delete['user_id'];\n+ foreach ($initial_member_and_creator_ids as $member_id) {\n+ if ($user_id === $member_id) {\n+ continue 2;\n+ }\n+ }\n+ $to_delete[] = $recalc_row_to_delete;\n+}\n+\n$processed_to_save = array();\n$members = array();\n$current_user_info = null;\n@@ -177,7 +204,7 @@ $message_infos = array(array(\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+ 'memberIDs' => array_map(\"strval\", $initial_member_and_creator_ids),\n),\n));\nif ($parent_thread_id) {\n" }, { "change_type": "MODIFY", "old_path": "server/permissions.php", "new_path": "server/permissions.php", "diff": "@@ -400,6 +400,9 @@ SQL;\n// )>,\n// to_delete: array<array(user_id: int, thread_id: int)>,\n// )\n+// When a user's permissions for a given thread are modified, this function gets\n+// called to make sure the permissions of all of its child threads are updated as\n+// well.\nfunction update_descendant_permissions(\n$initial_parent_thread_id,\n$initial_users_to_permissions_from_parent\n@@ -822,6 +825,14 @@ LEFT JOIN threads t ON t.id = m.thread\nLEFT JOIN roles r ON r.id = m.role\nLEFT JOIN memberships pm ON pm.thread = t.parent_thread_id AND pm.user = m.user\nWHERE m.thread = {$thread_id}\n+UNION SELECT pm.user, 0 AS role, NULL AS permissions,\n+ NULL AS permissions_for_children,\n+ pm.permissions_for_children AS permissions_from_parent,\n+ NULL AS role_permissions\n+FROM threads t\n+LEFT JOIN memberships pm ON pm.thread = t.parent_thread_id\n+LEFT JOIN memberships m ON m.thread = t.id AND m.user = pm.user\n+WHERE t.id = {$thread_id} AND m.thread IS NULL\nSQL;\n$result = $conn->query($query);\n@@ -831,7 +842,9 @@ SQL;\nwhile ($row = $result->fetch_assoc()) {\n$user_id = (int)$row['user'];\n$role = (int)$row['role'];\n- $old_permissions = json_decode($row['permissions'], true);\n+ $old_permissions = $row['permissions']\n+ ? json_decode($row['permissions'], true)\n+ : null;\n$old_permissions_for_children = $row['permissions_for_children']\n? json_decode($row['permissions_for_children'], true)\n: null;\n" }, { "change_type": "ADD", "old_path": null, "new_path": "server/scripts/recalculate_permissions.php", "diff": "+<?php\n+\n+require_once('../config.php');\n+require_once('../permissions.php');\n+\n+$recalc_results = recalculate_all_permissions(79571, 3);\n+$recalc_to_save = $recalc_results['to_save'];\n+$recalc_to_delete = $recalc_results['to_delete'];\n+save_memberships($recalc_to_save);\n+delete_memberships($recalc_to_delete);\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Make sure all role rows are populated on thread creation We weren't checking any rows on the parent that might translate to the child.
129,187
08.01.2018 18:10:02
18,000
38e0716b2a2017ab9cf423b0f3397e04b3e0208c
Generate notif text for CREATE_SUB_THREAD notifs Used when corresponding CREATE_THREAD notif isn't sent
[ { "change_type": "MODIFY", "old_path": "jserver/src/push/ios_notifs.js", "new_path": "jserver/src/push/ios_notifs.js", "diff": "@@ -111,6 +111,8 @@ async function fetchInfos(\nrawMessageInfo.initialThreadState.parentThreadID\n) {\nthreadIDs.add(rawMessageInfo.initialThreadState.parentThreadID);\n+ } else if (rawMessageInfo.type === messageType.CREATE_SUB_THREAD) {\n+ threadIDs.add(rawMessageInfo.childThreadID);\n}\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "lib/shared/notif-utils.js", "new_path": "lib/shared/notif-utils.js", "diff": "@@ -4,8 +4,6 @@ import type { MessageInfo, RobotextMessageInfo } from '../types/message-types';\nimport type { ThreadInfo } from '../types/thread-types';\nimport type { RelativeUserInfo } from '../types/user-types';\n-import invariant from 'invariant';\n-\nimport { messageType } from '../types/message-types';\nimport {\nrobotextForMessageInfo,\n@@ -33,6 +31,16 @@ function notifTextForMessageInfo(\nreturn fullNotifText.substr(0, 297) + \"...\";\n}\n+const notifTextForSubthreadCreation = (\n+ creator: RelativeUserInfo,\n+ parentThreadInfo: ThreadInfo,\n+ childThreadName: string,\n+) => {\n+ let text = `${stringForUser(creator)} created a new thread `;\n+ text += `in ${parentThreadInfo.name} called \"${childThreadName}\"`;\n+ return text;\n+}\n+\nfunction fullNotifTextForMessageInfo(\nmessageInfo: MessageInfo,\nthreadInfo: ThreadInfo,\n@@ -47,18 +55,26 @@ function fullNotifTextForMessageInfo(\nreturn `${userString} to your thread: ${messageInfo.text}`;\n}\n} else if (messageInfo.type === messageType.CREATE_THREAD) {\n- let text = `${stringForUser(messageInfo.creator)} created a new thread `;\n- const parentThread = messageInfo.initialThreadState.parentThreadInfo;\n- if (parentThread) {\n- text += `in ${parentThread.name} `;\n+ const parentThreadInfo = messageInfo.initialThreadState.parentThreadInfo;\n+ if (parentThreadInfo) {\n+ return notifTextForSubthreadCreation(\n+ messageInfo.creator,\n+ parentThreadInfo,\n+ messageInfo.initialThreadState.name,\n+ );\n}\n+ let text = `${stringForUser(messageInfo.creator)} created a new thread `;\ntext += `called \"${messageInfo.initialThreadState.name}\"`;\nreturn text;\n} else if (messageInfo.type === messageType.ADD_MEMBERS) {\nconst robotext = strippedRobotextForMessageInfo(messageInfo, threadInfo);\nreturn `${robotext} to ${threadInfo.name}`;\n} else if (messageInfo.type === messageType.CREATE_SUB_THREAD) {\n- invariant(false, \"no notifs should correspond to CREATE_SUB_THREAD\");\n+ return notifTextForSubthreadCreation(\n+ messageInfo.creator,\n+ threadInfo,\n+ messageInfo.childThreadInfo.name,\n+ );\n} else if (messageInfo.type === messageType.REMOVE_MEMBERS) {\nconst robotext = strippedRobotextForMessageInfo(messageInfo, threadInfo);\nreturn `${robotext} from ${threadInfo.name}`;\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Generate notif text for CREATE_SUB_THREAD notifs Used when corresponding CREATE_THREAD notif isn't sent
129,187
08.01.2018 23:33:21
18,000
837a0c5e7b67202003bc6767a4a502e9c3f44477
Use remote notifs for initial ping and remote notifs to rescind Using my custom worked version of `react-native-notifications` now.
[ { "change_type": "MODIFY", "old_path": "jserver/package-lock.json", "new_path": "jserver/package-lock.json", "diff": "\"uuid\": {\n\"version\": \"3.1.0\",\n\"resolved\": \"https://registry.npmjs.org/uuid/-/uuid-3.1.0.tgz\",\n- \"integrity\": \"sha512-DIWtzUkw04M4k3bf1IcpS2tngXEL26YUD2M0tMDUpnUrz2hgzUBlD55a4FjdLGPvfHxS6uluGWvaVEqgBcVa+g==\",\n- \"dev\": true\n+ \"integrity\": \"sha512-DIWtzUkw04M4k3bf1IcpS2tngXEL26YUD2M0tMDUpnUrz2hgzUBlD55a4FjdLGPvfHxS6uluGWvaVEqgBcVa+g==\"\n},\n\"v8flags\": {\n\"version\": \"2.1.1\",\n" }, { "change_type": "MODIFY", "old_path": "jserver/package.json", "new_path": "jserver/package.json", "diff": "\"lib\": \"file:../lib\",\n\"mysql2\": \"^1.5.1\",\n\"promise\": \"^8.0.1\",\n- \"sql-template-strings\": \"^2.2.2\"\n+ \"sql-template-strings\": \"^2.2.2\",\n+ \"uuid\": \"^3.1.0\"\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "jserver/src/push/ios_notifs.js", "new_path": "jserver/src/push/ios_notifs.js", "diff": "@@ -8,6 +8,7 @@ import type { Connection } from '../database';\nimport apn from 'apn';\nimport invariant from 'invariant';\n+import uuidv4 from 'uuid/v4';\nimport { notifTextForMessageInfo } from 'lib/shared/notif-utils';\nimport { messageType } from 'lib/types/message-types';\n@@ -66,7 +67,6 @@ async function sendIOSPushNotifs(req: $Request, res: $Response) {\nmessageInfo,\nthreadInfo,\nunreadCounts[userID],\n- uniqueID,\n);\npromises.push(apnProvider.send(\nnotification,\n@@ -77,7 +77,10 @@ async function sendIOSPushNotifs(req: $Request, res: $Response) {\nuserID,\nmessageInfo.threadID,\nmessageInfo.id,\n- JSON.stringify({ iosDeviceTokens: pushInfo[userID].deviceTokens }),\n+ JSON.stringify({\n+ iosDeviceTokens: pushInfo[userID].deviceTokens,\n+ iosIdentifier: notification.id,\n+ }),\n]);\n}\n}\n@@ -192,23 +195,17 @@ function prepareNotification(\nmessageInfo: MessageInfo,\nthreadInfo: ThreadInfo,\nunreadCount: number,\n- uniqueID: string,\n): apn.Notification {\nconst notifText = notifTextForMessageInfo(messageInfo, threadInfo);\n+ const uniqueID = uuidv4();\nconst notification = new apn.Notification();\n- notification.contentAvailable = true;\n- notification.badge = unreadCount;\n+ notification.body = notifText;\nnotification.topic = \"org.squadcal.app\";\n+ notification.sound = \"default\";\n+ notification.badge = unreadCount;\nnotification.threadId = messageInfo.threadID;\n- notification.payload = {\n- managedAps: {\n- action: \"CREATE\",\n- notificationId: uniqueID,\n- alert: {\n- body: notifText,\n- }\n- },\n- };\n+ notification.id = uniqueID;\n+ notification.collapseId = uniqueID;\nreturn notification;\n}\n" }, { "change_type": "MODIFY", "old_path": "jserver/src/push/rescind.js", "new_path": "jserver/src/push/rescind.js", "diff": "@@ -41,7 +41,7 @@ async function rescindPushNotifs(req: $Request, res: $Response) {\nnotification.payload = {\nmanagedAps: {\naction: \"CLEAR\",\n- notificationId: row.id,\n+ notificationId: row.delivery.iosIdentifier,\n},\n};\npromises.push(apnProvider.send(\n" }, { "change_type": "MODIFY", "old_path": "native/app.react.js", "new_path": "native/app.react.js", "diff": "@@ -374,10 +374,17 @@ class AppWithNavigationState extends React.PureComponent<Props> {\n}\niosForegroundNotificationReceived = (notification) => {\n+ if (\n+ notification.getData() &&\n+ notification.getData().managedAps &&\n+ notification.getData().managedAps.action === \"CLEAR\"\n+ ) {\n+ return;\n+ }\nconst threadID = notification.getThread();\ninvariant(this.inAppNotification, \"should be set\");\nthis.inAppNotification.show({\n- message: notification.getMessage().body,\n+ message: notification.getMessage(),\nonPress: () => {\nthis.props.dispatchActionPayload(\nnotificationPressActionType,\n" }, { "change_type": "MODIFY", "old_path": "native/ios/SquadCal.xcodeproj/project.pbxproj", "new_path": "native/ios/SquadCal.xcodeproj/project.pbxproj", "diff": "7FB58AC11E7F6BD900B4C1B1 /* OpenSans-Regular.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 7FB58ABC1E7F6BC600B4C1B1 /* OpenSans-Regular.ttf */; };\n7FB58AC21E7F6BDB00B4C1B1 /* OpenSans-Semibold.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 7FB58ABD1E7F6BC600B4C1B1 /* OpenSans-Semibold.ttf */; };\n7FB58AC31E7F6BDC00B4C1B1 /* OpenSans-Semibold.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 7FB58ABD1E7F6BC600B4C1B1 /* OpenSans-Semibold.ttf */; };\n+ 7FF1293F20047B700051F874 /* libRNNotifications.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7FF1293E200475800051F874 /* libRNNotifications.a */; };\n+ 7FF1294020047B8B0051F874 /* libRNVectorIcons.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7FB58ABA1E7F6B4400B4C1B1 /* libRNVectorIcons.a */; };\n+ 7FF1294120047BAC0051F874 /* libRNKeychain.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7FEB2DEC1E8D64D200C4B763 /* libRNKeychain.a */; };\n832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 832341B51AAA6A8300B99B32 /* libRCTText.a */; };\n8894ACD632254222B23F69E2 /* Ionicons.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 4ACC468F28D944F293B91ACC /* Ionicons.ttf */; };\n- 98856FAEFDD5420882A5C010 /* libRNVectorIcons.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 414381A5DC394FE6BF2D28F3 /* libRNVectorIcons.a */; };\n9985FC0D9B2A43E49A4C1789 /* FontAwesome.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 4AB1FC0EFD3A4ED1A082E32F /* FontAwesome.ttf */; };\nA1145AA76F5B4EF5B3ACB31D /* MaterialIcons.ttf in Resources */ = {isa = PBXBuildFile; fileRef = E4E90F44E9F4420080594671 /* MaterialIcons.ttf */; };\n- A1F391C5F8A84FB28AEA9876 /* libRNKeychain.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F7A1F0235EA94B91A16863FA /* libRNKeychain.a */; };\nAFA44E75249D4766A4ED74C7 /* Octicons.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 2D04F3CCBAFF4A8184206FAC /* Octicons.ttf */; };\n- CB9A230CB96044FCB0E49A59 /* libRNNotifications.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2F7B10A4C43D4C5093D7BC40 /* libRNNotifications.a */; };\nFA7F2215AD7646E2BE985BF3 /* SimpleLineIcons.ttf in Resources */ = {isa = PBXBuildFile; fileRef = AE31AFFF88FB4112A29ADE33 /* SimpleLineIcons.ttf */; };\n/* End PBXBuildFile section */\nremoteGlobalIDString = 52E319201C0655C200265D56;\nremoteInfo = OnePassword;\n};\n- 7FC61C332001500B008A5DD8 /* PBXContainerItemProxy */ = {\n- isa = PBXContainerItemProxy;\n- containerPortal = 1B2F80B4A64F4C028127F1C7 /* RNNotifications.xcodeproj */;\n- proxyType = 2;\n- remoteGlobalIDString = 134814201AA4EA6300B7C361;\n- remoteInfo = RNNotifications;\n- };\n7FEB2DEB1E8D64D200C4B763 /* PBXContainerItemProxy */ = {\nisa = PBXContainerItemProxy;\ncontainerPortal = 95EEFC35D4D14053ACA7E064 /* RNKeychain.xcodeproj */;\nremoteGlobalIDString = 5D82366F1B0CE05B005A9EF3;\nremoteInfo = RNKeychain;\n};\n+ 7FF1293D200475800051F874 /* PBXContainerItemProxy */ = {\n+ isa = PBXContainerItemProxy;\n+ containerPortal = D274F1D31C1445999BE68CF4 /* RNNotifications.xcodeproj */;\n+ proxyType = 2;\n+ remoteGlobalIDString = 134814201AA4EA6300B7C361;\n+ remoteInfo = RNNotifications;\n+ };\n832341B41AAA6A8300B99B32 /* PBXContainerItemProxy */ = {\nisa = PBXContainerItemProxy;\ncontainerPortal = 832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */;\n13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = SquadCal/Info.plist; sourceTree = \"<group>\"; };\n13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = SquadCal/main.m; sourceTree = \"<group>\"; };\n146833FF1AC3E56700842450 /* React.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = \"wrapper.pb-project\"; name = React.xcodeproj; path = \"../node_modules/react-native/React/React.xcodeproj\"; sourceTree = \"<group>\"; };\n- 1B2F80B4A64F4C028127F1C7 /* RNNotifications.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = \"wrapper.pb-project\"; name = RNNotifications.xcodeproj; path = \"../node_modules/react-native-notifications/RNNotifications/RNNotifications.xcodeproj\"; sourceTree = \"<group>\"; };\n1E94F1BD692B4E6EBE1BFBFB /* Entypo.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = Entypo.ttf; path = \"../node_modules/react-native-vector-icons/Fonts/Entypo.ttf\"; sourceTree = \"<group>\"; };\n2D02E47B1E0B4A5D006451C7 /* SquadCal-tvOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = \"SquadCal-tvOS.app\"; sourceTree = BUILT_PRODUCTS_DIR; };\n2D02E4901E0B4A5D006451C7 /* SquadCal-tvOSTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = \"SquadCal-tvOSTests.xctest\"; sourceTree = BUILT_PRODUCTS_DIR; };\n2D04F3CCBAFF4A8184206FAC /* Octicons.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = Octicons.ttf; path = \"../node_modules/react-native-vector-icons/Fonts/Octicons.ttf\"; sourceTree = \"<group>\"; };\n- 2F7B10A4C43D4C5093D7BC40 /* libRNNotifications.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRNNotifications.a; sourceTree = \"<group>\"; };\n3430816A291640AEACA13234 /* EvilIcons.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = EvilIcons.ttf; path = \"../node_modules/react-native-vector-icons/Fonts/EvilIcons.ttf\"; sourceTree = \"<group>\"; };\n- 414381A5DC394FE6BF2D28F3 /* libRNVectorIcons.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRNVectorIcons.a; sourceTree = \"<group>\"; };\n4AB1FC0EFD3A4ED1A082E32F /* FontAwesome.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = FontAwesome.ttf; path = \"../node_modules/react-native-vector-icons/Fonts/FontAwesome.ttf\"; sourceTree = \"<group>\"; };\n4ACC468F28D944F293B91ACC /* Ionicons.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = Ionicons.ttf; path = \"../node_modules/react-native-vector-icons/Fonts/Ionicons.ttf\"; sourceTree = \"<group>\"; };\n5E91572D1DD0AC6500FF2AA8 /* RCTAnimation.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = \"wrapper.pb-project\"; name = RCTAnimation.xcodeproj; path = \"../node_modules/react-native/Libraries/NativeAnimation/RCTAnimation.xcodeproj\"; sourceTree = \"<group>\"; };\n95EEFC35D4D14053ACA7E064 /* RNKeychain.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = \"wrapper.pb-project\"; name = RNKeychain.xcodeproj; path = \"../node_modules/react-native-keychain/RNKeychain.xcodeproj\"; sourceTree = \"<group>\"; };\nAE31AFFF88FB4112A29ADE33 /* SimpleLineIcons.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = SimpleLineIcons.ttf; path = \"../node_modules/react-native-vector-icons/Fonts/SimpleLineIcons.ttf\"; sourceTree = \"<group>\"; };\nC3BA31E561EB497494D7882F /* RNVectorIcons.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = \"wrapper.pb-project\"; name = RNVectorIcons.xcodeproj; path = \"../node_modules/react-native-vector-icons/RNVectorIcons.xcodeproj\"; sourceTree = \"<group>\"; };\n+ D274F1D31C1445999BE68CF4 /* RNNotifications.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = \"wrapper.pb-project\"; name = RNNotifications.xcodeproj; path = \"../node_modules/react-native-notifications/RNNotifications/RNNotifications.xcodeproj\"; sourceTree = \"<group>\"; };\nE4E90F44E9F4420080594671 /* MaterialIcons.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = MaterialIcons.ttf; path = \"../node_modules/react-native-vector-icons/Fonts/MaterialIcons.ttf\"; sourceTree = \"<group>\"; };\nE7D7D614C3184B1BB95EE661 /* OnePassword.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = \"wrapper.pb-project\"; name = OnePassword.xcodeproj; path = \"../node_modules/react-native-onepassword/OnePassword.xcodeproj\"; sourceTree = \"<group>\"; };\nEA40FBBA484449FAA8915A48 /* Foundation.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = Foundation.ttf; path = \"../node_modules/react-native-vector-icons/Fonts/Foundation.ttf\"; sourceTree = \"<group>\"; };\nEBD8879422144B0188A8336F /* Zocial.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = Zocial.ttf; path = \"../node_modules/react-native-vector-icons/Fonts/Zocial.ttf\"; sourceTree = \"<group>\"; };\n- F7A1F0235EA94B91A16863FA /* libRNKeychain.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRNKeychain.a; sourceTree = \"<group>\"; };\n/* End PBXFileReference section */\n/* Begin PBXFrameworksBuildPhase section */\nisa = PBXFrameworksBuildPhase;\nbuildActionMask = 2147483647;\nfiles = (\n+ 7FF1294120047BAC0051F874 /* libRNKeychain.a in Frameworks */,\n+ 7FF1294020047B8B0051F874 /* libRNVectorIcons.a in Frameworks */,\n+ 7FF1293F20047B700051F874 /* libRNNotifications.a in Frameworks */,\n146834051AC3E58100842450 /* libReact.a in Frameworks */,\n5E9157361DD0AC6A00FF2AA8 /* libRCTAnimation.a in Frameworks */,\n00C302E51ABCBA2D00DB3ED1 /* libRCTActionSheet.a in Frameworks */,\n832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */,\n00C302EA1ABCBA2D00DB3ED1 /* libRCTVibration.a in Frameworks */,\n139FDEF61B0652A700C62182 /* libRCTWebSocket.a in Frameworks */,\n- 98856FAEFDD5420882A5C010 /* libRNVectorIcons.a in Frameworks */,\n- A1F391C5F8A84FB28AEA9876 /* libRNKeychain.a in Frameworks */,\n7F033BB61F01B5E400700D63 /* libOnePassword.a in Frameworks */,\n- CB9A230CB96044FCB0E49A59 /* libRNNotifications.a in Frameworks */,\n);\nrunOnlyForDeploymentPostprocessing = 0;\n};\nname = Products;\nsourceTree = \"<group>\";\n};\n- 7F474C621F833FC900B71135 /* Recovered References */ = {\n- isa = PBXGroup;\n- children = (\n- 414381A5DC394FE6BF2D28F3 /* libRNVectorIcons.a */,\n- F7A1F0235EA94B91A16863FA /* libRNKeychain.a */,\n- 2F7B10A4C43D4C5093D7BC40 /* libRNNotifications.a */,\n- );\n- name = \"Recovered References\";\n- sourceTree = \"<group>\";\n- };\n7FB58A9D1E7F6B4300B4C1B1 /* Products */ = {\nisa = PBXGroup;\nchildren = (\nname = Products;\nsourceTree = \"<group>\";\n};\n- 7FC61C302001500B008A5DD8 /* Products */ = {\n+ 7FEB2DCE1E8D64D200C4B763 /* Products */ = {\nisa = PBXGroup;\nchildren = (\n- 7FC61C342001500B008A5DD8 /* libRNNotifications.a */,\n+ 7FEB2DEC1E8D64D200C4B763 /* libRNKeychain.a */,\n);\nname = Products;\nsourceTree = \"<group>\";\n};\n- 7FEB2DCE1E8D64D200C4B763 /* Products */ = {\n+ 7FF0870B1E833C3F000A1ACF /* Frameworks */ = {\nisa = PBXGroup;\nchildren = (\n- 7FEB2DEC1E8D64D200C4B763 /* libRNKeychain.a */,\n);\n- name = Products;\n+ name = Frameworks;\nsourceTree = \"<group>\";\n};\n- 7FF0870B1E833C3F000A1ACF /* Frameworks */ = {\n+ 7FF1293A200475800051F874 /* Products */ = {\nisa = PBXGroup;\nchildren = (\n+ 7FF1293E200475800051F874 /* libRNNotifications.a */,\n);\n- name = Frameworks;\n+ name = Products;\nsourceTree = \"<group>\";\n};\n832341AE1AAA6A7D00B99B32 /* Libraries */ = {\nC3BA31E561EB497494D7882F /* RNVectorIcons.xcodeproj */,\nE7D7D614C3184B1BB95EE661 /* OnePassword.xcodeproj */,\n95EEFC35D4D14053ACA7E064 /* RNKeychain.xcodeproj */,\n- 1B2F80B4A64F4C028127F1C7 /* RNNotifications.xcodeproj */,\n+ D274F1D31C1445999BE68CF4 /* RNNotifications.xcodeproj */,\n);\nname = Libraries;\nsourceTree = \"<group>\";\n83CBBA001A601CBA00E9B192 /* Products */,\n6534411766BE4CA4B0AB0A78 /* Resources */,\n7FF0870B1E833C3F000A1ACF /* Frameworks */,\n- 7F474C621F833FC900B71135 /* Recovered References */,\n);\nindentWidth = 2;\nsourceTree = \"<group>\";\nProjectRef = 95EEFC35D4D14053ACA7E064 /* RNKeychain.xcodeproj */;\n},\n{\n- ProductGroup = 7FC61C302001500B008A5DD8 /* Products */;\n- ProjectRef = 1B2F80B4A64F4C028127F1C7 /* RNNotifications.xcodeproj */;\n+ ProductGroup = 7FF1293A200475800051F874 /* Products */;\n+ ProjectRef = D274F1D31C1445999BE68CF4 /* RNNotifications.xcodeproj */;\n},\n{\nProductGroup = 7FB58A9D1E7F6B4300B4C1B1 /* Products */;\nremoteRef = 7FB58AD31E80C21000B4C1B1 /* PBXContainerItemProxy */;\nsourceTree = BUILT_PRODUCTS_DIR;\n};\n- 7FC61C342001500B008A5DD8 /* libRNNotifications.a */ = {\n+ 7FEB2DEC1E8D64D200C4B763 /* libRNKeychain.a */ = {\nisa = PBXReferenceProxy;\nfileType = archive.ar;\n- path = libRNNotifications.a;\n- remoteRef = 7FC61C332001500B008A5DD8 /* PBXContainerItemProxy */;\n+ path = libRNKeychain.a;\n+ remoteRef = 7FEB2DEB1E8D64D200C4B763 /* PBXContainerItemProxy */;\nsourceTree = BUILT_PRODUCTS_DIR;\n};\n- 7FEB2DEC1E8D64D200C4B763 /* libRNKeychain.a */ = {\n+ 7FF1293E200475800051F874 /* libRNNotifications.a */ = {\nisa = PBXReferenceProxy;\nfileType = archive.ar;\n- path = libRNKeychain.a;\n- remoteRef = 7FEB2DEB1E8D64D200C4B763 /* PBXContainerItemProxy */;\n+ path = libRNNotifications.a;\n+ remoteRef = 7FF1293D200475800051F874 /* PBXContainerItemProxy */;\nsourceTree = BUILT_PRODUCTS_DIR;\n};\n832341B51AAA6A8300B99B32 /* libRCTText.a */ = {\n" }, { "change_type": "MODIFY", "old_path": "native/ios/SquadCal/Images.xcassets/AppIcon.appiconset/Contents.json", "new_path": "native/ios/SquadCal/Images.xcassets/AppIcon.appiconset/Contents.json", "diff": "{\n\"images\" : [\n+ {\n+ \"idiom\" : \"iphone\",\n+ \"size\" : \"20x20\",\n+ \"scale\" : \"2x\"\n+ },\n+ {\n+ \"idiom\" : \"iphone\",\n+ \"size\" : \"20x20\",\n+ \"scale\" : \"3x\"\n+ },\n{\n\"idiom\" : \"iphone\",\n\"size\" : \"29x29\",\n\"idiom\" : \"iphone\",\n\"size\" : \"60x60\",\n\"scale\" : \"3x\"\n+ },\n+ {\n+ \"idiom\" : \"ios-marketing\",\n+ \"size\" : \"1024x1024\",\n+ \"scale\" : \"1x\"\n}\n],\n\"info\" : {\n" }, { "change_type": "MODIFY", "old_path": "native/ios/SquadCal/Info.plist", "new_path": "native/ios/SquadCal/Info.plist", "diff": "</dict>\n</dict>\n<key>NSLocationWhenInUseUsageDescription</key>\n- <string></string>\n+ <string/>\n<key>UIAppFonts</key>\n<array>\n<string>OpenSans-Semibold.ttf</string>\n" }, { "change_type": "MODIFY", "old_path": "native/package-lock.json", "new_path": "native/package-lock.json", "diff": "}\n},\n\"react-native-notifications\": {\n- \"version\": \"1.1.17\",\n- \"resolved\": \"https://registry.npmjs.org/react-native-notifications/-/react-native-notifications-1.1.17.tgz\",\n- \"integrity\": \"sha512-5fS1I9JbU8t8B4iloiDtxhx0LTHZFB0hR0O+1nYE3UWPRCHRXJh1PTLR+eXQyg4oIxJ4vGMJQdRe7LvuD3MV0A==\",\n+ \"version\": \"git+https://git@github.com/ashoat/react-native-notifications.git#f913ad5f8ed644bb0567eaf1e6e8c75ef0326198\",\n\"requires\": {\n\"core-js\": \"1.2.7\",\n\"uuid\": \"2.0.3\"\n" }, { "change_type": "MODIFY", "old_path": "native/package.json", "new_path": "native/package.json", "diff": "\"react-native-in-app-notification\": \"^2.1.0\",\n\"react-native-keychain\": \"^1.2.1\",\n\"react-native-modal\": \"^4.0.0\",\n- \"react-native-notifications\": \"^1.1.17\",\n+ \"react-native-notifications\": \"git+https://git@github.com/ashoat/react-native-notifications.git\",\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" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Use remote notifs for initial ping and remote notifs to rescind Using my custom worked version of `react-native-notifications` now.
129,187
08.01.2018 23:46:36
18,000
09165134e35bb8e469273cbcd0fa0c5094e7fc21
Set notifications to rescinded after rescinding them
[ { "change_type": "MODIFY", "old_path": "jserver/src/push/ios_notifs.js", "new_path": "jserver/src/push/ios_notifs.js", "diff": "@@ -81,12 +81,13 @@ async function sendIOSPushNotifs(req: $Request, res: $Response) {\niosDeviceTokens: pushInfo[userID].deviceTokens,\niosIdentifier: notification.id,\n}),\n+ 0,\n]);\n}\n}\nif (notifications.length > 0) {\nconst query = SQL`\n- INSERT INTO notifications (id, user, thread, message, delivery)\n+ INSERT INTO notifications (id, user, thread, message, delivery, rescinded)\nVALUES ${notifications}\n`;\npromises.push(conn.query(query));\n" }, { "change_type": "MODIFY", "old_path": "jserver/src/push/rescind.js", "new_path": "jserver/src/push/rescind.js", "diff": "@@ -21,19 +21,20 @@ async function rescindPushNotifs(req: $Request, res: $Response) {\nconst userID = pushRescindInfo.userID;\nconst conn = await connect();\n- const query = SQL`\n+ const fetchQuery = SQL`\nSELECT id, delivery\nFROM notifications\nWHERE user = ${userID} AND thread IN (${pushRescindInfo.threadIDs})\n+ AND rescinded = 0\n`;\n- const [ [ result ], unreadCounts ] = await Promise.all([\n- conn.query(query),\n+ const [ [ fetchResult ], unreadCounts ] = await Promise.all([\n+ conn.query(fetchQuery),\ngetUnreadCounts(conn, [ userID ]),\n]);\n- conn.end();\nconst promises = [];\n- for (let row of result) {\n+ const rescindedIDs = [];\n+ for (let row of fetchResult) {\nconst notification = new apn.Notification();\nnotification.contentAvailable = true;\nnotification.badge = unreadCounts[userID];\n@@ -48,8 +49,18 @@ async function rescindPushNotifs(req: $Request, res: $Response) {\nnotification,\nrow.delivery.iosDeviceTokens,\n));\n+ rescindedIDs.push(row.id);\n+ }\n+ if (rescindedIDs.length > 0) {\n+ const rescindQuery = SQL`\n+ UPDATE notifications SET rescinded = 1 WHERE id IN (${rescindedIDs})\n+ `;\n+ promises.push(conn.query(rescindQuery));\n}\n- return await Promise.all(promises);\n+\n+ const result = await Promise.all(promises);\n+ conn.end();\n+ return result;\n}\nexport {\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Set notifications to rescinded after rescinding them
129,187
09.01.2018 00:35:23
18,000
83898d7dc6eee04ee5cc4164808a24e78501212a
Save errors on initial push to database
[ { "change_type": "MODIFY", "old_path": "jserver/src/push/ios_notifs.js", "new_path": "jserver/src/push/ios_notifs.js", "diff": "@@ -40,15 +40,15 @@ async function sendIOSPushNotifs(req: $Request, res: $Response) {\nconst [\nunreadCounts,\n{ threadInfos, userInfos },\n- uniqueIDs,\n+ dbIDs,\n] = await Promise.all([\ngetUnreadCounts(conn, Object.keys(pushInfo)),\nfetchInfos(conn, pushInfo),\n- createUniqueIDs(conn, pushInfo),\n+ createDBIDs(conn, pushInfo),\n]);\n- const promises = [];\n- const notifications = [];\n+ const apnPromises = [];\n+ const notifications = {};\nfor (let userID in pushInfo) {\nfor (let rawMessageInfo of pushInfo[userID].messageInfos) {\nconst messageInfo = createMessageInfo(\n@@ -61,45 +61,76 @@ async function sendIOSPushNotifs(req: $Request, res: $Response) {\ncontinue;\n}\nconst threadInfo = threadInfos[messageInfo.threadID];\n- const uniqueID = uniqueIDs.shift();\n- invariant(uniqueID, \"should have sufficient unique IDs\");\n+ const dbID = dbIDs.shift();\n+ invariant(dbID, \"should have sufficient DB IDs\");\nconst notification = prepareNotification(\nmessageInfo,\nthreadInfo,\nunreadCounts[userID],\n);\n- promises.push(apnProvider.send(\n+ apnPromises.push(apnPush(\n+ apnProvider,\nnotification,\npushInfo[userID].deviceTokens,\n+ dbID,\n));\n- notifications.push([\n- uniqueID,\n+ notifications[dbID] = [\n+ dbID,\nuserID,\nmessageInfo.threadID,\nmessageInfo.id,\n- JSON.stringify({\n+ {\niosDeviceTokens: pushInfo[userID].deviceTokens,\niosIdentifier: notification.id,\n- }),\n+ },\n0,\n+ ];\n+ }\n+ }\n+ const dbPromises = [];\n+ if (dbIDs.length > 0) {\n+ const query = SQL`DELETE FROM ids WHERE id IN (${dbIDs})`;\n+ dbPromises.push(conn.query(query));\n+ }\n+\n+ const [ apnResults ] = await Promise.all([\n+ Promise.all(apnPromises),\n+ Promise.all(dbPromises),\n]);\n+ for (let apnResult of apnResults) {\n+ if (apnResult.error) {\n+ notifications[apnResult.dbID][4].error = apnResult.error;\n+ }\n}\n+\n+ const flattenedNotifications = [];\n+ for (let dbID in notifications) {\n+ const notification = notifications[dbID];\n+ const jsonConverted = [...notification];\n+ jsonConverted[4] = JSON.stringify(jsonConverted[4]);\n+ flattenedNotifications.push(jsonConverted);\n}\nif (notifications.length > 0) {\nconst query = SQL`\nINSERT INTO notifications (id, user, thread, message, delivery, rescinded)\n- VALUES ${notifications}\n+ VALUES ${flattenedNotifications}\n`;\n- promises.push(conn.query(query));\n+ await conn.query(query);\n}\n- if (uniqueIDs.length > 0) {\n- const query = SQL`DELETE FROM ids WHERE id IN (${uniqueIDs})`;\n- promises.push(conn.query(query));\n+ conn.end();\n}\n- const result = await Promise.all(promises);\n- conn.end();\n- return result;\n+async function apnPush(\n+ apnProvider: apn.Provider,\n+ notification: apn.Notification,\n+ deviceTokens: string[],\n+ dbID: string,\n+) {\n+ const result = await apnProvider.send(notification, deviceTokens);\n+ for (let failure of result.failed) {\n+ return { error: failure, dbID };\n+ }\n+ return { success: true, dbID };\n}\nasync function fetchInfos(\n@@ -169,7 +200,7 @@ async function fetchMissingUserInfos(\nreturn finalUserInfos;\n}\n-async function createUniqueIDs(\n+async function createDBIDs(\nconn: Connection,\npushInfo: IOSPushInfo,\n): Promise<string[]> {\n@@ -212,5 +243,5 @@ function prepareNotification(\nexport {\nsendIOSPushNotifs,\n- getUnreadCounts,\n+ apnPush,\n};\n" }, { "change_type": "MODIFY", "old_path": "jserver/src/push/rescind.js", "new_path": "jserver/src/push/rescind.js", "diff": "@@ -7,6 +7,7 @@ import apn from 'apn';\nimport apnConfig from '../../secrets/apn_config';\nimport { connect, SQL } from '../database';\nimport { getUnreadCounts } from './utils';\n+import { apnPush } from './ios_notifs';\ntype PushRescindInfo = {\nuserID: string,\n@@ -45,9 +46,11 @@ async function rescindPushNotifs(req: $Request, res: $Response) {\nnotificationId: row.delivery.iosIdentifier,\n},\n};\n- promises.push(apnProvider.send(\n+ promises.push(apnPush(\n+ apnProvider,\nnotification,\nrow.delivery.iosDeviceTokens,\n+ row.id,\n));\nrescindedIDs.push(row.id);\n}\n@@ -60,7 +63,6 @@ async function rescindPushNotifs(req: $Request, res: $Response) {\nconst result = await Promise.all(promises);\nconn.end();\n- return result;\n}\nexport {\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Save errors on initial push to database
129,187
09.01.2018 23:20:04
18,000
e5cd2e6b666c709b79125c82b9743672ff6ff6ec
Update to call completionHandler after processing remote notification Also a bugfix where iOS notifs weren't being saved to the database and adding the uniqueID to the payload of the remote notification.
[ { "change_type": "MODIFY", "old_path": "jserver/src/push/ios_notifs.js", "new_path": "jserver/src/push/ios_notifs.js", "diff": "@@ -110,7 +110,7 @@ async function sendIOSPushNotifs(req: $Request, res: $Response) {\njsonConverted[4] = JSON.stringify(jsonConverted[4]);\nflattenedNotifications.push(jsonConverted);\n}\n- if (notifications.length > 0) {\n+ if (flattenedNotifications.length > 0) {\nconst query = SQL`\nINSERT INTO notifications (id, user, thread, message, delivery, rescinded)\nVALUES ${flattenedNotifications}\n@@ -238,6 +238,7 @@ function prepareNotification(\nnotification.threadId = messageInfo.threadID;\nnotification.id = uniqueID;\nnotification.collapseId = uniqueID;\n+ notification.payload.id = uniqueID;\nreturn notification;\n}\n" }, { "change_type": "MODIFY", "old_path": "native/app.react.js", "new_path": "native/app.react.js", "diff": "@@ -379,6 +379,7 @@ class AppWithNavigationState extends React.PureComponent<Props> {\nnotification.getData().managedAps &&\nnotification.getData().managedAps.action === \"CLEAR\"\n) {\n+ notification.finish(NotificationsIOS.FetchResult.NoData);\nreturn;\n}\nconst threadID = notification.getThread();\n@@ -395,10 +396,17 @@ class AppWithNavigationState extends React.PureComponent<Props> {\n);\n},\n});\n+ notification.finish(NotificationsIOS.FetchResult.NewData);\n}\niosNotificationOpened = (notification) => {\nconst threadID = notification.getThread();\n+ if (!threadID) {\n+ console.log(\"Notification with missing threadID received!\");\n+ notification.finish(NotificationsIOS.FetchResult.NoData);\n+ return;\n+ }\n+ notification.finish();\nthis.props.dispatchActionPayload(\nnotificationPressActionType,\n{\n@@ -406,6 +414,7 @@ class AppWithNavigationState extends React.PureComponent<Props> {\nclearChatRoutes: true,\n},\n);\n+ notification.finish(NotificationsIOS.FetchResult.NewData);\n}\nping = () => {\n" }, { "change_type": "MODIFY", "old_path": "native/ios/SquadCal.xcodeproj/project.pbxproj", "new_path": "native/ios/SquadCal.xcodeproj/project.pbxproj", "diff": "781ED432789E4AFC93FA578A /* Entypo.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 1E94F1BD692B4E6EBE1BFBFB /* Entypo.ttf */; };\n7E350429243446AAA3856078 /* MaterialCommunityIcons.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 8D919BA72D8545CBBBF6B74F /* MaterialCommunityIcons.ttf */; };\n7F033BB61F01B5E400700D63 /* libOnePassword.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7FB58AD41E80C21000B4C1B1 /* libOnePassword.a */; };\n+ 7F5B10EA200534C300FE096A /* libRNNotifications.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7F5B10E92005349D00FE096A /* libRNNotifications.a */; };\n7FB58ABE1E7F6BD500B4C1B1 /* Anaheim-Regular.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 7FB58ABB1E7F6BC600B4C1B1 /* Anaheim-Regular.ttf */; };\n7FB58ABF1E7F6BD600B4C1B1 /* Anaheim-Regular.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 7FB58ABB1E7F6BC600B4C1B1 /* Anaheim-Regular.ttf */; };\n7FB58AC01E7F6BD800B4C1B1 /* OpenSans-Regular.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 7FB58ABC1E7F6BC600B4C1B1 /* OpenSans-Regular.ttf */; };\n7FB58AC11E7F6BD900B4C1B1 /* OpenSans-Regular.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 7FB58ABC1E7F6BC600B4C1B1 /* OpenSans-Regular.ttf */; };\n7FB58AC21E7F6BDB00B4C1B1 /* OpenSans-Semibold.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 7FB58ABD1E7F6BC600B4C1B1 /* OpenSans-Semibold.ttf */; };\n7FB58AC31E7F6BDC00B4C1B1 /* OpenSans-Semibold.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 7FB58ABD1E7F6BC600B4C1B1 /* OpenSans-Semibold.ttf */; };\n- 7FF1293F20047B700051F874 /* libRNNotifications.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7FF1293E200475800051F874 /* libRNNotifications.a */; };\n7FF1294020047B8B0051F874 /* libRNVectorIcons.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7FB58ABA1E7F6B4400B4C1B1 /* libRNVectorIcons.a */; };\n7FF1294120047BAC0051F874 /* libRNKeychain.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7FEB2DEC1E8D64D200C4B763 /* libRNKeychain.a */; };\n832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 832341B51AAA6A8300B99B32 /* libRCTText.a */; };\nremoteGlobalIDString = 3D383D621EBD27B9005632C8;\nremoteInfo = \"double-conversion-tvOS\";\n};\n+ 7F5B10E82005349D00FE096A /* PBXContainerItemProxy */ = {\n+ isa = PBXContainerItemProxy;\n+ containerPortal = 143FA99006A442AFB7B24B3A /* RNNotifications.xcodeproj */;\n+ proxyType = 2;\n+ remoteGlobalIDString = 134814201AA4EA6300B7C361;\n+ remoteInfo = RNNotifications;\n+ };\n7FB58AB91E7F6B4400B4C1B1 /* PBXContainerItemProxy */ = {\nisa = PBXContainerItemProxy;\ncontainerPortal = C3BA31E561EB497494D7882F /* RNVectorIcons.xcodeproj */;\nremoteGlobalIDString = 5D82366F1B0CE05B005A9EF3;\nremoteInfo = RNKeychain;\n};\n- 7FF1293D200475800051F874 /* PBXContainerItemProxy */ = {\n- isa = PBXContainerItemProxy;\n- containerPortal = D274F1D31C1445999BE68CF4 /* RNNotifications.xcodeproj */;\n- proxyType = 2;\n- remoteGlobalIDString = 134814201AA4EA6300B7C361;\n- remoteInfo = RNNotifications;\n- };\n832341B41AAA6A8300B99B32 /* PBXContainerItemProxy */ = {\nisa = PBXContainerItemProxy;\ncontainerPortal = 832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */;\n13B07FB51A68108700A75B9A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = SquadCal/Images.xcassets; sourceTree = \"<group>\"; };\n13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = SquadCal/Info.plist; sourceTree = \"<group>\"; };\n13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = SquadCal/main.m; sourceTree = \"<group>\"; };\n+ 143FA99006A442AFB7B24B3A /* RNNotifications.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = \"wrapper.pb-project\"; name = RNNotifications.xcodeproj; path = \"../node_modules/react-native-notifications/RNNotifications/RNNotifications.xcodeproj\"; sourceTree = \"<group>\"; };\n146833FF1AC3E56700842450 /* React.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = \"wrapper.pb-project\"; name = React.xcodeproj; path = \"../node_modules/react-native/React/React.xcodeproj\"; sourceTree = \"<group>\"; };\n1E94F1BD692B4E6EBE1BFBFB /* Entypo.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = Entypo.ttf; path = \"../node_modules/react-native-vector-icons/Fonts/Entypo.ttf\"; sourceTree = \"<group>\"; };\n2D02E47B1E0B4A5D006451C7 /* SquadCal-tvOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = \"SquadCal-tvOS.app\"; sourceTree = BUILT_PRODUCTS_DIR; };\n95EEFC35D4D14053ACA7E064 /* RNKeychain.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = \"wrapper.pb-project\"; name = RNKeychain.xcodeproj; path = \"../node_modules/react-native-keychain/RNKeychain.xcodeproj\"; sourceTree = \"<group>\"; };\nAE31AFFF88FB4112A29ADE33 /* SimpleLineIcons.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = SimpleLineIcons.ttf; path = \"../node_modules/react-native-vector-icons/Fonts/SimpleLineIcons.ttf\"; sourceTree = \"<group>\"; };\nC3BA31E561EB497494D7882F /* RNVectorIcons.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = \"wrapper.pb-project\"; name = RNVectorIcons.xcodeproj; path = \"../node_modules/react-native-vector-icons/RNVectorIcons.xcodeproj\"; sourceTree = \"<group>\"; };\n- D274F1D31C1445999BE68CF4 /* RNNotifications.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = \"wrapper.pb-project\"; name = RNNotifications.xcodeproj; path = \"../node_modules/react-native-notifications/RNNotifications/RNNotifications.xcodeproj\"; sourceTree = \"<group>\"; };\nE4E90F44E9F4420080594671 /* MaterialIcons.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = MaterialIcons.ttf; path = \"../node_modules/react-native-vector-icons/Fonts/MaterialIcons.ttf\"; sourceTree = \"<group>\"; };\nE7D7D614C3184B1BB95EE661 /* OnePassword.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = \"wrapper.pb-project\"; name = OnePassword.xcodeproj; path = \"../node_modules/react-native-onepassword/OnePassword.xcodeproj\"; sourceTree = \"<group>\"; };\nEA40FBBA484449FAA8915A48 /* Foundation.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = Foundation.ttf; path = \"../node_modules/react-native-vector-icons/Fonts/Foundation.ttf\"; sourceTree = \"<group>\"; };\nisa = PBXFrameworksBuildPhase;\nbuildActionMask = 2147483647;\nfiles = (\n+ 7F5B10EA200534C300FE096A /* libRNNotifications.a in Frameworks */,\n7FF1294120047BAC0051F874 /* libRNKeychain.a in Frameworks */,\n7FF1294020047B8B0051F874 /* libRNVectorIcons.a in Frameworks */,\n- 7FF1293F20047B700051F874 /* libRNNotifications.a in Frameworks */,\n146834051AC3E58100842450 /* libReact.a in Frameworks */,\n5E9157361DD0AC6A00FF2AA8 /* libRCTAnimation.a in Frameworks */,\n00C302E51ABCBA2D00DB3ED1 /* libRCTActionSheet.a in Frameworks */,\nname = Products;\nsourceTree = \"<group>\";\n};\n+ 7F5B10C02005349C00FE096A /* Recovered References */ = {\n+ isa = PBXGroup;\n+ children = (\n+ );\n+ name = \"Recovered References\";\n+ sourceTree = \"<group>\";\n+ };\n+ 7F5B10E52005349D00FE096A /* Products */ = {\n+ isa = PBXGroup;\n+ children = (\n+ 7F5B10E92005349D00FE096A /* libRNNotifications.a */,\n+ );\n+ name = Products;\n+ sourceTree = \"<group>\";\n+ };\n7FB58A9D1E7F6B4300B4C1B1 /* Products */ = {\nisa = PBXGroup;\nchildren = (\nname = Frameworks;\nsourceTree = \"<group>\";\n};\n- 7FF1293A200475800051F874 /* Products */ = {\n- isa = PBXGroup;\n- children = (\n- 7FF1293E200475800051F874 /* libRNNotifications.a */,\n- );\n- name = Products;\n- sourceTree = \"<group>\";\n- };\n832341AE1AAA6A7D00B99B32 /* Libraries */ = {\nisa = PBXGroup;\nchildren = (\nC3BA31E561EB497494D7882F /* RNVectorIcons.xcodeproj */,\nE7D7D614C3184B1BB95EE661 /* OnePassword.xcodeproj */,\n95EEFC35D4D14053ACA7E064 /* RNKeychain.xcodeproj */,\n- D274F1D31C1445999BE68CF4 /* RNNotifications.xcodeproj */,\n+ 143FA99006A442AFB7B24B3A /* RNNotifications.xcodeproj */,\n);\nname = Libraries;\nsourceTree = \"<group>\";\n83CBBA001A601CBA00E9B192 /* Products */,\n6534411766BE4CA4B0AB0A78 /* Resources */,\n7FF0870B1E833C3F000A1ACF /* Frameworks */,\n+ 7F5B10C02005349C00FE096A /* Recovered References */,\n);\nindentWidth = 2;\nsourceTree = \"<group>\";\nProjectRef = 95EEFC35D4D14053ACA7E064 /* RNKeychain.xcodeproj */;\n},\n{\n- ProductGroup = 7FF1293A200475800051F874 /* Products */;\n- ProjectRef = D274F1D31C1445999BE68CF4 /* RNNotifications.xcodeproj */;\n+ ProductGroup = 7F5B10E52005349D00FE096A /* Products */;\n+ ProjectRef = 143FA99006A442AFB7B24B3A /* RNNotifications.xcodeproj */;\n},\n{\nProductGroup = 7FB58A9D1E7F6B4300B4C1B1 /* Products */;\nremoteRef = 7F474C831F833FCA00B71135 /* PBXContainerItemProxy */;\nsourceTree = BUILT_PRODUCTS_DIR;\n};\n+ 7F5B10E92005349D00FE096A /* libRNNotifications.a */ = {\n+ isa = PBXReferenceProxy;\n+ fileType = archive.ar;\n+ path = libRNNotifications.a;\n+ remoteRef = 7F5B10E82005349D00FE096A /* PBXContainerItemProxy */;\n+ sourceTree = BUILT_PRODUCTS_DIR;\n+ };\n7FB58ABA1E7F6B4400B4C1B1 /* libRNVectorIcons.a */ = {\nisa = PBXReferenceProxy;\nfileType = archive.ar;\nremoteRef = 7FEB2DEB1E8D64D200C4B763 /* PBXContainerItemProxy */;\nsourceTree = BUILT_PRODUCTS_DIR;\n};\n- 7FF1293E200475800051F874 /* libRNNotifications.a */ = {\n- isa = PBXReferenceProxy;\n- fileType = archive.ar;\n- path = libRNNotifications.a;\n- remoteRef = 7FF1293D200475800051F874 /* PBXContainerItemProxy */;\n- sourceTree = BUILT_PRODUCTS_DIR;\n- };\n832341B51AAA6A8300B99B32 /* libRCTText.a */ = {\nisa = PBXReferenceProxy;\nfileType = archive.ar;\n\"$(SRCROOT)/../node_modules/react-native-onepassword\",\n\"$(SRCROOT)/../node_modules/react-native-keychain/RNKeychainManager\",\n\"$(SRCROOT)/../node_modules/react-native-notifications/RNNotifications\",\n+ \"$(SRCROOT)/../node_modules/react-native-notifications/RNNotifications\",\n);\nINFOPLIST_FILE = SquadCalTests/Info.plist;\nIPHONEOS_DEPLOYMENT_TARGET = 8.0;\nLIBRARY_SEARCH_PATHS = (\n\"$(inherited)\",\n\"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n+ \"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n);\nOTHER_LDFLAGS = (\n\"-ObjC\",\n\"$(SRCROOT)/../node_modules/react-native-onepassword\",\n\"$(SRCROOT)/../node_modules/react-native-keychain/RNKeychainManager\",\n\"$(SRCROOT)/../node_modules/react-native-notifications/RNNotifications\",\n+ \"$(SRCROOT)/../node_modules/react-native-notifications/RNNotifications\",\n);\nINFOPLIST_FILE = SquadCalTests/Info.plist;\nIPHONEOS_DEPLOYMENT_TARGET = 8.0;\nLIBRARY_SEARCH_PATHS = (\n\"$(inherited)\",\n\"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n+ \"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n);\nOTHER_LDFLAGS = (\n\"-ObjC\",\n\"$(SRCROOT)/../node_modules/react-native/Libraries/LinkingIOS\",\n\"$(SRCROOT)/../node_modules/react-native-keychain/RNKeychainManager\",\n\"$(SRCROOT)/../node_modules/react-native-notifications/RNNotifications\",\n+ \"$(SRCROOT)/../node_modules/react-native-notifications/RNNotifications\",\n);\nINFOPLIST_FILE = SquadCal/Info.plist;\nLD_RUNPATH_SEARCH_PATHS = \"$(inherited) @executable_path/Frameworks\";\n\"$(SRCROOT)/../node_modules/react-native/Libraries/LinkingIOS\",\n\"$(SRCROOT)/../node_modules/react-native-keychain/RNKeychainManager\",\n\"$(SRCROOT)/../node_modules/react-native-notifications/RNNotifications\",\n+ \"$(SRCROOT)/../node_modules/react-native-notifications/RNNotifications\",\n);\nINFOPLIST_FILE = SquadCal/Info.plist;\nLD_RUNPATH_SEARCH_PATHS = \"$(inherited) @executable_path/Frameworks\";\n\"$(SRCROOT)/../node_modules/react-native-onepassword\",\n\"$(SRCROOT)/../node_modules/react-native-keychain/RNKeychainManager\",\n\"$(SRCROOT)/../node_modules/react-native-notifications/RNNotifications\",\n+ \"$(SRCROOT)/../node_modules/react-native-notifications/RNNotifications\",\n);\nINFOPLIST_FILE = \"SquadCal-tvOS/Info.plist\";\nLD_RUNPATH_SEARCH_PATHS = \"$(inherited) @executable_path/Frameworks\";\nLIBRARY_SEARCH_PATHS = (\n\"$(inherited)\",\n\"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n+ \"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n);\nOTHER_LDFLAGS = (\n\"-ObjC\",\n\"$(SRCROOT)/../node_modules/react-native-onepassword\",\n\"$(SRCROOT)/../node_modules/react-native-keychain/RNKeychainManager\",\n\"$(SRCROOT)/../node_modules/react-native-notifications/RNNotifications\",\n+ \"$(SRCROOT)/../node_modules/react-native-notifications/RNNotifications\",\n);\nINFOPLIST_FILE = \"SquadCal-tvOS/Info.plist\";\nLD_RUNPATH_SEARCH_PATHS = \"$(inherited) @executable_path/Frameworks\";\nLIBRARY_SEARCH_PATHS = (\n\"$(inherited)\",\n\"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n+ \"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n);\nOTHER_LDFLAGS = (\n\"-ObjC\",\nLIBRARY_SEARCH_PATHS = (\n\"$(inherited)\",\n\"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n+ \"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n);\nPRODUCT_BUNDLE_IDENTIFIER = \"com.facebook.REACT.SquadCal-tvOSTests\";\nPRODUCT_NAME = \"$(TARGET_NAME)\";\nLIBRARY_SEARCH_PATHS = (\n\"$(inherited)\",\n\"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n+ \"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n);\nPRODUCT_BUNDLE_IDENTIFIER = \"com.facebook.REACT.SquadCal-tvOSTests\";\nPRODUCT_NAME = \"$(TARGET_NAME)\";\n" }, { "change_type": "MODIFY", "old_path": "native/ios/SquadCal/AppDelegate.m", "new_path": "native/ios/SquadCal/AppDelegate.m", "diff": "[RNNotifications didFailToRegisterForRemoteNotificationsWithError:error];\n}\n-// Required for the notification event.\n-- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)notification {\n- [RNNotifications didReceiveRemoteNotification:notification];\n+// Required for the notification event. You must call the completion handler after handling the remote notification.\n+- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)notification\n+ fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler\n+{\n+ [RNNotifications didReceiveRemoteNotification:notification fetchCompletionHandler:completionHandler];\n}\n// Required for the localNotification event.\n" }, { "change_type": "MODIFY", "old_path": "native/package-lock.json", "new_path": "native/package-lock.json", "diff": "}\n},\n\"react-native-notifications\": {\n- \"version\": \"git+https://git@github.com/ashoat/react-native-notifications.git#f913ad5f8ed644bb0567eaf1e6e8c75ef0326198\",\n+ \"version\": \"git+https://git@github.com/ashoat/react-native-notifications.git#d30e8c9c129fa397c305e364b5c6c5e2996ee24c\",\n\"requires\": {\n\"core-js\": \"1.2.7\",\n\"uuid\": \"2.0.3\"\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Update to call completionHandler after processing remote notification Also a bugfix where iOS notifs weren't being saved to the database and adding the uniqueID to the payload of the remote notification.
129,187
10.01.2018 00:28:36
18,000
ad76def7e7691ae24e338aa35a19e4febc309518
Use newer way of asking for permissions
[ { "change_type": "MODIFY", "old_path": "native/ios/SquadCal/AppDelegate.m", "new_path": "native/ios/SquadCal/AppDelegate.m", "diff": "restorationHandler:restorationHandler];\n}\n-// Required to register for notifications\n-- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings\n-{\n- [RNNotifications didRegisterUserNotificationSettings:notificationSettings];\n-}\n-\n- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken\n{\n[RNNotifications didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];\n" }, { "change_type": "MODIFY", "old_path": "native/package-lock.json", "new_path": "native/package-lock.json", "diff": "}\n},\n\"react-native-notifications\": {\n- \"version\": \"git+https://git@github.com/ashoat/react-native-notifications.git#d30e8c9c129fa397c305e364b5c6c5e2996ee24c\",\n+ \"version\": \"git+https://git@github.com/ashoat/react-native-notifications.git#add685dcc5b3e98104766ef69ba92821f49801eb\",\n\"requires\": {\n\"core-js\": \"1.2.7\",\n\"uuid\": \"2.0.3\"\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Use newer way of asking for permissions
129,187
10.01.2018 14:15:30
18,000
d56e7968ef433178a5c180f6fa84190a294fae88
Install react-native-fcm for Android notifications
[ { "change_type": "MODIFY", "old_path": "native/android/app/build.gradle", "new_path": "native/android/app/build.gradle", "diff": "apply plugin: \"com.android.application\"\n+apply plugin: 'com.google.gms.google-services'\nimport com.android.build.OutputFile\n@@ -133,7 +134,8 @@ android {\n}\ndependencies {\n- compile project(':react-native-notifications')\n+ compile project(':react-native-fcm')\n+ compile 'com.google.firebase:firebase-core:10.0.1' //this decides your firebase SDK version\ncompile project(':react-native-vector-icons')\ncompile project(':react-native-keychain')\ncompile fileTree(dir: \"libs\", include: [\"*.jar\"])\n" }, { "change_type": "ADD", "old_path": null, "new_path": "native/android/app/google-services.json", "diff": "+{\n+ \"project_info\": {\n+ \"project_number\": \"112225499479\",\n+ \"firebase_url\": \"https://squadcal0.firebaseio.com\",\n+ \"project_id\": \"squadcal0\",\n+ \"storage_bucket\": \"squadcal0.appspot.com\"\n+ },\n+ \"client\": [\n+ {\n+ \"client_info\": {\n+ \"mobilesdk_app_id\": \"1:112225499479:android:3ec8c4b5ce66e4d6\",\n+ \"android_client_info\": {\n+ \"package_name\": \"org.squadcal\"\n+ }\n+ },\n+ \"oauth_client\": [\n+ {\n+ \"client_id\": \"112225499479-96n7hrmcd0p6jrtneq0a9jln2r89njlf.apps.googleusercontent.com\",\n+ \"client_type\": 1,\n+ \"android_info\": {\n+ \"package_name\": \"org.squadcal\",\n+ \"certificate_hash\": \"f59f960eeb4350d6d1999acaffb04ad797c5aa9a\"\n+ }\n+ },\n+ {\n+ \"client_id\": \"112225499479-6o0pb12751igpglor28h4p3ankmulbpr.apps.googleusercontent.com\",\n+ \"client_type\": 3\n+ }\n+ ],\n+ \"api_key\": [\n+ {\n+ \"current_key\": \"AIzaSyCeKcy0v3rXSqdjixW93kgNVZvGx09CJMc\"\n+ }\n+ ],\n+ \"services\": {\n+ \"analytics_service\": {\n+ \"status\": 1\n+ },\n+ \"appinvite_service\": {\n+ \"status\": 2,\n+ \"other_platform_oauth_client\": [\n+ {\n+ \"client_id\": \"112225499479-6o0pb12751igpglor28h4p3ankmulbpr.apps.googleusercontent.com\",\n+ \"client_type\": 3\n+ }\n+ ]\n+ },\n+ \"ads_service\": {\n+ \"status\": 2\n+ }\n+ }\n+ }\n+ ],\n+ \"configuration_version\": \"1\"\n+}\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "native/android/app/src/main/AndroidManifest.xml", "new_path": "native/android/app/src/main/AndroidManifest.xml", "diff": "</intent-filter>\n</activity>\n<activity android:name=\"com.facebook.react.devsupport.DevSettingsActivity\" />\n+ <service android:name=\"com.evollu.react.fcm.MessagingService\" android:enabled=\"true\" android:exported=\"true\">\n+ <intent-filter>\n+ <action android:name=\"com.google.firebase.MESSAGING_EVENT\"/>\n+ </intent-filter>\n+ </service>\n+ <service android:name=\"com.evollu.react.fcm.InstanceIdService\" android:exported=\"false\">\n+ <intent-filter>\n+ <action android:name=\"com.google.firebase.INSTANCE_ID_EVENT\"/>\n+ </intent-filter>\n+ </service>\n</application>\n</manifest>\n" }, { "change_type": "MODIFY", "old_path": "native/android/app/src/main/java/org/squadcal/MainApplication.java", "new_path": "native/android/app/src/main/java/org/squadcal/MainApplication.java", "diff": "@@ -3,7 +3,7 @@ package org.squadcal;\nimport android.app.Application;\nimport com.facebook.react.ReactApplication;\n-import com.wix.reactnativenotifications.RNNotificationsPackage;\n+import com.evollu.react.fcm.FIRMessagingPackage;\nimport com.oblador.vectoricons.VectorIconsPackage;\nimport com.oblador.keychain.KeychainPackage;\nimport com.facebook.react.ReactNativeHost;\n@@ -26,7 +26,7 @@ public class MainApplication extends Application implements ReactApplication {\nprotected List<ReactPackage> getPackages() {\nreturn Arrays.<ReactPackage>asList(\nnew MainReactPackage(),\n- new RNNotificationsPackage(MainApplication.this),\n+ new FIRMessagingPackage(),\nnew VectorIconsPackage(),\nnew KeychainPackage()\n);\n" }, { "change_type": "MODIFY", "old_path": "native/android/build.gradle", "new_path": "native/android/build.gradle", "diff": "@@ -6,6 +6,7 @@ buildscript {\n}\ndependencies {\nclasspath 'com.android.tools.build:gradle:2.2.3'\n+ classpath 'com.google.gms:google-services:3.0.0'\n// NOTE: Do not place your application dependencies here; they belong\n// in the individual module build.gradle files\n" }, { "change_type": "MODIFY", "old_path": "native/android/settings.gradle", "new_path": "native/android/settings.gradle", "diff": "rootProject.name = 'SquadCal'\n-include ':react-native-notifications'\n-project(':react-native-notifications').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-notifications/android')\n+include ':react-native-fcm'\n+project(':react-native-fcm').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fcm/android')\ninclude ':react-native-vector-icons'\nproject(':react-native-vector-icons').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-vector-icons/android')\ninclude ':react-native-keychain'\n" }, { "change_type": "MODIFY", "old_path": "native/package-lock.json", "new_path": "native/package-lock.json", "diff": "\"react-native-drawer-layout\": \"1.3.2\"\n}\n},\n+ \"react-native-fcm\": {\n+ \"version\": \"11.2.0\",\n+ \"resolved\": \"https://registry.npmjs.org/react-native-fcm/-/react-native-fcm-11.2.0.tgz\",\n+ \"integrity\": \"sha512-o7KxIsTjAti387hMgFbKnnSnP8OjMAJQkkAbHIcG5qBuJRsD5WfITxfsQHGfscQIEAO4TSF4SAkkRkFo2DXlag==\"\n+ },\n\"react-native-in-app-notification\": {\n\"version\": \"2.1.0\",\n\"resolved\": \"https://registry.npmjs.org/react-native-in-app-notification/-/react-native-in-app-notification-2.1.0.tgz\",\n" }, { "change_type": "MODIFY", "old_path": "native/package.json", "new_path": "native/package.json", "diff": "\"lib\": \"file:../lib\",\n\"react\": \"16.0.0\",\n\"react-native\": \"^0.51.0\",\n+ \"react-native-fcm\": \"^11.2.0\",\n\"react-native-in-app-notification\": \"^2.1.0\",\n\"react-native-keychain\": \"^1.2.1\",\n\"react-native-modal\": \"^4.0.0\",\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Install react-native-fcm for Android notifications
129,187
12.01.2018 18:10:16
18,000
174bf6f6c3988ed315dc070d48fe0115bcb23fd5
Use local notifs for Android and rescind notifs and update badge count correctly
[ { "change_type": "MODIFY", "old_path": "jserver/src/push/rescind.js", "new_path": "jserver/src/push/rescind.js", "diff": "@@ -5,7 +5,7 @@ import type { $Response, $Request } from 'express';\nimport apn from 'apn';\nimport { connect, SQL } from '../database';\n-import { apnPush, getUnreadCounts } from './utils';\n+import { apnPush, fcmPush, getUnreadCounts } from './utils';\ntype PushRescindInfo = {\nuserID: string,\n@@ -32,7 +32,7 @@ async function rescindPushNotifs(req: $Request, res: $Response) {\nconst promises = [];\nconst rescindedIDs = [];\nfor (let row of fetchResult) {\n- if (row.delivery.iosIdentifier) {\n+ if (row.delivery.iosID) {\nconst notification = new apn.Notification();\nnotification.contentAvailable = true;\nnotification.badge = unreadCounts[userID];\n@@ -40,7 +40,7 @@ async function rescindPushNotifs(req: $Request, res: $Response) {\nnotification.payload = {\nmanagedAps: {\naction: \"CLEAR\",\n- notificationId: row.delivery.iosIdentifier,\n+ notificationId: row.delivery.iosID,\n},\n};\npromises.push(apnPush(\n@@ -49,6 +49,19 @@ async function rescindPushNotifs(req: $Request, res: $Response) {\nrow.id,\n));\n}\n+ if (row.delivery.androidID) {\n+ const notification = {\n+ data: {\n+ rescind: \"true\",\n+ dbID: row.id.toString(),\n+ },\n+ };\n+ promises.push(fcmPush(\n+ notification,\n+ row.delivery.androidDeviceTokens,\n+ row.id,\n+ ));\n+ }\nrescindedIDs.push(row.id);\n}\nif (rescindedIDs.length > 0) {\n" }, { "change_type": "MODIFY", "old_path": "jserver/src/push/send.js", "new_path": "jserver/src/push/send.js", "diff": "@@ -72,13 +72,14 @@ async function sendPushNotifs(req: $Request, res: $Response) {\n);\ndeliveryPromises.push(apnPush(notification, byDeviceType.ios, dbID));\ndelivery.iosDeviceTokens = byDeviceType.ios;\n- delivery.iosIdentifier = notification.id;\n+ delivery.iosID = notification.id;\n}\nif (byDeviceType.android) {\nconst notification = prepareAndroidNotification(\nmessageInfo,\nthreadInfo,\nunreadCounts[userID],\n+ dbID,\n);\ndeliveryPromises.push(fcmPush(\nnotification,\n@@ -104,13 +105,17 @@ async function sendPushNotifs(req: $Request, res: $Response) {\ndbPromises.push(conn.query(query));\n}\n- const [ apnResults ] = await Promise.all([\n+ const [ deliveryResults ] = await Promise.all([\nPromise.all(deliveryPromises),\nPromise.all(dbPromises),\n]);\n- for (let apnResult of apnResults) {\n- if (apnResult.error) {\n- notifications[apnResult.dbID][4].error = apnResult.error;\n+ for (let deliveryResult of deliveryResults) {\n+ if (deliveryResult.errors) {\n+ notifications[deliveryResult.dbID][4].errors = deliveryResult.errors;\n+ }\n+ if (deliveryResult.fcmIDs) {\n+ notifications[deliveryResult.dbID][4].androidID =\n+ deliveryResult.fcmIDs[0];\n}\n}\n@@ -258,15 +263,15 @@ function prepareAndroidNotification(\nmessageInfo: MessageInfo,\nthreadInfo: ThreadInfo,\nunreadCount: number,\n+ dbID: string,\n): Object {\nconst notifText = notifTextForMessageInfo(messageInfo, threadInfo);\nreturn {\n- notification: {\n- body: notifText,\n- },\ndata: {\n+ notifBody: notifText,\nbadgeCount: unreadCount.toString(),\nthreadID: messageInfo.threadID,\n+ dbID,\n},\n};\n}\n" }, { "change_type": "MODIFY", "old_path": "jserver/src/push/utils.js", "new_path": "jserver/src/push/utils.js", "diff": "@@ -20,8 +20,12 @@ async function apnPush(\ndbID: string,\n) {\nconst result = await apnProvider.send(notification, deviceTokens);\n+ const errors = [];\nfor (let failure of result.failed) {\n- return { error: failure, dbID };\n+ errors.push(failure);\n+ }\n+ if (errors.length > 0) {\n+ return { errors, dbID };\n}\nreturn { success: true, dbID };\n}\n@@ -32,15 +36,31 @@ async function fcmPush(\ndbID: string,\n) {\ntry {\n- const result = await fcmAdmin.messaging().sendToDevice(\n+ const deliveryResult = await fcmAdmin.messaging().sendToDevice(\ndeviceTokens,\nnotification,\n);\n- console.log(result);\n- return { success: true, dbID, result };\n+ const errors = [];\n+ const ids = [];\n+ for (let fcmResult of deliveryResult.results) {\n+ if (fcmResult.error) {\n+ errors.push(fcmResult.error);\n+ } else if (fcmResult.messageId) {\n+ ids.push(fcmResult.messageId);\n+ }\n+ }\n+ const result: Object = { dbID };\n+ if (ids.length > 0) {\n+ result.fcmIDs = ids;\n+ }\n+ if (errors.length > 0) {\n+ result.errors = errors;\n+ } else {\n+ result.success = true;\n+ }\n+ return result;\n} catch (e) {\n- console.log(e);\n- return { error: e, dbID };\n+ return { errors: [ e ], dbID };\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "native/app.react.js", "new_path": "native/app.react.js", "diff": "@@ -75,7 +75,11 @@ import {\ncreateIsForegroundSelector,\n} from './selectors/nav-selectors';\nimport { requestIOSPushPermissions } from './push/ios';\n-import { requestAndroidPushPermissions } from './push/android';\n+import {\n+ requestAndroidPushPermissions,\n+ recordAndroidNotificationActionType,\n+ clearAndroidNotificationActionType,\n+} from './push/android';\nimport NotificationBody from './push/notification-body.react';\nlet urlPrefix;\n@@ -200,7 +204,6 @@ class AppWithNavigationState extends React.PureComponent<Props> {\n\"notificationOpened\",\nthis.iosNotificationOpened,\n);\n- AppWithNavigationState.updateBadgeCount(this.props.unreadCount);\n} else if (Platform.OS === \"android\") {\nthis.androidNotifListener = FCM.on(\nFCMEvent.Notification,\n@@ -210,24 +213,35 @@ class AppWithNavigationState extends React.PureComponent<Props> {\nFCMEvent.RefreshToken,\nthis.registerPushPermissionsAndHandleInitialNotif,\n);\n- FCM.setBadgeNumber(this.props.unreadCount);\n}\n+ AppWithNavigationState.updateBadgeCount(this.props.unreadCount);\n}\nstatic updateBadgeCount(unreadCount: number) {\nif (Platform.OS === \"ios\") {\nNotificationsIOS.setBadgesCount(unreadCount);\n+ } else if (Platform.OS === \"android\") {\n+ FCM.setBadgeNumber(unreadCount);\n}\n}\n- static clearIOSNotifsOfThread(threadID: string) {\n+ static clearNotifsOfThread(props: Props) {\n+ const activeThread = props.activeThread;\n+ invariant(activeThread, \"activeThread should be set\");\n+ if (Platform.OS === \"ios\") {\nNotificationsIOS.getDeliveredNotifications(\n(notifications) =>\nAppWithNavigationState.clearDeliveredIOSNotificationsForThread(\n- threadID,\n+ activeThread,\nnotifications,\n),\n);\n+ } else if (Platform.OS === \"android\") {\n+ props.dispatchActionPayload(\n+ clearAndroidNotificationActionType,\n+ { threadID: activeThread },\n+ );\n+ }\n}\nstatic clearDeliveredIOSNotificationsForThread(\n@@ -317,14 +331,10 @@ class AppWithNavigationState extends React.PureComponent<Props> {\nnull,\n);\nthis.ensurePushNotifsEnabled();\n- if (Platform.OS === \"ios\") {\n- AppWithNavigationState.updateBadgeCount(this.props.unreadCount);\nif (this.props.activeThread) {\n- AppWithNavigationState.clearIOSNotifsOfThread(\n- this.props.activeThread,\n- );\n- }\n+ AppWithNavigationState.clearNotifsOfThread(this.props);\n}\n+ AppWithNavigationState.updateBadgeCount(this.props.unreadCount);\n} else if (\nlastState === \"active\" &&\nthis.currentState &&\n@@ -353,16 +363,14 @@ class AppWithNavigationState extends React.PureComponent<Props> {\nif (justLoggedIn) {\nthis.ensurePushNotifsEnabled();\n}\n- if (Platform.OS === \"ios\") {\nconst nextActiveThread = nextProps.activeThread;\nif (nextActiveThread && nextActiveThread !== this.props.activeThread) {\n- AppWithNavigationState.clearIOSNotifsOfThread(nextActiveThread);\n+ AppWithNavigationState.clearNotifsOfThread(nextProps);\n}\nif (nextProps.unreadCount !== this.props.unreadCount) {\nAppWithNavigationState.updateBadgeCount(nextProps.unreadCount);\n}\n}\n- }\nasync ensurePushNotifsEnabled() {\nif (Platform.OS === \"ios\") {\n@@ -386,7 +394,7 @@ class AppWithNavigationState extends React.PureComponent<Props> {\n}\nif (token) {\nawait this.registerPushPermissionsAndHandleInitialNotif(token);\n- } else {\n+ } else if (missingDeviceToken) {\nthis.failedToRegisterPushPermissions();\n}\n}\n@@ -480,11 +488,12 @@ class AppWithNavigationState extends React.PureComponent<Props> {\nandroidNotificationReceived = async (notification) => {\nif (notification.badgeCount) {\n- FCM.setBadgeNumber(parseInt(notification.badgeCount));\n+ AppWithNavigationState.updateBadgeCount(\n+ parseInt(notification.badgeCount),\n+ );\n}\nif (\n- notification.fcm &&\n- notification.fcm.body &&\n+ notification.notifBody &&\nthis.currentState === \"active\"\n) {\nconst threadID = notification.threadID;\n@@ -494,9 +503,26 @@ class AppWithNavigationState extends React.PureComponent<Props> {\n}\ninvariant(this.inAppNotification, \"should be set\");\nthis.inAppNotification.show({\n- message: notification.fcm.body,\n+ message: notification.notifBody,\nonPress: () => this.onPressNotificationForThread(threadID, false),\n});\n+ } else if (notification.notifBody) {\n+ FCM.presentLocalNotification({\n+ id: notification.dbID,\n+ body: notification.notifBody,\n+ priority: \"high\",\n+ sound: \"default\",\n+ });\n+ this.props.dispatchActionPayload(\n+ recordAndroidNotificationActionType,\n+ {\n+ threadID: notification.threadID,\n+ notifDBID: notification.dbID,\n+ },\n+ );\n+ }\n+ if (notification.rescind) {\n+ FCM.removeDeliveredNotification(notification.dbID);\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "native/navigation-setup.js", "new_path": "native/navigation-setup.js", "diff": "@@ -15,6 +15,7 @@ import type { AppState } from './redux-setup';\nimport type { SetCookiePayload } from 'lib/utils/action-utils';\nimport type { LeaveThreadResult } from 'lib/actions/thread-actions';\nimport type { NotificationPressPayload } from 'lib/shared/notif-utils';\n+import type { AndroidNotificationActions } from './push/android';\nimport {\nTabNavigator,\n@@ -88,10 +89,15 @@ function _getUuid() {\nreturn `${uniqueBaseId}-${uuidCount++}`;\n}\n-export type Action = BaseAction |\n- NavigationAction |\n- {| type: typeof handleURLActionType, payload: string |} |\n- {| type: typeof navigateToAppActionType, payload: null |};\n+export type Action =\n+ | BaseAction\n+ | NavigationAction\n+ | {| type: typeof handleURLActionType, payload: string |}\n+ | {| type: typeof navigateToAppActionType, payload: null |}\n+ | {|\n+ type: typeof notificationPressActionType,\n+ payload: NotificationPressPayload,\n+ |} | AndroidNotificationActions;\nconst AppNavigator = TabNavigator(\n{\n" }, { "change_type": "MODIFY", "old_path": "native/push/android.js", "new_path": "native/push/android.js", "diff": "@@ -15,6 +15,51 @@ async function requestAndroidPushPermissions(\nreturn token;\n}\n+const recordAndroidNotificationActionType = \"RECORD_ANDROID_NOTIFICATION\";\n+type RecordAndroidNotificationPayload = {|\n+ threadID: string,\n+ notifDBID: string,\n+|};\n+\n+const clearAndroidNotificationActionType = \"CLEAR_ANDROID_NOTIFICATION\";\n+type ClearAndroidNotificationPayload = {|\n+ threadID: string,\n+|};\n+\n+export type AndroidNotificationActions =\n+ | {|\n+ type: typeof recordAndroidNotificationActionType,\n+ payload: RecordAndroidNotificationPayload,\n+ |} | {|\n+ type: typeof clearAndroidNotificationActionType,\n+ payload: ClearAndroidNotificationPayload,\n+ |};\n+\n+function reduceThreadIDsToNotifDBIDs(\n+ state: {[threadID: string]: string[]},\n+ action: AndroidNotificationActions,\n+): {[threadID: string]: string[]} {\n+ if (action.type === recordAndroidNotificationActionType) {\n+ return {\n+ ...state,\n+ [action.payload.threadID]: [\n+ ...state[action.payload.threadID],\n+ action.payload.notifDBID,\n+ ],\n+ };\n+ } else if (action.type === clearAndroidNotificationActionType) {\n+ return {\n+ ...state,\n+ [action.payload.threadID]: [],\n+ };\n+ } else {\n+ return state;\n+ }\n+}\n+\nexport {\nrequestAndroidPushPermissions,\n+ recordAndroidNotificationActionType,\n+ clearAndroidNotificationActionType,\n+ reduceThreadIDsToNotifDBIDs,\n};\n" }, { "change_type": "MODIFY", "old_path": "native/redux-setup.js", "new_path": "native/redux-setup.js", "diff": "@@ -30,6 +30,11 @@ import {\ndefaultNavInfo,\nreduceNavInfo,\n} from './navigation-setup';\n+import {\n+ recordAndroidNotificationActionType,\n+ clearAndroidNotificationActionType,\n+ reduceThreadIDsToNotifDBIDs,\n+} from './push/android';\nexport type AppState = {|\nnavInfo: NavInfo,\n@@ -45,6 +50,7 @@ export type AppState = {|\nloadingStatuses: {[key: string]: {[idx: number]: LoadingStatus}},\ncookie: ?string,\ndeviceToken: ?string,\n+ threadIDsToNotifDBIDs: {[threadID: string]: string[]},\nrehydrateConcluded: bool,\n|};\n@@ -69,6 +75,7 @@ const defaultState = ({\nloadingStatuses: {},\ncookie: null,\ndeviceToken: null,\n+ threadIDsToNotifDBIDs: {},\nrehydrateConcluded: false,\n}: AppState);\n@@ -105,6 +112,7 @@ function reducer(state: AppState, action: *) {\nloadingStatuses: state.loadingStatuses,\ncookie: state.cookie,\ndeviceToken: state.deviceToken,\n+ threadIDsToNotifDBIDs: state.threadIDsToNotifDBIDs,\nrehydrateConcluded: state.rehydrateConcluded,\n};\n}\n@@ -123,9 +131,35 @@ function reducer(state: AppState, action: *) {\nloadingStatuses: state.loadingStatuses,\ncookie: state.cookie,\ndeviceToken: state.deviceToken,\n+ threadIDsToNotifDBIDs: state.threadIDsToNotifDBIDs,\nrehydrateConcluded: true,\n};\n}\n+ if (\n+ action.type === recordAndroidNotificationActionType ||\n+ action.type === clearAndroidNotificationActionType\n+ ) {\n+ return {\n+ navInfo: state.navInfo,\n+ currentUserInfo: state.currentUserInfo,\n+ sessionID: state.sessionID,\n+ entryStore: state.entryStore,\n+ lastUserInteraction: state.lastUserInteraction,\n+ threadInfos: state.threadInfos,\n+ userInfos: state.userInfos,\n+ messageStore: state.messageStore,\n+ drafts: state.drafts,\n+ currentAsOf: state.currentAsOf,\n+ loadingStatuses: state.loadingStatuses,\n+ cookie: state.cookie,\n+ deviceToken: state.deviceToken,\n+ threadIDsToNotifDBIDs: reduceThreadIDsToNotifDBIDs(\n+ state.threadIDsToNotifDBIDs,\n+ action.payload,\n+ ),\n+ rehydrateConcluded: state.rehydrateConcluded,\n+ };\n+ }\n// These action type are handled by reduceNavInfo above\nif (\naction.type === handleURLActionType ||\n@@ -170,6 +204,7 @@ function validateState(oldState: AppState, state: AppState): AppState {\nloadingStatuses: state.loadingStatuses,\ncookie: state.cookie,\ndeviceToken: state.deviceToken,\n+ threadIDsToNotifDBIDs: state.threadIDsToNotifDBIDs,\nrehydrateConcluded: state.rehydrateConcluded,\n};\n}\n@@ -198,6 +233,7 @@ function validateState(oldState: AppState, state: AppState): AppState {\nloadingStatuses: state.loadingStatuses,\ncookie: state.cookie,\ndeviceToken: state.deviceToken,\n+ threadIDsToNotifDBIDs: state.threadIDsToNotifDBIDs,\nrehydrateConcluded: state.rehydrateConcluded,\n};\n}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Use local notifs for Android and rescind notifs and update badge count correctly
129,187
15.01.2018 14:20:33
18,000
2febebdccde82a7f47d67ff0970385c5783e18dd
Get SectionFooter working on Dan's Android Note sure why `position: 'absolute'` works differently on his phone. Might have to do with the ancient version of Android (KitKat).
[ { "change_type": "MODIFY", "old_path": "native/calendar/section-footer.react.js", "new_path": "native/calendar/section-footer.react.js", "diff": "@@ -51,9 +51,9 @@ const styles = StyleSheet.create({\nsectionFooter: {\nbackgroundColor: 'white',\nheight: 40,\n+ alignItems: 'flex-start',\n},\naddButton: {\n- position: 'absolute',\nbackgroundColor: '#EEEEEE',\npaddingLeft: 10,\npaddingRight: 10,\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Get SectionFooter working on Dan's Android Note sure why `position: 'absolute'` works differently on his phone. Might have to do with the ancient version of Android (KitKat).
129,187
15.01.2018 15:37:50
18,000
a15109f5f92d491582bc500a01bee5cb7bfc70e4
Make log-in case insensitive ... and also fix a SQL injection vulnerability I somehow missed. Ouch.
[ { "change_type": "MODIFY", "old_path": "server/forgot_password.php", "new_path": "server/forgot_password.php", "diff": "@@ -12,12 +12,14 @@ if (!isset($_POST['username'])) {\n'error' => 'invalid_parameters',\n));\n}\n-$username = $_POST['username'];\n+$username = $conn->real_escape_string($_POST['username']);\n-$result = $conn->query(\n- \"SELECT id, username, email \".\n- \"FROM users WHERE username = '$username' OR email = '$username'\"\n-);\n+$query = <<<SQL\n+SELECT id, username, email\n+FROM users\n+WHERE LCASE(username) = LCASE('$username') OR LCASE(email) = LCASE('$username')\n+SQL;\n+$result = $conn->query($query);\n$user_row = $result->fetch_assoc();\nif (!$user_row) {\nasync_end(array(\n" }, { "change_type": "MODIFY", "old_path": "server/login.php", "new_path": "server/login.php", "diff": "@@ -26,10 +26,12 @@ if (\n));\n}\n-$result = $conn->query(\n- \"SELECT id, hash, username, email, email_verified \".\n- \"FROM users WHERE username = '$username' OR email = '$username'\"\n-);\n+$query = <<<SQL\n+SELECT id, hash, username, email, email_verified\n+FROM users\n+WHERE LCASE(username) = LCASE('$username') OR LCASE(email) = LCASE('$username')\n+SQL;\n+$result = $conn->query($query);\n$user_row = $result->fetch_assoc();\nif (!$user_row) {\nasync_end(array(\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Make log-in case insensitive ... and also fix a SQL injection vulnerability I somehow missed. Ouch.
129,187
16.01.2018 14:24:46
18,000
54a9776496446c5653d1d5978de82a199f025c90
Fix another weird MySQL sync error bug
[ { "change_type": "MODIFY", "old_path": "native/package.json", "new_path": "native/package.json", "diff": "\"scripts\": {\n\"start\": \"node node_modules/react-native/local-cli/cli.js start\",\n\"test\": \"jest\",\n- \"devtools\": \"react-devtools\"\n+ \"devtools\": \"react-devtools\",\n+ \"logfirebase\": \"adb shell logcat | grep -E -i 'FIRMessagingModule|firebase'\"\n},\n\"dependencies\": {\n\"babel-plugin-transform-remove-strict-mode\": \"0.0.2\",\n" }, { "change_type": "MODIFY", "old_path": "server/message_lib.php", "new_path": "server/message_lib.php", "diff": "@@ -485,6 +485,7 @@ function create_message_infos($new_message_infos) {\n$id_insert_query = <<<SQL\nINSERT INTO ids(table_name) VALUES {$id_insert_clause}\nSQL;\n+ $conn->next_result();\n$conn->query($id_insert_query);\n$id = $conn->insert_id - $num_new_messages + 1;\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Fix another weird MySQL sync error bug
129,187
16.01.2018 16:00:14
18,000
ad3739c3e79cdd2bf36fddbae48590b338b040cf
Allow emojis in thread names on native
[ { "change_type": "MODIFY", "old_path": "native/chat/add-thread.react.js", "new_path": "native/chat/add-thread.react.js", "diff": "@@ -240,7 +240,6 @@ class InnerAddThread extends React.PureComponent<Props, State> {\nautoFocus={true}\nautoCorrect={false}\nautoCapitalize=\"none\"\n- keyboardType=\"ascii-capable\"\nreturnKeyType=\"next\"\neditable={this.props.loadingStatus !== \"loading\"}\nunderlineColorAndroid=\"transparent\"\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Allow emojis in thread names on native
129,187
17.01.2018 17:37:35
18,000
96280034dbd7ac6e38dd04e1dd7f8f46e24156ba
Collapsing notifications
[ { "change_type": "MODIFY", "old_path": "jserver/src/database.js", "new_path": "jserver/src/database.js", "diff": "// @flow\n-import mysql from 'mysql2/promise';\n+import mysqlPromise from 'mysql2/promise';\n+import mysql from 'mysql2';\nimport SQL from 'sql-template-strings';\nimport dbConfig from '../secrets/db_config';\n+const SQLStatement = SQL.SQLStatement;\n+\nexport type QueryResult = [\nany[] & { insertId?: number },\nany[],\n@@ -16,10 +19,37 @@ export type Connection = {\n};\nasync function connect(): Promise<Connection> {\n- return await mysql.createConnection(dbConfig);\n+ return await mysqlPromise.createConnection(dbConfig);\n+}\n+\n+type SQLOrString = SQLStatement | string;\n+function appendSQLArray(\n+ sql: SQLStatement,\n+ sqlArray: SQLStatement[],\n+ delimeter: SQLOrString,\n+) {\n+ if (sqlArray.length === 0) {\n+ return sql;\n+ }\n+ const [ first, ...rest ] = sqlArray;\n+ sql.append(first);\n+ if (rest.length === 0) {\n+ return sql;\n+ }\n+ return rest.reduce(\n+ (prev: SQLStatement, curr: SQLStatement) =>\n+ prev.append(delimeter).append(curr),\n+ sql,\n+ );\n+}\n+\n+function rawSQL(statement: SQLStatement) {\n+ return mysql.format(statement.sql, ...statement.values);\n}\nexport {\nconnect,\nSQL,\n+ appendSQLArray,\n+ rawSQL,\n};\n" }, { "change_type": "ADD", "old_path": null, "new_path": "jserver/src/fetchers/message-fetcher.js", "diff": "+// @flow\n+\n+import type { Connection } from '../database';\n+import type { PushInfo } from '../push/send';\n+import type { UserInfo } from 'lib/types/user-types';\n+import type { RawMessageInfo } from 'lib/types/message-types';\n+\n+import invariant from 'invariant';\n+\n+import { notifCollapseKeyForRawMessageInfo } from 'lib/shared/notif-utils';\n+import { messageType } from 'lib/types/message-types';\n+import {\n+ assertVisibilityRules,\n+ assertEditRules,\n+ threadPermissions,\n+ visibilityRules,\n+} from 'lib/types/thread-types';\n+import { sortMessageInfoList } from 'lib/shared/message-utils';\n+\n+import { SQL, appendSQLArray, rawSQL } from '../database';\n+import { permissionHelper } from '../permissions/permissions';\n+\n+export type CollapsableNotifInfo = {|\n+ collapseKey: ?string,\n+ existingMessageInfos: RawMessageInfo[],\n+ newMessageInfos: RawMessageInfo[],\n+|};\n+export type FetchCollapsableNotifsResult = {|\n+ usersToCollapsableNotifInfo: { [userID: string]: CollapsableNotifInfo[] },\n+ userInfos: { [id: string]: UserInfo },\n+|};\n+\n+async function fetchCollapsableNotifs(\n+ conn: Connection,\n+ pushInfo: PushInfo,\n+): Promise<FetchCollapsableNotifsResult> {\n+ // First, we need to fetch any notifications that should be collapsed\n+ const usersToCollapseKeysToInfo = {};\n+ const usersToCollapsableNotifInfo = {};\n+ for (let userID in pushInfo) {\n+ usersToCollapseKeysToInfo[userID] = {};\n+ usersToCollapsableNotifInfo[userID] = [];\n+ for (let rawMessageInfo of pushInfo[userID].messageInfos) {\n+ const collapseKey = notifCollapseKeyForRawMessageInfo(rawMessageInfo);\n+ if (!collapseKey) {\n+ const collapsableNotifInfo = {\n+ collapseKey,\n+ existingMessageInfos: [],\n+ newMessageInfos: [ rawMessageInfo ],\n+ };\n+ usersToCollapsableNotifInfo[userID].push(collapsableNotifInfo);\n+ continue;\n+ }\n+ if (!usersToCollapseKeysToInfo[userID][collapseKey]) {\n+ usersToCollapseKeysToInfo[userID][collapseKey] = {\n+ collapseKey,\n+ existingMessageInfos: [],\n+ newMessageInfos: [],\n+ };\n+ }\n+ usersToCollapseKeysToInfo[userID][collapseKey].newMessageInfos.push(\n+ rawMessageInfo,\n+ );\n+ }\n+ }\n+\n+ const sqlTuples = [];\n+ for (let userID in usersToCollapseKeysToInfo) {\n+ const collapseKeysToInfo = usersToCollapseKeysToInfo[userID];\n+ for (let collapseKey in collapseKeysToInfo) {\n+ sqlTuples.push(\n+ SQL`(n.user = ${userID} AND n.collapse_key = ${collapseKey})`,\n+ );\n+ }\n+ }\n+\n+ if (sqlTuples.length === 0) {\n+ return { usersToCollapsableNotifInfo, userInfos: {} };\n+ }\n+\n+ const visPermissionExtractString = `$.${threadPermissions.VISIBLE}.value`;\n+ const collapseQuery = SQL`\n+ SELECT m.id, m.thread AS threadID, m.content, m.time, m.type,\n+ u.username AS creator, m.user AS creatorID,\n+ stm.permissions AS subthread_permissions,\n+ st.visibility_rules AS subthread_visibility_rules,\n+ st.edit_rules AS subthread_edit_rules, n.user, n.collapse_key\n+ FROM notifications n\n+ LEFT JOIN messages m ON m.id = n.message\n+ LEFT JOIN threads t ON t.id = m.thread\n+ LEFT JOIN memberships mm ON mm.thread = m.thread AND mm.user = n.user\n+ LEFT JOIN threads st\n+ ON m.type = ${messageType.CREATE_SUB_THREAD} AND st.id = m.content\n+ LEFT JOIN memberships stm\n+ ON m.type = ${messageType.CREATE_SUB_THREAD}\n+ AND stm.thread = m.content AND stm.user = n.user\n+ LEFT JOIN users u ON u.id = m.user\n+ WHERE\n+ (\n+ JSON_EXTRACT(mm.permissions, ${visPermissionExtractString}) IS TRUE\n+ OR t.visibility_rules = ${visibilityRules.OPEN}\n+ )\n+ AND n.rescinded = 0\n+ AND (\n+ `;\n+ appendSQLArray(collapseQuery, sqlTuples, \" OR \");\n+ collapseQuery.append(SQL`) ORDER BY m.time DESC`);\n+ const [ collapseResult ] = await conn.query(collapseQuery);\n+\n+ const userInfos = {};\n+ for (let row of collapseResult) {\n+ userInfos[row.creatorID] = { id: row.creatorID, username: row.creator };\n+ const rawMessageInfo = rawMessageInfoFromRow(row);\n+ if (rawMessageInfo) {\n+ const info = usersToCollapseKeysToInfo[row.user][row.collapse_key];\n+ info.existingMessageInfos.push(rawMessageInfo);\n+ }\n+ }\n+\n+ for (let userID in usersToCollapseKeysToInfo) {\n+ const collapseKeysToInfo = usersToCollapseKeysToInfo[userID];\n+ for (let collapseKey in collapseKeysToInfo) {\n+ const info = collapseKeysToInfo[collapseKey];\n+ usersToCollapsableNotifInfo[userID].push({\n+ collapseKey: info.collapseKey,\n+ existingMessageInfos: sortMessageInfoList(info.existingMessageInfos),\n+ newMessageInfos: sortMessageInfoList(info.newMessageInfos),\n+ });\n+ }\n+ }\n+\n+ return { usersToCollapsableNotifInfo, userInfos };\n+}\n+\n+function rawMessageInfoFromRow(row: Object): ?RawMessageInfo {\n+ const type = parseInt(row.type);\n+ if (type === messageType.TEXT) {\n+ return {\n+ id: row.id,\n+ threadID: row.threadID,\n+ time: parseInt(row.time),\n+ type,\n+ creatorID: row.creatorID,\n+ text: row.content,\n+ };\n+ } else if (type === messageType.CREATE_THREAD) {\n+ return {\n+ id: row.id,\n+ threadID: row.threadID,\n+ time: parseInt(row.time),\n+ type,\n+ creatorID: row.creatorID,\n+ initialThreadState: row.content,\n+ };\n+ } else if (type === messageType.ADD_MEMBERS) {\n+ return {\n+ id: row.id,\n+ threadID: row.threadID,\n+ time: parseInt(row.time),\n+ type,\n+ creatorID: row.creatorID,\n+ addedUserIDs: row.content,\n+ };\n+ } else if (type === messageType.CREATE_SUB_THREAD) {\n+ const subthreadPermissionInfo = {\n+ permissions: row.subthread_permissions,\n+ visibilityRules: assertVisibilityRules(row.subthread_visibility_rules),\n+ editRules: assertEditRules(row.subthread_edit_rules),\n+ };\n+ if (!permissionHelper(subthreadPermissionInfo, threadPermissions.KNOW_OF)) {\n+ return null;\n+ }\n+ return {\n+ id: row.id,\n+ threadID: row.threadID,\n+ time: parseInt(row.time),\n+ type,\n+ creatorID: row.creatorID,\n+ childThreadID: row.content,\n+ };\n+ } else if (type === messageType.CHANGE_SETTINGS) {\n+ const field = Object.keys(row.content)[0];\n+ return {\n+ id: row.id,\n+ threadID: row.threadID,\n+ time: parseInt(row.time),\n+ type,\n+ creatorID: row.creatorID,\n+ field,\n+ value: row.content[field],\n+ };\n+ } else if (type === messageType.REMOVE_MEMBERS) {\n+ return {\n+ id: row.id,\n+ threadID: row.threadID,\n+ time: parseInt(row.time),\n+ type,\n+ creatorID: row.creatorID,\n+ removedUserIDs: row.content,\n+ };\n+ } else if (type === messageType.CHANGE_ROLE) {\n+ return {\n+ id: row.id,\n+ threadID: row.threadID,\n+ time: parseInt(row.time),\n+ type,\n+ creatorID: row.creatorID,\n+ userIDs: row.content.userIDs,\n+ newRole: row.content.newRole,\n+ };\n+ } else if (type === messageType.LEAVE_THREAD) {\n+ return {\n+ id: row.id,\n+ threadID: row.threadID,\n+ time: parseInt(row.time),\n+ type: messageType.LEAVE_THREAD,\n+ creatorID: row.creatorID,\n+ };\n+ } else if (type === messageType.JOIN_THREAD) {\n+ return {\n+ id: row.id,\n+ threadID: row.threadID,\n+ time: parseInt(row.time),\n+ type: messageType.JOIN_THREAD,\n+ creatorID: row.creatorID,\n+ };\n+ } else if (type === messageType.CREATE_ENTRY) {\n+ return {\n+ id: row.id,\n+ threadID: row.threadID,\n+ time: parseInt(row.time),\n+ type: messageType.CREATE_ENTRY,\n+ creatorID: row.creatorID,\n+ entryID: row.content.entryID,\n+ date: row.content.date,\n+ text: row.content.text,\n+ };\n+ } else if (type === messageType.EDIT_ENTRY) {\n+ return {\n+ id: row.id,\n+ threadID: row.threadID,\n+ time: parseInt(row.time),\n+ type: messageType.EDIT_ENTRY,\n+ creatorID: row.creatorID,\n+ entryID: row.content.entryID,\n+ date: row.content.date,\n+ text: row.content.text,\n+ };\n+ } else {\n+ invariant(false, `unrecognized messageType ${type}`);\n+ }\n+}\n+\n+export {\n+ fetchCollapsableNotifs,\n+};\n" }, { "change_type": "MODIFY", "old_path": "jserver/src/push/send.js", "new_path": "jserver/src/push/send.js", "diff": "@@ -6,6 +6,10 @@ import type { UserInfo } from 'lib/types/user-types';\nimport type { RawThreadInfo, ThreadInfo } from 'lib/types/thread-types';\nimport type { Connection } from '../database';\nimport type { DeviceType } from 'lib/actions/device-actions';\n+import type {\n+ CollapsableNotifInfo,\n+ FetchCollapsableNotifsResult,\n+} from '../fetchers/message-fetcher';\nimport apn from 'apn';\nimport invariant from 'invariant';\n@@ -13,20 +17,24 @@ import uuidv4 from 'uuid/v4';\nimport { notifTextForMessageInfo } from 'lib/shared/notif-utils';\nimport { messageType } from 'lib/types/message-types';\n-import { createMessageInfo } from 'lib/shared/message-utils';\n+import {\n+ createMessageInfo,\n+ sortMessageInfoList,\n+} from 'lib/shared/message-utils';\nimport { rawThreadInfosToThreadInfos } from 'lib/selectors/thread-selectors';\nimport { connect, SQL } from '../database';\nimport { apnPush, fcmPush, getUnreadCounts } from './utils';\nimport { fetchThreadInfos } from '../fetchers/thread-fetcher';\nimport { fetchUserInfos } from '../fetchers/user-fetcher';\n+import { fetchCollapsableNotifs } from '../fetchers/message-fetcher';\ntype Device = { deviceType: DeviceType, deviceToken: string };\ntype PushUserInfo = {\ndevices: Device[],\nmessageInfos: RawMessageInfo[],\n};\n-type PushInfo = { [userID: string]: PushUserInfo };\n+export type PushInfo = { [userID: string]: PushUserInfo };\nasync function sendPushNotifs(req: $Request, res: $Response) {\nres.json({ success: true });\n@@ -39,7 +47,7 @@ async function sendPushNotifs(req: $Request, res: $Response) {\nconst conn = await connect();\nconst [\nunreadCounts,\n- { rawThreadInfos, userInfos },\n+ { usersToCollapsableNotifInfo, rawThreadInfos, userInfos },\ndbIDs,\n] = await Promise.all([\ngetUnreadCounts(conn, Object.keys(pushInfo)),\n@@ -49,31 +57,46 @@ async function sendPushNotifs(req: $Request, res: $Response) {\nconst deliveryPromises = [];\nconst notifications = {};\n- for (let userID in pushInfo) {\n+ for (let userID in usersToCollapsableNotifInfo) {\nconst threadInfos = rawThreadInfosToThreadInfos(\nrawThreadInfos,\nuserID,\nuserInfos,\n);\n- for (let rawMessageInfo of pushInfo[userID].messageInfos) {\n- const messageInfo = createMessageInfo(\n+ for (let notifInfo of usersToCollapsableNotifInfo[userID]) {\n+ const hydrateMessageInfo =\n+ (rawMessageInfo: RawMessageInfo) => createMessageInfo(\nrawMessageInfo,\nuserID,\nuserInfos,\nthreadInfos,\n);\n- if (!messageInfo) {\n+ const newMessageInfos = notifInfo.newMessageInfos.map(\n+ hydrateMessageInfo,\n+ ).filter(Boolean);\n+ if (newMessageInfos.length === 0) {\ncontinue;\n}\n- const threadInfo = threadInfos[messageInfo.threadID];\n+ const existingMessageInfos = notifInfo.existingMessageInfos.map(\n+ hydrateMessageInfo,\n+ ).filter(Boolean);\n+ const allMessageInfos = sortMessageInfoList(\n+ [ ...newMessageInfos, ...existingMessageInfos ],\n+ );\n+ const [ firstNewMessageInfo, ...remainingNewMessageInfos ] =\n+ newMessageInfos;\n+ const threadID = firstNewMessageInfo.threadID;\n+\n+ const threadInfo = threadInfos[threadID];\nconst dbID = dbIDs.shift();\ninvariant(dbID, \"should have sufficient DB IDs\");\nconst byDeviceType = getDevicesByDeviceType(pushInfo[userID].devices);\nconst delivery = {};\nif (byDeviceType.ios) {\nconst notification = prepareIOSNotification(\n- messageInfo,\n+ allMessageInfos,\nthreadInfo,\n+ notifInfo.collapseKey,\nunreadCounts[userID],\n);\ndeliveryPromises.push(apnPush(notification, byDeviceType.ios, dbID));\n@@ -82,8 +105,9 @@ async function sendPushNotifs(req: $Request, res: $Response) {\n}\nif (byDeviceType.android) {\nconst notification = prepareAndroidNotification(\n- messageInfo,\n+ allMessageInfos,\nthreadInfo,\n+ notifInfo.collapseKey,\nunreadCounts[userID],\ndbID,\n);\n@@ -94,14 +118,29 @@ async function sendPushNotifs(req: $Request, res: $Response) {\n));\ndelivery.androidDeviceTokens = byDeviceType.android;\n}\n+\nnotifications[dbID] = [\ndbID,\nuserID,\n- messageInfo.threadID,\n- messageInfo.id,\n+ threadID,\n+ firstNewMessageInfo.id,\n+ notifInfo.collapseKey,\ndelivery,\n0,\n];\n+ for (let newMessageInfo of remainingNewMessageInfos) {\n+ const newDBID = dbIDs.shift();\n+ invariant(newDBID, \"should have sufficient DB IDs\");\n+ notifications[newDBID] = [\n+ newDBID,\n+ userID,\n+ newMessageInfo.threadID,\n+ newMessageInfo.id,\n+ notifInfo.collapseKey,\n+ { collapsedInto: dbID },\n+ 0,\n+ ];\n+ }\n}\n}\n@@ -117,10 +156,10 @@ async function sendPushNotifs(req: $Request, res: $Response) {\n]);\nfor (let deliveryResult of deliveryResults) {\nif (deliveryResult.errors) {\n- notifications[deliveryResult.dbID][4].errors = deliveryResult.errors;\n+ notifications[deliveryResult.dbID][5].errors = deliveryResult.errors;\n}\nif (deliveryResult.fcmIDs) {\n- notifications[deliveryResult.dbID][4].androidID =\n+ notifications[deliveryResult.dbID][5].androidID =\ndeliveryResult.fcmIDs[0];\n}\n}\n@@ -129,12 +168,13 @@ async function sendPushNotifs(req: $Request, res: $Response) {\nfor (let dbID in notifications) {\nconst notification = notifications[dbID];\nconst jsonConverted = [...notification];\n- jsonConverted[4] = JSON.stringify(jsonConverted[4]);\n+ jsonConverted[5] = JSON.stringify(jsonConverted[5]);\nflattenedNotifications.push(jsonConverted);\n}\nif (flattenedNotifications.length > 0) {\nconst query = SQL`\n- INSERT INTO notifications (id, user, thread, message, delivery, rescinded)\n+ INSERT INTO notifications\n+ (id, user, thread, message, collapse_key, delivery, rescinded)\nVALUES ${flattenedNotifications}\n`;\nawait conn.query(query);\n@@ -147,9 +187,10 @@ async function fetchInfos(\nconn: Connection,\npushInfo: PushInfo,\n) {\n+ const collapsableNotifsResult = await fetchCollapsableNotifs(conn, pushInfo);\n+\nconst threadIDs = new Set();\n- for (let userID in pushInfo) {\n- for (let rawMessageInfo of pushInfo[userID].messageInfos) {\n+ const addThreadIDsFromMessageInfos = (rawMessageInfo: RawMessageInfo) => {\nthreadIDs.add(rawMessageInfo.threadID);\nif (\nrawMessageInfo.type === messageType.CREATE_THREAD &&\n@@ -159,26 +200,41 @@ async function fetchInfos(\n} else if (rawMessageInfo.type === messageType.CREATE_SUB_THREAD) {\nthreadIDs.add(rawMessageInfo.childThreadID);\n}\n+ };\n+ const usersToCollapsableNotifInfo =\n+ collapsableNotifsResult.usersToCollapsableNotifInfo;\n+ for (let userID in usersToCollapsableNotifInfo) {\n+ for (let notifInfo of usersToCollapsableNotifInfo[userID]) {\n+ for (let rawMessageInfo of notifInfo.existingMessageInfos) {\n+ addThreadIDsFromMessageInfos(rawMessageInfo);\n+ }\n+ for (let rawMessageInfo of notifInfo.newMessageInfos) {\n+ addThreadIDsFromMessageInfos(rawMessageInfo);\n+ }\n}\n}\n// These threadInfos won't have currentUser set\nconst { threadInfos: rawThreadInfos, userInfos: threadUserInfos } =\nawait fetchThreadInfos(conn, SQL`t.id IN (${[...threadIDs]})`, true);\n+ const mergedUserInfos = {\n+ ...collapsableNotifsResult.userInfos,\n+ ...threadUserInfos,\n+ };\nconst userInfos = await fetchMissingUserInfos(\nconn,\n- threadUserInfos,\n- pushInfo,\n+ mergedUserInfos,\n+ usersToCollapsableNotifInfo,\n);\n- return { rawThreadInfos, userInfos };\n+ return { usersToCollapsableNotifInfo, rawThreadInfos, userInfos };\n}\nasync function fetchMissingUserInfos(\nconn: Connection,\nuserInfos: { [id: string]: UserInfo },\n- pushInfo: PushInfo,\n+ usersToCollapsableNotifInfo: { [userID: string]: CollapsableNotifInfo[] },\n) {\nconst missingUserIDs = new Set();\nconst addIfMissing = (userID: string) => {\n@@ -186,19 +242,31 @@ async function fetchMissingUserInfos(\nmissingUserIDs.add(userID);\n}\n};\n-\n- for (let userID in pushInfo) {\n- for (let rawMessageInfo of pushInfo[userID].messageInfos) {\n+ const addUserIDsFromMessageInfos = (rawMessageInfo: RawMessageInfo) => {\naddIfMissing(rawMessageInfo.creatorID);\nif (rawMessageInfo.type === messageType.ADD_MEMBERS) {\nfor (let userID of rawMessageInfo.addedUserIDs) {\naddIfMissing(userID);\n}\n+ } else if (rawMessageInfo.type === messageType.REMOVE_MEMBERS) {\n+ for (let userID of rawMessageInfo.removedUserIDs) {\n+ addIfMissing(userID);\n+ }\n} else if (rawMessageInfo.type === messageType.CREATE_THREAD) {\nfor (let userID of rawMessageInfo.initialThreadState.memberIDs) {\naddIfMissing(userID);\n}\n}\n+ };\n+\n+ for (let userID in usersToCollapsableNotifInfo) {\n+ for (let notifInfo of usersToCollapsableNotifInfo[userID]) {\n+ for (let rawMessageInfo of notifInfo.existingMessageInfos) {\n+ addUserIDsFromMessageInfos(rawMessageInfo);\n+ }\n+ for (let rawMessageInfo of notifInfo.newMessageInfos) {\n+ addUserIDsFromMessageInfos(rawMessageInfo);\n+ }\n}\n}\n@@ -247,36 +315,41 @@ function getDevicesByDeviceType(\n}\nfunction prepareIOSNotification(\n- messageInfo: MessageInfo,\n+ messageInfos: MessageInfo[],\nthreadInfo: ThreadInfo,\n+ collapseKey: ?string,\nunreadCount: number,\n): apn.Notification {\n- const notifText = notifTextForMessageInfo(messageInfo, threadInfo);\n+ const notifText = notifTextForMessageInfo(messageInfos, threadInfo);\nconst uniqueID = uuidv4();\nconst notification = new apn.Notification();\nnotification.body = notifText;\nnotification.topic = \"org.squadcal.app\";\nnotification.sound = \"default\";\nnotification.badge = unreadCount;\n- notification.threadId = messageInfo.threadID;\n+ notification.threadId = threadInfo.id;\nnotification.id = uniqueID;\n- notification.collapseId = uniqueID;\nnotification.payload.id = uniqueID;\n+ notification.payload.threadID = threadInfo.id;\n+ if (collapseKey) {\n+ notification.collapseId = collapseKey;\n+ }\nreturn notification;\n}\nfunction prepareAndroidNotification(\n- messageInfo: MessageInfo,\n+ messageInfos: MessageInfo[],\nthreadInfo: ThreadInfo,\n+ collapseKey: ?string,\nunreadCount: number,\ndbID: string,\n): Object {\n- const notifText = notifTextForMessageInfo(messageInfo, threadInfo);\n+ const notifText = notifTextForMessageInfo(messageInfos, threadInfo);\nreturn {\ndata: {\nnotifBody: notifText,\nbadgeCount: unreadCount.toString(),\n- threadID: messageInfo.threadID,\n+ threadID: threadInfo.id,\ndbID,\n},\n};\n" }, { "change_type": "MODIFY", "old_path": "lib/shared/message-utils.js", "new_path": "lib/shared/message-utils.js", "diff": "@@ -346,10 +346,17 @@ function createMessageInfo(\ninvariant(false, `${rawMessageInfo.type} is not a messageType!`);\n}\n+function sortMessageInfoList<T: MessageInfo | RawMessageInfo>(\n+ messageInfos: T[],\n+): T[] {\n+ return messageInfos.sort((a: T, b: T) => b.time - a.time);\n+}\n+\nexport {\nmessageKey,\nmessageID,\nrobotextForMessageInfo,\nrobotextToRawString,\ncreateMessageInfo,\n+ sortMessageInfoList,\n};\n" }, { "change_type": "MODIFY", "old_path": "lib/shared/notif-utils.js", "new_path": "lib/shared/notif-utils.js", "diff": "// @flow\n-import type { MessageInfo, RobotextMessageInfo } from '../types/message-types';\n+import type {\n+ MessageInfo,\n+ RawMessageInfo,\n+ RobotextMessageInfo,\n+ MessageType,\n+} from '../types/message-types';\nimport type { ThreadInfo, RawThreadInfo } from '../types/thread-types';\nimport type { RelativeUserInfo } from '../types/user-types';\n+import invariant from 'invariant';\n+\nimport { messageType } from '../types/message-types';\nimport {\nrobotextForMessageInfo,\n@@ -12,6 +19,7 @@ import {\nimport { threadIsTwoPersonChat } from './thread-utils';\nimport { stringForUser } from './user-utils';\nimport { prettyDate } from '../utils/date-utils';\n+import { pluralize } from '../utils/text-utils';\nconst notificationPressActionType = \"NOTIFICATION_PRESS\";\n@@ -21,10 +29,10 @@ export type NotificationPressPayload = {\n};\nfunction notifTextForMessageInfo(\n- messageInfo: MessageInfo,\n+ messageInfos: MessageInfo[],\nthreadInfo: ThreadInfo,\n): string {\n- const fullNotifText = fullNotifTextForMessageInfo(messageInfo, threadInfo);\n+ const fullNotifText = fullNotifTextForMessageInfo(messageInfos, threadInfo);\nif (fullNotifText.length <= 300) {\nreturn fullNotifText;\n}\n@@ -56,11 +64,41 @@ function notifThreadName(threadInfo: ThreadInfo): string {\n}\n}\n+function assertSingleMessageInfo(\n+ messageInfos: MessageInfo[],\n+): MessageInfo {\n+ if (messageInfos.length === 0) {\n+ throw new Error(\"expected single MessageInfo, but none present!\");\n+ } else if (messageInfos.length !== 1) {\n+ const messageIDs = messageInfos.map(messageInfo => messageInfo.id);\n+ console.warn(\n+ \"expected single MessageInfo, but there are multiple! \" +\n+ messageIDs.join(\", \")\n+ );\n+ }\n+ return messageInfos[0];\n+}\n+\n+function mostRecentMessageInfoType(\n+ messageInfos: MessageInfo[],\n+): MessageType {\n+ if (messageInfos.length === 0) {\n+ throw new Error(\"expected MessageInfo, but none present!\");\n+ }\n+ return messageInfos[0].type;\n+}\n+\nfunction fullNotifTextForMessageInfo(\n- messageInfo: MessageInfo,\n+ messageInfos: MessageInfo[],\nthreadInfo: ThreadInfo,\n): string {\n- if (messageInfo.type === messageType.TEXT) {\n+ const mostRecentType = mostRecentMessageInfoType(messageInfos);\n+ if (mostRecentType === messageType.TEXT) {\n+ const messageInfo = assertSingleMessageInfo(messageInfos);\n+ invariant(\n+ messageInfo.type === messageType.TEXT,\n+ \"messageInfo should be messageType.TEXT!\",\n+ );\nif (!threadInfo.name && threadIsTwoPersonChat(threadInfo)) {\nreturn `${threadInfo.uiName}: ${messageInfo.text}`;\n} else {\n@@ -68,7 +106,12 @@ function fullNotifTextForMessageInfo(\nconst threadName = notifThreadName(threadInfo);\nreturn `${userString} to ${threadName}: ${messageInfo.text}`;\n}\n- } else if (messageInfo.type === messageType.CREATE_THREAD) {\n+ } else if (mostRecentType === messageType.CREATE_THREAD) {\n+ const messageInfo = assertSingleMessageInfo(messageInfos);\n+ invariant(\n+ messageInfo.type === messageType.CREATE_THREAD,\n+ \"messageInfo should be messageType.CREATE_THREAD!\",\n+ );\nconst parentThreadInfo = messageInfo.initialThreadState.parentThreadInfo;\nif (parentThreadInfo) {\nreturn notifTextForSubthreadCreation(\n@@ -82,29 +125,159 @@ function fullNotifTextForMessageInfo(\ntext += ` called \"${messageInfo.initialThreadState.name}\"`;\n}\nreturn text;\n- } else if (messageInfo.type === messageType.ADD_MEMBERS) {\n- const robotext = strippedRobotextForMessageInfo(messageInfo, threadInfo);\n+ } else if (mostRecentType === messageType.ADD_MEMBERS) {\n+ const addedMembersObject = {};\n+ for (let messageInfo of messageInfos) {\n+ invariant(\n+ messageInfo.type === messageType.ADD_MEMBERS,\n+ \"messageInfo should be messageType.ADD_MEMBERS!\",\n+ );\n+ for (let member of messageInfo.addedMembers) {\n+ addedMembersObject[member.id] = member;\n+ }\n+ }\n+ // https://github.com/facebook/flow/issues/2221\n+ const addedMembers =\n+ ((Object.values(addedMembersObject): any): RelativeUserInfo[]);\n+\n+ const mostRecentMessageInfo = messageInfos[0];\n+ invariant(\n+ mostRecentMessageInfo.type === messageType.ADD_MEMBERS,\n+ \"messageInfo should be messageType.ADD_MEMBERS!\",\n+ );\n+ const mergedMessageInfo = { ...mostRecentMessageInfo, addedMembers };\n+\n+ const robotext = strippedRobotextForMessageInfo(\n+ mergedMessageInfo,\n+ threadInfo,\n+ );\nreturn `${robotext} to ${notifThreadName(threadInfo)}`;\n- } else if (messageInfo.type === messageType.CREATE_SUB_THREAD) {\n+ } else if (mostRecentType === messageType.CREATE_SUB_THREAD) {\n+ const messageInfo = assertSingleMessageInfo(messageInfos);\n+ invariant(\n+ messageInfo.type === messageType.CREATE_SUB_THREAD,\n+ \"messageInfo should be messageType.CREATE_SUB_THREAD!\",\n+ );\nreturn notifTextForSubthreadCreation(\nmessageInfo.creator,\nthreadInfo,\nmessageInfo.childThreadInfo.name,\n);\n- } else if (messageInfo.type === messageType.REMOVE_MEMBERS) {\n- const robotext = strippedRobotextForMessageInfo(messageInfo, threadInfo);\n+ } else if (mostRecentType === messageType.REMOVE_MEMBERS) {\n+ const removedMembersObject = {};\n+ for (let messageInfo of messageInfos) {\n+ invariant(\n+ messageInfo.type === messageType.REMOVE_MEMBERS,\n+ \"messageInfo should be messageType.REMOVE_MEMBERS!\",\n+ );\n+ for (let member of messageInfo.removedMembers) {\n+ removedMembersObject[member.id] = member;\n+ }\n+ }\n+ // https://github.com/facebook/flow/issues/2221\n+ const removedMembers =\n+ ((Object.values(removedMembersObject): any): RelativeUserInfo[]);\n+\n+ const mostRecentMessageInfo = messageInfos[0];\n+ invariant(\n+ mostRecentMessageInfo.type === messageType.REMOVE_MEMBERS,\n+ \"messageInfo should be messageType.REMOVE_MEMBERS!\",\n+ );\n+ const mergedMessageInfo = { ...mostRecentMessageInfo, removedMembers };\n+\n+ const robotext = strippedRobotextForMessageInfo(\n+ mergedMessageInfo,\n+ threadInfo,\n+ );\nreturn `${robotext} from ${notifThreadName(threadInfo)}`;\n- } else if (messageInfo.type === messageType.CHANGE_ROLE) {\n- const robotext = strippedRobotextForMessageInfo(messageInfo, threadInfo);\n+ } else if (mostRecentType === messageType.CHANGE_ROLE) {\n+ const membersObject = {};\n+ for (let messageInfo of messageInfos) {\n+ invariant(\n+ messageInfo.type === messageType.CHANGE_ROLE,\n+ \"messageInfo should be messageType.CHANGE_ROLE!\",\n+ );\n+ for (let member of messageInfo.members) {\n+ membersObject[member.id] = member;\n+ }\n+ }\n+ // https://github.com/facebook/flow/issues/2221\n+ const members = ((Object.values(membersObject): any): RelativeUserInfo[]);\n+\n+ const mostRecentMessageInfo = messageInfos[0];\n+ invariant(\n+ mostRecentMessageInfo.type === messageType.CHANGE_ROLE,\n+ \"messageInfo should be messageType.CHANGE_ROLE!\",\n+ );\n+ const mergedMessageInfo = { ...mostRecentMessageInfo, members };\n+\n+ const robotext = strippedRobotextForMessageInfo(\n+ mergedMessageInfo,\n+ threadInfo,\n+ );\nreturn `${robotext} in ${notifThreadName(threadInfo)}`;\n- } else if (messageInfo.type === messageType.CREATE_ENTRY) {\n- return `${stringForUser(messageInfo.creator)} created an event for ` +\n- `${prettyDate(messageInfo.date)}: \"${messageInfo.text}\"`;\n- } else if (messageInfo.type === messageType.EDIT_ENTRY) {\n+ } else if (mostRecentType === messageType.LEAVE_THREAD) {\n+ const leaverBeavers = {};\n+ for (let messageInfo of messageInfos) {\n+ invariant(\n+ messageInfo.type === messageType.LEAVE_THREAD,\n+ \"messageInfo should be messageType.LEAVE_THREAD!\",\n+ );\n+ leaverBeavers[messageInfo.creator.id] = messageInfo.creator;\n+ }\n+ // https://github.com/facebook/flow/issues/2221\n+ const leavers =\n+ ((Object.values(leaverBeavers): any): RelativeUserInfo[]);\n+ const leaversString = pluralize(leavers.map(stringForUser));\n+\n+ return `${leaversString} left ${notifThreadName(threadInfo)}`;\n+ } else if (mostRecentType === messageType.JOIN_THREAD) {\n+ const joinerArray = {};\n+ for (let messageInfo of messageInfos) {\n+ invariant(\n+ messageInfo.type === messageType.JOIN_THREAD,\n+ \"messageInfo should be messageType.JOIN_THREAD!\",\n+ );\n+ joinerArray[messageInfo.creator.id] = messageInfo.creator;\n+ }\n+ // https://github.com/facebook/flow/issues/2221\n+ const joiners =\n+ ((Object.values(joinerArray): any): RelativeUserInfo[]);\n+ const joinersString = pluralize(joiners.map(stringForUser));\n+\n+ return `${joinersString} joined ${notifThreadName(threadInfo)}`;\n+ } else if (\n+ mostRecentType === messageType.CREATE_ENTRY ||\n+ mostRecentType === messageType.EDIT_ENTRY\n+ ) {\n+ const hasCreateEntry = messageInfos.some(\n+ messageInfo => messageInfo.type === messageType.CREATE_ENTRY,\n+ );\n+ const messageInfo = messageInfos[0];\n+ if (!hasCreateEntry) {\n+ invariant(\n+ messageInfo.type === messageType.EDIT_ENTRY,\n+ \"messageInfo should be messageType.EDIT_ENTRY!\",\n+ );\nreturn `${stringForUser(messageInfo.creator)} updated the text of an ` +\n`event for ${prettyDate(messageInfo.date)}: \"${messageInfo.text}\"`;\n+ }\n+ invariant(\n+ messageInfo.type === messageType.CREATE_ENTRY ||\n+ messageInfo.type === messageType.EDIT_ENTRY,\n+ \"messageInfo should be messageType.CREATE_ENTRY/EDIT_ENTRY!\",\n+ );\n+ return `${stringForUser(messageInfo.creator)} created an event for ` +\n+ `${prettyDate(messageInfo.date)}: \"${messageInfo.text}\"`;\n+ } else if (mostRecentType === messageType.CHANGE_SETTINGS) {\n+ const mostRecentMessageInfo = messageInfos[0];\n+ invariant(\n+ mostRecentMessageInfo.type === messageType.CHANGE_SETTINGS,\n+ \"messageInfo should be messageType.CHANGE_SETTINGS!\",\n+ );\n+ return strippedRobotextForMessageInfo(mostRecentMessageInfo, threadInfo);\n} else {\n- return strippedRobotextForMessageInfo(messageInfo, threadInfo);\n+ invariant(false, `unrecognized messageType ${mostRecentType}`);\n}\n}\n@@ -121,7 +294,56 @@ function strippedRobotextForMessageInfo(\nreturn robotextToRawString(threadMadeExplicit);\n}\n+function notifCollapseKeyForRawMessageInfo(\n+ rawMessageInfo: RawMessageInfo,\n+): ?string {\n+ const joinResult = (...keys: (string | number)[]) => keys.join(\"|\");\n+ if (\n+ rawMessageInfo.type === messageType.ADD_MEMBERS ||\n+ rawMessageInfo.type === messageType.REMOVE_MEMBERS\n+ ) {\n+ return joinResult(\n+ rawMessageInfo.type,\n+ rawMessageInfo.threadID,\n+ rawMessageInfo.creatorID,\n+ );\n+ } else if (rawMessageInfo.type === messageType.CHANGE_SETTINGS) {\n+ return joinResult(\n+ rawMessageInfo.type,\n+ rawMessageInfo.threadID,\n+ rawMessageInfo.creatorID,\n+ rawMessageInfo.field,\n+ );\n+ } else if (rawMessageInfo.type === messageType.CHANGE_ROLE) {\n+ return joinResult(\n+ rawMessageInfo.type,\n+ rawMessageInfo.threadID,\n+ rawMessageInfo.creatorID,\n+ rawMessageInfo.newRole,\n+ );\n+ } else if (\n+ rawMessageInfo.type === messageType.JOIN_THREAD ||\n+ rawMessageInfo.type === messageType.LEAVE_THREAD\n+ ) {\n+ return joinResult(\n+ rawMessageInfo.type,\n+ rawMessageInfo.threadID,\n+ );\n+ } else if (\n+ rawMessageInfo.type === messageType.CREATE_ENTRY ||\n+ rawMessageInfo.type === messageType.EDIT_ENTRY\n+ ) {\n+ return joinResult(\n+ rawMessageInfo.creatorID,\n+ rawMessageInfo.entryID,\n+ );\n+ } else {\n+ return null;\n+ }\n+}\n+\nexport {\nnotificationPressActionType,\nnotifTextForMessageInfo,\n+ notifCollapseKeyForRawMessageInfo,\n};\n" }, { "change_type": "MODIFY", "old_path": "native/app.react.js", "new_path": "native/app.react.js", "diff": "@@ -479,7 +479,12 @@ class AppWithNavigationState extends React.PureComponent<Props> {\nnotification.finish(NotificationsIOS.FetchResult.NoData);\nreturn;\n}\n- const threadID = notification.getThread();\n+ const threadID = notification.getData().threadID;\n+ if (!threadID) {\n+ console.log(\"Notification with missing threadID received!\");\n+ notification.finish(NotificationsIOS.FetchResult.NoData);\n+ return;\n+ }\ninvariant(this.inAppNotification, \"should be set\");\nthis.inAppNotification.show({\nmessage: notification.getMessage(),\n@@ -489,13 +494,12 @@ class AppWithNavigationState extends React.PureComponent<Props> {\n}\niosNotificationOpened = (notification) => {\n- const threadID = notification.getThread();\n+ const threadID = notification.getData().threadID;\nif (!threadID) {\nconsole.log(\"Notification with missing threadID received!\");\nnotification.finish(NotificationsIOS.FetchResult.NoData);\nreturn;\n}\n- notification.finish();\nthis.onPressNotificationForThread(threadID, true),\nnotification.finish(NotificationsIOS.FetchResult.NewData);\n}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Collapsing notifications
129,187
18.01.2018 11:34:43
18,000
5c775aab9fa8a3e6e76376b2b4f77fb0bb67aca8
Clean up invalid FCM tokens on the server side
[ { "change_type": "MODIFY", "old_path": "jserver/src/push/send.js", "new_path": "jserver/src/push/send.js", "diff": "@@ -23,7 +23,7 @@ import {\n} from 'lib/shared/message-utils';\nimport { rawThreadInfosToThreadInfos } from 'lib/selectors/thread-selectors';\n-import { connect, SQL } from '../database';\n+import { connect, SQL, appendSQLArray } from '../database';\nimport { apnPush, fcmPush, getUnreadCounts } from './utils';\nimport { fetchThreadInfos } from '../fetchers/thread-fetcher';\nimport { fetchUserInfos } from '../fetchers/user-fetcher';\n@@ -144,16 +144,17 @@ async function sendPushNotifs(req: $Request, res: $Response) {\n}\n}\n- const dbPromises = [];\n+ const cleanUpPromises = [];\nif (dbIDs.length > 0) {\nconst query = SQL`DELETE FROM ids WHERE id IN (${dbIDs})`;\n- dbPromises.push(conn.query(query));\n+ cleanUpPromises.push(conn.query(query));\n}\n-\nconst [ deliveryResults ] = await Promise.all([\nPromise.all(deliveryPromises),\n- Promise.all(dbPromises),\n+ Promise.all(cleanUpPromises),\n]);\n+\n+ const invalidTokens = [];\nfor (let deliveryResult of deliveryResults) {\nif (deliveryResult.errors) {\nnotifications[deliveryResult.dbID][5].errors = deliveryResult.errors;\n@@ -162,6 +163,20 @@ async function sendPushNotifs(req: $Request, res: $Response) {\nnotifications[deliveryResult.dbID][5].androidID =\ndeliveryResult.fcmIDs[0];\n}\n+ if (deliveryResult.invalidFCMTokens) {\n+ invalidTokens.push({\n+ userID: notifications[deliveryResult.dbID][1],\n+ fcmTokens: deliveryResult.invalidFCMTokens,\n+ });\n+ }\n+ }\n+\n+ const dbPromises = [];\n+ if (invalidTokens.length > 0) {\n+ dbPromises.push(removeInvalidFCMTokens(\n+ conn,\n+ invalidTokens,\n+ ));\n}\nconst flattenedNotifications = [];\n@@ -177,7 +192,10 @@ async function sendPushNotifs(req: $Request, res: $Response) {\n(id, user, thread, message, collapse_key, delivery, rescinded)\nVALUES ${flattenedNotifications}\n`;\n- await conn.query(query);\n+ dbPromises.push(conn.query(query));\n+ }\n+ if (dbPromises.length > 0) {\n+ await Promise.all(dbPromises);\n}\nconn.end();\n@@ -345,14 +363,38 @@ function prepareAndroidNotification(\ndbID: string,\n): Object {\nconst notifText = notifTextForMessageInfo(messageInfos, threadInfo);\n- return {\n- data: {\n- notifBody: notifText,\n- badgeCount: unreadCount.toString(),\n- threadID: threadInfo.id,\n- dbID,\n- },\n- };\n+ const data = {};\n+ data.notifBody = notifText;\n+ data.badgeCount = unreadCount.toString();\n+ data.threadID = threadInfo.id.toString();\n+ data.dbID = dbID;\n+ if (collapseKey) {\n+ data.tag = collapseKey;\n+ }\n+ return { data };\n+}\n+\n+async function removeInvalidFCMTokens(\n+ conn: Connection,\n+ invalidTokens: Array<{ userID: string, fcmTokens: string[] }>,\n+) {\n+ const query = SQL`\n+ UPDATE cookies\n+ SET android_device_token = NULL\n+ WHERE (\n+ `;\n+\n+ const sqlTuples = [];\n+ for (let invalidTokenUser of invalidTokens) {\n+ sqlTuples.push(SQL`(\n+ user = ${invalidTokenUser.userID} AND\n+ android_device_token IN (${invalidTokenUser.fcmTokens})\n+ )`);\n+ }\n+ appendSQLArray(query, sqlTuples, \" OR \");\n+ query.append(SQL`)`);\n+\n+ await conn.query(query);\n}\nexport {\n" }, { "change_type": "MODIFY", "old_path": "jserver/src/push/utils.js", "new_path": "jserver/src/push/utils.js", "diff": "@@ -14,6 +14,11 @@ fcmAdmin.initializeApp({\ncredential: fcmAdmin.credential.cert(fcmConfig),\n});\n+const fcmTokenInvalidationErrors = new Set([\n+ \"messaging/registration-token-not-registered\",\n+ \"messaging/invalid-registration-token\",\n+]);\n+\nasync function apnPush(\nnotification: apn.Notification,\ndeviceTokens: string[],\n@@ -35,20 +40,36 @@ async function fcmPush(\ndeviceTokens: string[],\ndbID: string,\n) {\n- try {\n- const deliveryResult = await fcmAdmin.messaging().sendToDevice(\n- deviceTokens,\n+ // firebase-admin is extremely barebones and has a lot of missing or poorly\n+ // thought-out functionality. One of the issues is that if you send a\n+ // multicast messages and one of the device tokens is invalid, the resultant\n+ // won't explain which of the device tokens is invalid. So we're forced to\n+ // avoid the multicast functionality and call it once per deviceToken.\n+ const promises = [];\n+ for (let deviceToken of deviceTokens) {\n+ promises.push(fcmSinglePush(\nnotification,\n- );\n+ deviceToken,\n+ ));\n+ }\n+ const pushResults = await Promise.all(promises);\n+\nconst errors = [];\nconst ids = [];\n- for (let fcmResult of deliveryResult.results) {\n- if (fcmResult.error) {\n- errors.push(fcmResult.error);\n- } else if (fcmResult.messageId) {\n- ids.push(fcmResult.messageId);\n+ const invalidTokens = [];\n+ for (let i = 0; i < pushResults.length; i++) {\n+ const pushResult = pushResults[i];\n+ for (let error of pushResult.errors) {\n+ errors.push(error);\n+ if (fcmTokenInvalidationErrors.has(error.errorInfo.code)) {\n+ invalidTokens.push(deviceTokens[i]);\n+ }\n}\n+ for (let id of pushResult.fcmIDs) {\n+ ids.push(id);\n}\n+ }\n+\nconst result: Object = { dbID };\nif (ids.length > 0) {\nresult.fcmIDs = ids;\n@@ -58,9 +79,33 @@ async function fcmPush(\n} else {\nresult.success = true;\n}\n+ if (invalidTokens.length > 0) {\n+ result.invalidFCMTokens = invalidTokens;\n+ }\nreturn result;\n+}\n+\n+async function fcmSinglePush(\n+ notification: Object,\n+ deviceToken: string,\n+) {\n+ try {\n+ const deliveryResult = await fcmAdmin.messaging().sendToDevice(\n+ deviceToken,\n+ notification,\n+ );\n+ const errors = [];\n+ const ids = [];\n+ for (let fcmResult of deliveryResult.results) {\n+ if (fcmResult.error) {\n+ errors.push(fcmResult.error);\n+ } else if (fcmResult.messageId) {\n+ ids.push(fcmResult.messageId);\n+ }\n+ }\n+ return { fcmIDs: ids, errors };\n} catch (e) {\n- return { errors: [ e ], dbID };\n+ return { fcmIDs: [], errors: [ e ] };\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "server/set_device_token.php", "new_path": "server/set_device_token.php", "diff": "@@ -7,7 +7,7 @@ require_once('auth.php');\nasync_start();\nif (\n- !isset($_POST['device_token']) ||\n+ empty($_POST['device_token']) ||\n!isset($_POST['device_type']) ||\n($_POST['device_type'] !== \"ios\" && $_POST['device_type'] !== \"android\")\n) {\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Clean up invalid FCM tokens on the server side
129,187
18.01.2018 12:09:10
18,000
85c8da471a950170bdd98021c0c1ae0d9d729d2f
Collapsing notification on Android
[ { "change_type": "MODIFY", "old_path": "jserver/src/push/rescind.js", "new_path": "jserver/src/push/rescind.js", "diff": "@@ -19,7 +19,7 @@ async function rescindPushNotifs(req: $Request, res: $Response) {\nconst conn = await connect();\nconst fetchQuery = SQL`\n- SELECT id, delivery\n+ SELECT id, delivery, collapse_key\nFROM notifications\nWHERE user = ${userID} AND thread IN (${pushRescindInfo.threadIDs})\nAND rescinded = 0\n@@ -53,12 +53,13 @@ async function rescindPushNotifs(req: $Request, res: $Response) {\nconst notification = {\ndata: {\nrescind: \"true\",\n- dbID: row.id.toString(),\n+ notifID: row.collapse_key ? row.collapse_key : row.id.toString(),\n},\n};\npromises.push(fcmPush(\nnotification,\nrow.delivery.androidDeviceTokens,\n+ null,\nrow.id,\n));\n}\n" }, { "change_type": "MODIFY", "old_path": "jserver/src/push/send.js", "new_path": "jserver/src/push/send.js", "diff": "@@ -114,6 +114,7 @@ async function sendPushNotifs(req: $Request, res: $Response) {\ndeliveryPromises.push(fcmPush(\nnotification,\nbyDeviceType.android,\n+ notifInfo.collapseKey,\ndbID,\n));\ndelivery.androidDeviceTokens = byDeviceType.android;\n@@ -367,10 +368,7 @@ function prepareAndroidNotification(\ndata.notifBody = notifText;\ndata.badgeCount = unreadCount.toString();\ndata.threadID = threadInfo.id.toString();\n- data.dbID = dbID;\n- if (collapseKey) {\n- data.tag = collapseKey;\n- }\n+ data.notifID = collapseKey ? collapseKey : dbID;\nreturn { data };\n}\n" }, { "change_type": "MODIFY", "old_path": "jserver/src/push/utils.js", "new_path": "jserver/src/push/utils.js", "diff": "@@ -38,8 +38,15 @@ async function apnPush(\nasync function fcmPush(\nnotification: Object,\ndeviceTokens: string[],\n+ collapseKey: ?string,\ndbID: string,\n) {\n+ const options: Object = {\n+ priority: 'high',\n+ };\n+ if (collapseKey) {\n+ options.collapseKey = collapseKey;\n+ }\n// firebase-admin is extremely barebones and has a lot of missing or poorly\n// thought-out functionality. One of the issues is that if you send a\n// multicast messages and one of the device tokens is invalid, the resultant\n@@ -50,6 +57,7 @@ async function fcmPush(\npromises.push(fcmSinglePush(\nnotification,\ndeviceToken,\n+ options,\n));\n}\nconst pushResults = await Promise.all(promises);\n@@ -88,11 +96,13 @@ async function fcmPush(\nasync function fcmSinglePush(\nnotification: Object,\ndeviceToken: string,\n+ options: Object,\n) {\ntry {\nconst deliveryResult = await fcmAdmin.messaging().sendToDevice(\ndeviceToken,\nnotification,\n+ options,\n);\nconst errors = [];\nconst ids = [];\n" }, { "change_type": "MODIFY", "old_path": "native/app.react.js", "new_path": "native/app.react.js", "diff": "@@ -526,7 +526,7 @@ class AppWithNavigationState extends React.PureComponent<Props> {\n});\n} else if (notification.notifBody) {\nFCM.presentLocalNotification({\n- id: notification.dbID,\n+ id: notification.notifID,\nbody: notification.notifBody,\npriority: \"high\",\nsound: \"default\",\n@@ -536,7 +536,7 @@ class AppWithNavigationState extends React.PureComponent<Props> {\nrecordAndroidNotificationActionType,\n{\nthreadID: notification.threadID,\n- notifDBID: notification.dbID,\n+ notifID: notification.notifID,\n},\n);\n}\n@@ -544,7 +544,7 @@ class AppWithNavigationState extends React.PureComponent<Props> {\nthis.onPressNotificationForThread(notification.threadID, true);\n}\nif (notification.rescind) {\n- FCM.removeDeliveredNotification(notification.dbID);\n+ FCM.removeDeliveredNotification(notification.notifID);\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "native/push/android.js", "new_path": "native/push/android.js", "diff": "@@ -13,7 +13,7 @@ async function requestAndroidPushPermissions(): Promise<?string> {\nconst recordAndroidNotificationActionType = \"RECORD_ANDROID_NOTIFICATION\";\ntype RecordAndroidNotificationPayload = {|\nthreadID: string,\n- notifDBID: string,\n+ notifID: string,\n|};\nconst clearAndroidNotificationActionType = \"CLEAR_ANDROID_NOTIFICATION\";\n@@ -30,7 +30,7 @@ export type AndroidNotificationActions =\npayload: ClearAndroidNotificationPayload,\n|};\n-function reduceThreadIDsToNotifDBIDs(\n+function reduceThreadIDsToNotifIDs(\nstate: {[threadID: string]: string[]},\naction: AndroidNotificationActions,\n): {[threadID: string]: string[]} {\n@@ -39,7 +39,7 @@ function reduceThreadIDsToNotifDBIDs(\n...state,\n[action.payload.threadID]: [\n...state[action.payload.threadID],\n- action.payload.notifDBID,\n+ action.payload.notifID,\n],\n};\n} else if (action.type === clearAndroidNotificationActionType) {\n@@ -56,5 +56,5 @@ export {\nrequestAndroidPushPermissions,\nrecordAndroidNotificationActionType,\nclearAndroidNotificationActionType,\n- reduceThreadIDsToNotifDBIDs,\n+ reduceThreadIDsToNotifIDs,\n};\n" }, { "change_type": "MODIFY", "old_path": "native/redux-setup.js", "new_path": "native/redux-setup.js", "diff": "@@ -33,7 +33,7 @@ import {\nimport {\nrecordAndroidNotificationActionType,\nclearAndroidNotificationActionType,\n- reduceThreadIDsToNotifDBIDs,\n+ reduceThreadIDsToNotifIDs,\n} from './push/android';\nexport type AppState = {|\n@@ -50,7 +50,7 @@ export type AppState = {|\nloadingStatuses: {[key: string]: {[idx: number]: LoadingStatus}},\ncookie: ?string,\ndeviceToken: ?string,\n- threadIDsToNotifDBIDs: {[threadID: string]: string[]},\n+ threadIDsToNotifIDs: {[threadID: string]: string[]},\nrehydrateConcluded: bool,\n|};\n@@ -75,7 +75,7 @@ const defaultState = ({\nloadingStatuses: {},\ncookie: null,\ndeviceToken: null,\n- threadIDsToNotifDBIDs: {},\n+ threadIDsToNotifIDs: {},\nrehydrateConcluded: false,\n}: AppState);\n@@ -112,7 +112,7 @@ function reducer(state: AppState, action: *) {\nloadingStatuses: state.loadingStatuses,\ncookie: state.cookie,\ndeviceToken: state.deviceToken,\n- threadIDsToNotifDBIDs: state.threadIDsToNotifDBIDs,\n+ threadIDsToNotifIDs: state.threadIDsToNotifIDs,\nrehydrateConcluded: state.rehydrateConcluded,\n};\n}\n@@ -131,7 +131,7 @@ function reducer(state: AppState, action: *) {\nloadingStatuses: state.loadingStatuses,\ncookie: state.cookie,\ndeviceToken: state.deviceToken,\n- threadIDsToNotifDBIDs: state.threadIDsToNotifDBIDs,\n+ threadIDsToNotifIDs: state.threadIDsToNotifIDs,\nrehydrateConcluded: true,\n};\n}\n@@ -153,8 +153,8 @@ function reducer(state: AppState, action: *) {\nloadingStatuses: state.loadingStatuses,\ncookie: state.cookie,\ndeviceToken: state.deviceToken,\n- threadIDsToNotifDBIDs: reduceThreadIDsToNotifDBIDs(\n- state.threadIDsToNotifDBIDs,\n+ threadIDsToNotifIDs: reduceThreadIDsToNotifIDs(\n+ state.threadIDsToNotifIDs,\naction.payload,\n),\nrehydrateConcluded: state.rehydrateConcluded,\n@@ -204,7 +204,7 @@ function validateState(oldState: AppState, state: AppState): AppState {\nloadingStatuses: state.loadingStatuses,\ncookie: state.cookie,\ndeviceToken: state.deviceToken,\n- threadIDsToNotifDBIDs: state.threadIDsToNotifDBIDs,\n+ threadIDsToNotifIDs: state.threadIDsToNotifIDs,\nrehydrateConcluded: state.rehydrateConcluded,\n};\n}\n@@ -233,7 +233,7 @@ function validateState(oldState: AppState, state: AppState): AppState {\nloadingStatuses: state.loadingStatuses,\ncookie: state.cookie,\ndeviceToken: state.deviceToken,\n- threadIDsToNotifDBIDs: state.threadIDsToNotifDBIDs,\n+ threadIDsToNotifIDs: state.threadIDsToNotifIDs,\nrehydrateConcluded: state.rehydrateConcluded,\n};\n}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Collapsing notification on Android
129,187
18.01.2018 19:41:43
18,000
9dcff53cec683c2f4e5c353430323068bd3877b3
Clean up invalid APN tokens on the server side
[ { "change_type": "MODIFY", "old_path": "jserver/src/push/send.js", "new_path": "jserver/src/push/send.js", "diff": "@@ -170,11 +170,17 @@ async function sendPushNotifs(req: $Request, res: $Response) {\nfcmTokens: deliveryResult.invalidFCMTokens,\n});\n}\n+ if (deliveryResult.invalidAPNTokens) {\n+ invalidTokens.push({\n+ userID: notifications[deliveryResult.dbID][1],\n+ apnTokens: deliveryResult.invalidAPNTokens,\n+ });\n+ }\n}\nconst dbPromises = [];\nif (invalidTokens.length > 0) {\n- dbPromises.push(removeInvalidFCMTokens(\n+ dbPromises.push(removeInvalidTokens(\nconn,\ninvalidTokens,\n));\n@@ -372,24 +378,40 @@ function prepareAndroidNotification(\nreturn { data };\n}\n-async function removeInvalidFCMTokens(\n+type InvalidToken = {\n+ userID: string,\n+ fcmTokens?: string[],\n+ apnTokens?: string[],\n+};\n+async function removeInvalidTokens(\nconn: Connection,\n- invalidTokens: Array<{ userID: string, fcmTokens: string[] }>,\n+ invalidTokens: InvalidToken[],\n) {\nconst query = SQL`\nUPDATE cookies\n- SET android_device_token = NULL\n+ SET android_device_token = NULL, ios_device_token = NULL\nWHERE (\n`;\nconst sqlTuples = [];\nfor (let invalidTokenUser of invalidTokens) {\n- sqlTuples.push(SQL`(\n- user = ${invalidTokenUser.userID} AND\n- android_device_token IN (${invalidTokenUser.fcmTokens})\n- )`);\n+ const deviceConditions = [];\n+ if (invalidTokenUser.fcmTokens && invalidTokenUser.fcmTokens.length > 0) {\n+ deviceConditions.push(\n+ SQL`android_device_token IN (${invalidTokenUser.fcmTokens})`,\n+ );\n+ }\n+ if (invalidTokenUser.apnTokens && invalidTokenUser.apnTokens.length > 0) {\n+ deviceConditions.push(\n+ SQL`ios_device_token IN (${invalidTokenUser.apnTokens})`,\n+ );\n+ }\n+ const statement = SQL`(user = ${invalidTokenUser.userID} AND (`;\n+ appendSQLArray(statement, deviceConditions, SQL` OR `);\n+ statement.append(SQL`))`);\n+ sqlTuples.push(statement);\n}\n- appendSQLArray(query, sqlTuples, \" OR \");\n+ appendSQLArray(query, sqlTuples, SQL` OR `);\nquery.append(SQL`)`);\nawait conn.query(query);\n" }, { "change_type": "MODIFY", "old_path": "jserver/src/push/utils.js", "new_path": "jserver/src/push/utils.js", "diff": "@@ -18,6 +18,7 @@ const fcmTokenInvalidationErrors = new Set([\n\"messaging/registration-token-not-registered\",\n\"messaging/invalid-registration-token\",\n]);\n+const apnTokenInvalidationErrorCode = 410;\nasync function apnPush(\nnotification: apn.Notification,\n@@ -26,14 +27,21 @@ async function apnPush(\n) {\nconst result = await apnProvider.send(notification, deviceTokens);\nconst errors = [];\n- for (let failure of result.failed) {\n- errors.push(failure);\n+ const invalidTokens = [];\n+ for (let error of result.failed) {\n+ errors.push(error);\n+ if (error.status === apnTokenInvalidationErrorCode) {\n+ invalidTokens.push(error.device);\n}\n- if (errors.length > 0) {\n- return { errors, dbID };\n}\n+ if (invalidTokens.length > 0) {\n+ return { errors, invalidAPNTokens: invalidTokens, dbID };\n+ } else if (errors.length > 0) {\n+ return { errors, dbID };\n+ } else {\nreturn { success: true, dbID };\n}\n+}\nasync function fcmPush(\nnotification: Object,\n" }, { "change_type": "MODIFY", "old_path": "native/package-lock.json", "new_path": "native/package-lock.json", "diff": "\"dependencies\": {\n\"lodash\": {\n\"version\": \"3.10.1\",\n- \"resolved\": \"https://registry.npmjs.org/lodash/-/lodash-3.10.1.tgz\",\n- \"integrity\": \"sha1-W/Rejkm6QYnhfUgnid/RW9FAt7Y=\"\n+ \"bundled\": true\n}\n}\n},\n}\n},\n\"react-native-notifications\": {\n- \"version\": \"git+https://git@github.com/ashoat/react-native-notifications.git#add685dcc5b3e98104766ef69ba92821f49801eb\",\n+ \"version\": \"git+https://git@github.com/ashoat/react-native-notifications.git#b58f93b1d77a78aa96d50e72f36884f431e4e80e\",\n\"requires\": {\n\"core-js\": \"1.2.7\",\n\"uuid\": \"2.0.3\"\n}\n},\n\"react-navigation\": {\n- \"version\": \"git://github.com/react-community/react-navigation.git#abbd88601f9c8b0aa0e596317a8728a05d34c9e8\",\n+ \"version\": \"git://github.com/react-community/react-navigation.git#b221afc80b223d88ae6adffcebbaec67b46f6215\",\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
Clean up invalid APN tokens on the server side
129,187
18.01.2018 21:22:14
18,000
c959fc44fe44895bb131cef30cef8b087c2a0ccf
Upgrade to redux-persist@5
[ { "change_type": "MODIFY", "old_path": "native/.flowconfig", "new_path": "native/.flowconfig", "diff": "; Ignore polyfills\n.*/Libraries/polyfills/.*\n+.*/node_modules/redux-persist/lib/index.js\n+\n[include]\n../lib\n" }, { "change_type": "ADD", "old_path": null, "new_path": "native/flow-typed/npm/react-native-fcm_vx.x.x.js", "diff": "+// flow-typed signature: 26a5630d3240651d66d1f59fd8377d2f\n+// flow-typed version: <<STUB>>/react-native-fcm_v^11.2.0/flow_v0.57.3\n+\n+/**\n+ * This is an autogenerated libdef stub for:\n+ *\n+ * 'react-native-fcm'\n+ *\n+ * Fill this stub out by replacing all the `any` types.\n+ *\n+ * Once filled out, we encourage you to share your work with the\n+ * community by sending a pull request to:\n+ * https://github.com/flowtype/flow-typed\n+ */\n+\n+declare module 'react-native-fcm' {\n+ declare module.exports: any;\n+}\n+\n+/**\n+ * We include stubs for each file inside this npm package in case you need to\n+ * require those files directly. Feel free to delete any files that aren't\n+ * needed.\n+ */\n+\n+\n+// Filename aliases\n+declare module 'react-native-fcm/index' {\n+ declare module.exports: $Exports<'react-native-fcm'>;\n+}\n+declare module 'react-native-fcm/index.js' {\n+ declare module.exports: $Exports<'react-native-fcm'>;\n+}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "native/flow-typed/npm/react-native-in-app-notification_vx.x.x.js", "diff": "+// flow-typed signature: 1e3cafaf46426ad00dc1da7a829f6f00\n+// flow-typed version: <<STUB>>/react-native-in-app-notification_v^2.1.0/flow_v0.57.3\n+\n+/**\n+ * This is an autogenerated libdef stub for:\n+ *\n+ * 'react-native-in-app-notification'\n+ *\n+ * Fill this stub out by replacing all the `any` types.\n+ *\n+ * Once filled out, we encourage you to share your work with the\n+ * community by sending a pull request to:\n+ * https://github.com/flowtype/flow-typed\n+ */\n+\n+declare module 'react-native-in-app-notification' {\n+ declare module.exports: any;\n+}\n+\n+/**\n+ * We include stubs for each file inside this npm package in case you need to\n+ * require those files directly. Feel free to delete any files that aren't\n+ * needed.\n+ */\n+declare module 'react-native-in-app-notification/DefaultNotificationBody.android' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-in-app-notification/DefaultNotificationBody.ios' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-in-app-notification/Notification' {\n+ declare module.exports: any;\n+}\n+\n+// Filename aliases\n+declare module 'react-native-in-app-notification/DefaultNotificationBody.android.js' {\n+ declare module.exports: $Exports<'react-native-in-app-notification/DefaultNotificationBody.android'>;\n+}\n+declare module 'react-native-in-app-notification/DefaultNotificationBody.ios.js' {\n+ declare module.exports: $Exports<'react-native-in-app-notification/DefaultNotificationBody.ios'>;\n+}\n+declare module 'react-native-in-app-notification/Notification.js' {\n+ declare module.exports: $Exports<'react-native-in-app-notification/Notification'>;\n+}\n" }, { "change_type": "MODIFY", "old_path": "native/flow-typed/npm/react-native-notifications_vx.x.x.js", "new_path": "native/flow-typed/npm/react-native-notifications_vx.x.x.js", "diff": "-// flow-typed signature: 08a87c27c47b18973dcd7b3bbefac870\n-// flow-typed version: <<STUB>>/react-native-notifications_v^1.1.17/flow_v0.57.3\n+// flow-typed signature: 6802d4ba619b963d064b10e0d0b693fe\n+// flow-typed version: <<STUB>>/react-native-notifications_vgit+https://git@github.com/ashoat/react-native-notifications.git/flow_v0.57.3\n/**\n* This is an autogenerated libdef stub for:\n" }, { "change_type": "MODIFY", "old_path": "native/flow-typed/npm/react-native-vector-icons_vx.x.x.js", "new_path": "native/flow-typed/npm/react-native-vector-icons_vx.x.x.js", "diff": "-// flow-typed signature: 1da06b21e58e5f16309c428c60ecc779\n+// flow-typed signature: 033aa6fbe80b7ba41dca7a45d04b3540\n// flow-typed version: <<STUB>>/react-native-vector-icons_v^4.3.0/flow_v0.57.3\n/**\n@@ -30,18 +30,6 @@ declare module 'react-native-vector-icons/bin/generate-material-icons' {\ndeclare module.exports: any;\n}\n-declare module 'react-native-vector-icons/dist/create-icon-set-from-fontello' {\n- declare module.exports: any;\n-}\n-\n-declare module 'react-native-vector-icons/dist/create-icon-set-from-icomoon' {\n- declare module.exports: any;\n-}\n-\n-declare module 'react-native-vector-icons/dist/create-icon-set' {\n- declare module.exports: any;\n-}\n-\ndeclare module 'react-native-vector-icons/dist/Entypo' {\ndeclare module.exports: any;\n}\n@@ -50,19 +38,15 @@ declare module 'react-native-vector-icons/dist/EvilIcons' {\ndeclare module.exports: any;\n}\n-declare module 'react-native-vector-icons/dist/FontAwesome' {\n+declare module 'react-native-vector-icons/dist/Feather' {\ndeclare module.exports: any;\n}\n-declare module 'react-native-vector-icons/dist/Foundation' {\n- declare module.exports: any;\n-}\n-\n-declare module 'react-native-vector-icons/dist/generate-icon-set-from-css' {\n+declare module 'react-native-vector-icons/dist/FontAwesome' {\ndeclare module.exports: any;\n}\n-declare module 'react-native-vector-icons/dist/icon-button' {\n+declare module 'react-native-vector-icons/dist/Foundation' {\ndeclare module.exports: any;\n}\n@@ -122,14 +106,6 @@ declare module 'react-native-vector-icons/dist/Octicons' {\ndeclare module.exports: any;\n}\n-declare module 'react-native-vector-icons/dist/react-native' {\n- declare module.exports: any;\n-}\n-\n-declare module 'react-native-vector-icons/dist/react-native.osx' {\n- declare module.exports: any;\n-}\n-\ndeclare module 'react-native-vector-icons/dist/RNIMigration' {\ndeclare module.exports: any;\n}\n@@ -138,14 +114,6 @@ declare module 'react-native-vector-icons/dist/SimpleLineIcons' {\ndeclare module.exports: any;\n}\n-declare module 'react-native-vector-icons/dist/tab-bar-item-ios' {\n- declare module.exports: any;\n-}\n-\n-declare module 'react-native-vector-icons/dist/toolbar-android' {\n- declare module.exports: any;\n-}\n-\ndeclare module 'react-native-vector-icons/dist/Zocial' {\ndeclare module.exports: any;\n}\n@@ -158,6 +126,10 @@ declare module 'react-native-vector-icons/EvilIcons' {\ndeclare module.exports: any;\n}\n+declare module 'react-native-vector-icons/Feather' {\n+ declare module.exports: any;\n+}\n+\ndeclare module 'react-native-vector-icons/FontAwesome' {\ndeclare module.exports: any;\n}\n@@ -237,33 +209,21 @@ declare module 'react-native-vector-icons/bin/generate-icon.js' {\ndeclare module 'react-native-vector-icons/bin/generate-material-icons.js' {\ndeclare module.exports: $Exports<'react-native-vector-icons/bin/generate-material-icons'>;\n}\n-declare module 'react-native-vector-icons/dist/create-icon-set-from-fontello.js' {\n- declare module.exports: $Exports<'react-native-vector-icons/dist/create-icon-set-from-fontello'>;\n-}\n-declare module 'react-native-vector-icons/dist/create-icon-set-from-icomoon.js' {\n- declare module.exports: $Exports<'react-native-vector-icons/dist/create-icon-set-from-icomoon'>;\n-}\n-declare module 'react-native-vector-icons/dist/create-icon-set.js' {\n- declare module.exports: $Exports<'react-native-vector-icons/dist/create-icon-set'>;\n-}\ndeclare module 'react-native-vector-icons/dist/Entypo.js' {\ndeclare module.exports: $Exports<'react-native-vector-icons/dist/Entypo'>;\n}\ndeclare module 'react-native-vector-icons/dist/EvilIcons.js' {\ndeclare module.exports: $Exports<'react-native-vector-icons/dist/EvilIcons'>;\n}\n+declare module 'react-native-vector-icons/dist/Feather.js' {\n+ declare module.exports: $Exports<'react-native-vector-icons/dist/Feather'>;\n+}\ndeclare module 'react-native-vector-icons/dist/FontAwesome.js' {\ndeclare module.exports: $Exports<'react-native-vector-icons/dist/FontAwesome'>;\n}\ndeclare module 'react-native-vector-icons/dist/Foundation.js' {\ndeclare module.exports: $Exports<'react-native-vector-icons/dist/Foundation'>;\n}\n-declare module 'react-native-vector-icons/dist/generate-icon-set-from-css.js' {\n- declare module.exports: $Exports<'react-native-vector-icons/dist/generate-icon-set-from-css'>;\n-}\n-declare module 'react-native-vector-icons/dist/icon-button.js' {\n- declare module.exports: $Exports<'react-native-vector-icons/dist/icon-button'>;\n-}\ndeclare module 'react-native-vector-icons/dist/index.js' {\ndeclare module.exports: $Exports<'react-native-vector-icons/dist/index'>;\n}\n@@ -306,24 +266,12 @@ declare module 'react-native-vector-icons/dist/MaterialIcons.js' {\ndeclare module 'react-native-vector-icons/dist/Octicons.js' {\ndeclare module.exports: $Exports<'react-native-vector-icons/dist/Octicons'>;\n}\n-declare module 'react-native-vector-icons/dist/react-native.js' {\n- declare module.exports: $Exports<'react-native-vector-icons/dist/react-native'>;\n-}\n-declare module 'react-native-vector-icons/dist/react-native.osx.js' {\n- declare module.exports: $Exports<'react-native-vector-icons/dist/react-native.osx'>;\n-}\ndeclare module 'react-native-vector-icons/dist/RNIMigration.js' {\ndeclare module.exports: $Exports<'react-native-vector-icons/dist/RNIMigration'>;\n}\ndeclare module 'react-native-vector-icons/dist/SimpleLineIcons.js' {\ndeclare module.exports: $Exports<'react-native-vector-icons/dist/SimpleLineIcons'>;\n}\n-declare module 'react-native-vector-icons/dist/tab-bar-item-ios.js' {\n- declare module.exports: $Exports<'react-native-vector-icons/dist/tab-bar-item-ios'>;\n-}\n-declare module 'react-native-vector-icons/dist/toolbar-android.js' {\n- declare module.exports: $Exports<'react-native-vector-icons/dist/toolbar-android'>;\n-}\ndeclare module 'react-native-vector-icons/dist/Zocial.js' {\ndeclare module.exports: $Exports<'react-native-vector-icons/dist/Zocial'>;\n}\n@@ -333,6 +281,9 @@ declare module 'react-native-vector-icons/Entypo.js' {\ndeclare module 'react-native-vector-icons/EvilIcons.js' {\ndeclare module.exports: $Exports<'react-native-vector-icons/EvilIcons'>;\n}\n+declare module 'react-native-vector-icons/Feather.js' {\n+ declare module.exports: $Exports<'react-native-vector-icons/Feather'>;\n+}\ndeclare module 'react-native-vector-icons/FontAwesome.js' {\ndeclare module.exports: $Exports<'react-native-vector-icons/FontAwesome'>;\n}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "native/flow-typed/npm/redux-persist_vx.x.x.js", "diff": "+// flow-typed signature: 137cf1283d00613a920849b28dffac06\n+// flow-typed version: <<STUB>>/redux-persist_v5.4.0/flow_v0.57.3\n+\n+/**\n+ * This is an autogenerated libdef stub for:\n+ *\n+ * 'redux-persist'\n+ *\n+ * Fill this stub out by replacing all the `any` types.\n+ *\n+ * Once filled out, we encourage you to share your work with the\n+ * community by sending a pull request to:\n+ * https://github.com/flowtype/flow-typed\n+ */\n+\n+declare module 'redux-persist' {\n+ declare module.exports: any;\n+}\n+\n+/**\n+ * We include stubs for each file inside this npm package in case you need to\n+ * require those files directly. Feel free to delete any files that aren't\n+ * needed.\n+ */\n+declare module 'redux-persist/es/constants' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'redux-persist/es/createMigrate' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'redux-persist/es/createPersistoid' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'redux-persist/es/createTransform' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'redux-persist/es/getStoredState' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'redux-persist/es/index' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'redux-persist/es/integration/getStoredStateMigrateV4' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'redux-persist/es/integration/react' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'redux-persist/es/persistCombineReducers' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'redux-persist/es/persistReducer' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'redux-persist/es/persistStore' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'redux-persist/es/purgeStoredState' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'redux-persist/es/stateReconciler/autoMergeLevel1' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'redux-persist/es/stateReconciler/autoMergeLevel2' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'redux-persist/es/stateReconciler/hardSet' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'redux-persist/es/storage/createWebStorage' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'redux-persist/es/storage/getStorage' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'redux-persist/es/storage/index' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'redux-persist/es/storage/index.native' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'redux-persist/es/storage/session' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'redux-persist/es/types' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'redux-persist/es/utils/curry' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'redux-persist/lib/constants' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'redux-persist/lib/createMigrate' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'redux-persist/lib/createPersistoid' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'redux-persist/lib/createTransform' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'redux-persist/lib/getStoredState' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'redux-persist/lib/index' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'redux-persist/lib/integration/getStoredStateMigrateV4' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'redux-persist/lib/integration/react' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'redux-persist/lib/persistCombineReducers' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'redux-persist/lib/persistReducer' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'redux-persist/lib/persistStore' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'redux-persist/lib/purgeStoredState' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'redux-persist/lib/stateReconciler/autoMergeLevel1' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'redux-persist/lib/stateReconciler/autoMergeLevel2' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'redux-persist/lib/stateReconciler/hardSet' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'redux-persist/lib/storage/createWebStorage' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'redux-persist/lib/storage/getStorage' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'redux-persist/lib/storage/index' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'redux-persist/lib/storage/index.native' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'redux-persist/lib/storage/session' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'redux-persist/lib/types' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'redux-persist/lib/utils/curry' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'redux-persist/src/constants' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'redux-persist/src/createMigrate' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'redux-persist/src/createPersistoid' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'redux-persist/src/createTransform' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'redux-persist/src/getStoredState' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'redux-persist/src/index' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'redux-persist/src/integration/getStoredStateMigrateV4' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'redux-persist/src/integration/react' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'redux-persist/src/persistCombineReducers' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'redux-persist/src/persistReducer' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'redux-persist/src/persistStore' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'redux-persist/src/purgeStoredState' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'redux-persist/src/stateReconciler/autoMergeLevel1' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'redux-persist/src/stateReconciler/autoMergeLevel2' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'redux-persist/src/stateReconciler/hardSet' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'redux-persist/src/storage/createWebStorage' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'redux-persist/src/storage/getStorage' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'redux-persist/src/storage/index' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'redux-persist/src/storage/index.native' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'redux-persist/src/storage/session' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'redux-persist/src/types' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'redux-persist/src/utils/curry' {\n+ declare module.exports: any;\n+}\n+\n+// Filename aliases\n+declare module 'redux-persist/es/constants.js' {\n+ declare module.exports: $Exports<'redux-persist/es/constants'>;\n+}\n+declare module 'redux-persist/es/createMigrate.js' {\n+ declare module.exports: $Exports<'redux-persist/es/createMigrate'>;\n+}\n+declare module 'redux-persist/es/createPersistoid.js' {\n+ declare module.exports: $Exports<'redux-persist/es/createPersistoid'>;\n+}\n+declare module 'redux-persist/es/createTransform.js' {\n+ declare module.exports: $Exports<'redux-persist/es/createTransform'>;\n+}\n+declare module 'redux-persist/es/getStoredState.js' {\n+ declare module.exports: $Exports<'redux-persist/es/getStoredState'>;\n+}\n+declare module 'redux-persist/es/index.js' {\n+ declare module.exports: $Exports<'redux-persist/es/index'>;\n+}\n+declare module 'redux-persist/es/integration/getStoredStateMigrateV4.js' {\n+ declare module.exports: $Exports<'redux-persist/es/integration/getStoredStateMigrateV4'>;\n+}\n+declare module 'redux-persist/es/integration/react.js' {\n+ declare module.exports: $Exports<'redux-persist/es/integration/react'>;\n+}\n+declare module 'redux-persist/es/persistCombineReducers.js' {\n+ declare module.exports: $Exports<'redux-persist/es/persistCombineReducers'>;\n+}\n+declare module 'redux-persist/es/persistReducer.js' {\n+ declare module.exports: $Exports<'redux-persist/es/persistReducer'>;\n+}\n+declare module 'redux-persist/es/persistStore.js' {\n+ declare module.exports: $Exports<'redux-persist/es/persistStore'>;\n+}\n+declare module 'redux-persist/es/purgeStoredState.js' {\n+ declare module.exports: $Exports<'redux-persist/es/purgeStoredState'>;\n+}\n+declare module 'redux-persist/es/stateReconciler/autoMergeLevel1.js' {\n+ declare module.exports: $Exports<'redux-persist/es/stateReconciler/autoMergeLevel1'>;\n+}\n+declare module 'redux-persist/es/stateReconciler/autoMergeLevel2.js' {\n+ declare module.exports: $Exports<'redux-persist/es/stateReconciler/autoMergeLevel2'>;\n+}\n+declare module 'redux-persist/es/stateReconciler/hardSet.js' {\n+ declare module.exports: $Exports<'redux-persist/es/stateReconciler/hardSet'>;\n+}\n+declare module 'redux-persist/es/storage/createWebStorage.js' {\n+ declare module.exports: $Exports<'redux-persist/es/storage/createWebStorage'>;\n+}\n+declare module 'redux-persist/es/storage/getStorage.js' {\n+ declare module.exports: $Exports<'redux-persist/es/storage/getStorage'>;\n+}\n+declare module 'redux-persist/es/storage/index.js' {\n+ declare module.exports: $Exports<'redux-persist/es/storage/index'>;\n+}\n+declare module 'redux-persist/es/storage/index.native.js' {\n+ declare module.exports: $Exports<'redux-persist/es/storage/index.native'>;\n+}\n+declare module 'redux-persist/es/storage/session.js' {\n+ declare module.exports: $Exports<'redux-persist/es/storage/session'>;\n+}\n+declare module 'redux-persist/es/types.js' {\n+ declare module.exports: $Exports<'redux-persist/es/types'>;\n+}\n+declare module 'redux-persist/es/utils/curry.js' {\n+ declare module.exports: $Exports<'redux-persist/es/utils/curry'>;\n+}\n+declare module 'redux-persist/lib/constants.js' {\n+ declare module.exports: $Exports<'redux-persist/lib/constants'>;\n+}\n+declare module 'redux-persist/lib/createMigrate.js' {\n+ declare module.exports: $Exports<'redux-persist/lib/createMigrate'>;\n+}\n+declare module 'redux-persist/lib/createPersistoid.js' {\n+ declare module.exports: $Exports<'redux-persist/lib/createPersistoid'>;\n+}\n+declare module 'redux-persist/lib/createTransform.js' {\n+ declare module.exports: $Exports<'redux-persist/lib/createTransform'>;\n+}\n+declare module 'redux-persist/lib/getStoredState.js' {\n+ declare module.exports: $Exports<'redux-persist/lib/getStoredState'>;\n+}\n+declare module 'redux-persist/lib/index.js' {\n+ declare module.exports: $Exports<'redux-persist/lib/index'>;\n+}\n+declare module 'redux-persist/lib/integration/getStoredStateMigrateV4.js' {\n+ declare module.exports: $Exports<'redux-persist/lib/integration/getStoredStateMigrateV4'>;\n+}\n+declare module 'redux-persist/lib/integration/react.js' {\n+ declare module.exports: $Exports<'redux-persist/lib/integration/react'>;\n+}\n+declare module 'redux-persist/lib/persistCombineReducers.js' {\n+ declare module.exports: $Exports<'redux-persist/lib/persistCombineReducers'>;\n+}\n+declare module 'redux-persist/lib/persistReducer.js' {\n+ declare module.exports: $Exports<'redux-persist/lib/persistReducer'>;\n+}\n+declare module 'redux-persist/lib/persistStore.js' {\n+ declare module.exports: $Exports<'redux-persist/lib/persistStore'>;\n+}\n+declare module 'redux-persist/lib/purgeStoredState.js' {\n+ declare module.exports: $Exports<'redux-persist/lib/purgeStoredState'>;\n+}\n+declare module 'redux-persist/lib/stateReconciler/autoMergeLevel1.js' {\n+ declare module.exports: $Exports<'redux-persist/lib/stateReconciler/autoMergeLevel1'>;\n+}\n+declare module 'redux-persist/lib/stateReconciler/autoMergeLevel2.js' {\n+ declare module.exports: $Exports<'redux-persist/lib/stateReconciler/autoMergeLevel2'>;\n+}\n+declare module 'redux-persist/lib/stateReconciler/hardSet.js' {\n+ declare module.exports: $Exports<'redux-persist/lib/stateReconciler/hardSet'>;\n+}\n+declare module 'redux-persist/lib/storage/createWebStorage.js' {\n+ declare module.exports: $Exports<'redux-persist/lib/storage/createWebStorage'>;\n+}\n+declare module 'redux-persist/lib/storage/getStorage.js' {\n+ declare module.exports: $Exports<'redux-persist/lib/storage/getStorage'>;\n+}\n+declare module 'redux-persist/lib/storage/index.js' {\n+ declare module.exports: $Exports<'redux-persist/lib/storage/index'>;\n+}\n+declare module 'redux-persist/lib/storage/index.native.js' {\n+ declare module.exports: $Exports<'redux-persist/lib/storage/index.native'>;\n+}\n+declare module 'redux-persist/lib/storage/session.js' {\n+ declare module.exports: $Exports<'redux-persist/lib/storage/session'>;\n+}\n+declare module 'redux-persist/lib/types.js' {\n+ declare module.exports: $Exports<'redux-persist/lib/types'>;\n+}\n+declare module 'redux-persist/lib/utils/curry.js' {\n+ declare module.exports: $Exports<'redux-persist/lib/utils/curry'>;\n+}\n+declare module 'redux-persist/src/constants.js' {\n+ declare module.exports: $Exports<'redux-persist/src/constants'>;\n+}\n+declare module 'redux-persist/src/createMigrate.js' {\n+ declare module.exports: $Exports<'redux-persist/src/createMigrate'>;\n+}\n+declare module 'redux-persist/src/createPersistoid.js' {\n+ declare module.exports: $Exports<'redux-persist/src/createPersistoid'>;\n+}\n+declare module 'redux-persist/src/createTransform.js' {\n+ declare module.exports: $Exports<'redux-persist/src/createTransform'>;\n+}\n+declare module 'redux-persist/src/getStoredState.js' {\n+ declare module.exports: $Exports<'redux-persist/src/getStoredState'>;\n+}\n+declare module 'redux-persist/src/index.js' {\n+ declare module.exports: $Exports<'redux-persist/src/index'>;\n+}\n+declare module 'redux-persist/src/integration/getStoredStateMigrateV4.js' {\n+ declare module.exports: $Exports<'redux-persist/src/integration/getStoredStateMigrateV4'>;\n+}\n+declare module 'redux-persist/src/integration/react.js' {\n+ declare module.exports: $Exports<'redux-persist/src/integration/react'>;\n+}\n+declare module 'redux-persist/src/persistCombineReducers.js' {\n+ declare module.exports: $Exports<'redux-persist/src/persistCombineReducers'>;\n+}\n+declare module 'redux-persist/src/persistReducer.js' {\n+ declare module.exports: $Exports<'redux-persist/src/persistReducer'>;\n+}\n+declare module 'redux-persist/src/persistStore.js' {\n+ declare module.exports: $Exports<'redux-persist/src/persistStore'>;\n+}\n+declare module 'redux-persist/src/purgeStoredState.js' {\n+ declare module.exports: $Exports<'redux-persist/src/purgeStoredState'>;\n+}\n+declare module 'redux-persist/src/stateReconciler/autoMergeLevel1.js' {\n+ declare module.exports: $Exports<'redux-persist/src/stateReconciler/autoMergeLevel1'>;\n+}\n+declare module 'redux-persist/src/stateReconciler/autoMergeLevel2.js' {\n+ declare module.exports: $Exports<'redux-persist/src/stateReconciler/autoMergeLevel2'>;\n+}\n+declare module 'redux-persist/src/stateReconciler/hardSet.js' {\n+ declare module.exports: $Exports<'redux-persist/src/stateReconciler/hardSet'>;\n+}\n+declare module 'redux-persist/src/storage/createWebStorage.js' {\n+ declare module.exports: $Exports<'redux-persist/src/storage/createWebStorage'>;\n+}\n+declare module 'redux-persist/src/storage/getStorage.js' {\n+ declare module.exports: $Exports<'redux-persist/src/storage/getStorage'>;\n+}\n+declare module 'redux-persist/src/storage/index.js' {\n+ declare module.exports: $Exports<'redux-persist/src/storage/index'>;\n+}\n+declare module 'redux-persist/src/storage/index.native.js' {\n+ declare module.exports: $Exports<'redux-persist/src/storage/index.native'>;\n+}\n+declare module 'redux-persist/src/storage/session.js' {\n+ declare module.exports: $Exports<'redux-persist/src/storage/session'>;\n+}\n+declare module 'redux-persist/src/types.js' {\n+ declare module.exports: $Exports<'redux-persist/src/types'>;\n+}\n+declare module 'redux-persist/src/utils/curry.js' {\n+ declare module.exports: $Exports<'redux-persist/src/utils/curry'>;\n+}\n" }, { "change_type": "MODIFY", "old_path": "native/flow-typed/npm/url-parse_vx.x.x.js", "new_path": "native/flow-typed/npm/url-parse_vx.x.x.js", "diff": "-// flow-typed signature: 4506d8b5f279287dc0e34f53d118f251\n+// flow-typed signature: 3132a28b3d6a5067b514e1680148d3a8\n// flow-typed version: <<STUB>>/url-parse_v^1.1.9/flow_v0.57.3\n/**\n@@ -22,9 +22,21 @@ declare module 'url-parse' {\n* require those files directly. Feel free to delete any files that aren't\n* needed.\n*/\n+declare module 'url-parse/dist/url-parse' {\n+ declare module.exports: any;\n+}\n+declare module 'url-parse/dist/url-parse.min' {\n+ declare module.exports: any;\n+}\n// Filename aliases\n+declare module 'url-parse/dist/url-parse.js' {\n+ declare module.exports: $Exports<'url-parse/dist/url-parse'>;\n+}\n+declare module 'url-parse/dist/url-parse.min.js' {\n+ declare module.exports: $Exports<'url-parse/dist/url-parse.min'>;\n+}\ndeclare module 'url-parse/index' {\ndeclare module.exports: $Exports<'url-parse'>;\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#b221afc80b223d88ae6adffcebbaec67b46f6215\",\n+ \"version\": \"1.0.0-beta.27\",\n+ \"resolved\": \"https://registry.npmjs.org/react-navigation/-/react-navigation-1.0.0-beta.27.tgz\",\n+ \"integrity\": \"sha512-lYF25UxxSa/e1cC5mq1rM04n8+pFuZ2mXt6ef+hOPLmymtbNR6PE+PI7g+e0dkCa+b39qqh6nDz/szqEwim3ag==\",\n\"requires\": {\n\"babel-plugin-transform-define\": \"1.3.0\",\n\"clamp\": \"1.0.1\",\n\"integrity\": \"sha1-4Pmo6N/KfBe+kscSSVijuU6ykR0=\"\n},\n\"redux-persist\": {\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- \"lodash-es\": \"4.17.4\"\n- }\n+ \"version\": \"5.4.0\",\n+ \"resolved\": \"https://registry.npmjs.org/redux-persist/-/redux-persist-5.4.0.tgz\",\n+ \"integrity\": \"sha512-Ohp7g5WRx2rDyDk/bKKCgbD3ES6ahGPWxFEp3QPx2opwst0jJEbZKigZtQewUeJZnomN/7Zo3QglPDOZ6EdYEw==\"\n},\n\"redux-thunk\": {\n\"version\": \"2.2.0\",\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\",\n+ \"react-navigation\": \"^1.0.0-beta.27\",\n\"react-redux\": \"^5.0.6\",\n\"redux\": \"^3.7.2\",\n\"redux-devtools-extension\": \"^2.13.2\",\n- \"redux-persist\": \"^4.10.2\",\n+ \"redux-persist\": \"^5.4.0\",\n\"redux-thunk\": \"^2.2.0\",\n\"reselect\": \"^3.0.1\",\n\"shallowequal\": \"^1.0.2\",\n" }, { "change_type": "MODIFY", "old_path": "native/redux-setup.js", "new_path": "native/redux-setup.js", "diff": "@@ -9,12 +9,11 @@ import type { NavInfo } from './navigation-setup';\nimport React from 'react';\nimport invariant from 'invariant';\n-import { REHYDRATE } from 'redux-persist/constants';\nimport thunk from 'redux-thunk';\n-import { AsyncStorage } from 'react-native';\n+import storage from 'redux-persist/lib/storage';\nimport { createStore, applyMiddleware } from 'redux';\nimport { composeWithDevTools } from 'redux-devtools-extension';\n-import { autoRehydrate, persistStore } from 'redux-persist';\n+import { persistStore, persistReducer, REHYDRATE } from 'redux-persist';\nimport PropTypes from 'prop-types';\nimport { NavigationActions } from 'react-navigation';\n@@ -240,15 +239,23 @@ function validateState(oldState: AppState, state: AppState): AppState {\nreturn state;\n}\n+const persistConfig = {\n+ key: 'root',\n+ storage,\n+ blacklist,\n+ debug: __DEV__,\n+};\nconst store = createStore(\n+ persistReducer(\n+ persistConfig,\nreducer,\n+ ),\ndefaultState,\ncomposeWithDevTools(\napplyMiddleware(thunk),\n- autoRehydrate(),\n),\n);\n-const persistor = persistStore(store, { storage: AsyncStorage, blacklist });\n+const persistor = persistStore(store);\nexport {\nstore,\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Upgrade to redux-persist@5
129,187
18.01.2018 21:39:25
18,000
eb1ac67d777cc46302185b9d86104b9ac5ad8934
Call redux-persist REHYDRATE ourselves in __DEV__ on Android For some reason it doesn't fire when I refresh the app source in the Android emulator, so we need to manually fire it.
[ { "change_type": "MODIFY", "old_path": "native/app.react.js", "new_path": "native/app.react.js", "diff": "@@ -41,6 +41,7 @@ import PropTypes from 'prop-types';\nimport NotificationsIOS from 'react-native-notifications';\nimport InAppNotification from 'react-native-in-app-notification';\nimport FCM, { FCMEvent } from 'react-native-fcm';\n+import { REHYDRATE } from 'redux-persist';\nimport { registerConfig } from 'lib/utils/config';\nimport {\n@@ -177,6 +178,9 @@ class AppWithNavigationState extends React.PureComponent<Props> {\ninitialAndroidNotifHandled = false;\ncomponentDidMount() {\n+ if (__DEV__ && Platform.OS === \"android\") {\n+ this.props.dispatchActionPayload(REHYDRATE, null);\n+ }\nNativeAppState.addEventListener('change', this.handleAppStateChange);\nthis.handleInitialURL();\nLinking.addEventListener('url', this.handleURLChange);\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Call redux-persist REHYDRATE ourselves in __DEV__ on Android For some reason it doesn't fire when I refresh the app source in the Android emulator, so we need to manually fire it.
129,187
22.01.2018 12:48:51
25,200
ccdf0039080b7be818b852478aec07272c77c794
Break down Thread Settings components into individual rows This is necessary to convert to FlatList
[ { "change_type": "MODIFY", "old_path": "native/chat/settings/thread-settings-category.react.js", "new_path": "native/chat/settings/thread-settings-category.react.js", "diff": "import * as React from 'react';\nimport { View, Text, StyleSheet } from 'react-native';\n+import invariant from 'invariant';\n-type Props = {|\n+type HeaderProps = {|\ntype: \"full\" | \"outline\" | \"unpadded\",\ntitle: string,\n- children?: React.Node,\n|};\n-function ThreadSettingsCategory(props: Props) {\n+function ThreadSettingsCategoryHeader(props: HeaderProps) {\n+ let contentStyle, paddingStyle;\n+ if (props.type === \"full\") {\n+ contentStyle = styles.fullHeader;\n+ paddingStyle = styles.fullHeaderPadding;\n+ } else if (props.type === \"outline\") {\n+ } else if (props.type === \"unpadded\") {\n+ contentStyle = styles.fullHeader;\n+ } else {\n+ invariant(false, \"invalid ThreadSettingsCategory type\");\n+ }\nreturn (\n- <View style={styles.category}>\n+ <View>\n+ <View style={[ styles.header, contentStyle ]}>\n<Text style={styles.title}>\n{props.title.toUpperCase()}\n</Text>\n- <View style={styles[props.type]}>\n- {props.children}\n</View>\n+ <View style={paddingStyle} />\n+ </View>\n+ );\n+}\n+\n+type FooterProps = {|\n+ type: \"full\" | \"outline\" | \"unpadded\",\n+|};\n+function ThreadSettingsCategoryFooter(props: FooterProps) {\n+ let contentStyle, paddingStyle;\n+ if (props.type === \"full\") {\n+ contentStyle = styles.fullFooter;\n+ paddingStyle = styles.fullFooterPadding;\n+ } else if (props.type === \"outline\") {\n+ } else if (props.type === \"unpadded\") {\n+ contentStyle = styles.fullFooter;\n+ paddingStyle = styles.unpaddedFooterPadding;\n+ } else {\n+ invariant(false, \"invalid ThreadSettingsCategory type\");\n+ }\n+ return (\n+ <View>\n+ <View style={paddingStyle} />\n+ <View style={[ styles.footer, contentStyle ]} />\n</View>\n);\n}\nconst styles = StyleSheet.create({\n- category: {\n- marginVertical: 16,\n+ header: {\n+ marginTop: 16,\n+ },\n+ footer: {\n+ marginBottom: 16,\n},\ntitle: {\npaddingLeft: 24,\n@@ -32,29 +68,29 @@ const styles = StyleSheet.create({\nfontWeight: \"400\",\ncolor: \"#888888\",\n},\n- full: {\n- borderTopWidth: 1,\n+ fullHeader: {\nborderBottomWidth: 1,\nborderColor: \"#CCCCCC\",\n- paddingHorizontal: 24,\n- paddingVertical: 6,\n+ },\n+ fullHeaderPadding: {\nbackgroundColor: \"white\",\n+ height: 6,\n},\n- unpadded: {\n+ fullFooter: {\nborderTopWidth: 1,\n- borderBottomWidth: 1,\nborderColor: \"#CCCCCC\",\n+ },\n+ fullFooterPadding: {\nbackgroundColor: \"white\",\n+ height: 6,\n},\n- outline: {\n- borderWidth: 1,\n- borderStyle: 'dashed',\n- borderColor: \"#CCCCCC\",\n- backgroundColor: \"#F5F5F5FF\",\n- marginLeft: -1,\n- marginRight: -1,\n- borderRadius: 1,\n+ unpaddedFooterPadding: {\n+ backgroundColor: \"white\",\n+ height: 4,\n},\n});\n-export default ThreadSettingsCategory;\n+export {\n+ ThreadSettingsCategoryHeader,\n+ ThreadSettingsCategoryFooter,\n+};\n" }, { "change_type": "MODIFY", "old_path": "native/chat/settings/thread-settings.react.js", "new_path": "native/chat/settings/thread-settings.react.js", "diff": "@@ -61,7 +61,10 @@ import {\nimport { threadHasPermission, viewerIsMember } from 'lib/shared/thread-utils';\nimport threadWatcher from 'lib/shared/thread-watcher';\n-import ThreadSettingsCategory from './thread-settings-category.react';\n+import {\n+ ThreadSettingsCategoryHeader,\n+ ThreadSettingsCategoryFooter,\n+} from './thread-settings-category.react';\nimport ColorSplotch from '../../components/color-splotch.react';\nimport EditSettingButton from './edit-setting-button.react';\nimport Button from '../../components/button.react';\n@@ -318,8 +321,9 @@ class InnerThreadSettings extends React.PureComponent<Props, State> {\ntextInputStyle.height = this.state.descriptionTextHeight;\n}\ndescriptionPanel = (\n- <ThreadSettingsCategory type=\"full\" title=\"Description\">\n- <View style={[styles.noPaddingRow, styles.padding]}>\n+ <View>\n+ <ThreadSettingsCategoryHeader type=\"full\" title=\"Description\" />\n+ <View style={[styles.row, styles.rowVerticalHalfPadding]}>\n<TextInput\nstyle={[\nstyles.descriptionText,\n@@ -334,17 +338,21 @@ class InnerThreadSettings extends React.PureComponent<Props, State> {\nselectTextOnFocus={true}\nonBlur={this.submitDescriptionEdit}\neditable={this.props.descriptionEditLoadingStatus !== \"loading\"}\n- onContentSizeChange={this.onDescriptionTextInputContentSizeChange}\n+ onContentSizeChange={\n+ this.onDescriptionTextInputContentSizeChange\n+ }\nref={this.descriptionTextInputRef}\n/>\n{button}\n</View>\n- </ThreadSettingsCategory>\n+ <ThreadSettingsCategoryFooter type=\"full\" />\n+ </View>\n);\n} else if (this.props.threadInfo.description) {\ndescriptionPanel = (\n- <ThreadSettingsCategory type=\"full\" title=\"Description\">\n- <View style={[styles.noPaddingRow, styles.padding]}>\n+ <View>\n+ <ThreadSettingsCategoryHeader type=\"full\" title=\"Description\" />\n+ <View style={[styles.row, styles.rowVerticalHalfPadding]}>\n<Text\nstyle={[styles.descriptionText, styles.currentValueText]}\nonLayout={this.onLayoutDescriptionText}\n@@ -357,11 +365,14 @@ class InnerThreadSettings extends React.PureComponent<Props, State> {\nkey=\"editButton\"\n/>\n</View>\n- </ThreadSettingsCategory>\n+ <ThreadSettingsCategoryFooter type=\"full\" />\n+ </View>\n);\n} else if (canEditThread) {\ndescriptionPanel = (\n- <ThreadSettingsCategory type=\"outline\" title=\"Description\">\n+ <View>\n+ <ThreadSettingsCategoryHeader type=\"outline\" title=\"Description\" />\n+ <View style={styles.outlineCategory}>\n<Button\nonPress={this.onPressEditDescription}\nstyle={styles.addDescriptionButton}\n@@ -378,7 +389,9 @@ class InnerThreadSettings extends React.PureComponent<Props, State> {\ncolor=\"#888888\"\n/>\n</Button>\n- </ThreadSettingsCategory>\n+ </View>\n+ <ThreadSettingsCategoryFooter type=\"outline\" />\n+ </View>\n);\n}\n@@ -387,7 +400,7 @@ class InnerThreadSettings extends React.PureComponent<Props, State> {\nparent = (\n<Button\nonPress={this.onPressParentThread}\n- style={[styles.currentValue, styles.padding]}\n+ style={[styles.currentValue, styles.rowVerticalHalfPadding]}\n>\n<Text\nstyle={[styles.currentValueText, styles.parentThreadLink]}\n@@ -402,7 +415,7 @@ class InnerThreadSettings extends React.PureComponent<Props, State> {\n<Text style={[\nstyles.currentValue,\nstyles.currentValueText,\n- styles.padding,\n+ styles.rowVerticalHalfPadding,\nstyles.noParent,\n]}>\nNo parent\n@@ -480,12 +493,12 @@ class InnerThreadSettings extends React.PureComponent<Props, State> {\nlet membersPanel = null;\nif (addMembers || members) {\nmembersPanel = (\n- <ThreadSettingsCategory type=\"unpadded\" title=\"Members\">\n- <View style={styles.itemList}>\n+ <View>\n+ <ThreadSettingsCategoryHeader type=\"unpadded\" title=\"Members\" />\n{addMembers}\n{members}\n+ <ThreadSettingsCategoryFooter type=\"unpadded\" />\n</View>\n- </ThreadSettingsCategory>\n);\n}\n@@ -549,12 +562,12 @@ class InnerThreadSettings extends React.PureComponent<Props, State> {\nlet childThreadPanel = null;\nif (addChildThread || childThreads) {\nchildThreadPanel = (\n- <ThreadSettingsCategory type=\"unpadded\" title=\"Child threads\">\n- <View style={styles.itemList}>\n+ <View>\n+ <ThreadSettingsCategoryHeader type=\"unpadded\" title=\"Child threads\" />\n{addChildThread}\n{childThreads}\n+ <ThreadSettingsCategoryFooter type=\"unpadded\" />\n</View>\n- </ThreadSettingsCategory>\n);\n}\n@@ -583,8 +596,8 @@ class InnerThreadSettings extends React.PureComponent<Props, State> {\nreturn (\n<View>\n<ScrollView contentContainerStyle={styles.scrollView}>\n- <ThreadSettingsCategory type=\"full\" title=\"Basics\">\n- <View style={styles.row}>\n+ <ThreadSettingsCategoryHeader type=\"full\" title=\"Basics\" />\n+ <View style={[styles.row, styles.rowVerticalPadding]}>\n<Text style={styles.label}>Name</Text>\n{name}\n</View>\n@@ -595,20 +608,22 @@ class InnerThreadSettings extends React.PureComponent<Props, State> {\n</View>\n{colorButton}\n</View>\n- </ThreadSettingsCategory>\n+ <ThreadSettingsCategoryFooter type=\"full\" />\n{descriptionPanel}\n- <ThreadSettingsCategory type=\"full\" title=\"Privacy\">\n- <View style={styles.noPaddingRow}>\n- <Text style={[styles.label, styles.padding]}>Parent</Text>\n+ <ThreadSettingsCategoryHeader type=\"full\" title=\"Privacy\" />\n+ <View style={styles.row}>\n+ <Text style={[styles.label, styles.rowVerticalHalfPadding]}>\n+ Parent\n+ </Text>\n{parent}\n</View>\n- <View style={styles.row}>\n+ <View style={[styles.row, styles.rowVerticalPadding]}>\n<Text style={styles.label}>Visibility</Text>\n<Text style={[styles.currentValue, styles.currentValueText]}>\n{visibility}\n</Text>\n</View>\n- </ThreadSettingsCategory>\n+ <ThreadSettingsCategoryFooter type=\"full\" />\n{childThreadPanel}\n{membersPanel}\n{leaveThreadButton}\n@@ -937,14 +952,24 @@ const styles = StyleSheet.create({\nscrollView: {\npaddingVertical: 16,\n},\n+ outlineCategory: {\n+ backgroundColor: \"#F5F5F5FF\",\n+ borderWidth: 1,\n+ borderStyle: 'dashed',\n+ borderColor: \"#CCCCCC\",\n+ marginLeft: -1,\n+ marginRight: -1,\n+ borderRadius: 1,\n+ },\nrow: {\nflexDirection: 'row',\n- paddingVertical: 8,\n+ paddingHorizontal: 24,\n+ backgroundColor: \"white\",\n},\n- noPaddingRow: {\n- flexDirection: 'row',\n+ rowVerticalPadding: {\n+ paddingVertical: 8,\n},\n- padding: {\n+ rowVerticalHalfPadding: {\npaddingVertical: 4,\n},\nlabel: {\n@@ -956,6 +981,8 @@ const styles = StyleSheet.create({\nflexDirection: 'row',\npaddingTop: 4,\npaddingBottom: 8,\n+ paddingHorizontal: 24,\n+ backgroundColor: \"white\",\n},\ncolorLine: {\nlineHeight: Platform.select({ android: 22, default: 25 }),\n@@ -967,19 +994,22 @@ const styles = StyleSheet.create({\nitemRow: {\nflex: 1,\nflexDirection: 'row',\n- marginHorizontal: 12,\n+ paddingHorizontal: 12,\nborderTopWidth: 1,\nborderColor: \"#CCCCCC\",\n+ backgroundColor: \"white\",\n},\nseeMoreRow: {\nborderTopWidth: 1,\nborderColor: \"#CCCCCC\",\n- marginHorizontal: 12,\n+ paddingHorizontal: 12,\npaddingTop: 2,\n+ backgroundColor: \"white\",\n},\naddItemRow: {\n- marginHorizontal: 12,\n- marginTop: 4,\n+ paddingHorizontal: 12,\n+ paddingTop: 4,\n+ backgroundColor: \"white\",\n},\ncurrentValueText: {\npaddingRight: 0,\n@@ -995,9 +1025,6 @@ const styles = StyleSheet.create({\nparentThreadLink: {\ncolor: \"#036AFF\",\n},\n- itemList: {\n- paddingBottom: 4,\n- },\nseeMoreIcon: {\nposition: 'absolute',\nright: 10,\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Break down Thread Settings components into individual rows This is necessary to convert to FlatList
129,187
22.01.2018 14:03:35
25,200
5de77e3b303dc43712336559d5b3c042f9aab3dc
Factor out name row in thread settings
[ { "change_type": "ADD", "old_path": null, "new_path": "native/chat/settings/thread-settings-name.react.js", "diff": "+// @flow\n+\n+import type { ThreadInfo } from 'lib/types/thread-types';\n+import { threadInfoPropType } from 'lib/types/thread-types';\n+import type { ChangeThreadSettingsResult } from 'lib/actions/thread-actions';\n+import type { DispatchActionPromise } from 'lib/utils/action-utils';\n+import type { LoadingStatus } from 'lib/types/loading-types';\n+import { loadingStatusPropType } from 'lib/types/loading-types';\n+import type { AppState } from '../../redux-setup';\n+\n+import React from 'react';\n+import {\n+ Text,\n+ StyleSheet,\n+ Alert,\n+ ActivityIndicator,\n+ TextInput,\n+ View,\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+ includeDispatchActionProps,\n+ bindServerCalls,\n+} from 'lib/utils/action-utils';\n+import {\n+ changeThreadSettingsActionTypes,\n+ changeSingleThreadSetting,\n+} from 'lib/actions/thread-actions';\n+import { createLoadingStatusSelector } from 'lib/selectors/loading-selectors';\n+\n+import EditSettingButton from './edit-setting-button.react';\n+import SaveSettingButton from './save-setting-button.react';\n+\n+type Props = {|\n+ threadInfo: ThreadInfo,\n+ nameEditValue: ?string,\n+ setNameEditValue: (value: ?string, callback?: () => void) => void,\n+ nameTextHeight: ?number,\n+ setNameTextHeight: (number: number) => void,\n+ canChangeSettings: bool,\n+ // Redux state\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+|};\n+class ThreadSettingsName extends React.PureComponent<Props> {\n+\n+ static propTypes = {\n+ threadInfo: threadInfoPropType.isRequired,\n+ nameEditValue: PropTypes.string,\n+ setNameEditValue: PropTypes.func.isRequired,\n+ nameTextHeight: PropTypes.number,\n+ setNameTextHeight: PropTypes.func.isRequired,\n+ canChangeSettings: PropTypes.bool.isRequired,\n+ loadingStatus: loadingStatusPropType.isRequired,\n+ dispatchActionPromise: PropTypes.func.isRequired,\n+ changeSingleThreadSetting: PropTypes.func.isRequired,\n+ };\n+ textInput: ?TextInput;\n+\n+ render() {\n+ return (\n+ <View style={styles.row}>\n+ <Text style={styles.label}>Name</Text>\n+ {this.renderContent()}\n+ </View>\n+ );\n+ }\n+\n+ renderContent() {\n+ if (\n+ this.props.nameEditValue === null ||\n+ this.props.nameEditValue === undefined\n+ ) {\n+ return [\n+ <Text\n+ style={styles.currentValue}\n+ onLayout={this.onLayoutText}\n+ key=\"text\"\n+ >\n+ {this.props.threadInfo.uiName}\n+ </Text>,\n+ <EditSettingButton\n+ onPress={this.onPressEdit}\n+ canChangeSettings={this.props.canChangeSettings}\n+ key=\"editButton\"\n+ />,\n+ ];\n+ }\n+\n+ let button;\n+ if (this.props.loadingStatus !== \"loading\") {\n+ button = (\n+ <SaveSettingButton\n+ onPress={this.onSubmit}\n+ key=\"saveButton\"\n+ />\n+ );\n+ } else {\n+ button = <ActivityIndicator size=\"small\" key=\"activityIndicator\" />;\n+ }\n+\n+ const textInputStyle = {};\n+ if (\n+ this.props.nameTextHeight !== undefined &&\n+ this.props.nameTextHeight !== null\n+ ) {\n+ textInputStyle.height = this.props.nameTextHeight;\n+ }\n+\n+ return [\n+ <TextInput\n+ style={[styles.currentValue, textInputStyle]}\n+ underlineColorAndroid=\"transparent\"\n+ value={this.props.nameEditValue}\n+ onChangeText={this.props.setNameEditValue}\n+ multiline={true}\n+ autoFocus={true}\n+ selectTextOnFocus={true}\n+ onBlur={this.onSubmit}\n+ editable={this.props.loadingStatus !== \"loading\"}\n+ onContentSizeChange={this.onTextInputContentSizeChange}\n+ ref={this.textInputRef}\n+ key=\"textInput\"\n+ />,\n+ button,\n+ ];\n+ }\n+\n+ textInputRef = (textInput: ?TextInput) => {\n+ this.textInput = textInput;\n+ }\n+\n+ onLayoutText = (event: { nativeEvent: { layout: { height: number } } }) => {\n+ this.props.setNameTextHeight(event.nativeEvent.layout.height);\n+ }\n+\n+ onTextInputContentSizeChange = (\n+ event: { nativeEvent: { contentSize: { height: number } } },\n+ ) => {\n+ this.props.setNameTextHeight(event.nativeEvent.contentSize.height);\n+ }\n+\n+ threadEditName() {\n+ return this.props.threadInfo.name ? this.props.threadInfo.name : \"\";\n+ }\n+\n+ onPressEdit = () => {\n+ this.props.setNameEditValue(this.threadEditName());\n+ }\n+\n+ onSubmit = () => {\n+ invariant(\n+ this.props.nameEditValue !== null &&\n+ this.props.nameEditValue !== undefined,\n+ \"should be set\",\n+ );\n+ const name = this.props.nameEditValue.trim();\n+\n+ if (name === this.threadEditName()) {\n+ this.props.setNameEditValue(null);\n+ return;\n+ }\n+\n+ this.props.dispatchActionPromise(\n+ changeThreadSettingsActionTypes,\n+ this.editName(name),\n+ { customKeyName: `${changeThreadSettingsActionTypes.started}: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.props.setNameEditValue(null);\n+ return result;\n+ } catch (e) {\n+ Alert.alert(\n+ \"Unknown error\",\n+ \"Uhh... try again?\",\n+ [\n+ { text: 'OK', onPress: this.onErrorAcknowledged },\n+ ],\n+ { cancelable: false },\n+ );\n+ throw e;\n+ }\n+ }\n+\n+ onErrorAcknowledged = () => {\n+ this.props.setNameEditValue(\n+ this.threadEditName(),\n+ () => {\n+ invariant(this.textInput, \"textInput should be set\");\n+ this.textInput.focus();\n+ },\n+ );\n+ }\n+\n+}\n+\n+const styles = StyleSheet.create({\n+ row: {\n+ flexDirection: 'row',\n+ paddingHorizontal: 24,\n+ backgroundColor: \"white\",\n+ paddingVertical: 8,\n+ },\n+ label: {\n+ fontSize: 16,\n+ width: 96,\n+ color: \"#888888\",\n+ },\n+ currentValue: {\n+ flex: 1,\n+ paddingLeft: 4,\n+ paddingRight: 0,\n+ paddingVertical: 0,\n+ margin: 0,\n+ fontSize: 16,\n+ color: \"#333333\",\n+ fontFamily: 'Arial',\n+ },\n+});\n+\n+const loadingStatusSelector = createLoadingStatusSelector(\n+ changeThreadSettingsActionTypes,\n+ `${changeThreadSettingsActionTypes.started}:name`,\n+);\n+\n+export default connect(\n+ (state: AppState) => ({\n+ loadingStatus: loadingStatusSelector(state),\n+ cookie: state.cookie,\n+ }),\n+ includeDispatchActionProps,\n+ bindServerCalls({ changeSingleThreadSetting }),\n+)(ThreadSettingsName);\n" }, { "change_type": "MODIFY", "old_path": "native/chat/settings/thread-settings.react.js", "new_path": "native/chat/settings/thread-settings.react.js", "diff": "@@ -77,6 +77,7 @@ import { AddThreadRouteName } from '../add-thread.react';\nimport { registerChatScreen } from '../chat-screen-registry';\nimport SaveSettingButton from './save-setting-button.react';\nimport ColorPickerModal from '../color-picker-modal.react';\n+import ThreadSettingsName from './thread-settings-name.react';\nconst itemPageLength = 5;\n@@ -148,7 +149,6 @@ class InnerThreadSettings extends React.PureComponent<Props, State> {\ntitle: navigation.state.params.threadInfo.uiName,\nheaderBackTitle: \"Back\",\n});\n- nameTextInput: ?TextInput;\ndescriptionTextInput: ?TextInput;\nconstructor(props: Props) {\n@@ -235,63 +235,6 @@ class InnerThreadSettings extends React.PureComponent<Props, State> {\n);\nconst canChangeSettings = canEditThread && canStartEditing;\n- let name;\n- if (\n- this.state.nameEditValue === null ||\n- this.state.nameEditValue === undefined\n- ) {\n- name = [\n- <Text\n- style={[styles.currentValue, styles.currentValueText]}\n- onLayout={this.onLayoutNameText}\n- key=\"text\"\n- >\n- {this.props.threadInfo.uiName}\n- </Text>,\n- <EditSettingButton\n- onPress={this.onPressEditName}\n- canChangeSettings={canChangeSettings}\n- key=\"editButton\"\n- />,\n- ];\n- } else {\n- let button;\n- if (this.props.nameEditLoadingStatus !== \"loading\") {\n- button = (\n- <SaveSettingButton\n- onPress={this.submitNameEdit}\n- key=\"saveButton\"\n- />\n- );\n- } else {\n- button = <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- }\n- name = [\n- <TextInput\n- style={[styles.currentValue, styles.currentValueText, textInputStyle]}\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={this.props.nameEditLoadingStatus !== \"loading\"}\n- onContentSizeChange={this.onNameTextInputContentSizeChange}\n- ref={this.nameTextInputRef}\n- key=\"textInput\"\n- />,\n- button,\n- ];\n- }\n-\nlet colorButton;\nif (this.props.colorEditLoadingStatus !== \"loading\") {\ncolorButton = (\n@@ -597,10 +540,14 @@ class InnerThreadSettings extends React.PureComponent<Props, State> {\n<View>\n<ScrollView contentContainerStyle={styles.scrollView}>\n<ThreadSettingsCategoryHeader type=\"full\" title=\"Basics\" />\n- <View style={[styles.row, styles.rowVerticalPadding]}>\n- <Text style={styles.label}>Name</Text>\n- {name}\n- </View>\n+ <ThreadSettingsName\n+ threadInfo={this.props.threadInfo}\n+ nameEditValue={this.state.nameEditValue}\n+ setNameEditValue={this.setNameEditValue}\n+ nameTextHeight={this.state.nameTextHeight}\n+ setNameTextHeight={this.setNameTextHeight}\n+ canChangeSettings={canChangeSettings}\n+ />\n<View style={styles.colorRow}>\n<Text style={[styles.label, styles.colorLine]}>Color</Text>\n<View style={styles.currentValue}>\n@@ -649,94 +596,12 @@ class InnerThreadSettings extends React.PureComponent<Props, State> {\n);\n}\n- nameTextInputRef = (nameTextInput: ?TextInput) => {\n- this.nameTextInput = nameTextInput;\n- }\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-\n- threadEditName() {\n- return this.props.threadInfo.name ? this.props.threadInfo.name : \"\";\n+ setNameEditValue = (value: ?string, callback?: () => void) => {\n+ this.setState({ nameEditValue: value }, callback);\n}\n- onPressEditName = () => {\n- this.setState({ nameEditValue: this.threadEditName() });\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-\n- if (name === this.threadEditName()) {\n- this.setState({ nameEditValue: null });\n- return;\n- } else 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- { customKeyName: `${changeThreadSettingsActionTypes.started}: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- }\n-\n- onNameErrorAcknowledged = () => {\n- this.setState(\n- { nameEditValue: this.threadEditName() },\n- () => {\n- invariant(this.nameTextInput, \"nameTextInput should be set\");\n- this.nameTextInput.focus();\n- },\n- );\n+ setNameTextHeight = (height: number) => {\n+ this.setState({ nameTextHeight: height });\n}\nonPressEditColor = () => {\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Factor out name row in thread settings
129,187
22.01.2018 14:41:04
25,200
022c261608f4bfdb35e246917fac1c4c3ec8e8cf
Factor out description category in thread settings
[ { "change_type": "ADD", "old_path": null, "new_path": "native/chat/settings/thread-settings-description.react.js", "diff": "+// @flow\n+\n+import type { ThreadInfo } from 'lib/types/thread-types';\n+import { threadInfoPropType, threadPermissions } from 'lib/types/thread-types';\n+import type { ChangeThreadSettingsResult } from 'lib/actions/thread-actions';\n+import type { DispatchActionPromise } from 'lib/utils/action-utils';\n+import type { LoadingStatus } from 'lib/types/loading-types';\n+import { loadingStatusPropType } from 'lib/types/loading-types';\n+import type { AppState } from '../../redux-setup';\n+\n+import React from 'react';\n+import {\n+ Text,\n+ StyleSheet,\n+ Alert,\n+ ActivityIndicator,\n+ TextInput,\n+ View,\n+} from 'react-native';\n+import { connect } from 'react-redux';\n+import PropTypes from 'prop-types';\n+import invariant from 'invariant';\n+import Icon from 'react-native-vector-icons/FontAwesome';\n+\n+import {\n+ includeDispatchActionProps,\n+ bindServerCalls,\n+} from 'lib/utils/action-utils';\n+import {\n+ changeThreadSettingsActionTypes,\n+ changeSingleThreadSetting,\n+} from 'lib/actions/thread-actions';\n+import { createLoadingStatusSelector } from 'lib/selectors/loading-selectors';\n+import { threadHasPermission } from 'lib/shared/thread-utils';\n+\n+import EditSettingButton from './edit-setting-button.react';\n+import SaveSettingButton from './save-setting-button.react';\n+import {\n+ ThreadSettingsCategoryHeader,\n+ ThreadSettingsCategoryFooter,\n+} from './thread-settings-category.react';\n+import Button from '../../components/button.react';\n+\n+type Props = {|\n+ threadInfo: ThreadInfo,\n+ descriptionEditValue: ?string,\n+ setDescriptionEditValue: (value: ?string, callback?: () => void) => void,\n+ descriptionTextHeight: ?number,\n+ setDescriptionTextHeight: (number: number) => void,\n+ canChangeSettings: bool,\n+ // Redux state\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+|};\n+class ThreadSettingsDescription extends React.PureComponent<Props> {\n+\n+ static propTypes = {\n+ threadInfo: threadInfoPropType.isRequired,\n+ descriptionEditValue: PropTypes.string,\n+ setDescriptionEditValue: PropTypes.func.isRequired,\n+ descriptionTextHeight: PropTypes.number,\n+ setDescriptionTextHeight: PropTypes.func.isRequired,\n+ canChangeSettings: PropTypes.bool.isRequired,\n+ loadingStatus: loadingStatusPropType.isRequired,\n+ dispatchActionPromise: PropTypes.func.isRequired,\n+ changeSingleThreadSetting: PropTypes.func.isRequired,\n+ };\n+ textInput: ?TextInput;\n+\n+ render() {\n+ if (\n+ this.props.descriptionEditValue !== null &&\n+ this.props.descriptionEditValue !== undefined\n+ ) {\n+ const button = this.props.loadingStatus !== \"loading\"\n+ ? <SaveSettingButton onPress={this.onSubmit} />\n+ : <ActivityIndicator size=\"small\" />;\n+ const textInputStyle = {};\n+ if (\n+ this.props.descriptionTextHeight !== undefined &&\n+ this.props.descriptionTextHeight !== null\n+ ) {\n+ textInputStyle.height = this.props.descriptionTextHeight;\n+ }\n+ return (\n+ <View>\n+ <ThreadSettingsCategoryHeader type=\"full\" title=\"Description\" />\n+ <View style={styles.row}>\n+ <TextInput\n+ style={[ styles.text, textInputStyle ]}\n+ underlineColorAndroid=\"transparent\"\n+ value={this.props.descriptionEditValue}\n+ onChangeText={this.props.setDescriptionEditValue}\n+ multiline={true}\n+ autoFocus={true}\n+ selectTextOnFocus={true}\n+ onBlur={this.onSubmit}\n+ editable={this.props.loadingStatus !== \"loading\"}\n+ onContentSizeChange={this.onTextInputContentSizeChange}\n+ ref={this.textInputRef}\n+ />\n+ {button}\n+ </View>\n+ <ThreadSettingsCategoryFooter type=\"full\" />\n+ </View>\n+ );\n+ }\n+\n+ if (this.props.threadInfo.description) {\n+ return (\n+ <View>\n+ <ThreadSettingsCategoryHeader type=\"full\" title=\"Description\" />\n+ <View style={styles.row}>\n+ <Text style={styles.text} onLayout={this.onLayoutText}>\n+ {this.props.threadInfo.description}\n+ </Text>\n+ <EditSettingButton\n+ onPress={this.onPressEdit}\n+ canChangeSettings={this.props.canChangeSettings}\n+ key=\"editButton\"\n+ />\n+ </View>\n+ <ThreadSettingsCategoryFooter type=\"full\" />\n+ </View>\n+ );\n+ }\n+\n+ const canEditThread = threadHasPermission(\n+ this.props.threadInfo,\n+ threadPermissions.EDIT_THREAD,\n+ );\n+ if (canEditThread) {\n+ return (\n+ <View>\n+ <ThreadSettingsCategoryHeader type=\"outline\" title=\"Description\" />\n+ <View style={styles.outlineCategory}>\n+ <Button\n+ onPress={this.onPressEdit}\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+ </View>\n+ <ThreadSettingsCategoryFooter type=\"outline\" />\n+ </View>\n+ );\n+ }\n+\n+ return null;\n+ }\n+\n+ textInputRef = (textInput: ?TextInput) => {\n+ this.textInput = textInput;\n+ }\n+\n+ onLayoutText = (event: { nativeEvent: { layout: { height: number } } }) => {\n+ this.props.setDescriptionTextHeight(event.nativeEvent.layout.height);\n+ }\n+\n+ onTextInputContentSizeChange = (\n+ event: { nativeEvent: { contentSize: { height: number } } },\n+ ) => {\n+ this.props.setDescriptionTextHeight(event.nativeEvent.contentSize.height);\n+ }\n+\n+ onPressEdit = () => {\n+ this.props.setDescriptionEditValue(this.props.threadInfo.description);\n+ }\n+\n+ onSubmit = () => {\n+ invariant(\n+ this.props.descriptionEditValue !== null &&\n+ this.props.descriptionEditValue !== undefined,\n+ \"should be set\",\n+ );\n+ const description = this.props.descriptionEditValue.trim();\n+\n+ if (description === this.props.threadInfo.description) {\n+ this.props.setDescriptionEditValue(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.props.setDescriptionEditValue(null);\n+ return result;\n+ } catch (e) {\n+ Alert.alert(\n+ \"Unknown error\",\n+ \"Uhh... try again?\",\n+ [\n+ { text: 'OK', onPress: this.onErrorAcknowledged },\n+ ],\n+ { cancelable: false },\n+ );\n+ throw e;\n+ }\n+ }\n+\n+ onErrorAcknowledged = () => {\n+ this.props.setDescriptionEditValue(\n+ this.props.threadInfo.description,\n+ () => {\n+ invariant(this.textInput, \"textInput should be set\");\n+ this.textInput.focus();\n+ },\n+ );\n+ }\n+\n+}\n+\n+const styles = StyleSheet.create({\n+ row: {\n+ flexDirection: 'row',\n+ paddingHorizontal: 24,\n+ backgroundColor: \"white\",\n+ paddingVertical: 4,\n+ },\n+ text: {\n+ flex: 1,\n+ padding: 0,\n+ margin: 0,\n+ fontSize: 16,\n+ color: \"#333333\",\n+ fontFamily: 'Arial',\n+ },\n+ addDescriptionButton: {\n+ flexDirection: 'row',\n+ paddingHorizontal: 24,\n+ paddingVertical: 10,\n+ },\n+ addDescriptionText: {\n+ fontSize: 16,\n+ color: \"#888888\",\n+ flex: 1,\n+ },\n+ outlineCategory: {\n+ backgroundColor: \"#F5F5F5FF\",\n+ borderWidth: 1,\n+ borderStyle: 'dashed',\n+ borderColor: \"#CCCCCC\",\n+ marginLeft: -1,\n+ marginRight: -1,\n+ borderRadius: 1,\n+ },\n+ editIcon: {\n+ textAlign: 'right',\n+ paddingLeft: 10,\n+ },\n+});\n+\n+const loadingStatusSelector = createLoadingStatusSelector(\n+ changeThreadSettingsActionTypes,\n+ `${changeThreadSettingsActionTypes.started}:description`,\n+);\n+\n+export default connect(\n+ (state: AppState) => ({\n+ loadingStatus: loadingStatusSelector(state),\n+ cookie: state.cookie,\n+ }),\n+ includeDispatchActionProps,\n+ bindServerCalls({ changeSingleThreadSetting }),\n+)(ThreadSettingsDescription);\n" }, { "change_type": "MODIFY", "old_path": "native/chat/settings/thread-settings.react.js", "new_path": "native/chat/settings/thread-settings.react.js", "diff": "@@ -78,6 +78,7 @@ import { registerChatScreen } from '../chat-screen-registry';\nimport SaveSettingButton from './save-setting-button.react';\nimport ColorPickerModal from '../color-picker-modal.react';\nimport ThreadSettingsName from './thread-settings-name.react';\n+import ThreadSettingsDescription from './thread-settings-description.react';\nconst itemPageLength = 5;\n@@ -149,7 +150,6 @@ class InnerThreadSettings extends React.PureComponent<Props, State> {\ntitle: navigation.state.params.threadInfo.uiName,\nheaderBackTitle: \"Back\",\n});\n- descriptionTextInput: ?TextInput;\nconstructor(props: Props) {\nsuper(props);\n@@ -248,96 +248,6 @@ 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- <View>\n- <ThreadSettingsCategoryHeader type=\"full\" title=\"Description\" />\n- <View style={[styles.row, styles.rowVerticalHalfPadding]}>\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={\n- this.onDescriptionTextInputContentSizeChange\n- }\n- ref={this.descriptionTextInputRef}\n- />\n- {button}\n- </View>\n- <ThreadSettingsCategoryFooter type=\"full\" />\n- </View>\n- );\n- } else if (this.props.threadInfo.description) {\n- descriptionPanel = (\n- <View>\n- <ThreadSettingsCategoryHeader type=\"full\" title=\"Description\" />\n- <View style={[styles.row, styles.rowVerticalHalfPadding]}>\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- <ThreadSettingsCategoryFooter type=\"full\" />\n- </View>\n- );\n- } else if (canEditThread) {\n- descriptionPanel = (\n- <View>\n- <ThreadSettingsCategoryHeader type=\"outline\" title=\"Description\" />\n- <View style={styles.outlineCategory}>\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- </View>\n- <ThreadSettingsCategoryFooter type=\"outline\" />\n- </View>\n- );\n- }\n-\nlet parent;\nif (this.props.parentThreadInfo) {\nparent = (\n@@ -556,7 +466,14 @@ class InnerThreadSettings extends React.PureComponent<Props, State> {\n{colorButton}\n</View>\n<ThreadSettingsCategoryFooter type=\"full\" />\n- {descriptionPanel}\n+ <ThreadSettingsDescription\n+ threadInfo={this.props.threadInfo}\n+ descriptionEditValue={this.state.descriptionEditValue}\n+ setDescriptionEditValue={this.setDescriptionEditValue}\n+ descriptionTextHeight={this.state.descriptionTextHeight}\n+ setDescriptionTextHeight={this.setDescriptionTextHeight}\n+ canChangeSettings={canChangeSettings}\n+ />\n<ThreadSettingsCategoryHeader type=\"full\" title=\"Privacy\" />\n<View style={styles.row}>\n<Text style={[styles.label, styles.rowVerticalHalfPadding]}>\n@@ -646,87 +563,12 @@ 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+ setDescriptionEditValue = (value: ?string, callback?: () => void) => {\n+ this.setState({ descriptionEditValue: value }, callback);\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+ setDescriptionTextHeight = (height: number) => {\n+ this.setState({ descriptionTextHeight: height });\n}\nonPressParentThread = () => {\n@@ -817,15 +659,6 @@ const styles = StyleSheet.create({\nscrollView: {\npaddingVertical: 16,\n},\n- outlineCategory: {\n- backgroundColor: \"#F5F5F5FF\",\n- borderWidth: 1,\n- borderStyle: 'dashed',\n- borderColor: \"#CCCCCC\",\n- marginLeft: -1,\n- marginRight: -1,\n- borderRadius: 1,\n- },\nrow: {\nflexDirection: 'row',\npaddingHorizontal: 24,\n@@ -895,24 +728,6 @@ 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- },\nleaveThread: {\nmarginVertical: 16,\nborderTopWidth: 1,\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Factor out description category in thread settings
129,187
22.01.2018 16:57:57
25,200
015694f9e5ed01530761eaae4643b801fc7b9bd1
Factor out color row in thread settings
[ { "change_type": "ADD", "old_path": null, "new_path": "native/chat/settings/thread-settings-color.react.js", "diff": "+// @flow\n+\n+import type { ThreadInfo } from 'lib/types/thread-types';\n+import { threadInfoPropType } from 'lib/types/thread-types';\n+import type { ChangeThreadSettingsResult } from 'lib/actions/thread-actions';\n+import type { DispatchActionPromise } from 'lib/utils/action-utils';\n+import type { LoadingStatus } from 'lib/types/loading-types';\n+import { loadingStatusPropType } from 'lib/types/loading-types';\n+import type { AppState } from '../../redux-setup';\n+\n+import React from 'react';\n+import {\n+ Text,\n+ StyleSheet,\n+ Alert,\n+ ActivityIndicator,\n+ View,\n+ Platform,\n+} from 'react-native';\n+import { connect } from 'react-redux';\n+import PropTypes from 'prop-types';\n+\n+import {\n+ includeDispatchActionProps,\n+ bindServerCalls,\n+} from 'lib/utils/action-utils';\n+import {\n+ changeThreadSettingsActionTypes,\n+ changeSingleThreadSetting,\n+} from 'lib/actions/thread-actions';\n+import { createLoadingStatusSelector } from 'lib/selectors/loading-selectors';\n+\n+import EditSettingButton from './edit-setting-button.react';\n+import ColorSplotch from '../../components/color-splotch.react';\n+import ColorPickerModal from '../color-picker-modal.react';\n+\n+type Props = {|\n+ threadInfo: ThreadInfo,\n+ colorEditValue: string,\n+ setColorEditValue: (color: string) => void,\n+ showEditColorModal: bool,\n+ setEditColorModalVisibility: (visible: bool) => void,\n+ canChangeSettings: bool,\n+ // Redux state\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+|};\n+class ThreadSettingsColor extends React.PureComponent<Props> {\n+\n+ static propTypes = {\n+ threadInfo: threadInfoPropType.isRequired,\n+ colorEditValue: PropTypes.string.isRequired,\n+ setColorEditValue: PropTypes.func.isRequired,\n+ showEditColorModal: PropTypes.bool.isRequired,\n+ setEditColorModalVisibility: PropTypes.func.isRequired,\n+ canChangeSettings: PropTypes.bool.isRequired,\n+ loadingStatus: loadingStatusPropType.isRequired,\n+ dispatchActionPromise: PropTypes.func.isRequired,\n+ changeSingleThreadSetting: PropTypes.func.isRequired,\n+ };\n+\n+ render() {\n+ let colorButton;\n+ if (this.props.loadingStatus !== \"loading\") {\n+ colorButton = (\n+ <EditSettingButton\n+ onPress={this.onPressEditColor}\n+ canChangeSettings={this.props.canChangeSettings}\n+ style={styles.colorLine}\n+ />\n+ );\n+ } else {\n+ colorButton = <ActivityIndicator size=\"small\" key=\"activityIndicator\" />;\n+ }\n+\n+ return (\n+ <View style={styles.colorRow}>\n+ <Text style={[styles.label, styles.colorLine]}>Color</Text>\n+ <View style={styles.currentValue}>\n+ <ColorSplotch color={this.props.threadInfo.color} />\n+ </View>\n+ {colorButton}\n+ <ColorPickerModal\n+ isVisible={this.props.showEditColorModal}\n+ closeModal={this.closeColorPicker}\n+ color={this.props.colorEditValue}\n+ oldColor={this.props.threadInfo.color}\n+ onColorSelected={this.onColorSelected}\n+ />\n+ </View>\n+ );\n+ }\n+\n+ onPressEditColor = () => {\n+ this.props.setEditColorModalVisibility(true);\n+ }\n+\n+ closeColorPicker = () => {\n+ this.props.setEditColorModalVisibility(false);\n+ }\n+\n+ onColorSelected = (color: string) => {\n+ const colorEditValue = color.substr(1);\n+ this.props.setColorEditValue(colorEditValue);\n+ this.props.dispatchActionPromise(\n+ changeThreadSettingsActionTypes,\n+ this.editColor(colorEditValue),\n+ { customKeyName: `${changeThreadSettingsActionTypes.started}:color` },\n+ );\n+ }\n+\n+ async editColor(newColor: string) {\n+ try {\n+ return await this.props.changeSingleThreadSetting(\n+ this.props.threadInfo.id,\n+ \"color\",\n+ newColor,\n+ );\n+ } catch (e) {\n+ Alert.alert(\n+ \"Unknown error\",\n+ \"Uhh... try again?\",\n+ [\n+ { text: 'OK', onPress: this.onErrorAcknowledged },\n+ ],\n+ { cancelable: false },\n+ );\n+ throw e;\n+ }\n+ }\n+\n+ onErrorAcknowledged = () => {\n+ this.props.setColorEditValue(this.props.threadInfo.color);\n+ }\n+\n+}\n+\n+const styles = StyleSheet.create({\n+ colorRow: {\n+ flexDirection: 'row',\n+ paddingTop: 4,\n+ paddingBottom: 8,\n+ paddingHorizontal: 24,\n+ backgroundColor: \"white\",\n+ },\n+ colorLine: {\n+ lineHeight: Platform.select({ android: 22, default: 25 }),\n+ },\n+ label: {\n+ fontSize: 16,\n+ width: 96,\n+ color: \"#888888\",\n+ },\n+ currentValue: {\n+ flex: 1,\n+ paddingLeft: 4,\n+ },\n+});\n+\n+const loadingStatusSelector = createLoadingStatusSelector(\n+ changeThreadSettingsActionTypes,\n+ `${changeThreadSettingsActionTypes.started}:color`,\n+);\n+\n+export default connect(\n+ (state: AppState) => ({\n+ loadingStatus: loadingStatusSelector(state),\n+ cookie: state.cookie,\n+ }),\n+ includeDispatchActionProps,\n+ bindServerCalls({ changeSingleThreadSetting }),\n+)(ThreadSettingsColor);\n" }, { "change_type": "MODIFY", "old_path": "native/chat/settings/thread-settings.react.js", "new_path": "native/chat/settings/thread-settings.react.js", "diff": "@@ -27,7 +27,6 @@ import {\nTextInput,\nAlert,\nActivityIndicator,\n- Platform,\n} from 'react-native';\nimport Modal from 'react-native-modal';\nimport invariant from 'invariant';\n@@ -65,7 +64,6 @@ import {\nThreadSettingsCategoryHeader,\nThreadSettingsCategoryFooter,\n} from './thread-settings-category.react';\n-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@@ -76,8 +74,8 @@ import ThreadSettingsChildThread from './thread-settings-child-thread.react';\nimport { AddThreadRouteName } from '../add-thread.react';\nimport { registerChatScreen } from '../chat-screen-registry';\nimport SaveSettingButton from './save-setting-button.react';\n-import ColorPickerModal from '../color-picker-modal.react';\nimport ThreadSettingsName from './thread-settings-name.react';\n+import ThreadSettingsColor from './thread-settings-color.react';\nimport ThreadSettingsDescription from './thread-settings-description.react';\nconst itemPageLength = 5;\n@@ -235,19 +233,6 @@ class InnerThreadSettings extends React.PureComponent<Props, State> {\n);\nconst canChangeSettings = canEditThread && canStartEditing;\n- let colorButton;\n- if (this.props.colorEditLoadingStatus !== \"loading\") {\n- colorButton = (\n- <EditSettingButton\n- onPress={this.onPressEditColor}\n- canChangeSettings={canChangeSettings}\n- style={styles.colorLine}\n- />\n- );\n- } else {\n- colorButton = <ActivityIndicator size=\"small\" key=\"activityIndicator\" />;\n- }\n-\nlet parent;\nif (this.props.parentThreadInfo) {\nparent = (\n@@ -458,13 +443,14 @@ class InnerThreadSettings extends React.PureComponent<Props, State> {\nsetNameTextHeight={this.setNameTextHeight}\ncanChangeSettings={canChangeSettings}\n/>\n- <View style={styles.colorRow}>\n- <Text style={[styles.label, styles.colorLine]}>Color</Text>\n- <View style={styles.currentValue}>\n- <ColorSplotch color={this.props.threadInfo.color} />\n- </View>\n- {colorButton}\n- </View>\n+ <ThreadSettingsColor\n+ threadInfo={this.props.threadInfo}\n+ colorEditValue={this.state.colorEditValue}\n+ setColorEditValue={this.setColorEditValue}\n+ showEditColorModal={this.state.showEditColorModal}\n+ setEditColorModalVisibility={this.setEditColorModalVisibility}\n+ canChangeSettings={canChangeSettings}\n+ />\n<ThreadSettingsCategoryFooter type=\"full\" />\n<ThreadSettingsDescription\nthreadInfo={this.props.threadInfo}\n@@ -502,13 +488,6 @@ class InnerThreadSettings extends React.PureComponent<Props, State> {\nclose={this.closeAddUsersModal}\n/>\n</Modal>\n- <ColorPickerModal\n- isVisible={this.state.showEditColorModal}\n- closeModal={this.closeColorPicker}\n- color={this.state.colorEditValue}\n- oldColor={this.props.threadInfo.color}\n- onColorSelected={this.onColorSelected}\n- />\n</View>\n);\n}\n@@ -521,46 +500,12 @@ class InnerThreadSettings extends React.PureComponent<Props, State> {\nthis.setState({ nameTextHeight: height });\n}\n- onPressEditColor = () => {\n- this.setState({ showEditColorModal: true });\n- }\n-\n- closeColorPicker = () => {\n- this.setState({ showEditColorModal: false });\n- }\n-\n- onColorSelected = (color: string) => {\n- const colorEditValue = color.substr(1);\n- this.setState({ showEditColorModal: false, colorEditValue });\n- this.props.dispatchActionPromise(\n- changeThreadSettingsActionTypes,\n- this.editColor(colorEditValue),\n- { customKeyName: `${changeThreadSettingsActionTypes.started}:color` },\n- );\n- }\n-\n- async editColor(newColor: string) {\n- try {\n- return await this.props.changeSingleThreadSetting(\n- this.props.threadInfo.id,\n- \"color\",\n- newColor,\n- );\n- } catch (e) {\n- Alert.alert(\n- \"Unknown error\",\n- \"Uhh... try again?\",\n- [\n- { text: 'OK', onPress: this.onColorErrorAcknowledged },\n- ],\n- { cancelable: false },\n- );\n- throw e;\n- }\n+ setEditColorModalVisibility = (visible: bool) => {\n+ this.setState({ showEditColorModal: visible });\n}\n- onColorErrorAcknowledged = () => {\n- this.setState({ colorEditValue: this.props.threadInfo.color });\n+ setColorEditValue = (color: string) => {\n+ this.setState({ showEditColorModal: false, colorEditValue: color });\n}\nsetDescriptionEditValue = (value: ?string, callback?: () => void) => {\n@@ -675,16 +620,6 @@ const styles = StyleSheet.create({\nwidth: 96,\ncolor: \"#888888\",\n},\n- colorRow: {\n- flexDirection: 'row',\n- paddingTop: 4,\n- paddingBottom: 8,\n- paddingHorizontal: 24,\n- backgroundColor: \"white\",\n- },\n- colorLine: {\n- lineHeight: Platform.select({ android: 22, default: 25 }),\n- },\ncurrentValue: {\nflex: 1,\npaddingLeft: 4,\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Factor out color row in thread settings
129,187
22.01.2018 17:50:20
25,200
5e8365fc2acfbb46cce31059509eda0e444f319d
Make sure to include currentUser even when current user isn't a member Without this we end up filtering these threadInfos from the client.
[ { "change_type": "MODIFY", "old_path": "jserver/src/fetchers/thread-fetcher.js", "new_path": "jserver/src/fetchers/thread-fetcher.js", "diff": "@@ -86,17 +86,24 @@ async function fetchThreadInfos(\n},\nthreadID,\n);\n+ const member = {\n+ id: userID,\n+ permissions: allPermissions,\n+ role: row.role ? row.role : null,\n+ };\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.\nif (row.role || allPermissions[threadPermissions.CHANGE_ROLE].value) {\n- const member = {\n+ threadInfos[threadID].members.push(member);\n+ if (row.username) {\n+ userInfos[userID] = {\nid: userID,\n- permissions: allPermissions,\n- role: row.role ? row.role : null,\n+ username: row.username,\n};\n- threadInfos[threadID].members.push(member);\n+ }\n+ }\nif (userID === viewerID) {\nthreadInfos[threadID].currentUser = {\npermissions: member.permissions,\n@@ -106,13 +113,6 @@ async function fetchThreadInfos(\n};\n}\n}\n- if (row.username) {\n- userInfos[userID] = {\n- id: userID,\n- username: row.username,\n- };\n- }\n- }\n}\nconst finalThreadInfos = {};\n" }, { "change_type": "MODIFY", "old_path": "native/redux-setup.js", "new_path": "native/redux-setup.js", "diff": "@@ -207,7 +207,11 @@ function validateState(oldState: AppState, state: AppState): AppState {\nrehydrateConcluded: state.rehydrateConcluded,\n};\n}\n- if (activeThread && oldActiveThread !== activeThread) {\n+ if (\n+ activeThread &&\n+ oldActiveThread !== activeThread &&\n+ state.messageStore.threads[activeThread]\n+ ) {\n// Update messageStore.threads[activeThread].lastNavigatedTo\nstate = {\nnavInfo: state.navInfo,\n" }, { "change_type": "MODIFY", "old_path": "server/thread_lib.php", "new_path": "server/thread_lib.php", "diff": "@@ -80,6 +80,11 @@ SQL;\n$permission_info = get_info_from_permissions_row($row);\n$all_permissions =\nget_all_thread_permissions($permission_info, $thread_id);\n+ $member = array(\n+ \"id\" => $user_id,\n+ \"permissions\" => $all_permissions,\n+ \"role\" => (int)$row['role'] === 0 ? null : $row['role'],\n+ );\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@@ -88,12 +93,14 @@ SQL;\n(int)$row['role'] !== 0 ||\n$all_permissions[PERMISSION_CHANGE_ROLE]['value']\n) {\n- $member = array(\n+ $thread_infos[$thread_id]['members'][] = $member;\n+ if ($row['username']) {\n+ $user_infos[$user_id] = array(\n\"id\" => $user_id,\n- \"permissions\" => $all_permissions,\n- \"role\" => (int)$row['role'] === 0 ? null : $row['role'],\n+ \"username\" => $row['username'],\n);\n- $thread_infos[$thread_id]['members'][] = $member;\n+ }\n+ }\nif ((int)$user_id === $viewer_id) {\n$thread_infos[$thread_id]['currentUser'] = array(\n\"permissions\" => $member['permissions'],\n@@ -103,13 +110,6 @@ SQL;\n);\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();\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Make sure to include currentUser even when current user isn't a member Without this we end up filtering these threadInfos from the client.
129,187
22.01.2018 18:05:05
25,200
aa986c4453c547496871e94ee2ed02633973fb0f
Factor out parent thread row in thread settings
[ { "change_type": "ADD", "old_path": null, "new_path": "native/chat/settings/thread-settings-parent.react.js", "diff": "+// @flow\n+\n+import type { ThreadInfo } from 'lib/types/thread-types';\n+import { threadInfoPropType } from 'lib/types/thread-types';\n+import type { AppState } from '../../redux-setup';\n+import type { NavigationParams } from 'react-navigation';\n+\n+import React from 'react';\n+import { Text, StyleSheet, View, Platform } from 'react-native';\n+import { connect } from 'react-redux';\n+import PropTypes from 'prop-types';\n+\n+import { threadInfoSelector } from 'lib/selectors/thread-selectors';\n+\n+import Button from '../../components/button.react';\n+import { MessageListRouteName } from '../message-list.react';\n+\n+type Props = {|\n+ threadInfo: ThreadInfo,\n+ navigate: (\n+ routeName: string,\n+ params?: NavigationParams,\n+ ) => bool,\n+ // Redux state\n+ parentThreadInfo?: ?ThreadInfo,\n+|};\n+class ThreadSettingsParent extends React.PureComponent<Props> {\n+\n+ static propTypes = {\n+ threadInfo: threadInfoPropType.isRequired,\n+ navigate: PropTypes.func.isRequired,\n+ parentThreadInfo: threadInfoPropType,\n+ };\n+\n+ render() {\n+ let parent;\n+ if (this.props.parentThreadInfo) {\n+ parent = (\n+ <Button onPress={this.onPressParentThread} style={styles.currentValue}>\n+ <Text\n+ style={[styles.currentValueText, styles.parentThreadLink]}\n+ numberOfLines={1}\n+ >\n+ {this.props.parentThreadInfo.uiName}\n+ </Text>\n+ </Button>\n+ );\n+ } else {\n+ parent = (\n+ <Text style={[\n+ styles.currentValue,\n+ styles.currentValueText,\n+ styles.noParent,\n+ ]}>\n+ No parent\n+ </Text>\n+ );\n+ }\n+ return (\n+ <View style={styles.row}>\n+ <Text style={styles.label}>\n+ Parent\n+ </Text>\n+ {parent}\n+ </View>\n+ );\n+ }\n+\n+ onPressParentThread = () => {\n+ this.props.navigate(\n+ MessageListRouteName,\n+ { threadInfo: this.props.parentThreadInfo },\n+ );\n+ }\n+\n+}\n+\n+const styles = StyleSheet.create({\n+ row: {\n+ flexDirection: 'row',\n+ paddingHorizontal: 24,\n+ backgroundColor: \"white\",\n+ },\n+ label: {\n+ fontSize: 16,\n+ width: 96,\n+ color: \"#888888\",\n+ paddingVertical: 4,\n+ },\n+ currentValue: {\n+ flex: 1,\n+ paddingLeft: 4,\n+ paddingTop: Platform.OS === \"ios\" ? 5 : 4,\n+ },\n+ currentValueText: {\n+ paddingRight: 0,\n+ margin: 0,\n+ fontSize: 16,\n+ color: \"#333333\",\n+ fontFamily: 'Arial',\n+ },\n+ noParent: {\n+ fontStyle: 'italic',\n+ },\n+ parentThreadLink: {\n+ color: \"#036AFF\",\n+ },\n+});\n+\n+export default connect(\n+ (state: AppState, ownProps: { threadInfo: ThreadInfo }): * => {\n+ const parsedThreadInfos = threadInfoSelector(state);\n+ const parentThreadInfo: ?ThreadInfo = ownProps.threadInfo.parentThreadID\n+ ? parsedThreadInfos[ownProps.threadInfo.parentThreadID]\n+ : null;\n+ return { parentThreadInfo };\n+ },\n+)(ThreadSettingsParent);\n" }, { "change_type": "MODIFY", "old_path": "native/chat/settings/thread-settings.react.js", "new_path": "native/chat/settings/thread-settings.react.js", "diff": "@@ -66,7 +66,6 @@ import {\n} from './thread-settings-category.react';\nimport EditSettingButton from './edit-setting-button.react';\nimport Button from '../../components/button.react';\n-import { MessageListRouteName } from '../message-list.react';\nimport ThreadSettingsUser from './thread-settings-user.react';\nimport ThreadSettingsListAction from './thread-settings-list-action.react';\nimport AddUsersModal from './add-users-modal.react';\n@@ -77,6 +76,7 @@ import SaveSettingButton from './save-setting-button.react';\nimport ThreadSettingsName from './thread-settings-name.react';\nimport ThreadSettingsColor from './thread-settings-color.react';\nimport ThreadSettingsDescription from './thread-settings-description.react';\n+import ThreadSettingsParent from './thread-settings-parent.react';\nconst itemPageLength = 5;\n@@ -85,7 +85,6 @@ type NavProp = NavigationScreenProp<NavigationRoute>\ntype StateProps = {|\nthreadInfo: ThreadInfo,\n- parentThreadInfo: ?ThreadInfo,\nthreadMembers: RelativeMemberInfo[],\nchildThreadInfos: ?ThreadInfo[],\nnameEditLoadingStatus: LoadingStatus,\n@@ -134,7 +133,6 @@ class InnerThreadSettings extends React.PureComponent<Props, State> {\nsetParams: PropTypes.func.isRequired,\n}).isRequired,\nthreadInfo: threadInfoPropType.isRequired,\n- parentThreadInfo: threadInfoPropType,\nthreadMembers: PropTypes.arrayOf(relativeMemberInfoPropType).isRequired,\nchildThreadInfos: PropTypes.arrayOf(threadInfoPropType),\nnameEditLoadingStatus: loadingStatusPropType.isRequired,\n@@ -233,34 +231,6 @@ class InnerThreadSettings extends React.PureComponent<Props, State> {\n);\nconst canChangeSettings = canEditThread && canStartEditing;\n- let parent;\n- if (this.props.parentThreadInfo) {\n- parent = (\n- <Button\n- onPress={this.onPressParentThread}\n- style={[styles.currentValue, styles.rowVerticalHalfPadding]}\n- >\n- <Text\n- style={[styles.currentValueText, styles.parentThreadLink]}\n- numberOfLines={1}\n- >\n- {this.props.parentThreadInfo.uiName}\n- </Text>\n- </Button>\n- );\n- } else {\n- parent = (\n- <Text style={[\n- styles.currentValue,\n- styles.currentValueText,\n- styles.rowVerticalHalfPadding,\n- styles.noParent,\n- ]}>\n- No parent\n- </Text>\n- );\n- }\n-\nconst visRules = this.props.threadInfo.visibilityRules;\nconst visibility =\nvisRules === visibilityRules.OPEN ||\n@@ -461,12 +431,10 @@ class InnerThreadSettings extends React.PureComponent<Props, State> {\ncanChangeSettings={canChangeSettings}\n/>\n<ThreadSettingsCategoryHeader type=\"full\" title=\"Privacy\" />\n- <View style={styles.row}>\n- <Text style={[styles.label, styles.rowVerticalHalfPadding]}>\n- Parent\n- </Text>\n- {parent}\n- </View>\n+ <ThreadSettingsParent\n+ threadInfo={this.props.threadInfo}\n+ navigate={this.props.navigation.navigate}\n+ />\n<View style={[styles.row, styles.rowVerticalPadding]}>\n<Text style={styles.label}>Visibility</Text>\n<Text style={[styles.currentValue, styles.currentValueText]}>\n@@ -516,13 +484,6 @@ class InnerThreadSettings extends React.PureComponent<Props, State> {\nthis.setState({ descriptionTextHeight: height });\n}\n- onPressParentThread = () => {\n- this.props.navigation.navigate(\n- MessageListRouteName,\n- { threadInfo: this.props.parentThreadInfo },\n- );\n- }\n-\nonPressAddUser = () => {\nthis.setState({ showAddUsersModal: true });\n}\n@@ -612,9 +573,6 @@ const styles = StyleSheet.create({\nrowVerticalPadding: {\npaddingVertical: 8,\n},\n- rowVerticalHalfPadding: {\n- paddingVertical: 4,\n- },\nlabel: {\nfontSize: 16,\nwidth: 96,\n@@ -652,12 +610,6 @@ const styles = StyleSheet.create({\ncolor: \"#333333\",\nfontFamily: 'Arial',\n},\n- noParent: {\n- fontStyle: 'italic',\n- },\n- parentThreadLink: {\n- color: \"#036AFF\",\n- },\nseeMoreIcon: {\nposition: 'absolute',\nright: 10,\n@@ -709,9 +661,6 @@ const ThreadSettings = connect(\n}\nreturn {\nthreadInfo,\n- parentThreadInfo: threadInfo.parentThreadID\n- ? parsedThreadInfos[threadInfo.parentThreadID]\n- : null,\nthreadMembers,\nchildThreadInfos: childThreadInfos(state)[threadInfo.id],\nnameEditLoadingStatus: createLoadingStatusSelector(\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Factor out parent thread row in thread settings
129,187
22.01.2018 18:11:46
25,200
34a191a2e414c944f79529fe4e6c438ebf9bfd7d
Factor out visibility row in thread settings
[ { "change_type": "ADD", "old_path": null, "new_path": "native/chat/settings/thread-settings-visibility.react.js", "diff": "+// @flow\n+\n+import type { ThreadInfo } from 'lib/types/thread-types';\n+import { threadInfoPropType } from 'lib/types/thread-types';\n+\n+import React from 'react';\n+import { Text, StyleSheet, View, Platform } from 'react-native';\n+\n+import { visibilityRules } from 'lib/types/thread-types';\n+\n+type Props = {|\n+ threadInfo: ThreadInfo,\n+|};\n+class ThreadSettingsVisibility extends React.PureComponent<Props> {\n+\n+ static propTypes = {\n+ threadInfo: threadInfoPropType.isRequired,\n+ };\n+\n+ render() {\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+ return (\n+ <View style={styles.row}>\n+ <Text style={styles.label}>Visibility</Text>\n+ <Text style={styles.currentValue}>\n+ {visibility}\n+ </Text>\n+ </View>\n+ );\n+ }\n+\n+}\n+\n+const styles = StyleSheet.create({\n+ row: {\n+ flexDirection: 'row',\n+ paddingHorizontal: 24,\n+ backgroundColor: \"white\",\n+ paddingVertical: 8,\n+ },\n+ label: {\n+ fontSize: 16,\n+ width: 96,\n+ color: \"#888888\",\n+ },\n+ currentValue: {\n+ flex: 1,\n+ paddingLeft: 4,\n+ paddingRight: 0,\n+ paddingTop: Platform.OS === \"ios\" ? 1 : 0,\n+ margin: 0,\n+ fontSize: 16,\n+ color: \"#333333\",\n+ fontFamily: 'Arial',\n+ },\n+});\n+\n+export default ThreadSettingsVisibility;\n" }, { "change_type": "MODIFY", "old_path": "native/chat/settings/thread-settings.react.js", "new_path": "native/chat/settings/thread-settings.react.js", "diff": "@@ -36,7 +36,6 @@ import _every from 'lodash/fp/every';\nimport _omit from 'lodash/fp/omit';\nimport shallowequal from 'shallowequal';\n-import { visibilityRules } from 'lib/types/thread-types';\nimport {\nrelativeMemberInfoSelectorForMembersOfThread,\n} from 'lib/selectors/user-selectors';\n@@ -77,6 +76,7 @@ import ThreadSettingsName from './thread-settings-name.react';\nimport ThreadSettingsColor from './thread-settings-color.react';\nimport ThreadSettingsDescription from './thread-settings-description.react';\nimport ThreadSettingsParent from './thread-settings-parent.react';\n+import ThreadSettingsVisibility from './thread-settings-visibility.react';\nconst itemPageLength = 5;\n@@ -231,13 +231,6 @@ class InnerThreadSettings extends React.PureComponent<Props, State> {\n);\nconst canChangeSettings = canEditThread && canStartEditing;\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-\nlet threadMembers;\nlet seeMoreMembers = null;\nif (this.props.threadMembers.length > this.state.showMaxMembers) {\n@@ -435,12 +428,7 @@ class InnerThreadSettings extends React.PureComponent<Props, State> {\nthreadInfo={this.props.threadInfo}\nnavigate={this.props.navigation.navigate}\n/>\n- <View style={[styles.row, styles.rowVerticalPadding]}>\n- <Text style={styles.label}>Visibility</Text>\n- <Text style={[styles.currentValue, styles.currentValueText]}>\n- {visibility}\n- </Text>\n- </View>\n+ <ThreadSettingsVisibility threadInfo={this.props.threadInfo} />\n<ThreadSettingsCategoryFooter type=\"full\" />\n{childThreadPanel}\n{membersPanel}\n@@ -565,23 +553,6 @@ const styles = StyleSheet.create({\nscrollView: {\npaddingVertical: 16,\n},\n- row: {\n- flexDirection: 'row',\n- paddingHorizontal: 24,\n- backgroundColor: \"white\",\n- },\n- rowVerticalPadding: {\n- paddingVertical: 8,\n- },\n- label: {\n- fontSize: 16,\n- width: 96,\n- color: \"#888888\",\n- },\n- currentValue: {\n- flex: 1,\n- paddingLeft: 4,\n- },\nitemRow: {\nflex: 1,\nflexDirection: 'row',\n@@ -602,14 +573,6 @@ const styles = StyleSheet.create({\npaddingTop: 4,\nbackgroundColor: \"white\",\n},\n- currentValueText: {\n- paddingRight: 0,\n- paddingVertical: 0,\n- margin: 0,\n- fontSize: 16,\n- color: \"#333333\",\n- fontFamily: 'Arial',\n- },\nseeMoreIcon: {\nposition: 'absolute',\nright: 10,\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Factor out visibility row in thread settings
129,187
22.01.2018 22:05:27
25,200
4e21387476fb53292f5db921003590776180dc93
Factor our ThreadSettingsListActions into separate rows
[ { "change_type": "MODIFY", "old_path": "native/chat/settings/thread-settings-child-thread.react.js", "new_path": "native/chat/settings/thread-settings-child-thread.react.js", "diff": "@@ -4,7 +4,7 @@ import type { ThreadInfo } from 'lib/types/thread-types';\nimport type { NavigationParams } from 'react-navigation';\nimport React from 'react';\n-import { Text, StyleSheet } from 'react-native';\n+import { Text, StyleSheet, View } from 'react-native';\nimport { MessageListRouteName } from '../message-list.react';\nimport Button from '../../components/button.react';\n@@ -21,15 +21,14 @@ class ThreadSettingsChildThread extends React.PureComponent<Props> {\nrender() {\nreturn (\n- <Button\n- onPress={this.onPress}\n- style={styles.container}\n- >\n+ <View style={styles.container}>\n+ <Button onPress={this.onPress} style={styles.button}>\n<Text style={styles.text} numberOfLines={1}>\n{this.props.threadInfo.uiName}\n</Text>\n<ColorSplotch color={this.props.threadInfo.color} />\n</Button>\n+ </View>\n);\n}\n@@ -44,6 +43,14 @@ class ThreadSettingsChildThread extends React.PureComponent<Props> {\nconst styles = StyleSheet.create({\ncontainer: {\n+ flex: 1,\n+ flexDirection: 'row',\n+ paddingHorizontal: 12,\n+ borderTopWidth: 1,\n+ borderColor: \"#CCCCCC\",\n+ backgroundColor: \"white\",\n+ },\n+ button: {\nflex: 1,\nflexDirection: 'row',\npaddingVertical: 8,\n" }, { "change_type": "MODIFY", "old_path": "native/chat/settings/thread-settings-list-action.react.js", "new_path": "native/chat/settings/thread-settings-list-action.react.js", "diff": "import type {\nStyleObj,\n} from 'react-native/Libraries/StyleSheet/StyleSheetTypes';\n+import type { ThreadInfo } from 'lib/types/thread-types';\n+import type { NavigationParams } from 'react-navigation';\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+import { AddThreadRouteName } from '../add-thread.react';\n-type Props = {\n+type ListActionProps = {|\nonPress: () => void,\ntext: string,\niconName: string,\niconColor: string,\niconSize: number,\niconStyle?: StyleObj,\n-};\n-function ThreadSettingsListAction(props: Props) {\n+|};\n+function ThreadSettingsListAction(props: ListActionProps) {\nreturn (\n<Button onPress={props.onPress}>\n<View style={styles.container}>\n@@ -34,6 +37,75 @@ function ThreadSettingsListAction(props: Props) {\n);\n}\n+type SeeMoreProps = {|\n+ onPress: () => void,\n+|};\n+function ThreadSettingsSeeMore(props: SeeMoreProps) {\n+ return (\n+ <View style={styles.seeMoreRow}>\n+ <ThreadSettingsListAction\n+ onPress={props.onPress}\n+ text=\"See more...\"\n+ iconName=\"ios-more\"\n+ iconColor=\"#036AFF\"\n+ iconSize={36}\n+ iconStyle={styles.seeMoreIcon}\n+ />\n+ </View>\n+ );\n+}\n+\n+type AddUserProps = {|\n+ onPress: () => void,\n+|};\n+function ThreadSettingsAddUser(props: AddUserProps) {\n+ return (\n+ <View style={styles.addItemRow}>\n+ <ThreadSettingsListAction\n+ onPress={props.onPress}\n+ text=\"Add users\"\n+ iconName=\"md-add\"\n+ iconColor=\"#009900\"\n+ iconSize={20}\n+ />\n+ </View>\n+ );\n+}\n+\n+type AddChildThreadProps = {|\n+ threadInfo: ThreadInfo,\n+ navigate: (\n+ routeName: string,\n+ params?: NavigationParams,\n+ ) => bool,\n+|};\n+class ThreadSettingsAddChildThread\n+ extends React.PureComponent<AddChildThreadProps> {\n+\n+ render() {\n+ return (\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+ onPressAddChildThread = () => {\n+ this.props.navigate(\n+ AddThreadRouteName,\n+ { parentThreadID: this.props.threadInfo.id },\n+ );\n+ }\n+\n+}\n+\n+\nconst styles = StyleSheet.create({\ncontainer: {\nflex: 1,\n@@ -51,6 +123,27 @@ const styles = StyleSheet.create({\nicon: {\nlineHeight: 20,\n},\n+ seeMoreRow: {\n+ borderTopWidth: 1,\n+ borderColor: \"#CCCCCC\",\n+ paddingHorizontal: 12,\n+ paddingTop: 2,\n+ backgroundColor: \"white\",\n+ },\n+ seeMoreIcon: {\n+ position: 'absolute',\n+ right: 10,\n+ top: 15,\n+ },\n+ addItemRow: {\n+ paddingHorizontal: 12,\n+ paddingTop: 4,\n+ backgroundColor: \"white\",\n+ },\n});\n-export default ThreadSettingsListAction;\n+export {\n+ ThreadSettingsSeeMore,\n+ ThreadSettingsAddUser,\n+ ThreadSettingsAddChildThread,\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": "@@ -298,8 +298,11 @@ class ThreadSettingsUser extends React.PureComponent<Props, State> {\nconst styles = StyleSheet.create({\ncontainer: {\nflex: 1,\n+ paddingHorizontal: 24,\npaddingVertical: 8,\n- paddingHorizontal: 12,\n+ borderTopWidth: 1,\n+ borderColor: \"#CCCCCC\",\n+ backgroundColor: \"white\",\n},\nrow: {\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": "@@ -66,7 +66,11 @@ import {\nimport EditSettingButton from './edit-setting-button.react';\nimport Button from '../../components/button.react';\nimport ThreadSettingsUser from './thread-settings-user.react';\n-import ThreadSettingsListAction from './thread-settings-list-action.react';\n+import {\n+ ThreadSettingsSeeMore,\n+ ThreadSettingsAddUser,\n+ ThreadSettingsAddChildThread,\n+} 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';\n@@ -231,22 +235,35 @@ class InnerThreadSettings extends React.PureComponent<Props, State> {\n);\nconst canChangeSettings = canEditThread && canStartEditing;\n+ let description = null;\n+ if (\n+ (this.state.descriptionEditValue !== null &&\n+ this.state.descriptionEditValue !== undefined) ||\n+ this.props.threadInfo.description ||\n+ canEditThread\n+ ) {\n+ description = (\n+ <ThreadSettingsDescription\n+ threadInfo={this.props.threadInfo}\n+ descriptionEditValue={this.state.descriptionEditValue}\n+ setDescriptionEditValue={this.setDescriptionEditValue}\n+ descriptionTextHeight={this.state.descriptionTextHeight}\n+ setDescriptionTextHeight={this.setDescriptionTextHeight}\n+ canChangeSettings={canChangeSettings}\n+ />\n+ );\n+ }\n+\nlet threadMembers;\nlet seeMoreMembers = null;\nif (this.props.threadMembers.length > this.state.showMaxMembers) {\nthreadMembers =\nthis.props.threadMembers.slice(0, this.state.showMaxMembers);\nseeMoreMembers = (\n- <View style={styles.seeMoreRow} key=\"seeMore\">\n- <ThreadSettingsListAction\n+ <ThreadSettingsSeeMore\nonPress={this.onPressSeeMoreMembers}\n- text=\"See more...\"\n- iconName=\"ios-more\"\n- iconColor=\"#036AFF\"\n- iconSize={36}\n- iconStyle={styles.seeMoreIcon}\n+ key=\"seeMore\"\n/>\n- </View>\n);\n} else {\nthreadMembers = this.props.threadMembers;\n@@ -257,15 +274,14 @@ class InnerThreadSettings extends React.PureComponent<Props, State> {\nconst changeRolesLoadingStatus =\nthis.props.changeRolesLoadingStatuses[memberInfo.id];\nreturn (\n- <View style={styles.itemRow} key={memberInfo.id}>\n<ThreadSettingsUser\nmemberInfo={memberInfo}\nthreadInfo={this.props.threadInfo}\ncanEdit={canStartEditing}\nremoveUsersLoadingStatus={removeUsersLoadingStatus}\nchangeRolesLoadingStatus={changeRolesLoadingStatus}\n+ key={memberInfo.id}\n/>\n- </View>\n);\n});\nif (seeMoreMembers) {\n@@ -278,17 +294,7 @@ class InnerThreadSettings extends React.PureComponent<Props, State> {\nthreadPermissions.ADD_MEMBERS,\n);\nif (canAddMembers) {\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+ addMembers = <ThreadSettingsAddUser onPress={this.onPressAddUser} />;\n}\nlet membersPanel = null;\n@@ -311,29 +317,21 @@ class InnerThreadSettings extends React.PureComponent<Props, State> {\nchildThreadInfos =\nthis.props.childThreadInfos.slice(0, this.state.showMaxChildThreads);\nseeMoreChildThreads = (\n- <View style={styles.seeMoreRow} key=\"seeMore\">\n- <ThreadSettingsListAction\n+ <ThreadSettingsSeeMore\nonPress={this.onPressSeeMoreChildThreads}\n- text=\"See more...\"\n- iconName=\"ios-more\"\n- iconColor=\"#036AFF\"\n- iconSize={32}\n- iconStyle={styles.seeMoreIcon}\nkey=\"seeMore\"\n/>\n- </View>\n);\n} else {\nchildThreadInfos = this.props.childThreadInfos;\n}\nchildThreads = childThreadInfos.map(threadInfo => {\nreturn (\n- <View style={styles.itemRow} key={threadInfo.id}>\n<ThreadSettingsChildThread\nthreadInfo={threadInfo}\nnavigate={this.props.navigation.navigate}\n+ key={threadInfo.id}\n/>\n- </View>\n);\n});\nif (seeMoreChildThreads) {\n@@ -348,15 +346,10 @@ class InnerThreadSettings extends React.PureComponent<Props, State> {\n);\nif (canCreateSubthreads) {\naddChildThread = (\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+ <ThreadSettingsAddChildThread\n+ threadInfo={this.props.threadInfo}\n+ navigate={this.props.navigation.navigate}\n/>\n- </View>\n);\n}\n@@ -415,14 +408,7 @@ class InnerThreadSettings extends React.PureComponent<Props, State> {\ncanChangeSettings={canChangeSettings}\n/>\n<ThreadSettingsCategoryFooter type=\"full\" />\n- <ThreadSettingsDescription\n- threadInfo={this.props.threadInfo}\n- descriptionEditValue={this.state.descriptionEditValue}\n- setDescriptionEditValue={this.setDescriptionEditValue}\n- descriptionTextHeight={this.state.descriptionTextHeight}\n- setDescriptionTextHeight={this.setDescriptionTextHeight}\n- canChangeSettings={canChangeSettings}\n- />\n+ {description}\n<ThreadSettingsCategoryHeader type=\"full\" title=\"Privacy\" />\n<ThreadSettingsParent\nthreadInfo={this.props.threadInfo}\n@@ -476,13 +462,6 @@ class InnerThreadSettings extends React.PureComponent<Props, State> {\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@@ -553,31 +532,6 @@ const styles = StyleSheet.create({\nscrollView: {\npaddingVertical: 16,\n},\n- itemRow: {\n- flex: 1,\n- flexDirection: 'row',\n- paddingHorizontal: 12,\n- borderTopWidth: 1,\n- borderColor: \"#CCCCCC\",\n- backgroundColor: \"white\",\n- },\n- seeMoreRow: {\n- borderTopWidth: 1,\n- borderColor: \"#CCCCCC\",\n- paddingHorizontal: 12,\n- paddingTop: 2,\n- backgroundColor: \"white\",\n- },\n- addItemRow: {\n- paddingHorizontal: 12,\n- paddingTop: 4,\n- backgroundColor: \"white\",\n- },\n- seeMoreIcon: {\n- position: 'absolute',\n- right: 10,\n- top: 15,\n- },\nleaveThread: {\nmarginVertical: 16,\nborderTopWidth: 1,\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Factor our ThreadSettingsListActions into separate rows
129,187
22.01.2018 23:02:43
25,200
1be6804698512a0ef2e6e963185a3cb55878e373
Factor out leave thread row in thread settings and simplify LoadingStatus logic in ThreadSettings This concludes the work to break down the thread settings `ScrollView` into discrete rows so we can move it to a `FlatList`.
[ { "change_type": "ADD", "old_path": null, "new_path": "native/chat/settings/thread-settings-leave-thread.react.js", "diff": "+// @flow\n+\n+import type { ThreadInfo, RelativeMemberInfo } from 'lib/types/thread-types';\n+import {\n+ threadInfoPropType,\n+ relativeMemberInfoPropType,\n+} from 'lib/types/thread-types';\n+import type { LeaveThreadResult } from 'lib/actions/thread-actions';\n+import type { LoadingStatus } from 'lib/types/loading-types';\n+import { loadingStatusPropType } from 'lib/types/loading-types';\n+import type { AppState } from '../../redux-setup';\n+import type { DispatchActionPromise } from 'lib/utils/action-utils';\n+\n+import React from 'react';\n+import {\n+ Text,\n+ StyleSheet,\n+ Alert,\n+ ActivityIndicator,\n+ View,\n+} from 'react-native';\n+import { connect } from 'react-redux';\n+import PropTypes from 'prop-types';\n+\n+import {\n+ includeDispatchActionProps,\n+ bindServerCalls,\n+} from 'lib/utils/action-utils';\n+import {\n+ leaveThreadActionTypes,\n+ leaveThread,\n+} from 'lib/actions/thread-actions';\n+import { createLoadingStatusSelector } from 'lib/selectors/loading-selectors';\n+\n+import Button from '../../components/button.react';\n+\n+type Props = {|\n+ threadInfo: ThreadInfo,\n+ threadMembers: RelativeMemberInfo[],\n+ // Redux state\n+ loadingStatus: LoadingStatus,\n+ // Redux dispatch functions\n+ dispatchActionPromise: DispatchActionPromise,\n+ // async functions that hit server APIs\n+ leaveThread: (threadID: string) => Promise<LeaveThreadResult>,\n+|};\n+class ThreadSettingsLeaveThread extends React.PureComponent<Props> {\n+\n+ static propTypes = {\n+ threadInfo: threadInfoPropType.isRequired,\n+ threadMembers: PropTypes.arrayOf(relativeMemberInfoPropType).isRequired,\n+ loadingStatus: loadingStatusPropType.isRequired,\n+ dispatchActionPromise: PropTypes.func.isRequired,\n+ leaveThread: PropTypes.func.isRequired,\n+ };\n+\n+ render() {\n+ const loadingIndicator = this.props.loadingStatus === \"loading\"\n+ ? <ActivityIndicator size=\"small\" />\n+ : null;\n+ return (\n+ <View style={styles.container}>\n+ <Button\n+ onPress={this.onPress}\n+ style={styles.button}\n+ iosFormat=\"highlight\"\n+ iosHighlightUnderlayColor=\"#EEEEEEDD\"\n+ >\n+ <Text style={styles.text}>Leave thread...</Text>\n+ {loadingIndicator}\n+ </Button>\n+ </View>\n+ );\n+ }\n+\n+ onPress = () => {\n+ let otherUsersExist = false;\n+ let otherAdminsExist = false;\n+ for (let member of this.props.threadMembers) {\n+ const role = member.role;\n+ if (role === undefined || role === null || member.isViewer) {\n+ continue;\n+ }\n+ otherUsersExist = true;\n+ if (this.props.threadInfo.roles[role].name === \"Admins\") {\n+ otherAdminsExist = true;\n+ break;\n+ }\n+ }\n+ if (otherUsersExist && !otherAdminsExist) {\n+ Alert.alert(\n+ \"Need another admin\",\n+ \"Make somebody else an admin before you leave!\",\n+ );\n+ return;\n+ }\n+\n+ Alert.alert(\n+ \"Confirm action\",\n+ \"Are you sure you want to leave this thread?\",\n+ [\n+ { text: 'Cancel', style: 'cancel' },\n+ { text: 'OK', onPress: this.onConfirmLeaveThread },\n+ ],\n+ );\n+ }\n+\n+ onConfirmLeaveThread = () => {\n+ this.props.dispatchActionPromise(\n+ leaveThreadActionTypes,\n+ this.leaveThread(),\n+ );\n+ }\n+\n+ async leaveThread() {\n+ try {\n+ return await this.props.leaveThread(this.props.threadInfo.id);\n+ } catch (e) {\n+ Alert.alert(\"Unknown error\", \"Uhh... try again?\");\n+ throw e;\n+ }\n+ }\n+\n+}\n+\n+const styles = StyleSheet.create({\n+ container: {\n+ marginVertical: 16,\n+ borderTopWidth: 1,\n+ borderBottomWidth: 1,\n+ borderColor: \"#CCCCCC\",\n+ backgroundColor: \"white\",\n+ },\n+ button: {\n+ flexDirection: 'row',\n+ paddingHorizontal: 24,\n+ paddingVertical: 10,\n+ },\n+ text: {\n+ fontSize: 16,\n+ color: \"#AA0000\",\n+ flex: 1,\n+ },\n+});\n+\n+const loadingStatusSelector\n+ = createLoadingStatusSelector(leaveThreadActionTypes);\n+\n+export default connect(\n+ (state: AppState) => ({\n+ loadingStatus: loadingStatusSelector(state),\n+ cookie: state.cookie,\n+ }),\n+ includeDispatchActionProps,\n+ bindServerCalls({ leaveThread }),\n+)(ThreadSettingsLeaveThread);\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": "@@ -40,6 +40,7 @@ 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@@ -48,8 +49,9 @@ type Props = {|\nmemberInfo: RelativeMemberInfo,\nthreadInfo: ThreadInfo,\ncanEdit: bool,\n- removeUsersLoadingStatus: LoadingStatus,\n- changeRolesLoadingStatus: LoadingStatus,\n+ // Redux state\n+ removeUserLoadingStatus: LoadingStatus,\n+ changeRoleLoadingStatus: LoadingStatus,\n// Redux dispatch functions\ndispatchActionPromise: DispatchActionPromise,\n// async functions that hit server APIs\n@@ -72,6 +74,11 @@ class ThreadSettingsUser extends React.PureComponent<Props, State> {\nmemberInfo: relativeMemberInfoPropType.isRequired,\nthreadInfo: threadInfoPropType.isRequired,\ncanEdit: PropTypes.bool.isRequired,\n+ removeUserLoadingStatus: loadingStatusPropType.isRequired,\n+ changeRoleLoadingStatus: loadingStatusPropType.isRequired,\n+ dispatchActionPromise: PropTypes.func.isRequired,\n+ removeUsersFromThread: PropTypes.func.isRequired,\n+ changeThreadMemberRoles: PropTypes.func.isRequired,\n};\nstatic memberIsAdmin(props: Props) {\n@@ -151,8 +158,8 @@ class ThreadSettingsUser extends React.PureComponent<Props, State> {\nlet editButton = null;\nif (\n- this.props.removeUsersLoadingStatus === \"loading\" ||\n- this.props.changeRolesLoadingStatus === \"loading\"\n+ this.props.removeUserLoadingStatus === \"loading\" ||\n+ this.props.changeRoleLoadingStatus === \"loading\"\n) {\neditButton = <ActivityIndicator size=\"small\" />;\n} else if (this.state.popoverConfig.length !== 0) {\n@@ -345,7 +352,17 @@ const icon = (\n);\nexport default connect(\n- (state: AppState) => ({ cookie: state.cookie }),\n+ (state: AppState, ownProps: { memberInfo: RelativeMemberInfo }) => ({\n+ removeUserLoadingStatus: createLoadingStatusSelector(\n+ removeUsersFromThreadActionTypes,\n+ `${removeUsersFromThreadActionTypes.started}:${ownProps.memberInfo.id}`,\n+ )(state),\n+ changeRoleLoadingStatus: createLoadingStatusSelector(\n+ changeThreadMemberRolesActionTypes,\n+ `${changeThreadMemberRolesActionTypes.started}:${ownProps.memberInfo.id}`,\n+ )(state),\n+ cookie: state.cookie,\n+ }),\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": "@@ -8,33 +8,13 @@ import {\nrelativeMemberInfoPropType,\n} from 'lib/types/thread-types';\nimport type { AppState } from '../../redux-setup';\n-import type { DispatchActionPromise } from 'lib/utils/action-utils';\n-import type {\n- ChangeThreadSettingsResult,\n- LeaveThreadResult,\n-} 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 {\n- ScrollView,\n- StyleSheet,\n- Text,\n- View,\n- TextInput,\n- Alert,\n- ActivityIndicator,\n-} from 'react-native';\n+import { ScrollView, StyleSheet, View } from 'react-native';\nimport Modal from 'react-native-modal';\n-import invariant from 'invariant';\nimport _isEqual from 'lodash/fp/isEqual';\n-import 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 {\nrelativeMemberInfoSelectorForMembersOfThread,\n@@ -46,16 +26,10 @@ import {\nimport { createLoadingStatusSelector } from 'lib/selectors/loading-selectors';\nimport {\nchangeThreadSettingsActionTypes,\n- changeSingleThreadSetting,\nleaveThreadActionTypes,\n- leaveThread,\nremoveUsersFromThreadActionTypes,\nchangeThreadMemberRolesActionTypes,\n} from 'lib/actions/thread-actions';\n-import {\n- includeDispatchActionProps,\n- bindServerCalls,\n-} from 'lib/utils/action-utils';\nimport { threadHasPermission, viewerIsMember } from 'lib/shared/thread-utils';\nimport threadWatcher from 'lib/shared/thread-watcher';\n@@ -63,8 +37,6 @@ import {\nThreadSettingsCategoryHeader,\nThreadSettingsCategoryFooter,\n} from './thread-settings-category.react';\n-import EditSettingButton from './edit-setting-button.react';\n-import Button from '../../components/button.react';\nimport ThreadSettingsUser from './thread-settings-user.react';\nimport {\nThreadSettingsSeeMore,\n@@ -73,14 +45,13 @@ import {\n} from './thread-settings-list-action.react';\nimport AddUsersModal from './add-users-modal.react';\nimport ThreadSettingsChildThread from './thread-settings-child-thread.react';\n-import { AddThreadRouteName } from '../add-thread.react';\nimport { registerChatScreen } from '../chat-screen-registry';\n-import SaveSettingButton from './save-setting-button.react';\nimport ThreadSettingsName from './thread-settings-name.react';\nimport ThreadSettingsColor from './thread-settings-color.react';\nimport ThreadSettingsDescription from './thread-settings-description.react';\nimport ThreadSettingsParent from './thread-settings-parent.react';\nimport ThreadSettingsVisibility from './thread-settings-visibility.react';\n+import ThreadSettingsLeaveThread from './thread-settings-leave-thread.react';\nconst itemPageLength = 5;\n@@ -91,26 +62,12 @@ type StateProps = {|\nthreadInfo: ThreadInfo,\nthreadMembers: RelativeMemberInfo[],\nchildThreadInfos: ?ThreadInfo[],\n- nameEditLoadingStatus: LoadingStatus,\n- colorEditLoadingStatus: LoadingStatus,\n- descriptionEditLoadingStatus: LoadingStatus,\n- leaveThreadLoadingStatus: LoadingStatus,\n- removeUsersLoadingStatuses: {[id: string]: LoadingStatus},\n- changeRolesLoadingStatuses: {[id: string]: LoadingStatus},\n+ somethingIsSaving: bool,\n|};\ntype Props = {|\nnavigation: NavProp,\n// Redux state\n...StateProps,\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- leaveThread: (threadID: string) => Promise<LeaveThreadResult>,\n|};\ntype State = {|\nshowAddUsersModal: bool,\n@@ -139,12 +96,7 @@ class InnerThreadSettings extends React.PureComponent<Props, State> {\nthreadInfo: threadInfoPropType.isRequired,\nthreadMembers: PropTypes.arrayOf(relativeMemberInfoPropType).isRequired,\nchildThreadInfos: PropTypes.arrayOf(threadInfoPropType),\n- nameEditLoadingStatus: loadingStatusPropType.isRequired,\n- colorEditLoadingStatus: loadingStatusPropType.isRequired,\n- descriptionEditLoadingStatus: loadingStatusPropType.isRequired,\n- leaveThreadLoadingStatus: loadingStatusPropType.isRequired,\n- dispatchActionPromise: PropTypes.func.isRequired,\n- changeSingleThreadSetting: PropTypes.func.isRequired,\n+ somethingIsSaving: PropTypes.bool.isRequired,\n};\nstatic navigationOptions = ({ navigation }) => ({\ntitle: navigation.state.params.threadInfo.uiName,\n@@ -209,22 +161,12 @@ 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 ||\nthis.state.nameEditValue === undefined) &&\n!this.state.showEditColorModal &&\n- this.props.nameEditLoadingStatus !== \"loading\" &&\n- this.props.colorEditLoadingStatus !== \"loading\" &&\n- this.props.descriptionEditLoadingStatus !== \"loading\" &&\n- this.props.leaveThreadLoadingStatus !== \"loading\" &&\n- _every(InnerThreadSettings.notLoading)\n- (this.props.removeUsersLoadingStatuses) &&\n- _every(InnerThreadSettings.notLoading)\n- (this.props.changeRolesLoadingStatuses);\n+ !this.props.somethingIsSaving;\n}\nrender() {\n@@ -269,17 +211,11 @@ class InnerThreadSettings extends React.PureComponent<Props, State> {\nthreadMembers = this.props.threadMembers;\n}\nconst members = threadMembers.map(memberInfo => {\n- const removeUsersLoadingStatus =\n- this.props.removeUsersLoadingStatuses[memberInfo.id];\n- const changeRolesLoadingStatus =\n- this.props.changeRolesLoadingStatuses[memberInfo.id];\nreturn (\n<ThreadSettingsUser\nmemberInfo={memberInfo}\nthreadInfo={this.props.threadInfo}\ncanEdit={canStartEditing}\n- removeUsersLoadingStatus={removeUsersLoadingStatus}\n- changeRolesLoadingStatus={changeRolesLoadingStatus}\nkey={memberInfo.id}\n/>\n);\n@@ -367,23 +303,11 @@ class InnerThreadSettings extends React.PureComponent<Props, State> {\nlet leaveThreadButton = null;\nif (viewerIsMember(this.props.threadInfo)) {\n- const loadingIndicator = this.props.leaveThreadLoadingStatus === \"loading\"\n- ? <ActivityIndicator size=\"small\" />\n- : null;\nleaveThreadButton = (\n- <View style={styles.leaveThread}>\n- <Button\n- onPress={this.onPressLeaveThread}\n- style={styles.leaveThreadButton}\n- iosFormat=\"highlight\"\n- iosHighlightUnderlayColor=\"#EEEEEEDD\"\n- >\n- <Text style={styles.leaveThreadText}>\n- Leave thread...\n- </Text>\n- {loadingIndicator}\n- </Button>\n- </View>\n+ <ThreadSettingsLeaveThread\n+ threadInfo={this.props.threadInfo}\n+ threadMembers={this.props.threadMembers}\n+ />\n);\n}\n@@ -478,143 +402,76 @@ class InnerThreadSettings extends React.PureComponent<Props, State> {\n}));\n}\n- onPressLeaveThread = () => {\n- let otherUsersExist = false;\n- let otherAdminsExist = false;\n- for (let member of this.props.threadMembers) {\n- const role = member.role;\n- if (role === undefined || role === null || member.isViewer) {\n- continue;\n- }\n- otherUsersExist = true;\n- if (this.props.threadInfo.roles[role].name === \"Admins\") {\n- otherAdminsExist = true;\n- break;\n- }\n- }\n- if (otherUsersExist && !otherAdminsExist) {\n- Alert.alert(\n- \"Need another admin\",\n- \"Make somebody else an admin before you leave!\",\n- );\n- return;\n- }\n-\n- Alert.alert(\n- \"Confirm action\",\n- \"Are you sure you want to leave this thread?\",\n- [\n- { text: 'Cancel', style: 'cancel' },\n- { text: 'OK', onPress: this.onConfirmLeaveThread },\n- ],\n- );\n- }\n-\n- onConfirmLeaveThread = () => {\n- this.props.dispatchActionPromise(\n- leaveThreadActionTypes,\n- this.leaveThread(),\n- );\n- }\n-\n- async leaveThread() {\n- try {\n- return await this.props.leaveThread(this.props.threadInfo.id);\n- } catch (e) {\n- Alert.alert(\"Unknown error\", \"Uhh... try again?\");\n- throw e;\n- }\n- }\n-\n}\nconst styles = StyleSheet.create({\nscrollView: {\npaddingVertical: 16,\n},\n- leaveThread: {\n- marginVertical: 16,\n- borderTopWidth: 1,\n- borderBottomWidth: 1,\n- borderColor: \"#CCCCCC\",\n- backgroundColor: \"white\",\n- },\n- leaveThreadButton: {\n- flexDirection: 'row',\n- paddingHorizontal: 24,\n- paddingVertical: 10,\n- },\n- leaveThreadText: {\n- fontSize: 16,\n- color: \"#AA0000\",\n- flex: 1,\n- },\n});\n+const editNameLoadingStatusSelector = createLoadingStatusSelector(\n+ changeThreadSettingsActionTypes,\n+ `${changeThreadSettingsActionTypes.started}:name`,\n+);\n+const editColorLoadingStatusSelector = createLoadingStatusSelector(\n+ changeThreadSettingsActionTypes,\n+ `${changeThreadSettingsActionTypes.started}:color`,\n+);\n+const editDescriptionLoadingStatusSelector = createLoadingStatusSelector(\n+ changeThreadSettingsActionTypes,\n+ `${changeThreadSettingsActionTypes.started}:color`,\n+);\nconst leaveThreadLoadingStatusSelector\n= createLoadingStatusSelector(leaveThreadActionTypes);\n-const ThreadSettingsRouteName = 'ThreadSettings';\n-const ThreadSettings = connect(\n- (state: AppState, ownProps: { navigation: NavProp }) => {\n- const parsedThreadInfos = threadInfoSelector(state);\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 = parsedThreadInfos[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+const somethingIsSaving = (\n+ state: AppState,\n+ threadMembers: RelativeMemberInfo[],\n+) => {\n+ if (\n+ editNameLoadingStatusSelector(state) === \"loading\" ||\n+ editColorLoadingStatusSelector(state) === \"loading\" ||\n+ editDescriptionLoadingStatusSelector(state) === \"loading\" ||\n+ leaveThreadLoadingStatusSelector(state) === \"loading\"\n+ ) {\n+ return true;\n+ }\nfor (let threadMember of threadMembers) {\n- removeUsersLoadingStatuses[threadMember.id] = createLoadingStatusSelector(\n+ const removeUserLoadingStatus = createLoadingStatusSelector(\nremoveUsersFromThreadActionTypes,\n`${removeUsersFromThreadActionTypes.started}:${threadMember.id}`,\n)(state);\n- changeRolesLoadingStatuses[threadMember.id] = createLoadingStatusSelector(\n+ if (removeUserLoadingStatus === \"loading\") {\n+ return true;\n+ }\n+ const changeRoleLoadingStatus = createLoadingStatusSelector(\nchangeThreadMemberRolesActionTypes,\n`${changeThreadMemberRolesActionTypes.started}:${threadMember.id}`,\n)(state);\n+ if (changeRoleLoadingStatus === \"loading\") {\n+ return true;\n}\n+ }\n+ return false;\n+};\n+\n+const ThreadSettingsRouteName = 'ThreadSettings';\n+const ThreadSettings = connect(\n+ (state: AppState, ownProps: { navigation: NavProp }): * => {\n+ const parsedThreadInfos = threadInfoSelector(state);\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 = parsedThreadInfos[passedThreadInfo.id];\n+ const threadMembers =\n+ relativeMemberInfoSelectorForMembersOfThread(threadInfo.id)(state);\nreturn {\nthreadInfo,\nthreadMembers,\nchildThreadInfos: childThreadInfos(state)[threadInfo.id],\n- nameEditLoadingStatus: createLoadingStatusSelector(\n- changeThreadSettingsActionTypes,\n- `${changeThreadSettingsActionTypes.started}:name`,\n- )(state),\n- colorEditLoadingStatus: createLoadingStatusSelector(\n- changeThreadSettingsActionTypes,\n- `${changeThreadSettingsActionTypes.started}:color`,\n- )(state),\n- descriptionEditLoadingStatus: createLoadingStatusSelector(\n- changeThreadSettingsActionTypes,\n- `${changeThreadSettingsActionTypes.started}:description`,\n- )(state),\n- leaveThreadLoadingStatus: leaveThreadLoadingStatusSelector(state),\n- removeUsersLoadingStatuses,\n- changeRolesLoadingStatuses,\n- cookie: state.cookie,\n+ somethingIsSaving: somethingIsSaving(state, threadMembers),\n};\n},\n- includeDispatchActionProps,\n- bindServerCalls({ 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
Factor out leave thread row in thread settings and simplify LoadingStatus logic in ThreadSettings This concludes the work to break down the thread settings `ScrollView` into discrete rows so we can move it to a `FlatList`.
129,187
24.01.2018 12:33:04
25,200
324b7a789f1858423d3ccb8c50ea6de7372ac4f5
Convert ThreadSettings ScrollView to FlatList
[ { "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,8 +4,9 @@ import * as React from 'react';\nimport { View, Text, StyleSheet } from 'react-native';\nimport invariant from 'invariant';\n+export type CategoryType = \"full\" | \"outline\" | \"unpadded\";\ntype HeaderProps = {|\n- type: \"full\" | \"outline\" | \"unpadded\",\n+ type: CategoryType,\ntitle: string,\n|};\nfunction ThreadSettingsCategoryHeader(props: HeaderProps) {\n@@ -32,7 +33,7 @@ function ThreadSettingsCategoryHeader(props: HeaderProps) {\n}\ntype FooterProps = {|\n- type: \"full\" | \"outline\" | \"unpadded\",\n+ type: CategoryType,\n|};\nfunction ThreadSettingsCategoryFooter(props: FooterProps) {\nlet contentStyle, paddingStyle;\n" }, { "change_type": "MODIFY", "old_path": "native/chat/settings/thread-settings-list-action.react.js", "new_path": "native/chat/settings/thread-settings-list-action.react.js", "diff": "@@ -55,10 +55,10 @@ function ThreadSettingsSeeMore(props: SeeMoreProps) {\n);\n}\n-type AddUserProps = {|\n+type AddMemberProps = {|\nonPress: () => void,\n|};\n-function ThreadSettingsAddUser(props: AddUserProps) {\n+function ThreadSettingsAddMember(props: AddMemberProps) {\nreturn (\n<View style={styles.addItemRow}>\n<ThreadSettingsListAction\n@@ -144,6 +144,6 @@ const styles = StyleSheet.create({\nexport {\nThreadSettingsSeeMore,\n- ThreadSettingsAddUser,\n+ ThreadSettingsAddMember,\nThreadSettingsAddChildThread,\n};\n" }, { "change_type": "RENAME", "old_path": "native/chat/settings/thread-settings-user.react.js", "new_path": "native/chat/settings/thread-settings-member.react.js", "diff": "@@ -68,7 +68,7 @@ type Props = {|\ntype State = {|\npopoverConfig: $ReadOnlyArray<{ label: string, onPress: () => void }>,\n|};\n-class ThreadSettingsUser extends React.PureComponent<Props, State> {\n+class ThreadSettingsMember extends React.PureComponent<Props, State> {\nstatic propTypes = {\nmemberInfo: relativeMemberInfoPropType.isRequired,\n@@ -118,7 +118,7 @@ class ThreadSettingsUser extends React.PureComponent<Props, State> {\n}\nif (canChangeRoles && props.memberInfo.username) {\n- const adminText = ThreadSettingsUser.memberIsAdmin(props)\n+ const adminText = ThreadSettingsMember.memberIsAdmin(props)\n? \"Remove admin\"\n: \"Make admin\";\nresult.push({ label: adminText, onPress: this.onPressMakeAdmin });\n@@ -173,7 +173,7 @@ class ThreadSettingsUser extends React.PureComponent<Props, State> {\n}\nlet roleInfo = null;\n- if (ThreadSettingsUser.memberIsAdmin(this.props)) {\n+ if (ThreadSettingsMember.memberIsAdmin(this.props)) {\nroleInfo = (\n<View style={styles.row}>\n<Text style={styles.role}>admin</Text>\n@@ -256,7 +256,7 @@ class ThreadSettingsUser extends React.PureComponent<Props, State> {\nshowMakeAdminConfirmation = () => {\nconst userText = stringForUser(this.props.memberInfo);\n- const actionClause = ThreadSettingsUser.memberIsAdmin(this.props)\n+ const actionClause = ThreadSettingsMember.memberIsAdmin(this.props)\n? `remove ${userText} as an admin`\n: `make ${userText} an admin`;\nAlert.alert(\n@@ -270,7 +270,7 @@ class ThreadSettingsUser extends React.PureComponent<Props, State> {\n}\nonConfirmMakeAdmin = () => {\n- const isCurrentlyAdmin = ThreadSettingsUser.memberIsAdmin(this.props);\n+ const isCurrentlyAdmin = ThreadSettingsMember.memberIsAdmin(this.props);\nlet newRole = null;\nfor (let roleID in this.props.threadInfo.roles) {\nconst role = this.props.threadInfo.roles[roleID];\n@@ -365,4 +365,4 @@ export default connect(\n}),\nincludeDispatchActionProps,\nbindServerCalls({ removeUsersFromThread, changeThreadMemberRoles }),\n-)(ThreadSettingsUser);\n+)(ThreadSettingsMember);\n" }, { "change_type": "MODIFY", "old_path": "native/chat/settings/thread-settings.react.js", "new_path": "native/chat/settings/thread-settings.react.js", "diff": "// @flow\n-import type { NavigationScreenProp, NavigationRoute } from 'react-navigation';\n+import type {\n+ NavigationScreenProp,\n+ NavigationRoute,\n+ NavigationParams,\n+} from 'react-navigation';\nimport type { ThreadInfo, RelativeMemberInfo } from 'lib/types/thread-types';\nimport {\nthreadInfoPropType,\n@@ -8,11 +12,12 @@ import {\nrelativeMemberInfoPropType,\n} from 'lib/types/thread-types';\nimport type { AppState } from '../../redux-setup';\n+import type { CategoryType } from './thread-settings-category.react';\nimport React from 'react';\nimport { connect } from 'react-redux';\nimport PropTypes from 'prop-types';\n-import { ScrollView, StyleSheet, View } from 'react-native';\n+import { FlatList, StyleSheet, View } from 'react-native';\nimport Modal from 'react-native-modal';\nimport _isEqual from 'lodash/fp/isEqual';\n@@ -37,10 +42,10 @@ import {\nThreadSettingsCategoryHeader,\nThreadSettingsCategoryFooter,\n} from './thread-settings-category.react';\n-import ThreadSettingsUser from './thread-settings-user.react';\n+import ThreadSettingsMember from './thread-settings-member.react';\nimport {\nThreadSettingsSeeMore,\n- ThreadSettingsAddUser,\n+ ThreadSettingsAddMember,\nThreadSettingsAddChildThread,\n} from './thread-settings-list-action.react';\nimport AddUsersModal from './add-users-modal.react';\n@@ -57,6 +62,87 @@ const itemPageLength = 5;\ntype NavProp = NavigationScreenProp<NavigationRoute>\n& { state: { params: { threadInfo: ThreadInfo } } };\n+type ChatSettingsItem =\n+ | {|\n+ itemType: \"header\",\n+ key: string,\n+ title: string,\n+ categoryType: CategoryType,\n+ |}\n+ | {|\n+ itemType: \"footer\",\n+ key: string,\n+ categoryType: CategoryType,\n+ |}\n+ | {|\n+ itemType: \"name\",\n+ key: string,\n+ threadInfo: ThreadInfo,\n+ nameEditValue: ?string,\n+ nameTextHeight: ?number,\n+ canChangeSettings: bool,\n+ |}\n+ | {|\n+ itemType: \"color\",\n+ key: string,\n+ threadInfo: ThreadInfo,\n+ colorEditValue: string,\n+ showEditColorModal: bool,\n+ canChangeSettings: bool,\n+ |}\n+ | {|\n+ itemType: \"description\",\n+ key: string,\n+ threadInfo: ThreadInfo,\n+ descriptionEditValue: ?string,\n+ descriptionTextHeight: ?number,\n+ canChangeSettings: bool,\n+ |}\n+ | {|\n+ itemType: \"parent\",\n+ key: string,\n+ threadInfo: ThreadInfo,\n+ navigate: (routeName: string, params?: NavigationParams) => bool,\n+ |}\n+ | {|\n+ itemType: \"visibility\",\n+ key: string,\n+ threadInfo: ThreadInfo,\n+ |}\n+ | {|\n+ itemType: \"seeMore\",\n+ key: string,\n+ onPress: () => void,\n+ |}\n+ | {|\n+ itemType: \"childThread\",\n+ key: string,\n+ threadInfo: ThreadInfo,\n+ navigate: (routeName: string, params?: NavigationParams) => bool,\n+ |}\n+ | {|\n+ itemType: \"addChildThread\",\n+ key: string,\n+ threadInfo: ThreadInfo,\n+ navigate: (routeName: string, params?: NavigationParams) => bool,\n+ |}\n+ | {|\n+ itemType: \"member\",\n+ key: string,\n+ memberInfo: RelativeMemberInfo,\n+ threadInfo: ThreadInfo,\n+ canEdit: bool,\n+ |}\n+ | {|\n+ itemType: \"addMember\",\n+ key: string,\n+ |}\n+ | {|\n+ itemType: \"leaveThread\",\n+ key: string,\n+ threadInfo: ThreadInfo,\n+ threadMembers: RelativeMemberInfo[],\n+ |};\ntype StateProps = {|\nthreadInfo: ThreadInfo,\n@@ -177,23 +263,134 @@ class InnerThreadSettings extends React.PureComponent<Props, State> {\n);\nconst canChangeSettings = canEditThread && canStartEditing;\n- let description = null;\n+ let listData: ChatSettingsItem[] = [];\n+ listData.push({\n+ itemType: \"header\",\n+ key: \"basicsHeader\",\n+ title: \"Basics\",\n+ categoryType: \"full\",\n+ });\n+ listData.push({\n+ itemType: \"name\",\n+ key: \"name\",\n+ threadInfo: this.props.threadInfo,\n+ nameEditValue: this.state.nameEditValue,\n+ nameTextHeight: this.state.nameTextHeight,\n+ canChangeSettings,\n+ });\n+ listData.push({\n+ itemType: \"color\",\n+ key: \"color\",\n+ threadInfo: this.props.threadInfo,\n+ colorEditValue: this.state.colorEditValue,\n+ showEditColorModal: this.state.showEditColorModal,\n+ canChangeSettings,\n+ });\n+ listData.push({\n+ itemType: \"footer\",\n+ key: \"basicsFooter\",\n+ categoryType: \"full\",\n+ });\n+\nif (\n(this.state.descriptionEditValue !== null &&\nthis.state.descriptionEditValue !== undefined) ||\nthis.props.threadInfo.description ||\ncanEditThread\n) {\n- description = (\n- <ThreadSettingsDescription\n- threadInfo={this.props.threadInfo}\n- descriptionEditValue={this.state.descriptionEditValue}\n- setDescriptionEditValue={this.setDescriptionEditValue}\n- descriptionTextHeight={this.state.descriptionTextHeight}\n- setDescriptionTextHeight={this.setDescriptionTextHeight}\n- canChangeSettings={canChangeSettings}\n- />\n+ listData.push({\n+ itemType: \"description\",\n+ key: \"description\",\n+ threadInfo: this.props.threadInfo,\n+ descriptionEditValue: this.state.descriptionEditValue,\n+ descriptionTextHeight: this.state.descriptionTextHeight,\n+ canChangeSettings,\n+ });\n+ }\n+\n+ listData.push({\n+ itemType: \"header\",\n+ key: \"privacyHeader\",\n+ title: \"Privacy\",\n+ categoryType: \"full\",\n+ });\n+ listData.push({\n+ itemType: \"parent\",\n+ key: \"parent\",\n+ threadInfo: this.props.threadInfo,\n+ navigate: this.props.navigation.navigate,\n+ });\n+ listData.push({\n+ itemType: \"visibility\",\n+ key: \"visibility\",\n+ threadInfo: this.props.threadInfo,\n+ });\n+ listData.push({\n+ itemType: \"footer\",\n+ key: \"privacyFooter\",\n+ categoryType: \"full\",\n+ });\n+\n+ let childThreads = null;\n+ if (this.props.childThreadInfos) {\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+ itemType: \"seeMore\",\n+ key: \"seeMoreChildThreads\",\n+ onPress: this.onPressSeeMoreChildThreads,\n+ };\n+ } else {\n+ childThreadInfos = this.props.childThreadInfos;\n+ }\n+ childThreads = childThreadInfos.map(threadInfo => ({\n+ itemType: \"childThread\",\n+ key: `childThread${threadInfo.id}`,\n+ threadInfo,\n+ navigate: this.props.navigation.navigate,\n+ }));\n+ if (seeMoreChildThreads) {\n+ childThreads.push(seeMoreChildThreads);\n+ }\n+ }\n+\n+ let addChildThread = null;\n+ const canCreateSubthreads = threadHasPermission(\n+ this.props.threadInfo,\n+ threadPermissions.CREATE_SUBTHREADS,\n);\n+ if (canCreateSubthreads) {\n+ addChildThread = {\n+ itemType: \"addChildThread\",\n+ key: \"addChildThread\",\n+ threadInfo: this.props.threadInfo,\n+ navigate: this.props.navigation.navigate,\n+ };\n+ }\n+\n+ if (addChildThread || childThreads) {\n+ listData.push({\n+ itemType: \"header\",\n+ key: \"childThreadHeader\",\n+ title: \"Child threads\",\n+ categoryType: \"unpadded\",\n+ });\n+ }\n+ if (addChildThread) {\n+ listData.push(addChildThread);\n+ }\n+ if (childThreads) {\n+ listData = [...listData, ...childThreads];\n+ }\n+ if (addChildThread || childThreads) {\n+ listData.push({\n+ itemType: \"footer\",\n+ key: \"childThreadFooter\",\n+ categoryType: \"unpadded\",\n+ });\n}\nlet threadMembers;\n@@ -201,25 +398,21 @@ class InnerThreadSettings extends React.PureComponent<Props, State> {\nif (this.props.threadMembers.length > this.state.showMaxMembers) {\nthreadMembers =\nthis.props.threadMembers.slice(0, this.state.showMaxMembers);\n- seeMoreMembers = (\n- <ThreadSettingsSeeMore\n- onPress={this.onPressSeeMoreMembers}\n- key=\"seeMore\"\n- />\n- );\n+ seeMoreMembers = {\n+ itemType: \"seeMore\",\n+ key: \"seeMoreMembers\",\n+ onPress: this.onPressSeeMoreMembers,\n+ };\n} else {\nthreadMembers = this.props.threadMembers;\n}\n- const members = threadMembers.map(memberInfo => {\n- return (\n- <ThreadSettingsUser\n- memberInfo={memberInfo}\n- threadInfo={this.props.threadInfo}\n- canEdit={canStartEditing}\n- key={memberInfo.id}\n- />\n- );\n- });\n+ const members = threadMembers.map(memberInfo => ({\n+ itemType: \"member\",\n+ key: `member${memberInfo.id}`,\n+ memberInfo,\n+ threadInfo: this.props.threadInfo,\n+ canEdit: canStartEditing,\n+ }));\nif (seeMoreMembers) {\nmembers.push(seeMoreMembers);\n}\n@@ -230,132 +423,151 @@ class InnerThreadSettings extends React.PureComponent<Props, State> {\nthreadPermissions.ADD_MEMBERS,\n);\nif (canAddMembers) {\n- addMembers = <ThreadSettingsAddUser onPress={this.onPressAddUser} />;\n+ addMembers = {\n+ itemType: \"addMember\",\n+ key: \"addMember\",\n+ };\n}\n- let membersPanel = null;\nif (addMembers || members) {\n- membersPanel = (\n- <View>\n- <ThreadSettingsCategoryHeader type=\"unpadded\" title=\"Members\" />\n- {addMembers}\n- {members}\n- <ThreadSettingsCategoryFooter type=\"unpadded\" />\n- </View>\n- );\n+ listData.push({\n+ itemType: \"header\",\n+ key: \"memberHeader\",\n+ title: \"Members\",\n+ categoryType: \"unpadded\",\n+ });\n}\n-\n- let childThreads = null;\n- if (this.props.childThreadInfos) {\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- <ThreadSettingsSeeMore\n- onPress={this.onPressSeeMoreChildThreads}\n- key=\"seeMore\"\n- />\n- );\n- } else {\n- childThreadInfos = this.props.childThreadInfos;\n+ if (addMembers) {\n+ listData.push(addMembers);\n}\n- childThreads = childThreadInfos.map(threadInfo => {\n- return (\n- <ThreadSettingsChildThread\n- threadInfo={threadInfo}\n- navigate={this.props.navigation.navigate}\n- key={threadInfo.id}\n- />\n- );\n- });\n- if (seeMoreChildThreads) {\n- childThreads.push(seeMoreChildThreads);\n+ if (members) {\n+ listData = [...listData, ...members];\n}\n+ if (addMembers || members) {\n+ listData.push({\n+ itemType: \"footer\",\n+ key: \"memberFooter\",\n+ categoryType: \"unpadded\",\n+ });\n}\n- let addChildThread = null;\n- const canCreateSubthreads = threadHasPermission(\n- this.props.threadInfo,\n- threadPermissions.CREATE_SUBTHREADS,\n- );\n- if (canCreateSubthreads) {\n- addChildThread = (\n- <ThreadSettingsAddChildThread\n- threadInfo={this.props.threadInfo}\n- navigate={this.props.navigation.navigate}\n- />\n- );\n+ if (viewerIsMember(this.props.threadInfo)) {\n+ listData.push({\n+ itemType: \"leaveThread\",\n+ key: \"leaveThread\",\n+ threadInfo: this.props.threadInfo,\n+ threadMembers: this.props.threadMembers,\n+ });\n}\n- let childThreadPanel = null;\n- if (addChildThread || childThreads) {\n- childThreadPanel = (\n+ return (\n<View>\n- <ThreadSettingsCategoryHeader type=\"unpadded\" title=\"Child threads\" />\n- {addChildThread}\n- {childThreads}\n- <ThreadSettingsCategoryFooter type=\"unpadded\" />\n+ <FlatList\n+ data={listData}\n+ contentContainerStyle={styles.flatList}\n+ renderItem={this.renderItem}\n+ />\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- let leaveThreadButton = null;\n- if (viewerIsMember(this.props.threadInfo)) {\n- leaveThreadButton = (\n- <ThreadSettingsLeaveThread\n- threadInfo={this.props.threadInfo}\n- threadMembers={this.props.threadMembers}\n+ renderItem = (row: { item: ChatSettingsItem }) => {\n+ const item = row.item;\n+ if (item.itemType === \"header\") {\n+ return (\n+ <ThreadSettingsCategoryHeader\n+ type={item.categoryType}\n+ title={item.title}\n/>\n);\n- }\n-\n+ } else if (item.itemType === \"footer\") {\n+ return <ThreadSettingsCategoryFooter type={item.categoryType} />;\n+ } else if (item.itemType === \"name\") {\nreturn (\n- <View>\n- <ScrollView contentContainerStyle={styles.scrollView}>\n- <ThreadSettingsCategoryHeader type=\"full\" title=\"Basics\" />\n<ThreadSettingsName\n- threadInfo={this.props.threadInfo}\n- nameEditValue={this.state.nameEditValue}\n+ threadInfo={item.threadInfo}\n+ nameEditValue={item.nameEditValue}\nsetNameEditValue={this.setNameEditValue}\n- nameTextHeight={this.state.nameTextHeight}\n+ nameTextHeight={item.nameTextHeight}\nsetNameTextHeight={this.setNameTextHeight}\n- canChangeSettings={canChangeSettings}\n+ canChangeSettings={item.canChangeSettings}\n/>\n+ );\n+ } else if (item.itemType === \"color\") {\n+ return (\n<ThreadSettingsColor\n- threadInfo={this.props.threadInfo}\n- colorEditValue={this.state.colorEditValue}\n+ threadInfo={item.threadInfo}\n+ colorEditValue={item.colorEditValue}\nsetColorEditValue={this.setColorEditValue}\n- showEditColorModal={this.state.showEditColorModal}\n+ showEditColorModal={item.showEditColorModal}\nsetEditColorModalVisibility={this.setEditColorModalVisibility}\n- canChangeSettings={canChangeSettings}\n+ canChangeSettings={item.canChangeSettings}\n+ />\n+ );\n+ } else if (item.itemType === \"description\") {\n+ return (\n+ <ThreadSettingsDescription\n+ threadInfo={item.threadInfo}\n+ descriptionEditValue={item.descriptionEditValue}\n+ setDescriptionEditValue={this.setDescriptionEditValue}\n+ descriptionTextHeight={item.descriptionTextHeight}\n+ setDescriptionTextHeight={this.setDescriptionTextHeight}\n+ canChangeSettings={item.canChangeSettings}\n/>\n- <ThreadSettingsCategoryFooter type=\"full\" />\n- {description}\n- <ThreadSettingsCategoryHeader type=\"full\" title=\"Privacy\" />\n+ );\n+ } else if (item.itemType === \"parent\") {\n+ return (\n<ThreadSettingsParent\n- threadInfo={this.props.threadInfo}\n- navigate={this.props.navigation.navigate}\n+ threadInfo={item.threadInfo}\n+ navigate={item.navigate}\n/>\n- <ThreadSettingsVisibility threadInfo={this.props.threadInfo} />\n- <ThreadSettingsCategoryFooter type=\"full\" />\n- {childThreadPanel}\n- {membersPanel}\n- {leaveThreadButton}\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+ } else if (item.itemType === \"visibility\") {\n+ return <ThreadSettingsVisibility threadInfo={item.threadInfo} />;\n+ } else if (item.itemType === \"seeMore\") {\n+ return <ThreadSettingsSeeMore onPress={item.onPress} />;\n+ } else if (item.itemType === \"childThread\") {\n+ return (\n+ <ThreadSettingsChildThread\n+ threadInfo={item.threadInfo}\n+ navigate={item.navigate}\n/>\n- </Modal>\n- </View>\n);\n+ } else if (item.itemType === \"addChildThread\") {\n+ return (\n+ <ThreadSettingsAddChildThread\n+ threadInfo={item.threadInfo}\n+ navigate={item.navigate}\n+ />\n+ );\n+ } else if (item.itemType === \"member\") {\n+ return (\n+ <ThreadSettingsMember\n+ memberInfo={item.memberInfo}\n+ threadInfo={item.threadInfo}\n+ canEdit={item.canEdit}\n+ />\n+ );\n+ } else if (item.itemType === \"addMember\") {\n+ return <ThreadSettingsAddMember onPress={this.onPressAddMember} />;\n+ } else if (item.itemType === \"leaveThread\") {\n+ return (\n+ <ThreadSettingsLeaveThread\n+ threadInfo={item.threadInfo}\n+ threadMembers={item.threadMembers}\n+ />\n+ );\n+ }\n}\nsetNameEditValue = (value: ?string, callback?: () => void) => {\n@@ -382,7 +594,7 @@ class InnerThreadSettings extends React.PureComponent<Props, State> {\nthis.setState({ descriptionTextHeight: height });\n}\n- onPressAddUser = () => {\n+ onPressAddMember = () => {\nthis.setState({ showAddUsersModal: true });\n}\n@@ -405,7 +617,7 @@ class InnerThreadSettings extends React.PureComponent<Props, State> {\n}\nconst styles = StyleSheet.create({\n- scrollView: {\n+ flatList: {\npaddingVertical: 16,\n},\n});\n" }, { "change_type": "MODIFY", "old_path": "native/selectors/chat-selectors.js", "new_path": "native/selectors/chat-selectors.js", "diff": "// @flow\n-import type { BaseAppState } from 'lib/types/redux-types';\n+import type { AppState } from '../redux-setup';\nimport type { ThreadInfo } from 'lib/types/thread-types';\nimport { threadInfoPropType } from 'lib/types/thread-types';\nimport type {\n@@ -41,9 +41,9 @@ const chatThreadItemPropType = PropTypes.shape({\n});\nconst chatListData = createSelector(\nthreadInfoSelector,\n- (state: BaseAppState) => state.messageStore,\n- (state: BaseAppState) => state.currentUserInfo && state.currentUserInfo.id,\n- (state: BaseAppState) => state.userInfos,\n+ (state: AppState) => state.messageStore,\n+ (state: AppState) => state.currentUserInfo && state.currentUserInfo.id,\n+ (state: AppState) => state.userInfos,\n(\nthreadInfos: {[id: string]: ThreadInfo},\nmessageStore: MessageStore,\n@@ -114,9 +114,9 @@ const chatMessageItemPropType = PropTypes.oneOfType([\n]);\nconst msInFiveMinutes = 5 * 60 * 1000;\nconst baseMessageListData = (threadID: string) => createSelector(\n- (state: BaseAppState) => state.messageStore,\n- (state: BaseAppState) => state.currentUserInfo && state.currentUserInfo.id,\n- (state: BaseAppState) => state.userInfos,\n+ (state: AppState) => state.messageStore,\n+ (state: AppState) => state.currentUserInfo && state.currentUserInfo.id,\n+ (state: AppState) => state.userInfos,\nthreadInfoSelector,\n(\nmessageStore: MessageStore,\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Convert ThreadSettings ScrollView to FlatList
129,187
24.01.2018 14:06:15
25,200
c6dc7411fd5dac9a03a346e746d2f77a61e31adb
Update to React Native 0.52
[ { "change_type": "MODIFY", "old_path": "native/.flowconfig", "new_path": "native/.flowconfig", "diff": "[libs]\nnode_modules/react-native/Libraries/react-native/react-native-interface.js\nnode_modules/react-native/flow/\n+node_modules/react-native/flow-github/\n[options]\nemoji=true\n@@ -46,14 +47,13 @@ suppress_type=$FlowIssue\nsuppress_type=$FlowFixMe\nsuppress_type=$FlowFixMeProps\nsuppress_type=$FlowFixMeState\n-suppress_type=$FixMe\n-suppress_comment=\\\\(.\\\\|\\n\\\\)*\\\\$FlowFixMe\\\\($\\\\|[^(]\\\\|(\\\\(>=0\\\\.\\\\(5[0-7]\\\\|[1-4][0-9]\\\\|[0-9]\\\\).[0-9]\\\\)? *\\\\(site=[a-z,_]*react_native[a-z,_]*\\\\)?)\\\\)\n-suppress_comment=\\\\(.\\\\|\\n\\\\)*\\\\$FlowIssue\\\\((\\\\(>=0\\\\.\\\\(5[0-7]\\\\|[1-4][0-9]\\\\|[0-9]\\\\).[0-9]\\\\)? *\\\\(site=[a-z,_]*react_native[a-z,_]*\\\\)?)\\\\)?:? #[0-9]+\n+suppress_comment=\\\\(.\\\\|\\n\\\\)*\\\\$FlowFixMe\\\\($\\\\|[^(]\\\\|(\\\\(<VERSION>\\\\)? *\\\\(site=[a-z,_]*react_native[a-z,_]*\\\\)?)\\\\)\n+suppress_comment=\\\\(.\\\\|\\n\\\\)*\\\\$FlowIssue\\\\((\\\\(<VERSION>\\\\)? *\\\\(site=[a-z,_]*react_native[a-z,_]*\\\\)?)\\\\)?:? #[0-9]+\nsuppress_comment=\\\\(.\\\\|\\n\\\\)*\\\\$FlowFixedInNextDeploy\nsuppress_comment=\\\\(.\\\\|\\n\\\\)*\\\\$FlowExpectedError\nunsafe.enable_getters_and_setters=true\n[version]\n-^0.57.0\n+^0.61.0\n" }, { "change_type": "MODIFY", "old_path": "native/ios/SquadCal.xcodeproj/project.pbxproj", "new_path": "native/ios/SquadCal.xcodeproj/project.pbxproj", "diff": "2D02E4C61E0B4AEC006451C7 /* libRCTSettings-tvOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3DAD3E901DF850E9000B6D8A /* libRCTSettings-tvOS.a */; };\n2D02E4C71E0B4AEC006451C7 /* libRCTText-tvOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3DAD3E941DF850E9000B6D8A /* libRCTText-tvOS.a */; };\n2D02E4C81E0B4AEC006451C7 /* libRCTWebSocket-tvOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3DAD3E991DF850E9000B6D8A /* libRCTWebSocket-tvOS.a */; };\n- 2D02E4C91E0B4AEC006451C7 /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3DAD3EA31DF850E9000B6D8A /* libReact.a */; };\n+ 2D16E6881FA4F8E400B85C8A /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2D16E6891FA4F8E400B85C8A /* libReact.a */; };\n2DCD954D1E0B4F2C00145EB5 /* SquadCalTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 00E356F21AD99517003FC87E /* SquadCalTests.m */; };\n2E5ADC2BAEA24F1AAD81E147 /* Zocial.ttf in Resources */ = {isa = PBXBuildFile; fileRef = EBD8879422144B0188A8336F /* Zocial.ttf */; };\n569C48070423498795574595 /* EvilIcons.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 3430816A291640AEACA13234 /* EvilIcons.ttf */; };\nremoteGlobalIDString = 2D02E47A1E0B4A5D006451C7;\nremoteInfo = \"SquadCal-tvOS\";\n};\n+ 2D16E6711FA4F8DC00B85C8A /* PBXContainerItemProxy */ = {\n+ isa = PBXContainerItemProxy;\n+ containerPortal = ADBDB91F1DFEBF0600ED6528 /* RCTBlob.xcodeproj */;\n+ proxyType = 2;\n+ remoteGlobalIDString = ADD01A681E09402E00F6D226;\n+ remoteInfo = \"RCTBlob-tvOS\";\n+ };\n+ 2D16E6831FA4F8DC00B85C8A /* PBXContainerItemProxy */ = {\n+ isa = PBXContainerItemProxy;\n+ containerPortal = 139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */;\n+ proxyType = 2;\n+ remoteGlobalIDString = 3DBE0D001F3B181A0099AA32;\n+ remoteInfo = fishhook;\n+ };\n+ 2D16E6851FA4F8DC00B85C8A /* PBXContainerItemProxy */ = {\n+ isa = PBXContainerItemProxy;\n+ containerPortal = 139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */;\n+ proxyType = 2;\n+ remoteGlobalIDString = 3DBE0D0D1F3B181C0099AA32;\n+ remoteInfo = \"fishhook-tvOS\";\n+ };\n3DAD3E831DF850E9000B6D8A /* PBXContainerItemProxy */ = {\nisa = PBXContainerItemProxy;\ncontainerPortal = 00C302BB1ABCB91800DB3ED1 /* RCTImage.xcodeproj */;\n3430816A291640AEACA13234 /* EvilIcons.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = EvilIcons.ttf; path = \"../node_modules/react-native-vector-icons/Fonts/EvilIcons.ttf\"; sourceTree = \"<group>\"; };\n4AB1FC0EFD3A4ED1A082E32F /* FontAwesome.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = FontAwesome.ttf; path = \"../node_modules/react-native-vector-icons/Fonts/FontAwesome.ttf\"; sourceTree = \"<group>\"; };\n4ACC468F28D944F293B91ACC /* Ionicons.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = Ionicons.ttf; path = \"../node_modules/react-native-vector-icons/Fonts/Ionicons.ttf\"; sourceTree = \"<group>\"; };\n+ 2D16E6891FA4F8E400B85C8A /* libReact.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libReact.a; sourceTree = BUILT_PRODUCTS_DIR; };\n5E91572D1DD0AC6500FF2AA8 /* RCTAnimation.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = \"wrapper.pb-project\"; name = RCTAnimation.xcodeproj; path = \"../node_modules/react-native/Libraries/NativeAnimation/RCTAnimation.xcodeproj\"; sourceTree = \"<group>\"; };\n78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = \"wrapper.pb-project\"; name = RCTLinking.xcodeproj; path = \"../node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj\"; sourceTree = \"<group>\"; };\n7FB58ABB1E7F6BC600B4C1B1 /* Anaheim-Regular.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = \"Anaheim-Regular.ttf\"; sourceTree = \"<group>\"; };\nbuildActionMask = 2147483647;\nfiles = (\n2D02E4C91E0B4AEC006451C7 /* libReact.a in Frameworks */,\n+ 2D16E6881FA4F8E400B85C8A /* libReact.a in Frameworks */,\n2D02E4C21E0B4AEC006451C7 /* libRCTAnimation.a in Frameworks */,\n2D02E4C31E0B4AEC006451C7 /* libRCTImage-tvOS.a in Frameworks */,\n2D02E4C41E0B4AEC006451C7 /* libRCTLinking-tvOS.a in Frameworks */,\n3DAD3E991DF850E9000B6D8A /* libRCTWebSocket-tvOS.a */,\n7F407AEB1FF1D826006997C8 /* libfishhook.a */,\n7F407AED1FF1D826006997C8 /* libfishhook-tvOS.a */,\n+ 2D16E6841FA4F8DC00B85C8A /* libfishhook.a */,\n+ 2D16E6861FA4F8DC00B85C8A /* libfishhook-tvOS.a */,\n);\nname = Products;\nsourceTree = \"<group>\";\nisa = PBXGroup;\nchildren = (\n146834041AC3E56700842450 /* libReact.a */,\n- 3DAD3EA31DF850E9000B6D8A /* libReact.a */,\n3DAD3EA51DF850E9000B6D8A /* libyoga.a */,\n3DAD3EA71DF850E9000B6D8A /* libyoga.a */,\n3DAD3EA91DF850E9000B6D8A /* libcxxreact.a */,\nname = Products;\nsourceTree = \"<group>\";\n};\n+ 2D16E6871FA4F8E400B85C8A /* Frameworks */ = {\n+ isa = PBXGroup;\n+ children = (\n+ 2D16E6891FA4F8E400B85C8A /* libReact.a */,\n+ );\n+ name = Frameworks;\n+ sourceTree = \"<group>\";\n+ };\n5E91572E1DD0AC6500FF2AA8 /* Products */ = {\nisa = PBXGroup;\nchildren = (\n6534411766BE4CA4B0AB0A78 /* Resources */,\n7FF0870B1E833C3F000A1ACF /* Frameworks */,\n7F5B10C02005349C00FE096A /* Recovered References */,\n+ 2D16E6871FA4F8E400B85C8A /* Frameworks */,\n);\nindentWidth = 2;\nsourceTree = \"<group>\";\nname = Products;\nsourceTree = \"<group>\";\n};\n+ ADBDB9201DFEBF0600ED6528 /* Products */ = {\n+ isa = PBXGroup;\n+ children = (\n+ ADBDB9271DFEBF0700ED6528 /* libRCTBlob.a */,\n+ 2D16E6721FA4F8DC00B85C8A /* libRCTBlob-tvOS.a */,\n+ );\n+ name = Products;\n+ sourceTree = \"<group>\";\n+ };\n/* End PBXGroup section */\n/* Begin PBXNativeTarget section */\nremoteRef = 146834031AC3E56700842450 /* PBXContainerItemProxy */;\nsourceTree = BUILT_PRODUCTS_DIR;\n};\n+ 2D16E6721FA4F8DC00B85C8A /* libRCTBlob-tvOS.a */ = {\n+ isa = PBXReferenceProxy;\n+ fileType = archive.ar;\n+ path = \"libRCTBlob-tvOS.a\";\n+ remoteRef = 2D16E6711FA4F8DC00B85C8A /* PBXContainerItemProxy */;\n+ sourceTree = BUILT_PRODUCTS_DIR;\n+ };\n+ 2D16E6841FA4F8DC00B85C8A /* libfishhook.a */ = {\n+ isa = PBXReferenceProxy;\n+ fileType = archive.ar;\n+ path = libfishhook.a;\n+ remoteRef = 2D16E6831FA4F8DC00B85C8A /* PBXContainerItemProxy */;\n+ sourceTree = BUILT_PRODUCTS_DIR;\n+ };\n+ 2D16E6861FA4F8DC00B85C8A /* libfishhook-tvOS.a */ = {\n+ isa = PBXReferenceProxy;\n+ fileType = archive.ar;\n+ path = \"libfishhook-tvOS.a\";\n+ remoteRef = 2D16E6851FA4F8DC00B85C8A /* PBXContainerItemProxy */;\n+ sourceTree = BUILT_PRODUCTS_DIR;\n+ };\n3DAD3E841DF850E9000B6D8A /* libRCTImage-tvOS.a */ = {\nisa = PBXReferenceProxy;\nfileType = archive.ar;\n" }, { "change_type": "MODIFY", "old_path": "native/package-lock.json", "new_path": "native/package-lock.json", "diff": "\"default-require-extensions\": \"1.0.0\"\n}\n},\n+ \"arch\": {\n+ \"version\": \"2.1.0\",\n+ \"resolved\": \"https://registry.npmjs.org/arch/-/arch-2.1.0.tgz\",\n+ \"integrity\": \"sha1-NhOqRhSQZLPB8GB5Gb8dR4boKIk=\"\n+ },\n\"are-we-there-yet\": {\n\"version\": \"1.1.4\",\n\"resolved\": \"https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-1.1.4.tgz\",\n\"resolved\": \"https://registry.npmjs.org/cli-width/-/cli-width-2.2.0.tgz\",\n\"integrity\": \"sha1-/xnt6Kml5XkyQUewwR8PvLq+1jk=\"\n},\n+ \"clipboardy\": {\n+ \"version\": \"1.2.2\",\n+ \"resolved\": \"https://registry.npmjs.org/clipboardy/-/clipboardy-1.2.2.tgz\",\n+ \"integrity\": \"sha512-16KrBOV7bHmHdxcQiCvfUFYVFyEah4FI8vYT1Fr7CGSA4G+xBWMEfUEQJS1hxeHGtI9ju1Bzs9uXSbj5HZKArw==\",\n+ \"requires\": {\n+ \"arch\": \"2.1.0\",\n+ \"execa\": \"0.8.0\"\n+ },\n+ \"dependencies\": {\n+ \"execa\": {\n+ \"version\": \"0.8.0\",\n+ \"resolved\": \"https://registry.npmjs.org/execa/-/execa-0.8.0.tgz\",\n+ \"integrity\": \"sha1-2NdrvBtVIX7RkP1t1J08d07PyNo=\",\n+ \"requires\": {\n+ \"cross-spawn\": \"5.1.0\",\n+ \"get-stream\": \"3.0.0\",\n+ \"is-stream\": \"1.1.0\",\n+ \"npm-run-path\": \"2.0.2\",\n+ \"p-finally\": \"1.0.0\",\n+ \"signal-exit\": \"3.0.2\",\n+ \"strip-eof\": \"1.0.0\"\n+ }\n+ }\n+ }\n+ },\n\"cliui\": {\n\"version\": \"3.2.0\",\n\"resolved\": \"https://registry.npmjs.org/cliui/-/cliui-3.2.0.tgz\",\n\"resolved\": \"https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz\",\n\"integrity\": \"sha1-4wOogrNCzD7oylE6eZmXNNqzriw=\"\n},\n- \"copy-paste\": {\n- \"version\": \"1.3.0\",\n- \"resolved\": \"https://registry.npmjs.org/copy-paste/-/copy-paste-1.3.0.tgz\",\n- \"integrity\": \"sha1-p+bEocKP3t8rCB5yuX3y75X0ce0=\",\n- \"requires\": {\n- \"iconv-lite\": \"0.4.19\",\n- \"sync-exec\": \"0.6.2\"\n- }\n- },\n\"core-js\": {\n\"version\": \"1.2.7\",\n\"resolved\": \"https://registry.npmjs.org/core-js/-/core-js-1.2.7.tgz\",\n\"repeating\": \"2.0.1\"\n}\n},\n+ \"detect-newline\": {\n+ \"version\": \"2.1.0\",\n+ \"resolved\": \"https://registry.npmjs.org/detect-newline/-/detect-newline-2.1.0.tgz\",\n+ \"integrity\": \"sha1-9B8cEL5LAOh7XxPaaAdZ8sW/0+I=\"\n+ },\n\"diff\": {\n\"version\": \"3.4.0\",\n\"resolved\": \"https://registry.npmjs.org/diff/-/diff-3.4.0.tgz\",\n}\n},\n\"envinfo\": {\n- \"version\": \"3.10.0\",\n- \"resolved\": \"https://registry.npmjs.org/envinfo/-/envinfo-3.10.0.tgz\",\n- \"integrity\": \"sha512-7m6zSyFfEb3lAjZI217G1XVSAkYeFJHk2EqAVeoncrt+WtHddW4nnft2qPg82Xu1aB/T8nC/DPvkGgUUahli4g==\",\n+ \"version\": \"3.11.0\",\n+ \"resolved\": \"https://registry.npmjs.org/envinfo/-/envinfo-3.11.0.tgz\",\n+ \"integrity\": \"sha512-jhE0+XzBaKIktPEfvAyMpWZK8bq9tMYKVYKFo7x+kRbDZtyifD6EtOfzFkdb0qpQTTlDczDHlDgptiLM4/azFg==\",\n\"requires\": {\n- \"copy-paste\": \"1.3.0\",\n+ \"clipboardy\": \"1.2.2\",\n\"glob\": \"7.1.2\",\n\"minimist\": \"1.2.0\",\n\"os-name\": \"2.0.1\",\n\"version\": \"0.1.6\",\n\"resolved\": \"https://registry.npmjs.org/errno/-/errno-0.1.6.tgz\",\n\"integrity\": \"sha512-IsORQDpaaSwcDP4ZZnHxgE85werpo34VYn1Ud3mq+eUsF593faR8oCZNXrROVkpFu2TsbrNhHin0aUrTsQ9vNw==\",\n+ \"dev\": true,\n\"requires\": {\n\"prr\": \"1.0.1\"\n}\n}\n},\n\"flow-bin\": {\n- \"version\": \"0.57.3\",\n- \"resolved\": \"https://registry.npmjs.org/flow-bin/-/flow-bin-0.57.3.tgz\",\n- \"integrity\": \"sha512-bbB7KLR1bLS0CvHSsKseOGFF6iI2N9ocL14EQv8Hng28ZksD0gNRzR2JopqA3WGrQYJukDU1W4ZuKoBaRuElFA==\",\n+ \"version\": \"0.61.0\",\n+ \"resolved\": \"https://registry.npmjs.org/flow-bin/-/flow-bin-0.61.0.tgz\",\n+ \"integrity\": \"sha512-w6SGi5CDfKLNGzYssRhW6N37qKclDXijsxDQ5M8c3WbivRYta0Horv22bwakegfKBVDnyeS0lRW3OqBC74eq2g==\",\n\"dev\": true\n},\n\"for-in\": {\n}\n},\n\"jest-docblock\": {\n- \"version\": \"21.2.0\",\n- \"resolved\": \"https://registry.npmjs.org/jest-docblock/-/jest-docblock-21.2.0.tgz\",\n- \"integrity\": \"sha512-5IZ7sY9dBAYSV+YjQ0Ovb540Ku7AO9Z5o2Cg789xj167iQuZ2cG+z0f3Uct6WeYLbU6aQiM2pCs7sZ+4dotydw==\"\n+ \"version\": \"22.0.3\",\n+ \"resolved\": \"https://registry.npmjs.org/jest-docblock/-/jest-docblock-22.0.3.tgz\",\n+ \"integrity\": \"sha512-LhviP2rqIg2IzS6m97W7T032oMrT699Tr6Njjhhl4FCLj+75BUy9CsSmGgfoVEql1uc+myBkssvcbn7T9xDR+A==\",\n+ \"requires\": {\n+ \"detect-newline\": \"2.1.0\"\n+ }\n},\n\"jest-environment-jsdom\": {\n\"version\": \"20.0.3\",\n}\n},\n\"jest-haste-map\": {\n- \"version\": \"21.2.0\",\n- \"resolved\": \"https://registry.npmjs.org/jest-haste-map/-/jest-haste-map-21.2.0.tgz\",\n- \"integrity\": \"sha512-5LhsY/loPH7wwOFRMs+PT4aIAORJ2qwgbpMFlbWbxfN0bk3ZCwxJ530vrbSiTstMkYLao6JwBkLhCJ5XbY7ZHw==\",\n+ \"version\": \"22.0.3\",\n+ \"resolved\": \"https://registry.npmjs.org/jest-haste-map/-/jest-haste-map-22.0.3.tgz\",\n+ \"integrity\": \"sha512-VosIMOFQFu1rTF+MvOWVuv2KVmZ9eTkRgfwW2yUAs6/AhwmIfXRl/tih+fIOYcHzU4Auu1G8Fvl2kkF5g0k6/A==\",\n\"requires\": {\n\"fb-watchman\": \"2.0.0\",\n\"graceful-fs\": \"4.1.11\",\n- \"jest-docblock\": \"21.2.0\",\n+ \"jest-docblock\": \"22.0.3\",\n+ \"jest-worker\": \"22.0.3\",\n\"micromatch\": \"2.3.11\",\n- \"sane\": \"2.2.0\",\n- \"worker-farm\": \"1.5.2\"\n+ \"sane\": \"2.2.0\"\n}\n},\n\"jest-jasmine2\": {\n}\n}\n},\n+ \"jest-worker\": {\n+ \"version\": \"22.0.3\",\n+ \"resolved\": \"https://registry.npmjs.org/jest-worker/-/jest-worker-22.0.3.tgz\",\n+ \"integrity\": \"sha512-fPdCTnogFQiR0CP6whEsIly2RfcHxvalqyLjhui6qa1SnOmHiX7L8k4Umo8CBIp5ndWY0+ej1o7OTE5MlzPabg==\",\n+ \"requires\": {\n+ \"merge-stream\": \"1.0.1\"\n+ }\n+ },\n\"js-tokens\": {\n\"version\": \"3.0.2\",\n\"resolved\": \"https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz\",\n\"resolved\": \"https://registry.npmjs.org/methods/-/methods-1.1.2.tgz\",\n\"integrity\": \"sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=\"\n},\n- \"metro-bundler\": {\n- \"version\": \"0.20.3\",\n- \"resolved\": \"https://registry.npmjs.org/metro-bundler/-/metro-bundler-0.20.3.tgz\",\n- \"integrity\": \"sha512-rKhIXSUEYbBUB9Ues30GYlcotM/4hPTmriBJGdNW5D+zdlxQUgJuPEo2Woo7khNM7xRG5tN7IRnMkKlzx43/Nw==\",\n+ \"metro\": {\n+ \"version\": \"0.24.4\",\n+ \"resolved\": \"https://registry.npmjs.org/metro/-/metro-0.24.4.tgz\",\n+ \"integrity\": \"sha512-XWAKE1J7D+BmriaylC/DyP55gE1Aevg9lHd7XZ3oG7QDrb+lgt8hbicQj1sphXxYJ6Rxbu6mzgGtBAL2ENzW+Q==\",\n\"requires\": {\n\"absolute-path\": \"0.0.0\",\n\"async\": \"2.6.0\",\n\"babylon\": \"6.18.0\",\n\"chalk\": \"1.1.3\",\n\"concat-stream\": \"1.6.0\",\n+ \"connect\": \"2.30.2\",\n\"core-js\": \"2.5.3\",\n\"debug\": \"2.6.9\",\n\"denodeify\": \"1.2.1\",\n\"fbjs\": \"0.8.16\",\n+ \"fs-extra\": \"1.0.0\",\n\"graceful-fs\": \"4.1.11\",\n\"image-size\": \"0.6.2\",\n- \"jest-docblock\": \"21.2.0\",\n- \"jest-haste-map\": \"21.2.0\",\n+ \"jest-docblock\": \"22.0.3\",\n+ \"jest-haste-map\": \"22.0.3\",\n+ \"jest-worker\": \"22.0.3\",\n\"json-stable-stringify\": \"1.0.1\",\n\"json5\": \"0.4.0\",\n\"left-pad\": \"1.2.0\",\n\"lodash\": \"4.17.4\",\n\"merge-stream\": \"1.0.1\",\n+ \"metro-core\": \"0.24.4\",\n+ \"metro-source-map\": \"0.24.4\",\n\"mime-types\": \"2.1.11\",\n\"mkdirp\": \"0.5.1\",\n\"request\": \"2.83.0\",\n\"uglify-es\": \"3.3.7\",\n\"wordwrap\": \"1.0.0\",\n\"write-file-atomic\": \"1.3.4\",\n- \"xpipe\": \"1.0.5\"\n+ \"xpipe\": \"1.0.5\",\n+ \"yargs\": \"9.0.1\"\n},\n\"dependencies\": {\n\"babel-preset-react-native\": {\n}\n}\n},\n+ \"metro-core\": {\n+ \"version\": \"0.24.4\",\n+ \"resolved\": \"https://registry.npmjs.org/metro-core/-/metro-core-0.24.4.tgz\",\n+ \"integrity\": \"sha512-ul1nNQgF8T/zivrK/deKdF74zgU0eUiooiIM8cqEY/bISmbbkENFJpcBW8BvznQGuYOkbF4HoqJprAcpU+HqgA==\"\n+ },\n+ \"metro-source-map\": {\n+ \"version\": \"0.24.4\",\n+ \"resolved\": \"https://registry.npmjs.org/metro-source-map/-/metro-source-map-0.24.4.tgz\",\n+ \"integrity\": \"sha512-05QGyTC87rI52HR4dKcYqnI8Jm8DUAIXUtdglXsGVPEZl0JoVEJ0dRxnbwGczWImalwjEI/D7fshauxKS6l3sg==\",\n+ \"requires\": {\n+ \"source-map\": \"0.5.7\"\n+ }\n+ },\n\"micromatch\": {\n\"version\": \"2.3.11\",\n\"resolved\": \"https://registry.npmjs.org/micromatch/-/micromatch-2.3.11.tgz\",\n\"prr\": {\n\"version\": \"1.0.1\",\n\"resolved\": \"https://registry.npmjs.org/prr/-/prr-1.0.1.tgz\",\n- \"integrity\": \"sha1-0/wRS6BplaRexok/SEzrHXj19HY=\"\n+ \"integrity\": \"sha1-0/wRS6BplaRexok/SEzrHXj19HY=\",\n+ \"dev\": true\n},\n\"pseudomap\": {\n\"version\": \"1.0.2\",\n}\n},\n\"react\": {\n- \"version\": \"16.0.0\",\n- \"resolved\": \"https://registry.npmjs.org/react/-/react-16.0.0.tgz\",\n- \"integrity\": \"sha1-zn348ZQbA28Cssyp29DLHw6FXi0=\",\n+ \"version\": \"16.2.0\",\n+ \"resolved\": \"https://registry.npmjs.org/react/-/react-16.2.0.tgz\",\n+ \"integrity\": \"sha512-ZmIomM7EE1DvPEnSFAHZn9Vs9zJl5A9H7el0EGTE6ZbW9FKe/14IYAlPbC8iH25YarEQxZL+E8VW7Mi7kfQrDQ==\",\n\"requires\": {\n\"fbjs\": \"0.8.16\",\n\"loose-envify\": \"1.3.1\",\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+ \"dev\": true,\n\"requires\": {\n\"shell-quote\": \"1.6.1\",\n\"ws\": \"2.3.1\"\n\"safe-buffer\": {\n\"version\": \"5.0.1\",\n\"resolved\": \"https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.0.1.tgz\",\n- \"integrity\": \"sha1-0mPKVGls2KMGtcplUekt5XkY++c=\"\n+ \"integrity\": \"sha1-0mPKVGls2KMGtcplUekt5XkY++c=\",\n+ \"dev\": true\n},\n\"ws\": {\n\"version\": \"2.3.1\",\n\"resolved\": \"https://registry.npmjs.org/ws/-/ws-2.3.1.tgz\",\n\"integrity\": \"sha1-a5Sz5EfLajY/eF6vlK9jWejoHIA=\",\n+ \"dev\": true,\n\"requires\": {\n\"safe-buffer\": \"5.0.1\",\n\"ultron\": \"1.1.1\"\n}\n},\n\"react-native\": {\n- \"version\": \"0.51.0\",\n- \"resolved\": \"https://registry.npmjs.org/react-native/-/react-native-0.51.0.tgz\",\n- \"integrity\": \"sha512-XpLmz3C7DOds5TUwIOpQBEXqoFDtU2/HmMBzVItGlHtowXpcHoQxJYSxL4Z9u8B4EeDfSvGfU2TFHq0sV3xd3Q==\",\n+ \"version\": \"0.52.0\",\n+ \"resolved\": \"https://registry.npmjs.org/react-native/-/react-native-0.52.0.tgz\",\n+ \"integrity\": \"sha512-2Z/1IIA+0PhgzW/r2qfTIWuDWpA8i+pKud/Ygp6JqoMnbFK79JYPkYSAMEkL7uz+oiQ+4bkKqbbUbVkwgF9ZOg==\",\n\"requires\": {\n\"absolute-path\": \"0.0.0\",\n\"art\": \"0.10.1\",\n\"create-react-class\": \"15.6.2\",\n\"debug\": \"2.6.9\",\n\"denodeify\": \"1.2.1\",\n- \"envinfo\": \"3.10.0\",\n+ \"envinfo\": \"3.11.0\",\n\"event-target-shim\": \"1.1.1\",\n\"fbjs\": \"0.8.16\",\n\"fbjs-scripts\": \"0.8.1\",\n\"graceful-fs\": \"4.1.11\",\n\"inquirer\": \"3.3.0\",\n\"lodash\": \"4.17.4\",\n- \"metro-bundler\": \"0.20.3\",\n+ \"metro\": \"0.24.4\",\n+ \"metro-core\": \"0.24.4\",\n\"mime\": \"1.6.0\",\n\"minimist\": \"1.2.0\",\n\"mkdirp\": \"0.5.1\",\n\"promise\": \"7.3.1\",\n\"prop-types\": \"15.6.0\",\n\"react-clone-referenced-element\": \"1.0.1\",\n- \"react-devtools-core\": \"2.5.2\",\n+ \"react-devtools-core\": \"3.0.0\",\n\"react-timer-mixin\": \"0.13.3\",\n\"regenerator-runtime\": \"0.11.1\",\n\"rimraf\": \"2.6.2\",\n\"yargs\": \"9.0.1\"\n},\n\"dependencies\": {\n+ \"react-devtools-core\": {\n+ \"version\": \"3.0.0\",\n+ \"resolved\": \"https://registry.npmjs.org/react-devtools-core/-/react-devtools-core-3.0.0.tgz\",\n+ \"integrity\": \"sha512-24oLTwNqZJceQXfAfKRp3PwCyg2agXAQhgGwe/x6V6CvjLmnMmba4/ut9S8JTIJq7pS9fpPaRDGo5u3923RLFA==\",\n+ \"requires\": {\n+ \"shell-quote\": \"1.6.1\",\n+ \"ws\": \"2.3.1\"\n+ },\n+ \"dependencies\": {\n+ \"ws\": {\n+ \"version\": \"2.3.1\",\n+ \"resolved\": \"https://registry.npmjs.org/ws/-/ws-2.3.1.tgz\",\n+ \"integrity\": \"sha1-a5Sz5EfLajY/eF6vlK9jWejoHIA=\",\n+ \"requires\": {\n+ \"safe-buffer\": \"5.0.1\",\n+ \"ultron\": \"1.1.1\"\n+ }\n+ }\n+ }\n+ },\n+ \"safe-buffer\": {\n+ \"version\": \"5.0.1\",\n+ \"resolved\": \"https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.0.1.tgz\",\n+ \"integrity\": \"sha1-0mPKVGls2KMGtcplUekt5XkY++c=\"\n+ },\n\"whatwg-fetch\": {\n\"version\": \"1.1.1\",\n\"resolved\": \"https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-1.1.1.tgz\",\n\"integrity\": \"sha1-rifbOPZgp64uHDt9G8KQgZuFGeY=\",\n\"dev\": true\n},\n- \"sync-exec\": {\n- \"version\": \"0.6.2\",\n- \"resolved\": \"https://registry.npmjs.org/sync-exec/-/sync-exec-0.6.2.tgz\",\n- \"integrity\": \"sha1-cX0izFPwzh3vVZQ2LzqJouu5EQU=\",\n- \"optional\": true\n- },\n\"temp\": {\n\"version\": \"0.8.3\",\n\"resolved\": \"https://registry.npmjs.org/temp/-/temp-0.8.3.tgz\",\n\"version\": \"1.5.2\",\n\"resolved\": \"https://registry.npmjs.org/worker-farm/-/worker-farm-1.5.2.tgz\",\n\"integrity\": \"sha512-XxiQ9kZN5n6mmnW+mFJ+wXjNNI/Nx4DIdaAKLX1Bn6LYBWlN/zaBhu34DQYPZ1AJobQuu67S2OfDdNSVULvXkQ==\",\n+ \"dev\": true,\n\"requires\": {\n\"errno\": \"0.1.6\",\n\"xtend\": \"4.0.1\"\n" }, { "change_type": "MODIFY", "old_path": "native/package.json", "new_path": "native/package.json", "diff": "\"color\": \"^2.0.0\",\n\"invariant\": \"^2.2.2\",\n\"lib\": \"file:../lib\",\n- \"react\": \"16.0.0\",\n- \"react-native\": \"^0.51.0\",\n+ \"react\": \"^16.2.0\",\n+ \"react-native\": \"^0.52.0\",\n\"react-native-fcm\": \"^11.2.0\",\n\"react-native-in-app-notification\": \"^2.1.0\",\n\"react-native-keychain\": \"^1.2.1\",\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-native-vector-icons\": \"^4.5.0\",\n\"react-navigation\": \"^1.0.0-beta.27\",\n\"react-redux\": \"^5.0.6\",\n\"redux\": \"^3.7.2\",\n\"babel-jest\": \"^20.0.3\",\n\"babel-plugin-transform-remove-console\": \"^6.8.5\",\n\"babel-preset-react-native\": \"3.0.2\",\n- \"flow-bin\": \"^0.57.3\",\n+ \"flow-bin\": \"^0.61.0\",\n\"jest\": \"^20.0.4\",\n\"react-devtools\": \"^2.5.0\",\n\"react-test-renderer\": \"^15.6.1\"\n" }, { "change_type": "ADD", "old_path": null, "new_path": "native/rn-cli.config.js", "diff": "+const blacklist = require('metro/src/blacklist');\n+\n+module.exports = {\n+ getBlacklistRE() {\n+ return blacklist([/react-native\\/local-cli\\/core\\/__fixtures__.*/]);\n+ },\n+}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Update to React Native 0.52
129,187
30.01.2018 15:20:07
18,000
c8513d0e508887bd53e44f57a4abe4cfa4b8a615
Import Header components directly from react-navigation to avoid Flow errors
[ { "change_type": "MODIFY", "old_path": "native/chat/message-list-header-title.react.js", "new_path": "native/chat/message-list-header-title.react.js", "diff": "@@ -8,7 +8,7 @@ import React from 'react';\nimport { View, Text, StyleSheet, Platform } from 'react-native';\nimport PropTypes from 'prop-types';\nimport Icon from 'react-native-vector-icons/Ionicons';\n-import HeaderTitle from 'react-navigation/src/views/Header/HeaderTitle';\n+import { HeaderTitle } from 'react-navigation';\nimport Button from '../components/button.react';\nimport { ThreadSettingsRouteName } from './settings/thread-settings.react';\n" }, { "change_type": "MODIFY", "old_path": "native/chat/message-list-header.react.js", "new_path": "native/chat/message-list-header.react.js", "diff": "import type { HeaderProps, NavigationScene } from 'react-navigation';\nimport React from 'react';\n-import Header from 'react-navigation/src/views/Header/Header';\n+import { Header } from 'react-navigation';\n// The whole reason for overriding header is because when we override\n// headerTitle, we end up having to implement headerTruncatedBackTitle ourselves\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Import Header components directly from react-navigation to avoid Flow errors
129,187
30.01.2018 15:20:19
18,000
2dc0c72083115f7d30a41b81bf78cfb1b56c5130
Upgrade react-devtools to avoid security vulnerability in old version of Electron
[ { "change_type": "MODIFY", "old_path": "native/package-lock.json", "new_path": "native/package-lock.json", "diff": "\"babel-template\": \"6.26.0\"\n}\n},\n- \"babel-plugin-transform-define\": {\n- \"version\": \"1.3.0\",\n- \"resolved\": \"https://registry.npmjs.org/babel-plugin-transform-define/-/babel-plugin-transform-define-1.3.0.tgz\",\n- \"integrity\": \"sha1-lMX5RZyBDHOMx8UMvUSjGCnW8xk=\",\n- \"requires\": {\n- \"lodash\": \"4.17.4\",\n- \"traverse\": \"0.6.6\"\n- }\n- },\n\"babel-plugin-transform-es2015-arrow-functions\": {\n\"version\": \"6.22.0\",\n\"resolved\": \"https://registry.npmjs.org/babel-plugin-transform-es2015-arrow-functions/-/babel-plugin-transform-es2015-arrow-functions-6.22.0.tgz\",\n\"integrity\": \"sha512-uTGIPNx/nSpBdsF6xnseRXLLtfr9VLqkz8ZqHXr3Y7b6SftyRxBGjwMtJj1OhNbmlc1wZzLNAlAcvyIiE8a6ZA==\",\n\"dev\": true\n},\n- \"clamp\": {\n- \"version\": \"1.0.1\",\n- \"resolved\": \"https://registry.npmjs.org/clamp/-/clamp-1.0.1.tgz\",\n- \"integrity\": \"sha1-ZqDmQBGBbjcZaCj9yMjBRzEshjQ=\"\n- },\n\"cli-boxes\": {\n\"version\": \"1.0.0\",\n\"resolved\": \"https://registry.npmjs.org/cli-boxes/-/cli-boxes-1.0.0.tgz\",\n\"integrity\": \"sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=\"\n},\n\"electron\": {\n- \"version\": \"1.7.10\",\n- \"resolved\": \"https://registry.npmjs.org/electron/-/electron-1.7.10.tgz\",\n- \"integrity\": \"sha1-Oj6D2WX9f6/kc76N349HJWG2JT0=\",\n+ \"version\": \"1.7.11\",\n+ \"resolved\": \"https://registry.npmjs.org/electron/-/electron-1.7.11.tgz\",\n+ \"integrity\": \"sha1-mTtqp54OeafPzDafTIE/vZoLCNk=\",\n\"dev\": true,\n\"requires\": {\n\"@types/node\": \"7.0.52\",\n\"minimist\": \"1.2.0\",\n\"nugget\": \"2.0.1\",\n\"path-exists\": \"2.1.0\",\n- \"rc\": \"1.2.3\",\n+ \"rc\": \"1.2.4\",\n\"semver\": \"5.4.1\",\n\"sumchecker\": \"1.3.1\"\n},\n}\n},\n\"es6-promise\": {\n- \"version\": \"4.2.2\",\n- \"resolved\": \"https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.2.tgz\",\n- \"integrity\": \"sha512-LSas5vsuA6Q4nEdf9wokY5/AJYXry98i0IzXsv49rYsgDGDNDPbqAYR1Pe23iFxygfbGZNR/5VrHXBCh2BhvUQ==\",\n+ \"version\": \"4.2.4\",\n+ \"resolved\": \"https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.4.tgz\",\n+ \"integrity\": \"sha512-/NdNZVJg+uZgtm9eS3O6lrOLYmQag2DjdEXuPaHlZ6RuVqgqaVZfgYCepEIKsLqwdQArOPtC3XzRLqGGfT8KQQ==\",\n\"dev\": true\n},\n\"escape-html\": {\n\"dev\": true,\n\"requires\": {\n\"got\": \"6.7.1\",\n- \"registry-auth-token\": \"3.3.1\",\n+ \"registry-auth-token\": \"3.3.2\",\n\"registry-url\": \"3.1.0\",\n\"semver\": \"5.4.1\"\n}\n\"integrity\": \"sha1-PBrfhx6pzWyUMbbqK9dKD/BVxME=\",\n\"dev\": true\n},\n- \"path-to-regexp\": {\n- \"version\": \"1.7.0\",\n- \"resolved\": \"https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-1.7.0.tgz\",\n- \"integrity\": \"sha1-Wf3g9DW62suhA6hOnTvGTpa5k30=\",\n- \"requires\": {\n- \"isarray\": \"0.0.1\"\n- }\n- },\n\"path-type\": {\n\"version\": \"2.0.0\",\n\"resolved\": \"https://registry.npmjs.org/path-type/-/path-type-2.0.0.tgz\",\n}\n},\n\"rc\": {\n- \"version\": \"1.2.3\",\n- \"resolved\": \"https://registry.npmjs.org/rc/-/rc-1.2.3.tgz\",\n- \"integrity\": \"sha1-UVdakA+N1oOBxxC0cSwhVMPiA1s=\",\n+ \"version\": \"1.2.4\",\n+ \"resolved\": \"https://registry.npmjs.org/rc/-/rc-1.2.4.tgz\",\n+ \"integrity\": \"sha1-oPYGyq4qO4YrvQ74VILAElsxX6M=\",\n\"dev\": true,\n\"requires\": {\n\"deep-extend\": \"0.4.2\",\n\"integrity\": \"sha1-vNMUeAJ7ZLMznxCJIatSC0MT3Cw=\"\n},\n\"react-devtools\": {\n- \"version\": \"2.5.2\",\n- \"resolved\": \"https://registry.npmjs.org/react-devtools/-/react-devtools-2.5.2.tgz\",\n- \"integrity\": \"sha1-tjGVkLKH9g2rdnAG6IJ3ARP6LK4=\",\n+ \"version\": \"3.0.0\",\n+ \"resolved\": \"https://registry.npmjs.org/react-devtools/-/react-devtools-3.0.0.tgz\",\n+ \"integrity\": \"sha512-V8JrJNSyaAOzzIyA2voQsaGwwUcdzHZwiheZSuY/W5QA67W+zxpzMT0pQ90e9HFSNzDgsBN1byg/nMFYWwutmg==\",\n\"dev\": true,\n\"requires\": {\n\"cross-spawn\": \"5.1.0\",\n- \"electron\": \"1.7.10\",\n+ \"electron\": \"1.7.11\",\n\"ip\": \"1.1.5\",\n\"minimist\": \"1.2.0\",\n- \"react-devtools-core\": \"2.5.2\",\n+ \"react-devtools-core\": \"3.0.0\",\n\"update-notifier\": \"2.3.0\"\n}\n},\n\"react-devtools-core\": {\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+ \"version\": \"3.0.0\",\n+ \"resolved\": \"https://registry.npmjs.org/react-devtools-core/-/react-devtools-core-3.0.0.tgz\",\n+ \"integrity\": \"sha512-24oLTwNqZJceQXfAfKRp3PwCyg2agXAQhgGwe/x6V6CvjLmnMmba4/ut9S8JTIJq7pS9fpPaRDGo5u3923RLFA==\",\n\"dev\": true,\n\"requires\": {\n\"shell-quote\": \"1.6.1\",\n\"prop-types\": \"15.6.0\"\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- \"integrity\": \"sha1-MohiQrPyMX4SHzrrmwpYXiuHm0k=\"\n- },\n- \"react-native-drawer-layout\": {\n- \"version\": \"1.3.2\",\n- \"resolved\": \"https://registry.npmjs.org/react-native-drawer-layout/-/react-native-drawer-layout-1.3.2.tgz\",\n- \"integrity\": \"sha512-fjO0scqbJUfNu2wuEpvywL7DYLXuCXJ2W/zYhWz986rdLytidbys1QGVvkaszHrb4Y7OqO96mTkgpOcP8KWevw==\",\n- \"requires\": {\n- \"react-native-dismiss-keyboard\": \"1.0.0\"\n- }\n- },\n- \"react-native-drawer-layout-polyfill\": {\n- \"version\": \"1.3.2\",\n- \"resolved\": \"https://registry.npmjs.org/react-native-drawer-layout-polyfill/-/react-native-drawer-layout-polyfill-1.3.2.tgz\",\n- \"integrity\": \"sha512-XzPhfLDJrYHru+e8+dFwhf0FtTeAp7JXPpFYezYV6P1nTeA1Tia/kDpFT+O2DWTrBKBEI8FGhZnThrroZmHIxg==\",\n- \"requires\": {\n- \"react-native-drawer-layout\": \"1.3.2\"\n- }\n- },\n\"react-native-fcm\": {\n\"version\": \"11.2.0\",\n\"resolved\": \"https://registry.npmjs.org/react-native-fcm/-/react-native-fcm-11.2.0.tgz\",\n\"resolved\": \"https://registry.npmjs.org/react-native-swipe-gestures/-/react-native-swipe-gestures-1.0.2.tgz\",\n\"integrity\": \"sha1-kU4acqlLxVsyK0YioBEDq4eSlt0=\"\n},\n- \"react-native-tab-view\": {\n- \"version\": \"0.0.74\",\n- \"resolved\": \"https://registry.npmjs.org/react-native-tab-view/-/react-native-tab-view-0.0.74.tgz\",\n- \"integrity\": \"sha512-aCrLugxt5LqdSk0pHqu/nDGZMIM3NvxVcXb464coY7ecWgem6IxQ8riO3QXPJhXZ7HaayfofBJF9w4uIWt/AoQ==\",\n- \"requires\": {\n- \"prop-types\": \"15.6.0\"\n- }\n- },\n\"react-native-vector-icons\": {\n\"version\": \"4.5.0\",\n\"resolved\": \"https://registry.npmjs.org/react-native-vector-icons/-/react-native-vector-icons-4.5.0.tgz\",\n}\n}\n},\n- \"react-navigation\": {\n- \"version\": \"git://github.com/react-navigation/react-navigation.git#d1d81d7033baa748e822a7c87dfcdc4b80429d32\",\n- \"requires\": {\n- \"babel-plugin-transform-define\": \"1.3.0\",\n- \"clamp\": \"1.0.1\",\n- \"hoist-non-react-statics\": \"2.3.1\",\n- \"path-to-regexp\": \"1.7.0\",\n- \"prop-types\": \"15.6.0\",\n- \"react-native-drawer-layout-polyfill\": \"1.3.2\",\n- \"react-native-tab-view\": \"0.0.74\"\n- }\n- },\n\"react-proxy\": {\n\"version\": \"1.1.8\",\n\"resolved\": \"https://registry.npmjs.org/react-proxy/-/react-proxy-1.1.8.tgz\",\n}\n},\n\"registry-auth-token\": {\n- \"version\": \"3.3.1\",\n- \"resolved\": \"https://registry.npmjs.org/registry-auth-token/-/registry-auth-token-3.3.1.tgz\",\n- \"integrity\": \"sha1-+w0yie4Nmtosu1KvXf5mywcNMAY=\",\n+ \"version\": \"3.3.2\",\n+ \"resolved\": \"https://registry.npmjs.org/registry-auth-token/-/registry-auth-token-3.3.2.tgz\",\n+ \"integrity\": \"sha512-JL39c60XlzCVgNrO+qq68FoNb56w/m7JYvGR2jT5iR1xBrUA3Mfx5Twk5rqTThPmQKMWydGmq8oFtDlxfrmxnQ==\",\n\"dev\": true,\n\"requires\": {\n- \"rc\": \"1.2.3\",\n+ \"rc\": \"1.2.4\",\n\"safe-buffer\": \"5.1.1\"\n}\n},\n\"integrity\": \"sha1-PU74cPc93h138M+aOBQyRE4XSUI=\",\n\"dev\": true,\n\"requires\": {\n- \"rc\": \"1.2.3\"\n+ \"rc\": \"1.2.4\"\n}\n},\n\"regjsgen\": {\n\"dev\": true,\n\"requires\": {\n\"debug\": \"2.6.9\",\n- \"es6-promise\": \"4.2.2\"\n+ \"es6-promise\": \"4.2.4\"\n}\n},\n\"supports-color\": {\n\"integrity\": \"sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o=\",\n\"dev\": true\n},\n- \"traverse\": {\n- \"version\": \"0.6.6\",\n- \"resolved\": \"https://registry.npmjs.org/traverse/-/traverse-0.6.6.tgz\",\n- \"integrity\": \"sha1-y99WD9e5r2MlAv7UD5GMFX6pcTc=\"\n- },\n\"trim-newlines\": {\n\"version\": \"1.0.0\",\n\"resolved\": \"https://registry.npmjs.org/trim-newlines/-/trim-newlines-1.0.0.tgz\",\n" }, { "change_type": "MODIFY", "old_path": "native/package.json", "new_path": "native/package.json", "diff": "\"babel-preset-react-native\": \"3.0.2\",\n\"flow-bin\": \"^0.61.0\",\n\"jest\": \"^20.0.4\",\n- \"react-devtools\": \"^2.5.0\",\n+ \"react-devtools\": \"^3.0.0\",\n\"react-test-renderer\": \"^15.6.1\"\n},\n\"jest\": {\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Upgrade react-devtools to avoid security vulnerability in old version of Electron
129,187
30.01.2018 16:02:42
18,000
52835fa4dce5ee50235da2024c8e032c0d9ecbf0
Fix bug where entry local IDs weren't being picked up from Redux
[ { "change_type": "MODIFY", "old_path": "lib/reducers/entry-reducer.js", "new_path": "lib/reducers/entry-reducer.js", "diff": "@@ -365,7 +365,7 @@ function reduceEntryInfos(\n};\n}\n} else if (action.type === rehydrateActionType) {\n- if (!action.payload || !action.payload.entryInfos) {\n+ if (!action.payload || !action.payload.entryStore) {\nreturn entryStore;\n}\nlet highestLocalIDFound = -1;\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Fix bug where entry local IDs weren't being picked up from Redux
129,187
30.01.2018 16:03:29
18,000
a0c504a31106e211101d27e90c9ca838cada4565
Update to react-navigation master We need to shim an empty `addListener` in our Redux integration root `navigation` prop
[ { "change_type": "MODIFY", "old_path": "native/app.react.js", "new_path": "native/app.react.js", "diff": "@@ -643,6 +643,9 @@ class AppWithNavigationState extends React.PureComponent<Props> {\nconst navigation: NavigationScreenProp<any> = addNavigationHelpers({\ndispatch: this.props.dispatch,\nstate: this.props.navigationState,\n+ addListener: (eventName: string, handler: Function) => {\n+ return { remove: () => {} };\n+ },\n});\nconst inAppNotificationHeight = DeviceInfo.isIPhoneX_deprecated ? 104 : 80;\nreturn (\n" }, { "change_type": "MODIFY", "old_path": "native/package-lock.json", "new_path": "native/package-lock.json", "diff": "\"babel-template\": \"6.26.0\"\n}\n},\n+ \"babel-plugin-transform-define\": {\n+ \"version\": \"1.3.0\",\n+ \"resolved\": \"https://registry.npmjs.org/babel-plugin-transform-define/-/babel-plugin-transform-define-1.3.0.tgz\",\n+ \"integrity\": \"sha1-lMX5RZyBDHOMx8UMvUSjGCnW8xk=\",\n+ \"requires\": {\n+ \"lodash\": \"4.17.4\",\n+ \"traverse\": \"0.6.6\"\n+ }\n+ },\n\"babel-plugin-transform-es2015-arrow-functions\": {\n\"version\": \"6.22.0\",\n\"resolved\": \"https://registry.npmjs.org/babel-plugin-transform-es2015-arrow-functions/-/babel-plugin-transform-es2015-arrow-functions-6.22.0.tgz\",\n\"integrity\": \"sha512-uTGIPNx/nSpBdsF6xnseRXLLtfr9VLqkz8ZqHXr3Y7b6SftyRxBGjwMtJj1OhNbmlc1wZzLNAlAcvyIiE8a6ZA==\",\n\"dev\": true\n},\n+ \"clamp\": {\n+ \"version\": \"1.0.1\",\n+ \"resolved\": \"https://registry.npmjs.org/clamp/-/clamp-1.0.1.tgz\",\n+ \"integrity\": \"sha1-ZqDmQBGBbjcZaCj9yMjBRzEshjQ=\"\n+ },\n\"cli-boxes\": {\n\"version\": \"1.0.0\",\n\"resolved\": \"https://registry.npmjs.org/cli-boxes/-/cli-boxes-1.0.0.tgz\",\n\"integrity\": \"sha1-PBrfhx6pzWyUMbbqK9dKD/BVxME=\",\n\"dev\": true\n},\n+ \"path-to-regexp\": {\n+ \"version\": \"1.7.0\",\n+ \"resolved\": \"https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-1.7.0.tgz\",\n+ \"integrity\": \"sha1-Wf3g9DW62suhA6hOnTvGTpa5k30=\",\n+ \"requires\": {\n+ \"isarray\": \"0.0.1\"\n+ }\n+ },\n\"path-type\": {\n\"version\": \"2.0.0\",\n\"resolved\": \"https://registry.npmjs.org/path-type/-/path-type-2.0.0.tgz\",\n\"prop-types\": \"15.6.0\"\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+ \"integrity\": \"sha1-MohiQrPyMX4SHzrrmwpYXiuHm0k=\"\n+ },\n+ \"react-native-drawer-layout\": {\n+ \"version\": \"1.3.2\",\n+ \"resolved\": \"https://registry.npmjs.org/react-native-drawer-layout/-/react-native-drawer-layout-1.3.2.tgz\",\n+ \"integrity\": \"sha512-fjO0scqbJUfNu2wuEpvywL7DYLXuCXJ2W/zYhWz986rdLytidbys1QGVvkaszHrb4Y7OqO96mTkgpOcP8KWevw==\",\n+ \"requires\": {\n+ \"react-native-dismiss-keyboard\": \"1.0.0\"\n+ }\n+ },\n+ \"react-native-drawer-layout-polyfill\": {\n+ \"version\": \"1.3.2\",\n+ \"resolved\": \"https://registry.npmjs.org/react-native-drawer-layout-polyfill/-/react-native-drawer-layout-polyfill-1.3.2.tgz\",\n+ \"integrity\": \"sha512-XzPhfLDJrYHru+e8+dFwhf0FtTeAp7JXPpFYezYV6P1nTeA1Tia/kDpFT+O2DWTrBKBEI8FGhZnThrroZmHIxg==\",\n+ \"requires\": {\n+ \"react-native-drawer-layout\": \"1.3.2\"\n+ }\n+ },\n\"react-native-fcm\": {\n\"version\": \"11.2.0\",\n\"resolved\": \"https://registry.npmjs.org/react-native-fcm/-/react-native-fcm-11.2.0.tgz\",\n}\n}\n},\n+ \"react-native-notifications\": {\n+ \"version\": \"git+https://git@github.com/ashoat/react-native-notifications.git#b58f93b1d77a78aa96d50e72f36884f431e4e80e\",\n+ \"requires\": {\n+ \"core-js\": \"1.2.7\",\n+ \"uuid\": \"2.0.3\"\n+ },\n+ \"dependencies\": {\n+ \"uuid\": {\n+ \"version\": \"2.0.3\",\n+ \"resolved\": \"https://registry.npmjs.org/uuid/-/uuid-2.0.3.tgz\",\n+ \"integrity\": \"sha1-Z+LoY3lyFVMN/zGOW/nc6/1Hsho=\"\n+ }\n+ }\n+ },\n\"react-native-onepassword\": {\n\"version\": \"1.0.6\",\n\"resolved\": \"https://registry.npmjs.org/react-native-onepassword/-/react-native-onepassword-1.0.6.tgz\",\n\"resolved\": \"https://registry.npmjs.org/react-native-swipe-gestures/-/react-native-swipe-gestures-1.0.2.tgz\",\n\"integrity\": \"sha1-kU4acqlLxVsyK0YioBEDq4eSlt0=\"\n},\n+ \"react-native-tab-view\": {\n+ \"version\": \"0.0.74\",\n+ \"resolved\": \"https://registry.npmjs.org/react-native-tab-view/-/react-native-tab-view-0.0.74.tgz\",\n+ \"integrity\": \"sha512-aCrLugxt5LqdSk0pHqu/nDGZMIM3NvxVcXb464coY7ecWgem6IxQ8riO3QXPJhXZ7HaayfofBJF9w4uIWt/AoQ==\",\n+ \"requires\": {\n+ \"prop-types\": \"15.6.0\"\n+ }\n+ },\n\"react-native-vector-icons\": {\n\"version\": \"4.5.0\",\n\"resolved\": \"https://registry.npmjs.org/react-native-vector-icons/-/react-native-vector-icons-4.5.0.tgz\",\n}\n}\n},\n+ \"react-navigation\": {\n+ \"version\": \"git://github.com/react-navigation/react-navigation.git#d1d81d7033baa748e822a7c87dfcdc4b80429d32\",\n+ \"requires\": {\n+ \"babel-plugin-transform-define\": \"1.3.0\",\n+ \"clamp\": \"1.0.1\",\n+ \"hoist-non-react-statics\": \"2.3.1\",\n+ \"path-to-regexp\": \"1.7.0\",\n+ \"prop-types\": \"15.6.0\",\n+ \"react-native-drawer-layout-polyfill\": \"1.3.2\",\n+ \"react-native-tab-view\": \"0.0.74\"\n+ }\n+ },\n\"react-proxy\": {\n\"version\": \"1.1.8\",\n\"resolved\": \"https://registry.npmjs.org/react-proxy/-/react-proxy-1.1.8.tgz\",\n\"integrity\": \"sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o=\",\n\"dev\": true\n},\n+ \"traverse\": {\n+ \"version\": \"0.6.6\",\n+ \"resolved\": \"https://registry.npmjs.org/traverse/-/traverse-0.6.6.tgz\",\n+ \"integrity\": \"sha1-y99WD9e5r2MlAv7UD5GMFX6pcTc=\"\n+ },\n\"trim-newlines\": {\n\"version\": \"1.0.0\",\n\"resolved\": \"https://registry.npmjs.org/trim-newlines/-/trim-newlines-1.0.0.tgz\",\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Update to react-navigation master We need to shim an empty `addListener` in our Redux integration root `navigation` prop
129,187
31.01.2018 12:13:51
18,000
a9287e43b030cd5d3d3012eab3c132b173ee1d8b
Update react-navigation libdef and remove deprecated "lazy" TabNavigator config param
[ { "change_type": "MODIFY", "old_path": "native/flow-typed/react-navigation.js", "new_path": "native/flow-typed/react-navigation.js", "diff": "@@ -262,10 +262,15 @@ declare module 'react-navigation' {\nRoute: NavigationRoute,\nOptions: {},\nProps: {}\n- > = React.ComponentType<NavigationNavigatorProps<Options, Route> & Props> & {\n- router?: void,\n- navigationOptions?: NavigationScreenConfig<Options>,\n- };\n+ > =\n+ & React.ComponentType<NavigationNavigatorProps<Options, Route> & Props>\n+ // The reason it can be a string is that React Fiber represents certain\n+ // native component types (View, Text, etc.) as strings\n+ & (\n+ | {}\n+ | { navigationOptions: NavigationScreenConfig<Options> }\n+ | string\n+ );\ndeclare export type NavigationNavigator<\nState: NavigationState,\n@@ -276,11 +281,10 @@ declare module 'react-navigation' {\nnavigationOptions?: ?NavigationScreenConfig<Options>,\n};\n- declare export type NavigationRouteConfig<T: {}> = {\n- ...$Exact<T>,\n+ declare export type NavigationRouteConfig = {\nnavigationOptions?: NavigationScreenConfig<*>,\npath?: string,\n- };\n+ } & NavigationScreenRouteConfig;\ndeclare export type NavigationScreenRouteConfig =\n| {\n@@ -295,7 +299,7 @@ declare module 'react-navigation' {\n};\ndeclare export type NavigationRouteConfigMap = {\n- [routeName: string]: NavigationRouteConfig<*>,\n+ [routeName: string]: NavigationRouteConfig,\n};\n/**\n@@ -338,32 +342,32 @@ declare module 'react-navigation' {\ngestureDirection?: 'default' | 'inverted',\n};\n- declare export type NavigationStackRouterConfig = {\n+ declare export type NavigationStackRouterConfig = {|\ninitialRouteName?: string,\ninitialRouteParams?: NavigationParams,\npaths?: NavigationPathsConfig,\nnavigationOptions?: NavigationScreenConfig<*>,\n- };\n+ |};\n- declare export type NavigationStackViewConfig = {\n+ declare export type NavigationStackViewConfig = {|\nmode?: 'card' | 'modal',\nheaderMode?: HeaderMode,\ncardStyle?: ViewStyleProp,\ntransitionConfig?: () => TransitionConfig,\nonTransitionStart?: () => void,\nonTransitionEnd?: () => void,\n- };\n+ |};\n- declare export type StackNavigatorConfig = {\n- ...$Exact<NavigationStackViewConfig>,\n- ...$Exact<NavigationStackRouterConfig>,\n- };\n+ declare export type StackNavigatorConfig = {|\n+ ...NavigationStackViewConfig,\n+ ...NavigationStackRouterConfig,\n+ |};\n/**\n* Tab Navigator\n*/\n- declare export type NavigationTabRouterConfig = {\n+ declare export type NavigationTabRouterConfig = {|\ninitialRouteName?: string,\ninitialRouteParams?: NavigationParams,\npaths?: NavigationPathsConfig,\n@@ -373,7 +377,7 @@ declare module 'react-navigation' {\n// Does the back button cause the router to switch to the initial tab\nbackBehavior?: 'none' | 'initialRoute', // defaults `initialRoute`\n- };\n+ |};\ndeclare type TabScene = {\nroute: NavigationRoute,\n@@ -445,7 +449,7 @@ declare module 'react-navigation' {\npayload: NavigationEventPayload\n) => void;\n- declare export type NavigationEventListener = {\n+ declare export type NavigationEventSubscription = {\nremove: () => void,\n};\n@@ -462,7 +466,7 @@ declare module 'react-navigation' {\naddListener: (\neventName: string,\ncallback: NavigationEventCallback\n- ) => NavigationEventListener,\n+ ) => NavigationEventSubscription,\n};\ndeclare export type NavigationNavigatorProps<O: {}, S: {}> = {\n@@ -722,7 +726,7 @@ declare module 'react-navigation' {\nstackConfig?: StackNavigatorConfig\n): NavigationContainer<*, *, *>;\n- declare type _TabViewConfig = {\n+ declare type _TabViewConfig = {|\ntabBarComponent?: React.ComponentType<*>,\ntabBarPosition?: 'top' | 'bottom',\ntabBarOptions?: {},\n@@ -733,17 +737,18 @@ declare module 'react-navigation' {\nnextTransitionProps: Object\n) => Object,\ninitialLayout?: Layout,\n- };\n- declare type _TabNavigatorConfig =\n- & { containerOptions?: void }\n- & NavigationTabRouterConfig\n- & _TabViewConfig;\n+ |};\n+ declare type _TabNavigatorConfig = {|\n+ ...NavigationTabRouterConfig,\n+ ..._TabViewConfig,\n+ containerOptions?: void,\n+ |};\ndeclare export function TabNavigator(\nrouteConfigs: NavigationRouteConfigMap,\nconfig?: _TabNavigatorConfig\n): NavigationContainer<*, *, *>;\n- declare type _DrawerViewConfig = {\n+ declare type _DrawerViewConfig = {|\ndrawerLockMode?: 'unlocked' | 'locked-closed' | 'locked-open',\ndrawerWidth?: number | (() => number),\ndrawerPosition?: 'left' | 'right',\n@@ -756,11 +761,12 @@ declare module 'react-navigation' {\nuseNativeAnimations?: boolean,\ndrawerBackgroundColor?: string,\nscreenProps?: {},\n- };\n- declare type _DrawerNavigatorConfig =\n- & { containerConfig?: void }\n- & NavigationTabRouterConfig\n- & _DrawerViewConfig;\n+ |};\n+ declare type _DrawerNavigatorConfig = $Exact<{\n+ ...NavigationTabRouterConfig,\n+ ..._DrawerViewConfig,\n+ containerConfig?: void,\n+ }>;\ndeclare export function DrawerNavigator(\nrouteConfigs: NavigationRouteConfigMap,\nconfig?: _DrawerNavigatorConfig\n" }, { "change_type": "MODIFY", "old_path": "native/navigation-setup.js", "new_path": "native/navigation-setup.js", "diff": "@@ -108,7 +108,6 @@ const AppNavigator = TabNavigator(\nMore: { screen: More },\n},\n{\n- lazy: false,\ninitialRouteName: CalendarRouteName,\n},\n);\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Update react-navigation libdef and remove deprecated "lazy" TabNavigator config param
129,187
01.02.2018 19:27:28
18,000
dd9ccb061afef71a6c627aa4a257c462687fdb69
Redux middleware from `react-navigation-redux-helpers`
[ { "change_type": "MODIFY", "old_path": "native/app.react.js", "new_path": "native/app.react.js", "diff": "@@ -36,6 +36,7 @@ import {\nDeviceInfo,\n} from 'react-native';\nimport { addNavigationHelpers } from 'react-navigation';\n+import { createReduxBoundAddListener } from 'react-navigation-redux-helpers';\nimport invariant from 'invariant';\nimport PropTypes from 'prop-types';\nimport NotificationsIOS from 'react-native-notifications';\n@@ -118,6 +119,8 @@ registerConfig({\n// app is active and the user is logged in.\nconst pingFrequency = 3 * 1000;\n+const reactNavigationAddListener = createReduxBoundAddListener(\"root\");\n+\ntype NativeDispatch = Dispatch\n& ((action: PossiblyDeprecatedNavigationAction) => boolean);\n@@ -643,9 +646,7 @@ class AppWithNavigationState extends React.PureComponent<Props> {\nconst navigation: NavigationScreenProp<any> = addNavigationHelpers({\ndispatch: this.props.dispatch,\nstate: this.props.navigationState,\n- addListener: (eventName: string, handler: Function) => {\n- return { remove: () => {} };\n- },\n+ addListener: reactNavigationAddListener,\n});\nconst inAppNotificationHeight = DeviceInfo.isIPhoneX_deprecated ? 104 : 80;\nreturn (\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-navigation/react-navigation.git#441b9ffe104f12ae74c79d472b91ec20b3a75eae\",\n+ \"version\": \"git://github.com/react-navigation/react-navigation.git#ed0306587cdfcc452b4564a5b429aa535e73c009\",\n\"requires\": {\n\"babel-plugin-transform-define\": \"1.3.0\",\n\"clamp\": \"1.0.1\",\n\"react-native-tab-view\": \"0.0.74\"\n}\n},\n+ \"react-navigation-redux-helpers\": {\n+ \"version\": \"1.0.0\",\n+ \"resolved\": \"https://registry.npmjs.org/react-navigation-redux-helpers/-/react-navigation-redux-helpers-1.0.0.tgz\",\n+ \"integrity\": \"sha512-aLsyMkvvcvMinGMTBBCejvMuC92yaY98pz6HDS5F4gp96hgsbNgVrvGLpIwD+NBY2EaoaCgCO4Ho8XHi7te3Hg==\",\n+ \"requires\": {\n+ \"invariant\": \"2.2.2\"\n+ }\n+ },\n\"react-proxy\": {\n\"version\": \"1.1.8\",\n\"resolved\": \"https://registry.npmjs.org/react-proxy/-/react-proxy-1.1.8.tgz\",\n" }, { "change_type": "MODIFY", "old_path": "native/package.json", "new_path": "native/package.json", "diff": "\"react-native-segmented-control-tab\": \"^3.2.1\",\n\"react-native-vector-icons\": \"^4.5.0\",\n\"react-navigation\": \"git://github.com/react-navigation/react-navigation.git\",\n+ \"react-navigation-redux-helpers\": \"^1.0.0\",\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": "@@ -16,6 +16,9 @@ import { composeWithDevTools } from 'redux-devtools-extension';\nimport { persistStore, persistReducer, REHYDRATE } from 'redux-persist';\nimport PropTypes from 'prop-types';\nimport { NavigationActions } from 'react-navigation';\n+import {\n+ createReactNavigationReduxMiddleware,\n+} from 'react-navigation-redux-helpers';\nimport baseReducer from 'lib/reducers/master-reducer';\nimport { newSessionID } from 'lib/selectors/session-selectors';\n@@ -249,6 +252,10 @@ const persistConfig = {\nblacklist,\ndebug: __DEV__,\n};\n+const reactNavigationMiddleware = createReactNavigationReduxMiddleware(\n+ \"root\",\n+ (state: AppState) => state.navInfo.navigationState,\n+);\nconst store = createStore(\npersistReducer(\npersistConfig,\n@@ -256,7 +263,7 @@ const store = createStore(\n),\ndefaultState,\ncomposeWithDevTools(\n- applyMiddleware(thunk),\n+ applyMiddleware(thunk, reactNavigationMiddleware),\n),\n);\nconst persistor = persistStore(store);\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Redux middleware from `react-navigation-redux-helpers`
129,187
05.02.2018 10:36:29
18,000
cb3654049e522edb30ea45148252dbab5a0411c4
No more edit_rules (You must be logged in to edit)
[ { "change_type": "MODIFY", "old_path": "jserver/src/creators/message-creator.js", "new_path": "jserver/src/creators/message-creator.js", "diff": "@@ -10,7 +10,6 @@ import {\nvisibilityRules,\nthreadPermissions,\nassertVisibilityRules,\n- assertEditRules,\n} from 'lib/types/thread-types';\nimport { rawMessageInfoFromMessageData } from 'lib/shared/message-utils';\nimport { earliestTimeConsideredCurrent } from 'lib/shared/ping-utils';\n@@ -253,7 +252,6 @@ async function sendPushNotifsForNewMessages(\n,\nstm${index}.permissions AS subthread${subthread}_permissions,\nst${index}.visibility_rules AS subthread${subthread}_visibility_rules,\n- st${index}.edit_rules AS subthread${subthread}_edit_rules,\nstm${index}.role AS subthread${subthread}_role\n`;\nsubthreadJoins.push(subthreadJoin(index, subthread));\n@@ -303,9 +301,6 @@ async function sendPushNotifsForNewMessages(\nvisibilityRules: assertVisibilityRules(\nrow[`subthread${subthread}_visibility_rules`],\n),\n- editRules: assertEditRules(\n- row[`subthread${subthread}_edit_rules`],\n- ),\n};\nconst isSubthreadMember = !!row[`subthread${subthread}_role`];\n// Only include the notification from the superthread if there is no\n" }, { "change_type": "MODIFY", "old_path": "jserver/src/fetchers/message-fetcher.js", "new_path": "jserver/src/fetchers/message-fetcher.js", "diff": "@@ -11,7 +11,6 @@ import { notifCollapseKeyForRawMessageInfo } from 'lib/shared/notif-utils';\nimport { messageType } from 'lib/types/message-types';\nimport {\nassertVisibilityRules,\n- assertEditRules,\nthreadPermissions,\nvisibilityRules,\n} from 'lib/types/thread-types';\n@@ -84,7 +83,7 @@ async function fetchCollapsableNotifs(\nu.username AS creator, m.user AS creatorID,\nstm.permissions AS subthread_permissions,\nst.visibility_rules AS subthread_visibility_rules,\n- st.edit_rules AS subthread_edit_rules, n.user, n.collapse_key\n+ n.user, n.collapse_key\nFROM notifications n\nLEFT JOIN messages m ON m.id = n.message\nLEFT JOIN threads t ON t.id = m.thread\n@@ -165,7 +164,6 @@ function rawMessageInfoFromRow(row: Object): ?RawMessageInfo {\nconst subthreadPermissionInfo = {\npermissions: row.subthread_permissions,\nvisibilityRules: assertVisibilityRules(row.subthread_visibility_rules),\n- editRules: assertEditRules(row.subthread_edit_rules),\n};\nif (!permissionHelper(subthreadPermissionInfo, threadPermissions.KNOW_OF)) {\nreturn null;\n" }, { "change_type": "MODIFY", "old_path": "jserver/src/fetchers/thread-fetcher.js", "new_path": "jserver/src/fetchers/thread-fetcher.js", "diff": "@@ -7,7 +7,6 @@ import type { Viewer } from '../session/viewer';\nimport {\nassertVisibilityRules,\n- assertEditRules,\nthreadPermissions,\n} from 'lib/types/thread-types';\n@@ -31,9 +30,9 @@ async function fetchThreadInfos(\nconst query = SQL`\nSELECT t.id, t.name, t.parent_thread_id, t.color, t.description,\n- t.edit_rules, t.visibility_rules, t.creation_time, t.default_role,\n- r.id AS role, r.name AS role_name, r.permissions AS role_permissions,\n- m.user, m.permissions, m.subscribed, m.unread, u.username\n+ t.visibility_rules, t.creation_time, t.default_role, r.id AS role,\n+ r.name AS role_name, r.permissions AS role_permissions, m.user,\n+ m.permissions, m.subscribed, m.unread, u.username\nFROM threads t\nLEFT JOIN (\nSELECT thread, id, name, permissions\n@@ -58,7 +57,6 @@ async function fetchThreadInfos(\ndescription: row.description,\nvisibilityRules: row.visibility_rules,\ncolor: row.color,\n- editRules: row.edit_rules,\ncreationTime: row.creation_time,\nparentThreadID: row.parent_thread_id,\nmembers: [],\n@@ -80,7 +78,6 @@ async function fetchThreadInfos(\n{\npermissions: row.permissions,\nvisibilityRules: assertVisibilityRules(row.visibility_rules),\n- editRules: assertEditRules(row.edit_rules),\n},\nthreadID,\n);\n@@ -122,7 +119,6 @@ async function fetchThreadInfos(\n{\npermissions: null,\nvisibilityRules: threadInfo.visibilityRules,\n- editRules: threadInfo.editRules,\n},\nthreadID,\n);\n" }, { "change_type": "MODIFY", "old_path": "jserver/src/permissions/permissions.js", "new_path": "jserver/src/permissions/permissions.js", "diff": "import type {\nThreadPermissionsBlob,\nVisibilityRules,\n- EditRules,\nThreadPermission,\n} from 'lib/types/thread-types';\nimport {\nvisibilityRules,\n- editRules,\nthreadPermissions,\n} from 'lib/types/thread-types';\n@@ -18,7 +16,6 @@ import { currentViewer } from '../session/viewer';\ntype PermissionsInfo = {\npermissions: ?ThreadPermissionsBlob,\nvisibilityRules: VisibilityRules,\n- editRules: EditRules,\n};\nfunction permissionLookup(\n@@ -56,33 +53,6 @@ function permissionHelper(\n)\n) {\nreturn true;\n- } else if (\n- permission === threadPermissions.EDIT_ENTRIES && (\n- visRules === visibilityRules.OPEN ||\n- visRules === visibilityRules.CLOSED ||\n- visRules === visibilityRules.SECRET\n- )\n- ) {\n- // The legacy visibility classes have functionality where you can play\n- // around with them on web without being logged in. This allows anybody\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- const lookup = permissionLookup(permissionsInfo.permissions, permission);\n- if (lookup) {\n- return true;\n- }\n- const canView = permissionHelper(\n- permissionsInfo,\n- threadPermissions.VISIBLE,\n- );\n- if (!canView) {\n- return false;\n- }\n- if (permissionsInfo.editRules === editRules.LOGGED_IN) {\n- return currentViewer().loggedIn;\n- }\n- return true;\n}\nreturn permissionLookup(permissionsInfo.permissions, permission);\n}\n" }, { "change_type": "MODIFY", "old_path": "lib/actions/thread-actions.js", "new_path": "lib/actions/thread-actions.js", "diff": "@@ -50,7 +50,6 @@ async function changeThreadSettings(\n'thread': newThreadInfo.id,\n'visibility_rules': newThreadInfo.visibilityRules,\n'color': newThreadInfo.color,\n- 'edit_rules': newThreadInfo.editRules,\n};\nif (newThreadPassword !== null && newThreadPassword !== undefined) {\nrequestData.new_password = newThreadPassword;\n" }, { "change_type": "MODIFY", "old_path": "lib/shared/thread-utils.js", "new_path": "lib/shared/thread-utils.js", "diff": "@@ -93,7 +93,6 @@ function createThreadInfo(\ndescription: rawThreadInfo.description,\nvisibilityRules: rawThreadInfo.visibilityRules,\ncolor: rawThreadInfo.color,\n- editRules: rawThreadInfo.editRules,\ncreationTime: rawThreadInfo.creationTime,\nparentThreadID: rawThreadInfo.parentThreadID,\nmembers: rawThreadInfo.members,\n@@ -109,7 +108,6 @@ function getRawThreadInfo(threadInfo: ThreadInfo): RawThreadInfo {\ndescription: threadInfo.description,\nvisibilityRules: threadInfo.visibilityRules,\ncolor: threadInfo.color,\n- editRules: threadInfo.editRules,\ncreationTime: threadInfo.creationTime,\nparentThreadID: threadInfo.parentThreadID,\nmembers: threadInfo.members,\n" }, { "change_type": "MODIFY", "old_path": "lib/types/thread-types.js", "new_path": "lib/types/thread-types.js", "diff": "@@ -30,24 +30,6 @@ export function assertVisibilityRules(\nreturn ourVisibilityRules;\n}\n-export const editRules = {\n- ANYBODY: 0,\n- LOGGED_IN: 1,\n-};\n-export type EditRules =\n- | typeof editRules.ANYBODY\n- | typeof editRules.LOGGED_IN;\n-export function assertEditRules(\n- ourEditRules: number,\n-): EditRules {\n- invariant(\n- ourEditRules === editRules.ANYBODY ||\n- ourEditRules === editRules.LOGGED_IN,\n- \"number is not editRules enum\",\n- );\n- return ourEditRules;\n-}\n-\n// Keep in sync with server/permissions.php\nexport const threadPermissions: { [key: string]: ThreadPermission } = {\nKNOW_OF: \"know_of\",\n@@ -162,7 +144,6 @@ export type RawThreadInfo = {|\ndescription: string,\nvisibilityRules: VisibilityRules,\ncolor: string, // hex, without \"#\" or \"0x\"\n- editRules: EditRules,\ncreationTime: number, // millisecond timestamp\nparentThreadID: ?string,\nmembers: MemberInfo[],\n@@ -177,7 +158,6 @@ export type ThreadInfo = {|\ndescription: string,\nvisibilityRules: VisibilityRules,\ncolor: string, // hex, without \"#\" or \"0x\"\n- editRules: EditRules,\ncreationTime: number, // millisecond timestamp\nparentThreadID: ?string,\nmembers: MemberInfo[],\n@@ -199,10 +179,6 @@ export const rawThreadInfoPropType = PropTypes.shape({\ndescription: PropTypes.string.isRequired,\nvisibilityRules: visibilityRulesPropType.isRequired,\ncolor: PropTypes.string.isRequired,\n- editRules: PropTypes.oneOf([\n- editRules.ANYBODY,\n- editRules.LOGGED_IN,\n- ]).isRequired,\ncreationTime: PropTypes.number.isRequired,\nparentThreadID: PropTypes.string,\nmembers: PropTypes.arrayOf(memberInfoPropType).isRequired,\n@@ -227,10 +203,6 @@ export const threadInfoPropType = PropTypes.shape({\ndescription: PropTypes.string.isRequired,\nvisibilityRules: visibilityRulesPropType.isRequired,\ncolor: PropTypes.string.isRequired,\n- editRules: PropTypes.oneOf([\n- editRules.ANYBODY,\n- editRules.LOGGED_IN,\n- ]).isRequired,\ncreationTime: PropTypes.number.isRequired,\nparentThreadID: PropTypes.string,\nmembers: PropTypes.arrayOf(memberInfoPropType).isRequired,\n" }, { "change_type": "MODIFY", "old_path": "server/edit_thread.php", "new_path": "server/edit_thread.php", "diff": "@@ -46,12 +46,6 @@ if (isset($_POST['color'])) {\n$changed_fields['color'] = $color;\n$changed_sql_fields['color'] = \"'\" . $color . \"'\";\n}\n-if (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$new_password = null;\nif (isset($_POST['new_password'])) {\n@@ -146,7 +140,6 @@ if (\n(\nisset($changed_sql_fields['parent_thread_id']) ||\nisset($changed_sql_fields['visibility_rules']) ||\n- isset($changed_sql_fields['edit_rules']) ||\nisset($changed_sql_fields['hash'])\n) && (\n!permission_helper($permission_info, PERMISSION_EDIT_PERMISSIONS) ||\n" }, { "change_type": "MODIFY", "old_path": "server/message_lib.php", "new_path": "server/message_lib.php", "diff": "@@ -126,15 +126,14 @@ function get_message_infos($thread_selection_criteria, $number_per_thread) {\nSELECT * FROM (\nSELECT x.id, x.content, x.time, x.type, x.user AS creatorID,\nu.username AS creator, x.subthread_permissions,\n- x.subthread_visibility_rules, x.subthread_edit_rules,\n+ x.subthread_visibility_rules,\n@num := if(@thread = x.thread, @num + 1, 1) AS number,\n@thread := x.thread AS threadID\nFROM (SELECT @num := 0, @thread := '') init\nJOIN (\nSELECT m.id, m.thread, m.user, m.content, m.time, m.type,\nstm.permissions AS subthread_permissions,\n- st.visibility_rules AS subthread_visibility_rules,\n- st.edit_rules AS subthread_edit_rules\n+ st.visibility_rules AS subthread_visibility_rules\nFROM messages m\nLEFT JOIN threads t ON t.id = m.thread\nLEFT JOIN memberships mm ON mm.thread = m.thread AND mm.user = {$viewer_id}\n@@ -226,8 +225,7 @@ function get_messages_since(\nSELECT m.id, m.thread AS threadID, m.content, m.time, m.type,\nu.username AS creator, m.user AS creatorID,\nstm.permissions AS subthread_permissions,\n- st.visibility_rules AS subthread_visibility_rules,\n- st.edit_rules AS subthread_edit_rules\n+ st.visibility_rules AS subthread_visibility_rules\nFROM messages m\nLEFT JOIN threads t ON t.id = m.thread\nLEFT JOIN memberships mm ON mm.thread = m.thread AND mm.user = {$viewer_id}\n@@ -306,7 +304,6 @@ function message_from_row($row) {\n$subthread_permission_info = get_info_from_permissions_row(array(\n\"permissions\" => $row['subthread_permissions'],\n\"visibility_rules\" => $row['subthread_visibility_rules'],\n- \"edit_rules\" => $row['subthread_edit_rules'],\n));\nif (!permission_helper($subthread_permission_info, PERMISSION_KNOW_OF)) {\nreturn null;\n" }, { "change_type": "MODIFY", "old_path": "server/new_thread.php", "new_path": "server/new_thread.php", "diff": "@@ -79,9 +79,6 @@ $sql_name = $name\n$description = $conn->real_escape_string($raw_description);\n$time = round(microtime(true) * 1000); // in milliseconds\n$creator = get_viewer_id();\n-$edit_rules = $vis_rules >= VISIBILITY_CLOSED\n- ? EDIT_LOGGED_IN\n- : EDIT_ANYBODY;\n$hash_sql_string =\n($vis_rules === VISIBILITY_CLOSED || $vis_rules === VISIBILITY_SECRET)\n? (\"'\" . password_hash($password, PASSWORD_BCRYPT) . \"'\")\n@@ -93,10 +90,10 @@ $parent_thread_id_sql_string = $parent_thread_id\n$default_role = $roles['members']['id'];\n$thread_insert_sql = <<<SQL\nINSERT INTO threads\n- (id, name, description, visibility_rules, hash, edit_rules, creator,\n+ (id, name, description, visibility_rules, hash, creator,\ncreation_time, color, parent_thread_id, default_role)\nVALUES\n- ($id, $sql_name, '$description', $vis_rules, $hash_sql_string, $edit_rules,\n+ ($id, $sql_name, '$description', $vis_rules, $hash_sql_string,\n$creator, $time, '$color', $parent_thread_id_sql_string, {$default_role})\nSQL;\n$conn->query($thread_insert_sql);\n@@ -174,7 +171,6 @@ foreach ($to_save as $row_to_save) {\narray(\n\"permissions\" => $row_to_save['permissions'],\n\"visibility_rules\" => $vis_rules,\n- \"edit_rules\" => $edit_rules,\n),\n$id\n),\n@@ -227,7 +223,6 @@ async_end(array(\n'description' => $raw_description,\n'visibilityRules' => $vis_rules,\n'color' => $color,\n- 'editRules' => $edit_rules,\n'creationTime' => $time,\n'parentThreadID' => $parent_thread_id !== null\n? (string)$parent_thread_id\n" }, { "change_type": "MODIFY", "old_path": "server/permissions.php", "new_path": "server/permissions.php", "diff": "@@ -78,7 +78,6 @@ function permission_lookup($blob, $permission) {\n// $info should include:\n// - permissions: ?array\n// - visibility_rules: int\n-// - edit_rules: int\nfunction permission_helper($info, $permission) {\nif (!$info) {\nreturn null;\n@@ -96,30 +95,6 @@ function permission_helper($info, $permission) {\n))\n) {\nreturn true;\n- } else if (\n- $permission === PERMISSION_EDIT_ENTRIES && (\n- $vis_rules === VISIBILITY_OPEN ||\n- $vis_rules === VISIBILITY_CLOSED ||\n- $vis_rules === VISIBILITY_SECRET\n- )\n- ) {\n- // The legacy visibility classes have functionality where you can play\n- // around with them on web without being logged in. This allows anybody\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($info['permissions'], $permission);\n- if ($lookup) {\n- return true;\n- }\n- $can_view = permission_helper($info, PERMISSION_VISIBLE);\n- if (!$can_view) {\n- return false;\n- }\n- if ($info['edit_rules'] === EDIT_LOGGED_IN) {\n- return user_logged_in();\n- }\n- return true;\n}\nreturn permission_lookup($info['permissions'], $permission);\n@@ -136,7 +111,6 @@ function get_info_from_permissions_row($row) {\nreturn array(\n\"permissions\" => $blob,\n\"visibility_rules\" => (int)$row['visibility_rules'],\n- \"edit_rules\" => (int)$row['edit_rules'],\n);\n}\n@@ -146,7 +120,7 @@ function fetch_thread_permission_info($thread) {\n$viewer_id = get_viewer_id();\n$query = <<<SQL\n-SELECT t.visibility_rules, t.edit_rules, m.permissions\n+SELECT t.visibility_rules, m.permissions\nFROM threads t\nLEFT JOIN memberships m ON m.thread = t.id AND m.user = {$viewer_id}\nWHERE t.id = {$thread}\n@@ -193,7 +167,7 @@ function check_thread_permission_for_entry($entry, $permission) {\n$viewer_id = get_viewer_id();\n$query = <<<SQL\n-SELECT m.permissions, t.visibility_rules, t.edit_rules\n+SELECT m.permissions, t.visibility_rules\nFROM entries e\nLEFT JOIN days d ON d.id = e.day\nLEFT JOIN threads t ON t.id = d.thread\n" }, { "change_type": "MODIFY", "old_path": "server/thread_lib.php", "new_path": "server/thread_lib.php", "diff": "@@ -10,8 +10,6 @@ define(\"VISIBILITY_CLOSED\", 1);\ndefine(\"VISIBILITY_SECRET\", 2);\ndefine(\"VISIBILITY_NESTED_OPEN\", 3);\ndefine(\"VISIBILITY_THREAD_SECRET\", 4);\n-define(\"EDIT_ANYBODY\", 0);\n-define(\"EDIT_LOGGED_IN\", 1);\ndefine(\"PING_INTERVAL\", 3000); // in milliseconds\n@@ -26,7 +24,7 @@ function get_thread_infos($specific_condition=\"\") {\n$where_clause = $specific_condition ? \"WHERE $specific_condition\" : \"\";\n$query = <<<SQL\n-SELECT t.id, t.name, t.parent_thread_id, t.color, t.description, t.edit_rules,\n+SELECT t.id, t.name, t.parent_thread_id, t.color, t.description,\nt.visibility_rules, t.creation_time, t.default_role, r.id AS role,\nr.name AS role_name, r.permissions AS role_permissions, m.user,\nm.permissions, m.subscribed, m.unread, u.username\n@@ -55,7 +53,6 @@ SQL;\n\"description\" => $row['description'],\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\"members\" => array(),\n@@ -119,7 +116,6 @@ SQL;\narray(\n\"permissions\" => null,\n\"visibility_rules\" => $thread_info['visibilityRules'],\n- \"edit_rules\" => $thread_info['editRules'],\n),\n$thread_id\n);\n" }, { "change_type": "MODIFY", "old_path": "web/calendar/day.react.js", "new_path": "web/calendar/day.react.js", "diff": "@@ -229,11 +229,7 @@ class Day extends React.PureComponent {\n}\ncreateNewEntry = (threadID: string) => {\n- const threadInfo = this.props.onScreenThreadInfos.find(\n- (onScreenThreadInfo) => onScreenThreadInfo.id === threadID,\n- );\n- invariant(threadInfo, \"matching ThreadInfo not found\");\n- if (threadInfo.editRules >= 1 && !this.props.loggedIn) {\n+ if (!this.props.loggedIn) {\nthis.props.setModal(\n<LogInFirstModal\ninOrderTo=\"edit this calendar\"\n" }, { "change_type": "MODIFY", "old_path": "web/calendar/entry.react.js", "new_path": "web/calendar/entry.react.js", "diff": "@@ -243,7 +243,7 @@ class Entry extends React.PureComponent {\n}\nonChange = (event: SyntheticEvent) => {\n- if (this.props.threadInfo.editRules >= 1 && !this.props.loggedIn) {\n+ if (!this.props.loggedIn) {\nthis.props.setModal(\n<LogInFirstModal\ninOrderTo=\"edit this calendar\"\n@@ -373,7 +373,7 @@ class Entry extends React.PureComponent {\nonDelete = (event: SyntheticEvent) => {\nevent.preventDefault();\n- if (this.props.threadInfo.editRules >= 1 && !this.props.loggedIn) {\n+ if (!this.props.loggedIn) {\nthis.props.setModal(\n<LogInFirstModal\ninOrderTo=\"edit this calendar\"\n@@ -405,8 +405,8 @@ class Entry extends React.PureComponent {\nasync deleteAction(serverID: ?string, focusOnNextEntry: bool) {\ninvariant(\n- this.props.threadInfo.editRules < 1 || this.props.loggedIn,\n- \"calendar should be editable if delete triggered\",\n+ this.props.loggedIn,\n+ \"user should be logged in if delete triggered\",\n);\nif (focusOnNextEntry) {\nthis.props.focusOnFirstEntryNewerThan(this.props.entryInfo.creationTime);\n" }, { "change_type": "MODIFY", "old_path": "web/modals/history/history-entry.react.js", "new_path": "web/modals/history/history-entry.react.js", "diff": "@@ -60,7 +60,7 @@ class HistoryEntry extends React.PureComponent {\nlet deleted = null;\nif (this.props.entryInfo.deleted) {\nlet restore = null;\n- if (this.props.threadInfo.editRules < 1 || this.props.loggedIn) {\n+ if (this.props.loggedIn) {\nrestore = (\n<span>\n<span className={css['restore-entry-label']}>\n" }, { "change_type": "MODIFY", "old_path": "web/modals/thread-settings-modal.react.js", "new_path": "web/modals/thread-settings-modal.react.js", "diff": "@@ -4,9 +4,7 @@ import type { ThreadInfo } from 'lib/types/thread-types';\nimport {\nthreadInfoPropType,\nvisibilityRules,\n- editRules,\nassertVisibilityRules,\n- assertEditRules,\n} from 'lib/types/thread-types';\nimport type { AppState } from '../redux-setup';\nimport type { DispatchActionPromise } from 'lib/utils/action-utils';\n@@ -284,51 +282,6 @@ class ThreadSettingsModal extends React.PureComponent {\n</div>\n</div>\n</div>\n- <div className={css['modal-radio-selector']}>\n- <div className={css['form-title']}>Who can edit?</div>\n- <div className={css['form-enum-selector']}>\n- <div className={css['form-enum-container']}>\n- <input\n- type=\"radio\"\n- name=\"edit-thread-edit-rules\"\n- id=\"edit-thread-edit-rules-anybody\"\n- value={0}\n- checked={this.state.threadInfo.editRules === 0}\n- onChange={this.onChangeEditRules}\n- disabled={this.props.inputDisabled}\n- />\n- <div className={css['form-enum-option']}>\n- <label htmlFor=\"edit-thread-edit-rules-anybody\">\n- Anybody\n- <span className={css['form-enum-description']}>\n- Anybody who can view the contents of the thread can also\n- edit them.\n- </span>\n- </label>\n- </div>\n- </div>\n- <div className={css['form-enum-container']}>\n- <input\n- type=\"radio\"\n- name=\"edit-thread-edit-rules\"\n- id=\"edit-thread-edit-rules-logged-in\"\n- value={1}\n- checked={this.state.threadInfo.editRules === 1}\n- onChange={this.onChangeEditRules}\n- disabled={this.props.inputDisabled}\n- />\n- <div className={css['form-enum-option']}>\n- <label htmlFor=\"edit-thread-edit-rules-logged-in\">\n- Logged In\n- <span className={css['form-enum-description']}>\n- Only users who are logged in can edit the contents of the\n- thread.\n- </span>\n- </label>\n- </div>\n- </div>\n- </div>\n- </div>\n</div>\n);\n} else if (this.state.currentTabType === \"delete\") {\n@@ -488,18 +441,6 @@ class ThreadSettingsModal extends React.PureComponent {\n}));\n}\n- onChangeEditRules = (event: SyntheticEvent) => {\n- const target = event.target;\n- invariant(target instanceof HTMLInputElement, \"target not input\");\n- this.setState((prevState, props) => ({\n- ...prevState,\n- threadInfo: {\n- ...prevState.threadInfo,\n- editRules: assertEditRules(parseInt(target.value)),\n- },\n- }));\n- }\n-\nonChangeNewThreadPassword = (event: SyntheticEvent) => {\nconst target = event.target;\ninvariant(target instanceof HTMLInputElement, \"target not input\");\n@@ -603,7 +544,6 @@ class ThreadSettingsModal extends React.PureComponent {\ndescription: this.state.threadInfo.description,\nvisibilityRules: this.state.threadInfo.visibilityRules,\ncolor: this.state.threadInfo.color,\n- editRules: this.state.threadInfo.editRules,\ncreationTime: this.state.threadInfo.creationTime,\nparentThreadID: this.state.threadInfo.parentThreadID,\nmembers: this.state.threadInfo.members,\n@@ -646,7 +586,6 @@ class ThreadSettingsModal extends React.PureComponent {\ndescription: this.props.threadInfo.description,\nvisibilityRules: this.props.threadInfo.visibilityRules,\ncolor: this.props.threadInfo.color,\n- editRules: this.props.threadInfo.editRules,\n},\nnewThreadPassword: \"\",\nconfirmThreadPassword: \"\",\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
No more edit_rules (You must be logged in to edit)
129,187
05.02.2018 15:36:00
18,000
3b8173422cb82b7b6c2ab782ca08e9eb33fb2eac
Allow removing anonymous members from thread
[ { "change_type": "MODIFY", "old_path": "server/remove_members.php", "new_path": "server/remove_members.php", "diff": "@@ -16,7 +16,7 @@ if (!isset($_POST['thread']) || !isset($_POST['member_ids'])) {\n));\n}\n$thread = (int)$_POST['thread'];\n-$member_ids = verify_user_ids($_POST['member_ids']);\n+$member_ids = verify_user_or_cookie_ids($_POST['member_ids']);\nif (\n!$member_ids ||\n" }, { "change_type": "MODIFY", "old_path": "server/user_lib.php", "new_path": "server/user_lib.php", "diff": "@@ -21,6 +21,26 @@ SQL;\nreturn $verified_user_ids;\n}\n+// $ids is an array of user or cookie IDs as strings\n+// returns an array of validated user or cookie IDs as ints\n+function verify_user_or_cookie_ids($ids) {\n+ global $conn;\n+\n+ $int_ids = array_map('intval', $ids);\n+ $ids_string = implode(\",\", $int_ids);\n+\n+ $query = <<<SQL\n+SELECT id FROM users WHERE id IN ({$ids_string})\n+UNION SELECT id FROM cookies WHERE id IN ({$ids_string})\n+SQL;\n+ $result = $conn->query($query);\n+ $verified_ids = array();\n+ while ($row = $result->fetch_assoc()) {\n+ $verified_ids[] = (int)$row['id'];\n+ }\n+ return $verified_ids;\n+}\n+\nfunction combine_keyed_user_info_arrays(...$user_info_arrays) {\nreturn array_values(array_merge(...$user_info_arrays));\n}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Allow removing anonymous members from thread
129,187
05.02.2018 15:36:39
18,000
9c25e363ab563eb94cb34508d856bbca23cf69fe
Fix type property of rawMessageInfoFromMessageData result Not sure how the typechecker missed this...
[ { "change_type": "MODIFY", "old_path": "lib/shared/message-utils.js", "new_path": "lib/shared/message-utils.js", "diff": "@@ -368,7 +368,7 @@ function rawMessageInfoFromMessageData(\n};\n} else if (messageData.type === messageType.CREATE_THREAD) {\nreturn {\n- type: messageType.TEXT,\n+ type: messageType.CREATE_THREAD,\nid,\nthreadID: messageData.threadID,\ncreatorID: messageData.creatorID,\n@@ -377,7 +377,7 @@ function rawMessageInfoFromMessageData(\n};\n} else if (messageData.type === messageType.ADD_MEMBERS) {\nreturn {\n- type: messageType.TEXT,\n+ type: messageType.ADD_MEMBERS,\nid,\nthreadID: messageData.threadID,\ncreatorID: messageData.creatorID,\n@@ -386,7 +386,7 @@ function rawMessageInfoFromMessageData(\n};\n} else if (messageData.type === messageType.CREATE_SUB_THREAD) {\nreturn {\n- type: messageType.TEXT,\n+ type: messageType.CREATE_SUB_THREAD,\nid,\nthreadID: messageData.threadID,\ncreatorID: messageData.creatorID,\n@@ -395,7 +395,7 @@ function rawMessageInfoFromMessageData(\n};\n} else if (messageData.type === messageType.CHANGE_SETTINGS) {\nreturn {\n- type: messageType.TEXT,\n+ type: messageType.CHANGE_SETTINGS,\nid,\nthreadID: messageData.threadID,\ncreatorID: messageData.creatorID,\n@@ -405,7 +405,7 @@ function rawMessageInfoFromMessageData(\n};\n} else if (messageData.type === messageType.REMOVE_MEMBERS) {\nreturn {\n- type: messageType.TEXT,\n+ type: messageType.REMOVE_MEMBERS,\nid,\nthreadID: messageData.threadID,\ncreatorID: messageData.creatorID,\n@@ -414,7 +414,7 @@ function rawMessageInfoFromMessageData(\n};\n} else if (messageData.type === messageType.CHANGE_ROLE) {\nreturn {\n- type: messageType.TEXT,\n+ type: messageType.CHANGE_ROLE,\nid,\nthreadID: messageData.threadID,\ncreatorID: messageData.creatorID,\n@@ -424,7 +424,7 @@ function rawMessageInfoFromMessageData(\n};\n} else if (messageData.type === messageType.LEAVE_THREAD) {\nreturn {\n- type: messageType.TEXT,\n+ type: messageType.LEAVE_THREAD,\nid,\nthreadID: messageData.threadID,\ncreatorID: messageData.creatorID,\n@@ -432,7 +432,7 @@ function rawMessageInfoFromMessageData(\n};\n} else if (messageData.type === messageType.JOIN_THREAD) {\nreturn {\n- type: messageType.TEXT,\n+ type: messageType.JOIN_THREAD,\nid,\nthreadID: messageData.threadID,\ncreatorID: messageData.creatorID,\n@@ -440,7 +440,7 @@ function rawMessageInfoFromMessageData(\n};\n} else if (messageData.type === messageType.CREATE_ENTRY) {\nreturn {\n- type: messageType.TEXT,\n+ type: messageType.CREATE_ENTRY,\nid,\nthreadID: messageData.threadID,\ncreatorID: messageData.creatorID,\n@@ -451,7 +451,7 @@ function rawMessageInfoFromMessageData(\n};\n} else if (messageData.type === messageType.EDIT_ENTRY) {\nreturn {\n- type: messageType.TEXT,\n+ type: messageType.EDIT_ENTRY,\nid,\nthreadID: messageData.threadID,\ncreatorID: messageData.creatorID,\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Fix type property of rawMessageInfoFromMessageData result Not sure how the typechecker missed this...
129,187
06.02.2018 11:21:59
18,000
acad7405f353fbd9945c22b6e1e58dd41be15b38
Move thread modals into new directory
[ { "change_type": "MODIFY", "old_path": "web/modals/account/log-in-first-modal.react.js", "new_path": "web/modals/account/log-in-first-modal.react.js", "diff": "// @flow\n-import type { AppState } from '../../redux-setup';\n-\nimport * as React from 'react';\nimport PropTypes from 'prop-types';\n" }, { "change_type": "RENAME", "old_path": "web/modals/color-picker.react.js", "new_path": "web/modals/threads/color-picker.react.js", "diff": "@@ -4,7 +4,7 @@ import * as React from 'react';\nimport { ChromePicker } from 'react-color';\nimport PropTypes from 'prop-types';\n-import css from '../style.css';\n+import css from '../../style.css';\ntype Props = {\nid: string,\n" }, { "change_type": "RENAME", "old_path": "web/modals/new-thread-modal.react.js", "new_path": "web/modals/threads/new-thread-modal.react.js", "diff": "@@ -5,7 +5,7 @@ import {\nvisibilityRules,\nassertVisibilityRules,\n} from 'lib/types/thread-types';\n-import type { AppState } from '../redux-setup';\n+import type { AppState } from '../../redux-setup';\nimport type { DispatchActionPromise } from 'lib/utils/action-utils';\nimport type { NewThreadResult } from 'lib/actions/thread-actions';\n@@ -24,8 +24,8 @@ import {\n} from 'lib/actions/thread-actions';\nimport { createLoadingStatusSelector } from 'lib/selectors/loading-selectors';\n-import css from '../style.css';\n-import Modal from './modal.react';\n+import css from '../../style.css';\n+import Modal from '../modal.react';\nimport ColorPicker from './color-picker.react';\ntype Props = {\n" }, { "change_type": "RENAME", "old_path": "web/modals/thread-settings-modal.react.js", "new_path": "web/modals/threads/thread-settings-modal.react.js", "diff": "@@ -6,7 +6,7 @@ import {\nvisibilityRules,\nassertVisibilityRules,\n} from 'lib/types/thread-types';\n-import type { AppState } from '../redux-setup';\n+import type { AppState } from '../../redux-setup';\nimport type { DispatchActionPromise } from 'lib/utils/action-utils';\nimport * as React from 'react';\n@@ -27,8 +27,8 @@ import {\n} from 'lib/actions/thread-actions';\nimport { createLoadingStatusSelector } from 'lib/selectors/loading-selectors';\n-import css from '../style.css';\n-import Modal from './modal.react';\n+import css from '../../style.css';\n+import Modal from '../modal.react';\nimport ColorPicker from './color-picker.react';\ntype TabType = \"general\" | \"privacy\" | \"delete\";\n" }, { "change_type": "MODIFY", "old_path": "web/typeahead/typeahead-action-option.react.js", "new_path": "web/typeahead/typeahead-action-option.react.js", "diff": "@@ -8,7 +8,7 @@ import { connect } from 'react-redux';\nimport PropTypes from 'prop-types';\nimport css from '../style.css';\n-import NewThreadModal from '../modals/new-thread-modal.react';\n+import NewThreadModal from '../modals/threads/new-thread-modal.react';\nimport LogInFirstModal from '../modals/account/log-in-first-modal.react';\nimport { monthURL } from '../url-utils';\nimport history from '../router-history';\n" }, { "change_type": "MODIFY", "old_path": "web/typeahead/typeahead-option-buttons.react.js", "new_path": "web/typeahead/typeahead-option-buttons.react.js", "diff": "@@ -45,7 +45,7 @@ import { visibilityRules } from 'lib/types/thread-types';\nimport css from '../style.css';\nimport LoadingIndicator from '../loading-indicator.react';\n-import ThreadSettingsModal from '../modals/thread-settings-modal.react';\n+import ThreadSettingsModal from '../modals/threads/thread-settings-modal.react';\ntype Props = {\nthreadInfo: ThreadInfo,\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Move thread modals into new directory
129,187
06.02.2018 11:43:02
18,000
6be8d89ef4afd2b2e6646147186fb3c206a0e1fe
Add linklocal to install step Unlike `npm`, `yarn` is overwriting any symlinked local deps. We can call `linklocal` after install to fix this.
[ { "change_type": "MODIFY", "old_path": "jserver/package.json", "new_path": "jserver/package.json", "diff": "\"description\": \"\",\n\"main\": \"dist/app\",\n\"scripts\": {\n+ \"install\": \"linklocal\",\n\"babel\": \"babel src/ --out-dir dist/ --ignore 'lib/flow-typed','lib/node_modules','lib/package.json','lib/package-lock.json' --copy-files\",\n\"prod\": \"node --experimental-modules --loader ./loader.mjs dist/app\",\n\"dev\": \"concurrently \\\"npm run babel -- --watch\\\" \\\"nodemon -e js,json --watch dist --experimental-modules --loader ./loader.mjs dist/app\\\"\"\n\"concurrently\": \"^3.5.1\",\n\"flow-bin\": \"^0.64.0\",\n\"flow-typed\": \"^2.2.3\",\n- \"nodemon\": \"^1.14.3\"\n+ \"nodemon\": \"^1.14.3\",\n+ \"linklocal\": \"^2.8.1\"\n},\n\"dependencies\": {\n\"apn\": \"^2.2.0\",\n" }, { "change_type": "MODIFY", "old_path": "jserver/yarn.lock", "new_path": "jserver/yarn.lock", "diff": "@@ -2502,6 +2502,16 @@ lcid@^1.0.0:\ntokenize-text \"^1.1.3\"\nwhatwg-fetch \"^2.0.3\"\n+linklocal@^2.8.1:\n+ version \"2.8.1\"\n+ resolved \"https://registry.yarnpkg.com/linklocal/-/linklocal-2.8.1.tgz#3db5a1767afaa127772bdc7a80cbae460dfa30a5\"\n+ dependencies:\n+ commander \"^2.11.0\"\n+ debug \"^2.6.8\"\n+ map-limit \"0.0.1\"\n+ mkdirp \"^0.5.1\"\n+ rimraf \"^2.6.1\"\n+\nload-json-file@^1.0.0:\nversion \"1.1.0\"\nresolved \"https://registry.yarnpkg.com/load-json-file/-/load-json-file-1.1.0.tgz#956905708d58b4bab4c2261b04f59f31c99374c0\"\n@@ -2603,6 +2613,12 @@ map-cache@^0.2.2:\nversion \"0.2.2\"\nresolved \"https://registry.yarnpkg.com/map-cache/-/map-cache-0.2.2.tgz#c32abd0bd6525d9b051645bb4f26ac5dc98a0dbf\"\n+map-limit@0.0.1:\n+ version \"0.0.1\"\n+ resolved \"https://registry.yarnpkg.com/map-limit/-/map-limit-0.0.1.tgz#eb7961031c0f0e8d001bf2d56fab685d58822f38\"\n+ dependencies:\n+ once \"~1.3.0\"\n+\nmap-stream@~0.1.0:\nversion \"0.1.0\"\nresolved \"https://registry.yarnpkg.com/map-stream/-/map-stream-0.1.0.tgz#e56aa94c4c8055a16404a0674b78f215f7c8e194\"\n@@ -2931,6 +2947,12 @@ once@^1.3.0, once@^1.3.1, once@^1.3.3, once@^1.4.0:\ndependencies:\nwrappy \"1\"\n+once@~1.3.0:\n+ version \"1.3.3\"\n+ resolved \"https://registry.yarnpkg.com/once/-/once-1.3.3.tgz#b2e261557ce4c314ec8304f3fa82663e4297ca20\"\n+ dependencies:\n+ wrappy \"1\"\n+\noptjs@~3.2.2:\nversion \"3.2.2\"\nresolved \"https://registry.yarnpkg.com/optjs/-/optjs-3.2.2.tgz#69a6ce89c442a44403141ad2f9b370bd5bb6f4ee\"\n" }, { "change_type": "MODIFY", "old_path": "native/package.json", "new_path": "native/package.json", "diff": "\"version\": \"0.0.1\",\n\"private\": true,\n\"scripts\": {\n+ \"install\": \"linklocal\",\n\"start\": \"node node_modules/react-native/local-cli/cli.js start\",\n\"test\": \"jest\",\n\"devtools\": \"react-devtools\",\n\"flow-bin\": \"^0.61.0\",\n\"jest\": \"^20.0.4\",\n\"react-devtools\": \"^3.0.0\",\n- \"react-test-renderer\": \"^15.6.1\"\n+ \"react-test-renderer\": \"^15.6.1\",\n+ \"linklocal\": \"^2.8.1\"\n},\n\"jest\": {\n\"preset\": \"react-native\"\n" }, { "change_type": "MODIFY", "old_path": "native/yarn.lock", "new_path": "native/yarn.lock", "diff": "@@ -1213,7 +1213,7 @@ combined-stream@^1.0.5, combined-stream@~1.0.5:\ndependencies:\ndelayed-stream \"~1.0.0\"\n-commander@^2.9.0:\n+commander@^2.11.0, commander@^2.9.0:\nversion \"2.14.0\"\nresolved \"https://registry.yarnpkg.com/commander/-/commander-2.14.0.tgz#7b25325963e6aace20d3a9285b09379b0c2208b5\"\n@@ -2929,6 +2929,16 @@ levn@~0.3.0:\ntokenize-text \"^1.1.3\"\nwhatwg-fetch \"^2.0.3\"\n+linklocal@^2.8.1:\n+ version \"2.8.1\"\n+ resolved \"https://registry.yarnpkg.com/linklocal/-/linklocal-2.8.1.tgz#3db5a1767afaa127772bdc7a80cbae460dfa30a5\"\n+ dependencies:\n+ commander \"^2.11.0\"\n+ debug \"^2.6.8\"\n+ map-limit \"0.0.1\"\n+ mkdirp \"^0.5.1\"\n+ rimraf \"^2.6.1\"\n+\nload-json-file@^1.0.0:\nversion \"1.1.0\"\nresolved \"https://registry.yarnpkg.com/load-json-file/-/load-json-file-1.1.0.tgz#956905708d58b4bab4c2261b04f59f31c99374c0\"\n@@ -3110,6 +3120,12 @@ makeerror@1.0.x:\ndependencies:\ntmpl \"1.0.x\"\n+map-limit@0.0.1:\n+ version \"0.0.1\"\n+ resolved \"https://registry.yarnpkg.com/map-limit/-/map-limit-0.0.1.tgz#eb7961031c0f0e8d001bf2d56fab685d58822f38\"\n+ dependencies:\n+ once \"~1.3.0\"\n+\nmap-obj@^1.0.0, map-obj@^1.0.1:\nversion \"1.0.1\"\nresolved \"https://registry.yarnpkg.com/map-obj/-/map-obj-1.0.1.tgz#d933ceb9205d82bdcf4886f6742bdc2b4dea146d\"\n@@ -3509,6 +3525,12 @@ once@^1.3.0, once@^1.3.3, once@^1.4.0:\ndependencies:\nwrappy \"1\"\n+once@~1.3.0:\n+ version \"1.3.3\"\n+ resolved \"https://registry.yarnpkg.com/once/-/once-1.3.3.tgz#b2e261557ce4c314ec8304f3fa82663e4297ca20\"\n+ dependencies:\n+ wrappy \"1\"\n+\nonetime@^2.0.0:\nversion \"2.0.1\"\nresolved \"https://registry.yarnpkg.com/onetime/-/onetime-2.0.1.tgz#067428230fd67443b2794b22bba528b6867962d4\"\n" }, { "change_type": "MODIFY", "old_path": "web/package.json", "new_path": "web/package.json", "diff": "\"style-loader\": \"^0.18.2\",\n\"uglifyjs-webpack-plugin\": \"^0.4.6\",\n\"webpack\": \"^3.0.0\",\n- \"webpack-dev-server\": \"^2.5.0\"\n+ \"webpack-dev-server\": \"^2.5.0\",\n+ \"linklocal\": \"^2.8.1\"\n},\n\"scripts\": {\n+ \"install\": \"linklocal\",\n\"dev\": \"webpack --env dev --progress && webpack-dev-server\",\n\"prod\": \"webpack --env prod --progress\",\n\"flow\": \"flow; test $? -eq 0 -o $? -eq 2\"\n" }, { "change_type": "MODIFY", "old_path": "web/yarn.lock", "new_path": "web/yarn.lock", "diff": "@@ -1280,6 +1280,10 @@ combined-stream@^1.0.5, combined-stream@~1.0.5:\ndependencies:\ndelayed-stream \"~1.0.0\"\n+commander@^2.11.0:\n+ version \"2.14.0\"\n+ resolved \"https://registry.yarnpkg.com/commander/-/commander-2.14.0.tgz#7b25325963e6aace20d3a9285b09379b0c2208b5\"\n+\ncommondir@^1.0.1:\nversion \"1.0.1\"\nresolved \"https://registry.yarnpkg.com/commondir/-/commondir-1.0.1.tgz#ddd800da0c66127393cca5950ea968a3aaf1253b\"\n@@ -2921,6 +2925,16 @@ lcid@^1.0.0:\ntokenize-text \"^1.1.3\"\nwhatwg-fetch \"^2.0.3\"\n+linklocal@^2.8.1:\n+ version \"2.8.1\"\n+ resolved \"https://registry.yarnpkg.com/linklocal/-/linklocal-2.8.1.tgz#3db5a1767afaa127772bdc7a80cbae460dfa30a5\"\n+ dependencies:\n+ commander \"^2.11.0\"\n+ debug \"^2.6.8\"\n+ map-limit \"0.0.1\"\n+ mkdirp \"^0.5.1\"\n+ rimraf \"^2.6.1\"\n+\nload-json-file@^1.0.0:\nversion \"1.1.0\"\nresolved \"https://registry.yarnpkg.com/load-json-file/-/load-json-file-1.1.0.tgz#956905708d58b4bab4c2261b04f59f31c99374c0\"\n@@ -3025,6 +3039,12 @@ map-cache@^0.2.2:\nversion \"0.2.2\"\nresolved \"https://registry.yarnpkg.com/map-cache/-/map-cache-0.2.2.tgz#c32abd0bd6525d9b051645bb4f26ac5dc98a0dbf\"\n+map-limit@0.0.1:\n+ version \"0.0.1\"\n+ resolved \"https://registry.yarnpkg.com/map-limit/-/map-limit-0.0.1.tgz#eb7961031c0f0e8d001bf2d56fab685d58822f38\"\n+ dependencies:\n+ once \"~1.3.0\"\n+\nmap-obj@^1.0.0, map-obj@^1.0.1:\nversion \"1.0.1\"\nresolved \"https://registry.yarnpkg.com/map-obj/-/map-obj-1.0.1.tgz#d933ceb9205d82bdcf4886f6742bdc2b4dea146d\"\n@@ -3411,6 +3431,12 @@ once@^1.3.0, once@^1.3.3:\ndependencies:\nwrappy \"1\"\n+once@~1.3.0:\n+ version \"1.3.3\"\n+ resolved \"https://registry.yarnpkg.com/once/-/once-1.3.3.tgz#b2e261557ce4c314ec8304f3fa82663e4297ca20\"\n+ dependencies:\n+ wrappy \"1\"\n+\nopn@^5.1.0:\nversion \"5.2.0\"\nresolved \"https://registry.yarnpkg.com/opn/-/opn-5.2.0.tgz#71fdf934d6827d676cecbea1531f95d354641225\"\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Add linklocal to install step Unlike `npm`, `yarn` is overwriting any symlinked local deps. We can call `linklocal` after install to fix this.
129,187
06.02.2018 11:47:29
18,000
178d557c290e756889e0fe92f21db4357e02f2e8
Save web dev build on change so that if I refresh the page I still get the latest
[ { "change_type": "MODIFY", "old_path": ".gitignore", "new_path": ".gitignore", "diff": "@@ -6,6 +6,7 @@ lib/node_modules\nweb/node_modules/*\n!web/node_modules/lib\nweb/dist/dev.build.js\n+web/dist/hot\njserver/dist\njserver/node_modules/*\n!jserver/node_modules/lib\n" }, { "change_type": "MODIFY", "old_path": "web/package.json", "new_path": "web/package.json", "diff": "\"uglifyjs-webpack-plugin\": \"^0.4.6\",\n\"webpack\": \"^3.0.0\",\n\"webpack-dev-server\": \"^2.5.0\",\n- \"linklocal\": \"^2.8.1\"\n+ \"linklocal\": \"^2.8.1\",\n+ \"concurrently\": \"^3.5.1\"\n},\n\"scripts\": {\n\"install\": \"linklocal\",\n- \"dev\": \"webpack --env dev --progress && webpack-dev-server\",\n+ \"dev\": \"concurrently \\\"webpack --env dev --progress --watch\\\" \\\"webpack-dev-server\\\"\",\n\"prod\": \"webpack --env prod --progress\",\n\"flow\": \"flow; test $? -eq 0 -o $? -eq 2\"\n},\n" }, { "change_type": "MODIFY", "old_path": "web/yarn.lock", "new_path": "web/yarn.lock", "diff": "@@ -63,6 +63,10 @@ ansi-html@0.0.7:\nversion \"0.0.7\"\nresolved \"https://registry.yarnpkg.com/ansi-html/-/ansi-html-0.0.7.tgz#813584021962a9e9e6fd039f940d12f56ca7859e\"\n+ansi-regex@^0.2.0, ansi-regex@^0.2.1:\n+ version \"0.2.1\"\n+ resolved \"https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-0.2.1.tgz#0d8e946967a3d8143f93e24e298525fc1b2235f9\"\n+\nansi-regex@^2.0.0:\nversion \"2.1.1\"\nresolved \"https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-2.1.1.tgz#c3b33ab5ee360d86e0e628f0468ae7ef27d654df\"\n@@ -71,6 +75,10 @@ ansi-regex@^3.0.0:\nversion \"3.0.0\"\nresolved \"https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-3.0.0.tgz#ed0317c322064f79466c02966bddb605ab37d998\"\n+ansi-styles@^1.1.0:\n+ version \"1.1.0\"\n+ resolved \"https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-1.1.0.tgz#eaecbf66cd706882760b2f4691582b8f55d7a7de\"\n+\nansi-styles@^2.2.1:\nversion \"2.2.1\"\nresolved \"https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-2.2.1.tgz#b432dd3358b634cf75e1e4664368240533c1ddbe\"\n@@ -1107,6 +1115,16 @@ center-align@^0.1.1:\nalign-text \"^0.1.3\"\nlazy-cache \"^1.0.3\"\n+chalk@0.5.1:\n+ version \"0.5.1\"\n+ resolved \"https://registry.yarnpkg.com/chalk/-/chalk-0.5.1.tgz#663b3a648b68b55d04690d49167aa837858f2174\"\n+ dependencies:\n+ ansi-styles \"^1.1.0\"\n+ escape-string-regexp \"^1.0.0\"\n+ has-ansi \"^0.1.0\"\n+ strip-ansi \"^0.3.0\"\n+ supports-color \"^0.2.0\"\n+\nchalk@^1.1.3:\nversion \"1.1.3\"\nresolved \"https://registry.yarnpkg.com/chalk/-/chalk-1.1.3.tgz#a8115c55e4a702fe4d150abd3872822a7e09fc98\"\n@@ -1280,6 +1298,10 @@ combined-stream@^1.0.5, combined-stream@~1.0.5:\ndependencies:\ndelayed-stream \"~1.0.0\"\n+commander@2.6.0:\n+ version \"2.6.0\"\n+ resolved \"https://registry.yarnpkg.com/commander/-/commander-2.6.0.tgz#9df7e52fb2a0cb0fb89058ee80c3104225f37e1d\"\n+\ncommander@^2.11.0:\nversion \"2.14.0\"\nresolved \"https://registry.yarnpkg.com/commander/-/commander-2.14.0.tgz#7b25325963e6aace20d3a9285b09379b0c2208b5\"\n@@ -1314,6 +1336,19 @@ concat-map@0.0.1:\nversion \"0.0.1\"\nresolved \"https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b\"\n+concurrently@^3.5.1:\n+ version \"3.5.1\"\n+ resolved \"https://registry.yarnpkg.com/concurrently/-/concurrently-3.5.1.tgz#ee8b60018bbe86b02df13e5249453c6ececd2521\"\n+ dependencies:\n+ chalk \"0.5.1\"\n+ commander \"2.6.0\"\n+ date-fns \"^1.23.0\"\n+ lodash \"^4.5.1\"\n+ rx \"2.3.24\"\n+ spawn-command \"^0.0.2-1\"\n+ supports-color \"^3.2.3\"\n+ tree-kill \"^1.1.0\"\n+\nconnect-history-api-fallback@^1.3.0:\nversion \"1.5.0\"\nresolved \"https://registry.yarnpkg.com/connect-history-api-fallback/-/connect-history-api-fallback-1.5.0.tgz#b06873934bc5e344fef611a196a6faae0aee015a\"\n@@ -1522,6 +1557,10 @@ dashdash@^1.12.0:\ndependencies:\nassert-plus \"^1.0.0\"\n+date-fns@^1.23.0:\n+ version \"1.29.0\"\n+ resolved \"https://registry.yarnpkg.com/date-fns/-/date-fns-1.29.0.tgz#12e609cdcb935127311d04d33334e2960a2a54e6\"\n+\ndate-now@^0.1.4:\nversion \"0.1.4\"\nresolved \"https://registry.yarnpkg.com/date-now/-/date-now-0.1.4.tgz#eaf439fd4d4848ad74e5cc7dbef200672b9e345b\"\n@@ -1807,7 +1846,7 @@ escape-html@~1.0.3:\nversion \"1.0.3\"\nresolved \"https://registry.yarnpkg.com/escape-html/-/escape-html-1.0.3.tgz#0258eae4d3d0c0974de1c169188ef0051d1d1988\"\n-escape-string-regexp@^1.0.2, escape-string-regexp@^1.0.5:\n+escape-string-regexp@^1.0.0, escape-string-regexp@^1.0.2, escape-string-regexp@^1.0.5:\nversion \"1.0.5\"\nresolved \"https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4\"\n@@ -2273,6 +2312,12 @@ har-validator@~4.2.1:\najv \"^4.9.1\"\nhar-schema \"^1.0.5\"\n+has-ansi@^0.1.0:\n+ version \"0.1.0\"\n+ resolved \"https://registry.yarnpkg.com/has-ansi/-/has-ansi-0.1.0.tgz#84f265aae8c0e6a88a12d7022894b7568894c62e\"\n+ dependencies:\n+ ansi-regex \"^0.2.0\"\n+\nhas-ansi@^2.0.0:\nversion \"2.0.0\"\nresolved \"https://registry.yarnpkg.com/has-ansi/-/has-ansi-2.0.0.tgz#34f5049ce1ecdf2b0649af3ef24e45ed35416d91\"\n@@ -2993,7 +3038,7 @@ lodash@^3.2.0:\nversion \"3.10.1\"\nresolved \"https://registry.yarnpkg.com/lodash/-/lodash-3.10.1.tgz#5bf45e8e49ba4189e17d482789dfd15bd140b7b6\"\n-lodash@^4.0.1, lodash@^4.14.0, lodash@^4.17.2, lodash@^4.17.4, lodash@^4.17.5, lodash@^4.2.0, lodash@^4.2.1, lodash@^4.6.1:\n+lodash@^4.0.1, lodash@^4.14.0, lodash@^4.17.2, lodash@^4.17.4, lodash@^4.17.5, lodash@^4.2.0, lodash@^4.2.1, lodash@^4.5.1, lodash@^4.6.1:\nversion \"4.17.5\"\nresolved \"https://registry.yarnpkg.com/lodash/-/lodash-4.17.5.tgz#99a92d65c0272debe8c96b6057bc8fbfa3bed511\"\n@@ -4389,6 +4434,10 @@ ripemd160@^2.0.0, ripemd160@^2.0.1:\nhash-base \"^2.0.0\"\ninherits \"^2.0.1\"\n+rx@2.3.24:\n+ version \"2.3.24\"\n+ resolved \"https://registry.yarnpkg.com/rx/-/rx-2.3.24.tgz#14f950a4217d7e35daa71bbcbe58eff68ea4b2b7\"\n+\nsafe-buffer@5.1.1, safe-buffer@^5.0.1, safe-buffer@^5.1.0, safe-buffer@^5.1.1, safe-buffer@~5.1.0, safe-buffer@~5.1.1:\nversion \"5.1.1\"\nresolved \"https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.1.tgz#893312af69b2123def71f57889001671eeb2c853\"\n@@ -4630,6 +4679,10 @@ sourcemapped-stacktrace@^1.1.6:\ndependencies:\nsource-map \"0.5.6\"\n+spawn-command@^0.0.2-1:\n+ version \"0.0.2-1\"\n+ resolved \"https://registry.yarnpkg.com/spawn-command/-/spawn-command-0.0.2-1.tgz#62f5e9466981c1b796dc5929937e11c9c6921bd0\"\n+\nspdx-correct@~1.0.0:\nversion \"1.0.2\"\nresolved \"https://registry.yarnpkg.com/spdx-correct/-/spdx-correct-1.0.2.tgz#4b3073d933ff51f3912f03ac5519498a4150db40\"\n@@ -4756,6 +4809,12 @@ stringstream@~0.0.4:\nversion \"0.0.5\"\nresolved \"https://registry.yarnpkg.com/stringstream/-/stringstream-0.0.5.tgz#4e484cd4de5a0bbbee18e46307710a8a81621878\"\n+strip-ansi@^0.3.0:\n+ version \"0.3.0\"\n+ resolved \"https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-0.3.0.tgz#25f48ea22ca79187f3174a4db8759347bb126220\"\n+ dependencies:\n+ ansi-regex \"^0.2.1\"\n+\nstrip-ansi@^3.0.0, strip-ansi@^3.0.1:\nversion \"3.0.1\"\nresolved \"https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-3.0.1.tgz#6a385fb8853d952d5ff05d0e8aaf94278dc63dcf\"\n@@ -4799,6 +4858,10 @@ style-loader@^0.18.2:\nloader-utils \"^1.0.2\"\nschema-utils \"^0.3.0\"\n+supports-color@^0.2.0:\n+ version \"0.2.0\"\n+ resolved \"https://registry.yarnpkg.com/supports-color/-/supports-color-0.2.0.tgz#d92de2694eb3f67323973d7ae3d8b55b4c22190a\"\n+\nsupports-color@^2.0.0:\nversion \"2.0.0\"\nresolved \"https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7\"\n@@ -4927,6 +4990,10 @@ tough-cookie@~2.3.0:\ndependencies:\npunycode \"^1.4.1\"\n+tree-kill@^1.1.0:\n+ version \"1.2.0\"\n+ resolved \"https://registry.yarnpkg.com/tree-kill/-/tree-kill-1.2.0.tgz#5846786237b4239014f05db156b643212d4c6f36\"\n+\ntrim-newlines@^1.0.0:\nversion \"1.0.0\"\nresolved \"https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-1.0.0.tgz#5887966bb582a4503a41eb524f7d35011815a613\"\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Save web dev build on change so that if I refresh the page I still get the latest
129,187
06.02.2018 14:26:55
18,000
b550a321c5f8d03d111dbea48a434607b21aef5f
Refactor TypeaheadPane so an entry actually stays highlighted when it's frozen
[ { "change_type": "MODIFY", "old_path": "web/typeahead/typeahead.react.js", "new_path": "web/typeahead/typeahead.react.js", "diff": "@@ -38,6 +38,12 @@ import TypeaheadPane from './typeahead-pane.react';\nimport { htmlTargetFromEvent } from '../vector-utils';\nimport { UpCaret, DownCaret, MagnifyingGlass } from '../vectors.react';\n+export type TypeaheadOptionInfo =\n+ | {| type: \"thread\", threadInfo: ThreadInfo, frozen: bool |}\n+ | {| type: \"action\", navID: NavID, name: string, frozen: bool |}\n+ | {| type: \"secret\", threadID: string, frozen: bool |}\n+ | {| type: \"noResults\" |};\n+\ntype Props = {\ncurrentNavID: ?string,\nthreadInfos: {[id: string]: ThreadInfo},\n@@ -60,12 +66,6 @@ type State = {\n};\nconst emptyArray = [];\n-const noResults = [(\n- <div className={css['thread-nav-no-results']} key=\"none\">\n- No results\n- </div>\n-)];\n-const noResultsFunc = () => noResults;\nclass Typeahead extends React.PureComponent<Props, State> {\n@@ -205,55 +205,38 @@ class Typeahead extends React.PureComponent<Props, State> {\nconst active = Typeahead.isActive(this.props, this.state);\nlet dropdown = null;\nif (this.state.searchActive) {\n- let resultsPane;\n- if (this.state.searchResults.length !== 0) {\n- resultsPane = (\n+ dropdown = (\n+ <div className={css['thread-nav-dropdown']} ref={this.dropdownRef}>\n<TypeaheadPane\npaneTitle=\"Results\"\npageSize={10}\n- totalResults={this.state.searchResults.length}\n- resultsBetween={this.searchResultOptionsForPage}\n+ optionInfos={this.optionInfosForSearchResults()}\n+ renderOption={this.renderOption}\nkey=\"results\"\n/>\n- );\n- } else {\n- resultsPane = (\n- <TypeaheadPane\n- paneTitle=\"Results\"\n- pageSize={1}\n- totalResults={1}\n- resultsBetween={noResultsFunc}\n- key=\"results\"\n- />\n- );\n- }\n- dropdown = (\n- <div className={css['thread-nav-dropdown']} ref={this.dropdownRef}>\n- {resultsPane}\n</div>\n);\n} else if (active) {\nconst panes = [];\n- const haveCurrentPane =\n- this.props.sortedThreadInfos.current.length > 0 ||\n- (this.props.currentThreadID &&\n- !this.props.threadInfos[this.props.currentThreadID]);\n+ const currentOptionInfo = this.optionInfosForCurrentPane();\n+ if (currentOptionInfo.length > 0) {\npanes.push(\n<TypeaheadPane\npaneTitle=\"Current\"\npageSize={1}\n- totalResults={haveCurrentPane ? 1 : 0}\n- resultsBetween={this.resultsBetweenForCurrentPane}\n+ optionInfos={currentOptionInfo}\n+ renderOption={this.renderOption}\nkey=\"current\"\n/>\n);\n+ }\nif (!this.props.currentlyHome) {\npanes.push(\n<TypeaheadPane\npaneTitle=\"Home\"\npageSize={1}\n- totalResults={1}\n- resultsBetween={this.resultsBetweenForHomePane}\n+ optionInfos={this.optionInfosForHomePane()}\n+ renderOption={this.renderOption}\nkey=\"home\"\n/>\n);\n@@ -262,8 +245,8 @@ class Typeahead extends React.PureComponent<Props, State> {\n<TypeaheadPane\npaneTitle=\"Subscribed\"\npageSize={5}\n- totalResults={this.props.sortedThreadInfos.subscribed.length}\n- resultsBetween={this.resultsBetweenForSubscribedPane}\n+ optionInfos={this.optionInfosForSubscribedPane()}\n+ renderOption={this.renderOption}\nkey=\"subscribed\"\n/>\n);\n@@ -271,8 +254,8 @@ class Typeahead extends React.PureComponent<Props, State> {\n<TypeaheadPane\npaneTitle=\"Recommended\"\npageSize={this.state.recommendedThreads.length}\n- totalResults={this.state.recommendedThreads.length}\n- resultsBetween={this.resultsBetweenForRecommendedPane}\n+ optionInfos={this.optionInfosForRecommendedPane()}\n+ renderOption={this.renderOption}\nkey=\"recommended\"\n/>\n);\n@@ -280,8 +263,8 @@ class Typeahead extends React.PureComponent<Props, State> {\n<TypeaheadPane\npaneTitle=\"Actions\"\npageSize={1}\n- totalResults={1}\n- resultsBetween={this.resultsBetweenForActionsPane}\n+ optionInfos={this.optionInfosForActionsPane()}\n+ renderOption={this.renderOption}\nkey=\"actions\"\n/>\n);\n@@ -389,54 +372,56 @@ class Typeahead extends React.PureComponent<Props, State> {\nthis.setState({ typeaheadFocused: true });\n}\n- buildOption(navID: string) {\n- const threadInfo = this.props.threadInfos[navID];\n- if (threadInfo !== undefined) {\n- return this.buildThreadOption(threadInfo);\n- } else if (navID === \"home\") {\n- return this.buildActionOption(\"home\", TypeaheadText.homeText);\n- } else if (navID === \"new\") {\n- return this.buildActionOption(\"new\", TypeaheadText.newText);\n- } else if (navID === this.props.currentThreadID) {\n- return this.buildSecretOption(navID);\n- } else {\n- invariant(false, \"invalid navID passed to buildOption\");\n+ renderOption = (optionInfo: TypeaheadOptionInfo) => {\n+ if (optionInfo.type === \"thread\") {\n+ return this.renderThreadOption(optionInfo.threadInfo, optionInfo.frozen);\n+ } else if (optionInfo.type === \"action\") {\n+ return this.renderActionOption(\n+ optionInfo.navID,\n+ optionInfo.name,\n+ optionInfo.frozen,\n+ );\n+ } else if (optionInfo.type === \"secret\") {\n+ return this.renderSecretOption(optionInfo.threadID, optionInfo.frozen);\n+ } else if (optionInfo.type === \"noResults\") {\n+ return (\n+ <div className={css['thread-nav-no-results']} key=\"none\">\n+ No results\n+ </div>\n+ );\n}\n}\n- buildActionOption(navID: NavID, name: string) {\n- const onTransition = () => {\n+ blur = () => {\ninvariant(this.input, \"ref should be set\");\nthis.input.blur();\n}\n+\n+ renderActionOption(navID: NavID, name: string, frozen: bool) {\nreturn (\n<TypeaheadActionOption\nnavID={navID}\nname={name}\nfreezeTypeahead={this.freeze}\nunfreezeTypeahead={this.unfreeze}\n- onTransition={onTransition}\n+ onTransition={this.blur}\nsetModal={this.props.setModal}\nclearModal={this.props.clearModal}\n- frozen={!!this.state.frozenNavIDs[navID]}\n+ frozen={frozen}\nkey={navID}\n/>\n);\n}\n- buildThreadOption(threadInfo: ThreadInfo) {\n- const onTransition = () => {\n- invariant(this.input, \"ref should be set\");\n- this.input.blur();\n- }\n+ renderThreadOption(threadInfo: ThreadInfo, frozen: bool) {\nreturn (\n<TypeaheadThreadOption\nthreadInfo={threadInfo}\nfreezeTypeahead={this.freeze}\nunfreezeTypeahead={this.unfreeze}\nfocusTypeahead={this.focusIfNotFocused}\n- onTransition={onTransition}\n- frozen={!!this.state.frozenNavIDs[threadInfo.id]}\n+ onTransition={this.blur}\n+ frozen={frozen}\nsetModal={this.props.setModal}\nclearModal={this.props.clearModal}\ntypeaheadFocused={this.state.typeaheadFocused}\n@@ -445,19 +430,15 @@ class Typeahead extends React.PureComponent<Props, State> {\n);\n}\n- buildSecretOption(secretThreadID: string) {\n- const onTransition = () => {\n- invariant(this.input, \"ref should be set\");\n- this.input.blur();\n- }\n+ renderSecretOption(secretThreadID: string, frozen: bool) {\nreturn (\n<TypeaheadThreadOption\nsecretThreadID={secretThreadID}\nfreezeTypeahead={this.freeze}\nunfreezeTypeahead={this.unfreeze}\nfocusTypeahead={this.focusIfNotFocused}\n- onTransition={onTransition}\n- frozen={!!this.state.frozenNavIDs[secretThreadID]}\n+ onTransition={this.blur}\n+ frozen={frozen}\nsetModal={this.props.setModal}\nclearModal={this.props.clearModal}\ntypeaheadFocused={this.state.typeaheadFocused}\n@@ -472,33 +453,83 @@ class Typeahead extends React.PureComponent<Props, State> {\n!_isEmpty(state.frozenNavIDs);\n}\n- resultsBetweenForCurrentPane = () => {\n+ threadOptionInfo = (threadInfo: ThreadInfo) => {\n+ return {\n+ type: \"thread\",\n+ threadInfo,\n+ frozen: !!this.state.frozenNavIDs[threadInfo.id],\n+ };\n+ }\n+\n+ actionOptionInfo = (navID: NavID, name: string) => {\n+ return {\n+ type: \"action\",\n+ navID,\n+ name,\n+ frozen: !!this.state.frozenNavIDs[navID],\n+ };\n+ }\n+\n+ secretOptionInfo = (threadID: string) => {\n+ return {\n+ type: \"secret\",\n+ threadID,\n+ frozen: !!this.state.frozenNavIDs[threadID],\n+ };\n+ }\n+\n+ optionInfosForCurrentPane = () => {\nif (this.props.sortedThreadInfos.current.length > 0) {\n- return this.props.sortedThreadInfos.current.map(\n- (threadInfo) => this.buildThreadOption(threadInfo),\n- );\n+ return this.props.sortedThreadInfos.current.map(this.threadOptionInfo);\n} else if (\nthis.props.currentThreadID &&\n!this.props.threadInfos[this.props.currentThreadID]\n) {\n- return [\n- this.buildSecretOption(this.props.currentThreadID)\n- ];\n+ return [ this.secretOptionInfo(this.props.currentThreadID) ];\n}\nreturn emptyArray;\n}\n- resultsBetweenForHomePane = () => {\n- return [ this.buildActionOption(\"home\", TypeaheadText.homeText) ];\n+ optionInfosForHomePane = () => {\n+ return [ this.actionOptionInfo(\"home\", TypeaheadText.homeText) ];\n+ }\n+\n+ optionInfosForSubscribedPane = () => {\n+ return this.props.sortedThreadInfos.subscribed.map(\n+ threadInfo => ({\n+ type: \"thread\",\n+ threadInfo,\n+ frozen: !!this.state.frozenNavIDs[threadInfo.id],\n+ }),\n+ );\n}\n- resultsBetweenForRecommendedPane = () => {\n- return this.state.recommendedThreads\n- .map((threadInfo) => this.buildThreadOption(threadInfo));\n+ optionInfosForRecommendedPane = () => {\n+ return this.state.recommendedThreads.map(this.threadOptionInfo);\n}\n- resultsBetweenForActionsPane = () => {\n- return [ this.buildActionOption(\"new\", TypeaheadText.newText) ];\n+ optionInfosForActionsPane = () => {\n+ return [ this.actionOptionInfo(\"new\", TypeaheadText.newText) ];\n+ }\n+\n+ optionInfosForSearchResults = () => {\n+ if (this.state.searchResults.length !== 0) {\n+ return [{ type: \"noResults\" }];\n+ }\n+ return this.state.searchResults.map((navID) => {\n+ const threadInfo = this.props.threadInfos[navID];\n+ if (threadInfo !== undefined) {\n+ return this.threadOptionInfo(threadInfo);\n+ } else if (navID === \"home\") {\n+ return this.actionOptionInfo(\"home\", TypeaheadText.homeText);\n+ } else if (navID === \"new\") {\n+ return this.actionOptionInfo(\"new\", TypeaheadText.newText);\n+ } else if (navID === this.props.currentThreadID) {\n+ return this.secretOptionInfo(navID);\n+ } else {\n+ invariant(false, \"invalid navID returned as a search result\");\n+ }\n+ });\n}\n// This method makes sure that this.state.typeaheadFocused iff typeahead input\n@@ -585,16 +616,6 @@ class Typeahead extends React.PureComponent<Props, State> {\ninput.select();\n}\n- searchResultOptionsForPage = (start: number, end: number) => {\n- return this.state.searchResults.slice(start, end)\n- .map((navID) => this.buildOption(navID));\n- }\n-\n- resultsBetweenForSubscribedPane = (start: number, end: number) => {\n- return this.props.sortedThreadInfos.subscribed.slice(start, end)\n- .map((threadInfo) => this.buildThreadOption(threadInfo));\n- }\n-\nstatic getRecommendationSize(props: Props) {\nif (props.currentlyHome && props.currentNavID === null) {\nreturn Typeahead.homeNullStateRecommendationSize;\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Refactor TypeaheadPane so an entry actually stays highlighted when it's frozen
129,187
06.02.2018 18:51:09
18,000
a5173b0a23f4ba176e86697874f80b5b1b14117a
A couple of missing pieces in the last commits
[ { "change_type": "MODIFY", "old_path": "jserver/.flowconfig", "new_path": "jserver/.flowconfig", "diff": "[ignore]\n<PROJECT_ROOT>/dist\n<PROJECT_ROOT>/node_modules/google-gax/node_modules/grpc/node_modules/protobufjs/src/bower.json\n-<PROJECT_ROOT>/node_modules/protobufjs/src/bower.json\n+.*/node_modules/protobufjs/src/bower.json\n[include]\n../lib\n" }, { "change_type": "MODIFY", "old_path": "jserver/src/fetchers/thread-fetcher.js", "new_path": "jserver/src/fetchers/thread-fetcher.js", "diff": "@@ -103,7 +103,7 @@ async function fetchThreadInfos(\nthreadInfos[threadID].currentUser = {\nrole: member.role,\npermissions: member.permissions,\n- subscription: member.subscription,\n+ subscription: row.subscription,\nunread: member.role ? row.unread : null,\n};\n}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
A couple of missing pieces in the last commits
129,187
07.02.2018 00:12:13
18,000
ad9b2f46693631561f163d5a3039aa5b55f94252
Backend endpoint for updating user subscription for a given thread Note: no input validation on the JS side yet
[ { "change_type": "MODIFY", "old_path": "jserver/src/app.js", "new_path": "jserver/src/app.js", "diff": "@@ -7,10 +7,21 @@ import cookieParser from 'cookie-parser';\nimport errorHandler from './error_handler';\nimport { messageCreationResponder } from './responders/message-responders';\nimport { updateActivityResponder } from './responders/activity-responders';\n+import { userSubscriptionUpdateResponder } from './responders/user-responders';\nconst app = express();\napp.use(bodyParser.json());\napp.use(cookieParser());\n-app.post('/create_messages', errorHandler(messageCreationResponder));\n-app.post('/update_activity', errorHandler(updateActivityResponder));\n+app.post(\n+ '/create_messages',\n+ errorHandler(messageCreationResponder),\n+);\n+app.post(\n+ '/update_activity',\n+ errorHandler(updateActivityResponder),\n+);\n+app.post(\n+ '/update_user_subscription',\n+ errorHandler(userSubscriptionUpdateResponder),\n+);\napp.listen(parseInt(process.env.PORT) || 3000, 'localhost');\n" }, { "change_type": "ADD", "old_path": null, "new_path": "jserver/src/responders/user-responders.js", "diff": "+// @flow\n+\n+import type { $Response, $Request } from 'express';\n+import type { SubscriptionUpdate } from 'lib/types/subscription-types';\n+\n+import { userSubscriptionUpdater } from '../updaters/user-subscription-updater';\n+import { connect } from '../database';\n+import { setCurrentViewerFromCookie } from '../session/cookies';\n+\n+async function userSubscriptionUpdateResponder(req: $Request, res: $Response) {\n+ const subscriptionUpdate: SubscriptionUpdate = req.body;\n+\n+ const conn = await connect();\n+ await setCurrentViewerFromCookie(conn, req.cookies);\n+ const threadSubscription = await userSubscriptionUpdater(\n+ conn,\n+ subscriptionUpdate,\n+ );\n+ conn.end();\n+ if (!threadSubscription) {\n+ return { error: 'not_member' };\n+ }\n+ return { success: true, threadSubscription };\n+}\n+\n+export {\n+ userSubscriptionUpdateResponder,\n+};\n" }, { "change_type": "ADD", "old_path": null, "new_path": "jserver/src/updaters/user-subscription-updater.js", "diff": "+// @flow\n+\n+import type { Connection } from '../database';\n+import type {\n+ ThreadSubscription,\n+ SubscriptionUpdate,\n+} from 'lib/types/subscription-types';\n+\n+import { currentViewer } from '../session/viewer';\n+import { SQL } from '../database';\n+\n+async function userSubscriptionUpdater(\n+ conn: Connection,\n+ update: SubscriptionUpdate,\n+): Promise<?ThreadSubscription> {\n+ const viewer = currentViewer();\n+ const query = SQL`\n+ SELECT subscription\n+ FROM memberships\n+ WHERE user = ${viewer.id} AND thread = ${update.threadID} AND role != 0\n+ `;\n+ const [ result ] = await conn.query(query);\n+ if (result.length === 0) {\n+ return null;\n+ }\n+ const row = result[0];\n+\n+ const newSubscription = {\n+ ...row.subscription,\n+ ...update.updatedFields,\n+ };\n+ const saveQuery = SQL`\n+ UPDATE memberships\n+ SET subscription = ${JSON.stringify(newSubscription)}\n+ WHERE user = ${viewer.id} AND thread = ${update.threadID}\n+ `;\n+ await conn.query(saveQuery);\n+\n+ return newSubscription;\n+}\n+\n+export {\n+ userSubscriptionUpdater,\n+};\n" }, { "change_type": "MODIFY", "old_path": "lib/actions/ping-actions.js", "new_path": "lib/actions/ping-actions.js", "diff": "@@ -61,10 +61,10 @@ async function updateActivity(\nactivityUpdates: $ReadOnlyArray<ActivityUpdate>,\n): Promise<UpdateActivityResult> {\nconst response = await fetchJSON('activity_update.php', {\n- 'activity_updates': activityUpdates,\n+ input: activityUpdates,\n});\nreturn {\n- unfocusedToUnread: response.set_unfocused_to_unread,\n+ unfocusedToUnread: response.unfocusedToUnread,\n};\n}\n" }, { "change_type": "MODIFY", "old_path": "lib/actions/user-actions.js", "new_path": "lib/actions/user-actions.js", "diff": "@@ -11,6 +11,10 @@ import type {\nimport type { CalendarResult } from './entry-actions';\nimport type { CalendarQuery } from '../selectors/nav-selectors';\nimport type { GenericMessagesResult } from './message-actions';\n+import type {\n+ SubscriptionUpdate,\n+ ThreadSubscription,\n+} from '../types/subscription-types';\nimport { verifyField } from '../utils/verify-utils';\nimport { numberPerThread } from '../reducers/message-reducer';\n@@ -367,6 +371,21 @@ async function searchUsers(\n};\n}\n+const updateSubscriptionActionTypes = Object.freeze({\n+ started: \"UPDATE_SUBSCRIPTION_STARTED\",\n+ success: \"UPDATE_SUBSCRIPTION_SUCCESS\",\n+ failed: \"UPDATE_SUBSCRIPTION_FAILED\",\n+});\n+async function updateSubscription(\n+ fetchJSON: FetchJSON,\n+ subscriptionUpdate: SubscriptionUpdate,\n+): Promise<ThreadSubscription> {\n+ const response = await fetchJSON('update_subscription.php', {\n+ input: subscriptionUpdate,\n+ });\n+ return response.threadSubscription;\n+}\n+\nexport {\nlogOutActionTypes,\nlogOut,\n@@ -393,4 +412,6 @@ export {\nhandleVerificationCode,\nsearchUsersActionTypes,\nsearchUsers,\n+ updateSubscriptionActionTypes,\n+ updateSubscription,\n};\n" }, { "change_type": "ADD", "old_path": null, "new_path": "lib/types/subscription-types.js", "diff": "+// @flow\n+\n+export type ThreadSubscription = {|\n+ pushNotifs: bool,\n+ home: bool,\n+|};\n+\n+export type SubscriptionUpdate = {|\n+ threadID: string,\n+ updatedFields: $Shape<ThreadSubscription>,\n+|};\n" }, { "change_type": "MODIFY", "old_path": "lib/types/thread-types.js", "new_path": "lib/types/thread-types.js", "diff": "// @flow\n+import type { ThreadSubscription } from './subscription-types';\n+\nimport PropTypes from 'prop-types';\nimport invariant from 'invariant';\n@@ -117,10 +119,7 @@ export type RoleInfo = {|\nexport type ThreadCurrentUserInfo = {|\nrole: ?string,\npermissions: ThreadPermissionsBlob,\n- subscription: {|\n- pushNotifs: bool,\n- home: bool,\n- |},\n+ subscription: ThreadSubscription,\nunread: ?bool,\n|};\n" }, { "change_type": "MODIFY", "old_path": "server/activity_update.php", "new_path": "server/activity_update.php", "diff": "<?php\n-require_once('async_lib.php');\nrequire_once('call_node.php');\n-async_start();\n-\n-$activity_updates = isset($_POST['activity_updates'])\n- ? $_POST['activity_updates']\n- : array();\n-\n-// For some reason, bools get stringified\n-$unstringified_activity_updates = array();\n-foreach ($activity_updates as $activity_update) {\n- if (isset($activity_update['focus'])) {\n- $activity_update['focus'] = $activity_update['focus'] === \"true\";\n- }\n- if (isset($activity_update['closing'])) {\n- $activity_update['closing'] = $activity_update['closing'] === \"true\";\n- }\n- $unstringified_activity_updates[] = $activity_update;\n-}\n-\n-$result = call_node('update_activity', $unstringified_activity_updates);\n-\n-if (isset($result['error'])) {\n- async_end(array(\n- 'error' => 'invalid_credentials',\n- ));\n-}\n-\n-async_end(array(\n- 'success' => true,\n- 'set_unfocused_to_unread' => $result['unfocusedToUnread'],\n-));\n+proxy_to_node('update_activity');\n" }, { "change_type": "MODIFY", "old_path": "server/call_node.php", "new_path": "server/call_node.php", "diff": "<?php\nrequire_once('auth.php');\n+require_once('async_lib.php');\nfunction call_node($path, $blob) {\n$url = \"http://localhost:3000/\" . $path;\n@@ -25,3 +26,33 @@ function call_node($path, $blob) {\n$body = substr($result, $header_size);\nreturn json_decode($body, true);\n}\n+\n+function proxy_to_node($path) {\n+ async_start();\n+\n+ if (!isset($_POST['input'])) {\n+ async_end(array(\n+ 'error' => 'invalid_parameters',\n+ ));\n+ }\n+\n+ $fixed_bools = fix_bools($_POST['input']);\n+\n+ async_end(call_node($path, $fixed_bools));\n+}\n+\n+function fix_bools($input) {\n+ $result = array();\n+ foreach ($input as $key => $value) {\n+ if (is_array($value)) {\n+ $result[$key] = fix_bools($value);\n+ } else if ($value === \"true\") {\n+ $result[$key] = true;\n+ } else if ($value === \"false\") {\n+ $result[$key] = false;\n+ } else {\n+ $result[$key] = $value;\n+ }\n+ }\n+ return $result;\n+}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "server/update_subscription.php", "diff": "+<?php\n+\n+require_once('call_node.php');\n+\n+proxy_to_node('update_user_subscription');\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Backend endpoint for updating user subscription for a given thread Note: no input validation on the JS side yet
129,187
07.02.2018 22:42:48
18,000
d43bb71ac7ee22bb51d5d3fadd756f3cf955411f
Push notif setting (finally!)
[ { "change_type": "ADD", "old_path": null, "new_path": "native/chat/settings/thread-settings-push-notifs.react.js", "diff": "+// @flow\n+\n+import type { ThreadInfo } from 'lib/types/thread-types';\n+import { threadInfoPropType } from 'lib/types/thread-types';\n+import type { AppState } from '../../redux-setup';\n+import type { DispatchActionPromise } from 'lib/utils/action-utils';\n+import type {\n+ SubscriptionUpdate,\n+ ThreadSubscription,\n+} from 'lib/types/subscription-types';\n+\n+import React from 'react';\n+import { Text, StyleSheet, View, Switch } from 'react-native';\n+import PropTypes from 'prop-types';\n+import { connect } from 'react-redux';\n+\n+import { visibilityRules } from 'lib/types/thread-types';\n+import {\n+ includeDispatchActionProps,\n+ bindServerCalls,\n+} from 'lib/utils/action-utils';\n+import {\n+ updateSubscriptionActionTypes,\n+ updateSubscription,\n+} from 'lib/actions/user-actions';\n+\n+type Props = {|\n+ threadInfo: ThreadInfo,\n+ // Redux dispatch functions\n+ dispatchActionPromise: DispatchActionPromise,\n+ // async functions that hit server APIs\n+ updateSubscription: (\n+ subscriptionUpdate: SubscriptionUpdate,\n+ ) => Promise<ThreadSubscription>,\n+|};\n+type State = {|\n+ currentValue: bool,\n+|};\n+class ThreadSettingsPushNotifs extends React.PureComponent<Props, State> {\n+\n+ static propTypes = {\n+ threadInfo: threadInfoPropType.isRequired,\n+ dispatchActionPromise: PropTypes.func.isRequired,\n+ updateSubscription: PropTypes.func.isRequired,\n+ };\n+\n+ constructor(props: Props) {\n+ super(props);\n+ this.state = {\n+ currentValue: props.threadInfo.currentUser.subscription.pushNotifs,\n+ };\n+ }\n+\n+ render() {\n+ return (\n+ <View style={styles.row}>\n+ <Text style={styles.label}>Push notifs</Text>\n+ <View style={styles.currentValue}>\n+ <Switch\n+ value={this.state.currentValue}\n+ onValueChange={this.onValueChange}\n+ />\n+ </View>\n+ </View>\n+ );\n+ }\n+\n+ onValueChange = (value: bool) => {\n+ this.setState({ currentValue: value });\n+ this.props.dispatchActionPromise(\n+ updateSubscriptionActionTypes,\n+ this.props.updateSubscription({\n+ threadID: this.props.threadInfo.id,\n+ updatedFields: {\n+ pushNotifs: value,\n+ },\n+ }),\n+ );\n+ }\n+\n+}\n+\n+const styles = StyleSheet.create({\n+ row: {\n+ flexDirection: 'row',\n+ alignItems: 'center',\n+ paddingHorizontal: 24,\n+ backgroundColor: \"white\",\n+ paddingVertical: 3,\n+ },\n+ label: {\n+ fontSize: 16,\n+ width: 96,\n+ color: \"#888888\",\n+ },\n+ currentValue: {\n+ flex: 1,\n+ paddingLeft: 4,\n+ paddingRight: 0,\n+ paddingVertical: 0,\n+ margin: 0,\n+ alignItems: 'flex-end',\n+ },\n+});\n+\n+export default connect(\n+ (state: AppState) => ({\n+ cookie: state.cookie,\n+ }),\n+ includeDispatchActionProps,\n+ bindServerCalls({ updateSubscription }),\n+)(ThreadSettingsPushNotifs);\n" }, { "change_type": "MODIFY", "old_path": "native/chat/settings/thread-settings.react.js", "new_path": "native/chat/settings/thread-settings.react.js", "diff": "@@ -56,6 +56,7 @@ import ThreadSettingsColor from './thread-settings-color.react';\nimport ThreadSettingsDescription from './thread-settings-description.react';\nimport ThreadSettingsParent from './thread-settings-parent.react';\nimport ThreadSettingsVisibility from './thread-settings-visibility.react';\n+import ThreadSettingsPushNotifs from './thread-settings-push-notifs.react';\nimport ThreadSettingsLeaveThread from './thread-settings-leave-thread.react';\nconst itemPageLength = 5;\n@@ -109,6 +110,11 @@ type ChatSettingsItem =\nkey: string,\nthreadInfo: ThreadInfo,\n|}\n+ | {|\n+ itemType: \"pushNotifs\",\n+ key: string,\n+ threadInfo: ThreadInfo,\n+ |}\n| {|\nitemType: \"seeMore\",\nkey: string,\n@@ -307,6 +313,23 @@ class InnerThreadSettings extends React.PureComponent<Props, State> {\n});\n}\n+ listData.push({\n+ itemType: \"header\",\n+ key: \"subscriptionHeader\",\n+ title: \"Subscription\",\n+ categoryType: \"full\",\n+ });\n+ listData.push({\n+ itemType: \"pushNotifs\",\n+ key: \"pushNotifs\",\n+ threadInfo: this.props.threadInfo,\n+ });\n+ listData.push({\n+ itemType: \"footer\",\n+ key: \"subscriptionFooter\",\n+ categoryType: \"full\",\n+ });\n+\nlistData.push({\nitemType: \"header\",\nkey: \"privacyHeader\",\n@@ -532,6 +555,8 @@ class InnerThreadSettings extends React.PureComponent<Props, State> {\n);\n} else if (item.itemType === \"visibility\") {\nreturn <ThreadSettingsVisibility threadInfo={item.threadInfo} />;\n+ } else if (item.itemType === \"pushNotifs\") {\n+ return <ThreadSettingsPushNotifs threadInfo={item.threadInfo} />;\n} else if (item.itemType === \"seeMore\") {\nreturn <ThreadSettingsSeeMore onPress={item.onPress} />;\n} else if (item.itemType === \"childThread\") {\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Push notif setting (finally!)
129,187
08.02.2018 11:28:03
18,000
d362e782f5ac42a5b5d0393854936f2c7bc7975c
Create new type ServerThreadInfo and function fetchServerThreadInfos (Used within node server)
[ { "change_type": "MODIFY", "old_path": "jserver/src/creators/message-creator.js", "new_path": "jserver/src/creators/message-creator.js", "diff": "@@ -13,6 +13,7 @@ import {\n} from 'lib/types/thread-types';\nimport { rawMessageInfoFromMessageData } from 'lib/shared/message-utils';\nimport { earliestTimeConsideredCurrent } from 'lib/shared/ping-utils';\n+import { permissionHelper } from 'lib/permissions/thread-permissions';\nimport {\nSQL,\n@@ -22,7 +23,6 @@ import {\nmergeOrConditions,\n} from '../database';\nimport createIDs from './id-creator';\n-import { permissionHelper } from '../permissions/permissions';\nimport { sendPushNotifs } from '../push/send';\ntype ThreadRestriction = {|\n" }, { "change_type": "MODIFY", "old_path": "jserver/src/fetchers/message-fetcher.js", "new_path": "jserver/src/fetchers/message-fetcher.js", "diff": "@@ -15,9 +15,9 @@ import {\nvisibilityRules,\n} from 'lib/types/thread-types';\nimport { sortMessageInfoList } from 'lib/shared/message-utils';\n+import { permissionHelper } from 'lib/permissions/thread-permissions';\nimport { SQL, mergeOrConditions } from '../database';\n-import { permissionHelper } from '../permissions/permissions';\nexport type CollapsableNotifInfo = {|\ncollapseKey: ?string,\n" }, { "change_type": "MODIFY", "old_path": "jserver/src/fetchers/thread-fetcher.js", "new_path": "jserver/src/fetchers/thread-fetcher.js", "diff": "// @flow\nimport type { Connection } from '../database';\n-import type { RawThreadInfo } from 'lib/types/thread-types';\n+import type { RawThreadInfo, ServerThreadInfo } from 'lib/types/thread-types';\nimport type { UserInfo } from 'lib/types/user-types';\n-import type { Viewer } from '../session/viewer';\nimport {\nassertVisibilityRules,\nthreadPermissions,\n} from 'lib/types/thread-types';\n+import { getAllThreadPermissions } from 'lib/permissions/thread-permissions';\n+import { rawThreadInfoFromServerThreadInfo } from 'lib/shared/thread-utils';\nimport { SQL, SQLStatement } from '../database';\n-import {\n- permissionLookup,\n- getAllThreadPermissions,\n-} from '../permissions/permissions';\n+import { currentViewer } from '../session/viewer';\n-type FetchThreadInfosResult = {|\n- threadInfos: {[id: string]: RawThreadInfo},\n+type FetchServerThreadInfosResult = {|\n+ threadInfos: {[id: string]: ServerThreadInfo},\nuserInfos: {[id: string]: UserInfo},\n|};\n-async function fetchThreadInfos(\n+async function fetchServerThreadInfos(\nconn: Connection,\ncondition?: SQLStatement,\n- viewer: ?Viewer,\n-): Promise<FetchThreadInfosResult> {\n+): Promise<FetchServerThreadInfosResult> {\nconst whereClause = condition ? SQL`WHERE `.append(condition) : \"\";\nconst query = SQL`\n@@ -45,7 +42,6 @@ async function fetchThreadInfos(\n`.append(whereClause).append(SQL`ORDER BY m.user ASC`);\nconst [ result ] = await conn.query(query);\n- const viewerID = viewer && viewer.id;\nconst threadInfos = {};\nconst userInfos = {};\nfor (let row of result) {\n@@ -61,7 +57,6 @@ async function fetchThreadInfos(\nparentThreadID: row.parent_thread_id,\nmembers: [],\nroles: {},\n- currentUser: null,\n};\n}\nif (row.role && !threadInfos[threadID].roles[row.role]) {\n@@ -85,6 +80,8 @@ async function fetchThreadInfos(\nid: userID,\npermissions: allPermissions,\nrole: row.role ? row.role : null,\n+ subscription: row.subscription,\n+ unread: row.role ? row.unread : null,\n};\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@@ -99,56 +96,38 @@ async function fetchThreadInfos(\n};\n}\n}\n- if (userID === viewerID) {\n- threadInfos[threadID].currentUser = {\n- role: member.role,\n- permissions: member.permissions,\n- subscription: row.subscription,\n- unread: member.role ? row.unread : null,\n- };\n}\n}\n+ return { threadInfos, userInfos };\n}\n- const finalThreadInfos = {};\n- for (let threadID in threadInfos) {\n- let threadInfo = threadInfos[threadID];\n- let allPermissions;\n- if (!threadInfo.currentUser) {\n- allPermissions = getAllThreadPermissions(\n- {\n- permissions: null,\n- visibilityRules: threadInfo.visibilityRules,\n- },\n- threadID,\n+type FetchThreadInfosResult = {|\n+ threadInfos: {[id: string]: RawThreadInfo},\n+ userInfos: {[id: string]: UserInfo},\n+|};\n+\n+async function fetchThreadInfos(\n+ conn: Connection,\n+ condition?: SQLStatement,\n+): Promise<FetchThreadInfosResult> {\n+ const serverResult = await fetchServerThreadInfos(conn, condition);\n+ const viewerID = currentViewer().id;\n+ const threadInfos = {};\n+ const userInfos = {};\n+ for (let threadID in serverResult.threadInfos) {\n+ const serverThreadInfo = serverResult.threadInfos[threadID];\n+ const threadInfo = rawThreadInfoFromServerThreadInfo(\n+ serverThreadInfo,\n+ viewerID,\n);\n- threadInfo = {\n- ...threadInfo,\n- currentUser: {\n- role: null,\n- permissions: allPermissions,\n- subscription: {\n- home: false,\n- pushNotifs: false,\n- },\n- unread: null,\n- },\n- };\n- } else {\n- allPermissions = threadInfo.currentUser.permissions;\n+ if (threadInfo) {\n+ threadInfos[threadID] = threadInfo;\n+ for (let member of threadInfo.members) {\n+ userInfos[member.id] = serverResult.userInfos[member.id];\n}\n- if (\n- !viewer ||\n- permissionLookup(allPermissions, threadPermissions.KNOW_OF)\n- ) {\n- finalThreadInfos[threadID] = threadInfo;\n}\n}\n-\n- return {\n- threadInfos: finalThreadInfos,\n- userInfos,\n- };\n+ return { threadInfos, userInfos };\n}\nasync function verifyThreadIDs(\n@@ -170,6 +149,7 @@ async function verifyThreadIDs(\n}\nexport {\n+ fetchServerThreadInfos,\nfetchThreadInfos,\nverifyThreadIDs,\n};\n" }, { "change_type": "MODIFY", "old_path": "jserver/src/push/send.js", "new_path": "jserver/src/push/send.js", "diff": "import type { RawMessageInfo, MessageInfo } from 'lib/types/message-types';\nimport type { UserInfo } from 'lib/types/user-types';\n-import type { RawThreadInfo, ThreadInfo } from 'lib/types/thread-types';\n+import type { ServerThreadInfo, ThreadInfo } from 'lib/types/thread-types';\nimport type { Connection } from '../database';\nimport type { DeviceType } from 'lib/actions/device-actions';\nimport type {\n@@ -13,6 +13,9 @@ import type {\nimport apn from 'apn';\nimport invariant from 'invariant';\nimport uuidv4 from 'uuid/v4';\n+import _flow from 'lodash/fp/flow';\n+import _mapValues from 'lodash/fp/mapValues';\n+import _pickBy from 'lodash/fp/pickBy';\nimport { notifTextForMessageInfo } from 'lib/shared/notif-utils';\nimport { messageType } from 'lib/types/message-types';\n@@ -20,11 +23,14 @@ import {\ncreateMessageInfo,\nsortMessageInfoList,\n} from 'lib/shared/message-utils';\n-import { rawThreadInfosToThreadInfos } from 'lib/selectors/thread-selectors';\n+import {\n+ rawThreadInfoFromServerThreadInfo,\n+ threadInfoFromRawThreadInfo,\n+} from 'lib/shared/thread-utils';\nimport { SQL, mergeOrConditions } from '../database';\nimport { apnPush, fcmPush, getUnreadCounts } from './utils';\n-import { fetchThreadInfos } from '../fetchers/thread-fetcher';\n+import { fetchServerThreadInfos } from '../fetchers/thread-fetcher';\nimport { fetchUserInfos } from '../fetchers/user-fetcher';\nimport { fetchCollapsableNotifs } from '../fetchers/message-fetcher';\nimport createIDs from '../creators/id-creator';\n@@ -46,7 +52,7 @@ async function sendPushNotifs(\nconst [\nunreadCounts,\n- { usersToCollapsableNotifInfo, rawThreadInfos, userInfos },\n+ { usersToCollapsableNotifInfo, serverThreadInfos, userInfos },\ndbIDs,\n] = await Promise.all([\ngetUnreadCounts(conn, Object.keys(pushInfo)),\n@@ -57,11 +63,25 @@ async function sendPushNotifs(\nconst deliveryPromises = [];\nconst notifications = {};\nfor (let userID in usersToCollapsableNotifInfo) {\n- const threadInfos = rawThreadInfosToThreadInfos(\n- rawThreadInfos,\n+ const threadInfos = _flow(\n+ _mapValues(\n+ (serverThreadInfo: ServerThreadInfo) => {\n+ const rawThreadInfo = rawThreadInfoFromServerThreadInfo(\n+ serverThreadInfo,\n+ userID,\n+ );\n+ if (!rawThreadInfo) {\n+ return null;\n+ }\n+ return threadInfoFromRawThreadInfo(\n+ rawThreadInfo,\nuserID,\nuserInfos,\n);\n+ },\n+ ),\n+ _pickBy(threadInfo => threadInfo),\n+ )(serverThreadInfos);\nfor (let notifInfo of usersToCollapsableNotifInfo[userID]) {\nconst hydrateMessageInfo =\n(rawMessageInfo: RawMessageInfo) => createMessageInfo(\n@@ -237,8 +257,8 @@ async function fetchInfos(\n}\n// These threadInfos won't have currentUser set\n- const { threadInfos: rawThreadInfos, userInfos: threadUserInfos } =\n- await fetchThreadInfos(conn, SQL`t.id IN (${[...threadIDs]})`, null);\n+ const { threadInfos: serverThreadInfos, userInfos: threadUserInfos } =\n+ await fetchServerThreadInfos(conn, SQL`t.id IN (${[...threadIDs]})`);\nconst mergedUserInfos = {\n...collapsableNotifsResult.userInfos,\n...threadUserInfos,\n@@ -250,7 +270,7 @@ async function fetchInfos(\nusersToCollapsableNotifInfo,\n);\n- return { usersToCollapsableNotifInfo, rawThreadInfos, userInfos };\n+ return { usersToCollapsableNotifInfo, serverThreadInfos, userInfos };\n}\nasync function fetchMissingUserInfos(\n" }, { "change_type": "RENAME", "old_path": "jserver/src/permissions/permissions.js", "new_path": "lib/permissions/thread-permissions.js", "diff": "@@ -4,14 +4,12 @@ import type {\nThreadPermissionsBlob,\nVisibilityRules,\nThreadPermission,\n-} from 'lib/types/thread-types';\n+} from '../types/thread-types';\nimport {\nvisibilityRules,\nthreadPermissions,\n-} from 'lib/types/thread-types';\n-\n-import { currentViewer } from '../session/viewer';\n+} from '../types/thread-types';\ntype PermissionsInfo = {\npermissions: ?ThreadPermissionsBlob,\n" }, { "change_type": "MODIFY", "old_path": "lib/selectors/thread-selectors.js", "new_path": "lib/selectors/thread-selectors.js", "diff": "@@ -24,7 +24,10 @@ const _mapValuesWithKeys = _mapValues.convert({ cap: false });\nimport { currentNavID } from './nav-selectors';\nimport { dateString, dateFromString } from '../utils/date-utils';\nimport { createEntryInfo } from '../shared/entry-utils';\n-import { viewerIsMember, createThreadInfo } from '../shared/thread-utils';\n+import {\n+ viewerIsMember,\n+ threadInfoFromRawThreadInfo,\n+} from '../shared/thread-utils';\nimport { relativeMemberInfoSelectorForMembersOfThread } from './user-selectors';\nconst rawThreadInfosToThreadInfos = (\n@@ -32,7 +35,7 @@ const rawThreadInfosToThreadInfos = (\nviewerID: ?string,\nuserInfos: {[id: string]: UserInfo},\n): {[id: string]: ThreadInfo} => _mapValues(\n- (rawThreadInfo: RawThreadInfo) => createThreadInfo(\n+ (rawThreadInfo: RawThreadInfo) => threadInfoFromRawThreadInfo(\nrawThreadInfo,\nviewerID,\nuserInfos,\n" }, { "change_type": "MODIFY", "old_path": "lib/shared/thread-utils.js", "new_path": "lib/shared/thread-utils.js", "diff": "@@ -5,12 +5,18 @@ import type {\nThreadInfo,\nThreadPermission,\nMemberInfo,\n+ ServerThreadInfo,\n} from '../types/thread-types';\nimport type { UserInfo } from '../types/user-types';\nimport Color from 'color';\nimport { pluralize } from '../utils/text-utils';\n+import {\n+ permissionLookup,\n+ getAllThreadPermissions,\n+} from '../permissions/thread-permissions';\n+import { threadPermissions } from '../types/thread-types';\nfunction colorIsDark(color: string) {\nreturn Color(`#${color}`).dark();\n@@ -81,7 +87,68 @@ function threadUIName(\nreturn pluralize(threadUsernames);\n}\n-function createThreadInfo(\n+function rawThreadInfoFromServerThreadInfo(\n+ serverThreadInfo: ServerThreadInfo,\n+ viewerID: string,\n+): ?RawThreadInfo {\n+ const members = [];\n+ let currentUser;\n+ for (let serverMember of serverThreadInfo.members) {\n+ members.push({\n+ id: serverMember.id,\n+ role: serverMember.role,\n+ permissions: serverMember.permissions,\n+ });\n+ if (serverMember.id === viewerID) {\n+ currentUser = {\n+ role: serverMember.role,\n+ permissions: serverMember.permissions,\n+ subscription: serverMember.subscription,\n+ unread: serverMember.unread,\n+ };\n+ }\n+ }\n+\n+ let currentUserPermissions;\n+ if (currentUser) {\n+ currentUserPermissions = currentUser.permissions;\n+ } else {\n+ currentUserPermissions = getAllThreadPermissions(\n+ {\n+ permissions: null,\n+ visibilityRules: serverThreadInfo.visibilityRules,\n+ },\n+ serverThreadInfo.id,\n+ );\n+ currentUser = {\n+ role: null,\n+ permissions: currentUserPermissions,\n+ subscription: {\n+ home: false,\n+ pushNotifs: false,\n+ },\n+ unread: null,\n+ };\n+ }\n+ if (!permissionLookup(currentUserPermissions, threadPermissions.KNOW_OF)) {\n+ return null;\n+ }\n+\n+ return {\n+ id: serverThreadInfo.id,\n+ name: serverThreadInfo.name,\n+ description: serverThreadInfo.description,\n+ visibilityRules: serverThreadInfo.visibilityRules,\n+ color: serverThreadInfo.color,\n+ creationTime: serverThreadInfo.creationTime,\n+ parentThreadID: serverThreadInfo.parentThreadID,\n+ members,\n+ roles: serverThreadInfo.roles,\n+ currentUser,\n+ };\n+}\n+\n+function threadInfoFromRawThreadInfo(\nrawThreadInfo: RawThreadInfo,\nviewerID: ?string,\nuserInfos: {[id: string]: UserInfo},\n@@ -101,7 +168,7 @@ function createThreadInfo(\n};\n}\n-function getRawThreadInfo(threadInfo: ThreadInfo): RawThreadInfo {\n+function rawThreadInfoFromThreadInfo(threadInfo: ThreadInfo): RawThreadInfo {\nreturn {\nid: threadInfo.id,\nname: threadInfo.name,\n@@ -124,6 +191,7 @@ export {\nthreadActualMembers,\nthreadIsPersonalChat,\nthreadIsTwoPersonChat,\n- createThreadInfo,\n- getRawThreadInfo,\n+ rawThreadInfoFromServerThreadInfo,\n+ threadInfoFromRawThreadInfo,\n+ rawThreadInfoFromThreadInfo,\n}\n" }, { "change_type": "MODIFY", "old_path": "lib/types/thread-types.js", "new_path": "lib/types/thread-types.js", "diff": "@@ -201,3 +201,23 @@ export const threadInfoPropType = PropTypes.shape({\nroles: PropTypes.objectOf(rolePropType).isRequired,\ncurrentUser: currentUserPropType.isRequired,\n});\n+\n+export type ServerMemberInfo = {|\n+ id: string,\n+ role: ?string,\n+ permissions: ThreadPermissionsBlob,\n+ subscription: ThreadSubscription,\n+ unread: ?bool,\n+|};\n+\n+export type ServerThreadInfo = {|\n+ id: string,\n+ name: ?string,\n+ description: string,\n+ visibilityRules: VisibilityRules,\n+ color: string, // hex, without \"#\" or \"0x\"\n+ creationTime: number, // millisecond timestamp\n+ parentThreadID: ?string,\n+ members: ServerMemberInfo[],\n+ roles: {[id: string]: RoleInfo},\n+|};\n" }, { "change_type": "MODIFY", "old_path": "native/navigation-setup.js", "new_path": "native/navigation-setup.js", "diff": "@@ -48,7 +48,7 @@ import {\nnewThreadActionTypes,\n} from 'lib/actions/thread-actions';\nimport { notificationPressActionType } from 'lib/shared/notif-utils';\n-import { createThreadInfo } from 'lib/shared/thread-utils';\n+import { threadInfoFromRawThreadInfo } from 'lib/shared/thread-utils';\nimport {\nCalendar,\n@@ -599,7 +599,11 @@ function replaceChatStackWithThread(\nviewerID: ?string,\nuserInfos: {[id: string]: UserInfo},\n): NavigationState {\n- const threadInfo = createThreadInfo(rawThreadInfo, viewerID, userInfos);\n+ const threadInfo = threadInfoFromRawThreadInfo(\n+ rawThreadInfo,\n+ viewerID,\n+ userInfos,\n+ );\nconst appRoute = assertNavigationRouteNotLeafNode(state.routes[0]);\nconst chatRoute = assertNavigationRouteNotLeafNode(appRoute.routes[1]);\n@@ -649,7 +653,7 @@ function handleNotificationPress(\n);\n}\n- const threadInfo = createThreadInfo(\n+ const threadInfo = threadInfoFromRawThreadInfo(\npayload.rawThreadInfo,\nviewerID,\nuserInfos,\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Create new type ServerThreadInfo and function fetchServerThreadInfos (Used within node server)
129,187
08.02.2018 12:46:37
18,000
dbf029f265342ed6ca3d8ae8f467aa761cfa4acf
Update badge count even when user disables push notifs for a thread
[ { "change_type": "MODIFY", "old_path": "jserver/src/creators/message-creator.js", "new_path": "jserver/src/creators/message-creator.js", "diff": "@@ -274,7 +274,7 @@ async function sendPushNotifsForNewMessages(\nappendSQLArray(query, subthreadJoins, SQL` `);\nquery.append(SQL`\nWHERE m.role != 0 AND c.user IS NOT NULL AND f.user IS NULL AND\n- JSON_EXTRACT(m.subscription, '$.pushNotifs') IS TRUE AND (\n+ (\nJSON_EXTRACT(m.permissions, ${visibleExtractString}) IS TRUE\nOR t.visibility_rules = ${visibilityRules.OPEN}\n) AND\n" }, { "change_type": "MODIFY", "old_path": "jserver/src/database.js", "new_path": "jserver/src/database.js", "diff": "@@ -58,10 +58,6 @@ function mergeOrConditions(andConditions: SQLStatement[]) {\nreturn mergeConditions(andConditions, SQL` OR `);\n}\n-function rawSQL(statement: SQLStatement) {\n- return mysql.format(statement.sql, ...statement.values);\n-}\n-\nexport {\nconnect,\nSQL,\n@@ -69,5 +65,4 @@ export {\nappendSQLArray,\nmergeAndConditions,\nmergeOrConditions,\n- rawSQL,\n};\n" }, { "change_type": "MODIFY", "old_path": "jserver/src/fetchers/thread-fetcher.js", "new_path": "jserver/src/fetchers/thread-fetcher.js", "diff": "@@ -45,7 +45,7 @@ async function fetchServerThreadInfos(\nconst threadInfos = {};\nconst userInfos = {};\nfor (let row of result) {\n- const threadID = row.id;\n+ const threadID = row.id.toString();\nif (!threadInfos[threadID]) {\nthreadInfos[threadID] = {\nid: threadID,\n@@ -54,21 +54,24 @@ async function fetchServerThreadInfos(\nvisibilityRules: row.visibility_rules,\ncolor: row.color,\ncreationTime: row.creation_time,\n- parentThreadID: row.parent_thread_id,\n+ parentThreadID: row.parent_thread_id\n+ ? row.parent_thread_id.toString()\n+ : null,\nmembers: [],\nroles: {},\n};\n}\n- if (row.role && !threadInfos[threadID].roles[row.role]) {\n- threadInfos[threadID].roles[row.role] = {\n- id: row.role,\n+ const role = row.role.toString();\n+ if (role && !threadInfos[threadID].roles[role]) {\n+ threadInfos[threadID].roles[role] = {\n+ id: role,\nname: row.role_name,\npermissions: row.role_permissions,\n- isDefault: row.role === row.default_role,\n+ isDefault: role === row.default_role.toString(),\n};\n}\nif (row.user) {\n- const userID = row.user;\n+ const userID = row.user.toString();\nconst allPermissions = getAllThreadPermissions(\n{\npermissions: row.permissions,\n@@ -79,7 +82,7 @@ async function fetchServerThreadInfos(\nconst member = {\nid: userID,\npermissions: allPermissions,\n- role: row.role ? row.role : null,\n+ role: row.role ? role : null,\nsubscription: row.subscription,\nunread: row.role ? row.unread : null,\n};\n" }, { "change_type": "MODIFY", "old_path": "jserver/src/push/send.js", "new_path": "jserver/src/push/send.js", "diff": "@@ -107,6 +107,11 @@ async function sendPushNotifs(\nconst threadID = firstNewMessageInfo.threadID;\nconst threadInfo = threadInfos[threadID];\n+ const badgeOnly = !threadInfo.currentUser.subscription.pushNotifs;\n+ if (badgeOnly && !threadInfo.currentUser.subscription.home) {\n+ continue;\n+ }\n+\nconst dbID = dbIDs.shift();\ninvariant(dbID, \"should have sufficient DB IDs\");\nconst byDeviceType = getDevicesByDeviceType(pushInfo[userID].devices);\n@@ -116,6 +121,7 @@ async function sendPushNotifs(\nallMessageInfos,\nthreadInfo,\nnotifInfo.collapseKey,\n+ badgeOnly,\nunreadCounts[userID],\n);\ndeliveryPromises.push(apnPush(notification, byDeviceType.ios, dbID));\n@@ -127,6 +133,7 @@ async function sendPushNotifs(\nallMessageInfos,\nthreadInfo,\nnotifInfo.collapseKey,\n+ badgeOnly,\nunreadCounts[userID],\ndbID,\n);\n@@ -348,14 +355,17 @@ function prepareIOSNotification(\nmessageInfos: MessageInfo[],\nthreadInfo: ThreadInfo,\ncollapseKey: ?string,\n+ badgeOnly: bool,\nunreadCount: number,\n): apn.Notification {\nconst notifText = notifTextForMessageInfo(messageInfos, threadInfo);\nconst uniqueID = uuidv4();\nconst notification = new apn.Notification();\n- notification.body = notifText;\nnotification.topic = \"org.squadcal.app\";\n+ if (!badgeOnly) {\n+ notification.body = notifText;\nnotification.sound = \"default\";\n+ }\nnotification.badge = unreadCount;\nnotification.threadId = threadInfo.id;\nnotification.id = uniqueID;\n@@ -371,12 +381,15 @@ function prepareAndroidNotification(\nmessageInfos: MessageInfo[],\nthreadInfo: ThreadInfo,\ncollapseKey: ?string,\n+ badgeOnly: bool,\nunreadCount: number,\ndbID: string,\n): Object {\nconst notifText = notifTextForMessageInfo(messageInfos, threadInfo);\nconst data = {};\n+ if (!badgeOnly) {\ndata.notifBody = notifText;\n+ }\ndata.badgeCount = unreadCount.toString();\ndata.threadID = threadInfo.id.toString();\ndata.notifID = collapseKey ? collapseKey : dbID;\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Update badge count even when user disables push notifs for a thread
129,187
08.02.2018 14:56:35
18,000
2d832a726c3340446d881e7bbf49781e638f80cf
Move node to using connection pooling Side benefit is we don't need to pass the connection around or end it...
[ { "change_type": "MODIFY", "old_path": "jserver/src/creators/id-creator.js", "new_path": "jserver/src/creators/id-creator.js", "diff": "// @flow\n-import type { Connection } from '../database';\n-\nimport invariant from 'invariant';\n-import { SQL } from '../database';\n+import { pool, SQL } from '../database';\nasync function createIDs(\n- conn: Connection,\ntableName: string,\nnumIDsToCreate: number,\n): Promise<string[]> {\n@@ -17,7 +14,7 @@ async function createIDs(\nconst idInserts = Array(numIDsToCreate).fill([tableName]);\nconst query = SQL`INSERT INTO ids(table_name) VALUES ${idInserts}`;\n- const [ result ] = await conn.query(query);\n+ const [ result ] = await pool.query(query);\nconst lastNewID = result.insertId;\ninvariant(lastNewID !== null && lastNewID !== undefined, \"should be set\");\nconst firstNewID = lastNewID - numIDsToCreate + 1;\n" }, { "change_type": "MODIFY", "old_path": "jserver/src/creators/message-creator.js", "new_path": "jserver/src/creators/message-creator.js", "diff": "// @flow\n-import type { Connection } from '../database';\nimport type { MessageData, RawMessageInfo } from 'lib/types/message-types';\nimport invariant from 'invariant';\n@@ -16,6 +15,7 @@ import { earliestTimeConsideredCurrent } from 'lib/shared/ping-utils';\nimport { permissionHelper } from 'lib/permissions/thread-permissions';\nimport {\n+ pool,\nSQL,\nSQLStatement,\nappendSQLArray,\n@@ -31,14 +31,13 @@ type ThreadRestriction = {|\n|};\nasync function createMessages(\n- conn: Connection,\nmessageDatas: MessageData[],\n): Promise<RawMessageInfo[]> {\nif (messageDatas.length === 0) {\nreturn [];\n}\n- const ids = await createIDs(conn, \"messages\", messageDatas.length);\n+ const ids = await createIDs(\"messages\", messageDatas.length);\n// threadRestrictions contains the conditions that must be met for a\n// membership row to be set to unread or the corresponding user notified for a\n@@ -152,10 +151,9 @@ async function createMessages(\nVALUES ${messageInsertRows}\n`;\nawait Promise.all([\n- conn.query(messageInsertQuery),\n- updateUnreadStatus(conn, threadRestrictions),\n+ pool.query(messageInsertQuery),\n+ updateUnreadStatus(threadRestrictions),\nsendPushNotifsForNewMessages(\n- conn,\nthreadRestrictions,\nsubthreadPermissionsToCheck,\nthreadsToMessageIndices,\n@@ -167,7 +165,6 @@ async function createMessages(\n}\nasync function updateUnreadStatus(\n- conn: Connection,\nthreadRestrictions: Map<string, ThreadRestriction>,\n) {\nconst knowOfExtractString = `$.${threadPermissions.KNOW_OF}.value`;\n@@ -222,11 +219,10 @@ async function updateUnreadStatus(\n) AND\n`);\nquery.append(conditionClause);\n- await conn.query(query);\n+ await pool.query(query);\n}\nasync function sendPushNotifsForNewMessages(\n- conn: Connection,\nthreadRestrictions: Map<string, ThreadRestriction>,\nsubthreadPermissionsToCheck: Set<string>,\nthreadsToMessageIndices: Map<string, number[]>,\n@@ -282,7 +278,7 @@ async function sendPushNotifsForNewMessages(\nquery.append(conditionClause);\nconst prePushInfo = new Map();\n- const [ result ] = await conn.query(query);\n+ const [ result ] = await pool.query(query);\nfor (let row of result) {\nconst userID = row.user.toString();\nconst threadID = row.thread.toString();\n@@ -354,7 +350,7 @@ async function sendPushNotifsForNewMessages(\n}\n}\n- await sendPushNotifs(conn, pushInfo);\n+ await sendPushNotifs(pushInfo);\n}\n// Note: does *not* consider subthread\n" }, { "change_type": "MODIFY", "old_path": "jserver/src/database.js", "new_path": "jserver/src/database.js", "diff": "@@ -13,14 +13,10 @@ export type QueryResult = [\nany[],\n];\n-export type Connection = {\n- query(query: string): Promise<QueryResult>;\n- end(): Promise<void>;\n-};\n-\n-async function connect(): Promise<Connection> {\n- return await mysqlPromise.createConnection(dbConfig);\n-}\n+const pool = mysqlPromise.createPool({\n+ ...dbConfig,\n+ connectionLimit: 10,\n+});\ntype SQLOrString = SQLStatement | string;\nfunction appendSQLArray(\n@@ -59,7 +55,7 @@ function mergeOrConditions(andConditions: SQLStatement[]) {\n}\nexport {\n- connect,\n+ pool,\nSQL,\nSQLStatement,\nappendSQLArray,\n" }, { "change_type": "MODIFY", "old_path": "jserver/src/fetchers/message-fetcher.js", "new_path": "jserver/src/fetchers/message-fetcher.js", "diff": "// @flow\n-import type { Connection } from '../database';\nimport type { PushInfo } from '../push/send';\nimport type { UserInfo } from 'lib/types/user-types';\nimport type { RawMessageInfo } from 'lib/types/message-types';\n@@ -17,7 +16,7 @@ import {\nimport { sortMessageInfoList } from 'lib/shared/message-utils';\nimport { permissionHelper } from 'lib/permissions/thread-permissions';\n-import { SQL, mergeOrConditions } from '../database';\n+import { pool, SQL, mergeOrConditions } from '../database';\nexport type CollapsableNotifInfo = {|\ncollapseKey: ?string,\n@@ -30,7 +29,6 @@ export type FetchCollapsableNotifsResult = {|\n|};\nasync function fetchCollapsableNotifs(\n- conn: Connection,\npushInfo: PushInfo,\n): Promise<FetchCollapsableNotifsResult> {\n// First, we need to fetch any notifications that should be collapsed\n@@ -104,7 +102,7 @@ async function fetchCollapsableNotifs(\n`;\ncollapseQuery.append(mergeOrConditions(sqlTuples));\ncollapseQuery.append(SQL`ORDER BY m.time DESC`);\n- const [ collapseResult ] = await conn.query(collapseQuery);\n+ const [ collapseResult ] = await pool.query(collapseQuery);\nconst userInfos = {};\nfor (let row of collapseResult) {\n" }, { "change_type": "MODIFY", "old_path": "jserver/src/fetchers/thread-fetcher.js", "new_path": "jserver/src/fetchers/thread-fetcher.js", "diff": "// @flow\n-import type { Connection } from '../database';\nimport type { RawThreadInfo, ServerThreadInfo } from 'lib/types/thread-types';\nimport type { UserInfo } from 'lib/types/user-types';\n@@ -11,7 +10,7 @@ import {\nimport { getAllThreadPermissions } from 'lib/permissions/thread-permissions';\nimport { rawThreadInfoFromServerThreadInfo } from 'lib/shared/thread-utils';\n-import { SQL, SQLStatement } from '../database';\n+import { pool, SQL, SQLStatement } from '../database';\nimport { currentViewer } from '../session/viewer';\ntype FetchServerThreadInfosResult = {|\n@@ -20,7 +19,6 @@ type FetchServerThreadInfosResult = {|\n|};\nasync function fetchServerThreadInfos(\n- conn: Connection,\ncondition?: SQLStatement,\n): Promise<FetchServerThreadInfosResult> {\nconst whereClause = condition ? SQL`WHERE `.append(condition) : \"\";\n@@ -40,7 +38,7 @@ async function fetchServerThreadInfos(\nLEFT JOIN memberships m ON m.role = r.id AND m.thread = t.id\nLEFT JOIN users u ON u.id = m.user\n`.append(whereClause).append(SQL`ORDER BY m.user ASC`);\n- const [ result ] = await conn.query(query);\n+ const [ result ] = await pool.query(query);\nconst threadInfos = {};\nconst userInfos = {};\n@@ -110,10 +108,9 @@ type FetchThreadInfosResult = {|\n|};\nasync function fetchThreadInfos(\n- conn: Connection,\ncondition?: SQLStatement,\n): Promise<FetchThreadInfosResult> {\n- const serverResult = await fetchServerThreadInfos(conn, condition);\n+ const serverResult = await fetchServerThreadInfos(condition);\nconst viewerID = currentViewer().id;\nconst threadInfos = {};\nconst userInfos = {};\n@@ -134,7 +131,6 @@ async function fetchThreadInfos(\n}\nasync function verifyThreadIDs(\n- conn: Connection,\nthreadIDs: $ReadOnlyArray<string>,\n): Promise<$ReadOnlyArray<string>> {\nif (threadIDs.length === 0) {\n@@ -142,7 +138,7 @@ async function verifyThreadIDs(\n}\nconst query = SQL`SELECT id FROM threads WHERE id IN (${threadIDs})`;\n- const [ result ] = await conn.query(query);\n+ const [ result ] = await pool.query(query);\nconst verified = [];\nfor (let row of result) {\n" }, { "change_type": "MODIFY", "old_path": "jserver/src/fetchers/user-fetcher.js", "new_path": "jserver/src/fetchers/user-fetcher.js", "diff": "// @flow\n-import type { Connection } from '../database';\nimport type { UserInfo } from 'lib/types/user-types';\n-import { SQL } from '../database';\n+import { pool, SQL } from '../database';\nasync function fetchUserInfos(\n- conn: Connection,\nuserIDs: string[],\n): Promise<{[id: string]: UserInfo}> {\nif (userIDs.length <= 0) {\n@@ -16,7 +14,7 @@ async function fetchUserInfos(\nconst query = SQL`\nSELECT id, username FROM users WHERE id IN (${userIDs})\n`;\n- const [ result ] = await conn.query(query);\n+ const [ result ] = await pool.query(query);\nconst userInfos = {};\nfor (let row of result) {\n" }, { "change_type": "MODIFY", "old_path": "jserver/src/push/rescind.js", "new_path": "jserver/src/push/rescind.js", "diff": "// @flow\n-import type { Connection } from '../database';\n-\nimport apn from 'apn';\n-import { SQL } from '../database';\n+import { pool, SQL } from '../database';\nimport { apnPush, fcmPush, getUnreadCounts } from './utils';\nasync function rescindPushNotifs(\n- conn: Connection,\nuserID: string,\nthreadIDs: $ReadOnlyArray<string>,\n) {\n@@ -19,8 +16,8 @@ async function rescindPushNotifs(\nAND rescinded = 0\n`;\nconst [ [ fetchResult ], unreadCounts ] = await Promise.all([\n- conn.query(fetchQuery),\n- getUnreadCounts(conn, [ userID ]),\n+ pool.query(fetchQuery),\n+ getUnreadCounts([ userID ]),\n]);\nconst promises = [];\n@@ -63,7 +60,7 @@ async function rescindPushNotifs(\nconst rescindQuery = SQL`\nUPDATE notifications SET rescinded = 1 WHERE id IN (${rescindedIDs})\n`;\n- promises.push(conn.query(rescindQuery));\n+ promises.push(pool.query(rescindQuery));\n}\nawait Promise.all(promises);\n" }, { "change_type": "MODIFY", "old_path": "jserver/src/push/send.js", "new_path": "jserver/src/push/send.js", "diff": "import type { RawMessageInfo, MessageInfo } from 'lib/types/message-types';\nimport type { UserInfo } from 'lib/types/user-types';\nimport type { ServerThreadInfo, ThreadInfo } from 'lib/types/thread-types';\n-import type { Connection } from '../database';\nimport type { DeviceType } from 'lib/actions/device-actions';\nimport type {\nCollapsableNotifInfo,\n@@ -28,7 +27,7 @@ import {\nthreadInfoFromRawThreadInfo,\n} from 'lib/shared/thread-utils';\n-import { SQL, mergeOrConditions } from '../database';\n+import { pool, SQL, mergeOrConditions } from '../database';\nimport { apnPush, fcmPush, getUnreadCounts } from './utils';\nimport { fetchServerThreadInfos } from '../fetchers/thread-fetcher';\nimport { fetchUserInfos } from '../fetchers/user-fetcher';\n@@ -42,10 +41,7 @@ type PushUserInfo = {\n};\nexport type PushInfo = { [userID: string]: PushUserInfo };\n-async function sendPushNotifs(\n- conn: Connection,\n- pushInfo: PushInfo,\n-) {\n+async function sendPushNotifs(pushInfo: PushInfo) {\nif (Object.keys(pushInfo).length === 0) {\nreturn [];\n}\n@@ -55,9 +51,9 @@ async function sendPushNotifs(\n{ usersToCollapsableNotifInfo, serverThreadInfos, userInfos },\ndbIDs,\n] = await Promise.all([\n- getUnreadCounts(conn, Object.keys(pushInfo)),\n- fetchInfos(conn, pushInfo),\n- createDBIDs(conn, pushInfo),\n+ getUnreadCounts(Object.keys(pushInfo)),\n+ fetchInfos(pushInfo),\n+ createDBIDs(pushInfo),\n]);\nconst deliveryPromises = [];\n@@ -174,7 +170,7 @@ async function sendPushNotifs(\nconst cleanUpPromises = [];\nif (dbIDs.length > 0) {\nconst query = SQL`DELETE FROM ids WHERE id IN (${dbIDs})`;\n- cleanUpPromises.push(conn.query(query));\n+ cleanUpPromises.push(pool.query(query));\n}\nconst [ deliveryResults ] = await Promise.all([\nPromise.all(deliveryPromises),\n@@ -206,10 +202,7 @@ async function sendPushNotifs(\nconst dbPromises = [];\nif (invalidTokens.length > 0) {\n- dbPromises.push(removeInvalidTokens(\n- conn,\n- invalidTokens,\n- ));\n+ dbPromises.push(removeInvalidTokens(invalidTokens));\n}\nconst flattenedNotifications = [];\n@@ -225,18 +218,15 @@ async function sendPushNotifs(\n(id, user, thread, message, collapse_key, delivery, rescinded)\nVALUES ${flattenedNotifications}\n`;\n- dbPromises.push(conn.query(query));\n+ dbPromises.push(pool.query(query));\n}\nif (dbPromises.length > 0) {\nawait Promise.all(dbPromises);\n}\n}\n-async function fetchInfos(\n- conn: Connection,\n- pushInfo: PushInfo,\n-) {\n- const collapsableNotifsResult = await fetchCollapsableNotifs(conn, pushInfo);\n+async function fetchInfos(pushInfo: PushInfo) {\n+ const collapsableNotifsResult = await fetchCollapsableNotifs(pushInfo);\nconst threadIDs = new Set();\nconst addThreadIDsFromMessageInfos = (rawMessageInfo: RawMessageInfo) => {\n@@ -265,14 +255,13 @@ async function fetchInfos(\n// These threadInfos won't have currentUser set\nconst { threadInfos: serverThreadInfos, userInfos: threadUserInfos } =\n- await fetchServerThreadInfos(conn, SQL`t.id IN (${[...threadIDs]})`);\n+ await fetchServerThreadInfos(SQL`t.id IN (${[...threadIDs]})`);\nconst mergedUserInfos = {\n...collapsableNotifsResult.userInfos,\n...threadUserInfos,\n};\nconst userInfos = await fetchMissingUserInfos(\n- conn,\nmergedUserInfos,\nusersToCollapsableNotifInfo,\n);\n@@ -281,7 +270,6 @@ async function fetchInfos(\n}\nasync function fetchMissingUserInfos(\n- conn: Connection,\nuserInfos: { [id: string]: UserInfo },\nusersToCollapsableNotifInfo: { [userID: string]: CollapsableNotifInfo[] },\n) {\n@@ -321,21 +309,18 @@ async function fetchMissingUserInfos(\nlet finalUserInfos = userInfos;\nif (missingUserIDs.size > 0) {\n- const newUserInfos = await fetchUserInfos(conn, [...missingUserIDs]);\n+ const newUserInfos = await fetchUserInfos([...missingUserIDs]);\nfinalUserInfos = { ...userInfos, ...newUserInfos };\n}\nreturn finalUserInfos;\n}\n-async function createDBIDs(\n- conn: Connection,\n- pushInfo: PushInfo,\n-): Promise<string[]> {\n+async function createDBIDs(pushInfo: PushInfo): Promise<string[]> {\nlet numIDsNeeded = 0;\nfor (let userID in pushInfo) {\nnumIDsNeeded += pushInfo[userID].messageInfos.length;\n}\n- return await createIDs(conn, \"notifications\", numIDsNeeded);\n+ return await createIDs(\"notifications\", numIDsNeeded);\n}\nfunction getDevicesByDeviceType(\n@@ -401,10 +386,7 @@ type InvalidToken = {\nfcmTokens?: string[],\napnTokens?: string[],\n};\n-async function removeInvalidTokens(\n- conn: Connection,\n- invalidTokens: InvalidToken[],\n-) {\n+async function removeInvalidTokens(invalidTokens: InvalidToken[]) {\nconst query = SQL`\nUPDATE cookies\nSET android_device_token = NULL, ios_device_token = NULL\n@@ -430,7 +412,7 @@ async function removeInvalidTokens(\n}\nquery.append(mergeOrConditions(sqlTuples));\n- await conn.query(query);\n+ await pool.query(query);\n}\nexport {\n" }, { "change_type": "MODIFY", "old_path": "jserver/src/push/utils.js", "new_path": "jserver/src/push/utils.js", "diff": "// @flow\n-import type { Connection } from '../database';\n-\nimport apn from 'apn';\nimport fcmAdmin from 'firebase-admin';\n-import { SQL } from '../database';\n+import { pool, SQL } from '../database';\nimport apnConfig from '../../secrets/apn_config';\nimport fcmConfig from '../../secrets/fcm_config';\n@@ -128,7 +126,6 @@ async function fcmSinglePush(\n}\nasync function getUnreadCounts(\n- conn: Connection,\nuserIDs: string[],\n): Promise<{ [userID: string]: number }> {\nconst query = SQL`\n@@ -137,7 +134,7 @@ async function getUnreadCounts(\nWHERE user IN (${userIDs}) AND unread = 1 AND role != 0\nGROUP BY user\n`;\n- const [ result ] = await conn.query(query);\n+ const [ result ] = await pool.query(query);\nconst usersToUnreadCounts = {};\nfor (let row of result) {\nusersToUnreadCounts[row.user.toString()] = row.unread_count;\n" }, { "change_type": "MODIFY", "old_path": "jserver/src/responders/activity-responders.js", "new_path": "jserver/src/responders/activity-responders.js", "diff": "@@ -6,7 +6,6 @@ import type { ActivityUpdate } from 'lib/types/activity-types';\nimport t from 'tcomb';\nimport { activityUpdater } from '../updaters/activity-updater';\n-import { connect } from '../database';\nimport { setCurrentViewerFromCookie } from '../session/cookies';\nimport { tBool } from '../utils/tcomb-utils';\n@@ -34,10 +33,8 @@ async function updateActivityResponder(req: $Request, res: $Response) {\nreturn { error: 'invalid_parameters' };\n}\n- const conn = await connect();\n- await setCurrentViewerFromCookie(conn, req.cookies);\n- const result = await activityUpdater(conn, updates);\n- conn.end();\n+ await setCurrentViewerFromCookie(req.cookies);\n+ const result = await activityUpdater(updates);\nif (result) {\nreturn { success: true, unfocusedToUnread: result.unfocusedToUnread };\n" }, { "change_type": "MODIFY", "old_path": "jserver/src/responders/message-responders.js", "new_path": "jserver/src/responders/message-responders.js", "diff": "@@ -4,17 +4,14 @@ import type { $Response, $Request } from 'express';\nimport type { MessageData } from 'lib/types/message-types';\nimport createMessages from '../creators/message-creator';\n-import { connect } from '../database';\nimport { setCurrentViewerFromCookie } from '../session/cookies';\nasync function messageCreationResponder(req: $Request, res: $Response) {\nconst messageDatas: MessageData[] = (req.body: any);\n// We don't currently do any input validation since we have only internal\n// callers as of now\n- const conn = await connect();\n- await setCurrentViewerFromCookie(conn, req.cookies);\n- const rawMessageInfos = await createMessages(conn, messageDatas);\n- conn.end();\n+ await setCurrentViewerFromCookie(req.cookies);\n+ const rawMessageInfos = await createMessages(messageDatas);\nreturn { success: true, rawMessageInfos };\n}\n" }, { "change_type": "MODIFY", "old_path": "jserver/src/responders/user-responders.js", "new_path": "jserver/src/responders/user-responders.js", "diff": "@@ -6,7 +6,6 @@ import type { SubscriptionUpdate } from 'lib/types/subscription-types';\nimport t from 'tcomb';\nimport { userSubscriptionUpdater } from '../updaters/user-subscription-updater';\n-import { connect } from '../database';\nimport { setCurrentViewerFromCookie } from '../session/cookies';\nasync function userSubscriptionUpdateResponder(req: $Request, res: $Response) {\n@@ -25,13 +24,8 @@ async function userSubscriptionUpdateResponder(req: $Request, res: $Response) {\nreturn { error: 'invalid_parameters' };\n}\n- const conn = await connect();\n- await setCurrentViewerFromCookie(conn, req.cookies);\n- const threadSubscription = await userSubscriptionUpdater(\n- conn,\n- subscriptionUpdate,\n- );\n- conn.end();\n+ await setCurrentViewerFromCookie(req.cookies);\n+ const threadSubscription = await userSubscriptionUpdater(subscriptionUpdate);\nif (!threadSubscription) {\nreturn { error: 'not_member' };\n" }, { "change_type": "MODIFY", "old_path": "jserver/src/session/cookies.js", "new_path": "jserver/src/session/cookies.js", "diff": "// @flow\n-import type { Connection } from '../database';\n-\nimport invariant from 'invariant';\nimport bcrypt from 'twin-bcrypt';\nimport { setCurrentViewer } from './viewer';\n-import { SQL } from '../database';\n+import { pool, SQL } from '../database';\nconst cookieLifetime = 30*24*60*60*1000; // in milliseconds\n@@ -14,7 +12,6 @@ const cookieLifetime = 30*24*60*60*1000; // in milliseconds\n// That means it doesn't have any logic to handle an invalid cookie, and it\n// doesn't the cookie's last_update timestamp.\nasync function setCurrentViewerFromCookie(\n- conn: Connection,\ncookieData: {[cookieName: string]: string},\n) {\nif (cookieData.user) {\n@@ -24,7 +21,7 @@ async function setCurrentViewerFromCookie(\nSELECT hash, user, last_update FROM cookies\nWHERE id = ${cookieID} AND user IS NOT NULL\n`;\n- const [ result ] = await conn.query(query);\n+ const [ result ] = await pool.query(query);\nconst cookieRow = result[0];\ninvariant(cookieRow, `invalid user cookie ID ${cookieID}`);\ninvariant(\n@@ -48,7 +45,7 @@ async function setCurrentViewerFromCookie(\nSELECT last_update, hash FROM cookies\nWHERE id = ${cookieID} AND user IS NULL\n`;\n- const [ result ] = await conn.query(query);\n+ const [ result ] = await pool.query(query);\nconst cookieRow = result[0];\ninvariant(cookieRow, `invalid anonymous cookie ID ${cookieID}`);\ninvariant(\n" }, { "change_type": "MODIFY", "old_path": "jserver/src/updaters/activity-updater.js", "new_path": "jserver/src/updaters/activity-updater.js", "diff": "// @flow\n-import type { Connection } from '../database';\nimport type {\nActivityUpdate,\nUpdateActivityResult,\n@@ -14,12 +13,11 @@ import { messageType } from 'lib/types/message-types';\nimport { visibilityRules, threadPermissions } from 'lib/types/thread-types';\nimport { currentViewer } from '../session/viewer';\n-import { SQL, mergeOrConditions } from '../database';\n+import { pool, SQL, mergeOrConditions } from '../database';\nimport { verifyThreadIDs } from '../fetchers/thread-fetcher';\nimport { rescindPushNotifs } from '../push/rescind';\nasync function activityUpdater(\n- conn: Connection,\nupdates: $ReadOnlyArray<ActivityUpdate>,\n): Promise<?UpdateActivityResult> {\nconst viewer = currentViewer();\n@@ -41,17 +39,17 @@ async function activityUpdater(\n}\nconst dbPromises = [];\n- dbPromises.push(conn.query(SQL`\n+ dbPromises.push(pool.query(SQL`\nDELETE FROM focused\nWHERE user = ${viewer.userID} AND cookie = ${viewer.cookieID}\n`));\nif (closing) {\n- dbPromises.push(conn.query(SQL`\n+ dbPromises.push(pool.query(SQL`\nUPDATE cookies SET last_ping = 0 WHERE id = ${viewer.cookieID}\n`));\n}\nconst [ verifiedThreadIDs ] = await Promise.all([\n- verifyThreadIDs(conn, [...unverifiedThreadIDs]),\n+ verifyThreadIDs([...unverifiedThreadIDs]),\nPromise.all(dbPromises),\n]);\n@@ -81,11 +79,11 @@ async function activityUpdater(\nthreadID,\ntime,\n]);\n- promises.push(conn.query(SQL`\n+ promises.push(pool.query(SQL`\nINSERT INTO focused (user, cookie, thread, time)\nVALUES ${focusedInsertRows}\n`));\n- promises.push(conn.query(SQL`\n+ promises.push(pool.query(SQL`\nUPDATE memberships\nSET unread = 0\nWHERE role != 0\n@@ -93,7 +91,6 @@ async function activityUpdater(\nAND user = ${viewer.userID}\n`));\npromises.push(rescindPushNotifs(\n- conn,\nviewer.userID,\nfocusedThreadIDs,\n));\n@@ -101,7 +98,6 @@ async function activityUpdater(\nconst [ resetToUnread ] = await Promise.all([\npossiblyResetThreadsToUnread(\n- conn,\nunfocusedThreadIDs,\nunfocusedThreadLatestMessages,\n),\n@@ -117,7 +113,6 @@ async function activityUpdater(\n// Returns the set of unfocused threads that should be set to unread on\n// the client because a new message arrived since they were unfocused.\nasync function possiblyResetThreadsToUnread(\n- conn: Connection,\nunfocusedThreadIDs: $ReadOnlyArray<string>,\nunfocusedThreadLatestMessages: Map<string, string>,\n): Promise<string[]> {\n@@ -129,10 +124,7 @@ async function possiblyResetThreadsToUnread(\nconst threadUserPairs = unfocusedThreadIDs.map(\nthreadID => [viewer.userID, threadID],\n);\n- const focusedElsewherePairs = await checkThreadsFocused(\n- conn,\n- threadUserPairs,\n- );\n+ const focusedElsewherePairs = await checkThreadsFocused(threadUserPairs);\nconst focusedElsewhereThreadIDs = focusedElsewherePairs.map(pair => pair[1]);\nconst unreadCandidates =\n_difference(unfocusedThreadIDs)(focusedElsewhereThreadIDs);\n@@ -156,7 +148,7 @@ async function possiblyResetThreadsToUnread(\n)\nGROUP BY m.thread\n`;\n- const [ result ] = await conn.query(query);\n+ const [ result ] = await pool.query(query);\nconst resetToUnread = [];\nfor (let row of result) {\n@@ -178,13 +170,12 @@ async function possiblyResetThreadsToUnread(\nAND thread IN (${resetToUnread})\nAND user = ${viewer.userID}\n`;\n- await conn.query(unreadQuery);\n+ await pool.query(unreadQuery);\nreturn resetToUnread;\n}\nasync function checkThreadsFocused(\n- conn: Connection,\nthreadUserPairs: $ReadOnlyArray<[string, string]>,\n): Promise<$ReadOnlyArray<[string, string]>> {\nconst conditions = threadUserPairs.map(\n@@ -199,7 +190,7 @@ async function checkThreadsFocused(\n`;\nquery.append(mergeOrConditions(conditions));\nquery.append(SQL`GROUP BY user, thread`);\n- const [ result ] = await conn.query(query);\n+ const [ result ] = await pool.query(query);\nconst focusedThreadUserPairs = [];\nfor (let row of result) {\n" }, { "change_type": "MODIFY", "old_path": "jserver/src/updaters/user-subscription-updater.js", "new_path": "jserver/src/updaters/user-subscription-updater.js", "diff": "// @flow\n-import type { Connection } from '../database';\nimport type {\nThreadSubscription,\nSubscriptionUpdate,\n} from 'lib/types/subscription-types';\nimport { currentViewer } from '../session/viewer';\n-import { SQL } from '../database';\n+import { pool, SQL } from '../database';\nasync function userSubscriptionUpdater(\n- conn: Connection,\nupdate: SubscriptionUpdate,\n): Promise<?ThreadSubscription> {\nconst viewer = currentViewer();\n@@ -19,7 +17,7 @@ async function userSubscriptionUpdater(\nFROM memberships\nWHERE user = ${viewer.id} AND thread = ${update.threadID} AND role != 0\n`;\n- const [ result ] = await conn.query(query);\n+ const [ result ] = await pool.query(query);\nif (result.length === 0) {\nreturn null;\n}\n@@ -34,7 +32,7 @@ async function userSubscriptionUpdater(\nSET subscription = ${JSON.stringify(newSubscription)}\nWHERE user = ${viewer.id} AND thread = ${update.threadID}\n`;\n- await conn.query(saveQuery);\n+ await pool.query(saveQuery);\nreturn newSubscription;\n}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Move node to using connection pooling Side benefit is we don't need to pass the connection around or end it...
129,187
08.02.2018 15:01:22
18,000
eb92aa4e02d990efaad31a790a37b86e4ee896ca
Don't block message creation on notification sends
[ { "change_type": "MODIFY", "old_path": "jserver/src/creators/message-creator.js", "new_path": "jserver/src/creators/message-creator.js", "diff": "@@ -150,15 +150,16 @@ async function createMessages(\nINSERT INTO messages(id, thread, user, type, content, time)\nVALUES ${messageInsertRows}\n`;\n- await Promise.all([\n- pool.query(messageInsertQuery),\n- updateUnreadStatus(threadRestrictions),\n+ // This returns a Promise but we don't want to wait on it\nsendPushNotifsForNewMessages(\nthreadRestrictions,\nsubthreadPermissionsToCheck,\nthreadsToMessageIndices,\nmessageInfos,\n- ),\n+ );\n+ await Promise.all([\n+ pool.query(messageInsertQuery),\n+ updateUnreadStatus(threadRestrictions),\n]);\nreturn messageInfos;\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Don't block message creation on notification sends
129,187
09.02.2018 12:20:34
18,000
bb458b87e7e83ae8b347718e32b9ae5738881053
Fix up flow-mono postinstall scripts
[ { "change_type": "MODIFY", "old_path": "jserver/package.json", "new_path": "jserver/package.json", "diff": "\"description\": \"\",\n\"main\": \"dist/app\",\n\"scripts\": {\n+ \"postinstall\": \"cd ../; npx flow-mono create-symlinks jserver/.flowconfig\",\n\"babel\": \"babel src/ --out-dir dist/ --ignore 'lib/flow-typed','lib/node_modules','lib/package.json','lib/package-lock.json' --copy-files\",\n\"prod\": \"node --experimental-modules --loader ./loader.mjs dist/app\",\n\"dev\": \"concurrently \\\"npm run babel -- --watch\\\" \\\"nodemon -e js,json --watch dist --experimental-modules --loader ./loader.mjs dist/app\\\"\"\n" }, { "change_type": "MODIFY", "old_path": "lib/package.json", "new_path": "lib/package.json", "diff": "\"flow-bin\": \"^0.64.0\"\n},\n\"scripts\": {\n+ \"postinstall\": \"cd ../; npx flow-mono create-symlinks lib/.flowconfig\",\n\"flow\": \"flow; test $? -eq 0 -o $? -eq 2\"\n},\n\"dependencies\": {\n" }, { "change_type": "MODIFY", "old_path": "native/package.json", "new_path": "native/package.json", "diff": "\"version\": \"0.0.1\",\n\"private\": true,\n\"scripts\": {\n+ \"postinstall\": \"cd ../; npx flow-mono create-symlinks native/.flowconfig\",\n\"start\": \"node node_modules/react-native/local-cli/cli.js start\",\n\"test\": \"jest\",\n\"devtools\": \"react-devtools\",\n" }, { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "],\n\"devDependencies\": {\n\"flow-mono-cli\": \"^1.3.0\"\n- },\n- \"scripts\": {\n- \"postinstall\": \"flow-mono create-symlinks lib/.flowconfig && flow-mono create-symlinks web/.flowconfig && flow-mono create-symlinks native/.flowconfig && flow-mono create-symlinks jserver/.flowconfig\"\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "web/package.json", "new_path": "web/package.json", "diff": "\"concurrently\": \"^3.5.1\"\n},\n\"scripts\": {\n+ \"postinstall\": \"cd ../; npx flow-mono create-symlinks web/.flowconfig\",\n\"dev\": \"concurrently \\\"webpack --env dev --progress --watch\\\" \\\"webpack-dev-server\\\"\",\n\"prod\": \"webpack --env prod --progress\",\n\"flow\": \"flow; test $? -eq 0 -o $? -eq 2\"\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Fix up flow-mono postinstall scripts
129,187
11.02.2018 20:25:57
18,000
964327836c2ff20c856d26c689509f2e11f8cd0f
Get rid of setTimeout hack to avoid RN issue Also some npm scripts and updating some versions
[ { "change_type": "MODIFY", "old_path": "native/chat/settings/thread-settings-member.react.js", "new_path": "native/chat/settings/thread-settings-member.react.js", "diff": "@@ -114,14 +114,14 @@ class ThreadSettingsMember extends React.PureComponent<Props, State> {\n)\n)\n) {\n- result.push({ label: \"Remove user\", onPress: this.onPressRemoveUser });\n+ result.push({ label: \"Remove user\", onPress: this.showRemoveUserConfirmation });\n}\nif (canChangeRoles && props.memberInfo.username) {\nconst adminText = ThreadSettingsMember.memberIsAdmin(props)\n? \"Remove admin\"\n: \"Make admin\";\n- result.push({ label: adminText, onPress: this.onPressMakeAdmin });\n+ result.push({ label: adminText, onPress: this.showMakeAdminConfirmation });\n}\nreturn result;\n@@ -207,15 +207,6 @@ class ThreadSettingsMember extends React.PureComponent<Props, State> {\n);\n}\n- onPressRemoveUser = () => {\n- if (Platform.OS === \"ios\") {\n- // https://github.com/facebook/react-native/issues/10471\n- setTimeout(this.showRemoveUserConfirmation, 500);\n- } else {\n- this.showRemoveUserConfirmation();\n- }\n- }\n-\nshowRemoveUserConfirmation = () => {\nconst userText = stringForUser(this.props.memberInfo);\nAlert.alert(\n@@ -245,15 +236,6 @@ class ThreadSettingsMember extends React.PureComponent<Props, State> {\n);\n}\n- onPressMakeAdmin = () => {\n- if (Platform.OS === \"ios\") {\n- // https://github.com/facebook/react-native/issues/10471\n- setTimeout(this.showMakeAdminConfirmation, 500);\n- } else {\n- this.showMakeAdminConfirmation();\n- }\n- }\n-\nshowMakeAdminConfirmation = () => {\nconst userText = stringForUser(this.props.memberInfo);\nconst actionClause = ThreadSettingsMember.memberIsAdmin(this.props)\n" }, { "change_type": "MODIFY", "old_path": "native/package.json", "new_path": "native/package.json", "diff": "\"version\": \"0.0.1\",\n\"private\": true,\n\"scripts\": {\n- \"postinstall\": \"cd ../; npx flow-mono create-symlinks native/.flowconfig\",\n+ \"postinstall\": \"cd ../; npx flow-mono create-symlinks native/.flowconfig && rm node_modules/react-native/local-cli/core/__fixtures__/files/package.json\",\n\"start\": \"node node_modules/react-native/local-cli/cli.js start\",\n\"test\": \"jest\",\n\"devtools\": \"react-devtools\",\n\"react-native-modal\": \"^4.0.0\",\n\"react-native-notifications\": \"git+https://git@github.com/ashoat/react-native-notifications.git\",\n\"react-native-onepassword\": \"^1.0.6\",\n- \"react-native-popover-tooltip\": \"^1.1.4\",\n+ \"react-native-popover-tooltip\": \"git+https://git@github.com/ashoat/react-native-popover-tooltip.git\",\n\"react-native-segmented-control-tab\": \"^3.2.1\",\n\"react-native-vector-icons\": \"^4.5.0\",\n- \"react-navigation\": \"^1.0.2\",\n- \"react-navigation-redux-helpers\": \"^1.0.0\",\n+ \"react-navigation\": \"^1.0.3\",\n+ \"react-navigation-redux-helpers\": \"^1.0.1\",\n\"react-redux\": \"^5.0.6\",\n\"redux\": \"^3.7.2\",\n\"redux-devtools-extension\": \"^2.13.2\",\n" }, { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "],\n\"devDependencies\": {\n\"flow-mono-cli\": \"^1.3.0\"\n+ },\n+ \"scripts\": {\n+ \"clean\": \"rm -rf node_modules/ && rm -rf lib/node_modules/ && rm -rf web/node_modules/ && rm -rf native/node_modules/ && rm -rf jserver/node_modules/\",\n+ \"cleaninstall\": \"rm -rf node_modules/ && rm -rf lib/node_modules/ && rm -rf web/node_modules/ && rm -rf native/node_modules/ && rm -rf jserver/node_modules/ && yarn\"\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "yarn.lock", "new_path": "yarn.lock", "diff": "@@ -7299,9 +7299,9 @@ react-native-onepassword@^1.0.6:\ndependencies:\n\"1PasswordExtension\" \"git+https://github.com/jjshammas/onepassword-app-extension.git\"\n-react-native-popover-tooltip@^1.1.4:\n+\"react-native-popover-tooltip@git+https://git@github.com/ashoat/react-native-popover-tooltip.git\":\nversion \"1.1.4\"\n- resolved \"https://registry.yarnpkg.com/react-native-popover-tooltip/-/react-native-popover-tooltip-1.1.4.tgz#f6f2121e6725e9da2c014a33b946162c197a4eb4\"\n+ resolved \"git+https://git@github.com/ashoat/react-native-popover-tooltip.git#26b8eef75ade5afcbe45ea0393f8618f15020e7d\"\ndependencies:\ninvariant \"^2.2.2\"\nprop-types \"^15.6.0\"\n@@ -7395,15 +7395,15 @@ react-native@^0.52.0:\nxmldoc \"^0.4.0\"\nyargs \"^9.0.0\"\n-react-navigation-redux-helpers@^1.0.0:\n+react-navigation-redux-helpers@^1.0.1:\nversion \"1.0.1\"\nresolved \"https://registry.yarnpkg.com/react-navigation-redux-helpers/-/react-navigation-redux-helpers-1.0.1.tgz#1d98cb6364ebdf98a90d34aa7b4592b9073d76e2\"\ndependencies:\ninvariant \"^2.2.2\"\n-react-navigation@^1.0.2:\n- version \"1.0.2\"\n- resolved \"https://registry.yarnpkg.com/react-navigation/-/react-navigation-1.0.2.tgz#a945d4342e5f713d9000414deeb1ebff4cfa6798\"\n+react-navigation@^1.0.3:\n+ version \"1.0.3\"\n+ resolved \"https://registry.yarnpkg.com/react-navigation/-/react-navigation-1.0.3.tgz#1687ea67a72a382633b01e7afda88582ebc3b5f9\"\ndependencies:\nclamp \"^1.0.1\"\nhoist-non-react-statics \"^2.2.0\"\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Get rid of setTimeout hack to avoid RN issue #10471 Also some npm scripts and updating some versions
129,187
12.02.2018 13:10:54
18,000
9566574f50fbf9dc79c50293af1af6058d7cd562
Fix emailVerified field of CurrentUserInfo
[ { "change_type": "MODIFY", "old_path": "server/user_lib.php", "new_path": "server/user_lib.php", "diff": "@@ -70,6 +70,6 @@ SQL;\n'id' => (string)$viewer_id,\n'username' => $user_row['username'],\n'email' => $user_row['email'],\n- 'email_verified' => (bool)$user_row['email_verified'],\n+ 'emailVerified' => (bool)$user_row['email_verified'],\n);\n}\n" } ]
JavaScript
BSD 3-Clause New or Revised License
comme2e/comm
Fix emailVerified field of CurrentUserInfo