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 |
|---|---|---|---|---|---|---|---|---|---|
263,096 | 06.12.2022 09:14:52 | -3,600 | e2301653c3ed286cb08e807e38c1ad4f91b7646c | check if plaso is not installed to err out | [
{
"change_type": "MODIFY",
"old_path": "timesketch/tsctl.py",
"new_path": "timesketch/tsctl.py",
"diff": "@@ -455,8 +455,11 @@ def info():\nprint(f\"Timesketch version: {version.get_version()}\")\n# Get plaso version\n+ try:\noutput = subprocess.check_output([\"psort.py\", \"--version\"])\nprint(output.decode(\"utf-8\"))\n+ except FileNotFoundError:\n+ print(\"psort.py not installed\")\n# Get installed node version\noutput = subprocess.check_output([\"node\", \"--version\"]).decode(\"utf-8\")\n"
}
] | Python | Apache License 2.0 | google/timesketch | check if plaso is not installed to err out (#2446) |
263,093 | 16.12.2022 17:20:58 | -3,600 | c68cb167afe67472d795f0b274a7cd23a06422fc | Consistent colors on hover | [
{
"change_type": "MODIFY",
"old_path": "timesketch/frontend-ng/src/assets/main.scss",
"new_path": "timesketch/frontend-ng/src/assets/main.scss",
"diff": "@@ -125,7 +125,7 @@ html {\n}\n.dark-hover:hover {\n- background-color: #555;\n+ background-color: #303030;\n}\n.light-hover-on-highlight:hover {\n@@ -133,7 +133,7 @@ html {\n}\n.dark-hover-on-highlight:hover {\n- background-color: rgb(66, 66, 66);\n+ background-color: #393838;\n}\n.light-highlight {\n@@ -141,7 +141,7 @@ html {\n}\n.dark-highlight {\n- background-color: #555;\n+ background-color: #303030;\n}\n.timeline-name-ellipsis {\n@@ -150,3 +150,11 @@ html {\noverflow: hidden;\ntext-overflow: ellipsis\n}\n+\n+.theme--dark.v-navigation-drawer {\n+ background-color: #1e1e1e;\n+}\n+\n+.theme--dark.v-data-table tbody tr:hover:not(.v-data-table__expanded__content) {\n+ background: #303030 !important;\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "timesketch/frontend-ng/src/views/Explore.vue",
"new_path": "timesketch/frontend-ng/src/views/Explore.vue",
"diff": "@@ -243,7 +243,7 @@ limitations under the License.\n<v-card\nv-if=\"eventList.objects.length || (searchInProgress && this.currentQueryFilter.indices.length)\"\nflat\n- class=\"mt-3\"\n+ class=\"mt-3 mx-3\"\n>\n<v-data-table\nv-model=\"selectedEvents\"\n"
},
{
"change_type": "MODIFY",
"old_path": "timesketch/frontend-ng/src/views/Sketch.vue",
"new_path": "timesketch/frontend-ng/src/views/Sketch.vue",
"diff": "@@ -17,7 +17,7 @@ limitations under the License.\n<div v-if=\"sketch\">\n<!-- Top horizontal toolbar -->\n<v-toolbar flat color=\"transparent\">\n- <v-avatar v-show=\"!showLeftPanel\" class=\"mt-2 ml-n1\">\n+ <v-avatar v-show=\"!showLeftPanel\" class=\"ml-n1\">\n<router-link to=\"/\">\n<v-img src=\"/dist/timesketch-color.png\" max-height=\"25\" max-width=\"25\" contain></v-img>\n</router-link>\n@@ -87,7 +87,7 @@ limitations under the License.\n<v-navigation-drawer app permanent :width=\"navigationDrawer.width\" hide-overlay ref=\"drawer\">\n<div v-show=\"showLeftPanel\">\n<v-toolbar flat>\n- <v-avatar class=\"mt-2 ml-n3\">\n+ <v-avatar class=\"ml-n3\">\n<router-link to=\"/\">\n<v-img src=\"/dist/timesketch-color.png\" max-height=\"25\" max-width=\"25\" contain></v-img>\n</router-link>\n"
}
] | Python | Apache License 2.0 | google/timesketch | Consistent colors on hover (#2464) |
263,171 | 16.12.2022 17:28:31 | -3,600 | eab3496dcf0e4257a44cd0a9443e7bde3d579052 | Add proxy_read_timeout in gninx conf
Some requests can take long time | [
{
"change_type": "MODIFY",
"old_path": "contrib/nginx.conf",
"new_path": "contrib/nginx.conf",
"diff": "@@ -11,6 +11,7 @@ http {\nproxy_buffer_size 128k;\nproxy_buffers 4 256k;\nproxy_busy_buffers_size 256k;\n+ proxy_read_timeout 120s;\nproxy_pass http://timesketch-web:5000;\nproxy_set_header Host $host;\nproxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n@@ -20,6 +21,7 @@ http {\nproxy_buffer_size 128k;\nproxy_buffers 4 256k;\nproxy_busy_buffers_size 256k;\n+ proxy_read_timeout 120s;\nproxy_pass http://timesketch-web-v2:5000;\nproxy_set_header Host $host;\nproxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n"
}
] | Python | Apache License 2.0 | google/timesketch | Add proxy_read_timeout in gninx conf (#2466)
Some requests can take long time
Co-authored-by: Johan Berggren <jberggren@gmail.com> |
263,096 | 16.12.2022 17:49:37 | -3,600 | a985c0c673be2daaa2dcb2216cc89b1b57aebf3e | Adding a trailing /
I confirmed applying that fix manually on a system installed with
chmod 755 deploy_timesketch.sh worked | [
{
"change_type": "MODIFY",
"old_path": "contrib/nginx.conf",
"new_path": "contrib/nginx.conf",
"diff": "@@ -11,8 +11,8 @@ http {\nproxy_buffer_size 128k;\nproxy_buffers 4 256k;\nproxy_busy_buffers_size 256k;\n+ proxy_pass http://timesketch-web:5000/;\nproxy_read_timeout 120s;\n- proxy_pass http://timesketch-web:5000;\nproxy_set_header Host $host;\nproxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\nproxy_set_header X-Forwarded-Proto $scheme;\n@@ -21,8 +21,8 @@ http {\nproxy_buffer_size 128k;\nproxy_buffers 4 256k;\nproxy_busy_buffers_size 256k;\n+ proxy_pass http://timesketch-web-v2:5000/;\nproxy_read_timeout 120s;\n- proxy_pass http://timesketch-web-v2:5000;\nproxy_set_header Host $host;\nproxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\nproxy_set_header X-Forwarded-Proto $scheme;\n"
}
] | Python | Apache License 2.0 | google/timesketch | Adding a trailing / (#2455)
https://github.com/google/timesketch/issues/2363
I confirmed applying that fix manually on a system installed with https://raw.githubusercontent.com/google/timesketch/master/contrib/deploy_timesketch.sh
chmod 755 deploy_timesketch.sh worked
Co-authored-by: Johan Berggren <jberggren@gmail.com> |
263,151 | 16.12.2022 23:43:06 | -3,600 | ec87b55c307f2e66f2cb88704c3ec96a046e8a6f | MISP and Hashlookup analyzers | [
{
"change_type": "MODIFY",
"old_path": "data/timesketch.conf",
"new_path": "data/timesketch.conf",
"diff": "@@ -262,6 +262,16 @@ YETI_API_KEY = ''\n# Labels to narrow down indicator selection\nYETI_INDICATOR_LABELS = ['domain']\n+\n+# Url to MISP instance\n+MISP_URL = ''\n+\n+# API key to authenticate requests\n+MISP_API_KEY = ''\n+\n+# Url to Hashlookup instance\n+HASHLOOKUP_URL = ''\n+\n# GeoIP Analyzer Settings\n#\n# Disclaimer: Please note that the geolocation results obtained from this analyzer\n"
},
{
"change_type": "MODIFY",
"old_path": "timesketch/lib/analyzers/contrib/__init__.py",
"new_path": "timesketch/lib/analyzers/contrib/__init__.py",
"diff": "# limitations under the License.\n\"\"\"Contrib Analyzer module.\"\"\"\nfrom timesketch.lib.analyzers.contrib import bigquery_matcher\n+from timesketch.lib.analyzers.contrib import misp_analyzer\n+from timesketch.lib.analyzers.contrib import hashlookup_analyzer\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "timesketch/lib/analyzers/contrib/hashlookup_analyzer.py",
"diff": "+\"\"\"Index analyzer plugin for Hashlookup.\"\"\"\n+\n+import logging\n+\n+from flask import current_app\n+import requests\n+\n+from timesketch.lib.analyzers import interface\n+from timesketch.lib.analyzers import manager\n+from timesketch.lib import emojis\n+\n+\n+logger = logging.getLogger(\"timesketch.analyzers.hashlookup\")\n+\n+\n+class HashlookupAnalyzer(interface.BaseAnalyzer):\n+ \"\"\"Analyzer for Hashlookup.\"\"\"\n+\n+ NAME = \"hashlookup_analyzer\"\n+ DISPLAY_NAME = \"Hashlookup\"\n+ DESCRIPTION = \"Mark events using Hashlookup\"\n+\n+ def __init__(self, index_name, sketch_id, timeline_id=None, **kwargs):\n+ \"\"\"Initialize the Analyzer.\n+\n+ Args:\n+ index_name: OpenSearch index name\n+ sketch_id: The ID of the sketch.\n+ timeline_id: The ID of the timeline.\n+ \"\"\"\n+ super().__init__(index_name, sketch_id, timeline_id=timeline_id)\n+ self.hashlookup_url = kwargs.get(\"hashlookup_url\")\n+ self.total_event_counter = 0\n+ self.request_set = set()\n+ self.result_dict = dict()\n+\n+ @staticmethod\n+ def get_kwargs():\n+ \"\"\"Get kwargs for the analyzer.\n+\n+ Returns:\n+ Info to connect to Hashlookup.\n+ \"\"\"\n+\n+ hashlookup_url = current_app.config.get(\"HASHLOOKUP_URL\")\n+\n+ if not hashlookup_url:\n+ logger.error(\"Hashlookup conf not found\")\n+ return []\n+\n+ matcher_kwargs = [{\"hashlookup_url\": hashlookup_url}]\n+ return matcher_kwargs\n+\n+ def get_hash_info(self, hash_value):\n+ \"\"\"Search event on Hashlookup.\n+\n+ Args:\n+ hash_value: hash value that will be check\n+ if it's a known one on hashlookup.\n+\n+ Returns:\n+ JSON of Hashlookup's results.\n+ \"\"\"\n+ results = requests.get(f\"{self.hashlookup_url}sha256/{hash_value}\")\n+\n+ result_loc = results.json()\n+ if not \"message\" in result_loc and results.status_code != 200:\n+ logger.error(\"Error with Hashlookup url\")\n+ return []\n+ # If message in result_loc then the hash is not find in Hashlookup\n+ if \"message\" in result_loc:\n+ return []\n+\n+ return result_loc\n+\n+ def mark_event(self, event, hash_value):\n+ \"\"\"Annotate an event with data from Hashlookup.\n+\n+ Tags with validate emoji, adds a comment to the event.\n+\n+ Args:\n+ event: The OpenSearch event object that contains this hash and needs\n+ to be tagged or to add an attribute.\n+ hash_value: A string of a sha256 hash value.\n+ \"\"\"\n+\n+ event.add_comment(f\"{self.hashlookup_url}sha256/{hash_value}\")\n+\n+ event.add_tags([\"Hashlookup\"])\n+ event.add_emojis([emojis.get_emoji(\"VALIDATE\")])\n+ event.commit()\n+\n+ def query_hashlookup(self, query, return_fields):\n+ \"\"\"Get event from timesketch, request Hashlookup and mark event.\n+\n+ Args:\n+ query: Search for all events that contains sha256 value.\n+ return_fields: Fields return with a matching event.\n+ \"\"\"\n+\n+ events = self.event_stream(query_string=query, return_fields=return_fields)\n+ create_a_view = False\n+ for event in events:\n+ hash_value = None\n+ for key in return_fields:\n+ if key in event.source.keys():\n+ hash_value = event.source.get(key)\n+ break\n+\n+ if len(hash_value) != 64:\n+ logger.warning(\n+ \"The extracted hash does not match the required \"\n+ \"length (64) of a SHA256 hash. Skipping this \"\n+ \"event! Hash: %s - Length: %d\",\n+ hash_value,\n+ len(hash_value),\n+ )\n+ error_hash_counter += 1\n+ continue\n+\n+ if not hash_value in self.request_set:\n+ result = self.get_hash_info(hash_value)\n+ if result:\n+ self.total_event_counter += 1\n+ create_a_view = True\n+ self.mark_event(event, hash_value)\n+ self.result_dict[hash_value] = True\n+ else:\n+ self.result_dict[hash_value] = False\n+ self.request_set.add(hash_value)\n+ elif self.result_dict[hash_value]:\n+ self.total_event_counter += 1\n+ self.mark_event(event, hash_value)\n+\n+ if create_a_view:\n+ self.sketch.add_view(\n+ view_name=\"Hashlookup\",\n+ analyzer_name=self.NAME,\n+ query_string=('tag:\"Hashlookup\"'),\n+ )\n+\n+ def run(self):\n+ \"\"\"Entry point for the analyzer.\n+\n+ Returns:\n+ String with summary of the analyzer result\n+ \"\"\"\n+ if not self.hashlookup_url:\n+ return \"No Hashlookup configuration settings found, aborting.\"\n+\n+ # Note: Add fieldnames that contain sha256 values in your events.\n+ query = (\n+ \"_exists_:hash_sha256 OR _exists_:sha256 OR _exists_:hash OR \"\n+ \"_exists_:sha256_hash\"\n+ )\n+\n+ # Note: Add fieldnames that contain sha256 values in your events.\n+ return_fields = [\"hash_sha256\", \"hash\", \"sha256\", \"sha256_hash\"]\n+ self.query_hashlookup(query, return_fields)\n+\n+ return f\"Hashlookup Matches: {self.total_event_counter}\"\n+\n+\n+manager.AnalysisManager.register_analyzer(HashlookupAnalyzer)\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "timesketch/lib/analyzers/contrib/hashlookup_analyzer_test.py",
"diff": "+\"\"\"Test for Hashlookup\"\"\"\n+\n+import copy\n+import mock\n+\n+from flask import current_app\n+\n+from timesketch.lib.analyzers.contrib import hashlookup_analyzer\n+from timesketch.lib.testlib import BaseTest\n+from timesketch.lib.testlib import MockDataStore\n+\n+SHA256_HASH = \"ac7233de5daa4ab262e2e751028f56a7e9d5b9e724624c1d55e8b070d8c3cd09\"\n+SHA256_N_HASH = \"bc7233de5daa4ab262e2e751028f56a7e9d5b9e724624c1d55e8b070d8c3cd09\"\n+MATCHING_HASH = {\"sha256_hash\": SHA256_HASH}\n+NO_MATCHING_HASH = {\"sha256_hash\": SHA256_N_HASH}\n+\n+\n+class TestHashlookup(BaseTest):\n+ \"\"\"Tests the functionality of the analyzer.\"\"\"\n+\n+ def setUp(self):\n+ super().setUp()\n+ current_app.config[\"HASHLOOKUP_URL\"] = \"https://test.com/\"\n+\n+ @mock.patch(\"timesketch.lib.analyzers.interface.OpenSearchDataStore\", MockDataStore)\n+ @mock.patch(\"requests.get\")\n+ def test_hash_match(self, mock_requests_get):\n+ \"\"\"Test match\"\"\"\n+ analyzer = hashlookup_analyzer.HashlookupAnalyzer(\"test_index\", 1)\n+ analyzer.hashlookup_url = \"https://test.com/\"\n+ analyzer.datastore.client = mock.Mock()\n+ mock_requests_get.return_value.status_code = 200\n+ mock_requests_get.return_value.json.return_value = {\"FileName\": \"test.txt\"}\n+\n+ event = copy.deepcopy(MockDataStore.event_dict)\n+ event[\"_source\"].update(MATCHING_HASH)\n+ analyzer.datastore.import_event(\"test_index\", event[\"_source\"], \"0\")\n+\n+ message = analyzer.run()\n+ self.assertEqual(\n+ message,\n+ (\"Hashlookup Matches: 1\"),\n+ )\n+ url = f\"https://test.com/sha256/{SHA256_HASH}\"\n+ mock_requests_get.assert_called_with(url)\n+\n+ @mock.patch(\"timesketch.lib.analyzers.interface.OpenSearchDataStore\", MockDataStore)\n+ @mock.patch(\"requests.get\")\n+ def test_hash_nomatch(self, mock_requests_get):\n+ \"\"\"Test no match\"\"\"\n+ analyzer = hashlookup_analyzer.HashlookupAnalyzer(\"test_index\", 1)\n+ analyzer.hashlookup_url = \"https://test.com/\"\n+ analyzer.datastore.client = mock.Mock()\n+ mock_requests_get.return_value.status_code = 404\n+ mock_requests_get.return_value.json.return_value = []\n+\n+ event = copy.deepcopy(MockDataStore.event_dict)\n+ event[\"_source\"].update(NO_MATCHING_HASH)\n+ analyzer.datastore.import_event(\"test_index\", event[\"_source\"], \"0\")\n+\n+ message = analyzer.run()\n+ self.assertEqual(\n+ message,\n+ (\"Hashlookup Matches: 0\"),\n+ )\n+ url = f\"https://test.com/sha256/{SHA256_N_HASH}\"\n+ mock_requests_get.assert_called_with(url)\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "timesketch/lib/analyzers/contrib/misp_analyzer.py",
"diff": "+\"\"\"Index analyzer plugin for MISP.\"\"\"\n+\n+import logging\n+import ntpath\n+import requests\n+\n+from flask import current_app\n+from timesketch.lib.analyzers import interface\n+from timesketch.lib.analyzers import manager\n+\n+\n+logger = logging.getLogger(\"timesketch.analyzers.misp\")\n+\n+\n+class MispAnalyzer(interface.BaseAnalyzer):\n+ \"\"\"Analyzer for MISP.\"\"\"\n+\n+ NAME = \"misp_analyzer\"\n+ DISPLAY_NAME = \"MISP\"\n+ DESCRIPTION = \"Mark events using MISP\"\n+\n+\n+ def __init__(self, index_name, sketch_id, timeline_id=None, **kwargs):\n+ \"\"\"Initialize the Analyzer.\n+\n+ Args:\n+ index_name: OpenSearch index name\n+ sketch_id: The ID of the sketch.\n+ timeline_id: The ID of the timeline.\n+ \"\"\"\n+ super().__init__(index_name, sketch_id, timeline_id=timeline_id)\n+ self.misp_url = kwargs.get(\"misp_url\")\n+ self.misp_api_key = kwargs.get(\"misp_api_key\")\n+ self.total_event_counter = 0\n+ self.request_set = set()\n+ self.result_dict = dict()\n+\n+ @staticmethod\n+ def get_kwargs():\n+ \"\"\"Get kwargs for the analyzer.\n+\n+ Returns:\n+ Info to connect to MISP.\n+ \"\"\"\n+\n+ misp_url = current_app.config.get(\"MISP_URL\")\n+ misp_api_key = current_app.config.get(\"MISP_API_KEY\")\n+\n+ if not misp_api_key or not misp_url:\n+ logger.error(\"MISP conf not found\")\n+ return []\n+\n+ matcher_kwargs = [{\"misp_url\": misp_url, \"misp_api_key\": misp_api_key}]\n+ return matcher_kwargs\n+\n+ def get_misp_attributes(self, value, attr):\n+ \"\"\"Search event on MISP.\n+\n+ Args:\n+ value: Can be a valur for: sha1 - sha256 - md5 - filename.\n+ attr: type of the value.\n+\n+ Returns:\n+ List of matching MISP attibutes.\n+ \"\"\"\n+ results = requests.post(\n+ f\"{self.misp_url}/attributes/restSearch/\",\n+ data={\"returnFormat\": \"json\", \"value\": value, \"type\": attr},\n+ headers={\"Authorization\": self.misp_api_key},\n+ verify=False,\n+ )\n+\n+ if results.status_code != 200:\n+ msg_error = \"Error with MISP query: Status code\"\n+ logger.error(\"{} {}\".format(msg_error, results.status_code))\n+ # logger.error(f\"{msg_error} {results.status_code}\")\n+ return []\n+ result_loc = results.json()\n+ if \"name\" in result_loc:\n+ if \"Authentication failed.\" in result_loc[\"name\"]:\n+ logger.error(\"Bad API key. Please change it.\")\n+ return []\n+ if not result_loc[\"response\"][\"Attribute\"]:\n+ return []\n+\n+ return result_loc[\"response\"][\"Attribute\"]\n+\n+ def mark_event(self, event, result, attr):\n+ \"\"\"Anotate an event with data from MISP result.\n+\n+ Add a comment to the event.\n+\n+ Args:\n+ event: The OpenSearch event object that contains type of value we search\n+ for and needs to be tagged or to add an attribute.\n+ result: Dictionnary with results from MISP.\n+ attr: type of the current value.\n+ \"\"\"\n+\n+ msg = \"Event that match files: \"\n+ for misp_attr in result:\n+ info = misp_attr[\"Event\"][\"info\"]\n+ id_event = misp_attr[\"Event\"][\"id\"]\n+ msg += f'\"Event info\": \"{info}\"'\n+ msg += f'- \"url\": {self.misp_url}/events/view/{id_event} || '\n+\n+ event.add_comment(msg)\n+ event.add_tags([f\"MISP-{attr}\"])\n+ event.commit()\n+\n+ def query_misp(self, query, attr, timesketch_attr):\n+ \"\"\"Get event from timesketch, request MISP and mark event.\n+\n+ Args:\n+ query: Search for all events that contains 'timesketch_attr' value.\n+ attr: type of the current value.\n+ timesketch_attr: type of the current value in timesketch format.\n+ \"\"\"\n+ events = self.event_stream(query_string=query, return_fields=[timesketch_attr])\n+ create_a_view = False\n+ for event in events:\n+ loc = event.source.get(timesketch_attr)\n+ if loc:\n+ if attr == \"filename\":\n+ loc = ntpath.basename(loc)\n+ if not loc:\n+ _, loc = ntpath.split(event.source.get(timesketch_attr))\n+\n+ if not loc in self.request_set:\n+ result = self.get_misp_attributes(loc, attr)\n+ if result:\n+ self.total_event_counter += 1\n+ create_a_view = True\n+ self.mark_event(event, result, attr)\n+ self.result_dict[f\"{attr}:{loc}\"] = result\n+ else:\n+ self.result_dict[f\"{attr}:{loc}\"] = False\n+ self.request_set.add(loc)\n+ elif self.result_dict[f\"{attr}:{loc}\"]:\n+ self.total_event_counter += 1\n+ self.mark_event(event, self.result_dict[f\"{attr}:{loc}\"], attr)\n+\n+ if create_a_view:\n+ self.sketch.add_view(\n+ view_name=\"MISP known attribute\",\n+ analyzer_name=self.NAME,\n+ query_string='tag:\"MISP\"',\n+ )\n+\n+ def run(self):\n+ \"\"\"Entry point for the analyzer.\n+\n+ Returns:\n+ String with summary of the analyzer result\n+ \"\"\"\n+ if not self.misp_url or not self.misp_api_key:\n+ return \"No MISP configuration settings found, aborting.\"\n+\n+ query_sha = \"md5_hash:*\"\n+ self.query_misp(query_sha, \"md5\", \"md5_hash\")\n+\n+ query_sha = \"sha1_hash:*\"\n+ self.query_misp(query_sha, \"sha1\", \"sha1_hash\")\n+\n+ query_sha = \"sha256_hash:*\"\n+ self.query_misp(query_sha, \"sha256\", \"sha256_hash\")\n+\n+ query = \"filename:*\"\n+ self.query_misp(query, \"filename\", \"filename\")\n+\n+ return f\"MISP Match: {self.total_event_counter}\"\n+\n+\n+manager.AnalysisManager.register_analyzer(MispAnalyzer)\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "timesketch/lib/analyzers/contrib/misp_analyzer_test.py",
"diff": "+\"\"\"Test for MISP\"\"\"\n+\n+import copy\n+import mock\n+\n+from flask import current_app\n+\n+from timesketch.lib.analyzers.contrib import misp_analyzer\n+from timesketch.lib.testlib import BaseTest\n+from timesketch.lib.testlib import MockDataStore\n+\n+SHA256_VALUE = \"ac7233de5daa4ab262e2e751028f56a7e9d5b9e724624c1d55e8b070d8c3cd09\"\n+MISP_ATTR = {\n+ \"response\": {\n+ \"Attribute\": [\n+ {\n+ \"event_id\": \"5\",\n+ \"category\": \"Payload delivery\",\n+ \"type\": \"filename\",\n+ \"value\": \"test.txt\",\n+ \"Event\": {\n+ \"org_id\": \"1\",\n+ \"id\": \"5\",\n+ \"info\": \"Hash Test\",\n+ \"uuid\": \"1f456b69-00c6-4fb0-8d92-709a0061b7d4\",\n+ },\n+ },\n+ ]\n+ }\n+}\n+MATCHING_MISP = {\"filename\": \"test.txt\"}\n+\n+\n+class TestMisp(BaseTest):\n+ \"\"\"Tests the functionality of the analyzer.\"\"\"\n+\n+ def setUp(self):\n+ super().setUp()\n+ current_app.config[\"MISP_URL\"] = \"https://test.com/\"\n+ current_app.config[\"MISP_API_KEY\"] = \"test\"\n+\n+ @mock.patch(\"timesketch.lib.analyzers.interface.OpenSearchDataStore\", MockDataStore)\n+ @mock.patch(\"requests.post\")\n+ def test_attr_match(self, mock_requests_post):\n+ \"\"\"Test match\"\"\"\n+ analyzer = misp_analyzer.MispAnalyzer(\"test_index\", 1)\n+ analyzer.misp_url = \"https://test.com/\"\n+ analyzer.misp_api_key = \"test\"\n+ analyzer.datastore.client = mock.Mock()\n+ mock_requests_post.return_value.status_code = 200\n+ mock_requests_post.return_value.json.return_value = MISP_ATTR\n+\n+ event = copy.deepcopy(MockDataStore.event_dict)\n+ event[\"_source\"].update(MATCHING_MISP)\n+ analyzer.datastore.import_event(\"test_index\", event[\"_source\"], \"0\")\n+\n+ message = analyzer.run()\n+ self.assertEqual(\n+ message,\n+ (\"MISP Match: 1\"),\n+ )\n+ mock_requests_post.assert_called_with(\n+ \"https://test.com//attributes/restSearch/\",\n+ data={\"returnFormat\": \"json\", \"value\": \"test.txt\", \"type\": \"filename\"},\n+ headers={\"Authorization\": \"test\"},\n+ verify=False,\n+ )\n+\n+ @mock.patch(\"timesketch.lib.analyzers.interface.OpenSearchDataStore\", MockDataStore)\n+ @mock.patch(\"requests.post\")\n+ def test_attr_nomatch(self, mock_requests_post):\n+ \"\"\"Test no match\"\"\"\n+ analyzer = misp_analyzer.MispAnalyzer(\"test_index\", 1)\n+ analyzer.misp_url = \"https://test.com/\"\n+ analyzer.misp_api_key = \"test\"\n+ analyzer.datastore.client = mock.Mock()\n+ mock_requests_post.return_value.status_code = 200\n+ mock_requests_post.return_value.json.return_value = {\n+ \"response\": {\"Attribute\": []}\n+ }\n+\n+ event = copy.deepcopy(MockDataStore.event_dict)\n+ event[\"_source\"].update(MATCHING_MISP)\n+ analyzer.datastore.import_event(\"test_index\", event[\"_source\"], \"0\")\n+\n+ message = analyzer.run()\n+ self.assertEqual(\n+ message,\n+ (\"MISP Match: 0\"),\n+ )\n+ mock_requests_post.assert_called_with(\n+ \"https://test.com//attributes/restSearch/\",\n+ data={\"returnFormat\": \"json\", \"value\": \"test.txt\", \"type\": \"filename\"},\n+ headers={\"Authorization\": \"test\"},\n+ verify=False,\n+ )\n"
},
{
"change_type": "MODIFY",
"old_path": "timesketch/lib/emojis.py",
"new_path": "timesketch/lib/emojis.py",
"diff": "@@ -25,6 +25,7 @@ emoji = collections.namedtuple(\"emoji\", \"code help\")\nEMOJI_MAP = {\n+ \"VALIDATE\": emoji(\"✅\", \"Validate\"),\n\"BUCKET\": emoji(\"🪣\", \"Storage bucket\"),\n\"CAMERA\": emoji(\"📷\", \"Screenshot activity\"),\n\"FISHING_POLE\": emoji(\"🎣\", \"Phishing\"),\n"
}
] | Python | Apache License 2.0 | google/timesketch | MISP and Hashlookup analyzers (#2429) |
263,096 | 29.12.2022 09:05:51 | -3,600 | abea1c2abd7a0ed3dd68568b46200a1d7d3f4f59 | some minor changes to frontend dev doc | [
{
"change_type": "MODIFY",
"old_path": "docs/changelog/2022-12.md",
"new_path": "docs/changelog/2022-12.md",
"diff": "@@ -28,3 +28,7 @@ Visit [CLI howto](../guides/admin/admin-cli) for more information\nWith [#2439](https://github.com/google/timesketch/issues/2439) we introduced context links to the v2 UI. This feature allows linking specific event values to external lookup services for an easy analyst workflow. Now this hash lookup with your favorite CTI platform is just two clicks away.\nCheck out the [context link documentation](../guides/admin/context-links.md) for more information.\n+\n+## Development documentation\n+\n+Some minor edits to https://timesketch.org/developers/frontend-development/\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "docs/developers/frontend-development.md",
"new_path": "docs/developers/frontend-development.md",
"diff": "hide:\n- footer\n---\n-## Frontend development\n+### Frontend (old) development dependencies\n+\n+When developing the frontend you use the VueJS frontend server. Changes will be picked up automatically\n+as soon as a `.vue` file is saved without having to rebuild the frontend or even refresh your browser.\n+\n+If you develop a new feature, consider changing to `frontent-ng`, the old frontend is likely to be deprecated in 2023.\nFirst we need to get an interactive shell to the container to install the frontend modules:\n@@ -31,19 +36,14 @@ This will create `node_modules/` folder from `package.json` in the frontend dire\n! yarn install\n```\n-## Frontend development\n-\n-When developing the frontend you use the VueJS frontend server. Changes will be picked up automatically\n-as soon as a `.vue` file is saved without having to rebuild the frontend or even refresh your browser.\n-\n-Follow the steps in the previous section to get dependencies installed.\n-\n-### Tweak config files\n+### Tweak config file\n* In your `timesketch` docker container, edit `/etc/timesketch/timesketch.conf` and set `WTF_CSRF_ENABLED = False`.\n### Start the VueJS development server\n+Follow the steps in the previous section to get dependencies installed and the config file tweaked.\n+\nYou need two shells:\n1. Start the main webserver (for serving the API etc) in the first shell:\n@@ -64,14 +64,12 @@ be instantly picked up.\n## Frontend-ng developement\n-## Frontend development\n-\n-When developing the frontend-ng you use the VueJS frontend server. Changes will be picked up automatically\n+When developing the `frontend-ng` you use the VueJS frontend server. Changes will be picked up automatically\nas soon as a `.vue` file is saved without having to rebuild the frontend or even refresh your browser.\nFollow the steps in the previous section to get dependencies installed.\n-### Tweak config files\n+### Tweak config file\n* In your `timesketch` docker container, edit `/etc/timesketch/timesketch.conf` and set `WTF_CSRF_ENABLED = False`.\n"
}
] | Python | Apache License 2.0 | google/timesketch | some minor changes to frontend dev doc (#2469) |
263,093 | 04.01.2023 14:00:03 | -3,600 | 1cef69b041c488878f062ce9e515313aa05f96cd | Rename sketch | [
{
"change_type": "ADD",
"old_path": null,
"new_path": "timesketch/frontend-ng/src/components/RenameSketch.vue",
"diff": "+<!--\n+Copyright 2023 Google Inc. All rights reserved.\n+\n+Licensed under the Apache License, Version 2.0 (the \"License\");\n+you may not use this file except in compliance with the License.\n+You may obtain a copy of the License at\n+\n+ http://www.apache.org/licenses/LICENSE-2.0\n+\n+Unless required by applicable law or agreed to in writing, software\n+distributed under the License is distributed on an \"AS IS\" BASIS,\n+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+See the License for the specific language governing permissions and\n+limitations under the License.\n+-->\n+<template>\n+ <div>\n+ <h3>Rename sketch</h3>\n+ <br />\n+ <v-text-field outlined dense autofocus v-model=\"newSketchName\" @focus=\"$event.target.select()\"> </v-text-field>\n+ <v-card-actions>\n+ <v-spacer></v-spacer>\n+ <v-btn color=\"primary\" text @click=\"closeDialog()\"> Cancel </v-btn>\n+ <v-btn color=\"primary\" depressed @click=\"renameSketch()\"> Save </v-btn>\n+ </v-card-actions>\n+ </div>\n+</template>\n+\n+<script>\n+import ApiClient from '../utils/RestApiClient'\n+\n+export default {\n+ data() {\n+ return {\n+ newSketchName: '',\n+ }\n+ },\n+ computed: {\n+ sketch() {\n+ return this.$store.state.sketch\n+ },\n+ },\n+ methods: {\n+ renameSketch() {\n+ ApiClient.saveSketchSummary(this.sketch.id, this.newSketchName, '')\n+ .then((response) => {\n+ this.$store.dispatch('updateSketch', this.sketch.id).then(() => {})\n+ })\n+ .catch((e) => {\n+ console.error(e)\n+ })\n+ this.$emit('close')\n+ },\n+ closeDialog: function () {\n+ this.newSketchName = this.sketch.name\n+ this.$emit('close')\n+ },\n+ },\n+ created() {\n+ this.newSketchName = this.sketch.name\n+ },\n+}\n+</script>\n+\n+<!-- CSS scoped to this component only -->\n+<style scoped lang=\"scss\"></style>\n"
},
{
"change_type": "MODIFY",
"old_path": "timesketch/frontend-ng/src/views/Sketch.vue",
"new_path": "timesketch/frontend-ng/src/views/Sketch.vue",
"diff": "@@ -99,19 +99,36 @@ limitations under the License.\n<v-navigation-drawer app permanent :width=\"navigationDrawer.width\" hide-overlay ref=\"drawer\">\n<div v-show=\"showLeftPanel\">\n<v-toolbar flat>\n- <v-avatar class=\"ml-n3\">\n+ <v-avatar class=\"ml-n3 mt-1\">\n<router-link to=\"/\">\n<v-img src=\"/dist/timesketch-color.png\" max-height=\"25\" max-width=\"25\" contain></v-img>\n</router-link>\n</v-avatar>\n- <span @click=\"showSketchMetadata = !showSketchMetadata\" style=\"font-size: 1.1em; cursor: pointer\"\n- >{{ sketch.name }}\n- </span>\n+ <div\n+ @click=\"showSketchMetadata = !showSketchMetadata\"\n+ style=\"font-size: 1.1em; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis\"\n+ :title=\"sketch.name\"\n+ >\n+ {{ sketch.name }}\n+ </div>\n<v-spacer></v-spacer>\n<v-icon @click=\"toggleLeftPanel\">mdi-chevron-left</v-icon>\n</v-toolbar>\n<v-expand-transition>\n- <v-list v-show=\"showSketchMetadata\" two-line>\n+ <div class=\"px-4\" v-show=\"showSketchMetadata\">\n+ <v-dialog v-model=\"renameSketchDialog\" width=\"600\">\n+ <template v-slot:activator=\"{ on, attrs }\">\n+ <v-btn small outlined depressed color=\"primary\" v-bind=\"attrs\" v-on=\"on\">\n+ <v-icon left> mdi-pencil </v-icon>\n+ Rename</v-btn\n+ >\n+ </template>\n+ <v-card class=\"pa-4\">\n+ <ts-rename-sketch @close=\"renameSketchDialog = false\"></ts-rename-sketch>\n+ </v-card>\n+ </v-dialog>\n+\n+ <v-list class=\"mx-n4\" two-line>\n<v-list-item v-if=\"sketch.user\">\n<v-list-item-content>\n<v-list-item-title>\n@@ -148,6 +165,7 @@ limitations under the License.\n</v-list-item-content>\n</v-list-item>\n</v-list>\n+ </div>\n</v-expand-transition>\n<v-divider></v-divider>\n@@ -243,6 +261,7 @@ import TsDataTypes from '../components/LeftPanel/DataTypes'\nimport TsTags from '../components/LeftPanel/Tags'\nimport TsSearchTemplates from '../components/LeftPanel/SearchTemplates'\nimport TsSigmaRules from '../components/LeftPanel/SigmaRules'\n+import TsRenameSketch from '../components/RenameSketch'\nexport default {\nprops: ['sketchId'],\n@@ -253,6 +272,7 @@ export default {\nTsTags,\nTsSearchTemplates,\nTsSigmaRules,\n+ TsRenameSketch,\n},\ndata() {\nreturn {\n@@ -265,8 +285,7 @@ export default {\nshowLeftPanel: true,\nleftPanelTab: 0,\nleftPanelTabItems: ['Explore', 'Investigate'],\n- renameScenarioDialog: false,\n- newScenarioName: '',\n+ renameSketchDialog: false,\nshowHidden: false,\n}\n},\n"
}
] | Python | Apache License 2.0 | google/timesketch | Rename sketch (#2495)
Co-authored-by: Alexander J <741037+jaegeral@users.noreply.github.com> |
263,153 | 10.01.2023 23:25:33 | -39,600 | 17cfa41def67d589c4c12efe385900f1d9e7ad14 | Fixed interface BaseAnalyzer class name | [
{
"change_type": "MODIFY",
"old_path": "test_tools/timesketch/lib/analyzers/interface.py",
"new_path": "test_tools/timesketch/lib/analyzers/interface.py",
"diff": "@@ -557,7 +557,7 @@ class Sketch(object):\nself._context = context\n-class BaseIndexAnalyzer(object):\n+class BaseAnalyzer(object):\n\"\"\"Base class for analyzers.\nAttributes:\n@@ -716,7 +716,7 @@ class BaseIndexAnalyzer(object):\nself.datastore = context\n-class BaseSketchAnalyzer(BaseIndexAnalyzer):\n+class BaseSketchAnalyzer(BaseAnalyzer):\n\"\"\"Base class for sketch analyzers.\nAttributes:\n"
}
] | Python | Apache License 2.0 | google/timesketch | Fixed interface BaseAnalyzer class name (#2506)
Co-authored-by: Roshan Maskey <rmaskey@google.com>
Co-authored-by: Johan Berggren <jberggren@gmail.com> |
263,093 | 17.01.2023 14:25:29 | -3,600 | 50343d24efa953d6f02ba49e343e527d4c8d8182 | Edit timefilter | [
{
"change_type": "MODIFY",
"old_path": "timesketch/frontend-ng/src/components/Explore/FilterMenu.vue",
"new_path": "timesketch/frontend-ng/src/components/Explore/FilterMenu.vue",
"diff": "@@ -84,6 +84,7 @@ import dayjs from '@/plugins/dayjs'\nimport DatePicker from 'v-calendar/lib/components/date-picker.umd'\nexport default {\n+ props: ['selectedChip'],\ncomponents: {\nDatePicker,\n},\n@@ -121,20 +122,26 @@ export default {\nreturn this.range.end\n},\n},\n+ created() {\n+ if (this.selectedChip) {\n+ this.range.start = this.selectedChip.value.split(',')[0]\n+ this.range.end = this.selectedChip.value.split(',')[1]\n+ }\n+ },\nmethods: {\ngetDateRange: function (num, resolution) {\nlet now = dayjs.utc()\nlet then = now.subtract(num, resolution)\nlet chipType = 'datetime_range'\nlet chipValue = then.format('YYYY-MM-DD') + ',' + now.format('YYYY-MM-DD')\n- this.chip = {\n+ let chip = {\nfield: '',\ntype: chipType,\nvalue: chipValue,\noperator: 'must',\nactive: true,\n}\n- this.$emit('addChip', this.chip)\n+ this.addChip(chip)\nthis.$emit('cancel')\nreturn { start: now, end: then }\n@@ -169,7 +176,7 @@ export default {\noperator: 'must',\nactive: true,\n}\n- this.$emit('addChip', chip)\n+ this.addChip(chip)\nthis.range = {\nstart: null,\nend: null,\n@@ -182,6 +189,13 @@ export default {\n}\nthis.$emit('cancel')\n},\n+ addChip: function (newChip) {\n+ if (this.selectedChip) {\n+ this.$emit('updateChip', newChip)\n+ } else {\n+ this.$emit('addChip', newChip)\n+ }\n+ },\nsubmit: function () {\nif (!this.range.start) {\nreturn\n@@ -200,14 +214,14 @@ export default {\nif (this.range.start !== this.range.end) {\nlet chipType = 'datetime_range'\nlet chipValue = this.range.start + ',' + this.range.end\n- this.chip = {\n+ let chip = {\nfield: '',\ntype: chipType,\nvalue: chipValue,\noperator: 'must',\nactive: true,\n}\n- this.$emit('addChip', this.chip)\n+ this.addChip(chip)\nthis.range = {\nstart: '',\nend: '',\n"
},
{
"change_type": "MODIFY",
"old_path": "timesketch/frontend-ng/src/views/Explore.vue",
"new_path": "timesketch/frontend-ng/src/views/Explore.vue",
"diff": "@@ -123,12 +123,26 @@ limitations under the License.\n</template>\n<v-card>\n<v-list>\n- <v-list-item>\n+ <!-- Edit timefilter menu -->\n+ <v-menu\n+ offset-y\n+ :close-on-content-click=\"false\"\n+ :close-on-click=\"true\"\n+ nudge-top=\"70\"\n+ content-class=\"menu-with-gap\"\n+ allow-overflow\n+ style=\"overflow: visible\"\n+ >\n+ <template v-slot:activator=\"{ on, attrs }\">\n+ <v-list-item v-bind=\"attrs\" v-on=\"on\">\n<v-list-item-action>\n<v-icon>mdi-square-edit-outline</v-icon>\n</v-list-item-action>\n<v-list-item-subtitle>Edit filter</v-list-item-subtitle>\n</v-list-item>\n+ </template>\n+ <ts-filter-menu app :selected-chip=\"chip\" @updateChip=\"updateChip($event, chip)\"></ts-filter-menu>\n+ </v-menu>\n<v-list-item @click=\"toggleChip(chip)\">\n<v-list-item-action>\n@@ -654,7 +668,6 @@ export default {\nbad: { color: 'red', textColor: 'white', label: 'mdi-alert-circle-outline' },\nsuspicious: { color: 'orange', textColor: 'white', label: 'mdi-help-circle-outline' },\n},\n-\n// old stuff\nparams: {},\nsearchInProgress: false,\n"
}
] | Python | Apache License 2.0 | google/timesketch | Edit timefilter (#2510) |
263,096 | 07.02.2023 10:01:34 | -3,600 | b6cbac3594c0d8b21860e45b167450d81788d192 | use a fixed id if crypto.randomUUID is not available | [
{
"change_type": "MODIFY",
"old_path": "timesketch/frontend-ng/src/utils/SigmaRuleTemplates.js",
"new_path": "timesketch/frontend-ng/src/utils/SigmaRuleTemplates.js",
"diff": "@@ -11,9 +11,16 @@ See the License for the specific language governing permissions and\nlimitations under the License.\n*/\n+try {\n+ var ruleUuid = crypto.randomUUID()\n+} catch (e) {\n+ console.log('crypto.randomUUID() not supported, using a fixed value instead')\n+ ruleUuid = '10a4fb8c-29d5-4eb6-905f-13d6a553d470'\n+}\n+\n// General first part of every Sigma rule:\nconst SkeletonFirst = `title: SigmaRuleTemplateTitle\n-id: ${crypto.randomUUID()}\n+id: ${ruleUuid}\ndescription: Detects suspicious activity\nreferences:\n- https://\n"
}
] | Python | Apache License 2.0 | google/timesketch | use a fixed id if crypto.randomUUID is not available (#2537) |
263,096 | 08.02.2023 12:53:17 | -3,600 | ed7b5d8df32e605d49ed580a5783542a9ac3db06 | don't mutate the prop | [
{
"change_type": "MODIFY",
"old_path": "timesketch/frontend-ng/src/components/Studio/SigmaRuleModification.vue",
"new_path": "timesketch/frontend-ng/src/components/Studio/SigmaRuleModification.vue",
"diff": "@@ -131,7 +131,6 @@ export default {\nthis.ruleYamlTextArea = defaultSigmaPlaceholder\nthis.editingRule.rule_yaml = defaultSigmaPlaceholder\nthis.parseSigma(this.editingRule.rule_yaml)\n- this.rule_uuid = this.editingRule.rule_uuid\n},\nselectTemplate(text) {\nvar matchingTemplate = this.SigmaTemplates.find((obj) => {\n@@ -154,7 +153,6 @@ export default {\nthis.isParsingSuccesful = false\n} else {\nthis.editingRule = parsedRule\n- this.rule_uuid = parsedRule.uuid\nthis.isParsingSuccesful = true\nthis.status_text = ''\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "timesketch/frontend-ng/src/utils/SigmaRuleTemplates.js",
"new_path": "timesketch/frontend-ng/src/utils/SigmaRuleTemplates.js",
"diff": "@@ -31,7 +31,7 @@ status: experimental\nfalsepositives: unknown\nlevel: informational\ntags:\n- -`\n+ - attack.defense_evasion`\n// General last part of every Sigma rule:\nconst SkeletonLast = `falsepositives:\n"
}
] | Python | Apache License 2.0 | google/timesketch | don't mutate the prop (#2542) |
263,096 | 08.02.2023 13:03:20 | -3,600 | 757d73a74f73fb34be4654920ef60fd959d75614 | update Sigma create rule gif | [
{
"change_type": "ADD",
"old_path": "docs/assets/images/Sigma_create_rule_new.gif",
"new_path": "docs/assets/images/Sigma_create_rule_new.gif",
"diff": "Binary files /dev/null and b/docs/assets/images/Sigma_create_rule_new.gif differ\n"
},
{
"change_type": "MODIFY",
"old_path": "docs/guides/user/sigma.md",
"new_path": "docs/guides/user/sigma.md",
"diff": "@@ -75,7 +75,7 @@ Visit\nhttps://$TIMESKETCH/v2/studio/sigma/new\n```\n-\n+\nThere are some [best practices](#Compose-new-rules) to compose new Sigma rules.\n"
}
] | Python | Apache License 2.0 | google/timesketch | update Sigma create rule gif (#2544) |
129,187 | 01.01.2017 18:54:13 | 18,000 | 8f5e37f46fceff21932637df9aff1eaaa3633501 | Factor out all the typeahead panes | [
{
"change_type": "MODIFY",
"old_path": "js/typeahead/typeahead.react.js",
"new_path": "js/typeahead/typeahead.react.js",
"diff": "@@ -16,7 +16,7 @@ import { connect } from 'react-redux';\nimport TypeaheadActionOption from './typeahead-action-option.react';\nimport TypeaheadCalendarOption from './typeahead-calendar-option.react';\nimport TypeaheadOptionButtons from './typeahead-option-buttons.react';\n-import TypeaheadPageablePane from './typeahead-pageable-pane.react';\n+import TypeaheadPane from './typeahead-pane.react';\nimport { SearchIndex, searchIndex } from './search-index';\nimport { currentNavID } from '../nav-utils';\nimport {\n@@ -174,64 +174,61 @@ class Typeahead extends React.Component {\n</div>\n);\n} else if (this.state.active) {\n- const currentInfos = this.props.sortedCalendarInfos.current;\n- const subscribedInfos = this.props.sortedCalendarInfos.subscribed;\n- const recommendedInfos = this.props.sortedCalendarInfos.recommended;\n-\nconst panes = [];\n- if (this.props.currentNavID !== \"home\" && this.props.subscriptionExists) {\n- panes.push(\n- <div className=\"calendar-nav-option-pane\" key=\"home\">\n- <div className=\"calendar-nav-option-pane-header\">\n- Home\n- </div>\n- {this.buildActionOption(\"home\", TypeaheadActionOption.homeText)}\n- </div>\n- );\n- }\n- const currentOptions = currentInfos.map(\n+ const currentOptions = this.props.sortedCalendarInfos.current.map(\n(calendarInfo) => this.buildCalendarOption(calendarInfo),\n);\n- if (currentOptions.length > 0) {\npanes.push(\n- <div className=\"calendar-nav-option-pane\" key=\"current\">\n- <div className=\"calendar-nav-option-pane-header\">\n- Current\n- </div>\n- {currentOptions}\n- </div>\n+ <TypeaheadPane\n+ paneTitle=\"Current\"\n+ pageSize={1}\n+ totalResults={currentOptions.length}\n+ resultsBetween={() => currentOptions}\n+ key=\"current\"\n+ />\n+ );\n+ if (this.props.currentNavID !== \"home\" && this.props.subscriptionExists) {\n+ const homeOption =\n+ this.buildActionOption(\"home\", TypeaheadActionOption.homeText);\n+ panes.push(\n+ <TypeaheadPane\n+ paneTitle=\"Home\"\n+ pageSize={1}\n+ totalResults={1}\n+ resultsBetween={() => [ homeOption ]}\n+ key=\"home\"\n+ />\n);\n}\npanes.push(\n- <TypeaheadPageablePane\n+ <TypeaheadPane\npaneTitle=\"Subscribed\"\npageSize={5}\n- totalResults={subscribedInfos.length}\n+ totalResults={this.props.sortedCalendarInfos.subscribed.length}\nresultsBetween={this.subscribedCalendarOptionsForPage.bind(this)}\nkey=\"subscribed\"\n/>\n);\n- const recommendedOptions = recommendedInfos.map(\n- (calendarInfo) => this.buildCalendarOption(calendarInfo),\n- );\n- if (recommendedOptions.length > 0) {\npanes.push(\n- <div className=\"calendar-nav-option-pane\" key=\"recommended\">\n- <div className=\"calendar-nav-option-pane-header\">\n- Recommended\n- </div>\n- {recommendedOptions}\n- </div>\n+ <TypeaheadPane\n+ paneTitle=\"Recommended\"\n+ pageSize={3}\n+ totalResults={this.props.sortedCalendarInfos.recommended.length}\n+ resultsBetween={this.recommendedCalendarOptionsForPage.bind(this)}\n+ key=\"recommended\"\n+ />\n);\n- }\nif (this.props.currentNavID) {\n+ const newOption =\n+ this.buildActionOption(\"new\", TypeaheadActionOption.newText);\npanes.push(\n- <div className=\"calendar-nav-option-pane\" key=\"actions\">\n- <div className=\"calendar-nav-option-pane-header\">\n- Actions\n- </div>\n- {this.buildActionOption(\"new\", TypeaheadActionOption.newText)}\n- </div>\n+ <TypeaheadPane\n+ paneTitle=\"Actions\"\n+ pageSize={1}\n+ totalResults={1}\n+ resultsBetween={() => [ newOption ]}\n+ key=\"actions\"\n+ />\n);\n}\ndropdown = (\n@@ -503,6 +500,11 @@ class Typeahead extends React.Component {\n.map((calendarInfo) => this.buildCalendarOption(calendarInfo));\n}\n+ recommendedCalendarOptionsForPage(start: number, end: number) {\n+ return this.props.sortedCalendarInfos.recommended.slice(start, end)\n+ .map((calendarInfo) => this.buildCalendarOption(calendarInfo));\n+ }\n+\n}\nTypeahead.propTypes = {\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Factor out all the typeahead panes |
129,187 | 02.01.2017 07:42:59 | 18,000 | d692ef6096caf7a4dde60ccc12199c1b0a7de665 | Fix minor visual bug | [
{
"change_type": "MODIFY",
"old_path": "style.css",
"new_path": "style.css",
"diff": "@@ -269,6 +269,7 @@ div.calendar-nav-option-pane-header {\ncolor: #777777;\nfont-family: 'Open Sans', sans-serif;\nfont-size: 9px;\n+ position: relative;\n}\ndiv.calendar-nav-option {\ncursor: pointer;\n@@ -276,7 +277,6 @@ div.calendar-nav-option {\npadding-bottom: 6px;\npadding-top: 3px;\nposition: relative;\n- clear: both;\n}\ndiv.calendar-nav-option-name {\nwhite-space: nowrap;\n@@ -354,8 +354,9 @@ div.calendar-nav-color-preview {\nborder-radius: 2px;\n}\ndiv.calendar-nav-pager {\n- float: right;\n- line-height: 13px;\n+ position: absolute;\n+ top: 0px;\n+ right: 0px;\n}\na.calendar-nav-pager-button {\nvertical-align: top;\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Fix minor visual bug |
129,187 | 03.01.2017 17:02:59 | 18,000 | d8ca3f74fa6f605384f18822796516be3bcddd2b | Fix width of calendar selector | [
{
"change_type": "MODIFY",
"old_path": "style.css",
"new_path": "style.css",
"diff": "@@ -904,7 +904,7 @@ span.select-calendar {\ndisplay: inline-block;\noverflow: hidden;\ntext-overflow: ellipsis;\n- max-width: 150px;\n+ width: 110px;\n}\ndiv.pick-calendar > div.pick-calendar-option {\nborder-bottom: 1px solid #D3D3D3;\n@@ -933,7 +933,6 @@ div.calendar-picker-pager-container {\ntext-align: center;\nheight: 15px;\nmargin-top: -2px;\n- min-width: 120px;\ncursor: default;\nbackground-color: #EAEAEA;\nposition: relative;\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Fix width of calendar selector |
129,187 | 04.01.2017 16:54:49 | 18,000 | 95cb16410ad24ccebc253cdbcbbe4e6095ffb411 | Fix bug in *_entry.php where text was not escaped before being passed to SQL | [
{
"change_type": "MODIFY",
"old_path": "delete_entry.php",
"new_path": "delete_entry.php",
"diff": "@@ -71,12 +71,13 @@ if (\n)));\n}\n+$escaped_text = $conn->real_escape_string($text);\n$conn->query(\"INSERT INTO ids(table_name) VALUES('revisions')\");\n$revision_id = $conn->insert_id;\n$conn->query(\n\"INSERT INTO revisions(id, entry, author, text, creation_time, \".\n\"session_id, last_update, deleted) VALUES ($revision_id, $id, \".\n- \"$viewer_id, '$text', $timestamp, '$session_id', $timestamp, 1)\"\n+ \"$viewer_id, '$escaped_text', $timestamp, '$session_id', $timestamp, 1)\"\n);\n$conn->query(\"UPDATE entries SET deleted = 1 WHERE id = $id\");\n"
},
{
"change_type": "MODIFY",
"old_path": "restore_entry.php",
"new_path": "restore_entry.php",
"diff": "@@ -54,7 +54,7 @@ if (!$last_revision_row['deleted']) {\n'error' => 'entry_not_deleted',\n)));\n}\n-$text = $last_revision_row['text'];\n+$text = $conn->real_escape_string($last_revision_row['text']);\n$viewer_id = get_viewer_id();\n$conn->query(\"INSERT INTO ids(table_name) VALUES('revisions')\");\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Fix bug in *_entry.php where text was not escaped before being passed to SQL |
129,187 | 05.01.2017 17:41:53 | 18,000 | 23bd9b14f146d8c7c760788486e72018904dd18f | Update save.php, delete_entry.php, and restore_entry.php to check `edit_rules` | [
{
"change_type": "MODIFY",
"old_path": "auth.php",
"new_path": "auth.php",
"diff": "@@ -278,3 +278,52 @@ function viewer_can_see_entry($entry) {\n}\nreturn !$entry_row['requires_auth'];\n}\n+\n+function edit_rules_helper($mysql_row) {\n+ if (!$mysql_row) {\n+ return null;\n+ }\n+ if ($mysql_row['requires_auth']) {\n+ return false;\n+ }\n+ if (!user_logged_in() && intval($mysql_row['edit_rules']) === 1) {\n+ return false;\n+ }\n+ return true;\n+}\n+\n+// null if calendar does not exist\n+// false if the viewer can't see into the calendar, or can't edit it\n+// true if the viewer can see into and edit the calendar\n+function viewer_can_edit_calendar($calendar) {\n+ global $conn;\n+\n+ $viewer_id = get_viewer_id();\n+ $result = $conn->query(\n+ \"SELECT c.hash IS NOT NULL AND (r.calendar IS NULL OR r.role < \".\n+ ROLE_SUCCESSFUL_AUTH.\") AS requires_auth, c.edit_rules FROM calendars c \".\n+ \"LEFT JOIN roles r ON r.calendar = c.id AND r.user = {$viewer_id} \".\n+ \"WHERE c.id = $calendar\"\n+ );\n+ return edit_rules_helper($result->fetch_assoc());\n+}\n+\n+// null if entry does not exist\n+// false if the viewer can't see into the calendar, or can't edit it\n+// true if the viewer can see into and edit the calendar\n+// note that this function does not check if the entry is deleted\n+function viewer_can_edit_entry($entry) {\n+ global $conn;\n+\n+ $viewer_id = get_viewer_id();\n+ $result = $conn->query(\n+ \"SELECT c.hash IS NOT NULL AND (r.calendar IS NULL OR r.role < \".\n+ ROLE_SUCCESSFUL_AUTH.\") AS requires_auth, c.edit_rules \".\n+ \"FROM entries e \".\n+ \"LEFT JOIN days d ON d.id = e.day \".\n+ \"LEFT JOIN calendars c ON c.id = d.calendar \".\n+ \"LEFT JOIN roles r ON r.calendar = d.calendar AND r.user = {$viewer_id} \".\n+ \"WHERE e.id = $entry\"\n+ );\n+ return edit_rules_helper($result->fetch_assoc());\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "day_lib.php",
"new_path": "day_lib.php",
"diff": "@@ -5,7 +5,7 @@ require_once('auth.php');\n// null if invalid parameters\n// false if invalid credentials\n-function get_day_id($calendar, $day, $month, $year) {\n+function get_editable_day_id($calendar, $day, $month, $year) {\nglobal $conn;\n$date = date('Y-m-d', strtotime(\"$month/$day/$year\"));\n@@ -13,7 +13,7 @@ function get_day_id($calendar, $day, $month, $year) {\nreturn null;\n}\n- $can_see = viewer_can_see_calendar($calendar);\n+ $can_see = viewer_can_edit_calendar($calendar);\nif (!$can_see) {\n// can be null or false, see comment above\nreturn $can_see;\n"
},
{
"change_type": "MODIFY",
"old_path": "delete_entry.php",
"new_path": "delete_entry.php",
"diff": "@@ -24,7 +24,7 @@ $id = intval($_POST['id']);\n$timestamp = intval($_POST['timestamp']);\n$session_id = $conn->real_escape_string($_POST['session_id']);\n-$can_see = viewer_can_see_entry($id);\n+$can_see = viewer_can_edit_entry($id);\nif ($can_see === null) {\nexit(json_encode(array(\n'error' => 'invalid_parameters',\n"
},
{
"change_type": "MODIFY",
"old_path": "restore_entry.php",
"new_path": "restore_entry.php",
"diff": "@@ -24,7 +24,7 @@ $id = intval($_POST['id']);\n$timestamp = intval($_POST['timestamp']);\n$session_id = $conn->real_escape_string($_POST['session_id']);\n-$can_see = viewer_can_see_entry($id);\n+$can_see = viewer_can_edit_entry($id);\nif ($can_see === null) {\nexit(json_encode(array(\n'error' => 'invalid_parameters',\n"
},
{
"change_type": "MODIFY",
"old_path": "save.php",
"new_path": "save.php",
"diff": "@@ -28,7 +28,9 @@ if ($entry_id === -1) {\n$month = intval($_POST['month']);\n$year = intval($_POST['year']);\n$calendar = intval($_POST['calendar']);\n- $day_id = get_day_id($calendar, $day, $month, $year);\n+ // For the case of a new entry, the privacy check to make sure that the user\n+ // is allowed to edit this calendar happens here\n+ $day_id = get_editable_day_id($calendar, $day, $month, $year);\n} else {\n$result = $conn->query(\n\"SELECT day, deleted, text FROM entries WHERE id = $entry_id\"\n@@ -45,6 +47,12 @@ if ($entry_id === -1) {\n)));\n}\n$day_id = intval($entry_row['day']);\n+ // For the case of an existing entry, the privacy check to make sure that the\n+ // user is allowed to edit this calendar (and entry) happens here\n+ $can_edit = viewer_can_edit_entry($entry_id);\n+ if (!$can_edit) {\n+ $day_id = $can_edit;\n+ }\n}\nif ($day_id === null) {\nexit(json_encode(array(\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Update save.php, delete_entry.php, and restore_entry.php to check `edit_rules` |
129,187 | 06.01.2017 13:59:09 | 18,000 | 7867fa8419031bf77e5cea79c470086ef3c40626 | Changes to INSERT INTO calendars queries corresponding to introduction of new MySQL column | [
{
"change_type": "MODIFY",
"old_path": "new_calendar.php",
"new_path": "new_calendar.php",
"diff": "@@ -69,22 +69,23 @@ $conn->query(\"INSERT INTO ids(table_name) VALUES('calendars')\");\n$id = $conn->insert_id;\n$creator = get_viewer_id();\n$edit_rules = $is_closed ? 1 : 0;\n+$visibility_rules = $is_closed ? 1 : 0;\nif ($is_closed) {\n$hash = password_hash($password, PASSWORD_BCRYPT);\n$conn->query(\n\"INSERT INTO calendars\".\n- \"(id, name, description, hash, edit_rules, \".\n+ \"(id, name, description, visibility_rules, hash, edit_rules, \".\n\"creator, creation_time, color) \".\n- \"VALUES ($id, '$name', '$description', '$hash', \".\n+ \"VALUES ($id, '$name', '$description', $visibility_rules, '$hash', \".\n\"$edit_rules, $creator, $time, '$color')\"\n);\n} else {\n$conn->query(\n\"INSERT INTO calendars\".\n- \"(id, name, description, hash, edit_rules, \".\n+ \"(id, name, description, visibility_rules, hash, edit_rules, \".\n\"creator, creation_time, color) \".\n- \"VALUES ($id, '$name', '$description', NULL, $edit_rules, \".\n- \"$creator, $time, '$color')\"\n+ \"VALUES ($id, '$name', '$description', $visibility_rules, NULL, \".\n+ \"$edit_rules, $creator, $time, '$color')\"\n);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "style.css",
"new_path": "style.css",
"diff": "@@ -560,7 +560,7 @@ div.form-enum-selector div.form-enum-option {\nfont-size: 15px;\nfont-family: 'Open Sans', sans-serif;\nfont-weight: 600;\n- padding-left: 4px;\n+ padding-left: 3px;\n}\ndiv.form-enum-selector span.form-enum-description {\ndisplay: block;\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Changes to INSERT INTO calendars queries corresponding to introduction of new MySQL column |
129,187 | 09.01.2017 15:59:06 | 18,000 | 3027e9eb1852f88d4fb9e95a45c0437f43975c50 | Add some constants for _rules fields in calendars | [
{
"change_type": "MODIFY",
"old_path": "calendar_lib.php",
"new_path": "calendar_lib.php",
"diff": "require_once('config.php');\nrequire_once('auth.php');\n+define(\"VISIBILITY_OPEN\", 0);\n+define(\"VISIBILITY_CLOSED\", 1);\n+define(\"VISIBILITY_SECRET\", 2);\n+define(\"EDIT_ANYBODY\", 0);\n+define(\"EDIT_LOGGED_IN\", 1);\n+\nfunction get_calendar_infos($viewer_id) {\nglobal $conn;\n$result = $conn->query(\n"
},
{
"change_type": "MODIFY",
"old_path": "edit_calendar.php",
"new_path": "edit_calendar.php",
"diff": "require_once('config.php');\nrequire_once('auth.php');\n+require_once('calendar_lib.php');\nheader(\"Content-Type: application/json\");\n@@ -39,7 +40,7 @@ if (!preg_match('/^[a-f0-9]{6}$/', $color)) {\n$visibility_rules = intval($_POST['visibility_rules']);\n$new_password = null;\n-if ($visibility_rules >= 1) {\n+if ($visibility_rules >= VISIBILITY_CLOSED) {\nif (!isset($_POST['new_password'])) {\nexit(json_encode(array(\n'error' => 'invalid_parameters',\n@@ -80,8 +81,8 @@ if (!password_verify($personal_password, $row['hash'])) {\n// If the calendar is currently open but is being switched to closed,\n// then a password *must* be specified\nif (\n- intval($row['visibility_rules']) < 1 &&\n- $visibility_rules >= 1 &&\n+ intval($row['visibility_rules']) < VISIBILITY_CLOSED &&\n+ $visibility_rules >= VISIBILITY_CLOSED &&\ntrim($new_password) === ''\n) {\nexit(json_encode(array(\n@@ -91,7 +92,7 @@ if (\n$name = $conn->real_escape_string($_POST['name']);\n$description = $conn->real_escape_string($_POST['description']);\n-if ($visibility_rules >= 1 && trim($new_password) !== '') {\n+if ($visibility_rules >= VISIBILITY_CLOSED && trim($new_password) !== '') {\n$hash = password_hash($new_password, PASSWORD_BCRYPT);\n$conn->query(\n\"UPDATE calendars SET name = '$name', description = '$description', \".\n@@ -99,7 +100,7 @@ if ($visibility_rules >= 1 && trim($new_password) !== '') {\n\"hash = '$hash', edit_rules = $edit_rules \".\n\"WHERE id = $calendar\"\n);\n-} else if ($visibility_rules >= 1) {\n+} else if ($visibility_rules >= VISIBILITY_CLOSED) {\n// We are guaranteed that the calendar was closed beforehand, as otherwise\n// $new_password would have to be set and the above condition would've tripped\n$conn->query(\n"
},
{
"change_type": "MODIFY",
"old_path": "new_calendar.php",
"new_path": "new_calendar.php",
"diff": "require_once('config.php');\nrequire_once('auth.php');\n+require_once('calendar_lib.php');\nheader(\"Content-Type: application/json\");\n@@ -38,7 +39,7 @@ if (!user_logged_in()) {\n$visibility_rules = intval($_POST['visibility_rules']);\n$password = null;\n-if ($visibility_rules >= 1) {\n+if ($visibility_rules >= VISIBILITY_CLOSED) {\nif (!isset($_POST['password'])) {\nexit(json_encode(array(\n'error' => 'invalid_parameters',\n@@ -53,8 +54,10 @@ $time = round(microtime(true) * 1000); // in milliseconds\n$conn->query(\"INSERT INTO ids(table_name) VALUES('calendars')\");\n$id = $conn->insert_id;\n$creator = get_viewer_id();\n-$edit_rules = $visibility_rules >= 1 ? 1 : 0;\n-if ($visibility_rules >= 1) {\n+$edit_rules = $visibility_rules >= VISIBILITY_CLOSED\n+ ? EDIT_LOGGED_IN\n+ : EDIT_ANYBODY;\n+if ($visibility_rules >= VISIBILITY_CLOSED) {\n$hash = password_hash($password, PASSWORD_BCRYPT);\n$conn->query(\n\"INSERT INTO calendars\".\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Add some constants for _rules fields in calendars |
129,187 | 09.01.2017 18:23:31 | 18,000 | 2c515c2488287d171bd90a9d4afda110045d7e51 | Update all remaining SQL queries that check nullness of hash column to check visibility_rules instead | [
{
"change_type": "MODIFY",
"old_path": "auth.php",
"new_path": "auth.php",
"diff": "<?php\nrequire_once('config.php');\n+require_once('calendar_lib.php');\ndefine(\"ROLE_VIEWED\", 0);\ndefine(\"ROLE_SUCCESSFUL_AUTH\", 5);\n@@ -228,8 +229,9 @@ function viewer_can_see_calendar($calendar) {\n$viewer_id = get_viewer_id();\n$result = $conn->query(\n- \"SELECT c.hash IS NOT NULL AND (r.calendar IS NULL OR r.role < \".\n- ROLE_SUCCESSFUL_AUTH.\") AS requires_auth FROM calendars c \".\n+ \"SELECT c.visibility_rules >= \".VISIBILITY_CLOSED.\" AND \".\n+ \"(r.calendar IS NULL OR r.role < \".ROLE_SUCCESSFUL_AUTH.\") \".\n+ \"AS requires_auth FROM calendars c \".\n\"LEFT JOIN roles r ON r.calendar = c.id AND r.user = {$viewer_id} \".\n\"WHERE c.id = $calendar\"\n);\n@@ -246,8 +248,9 @@ function viewer_can_see_day($day) {\n$viewer_id = get_viewer_id();\n$result = $conn->query(\n- \"SELECT c.hash IS NOT NULL AND (r.calendar IS NULL OR r.role < \".\n- ROLE_SUCCESSFUL_AUTH.\") AS requires_auth FROM days d \".\n+ \"SELECT c.visibility_rules >= \".VISIBILITY_CLOSED.\" AND \".\n+ \"(r.calendar IS NULL OR r.role < \".ROLE_SUCCESSFUL_AUTH.\") \".\n+ \"AS requires_auth FROM days d \".\n\"LEFT JOIN calendars c ON c.id = d.calendar \".\n\"LEFT JOIN roles r ON r.calendar = d.calendar AND r.user = {$viewer_id} \".\n\"WHERE d.id = $day\"\n@@ -265,8 +268,9 @@ function viewer_can_see_entry($entry) {\n$viewer_id = get_viewer_id();\n$result = $conn->query(\n- \"SELECT c.hash IS NOT NULL AND (r.calendar IS NULL OR r.role < \".\n- ROLE_SUCCESSFUL_AUTH.\") AS requires_auth FROM entries e \".\n+ \"SELECT c.visibility_rules >= \".VISIBILITY_CLOSED.\" AND \".\n+ \"(r.calendar IS NULL OR r.role < \".ROLE_SUCCESSFUL_AUTH.\") \".\n+ \"AS requires_auth FROM entries e \".\n\"LEFT JOIN days d ON d.id = e.day \".\n\"LEFT JOIN calendars c ON c.id = d.calendar \".\n\"LEFT JOIN roles r ON r.calendar = d.calendar AND r.user = {$viewer_id} \".\n@@ -300,8 +304,9 @@ function viewer_can_edit_calendar($calendar) {\n$viewer_id = get_viewer_id();\n$result = $conn->query(\n- \"SELECT c.hash IS NOT NULL AND (r.calendar IS NULL OR r.role < \".\n- ROLE_SUCCESSFUL_AUTH.\") AS requires_auth, c.edit_rules FROM calendars c \".\n+ \"SELECT c.visibility_rules >= \".VISIBILITY_CLOSED.\" AND \".\n+ \"(r.calendar IS NULL OR r.role < \".ROLE_SUCCESSFUL_AUTH.\") \".\n+ \"AS requires_auth, c.edit_rules FROM calendars c \".\n\"LEFT JOIN roles r ON r.calendar = c.id AND r.user = {$viewer_id} \".\n\"WHERE c.id = $calendar\"\n);\n@@ -317,9 +322,9 @@ function viewer_can_edit_entry($entry) {\n$viewer_id = get_viewer_id();\n$result = $conn->query(\n- \"SELECT c.hash IS NOT NULL AND (r.calendar IS NULL OR r.role < \".\n- ROLE_SUCCESSFUL_AUTH.\") AS requires_auth, c.edit_rules \".\n- \"FROM entries e \".\n+ \"SELECT c.visibility_rules >= \".VISIBILITY_CLOSED.\" AND \".\n+ \"(r.calendar IS NULL OR r.role < \".ROLE_SUCCESSFUL_AUTH.\") \".\n+ \"AS requires_auth, c.edit_rules FROM entries e \".\n\"LEFT JOIN days d ON d.id = e.day \".\n\"LEFT JOIN calendars c ON c.id = d.calendar \".\n\"LEFT JOIN roles r ON r.calendar = d.calendar AND r.user = {$viewer_id} \".\n"
},
{
"change_type": "MODIFY",
"old_path": "day_history.php",
"new_path": "day_history.php",
"diff": "require_once('config.php');\nrequire_once('auth.php');\n+require_once('calendar_lib.php');\nheader(\"Content-Type: application/json\");\n@@ -44,8 +45,9 @@ $result = $conn->query(\n\"LEFT JOIN calendars c ON c.id = d.calendar \".\n\"LEFT JOIN roles r ON r.calendar = d.calendar AND r.user = $viewer_id \".\n\"WHERE MONTH(d.date) = $month AND YEAR(d.date) = $year AND \".\n- \"DAY(d.date) = $day AND (c.hash IS NULL OR (r.calendar IS NOT NULL AND \".\n- \"r.role >= \".ROLE_SUCCESSFUL_AUTH.\")) AND \".$additional_condition.\" \".\n+ \"DAY(d.date) = $day AND (c.visibility_rules < \".VISIBILITY_CLOSED.\" OR \".\n+ \"(r.calendar IS NOT NULL AND r.role >= \".ROLE_SUCCESSFUL_AUTH.\")) AND \".\n+ $additional_condition.\" \".\n\"ORDER BY e.creation_time DESC\"\n);\n"
},
{
"change_type": "MODIFY",
"old_path": "month_entries.php",
"new_path": "month_entries.php",
"diff": "require_once('config.php');\nrequire_once('auth.php');\n+require_once('calendar_lib.php');\nheader(\"Content-Type: application/json\");\n@@ -44,8 +45,9 @@ $result = $conn->query(\n\"LEFT JOIN roles r ON r.calendar = d.calendar AND r.user = $viewer_id \".\n\"LEFT JOIN users u ON u.id = e.creator \".\n\"WHERE MONTH(d.date) = $month AND YEAR(d.date) = $year AND \".\n- \"e.deleted = 0 AND (c.hash IS NULL OR (r.calendar IS NOT NULL AND \".\n- \"r.role >= \".ROLE_SUCCESSFUL_AUTH.\")) AND \".$additional_condition.\" \".\n+ \"e.deleted = 0 AND (c.visibility_rules < \".VISIBILITY_CLOSED.\" OR \".\n+ \"(r.calendar IS NOT NULL AND r.role >= \".ROLE_SUCCESSFUL_AUTH.\")) AND \".\n+ $additional_condition.\" \".\n\"ORDER BY e.creation_time DESC\"\n);\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Update all remaining SQL queries that check nullness of hash column to check visibility_rules instead |
129,187 | 10.01.2017 09:50:05 | 18,000 | d9a0c514dd5810c0dd2d644f978e0d30548f5cda | 1) Add the down arrow to the account bar when loading
2) Add a gray transparent overlay over everything when loading to make it clear that nothing is clickable | [
{
"change_type": "MODIFY",
"old_path": "index.php",
"new_path": "index.php",
"diff": "@@ -224,6 +224,19 @@ if (user_logged_in()) {\necho <<<HTML\nlogged in as\n<span class=\"username\">$username</span>\n+ <svg\n+ version=\"1.1\"\n+ xmlns=\"http://www.w3.org/2000/svg\"\n+ xml:space=\"preserve\"\n+ xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n+ viewBox=\"0 0 8 8\"\n+ preserveAspectRatio=\"none\"\n+ height=\"10px\"\n+ width=\"10px\"\n+ class=\"account-caret\"\n+ >\n+ <path d=\"M4 2l-4 4h8l-4-4z\"></path>\n+ </svg>\nHTML;\n} else {\n@@ -269,6 +282,7 @@ echo <<<HTML\n<a href=\"{$next_url}\" class=\"next-month-link\">></a>\n</h2>\n</header>\n+ <div class=\"modal-overlay\"></div>\n</div>\nHTML;\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | 1) Add the down arrow to the account bar when loading
2) Add a gray transparent overlay over everything when loading to make it clear that nothing is clickable |
129,187 | 11.01.2017 16:12:26 | 18,000 | f72a795eaba3e6c36d48d135900c193894f67961 | Make recommendationSize larger in the case of a null home state | [
{
"change_type": "MODIFY",
"old_path": "js/typeahead/typeahead.react.js",
"new_path": "js/typeahead/typeahead.react.js",
"diff": "@@ -49,6 +49,7 @@ type TypeaheadCalendarOptionConnect = {\nclass Typeahead extends React.Component {\nstatic recommendationSize;\n+ static homeNullStateRecommendationSize;\nprops: Props;\nstate: State;\n@@ -73,7 +74,7 @@ class Typeahead extends React.Component {\n}\nactive = true;\n}\n- const recommendedCalendars = this.sampleRecommendations(props);\n+ const recommendedCalendars = Typeahead.sampleRecommendations(props);\nthis.state = {\nactive,\nsearchActive: false,\n@@ -125,7 +126,9 @@ class Typeahead extends React.Component {\nif (\nnextProps.sortedCalendarInfos.recommended !==\n- this.props.sortedCalendarInfos.recommended\n+ this.props.sortedCalendarInfos.recommended ||\n+ Typeahead.getRecommendationSize(nextProps) >\n+ Typeahead.getRecommendationSize(this.props)\n) {\nconst stillValidRecommendations = _.filter(\nthis.state.recommendedCalendars,\n@@ -134,8 +137,8 @@ class Typeahead extends React.Component {\n{ id: calendarInfo.id },\n),\n);\n- let newRecommendationsNeeded =\n- Typeahead.recommendationSize - stillValidRecommendations.length;\n+ let newRecommendationsNeeded = Typeahead.getRecommendationSize(this.props)\n+ - stillValidRecommendations.length;\nif (newRecommendationsNeeded > 0) {\nconst randomCalendarInfos =\n_.chain(nextProps.sortedCalendarInfos.recommended)\n@@ -259,7 +262,7 @@ class Typeahead extends React.Component {\npanes.push(\n<TypeaheadPane\npaneTitle=\"Recommended\"\n- pageSize={Typeahead.recommendationSize}\n+ pageSize={Typeahead.getRecommendationSize(this.props)}\ntotalResults={recommendedOptions.length}\nresultsBetween={() => recommendedOptions}\nkey=\"recommended\"\n@@ -449,7 +452,7 @@ class Typeahead extends React.Component {\nsetFocus = active;\nif (!active) {\ntypeaheadValue = Typeahead.getCurrentNavName(props);\n- recommendedCalendars = this.sampleRecommendations(props);\n+ recommendedCalendars = Typeahead.sampleRecommendations(props);\n}\nreturn {\nactive,\n@@ -577,16 +580,25 @@ class Typeahead extends React.Component {\n.map((calendarInfo) => this.buildCalendarOption(calendarInfo));\n}\n- sampleRecommendations(props: Props) {\n+ static getRecommendationSize(props: Props) {\n+ if (props.currentlyHome && props.currentNavID === null) {\n+ return Typeahead.homeNullStateRecommendationSize;\n+ } else {\n+ return Typeahead.recommendationSize;\n+ }\n+ }\n+\n+ static sampleRecommendations(props: Props) {\nreturn _.sampleSize(\nprops.sortedCalendarInfos.recommended,\n- Typeahead.recommendationSize,\n+ Typeahead.getRecommendationSize(props),\n);\n}\n}\nTypeahead.recommendationSize = 3;\n+Typeahead.homeNullStateRecommendationSize = 6;\nTypeahead.propTypes = {\ncurrentNavID: React.PropTypes.string,\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Make recommendationSize larger in the case of a null home state |
129,187 | 13.01.2017 15:32:57 | 18,000 | e3a7d333cd37f961bb12dad47634c3d281616574 | Only darken the loading screen if it will be dark after load | [
{
"change_type": "MODIFY",
"old_path": "style.css",
"new_path": "style.css",
"diff": "@@ -424,9 +424,7 @@ div.account-menu > div {\nspan.username {\ndisplay: inline-block;\ncolor: #2A5DB0;\n-}\n-span.username:hover {\n- cursor: default;\n+ cursor: pointer;\n}\nsvg.account-caret {\npadding-left: 6px;\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Only darken the loading screen if it will be dark after load |
129,187 | 13.01.2017 20:09:34 | 18,000 | 9aa15958595c21b07a6799c1a85a017f4a04bf6f | Fix up a bug in when pre-load modal-overlay is displayed | [
{
"change_type": "MODIFY",
"old_path": "index.php",
"new_path": "index.php",
"diff": "@@ -47,9 +47,6 @@ if (!$home && !isset($calendar_infos[$calendar])) {\nexit;\n}\n}\n-$current_calendar_authorized = !$home\n- && isset($calendar_infos[$calendar])\n- && $calendar_infos[$calendar]['authorized'];\n$month_beginning_timestamp = date_create(\"$month/1/$year\");\nif ($month < 1 || $month > 12) {\n@@ -57,13 +54,19 @@ if ($month < 1 || $month > 12) {\nexit;\n}\n-$subscription_exists = false;\n+$null_state = null;\n+if ($home) {\n+ $null_state = true;\nforeach ($calendar_infos as $calendar_info) {\nif ($calendar_info['subscribed']) {\n- $subscription_exists = true;\n+ $null_state = false;\nbreak;\n}\n}\n+} else {\n+ $null_state = isset($calendar_infos[$calendar])\n+ && $calendar_infos[$calendar]['authorized'];\n+}\n$verify_rewrite_matched = preg_match(\n'#/verify/([a-f0-9]+)(/|$)#i',\n@@ -232,7 +235,7 @@ echo <<<HTML\n</header>\nHTML;\n-if (($home && !$subscription_exists) || !$current_calendar_authorized) {\n+if ($null_state) {\necho <<<HTML\n<div class=\"modal-overlay\"></div>\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Fix up a bug in when pre-load modal-overlay is displayed |
129,187 | 14.01.2017 13:47:43 | 18,000 | 1550845f040aea7fb7e647cd478f2eb281daef87 | The guide lines for IntroModal. I'm gonna get rid of these... this is a temp commit (without a build) just in case I ever want to bring them back | [
{
"change_type": "MODIFY",
"old_path": "js/app.react.js",
"new_path": "js/app.react.js",
"diff": "@@ -68,7 +68,12 @@ class App extends React.Component {\ncomponentDidMount() {\nif (!this.props.currentNavID) {\nif (this.props.navInfo.home) {\n- this.setModal(<IntroModal />);\n+ this.setModal(\n+ <IntroModal\n+ setModal={this.setModal.bind(this)}\n+ clearModal={this.clearModal.bind(this)}\n+ />\n+ );\n} else {\nthis.setModal(<div className=\"modal-overlay\" />);\n}\n@@ -93,7 +98,10 @@ class App extends React.Component {\nreturn prevState;\n}\nconst overlay = props.navInfo.home\n- ? <IntroModal />\n+ ? <IntroModal\n+ setModal={this.setModal.bind(this)}\n+ clearModal={this.clearModal.bind(this)}\n+ />\n: <div className=\"modal-overlay\" />;\nreturn update(prevState, { currentModal: { $set: overlay }});\n});\n@@ -222,7 +230,12 @@ class App extends React.Component {\nif (this.props.currentNavID) {\nthis.setState({ currentModal: null });\n} else if (this.props.navInfo.home) {\n- this.setModal(<IntroModal />);\n+ this.setModal(\n+ <IntroModal\n+ setModal={this.setModal.bind(this)}\n+ clearModal={this.clearModal.bind(this)}\n+ />\n+ );\n} else {\nthis.setModal(<div className=\"modal-overlay\" />);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "js/modals/intro-modal.react.js",
"new_path": "js/modals/intro-modal.react.js",
"diff": "import React from 'react';\n+import { LeftPager, RightPager, DownArrow } from '../vectors.react';\n+import LogInModal from './account/log-in-modal.react';\n+import RegisterModal from './account/register-modal.react';\n+\ntype Props = {\n+ setModal: (modal: React.Element<any>) => void,\n+ clearModal: () => void,\n};\ntype State = {\nscreenWidth: number,\nscreenHeight: number,\n+ showFirstGuide: bool,\n+ showSecondGuide: bool,\n+ showThirdGuide: bool,\n};\nclass IntroModal extends React.Component {\n@@ -23,6 +32,9 @@ class IntroModal extends React.Component {\nthis.state = {\nscreenWidth: window.innerWidth,\nscreenHeight: window.innerHeight,\n+ showFirstGuide: false,\n+ showSecondGuide: false,\n+ showThirdGuide: false,\n};\nthis.onResizeCallback = this.onResize.bind(this);\n}\n@@ -43,46 +55,132 @@ class IntroModal extends React.Component {\n}\nrender() {\n- if (this.state.screenWidth < (350 + 432)) {\n+ const maxWidth = (350 + 432 + 60 + IntroModal.maxDistanceFromTypeahead);\n+ if (this.state.screenWidth < maxWidth || this.state.screenHeight < 310) {\nreturn <div className=\"modal-overlay\" />;\n}\n- let left = (this.state.screenWidth - 350) / 2;\n- const rightEdge = left + 350;\n+ let modalLeft = (this.state.screenWidth - 350) / 2;\n+ const rightEdge = modalLeft + 350;\nconst typeaheadLeftEdge = this.state.screenWidth - 432;\nif (rightEdge > (typeaheadLeftEdge - IntroModal.maxDistanceFromTypeahead)) {\n- left = typeaheadLeftEdge - IntroModal.maxDistanceFromTypeahead - 350;\n+ modalLeft = typeaheadLeftEdge - IntroModal.maxDistanceFromTypeahead - 350;\n+ }\n+ if (modalLeft < 0) {\n+ modalLeft = 0;\n+ }\n+\n+ const firstOutlineWidth = modalLeft - 10;\n+ const secondOutlineLeft = modalLeft + 360;\n+ const secondOutlineWidth = typeaheadLeftEdge - secondOutlineLeft - 10;\n+\n+ const thirdOutlineWidth = modalLeft + 175;\n+\n+ let firstGuide = null;\n+ if (this.state.showFirstGuide) {\n+ firstGuide = (\n+ <div\n+ className=\"intro-first-outline-container\"\n+ style={{ width: firstOutlineWidth }}\n+ >\n+ <div className=\"intro-first-outline\" />\n+ <DownArrow className=\"intro-first-outline-arrow\" />\n+ </div>\n+ );\n+ }\n+ let secondGuide = null;\n+ if (this.state.showSecondGuide) {\n+ secondGuide = (\n+ <div\n+ className=\"intro-second-outline-container\"\n+ style={{ left: secondOutlineLeft, width: secondOutlineWidth }}\n+ >\n+ <div className=\"intro-second-outline\" />\n+ <RightPager className=\"intro-second-outline-arrow\" />\n+ </div>\n+ );\n}\n- if (left < 0) {\n- left = 0;\n+ let thirdGuide = null;\n+ if (this.state.showThirdGuide) {\n+ thirdGuide = (\n+ <div\n+ className=\"intro-third-outline-container\"\n+ style={{ width: thirdOutlineWidth }}\n+ >\n+ <div className=\"intro-third-outline\" />\n+ <LeftPager className=\"intro-third-outline-arrow\" />\n+ </div>\n+ );\n}\n+\nreturn (\n<div className=\"modal-overlay\">\n- <div className=\"intro-modal\" style={{ left }}>\n+ <div className=\"intro-modal\" style={{ left: modalLeft }}>\n<h3 className=\"intro-modal-welcome\">Welcome!</h3>\n<ol>\n<li>\n{\"If you already have an account, \"}\n- <span className=\"bold\">log in</span>.\n+ <a\n+ onClick={this.onLogIn.bind(this)}\n+ onMouseOver={() => this.setState({ showFirstGuide: true })}\n+ onMouseOut={() => this.setState({ showFirstGuide: false })}\n+ className=\"intro-link\"\n+ >log in</a>.\n</li>\n<li>\nIf you're just browsing, have a look at some calendars and\n- maybe <span className=\"bold\">subscribe</span>.\n+ {\" maybe \"}\n+ <span\n+ onMouseOver={() => this.setState({ showSecondGuide: true })}\n+ onMouseOut={() => this.setState({ showSecondGuide: false })}\n+ className=\"intro-guide\"\n+ >subscribe</span>.\n</li>\n<li>\nIf you want to save your subscriptions or create a new\n- calendar, <span className=\"bold\">register</span> an account.\n+ {\"calendar, \"}\n+ <a\n+ onClick={this.onRegister.bind(this)}\n+ onMouseOver={() => this.setState({ showThirdGuide: true })}\n+ onMouseOut={() => this.setState({ showThirdGuide: false })}\n+ className=\"intro-link\"\n+ >register</a> an account.\n</li>\n</ol>\n</div>\n+ {firstGuide}\n+ {secondGuide}\n+ {thirdGuide}\n</div>\n);\n}\n+ onLogIn(event: SyntheticEvent) {\n+ event.preventDefault();\n+ this.props.setModal(\n+ <LogInModal\n+ onClose={this.props.clearModal}\n+ setModal={this.props.setModal}\n+ />\n+ );\n+ }\n+\n+ onRegister(event: SyntheticEvent) {\n+ event.preventDefault();\n+ this.props.setModal(\n+ <RegisterModal\n+ onClose={this.props.clearModal}\n+ setModal={this.props.setModal}\n+ />\n+ );\n+ }\n+\n}\n-IntroModal.maxDistanceFromTypeahead = 30;\n+IntroModal.maxDistanceFromTypeahead = 50;\nIntroModal.propTypes = {\n+ setModal: React.PropTypes.func.isRequired,\n+ clearModal: React.PropTypes.func.isRequired,\n};\nexport default IntroModal;\n"
},
{
"change_type": "MODIFY",
"old_path": "js/vectors.react.js",
"new_path": "js/vectors.react.js",
"diff": "@@ -44,6 +44,17 @@ export function RightPager(props: { className: string }) {\n);\n}\n+export function DownArrow(props: { className: string }) {\n+ return (\n+ <SVG className={props.className} viewBox=\"0 0 512 512\">\n+ <polygon transform=\"rotate(90, 256, 256)\" points={\n+ \"160,128.4 192.3,96 352,256 352,256 352,256 192.3,416 \" +\n+ \"160,383.6 287.3,256 \"\n+ } />\n+ </SVG>\n+ );\n+}\n+\nexport function UpCaret(props: { className: string }) {\nreturn (\n<SVG\n"
},
{
"change_type": "MODIFY",
"old_path": "style.css",
"new_path": "style.css",
"diff": "@@ -1123,7 +1123,15 @@ h3.intro-modal-welcome {\nfont-weight: 600;\nfont-size: 21px;\n}\n-span.bold {\n+a.intro-link {\n+ font-weight: 600;\n+ cursor: pointer;\n+}\n+a.intro-link:hover {\n+ text-decoration: underline;\n+}\n+span.intro-guide {\n+ color: #2A5DB0;\nfont-weight: 600;\n}\ndiv.intro-modal ol {\n@@ -1135,3 +1143,65 @@ div.intro-modal ol > li {\ndiv.intro-modal ol > li:last-child {\npadding-bottom: 0;\n}\n+div.intro-first-outline-container {\n+ box-sizing: border-box;\n+ position: fixed;\n+ height: 100%;\n+ padding-bottom: 40px;\n+ padding-left: 40px;\n+ padding-top: 151px;\n+}\n+div.intro-first-outline {\n+ border-top: 2px solid #333333;\n+ border-left: 2px solid #333333;\n+ height: 100%;\n+ width: 100%;\n+ border-radius: 10px 0 0 0;\n+}\n+svg.intro-first-outline-arrow {\n+ width: 24px;\n+ position: relative;\n+ right: 11px;\n+ bottom: 14px;\n+ fill: #333333;\n+}\n+div.intro-second-outline-container {\n+ box-sizing: border-box;\n+ position: fixed;\n+ padding-top: 186px;\n+}\n+div.intro-second-outline {\n+ border-top: 2px solid #333333;\n+ height: 100%;\n+ width: 100%;\n+}\n+svg.intro-second-outline-arrow {\n+ float: right;\n+ width: 24px;\n+ position: relative;\n+ left: 10px;\n+ bottom: 13px;\n+ fill: #333333;\n+}\n+div.intro-third-outline-container {\n+ box-sizing: border-box;\n+ position: fixed;\n+ padding-top: 289px;\n+ padding-left: 158px;\n+ padding-bottom: 16px;\n+ height: 100%;\n+}\n+div.intro-third-outline {\n+ border-bottom: 2px solid #333333;\n+ border-right: 2px solid #333333;\n+ border-radius: 0 0 10px 0;\n+ height: 100%;\n+ width: 100%;\n+}\n+svg.intro-third-outline-arrow {\n+ width: 24px;\n+ position: relative;\n+ bottom: 13px;\n+ right: 9px;\n+ fill: #333333;\n+}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | The guide lines for IntroModal. I'm gonna get rid of these... this is a temp commit (without a build) just in case I ever want to bring them back |
129,187 | 27.01.2017 14:57:25 | 18,000 | 239697ba63e99400fc6f4fd92871a9b62ac8d126 | Compare values at same time | [
{
"change_type": "MODIFY",
"old_path": "save.php",
"new_path": "save.php",
"diff": "@@ -33,7 +33,7 @@ if ($entry_id === -1) {\n$day_id = get_editable_day_id($calendar, $day, $month, $year);\n} else {\n$result = $conn->query(\n- \"SELECT day, deleted, text FROM entries WHERE id = $entry_id\"\n+ \"SELECT day, deleted FROM entries WHERE id = $entry_id\"\n);\n$entry_row = $result->fetch_assoc();\nif (!$entry_row) {\n@@ -103,8 +103,10 @@ if ($entry_id === -1) {\n}\n$result = $conn->query(\n- \"SELECT id, author, text, session_id, last_update, deleted FROM revisions \".\n- \"WHERE entry = $entry_id ORDER BY last_update DESC LIMIT 1\"\n+ \"SELECT r.id, r.author, r.text, r.session_id, \".\n+ \"r.last_update, r.deleted, e.text AS entry_text \".\n+ \"FROM revisions r LEFT JOIN entries e ON r.entry = e.id \".\n+ \"WHERE r.entry = $entry_id ORDER BY r.last_update DESC LIMIT 1\"\n);\n$last_revision_row = $result->fetch_assoc();\nif (!$last_revision_row) {\n@@ -114,7 +116,7 @@ if (!$last_revision_row) {\n}\nif (\n$last_revision_row['deleted'] ||\n- $last_revision_row['text'] !== $entry_row['text']\n+ $last_revision_row['text'] !== $last_revision_row['entry_text']\n) {\nexit(json_encode(array(\n'error' => 'database_corruption',\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Compare values at same time |
129,187 | 08.02.2017 16:23:10 | 18,000 | 2af5154a23a4794ee8739c20e7ee911b9fc669cc | Add flow-typed for Redux | [
{
"change_type": "MODIFY",
"old_path": "lib/model/redux-reducer.js",
"new_path": "lib/model/redux-reducer.js",
"diff": "@@ -63,7 +63,9 @@ export type Dispatch<T: BaseAppState, A> =\n((promisedAction: PromisedAction<T, A>) => void) &\n((promisedAction: PromisedAction<T, BaseAction<T>>) => void);\n-export function baseReducer<T: BaseAppState>(state: T, action: BaseAction<T>) {\n+export function baseReducer<T: BaseAppState>(\n+ state: T, action: BaseAction<T>,\n+): T {\nif (action.type === \"GENERIC\") {\nreturn action.callback(state);\n}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "web/flow-typed/npm/redux_v3.x.x.js",
"diff": "+// flow-typed signature: ba132c96664f1a05288f3eb2272a3c35\n+// flow-typed version: c4bbd91cfc/redux_v3.x.x/flow_>=v0.33.x\n+\n+declare module 'redux' {\n+\n+ /*\n+\n+ S = State\n+ A = Action\n+\n+ */\n+\n+ declare type Dispatch<A: { type: $Subtype<string> }> = (action: A) => A;\n+\n+ declare type MiddlewareAPI<S, A> = {\n+ dispatch: Dispatch<A>;\n+ getState(): S;\n+ };\n+\n+ declare type Store<S, A> = {\n+ // rewrite MiddlewareAPI members in order to get nicer error messages (intersections produce long messages)\n+ dispatch: Dispatch<A>;\n+ getState(): S;\n+ subscribe(listener: () => void): () => void;\n+ replaceReducer(nextReducer: Reducer<S, A>): void\n+ };\n+\n+ declare type Reducer<S, A> = (state: S, action: A) => S;\n+\n+ declare type Middleware<S, A> =\n+ (api: MiddlewareAPI<S, A>) =>\n+ (next: Dispatch<A>) => Dispatch<A>;\n+\n+ declare type StoreCreator<S, A> = {\n+ (reducer: Reducer<S, A>, enhancer?: StoreEnhancer<S, A>): Store<S, A>;\n+ (reducer: Reducer<S, A>, preloadedState: S, enhancer?: StoreEnhancer<S, A>): Store<S, A>;\n+ };\n+\n+ declare type StoreEnhancer<S, A> = (next: StoreCreator<S, A>) => StoreCreator<S, A>;\n+\n+ declare function createStore<S, A>(reducer: Reducer<S, A>, enhancer?: StoreEnhancer<S, A>): Store<S, A>;\n+ declare function createStore<S, A>(reducer: Reducer<S, A>, preloadedState: S, enhancer?: StoreEnhancer<S, A>): Store<S, A>;\n+\n+ declare function applyMiddleware<S, A>(...middlewares: Array<Middleware<S, A>>): StoreEnhancer<S, A>;\n+\n+ declare type ActionCreator<A, B> = (...args: Array<B>) => A;\n+ declare type ActionCreators<K, A> = { [key: K]: ActionCreator<A, any> };\n+\n+ declare function bindActionCreators<A, C: ActionCreator<A, any>>(actionCreator: C, dispatch: Dispatch<A>): C;\n+ declare function bindActionCreators<A, K, C: ActionCreators<K, A>>(actionCreators: C, dispatch: Dispatch<A>): C;\n+\n+ declare function combineReducers<O: Object, A>(reducers: O): Reducer<$ObjMap<O, <S>(r: Reducer<S, any>) => S>, A>;\n+\n+ declare function compose<S, A>(...fns: Array<StoreEnhancer<S, A>>): Function;\n+\n+}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Add flow-typed for Redux |
129,187 | 08.02.2017 23:03:29 | 18,000 | 003bb3547f2eaeb023650ed5aee6beabb1753583 | Pull out types into separate files too | [
{
"change_type": "MODIFY",
"old_path": "lib/reducers/loading-reducer.js",
"new_path": "lib/reducers/loading-reducer.js",
"diff": "import type {\nBaseAppState,\n- LoadingStatus,\nBaseAction,\n} from '../types/redux-types';\n+import type { LoadingStatus } from '../types/loading-types';\nimport _ from 'lodash';\nimport invariant from 'invariant';\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/selectors/loading-selectors.js",
"new_path": "lib/selectors/loading-selectors.js",
"diff": "// @flow\n-import type { BaseAppState, LoadingStatus } from '../types/redux-types';\n+import type { BaseAppState } from '../types/redux-types';\n+import type { LoadingStatus } from '../types/loading-types';\nimport { createSelector } from 'reselect';\nimport _ from 'lodash';\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/selectors/nav-selectors.js",
"new_path": "lib/selectors/nav-selectors.js",
"diff": "// @flow\n-import type { BaseNavInfo, BaseAppState } from '../types/redux-types';\n+import type { BaseAppState } from '../types/redux-types';\n+import type { BaseNavInfo } from '../types/nav-types';\nimport type { CalendarInfo } from '../types/calendar-types';\nimport { createSelector } from 'reselect';\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "lib/types/loading-types.js",
"diff": "+// @flow\n+\n+export type LoadingStatus = \"inactive\" | \"loading\" | \"error\";\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "lib/types/nav-types.js",
"diff": "+// @flow\n+\n+export type BaseNavInfo = {\n+ home: bool,\n+ calendarID: ?string,\n+};\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/types/redux-types.js",
"new_path": "lib/types/redux-types.js",
"diff": "import type { CalendarInfo } from './calendar-types';\nimport type { EntryInfo } from './entry-types';\n-\n-export type BaseNavInfo = {\n- home: bool,\n- calendarID: ?string,\n-};\n-\n-export type UserInfo = {\n- username: string,\n- email: string,\n- emailVerified: bool,\n-};\n-\n-export type LoadingStatus = \"inactive\" | \"loading\" | \"error\";\n+import type { LoadingStatus } from './loading-types';\n+import type { BaseNavInfo } from './nav-types';\n+import type { UserInfo } from './user-types';\nexport type BaseAppState = {\n// This \"+\" means that navInfo can be a sub-type of BaseNavInfo. As a result,\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "lib/types/user-types.js",
"diff": "+// @flow\n+\n+export type UserInfo = {\n+ username: string,\n+ email: string,\n+ emailVerified: bool,\n+};\n"
},
{
"change_type": "MODIFY",
"old_path": "web/app.react.js",
"new_path": "web/app.react.js",
"diff": "@@ -7,8 +7,8 @@ import type {\nUpdateStore,\nDispatch,\nUpdateCallback,\n- LoadingStatus,\n} from 'lib/types/redux-types';\n+import type { LoadingStatus } from 'lib/types/loading-types';\nimport type { AppState, NavInfo, Action } from './redux-setup';\nimport { navInfoPropType } from './redux-setup';\n"
},
{
"change_type": "MODIFY",
"old_path": "web/calendar/entry.react.js",
"new_path": "web/calendar/entry.react.js",
"diff": "@@ -4,7 +4,8 @@ import type { EntryInfo } from 'lib/types/entry-types';\nimport { entryInfoPropType } from 'lib/types/entry-types';\nimport type { CalendarInfo } from 'lib/types/calendar-types';\nimport { calendarInfoPropType } from 'lib/types/calendar-types';\n-import type { UpdateStore, LoadingStatus } from 'lib/types/redux-types';\n+import type { UpdateStore } from 'lib/types/redux-types';\n+import type { LoadingStatus } from 'lib/types/loading-types';\nimport type { AppState } from '../redux-setup';\nimport React from 'react';\n"
},
{
"change_type": "MODIFY",
"old_path": "web/loading-indicator.react.js",
"new_path": "web/loading-indicator.react.js",
"diff": "// @flow\n-import type { LoadingStatus } from 'lib/types/redux-types';\n+import type { LoadingStatus } from 'lib/types/loading-types';\nimport React from 'react';\n"
},
{
"change_type": "MODIFY",
"old_path": "web/modals/history/history-entry.react.js",
"new_path": "web/modals/history/history-entry.react.js",
"diff": "@@ -5,7 +5,7 @@ import { calendarInfoPropType } from 'lib/types/calendar-types';\nimport type { EntryInfo } from 'lib/types/entry-types';\nimport { entryInfoPropType } from 'lib/types/entry-types';\nimport type { AppState } from '../../redux-setup';\n-import type { LoadingStatus } from 'lib/types/redux-types';\n+import type { LoadingStatus } from 'lib/types/loading-types';\nimport React from 'react';\nimport classNames from 'classnames';\n"
},
{
"change_type": "MODIFY",
"old_path": "web/modals/history/history-modal.react.js",
"new_path": "web/modals/history/history-modal.react.js",
"diff": "@@ -8,9 +8,9 @@ import { entryInfoPropType } from 'lib/types/entry-types';\nimport type {\nUpdateStore,\nUpdateCallback,\n- LoadingStatus,\nDispatch,\n} from 'lib/types/redux-types';\n+import type { LoadingStatus } from 'lib/types/loading-types';\nimport type { AppState, Action } from '../../redux-setup';\nimport React from 'react';\n"
},
{
"change_type": "MODIFY",
"old_path": "web/redux-setup.js",
"new_path": "web/redux-setup.js",
"diff": "import type { CalendarInfo } from 'lib/types/calendar-types';\nimport type { EntryInfo } from 'lib/types/entry-types';\n-import type {\n- UserInfo,\n- LoadingStatus,\n- BaseAction,\n-} from 'lib/types/redux-types';\n+import type { BaseAction } from 'lib/types/redux-types';\n+import type { LoadingStatus } from 'lib/types/loading-types';\n+import type { UserInfo } from 'lib/types/user-types';\nimport baseReducer from 'lib/reducers/master-reducer';\n"
},
{
"change_type": "MODIFY",
"old_path": "web/typeahead/typeahead-calendar-option.react.js",
"new_path": "web/typeahead/typeahead-calendar-option.react.js",
"diff": "import type { CalendarInfo } from 'lib/types/calendar-types';\nimport { calendarInfoPropType } from 'lib/types/calendar-types';\n-import type { UpdateStore, LoadingStatus } from 'lib/types/redux-types';\n+import type { UpdateStore } from 'lib/types/redux-types';\n+import type { LoadingStatus } from 'lib/types/loading-types';\nimport type { AppState } from '../redux-setup';\nimport React from 'react';\n"
},
{
"change_type": "MODIFY",
"old_path": "web/typeahead/typeahead-option-buttons.react.js",
"new_path": "web/typeahead/typeahead-option-buttons.react.js",
"diff": "@@ -6,8 +6,8 @@ import type {\nUpdateStore,\nDispatch,\nUpdateCallback,\n- LoadingStatus,\n} from 'lib/types/redux-types';\n+import type { LoadingStatus } from 'lib/types/loading-types';\nimport type { AppState, Action } from '../redux-setup';\nimport React from 'react';\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Pull out types into separate files too |
129,187 | 11.02.2017 21:17:15 | 18,000 | 0c55cf6634d6b60afdaa279729b64ee94ea29f04 | goodbye GENERIC! everything is action-ified | [
{
"change_type": "DELETE",
"old_path": "lib/shared/redux-utils.js",
"new_path": null,
"diff": "-// @flow\n-\n-import type {\n- Dispatch,\n- UpdateCallback,\n- BaseAppState,\n-} from '../types/redux-types';\n-\n-function mapStateToUpdateStore<T: BaseAppState, A>(\n- dispatch: Dispatch<T, A>,\n-) {\n- return {\n- updateStore: (callback: UpdateCallback<T>) =>\n- dispatch({ type: \"GENERIC\", callback }),\n- };\n-}\n-\n-export { mapStateToUpdateStore }\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/types/redux-types.js",
"new_path": "lib/types/redux-types.js",
"diff": "@@ -18,12 +18,8 @@ export type BaseAppState = {\nloadingStatuses: {[key: string]: {[idx: number]: LoadingStatus}},\n};\n-export type UpdateCallback<T: BaseAppState> = (prevState: T) => T;\n-export type UpdateStore<T: BaseAppState> = (update: UpdateCallback<T>) => void;\n-\nexport type BaseAction<T: BaseAppState> =\n- { type: \"@@redux/INIT\" } |\n- { type: \"GENERIC\", callback: UpdateCallback<T> } | {\n+ { type: \"@@redux/INIT\" } | {\ntype: \"FETCH_MONTH_ENTRIES_STARTED\",\nloadingInfo: LoadingInfo,\n} | {\n@@ -286,7 +282,6 @@ export type BaseAction<T: BaseAppState> =\nloadingInfo: LoadingInfo,\n};\n-\ntype ThunkedAction<T: BaseAppState, A> = (dispatch: Dispatch<T, A>) => void;\ntype PromisedAction<T: BaseAppState, A> =\n(dispatch: Dispatch<T, A>) => Promise<void>;\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | goodbye GENERIC! everything is action-ified |
129,187 | 15.02.2017 03:54:41 | 18,000 | e3c9b811e146378bedecb7a6109debb38de3d2f6 | NavigatorIOS to react-navigation, and I can run it in Android now! | [
{
"change_type": "MODIFY",
"old_path": "native/.flowconfig",
"new_path": "native/.flowconfig",
"diff": ".*/Libraries/react-native/React.js\n.*/Libraries/react-native/ReactNative.js\n+; These guys...\n+.*/node_modules/react-navigation/.*\n+\n[include]\n[libs]\n@@ -41,5 +44,7 @@ suppress_comment=\\\\(.\\\\|\\n\\\\)*\\\\$FlowFixedInNextDeploy\nunsafe.enable_getters_and_setters=true\n+module.name_mapper='^react-navigation$' -> 'emptyObject'\n+\n[version]\n^0.36.0\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/app.react.js",
"diff": "+// @flow\n+\n+import React from 'react';\n+import {\n+ AppRegistry,\n+ StyleSheet,\n+ Text,\n+ View,\n+} from 'react-native';\n+import Icon from 'react-native-vector-icons/FontAwesome';\n+import { TabNavigator } from 'react-navigation';\n+\n+import Calendar from './calendar/calendar.react';\n+import Chat from './chat/chat.react';\n+import More from './more/more.react';\n+\n+const App = TabNavigator({\n+ Calendar: { screen: Calendar },\n+ Chat: { screen: Chat },\n+ More: { screen: More },\n+});\n+\n+AppRegistry.registerComponent('SquadCal', () => App);\n"
},
{
"change_type": "RENAME",
"old_path": "native/ios-components/calendar.js",
"new_path": "native/calendar/calendar.react.js",
"diff": "import React from 'react';\nimport { View, StyleSheet, Text } from 'react-native';\n+import Icon from 'react-native-vector-icons/FontAwesome';\nimport * as TypeaheadText from 'lib/shared/typeahead-text.js';\n@@ -10,11 +11,23 @@ type Props = {\ntype State = {\n};\n-class Calendar extends React.Component {\n+class Calendar extends React.PureComponent {\nprops: Props;\nstate: State;\n+ static navigationOptions = {\n+ tabBar: {\n+ label: 'Calendar',\n+ icon: ({ tintColor }) => (\n+ <Icon\n+ name=\"calendar\"\n+ style={[styles.icon, { color: tintColor }]}\n+ />\n+ ),\n+ },\n+ };\n+\nconstructor(props: Props) {\nsuper(props);\nthis.state = {\n@@ -37,6 +50,9 @@ class Calendar extends React.Component {\n}\nconst styles = StyleSheet.create({\n+ icon: {\n+ fontSize: 28,\n+ },\ncontainer: {\nflex: 1,\njustifyContent: 'center',\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/chat/chat.react.js",
"diff": "+// @flow\n+\n+import React from 'react';\n+import { View, StyleSheet, Text } from 'react-native';\n+import Icon from 'react-native-vector-icons/FontAwesome';\n+\n+type Props = {\n+};\n+type State = {\n+};\n+\n+class Chat extends React.PureComponent {\n+\n+ props: Props;\n+ state: State;\n+\n+ static navigationOptions = {\n+ tabBar: {\n+ label: 'Chat',\n+ icon: ({ tintColor }) => (\n+ <Icon\n+ name=\"comments-o\"\n+ style={[styles.icon, { color: tintColor }]}\n+ />\n+ ),\n+ },\n+ };\n+\n+ render() {\n+ return (\n+ <View style={styles.container}>\n+ <Text style={styles.instructions}>\n+ Stay down\n+ </Text>\n+ </View>\n+ );\n+ }\n+\n+}\n+\n+const styles = StyleSheet.create({\n+ icon: {\n+ fontSize: 28,\n+ },\n+ container: {\n+ flex: 1,\n+ justifyContent: 'center',\n+ alignItems: 'center',\n+ backgroundColor: '#F5FCFF',\n+ },\n+ instructions: {\n+ textAlign: 'center',\n+ color: '#333333',\n+ marginBottom: 5,\n+ },\n+});\n+\n+export default Chat;\n"
},
{
"change_type": "MODIFY",
"old_path": "native/index.android.js",
"new_path": "native/index.android.js",
"diff": "-/**\n- * Sample React Native App\n- * https://github.com/facebook/react-native\n- * @flow\n- */\n+// @flow\n-import React, { Component } from 'react';\n-import {\n- AppRegistry,\n- StyleSheet,\n- Text,\n- View\n-} from 'react-native';\n-\n-export default class SquadCal extends Component {\n- render() {\n- return (\n- <View style={styles.container}>\n- <Text style={styles.welcome}>\n- Welcome to React Native!\n- </Text>\n- <Text style={styles.instructions}>\n- To get started, edit index.android.js\n- </Text>\n- <Text style={styles.instructions}>\n- Double tap R on your keyboard to reload,{'\\n'}\n- Shake or press menu button for dev menu\n- </Text>\n- </View>\n- );\n- }\n-}\n-\n-const styles = StyleSheet.create({\n- container: {\n- flex: 1,\n- justifyContent: 'center',\n- alignItems: 'center',\n- backgroundColor: '#F5FCFF',\n- },\n- welcome: {\n- fontSize: 20,\n- textAlign: 'center',\n- margin: 10,\n- },\n- instructions: {\n- textAlign: 'center',\n- color: '#333333',\n- marginBottom: 5,\n- },\n-});\n-\n-AppRegistry.registerComponent('SquadCal', () => SquadCal);\n+import './app.react';\n"
},
{
"change_type": "MODIFY",
"old_path": "native/index.ios.js",
"new_path": "native/index.ios.js",
"diff": "// @flow\n-import React from 'react';\n-import {\n- AppRegistry,\n- StyleSheet,\n- Text,\n- View,\n- TabBarIOS,\n-} from 'react-native';\n-import Icon from 'react-native-vector-icons/FontAwesome';\n-\n-import Calendar from './ios-components/calendar';\n-\n-type Props = {\n-};\n-type State = {\n- selectedTab: string,\n-};\n-\n-class SquadCal extends React.Component {\n-\n- props: Props;\n- state: State;\n-\n- constructor(props: Props) {\n- super(props);\n- this.state = {\n- selectedTab: 'calendar',\n- };\n- }\n-\n- render() {\n- return (\n- <TabBarIOS>\n- <Icon.TabBarItemIOS\n- title=\"Calendar\"\n- selected={this.state.selectedTab === 'calendar'}\n- onPress={() => this.setState({ selectedTab: 'calendar' })}\n- iconName=\"calendar\"\n- >\n- <Calendar />\n- </Icon.TabBarItemIOS>\n- <Icon.TabBarItemIOS\n- title=\"Chat\"\n- selected={this.state.selectedTab === 'chat'}\n- onPress={() => this.setState({ selectedTab: 'chat' })}\n- iconName=\"comments-o\"\n- >\n- <View style={styles.container}>\n- <Text style={styles.instructions}>\n- Stay down\n- </Text>\n- </View>\n- </Icon.TabBarItemIOS>\n- <Icon.TabBarItemIOS\n- title=\"More\"\n- selected={this.state.selectedTab === 'more'}\n- onPress={() => this.setState({ selectedTab: 'more' })}\n- iconName=\"bars\"\n- >\n- <View style={styles.container}>\n- <Text style={styles.instructions}>\n- Press Cmd+R to reload,{'\\n'}\n- Cmd+D or shake for dev menu\n- </Text>\n- </View>\n- </Icon.TabBarItemIOS>\n- </TabBarIOS>\n- );\n- }\n-\n-}\n-\n-const styles = StyleSheet.create({\n- container: {\n- flex: 1,\n- justifyContent: 'center',\n- alignItems: 'center',\n- backgroundColor: '#F5FCFF',\n- },\n- instructions: {\n- textAlign: 'center',\n- color: '#333333',\n- marginBottom: 5,\n- },\n-});\n-\n-AppRegistry.registerComponent('SquadCal', () => SquadCal);\n-\n-export default SquadCal;\n+import './app.react';\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/more/more.react.js",
"diff": "+// @flow\n+\n+import React from 'react';\n+import { View, StyleSheet, Text } from 'react-native';\n+import Icon from 'react-native-vector-icons/FontAwesome';\n+\n+type Props = {\n+};\n+type State = {\n+};\n+\n+class More extends React.PureComponent {\n+\n+ props: Props;\n+ state: State;\n+\n+ static navigationOptions = {\n+ tabBar: {\n+ label: 'More',\n+ icon: ({ tintColor }) => (\n+ <Icon\n+ name=\"bars\"\n+ style={[styles.icon, { color: tintColor }]}\n+ />\n+ ),\n+ },\n+ };\n+\n+ render() {\n+ return (\n+ <View style={styles.container}>\n+ <Text style={styles.instructions}>\n+ Press Cmd+R to reload,{'\\n'}\n+ Cmd+D or shake for dev menu\n+ </Text>\n+ </View>\n+ );\n+ }\n+\n+}\n+\n+const styles = StyleSheet.create({\n+ icon: {\n+ fontSize: 28,\n+ },\n+ container: {\n+ flex: 1,\n+ justifyContent: 'center',\n+ alignItems: 'center',\n+ backgroundColor: '#F5FCFF',\n+ },\n+ instructions: {\n+ textAlign: 'center',\n+ color: '#333333',\n+ marginBottom: 5,\n+ },\n+});\n+\n+export default More;\n"
},
{
"change_type": "MODIFY",
"old_path": "native/package.json",
"new_path": "native/package.json",
"diff": "\"dependencies\": {\n\"react\": \"15.4.2\",\n\"react-native\": \"0.40.0\",\n- \"react-native-vector-icons\": \"^4.0.0\"\n+ \"react-native-vector-icons\": \"^4.0.0\",\n+ \"react-navigation\": \"^1.0.0-beta.3\"\n},\n\"devDependencies\": {\n\"babel-jest\": \"18.0.0\",\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | NavigatorIOS to react-navigation, and I can run it in Android now! |
129,187 | 15.02.2017 04:20:16 | 18,000 | 7e0572e16f25bf711d3bf4a8d0fa1e4ead65095b | Upgrade react-native versions | [
{
"change_type": "MODIFY",
"old_path": "native/.flowconfig",
"new_path": "native/.flowconfig",
"diff": "@@ -38,8 +38,8 @@ suppress_type=$FlowIssue\nsuppress_type=$FlowFixMe\nsuppress_type=$FixMe\n-suppress_comment=\\\\(.\\\\|\\n\\\\)*\\\\$FlowFixMe\\\\($\\\\|[^(]\\\\|(\\\\(>=0\\\\.\\\\(3[0-6]\\\\|[1-2][0-9]\\\\|[0-9]\\\\).[0-9]\\\\)? *\\\\(site=[a-z,_]*react_native[a-z,_]*\\\\)?)\\\\)\n-suppress_comment=\\\\(.\\\\|\\n\\\\)*\\\\$FlowIssue\\\\((\\\\(>=0\\\\.\\\\(3[0-6]\\\\|1[0-9]\\\\|[1-2][0-9]\\\\).[0-9]\\\\)? *\\\\(site=[a-z,_]*react_native[a-z,_]*\\\\)?)\\\\)?:? #[0-9]+\n+suppress_comment=\\\\(.\\\\|\\n\\\\)*\\\\$FlowFixMe\\\\($\\\\|[^(]\\\\|(\\\\(>=0\\\\.\\\\(3[0-7]\\\\|[1-2][0-9]\\\\|[0-9]\\\\).[0-9]\\\\)? *\\\\(site=[a-z,_]*react_native[a-z,_]*\\\\)?)\\\\)\n+suppress_comment=\\\\(.\\\\|\\n\\\\)*\\\\$FlowIssue\\\\((\\\\(>=0\\\\.\\\\(3[0-7]\\\\|1[0-9]\\\\|[1-2][0-9]\\\\).[0-9]\\\\)? *\\\\(site=[a-z,_]*react_native[a-z,_]*\\\\)?)\\\\)?:? #[0-9]+\nsuppress_comment=\\\\(.\\\\|\\n\\\\)*\\\\$FlowFixedInNextDeploy\nunsafe.enable_getters_and_setters=true\n@@ -47,4 +47,4 @@ unsafe.enable_getters_and_setters=true\nmodule.name_mapper='^react-navigation$' -> 'emptyObject'\n[version]\n-^0.36.0\n+^0.37.0\n"
},
{
"change_type": "MODIFY",
"old_path": "native/.gitignore",
"new_path": "native/.gitignore",
"diff": "@@ -30,6 +30,7 @@ local.properties\n#\nnode_modules/\nnpm-debug.log\n+yarn-error.log\n# BUCK\nbuck-out/\n"
},
{
"change_type": "MODIFY",
"old_path": "native/android/app/src/main/java/com/squadcal/MainApplication.java",
"new_path": "native/android/app/src/main/java/com/squadcal/MainApplication.java",
"diff": "@@ -18,7 +18,7 @@ public class MainApplication extends Application implements ReactApplication {\nprivate final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {\n@Override\n- protected boolean getUseDeveloperSupport() {\n+ public boolean getUseDeveloperSupport() {\nreturn BuildConfig.DEBUG;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "native/android/app/src/main/res/values/strings.xml",
"new_path": "native/android/app/src/main/res/values/strings.xml",
"diff": "<resources>\n- <string name=\"app_name\">SquadCal</string>\n+ <string name=\"app_name\">Hello App Display Name</string>\n</resources>\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/app.json",
"diff": "+{\n+ \"name\": \"SquadCal\",\n+ \"displayName\": \"SquadCal\"\n+}\n\\ No newline at end of file\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/ios/SquadCal-tvOS/Info.plist",
"diff": "+<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n+<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n+<plist version=\"1.0\">\n+<dict>\n+ <key>CFBundleDevelopmentRegion</key>\n+ <string>en</string>\n+ <key>CFBundleExecutable</key>\n+ <string>$(EXECUTABLE_NAME)</string>\n+ <key>CFBundleIdentifier</key>\n+ <string>org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)</string>\n+ <key>CFBundleInfoDictionaryVersion</key>\n+ <string>6.0</string>\n+ <key>CFBundleName</key>\n+ <string>$(PRODUCT_NAME)</string>\n+ <key>CFBundlePackageType</key>\n+ <string>APPL</string>\n+ <key>CFBundleShortVersionString</key>\n+ <string>1.0</string>\n+ <key>CFBundleSignature</key>\n+ <string>????</string>\n+ <key>CFBundleVersion</key>\n+ <string>1</string>\n+ <key>LSRequiresIPhoneOS</key>\n+ <true/>\n+ <key>UILaunchStoryboardName</key>\n+ <string>LaunchScreen</string>\n+ <key>UIRequiredDeviceCapabilities</key>\n+ <array>\n+ <string>armv7</string>\n+ </array>\n+ <key>UISupportedInterfaceOrientations</key>\n+ <array>\n+ <string>UIInterfaceOrientationPortrait</string>\n+ <string>UIInterfaceOrientationLandscapeLeft</string>\n+ <string>UIInterfaceOrientationLandscapeRight</string>\n+ </array>\n+ <key>UIViewControllerBasedStatusBarAppearance</key>\n+ <false/>\n+ <key>NSLocationWhenInUseUsageDescription</key>\n+ <string></string>\n+ <key>NSAppTransportSecurity</key>\n+ <!--See http://ste.vn/2015/06/10/configuring-app-transport-security-ios-9-osx-10-11/ -->\n+ <dict>\n+ <key>NSExceptionDomains</key>\n+ <dict>\n+ <key>localhost</key>\n+ <dict>\n+ <key>NSExceptionAllowsInsecureHTTPLoads</key>\n+ <true/>\n+ </dict>\n+ </dict>\n+ </dict>\n+</dict>\n+</plist>\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/ios/SquadCal-tvOSTests/Info.plist",
"diff": "+<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n+<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n+<plist version=\"1.0\">\n+<dict>\n+ <key>CFBundleDevelopmentRegion</key>\n+ <string>en</string>\n+ <key>CFBundleExecutable</key>\n+ <string>$(EXECUTABLE_NAME)</string>\n+ <key>CFBundleIdentifier</key>\n+ <string>org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)</string>\n+ <key>CFBundleInfoDictionaryVersion</key>\n+ <string>6.0</string>\n+ <key>CFBundleName</key>\n+ <string>$(PRODUCT_NAME)</string>\n+ <key>CFBundlePackageType</key>\n+ <string>BNDL</string>\n+ <key>CFBundleShortVersionString</key>\n+ <string>1.0</string>\n+ <key>CFBundleSignature</key>\n+ <string>????</string>\n+ <key>CFBundleVersion</key>\n+ <string>1</string>\n+</dict>\n+</plist>\n"
},
{
"change_type": "MODIFY",
"old_path": "native/ios/SquadCal.xcodeproj/project.pbxproj",
"new_path": "native/ios/SquadCal.xcodeproj/project.pbxproj",
"diff": "1AB3FA5006B7410FB4C0C308 /* Zocial.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 74BC06F2619F4105BB8D473C /* Zocial.ttf */; };\n24B72AE3C09241F9A274374B /* SimpleLineIcons.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 72CCB14CB9C744758BCC6EE2 /* SimpleLineIcons.ttf */; };\n545521FF2565416A81948191 /* Entypo.ttf in Resources */ = {isa = PBXBuildFile; fileRef = D8C2220A10374037B86EF5C7 /* Entypo.ttf */; };\n+ 2D02E4BC1E0B4A80006451C7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB01A68108700A75B9A /* AppDelegate.m */; };\n+ 2D02E4BD1E0B4A84006451C7 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; };\n+ 2D02E4BF1E0B4AB3006451C7 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; };\n+ 2D02E4C21E0B4AEC006451C7 /* libRCTAnimation-tvOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5E9157351DD0AC6500FF2AA8 /* libRCTAnimation-tvOS.a */; };\n+ 2D02E4C31E0B4AEC006451C7 /* libRCTImage-tvOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3DAD3E841DF850E9000B6D8A /* libRCTImage-tvOS.a */; };\n+ 2D02E4C41E0B4AEC006451C7 /* libRCTLinking-tvOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3DAD3E881DF850E9000B6D8A /* libRCTLinking-tvOS.a */; };\n+ 2D02E4C51E0B4AEC006451C7 /* libRCTNetwork-tvOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3DAD3E8C1DF850E9000B6D8A /* libRCTNetwork-tvOS.a */; };\n+ 2D02E4C61E0B4AEC006451C7 /* libRCTSettings-tvOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3DAD3E901DF850E9000B6D8A /* libRCTSettings-tvOS.a */; };\n+ 2D02E4C71E0B4AEC006451C7 /* libRCTText-tvOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3DAD3E941DF850E9000B6D8A /* libRCTText-tvOS.a */; };\n+ 2D02E4C81E0B4AEC006451C7 /* 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+ 2DCD954D1E0B4F2C00145EB5 /* SquadCalTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 00E356F21AD99517003FC87E /* SquadCalTests.m */; };\n5E9157361DD0AC6A00FF2AA8 /* libRCTAnimation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5E9157331DD0AC6500FF2AA8 /* libRCTAnimation.a */; };\n6280BFDC755A423EA3F9F1F3 /* EvilIcons.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 25382D0B9DF641E5980C767A /* EvilIcons.ttf */; };\n73AC2D19D21A429F82DFEF39 /* MaterialIcons.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 252B3C4EBB754456AC3DA62B /* MaterialIcons.ttf */; };\nremoteGlobalIDString = 83CBBA2E1A601D0E00E9B192;\nremoteInfo = React;\n};\n+ 2D02E4911E0B4A5D006451C7 /* PBXContainerItemProxy */ = {\n+ isa = PBXContainerItemProxy;\n+ containerPortal = 83CBB9F71A601CBA00E9B192 /* Project object */;\n+ proxyType = 1;\n+ remoteGlobalIDString = 2D02E47A1E0B4A5D006451C7;\n+ remoteInfo = \"SquadCal-tvOS\";\n+ };\n3DAD3E831DF850E9000B6D8A /* PBXContainerItemProxy */ = {\nisa = PBXContainerItemProxy;\ncontainerPortal = 00C302BB1ABCB91800DB3ED1 /* RCTImage.xcodeproj */;\n3CF8E5A2C4D7400DABC42E1C /* 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>\"; };\n3FA5703B95A944A3B8C2A544 /* 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>\"; };\n46133BB826CA47C8896F9081 /* 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+ 2D02E47B1E0B4A5D006451C7 /* SquadCal-tvOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = \"SquadCal-tvOS.app\"; sourceTree = BUILT_PRODUCTS_DIR; };\n+ 2D02E4901E0B4A5D006451C7 /* SquadCal-tvOSTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = \"SquadCal-tvOSTests.xctest\"; 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>\"; };\n72CCB14CB9C744758BCC6EE2 /* 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>\"; };\n74BC06F2619F4105BB8D473C /* 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>\"; };\nisa = PBXFrameworksBuildPhase;\nbuildActionMask = 2147483647;\nfiles = (\n- 5E9157361DD0AC6A00FF2AA8 /* libRCTAnimation.a in Frameworks */,\n146834051AC3E58100842450 /* libReact.a in Frameworks */,\n+ 5E9157361DD0AC6A00FF2AA8 /* libRCTAnimation.a in Frameworks */,\n00C302E51ABCBA2D00DB3ED1 /* libRCTActionSheet.a in Frameworks */,\n00C302E71ABCBA2D00DB3ED1 /* libRCTGeolocation.a in Frameworks */,\n00C302E81ABCBA2D00DB3ED1 /* libRCTImage.a in Frameworks */,\n);\nrunOnlyForDeploymentPostprocessing = 0;\n};\n+ 2D02E4781E0B4A5D006451C7 /* Frameworks */ = {\n+ isa = PBXFrameworksBuildPhase;\n+ buildActionMask = 2147483647;\n+ files = (\n+ 2D02E4C91E0B4AEC006451C7 /* libReact.a in Frameworks */,\n+ 2D02E4C21E0B4AEC006451C7 /* libRCTAnimation-tvOS.a in Frameworks */,\n+ 2D02E4C31E0B4AEC006451C7 /* libRCTImage-tvOS.a in Frameworks */,\n+ 2D02E4C41E0B4AEC006451C7 /* libRCTLinking-tvOS.a in Frameworks */,\n+ 2D02E4C51E0B4AEC006451C7 /* libRCTNetwork-tvOS.a in Frameworks */,\n+ 2D02E4C61E0B4AEC006451C7 /* libRCTSettings-tvOS.a in Frameworks */,\n+ 2D02E4C71E0B4AEC006451C7 /* libRCTText-tvOS.a in Frameworks */,\n+ 2D02E4C81E0B4AEC006451C7 /* libRCTWebSocket-tvOS.a in Frameworks */,\n+ );\n+ runOnlyForDeploymentPostprocessing = 0;\n+ };\n+ 2D02E48D1E0B4A5D006451C7 /* Frameworks */ = {\n+ isa = PBXFrameworksBuildPhase;\n+ buildActionMask = 2147483647;\n+ files = (\n+ );\n+ runOnlyForDeploymentPostprocessing = 0;\n+ };\n/* End PBXFrameworksBuildPhase section */\n/* Begin PBXGroup section */\nchildren = (\n13B07F961A680F5B00A75B9A /* SquadCal.app */,\n00E356EE1AD99517003FC87E /* SquadCalTests.xctest */,\n+ 2D02E47B1E0B4A5D006451C7 /* SquadCal-tvOS.app */,\n+ 2D02E4901E0B4A5D006451C7 /* SquadCal-tvOSTests.xctest */,\n);\nname = Products;\nsourceTree = \"<group>\";\nproductReference = 13B07F961A680F5B00A75B9A /* SquadCal.app */;\nproductType = \"com.apple.product-type.application\";\n};\n+ 2D02E47A1E0B4A5D006451C7 /* SquadCal-tvOS */ = {\n+ isa = PBXNativeTarget;\n+ buildConfigurationList = 2D02E4BA1E0B4A5E006451C7 /* Build configuration list for PBXNativeTarget \"SquadCal-tvOS\" */;\n+ buildPhases = (\n+ 2D02E4771E0B4A5D006451C7 /* Sources */,\n+ 2D02E4781E0B4A5D006451C7 /* Frameworks */,\n+ 2D02E4791E0B4A5D006451C7 /* Resources */,\n+ 2D02E4CB1E0B4B27006451C7 /* Bundle React Native Code And Images */,\n+ );\n+ buildRules = (\n+ );\n+ dependencies = (\n+ );\n+ name = \"SquadCal-tvOS\";\n+ productName = \"SquadCal-tvOS\";\n+ productReference = 2D02E47B1E0B4A5D006451C7 /* SquadCal-tvOS.app */;\n+ productType = \"com.apple.product-type.application\";\n+ };\n+ 2D02E48F1E0B4A5D006451C7 /* SquadCal-tvOSTests */ = {\n+ isa = PBXNativeTarget;\n+ buildConfigurationList = 2D02E4BB1E0B4A5E006451C7 /* Build configuration list for PBXNativeTarget \"SquadCal-tvOSTests\" */;\n+ buildPhases = (\n+ 2D02E48C1E0B4A5D006451C7 /* Sources */,\n+ 2D02E48D1E0B4A5D006451C7 /* Frameworks */,\n+ 2D02E48E1E0B4A5D006451C7 /* Resources */,\n+ );\n+ buildRules = (\n+ );\n+ dependencies = (\n+ 2D02E4921E0B4A5D006451C7 /* PBXTargetDependency */,\n+ );\n+ name = \"SquadCal-tvOSTests\";\n+ productName = \"SquadCal-tvOSTests\";\n+ productReference = 2D02E4901E0B4A5D006451C7 /* SquadCal-tvOSTests.xctest */;\n+ productType = \"com.apple.product-type.bundle.unit-test\";\n+ };\n/* End PBXNativeTarget section */\n/* Begin PBXProject section */\nCreatedOnToolsVersion = 6.2;\nTestTargetID = 13B07F861A680F5B00A75B9A;\n};\n+ 2D02E47A1E0B4A5D006451C7 = {\n+ CreatedOnToolsVersion = 8.2.1;\n+ ProvisioningStyle = Automatic;\n+ };\n+ 2D02E48F1E0B4A5D006451C7 = {\n+ CreatedOnToolsVersion = 8.2.1;\n+ ProvisioningStyle = Automatic;\n+ TestTargetID = 2D02E47A1E0B4A5D006451C7;\n+ };\n};\n};\nbuildConfigurationList = 83CBB9FA1A601CBA00E9B192 /* Build configuration list for PBXProject \"SquadCal\" */;\ntargets = (\n13B07F861A680F5B00A75B9A /* SquadCal */,\n00E356ED1AD99517003FC87E /* SquadCalTests */,\n+ 2D02E47A1E0B4A5D006451C7 /* SquadCal-tvOS */,\n+ 2D02E48F1E0B4A5D006451C7 /* SquadCal-tvOSTests */,\n);\n};\n/* End PBXProject section */\n);\nrunOnlyForDeploymentPostprocessing = 0;\n};\n+ 2D02E4791E0B4A5D006451C7 /* Resources */ = {\n+ isa = PBXResourcesBuildPhase;\n+ buildActionMask = 2147483647;\n+ files = (\n+ 2D02E4BD1E0B4A84006451C7 /* Images.xcassets in Resources */,\n+ );\n+ runOnlyForDeploymentPostprocessing = 0;\n+ };\n+ 2D02E48E1E0B4A5D006451C7 /* Resources */ = {\n+ isa = PBXResourcesBuildPhase;\n+ buildActionMask = 2147483647;\n+ files = (\n+ );\n+ runOnlyForDeploymentPostprocessing = 0;\n+ };\n/* End PBXResourcesBuildPhase section */\n/* Begin PBXShellScriptBuildPhase section */\nshellPath = /bin/sh;\nshellScript = \"export NODE_BINARY=node\\n../node_modules/react-native/packager/react-native-xcode.sh\";\n};\n+ 2D02E4CB1E0B4B27006451C7 /* Bundle React Native Code And Images */ = {\n+ isa = PBXShellScriptBuildPhase;\n+ buildActionMask = 2147483647;\n+ files = (\n+ );\n+ inputPaths = (\n+ );\n+ name = \"Bundle React Native Code And Images\";\n+ outputPaths = (\n+ );\n+ runOnlyForDeploymentPostprocessing = 0;\n+ shellPath = /bin/sh;\n+ shellScript = \"export NODE_BINARY=node\\n../node_modules/react-native/packager/react-native-xcode.sh\";\n+ };\n/* End PBXShellScriptBuildPhase section */\n/* Begin PBXSourcesBuildPhase section */\n);\nrunOnlyForDeploymentPostprocessing = 0;\n};\n+ 2D02E4771E0B4A5D006451C7 /* Sources */ = {\n+ isa = PBXSourcesBuildPhase;\n+ buildActionMask = 2147483647;\n+ files = (\n+ 2D02E4BF1E0B4AB3006451C7 /* main.m in Sources */,\n+ 2D02E4BC1E0B4A80006451C7 /* AppDelegate.m in Sources */,\n+ );\n+ runOnlyForDeploymentPostprocessing = 0;\n+ };\n+ 2D02E48C1E0B4A5D006451C7 /* Sources */ = {\n+ isa = PBXSourcesBuildPhase;\n+ buildActionMask = 2147483647;\n+ files = (\n+ 2DCD954D1E0B4F2C00145EB5 /* SquadCalTests.m in Sources */,\n+ );\n+ runOnlyForDeploymentPostprocessing = 0;\n+ };\n/* End PBXSourcesBuildPhase section */\n/* Begin PBXTargetDependency section */\ntarget = 13B07F861A680F5B00A75B9A /* SquadCal */;\ntargetProxy = 00E356F41AD99517003FC87E /* PBXContainerItemProxy */;\n};\n+ 2D02E4921E0B4A5D006451C7 /* PBXTargetDependency */ = {\n+ isa = PBXTargetDependency;\n+ target = 2D02E47A1E0B4A5D006451C7 /* SquadCal-tvOS */;\n+ targetProxy = 2D02E4911E0B4A5D006451C7 /* PBXContainerItemProxy */;\n+ };\n/* End PBXTargetDependency section */\n/* Begin PBXVariantGroup section */\nINFOPLIST_FILE = SquadCalTests/Info.plist;\nIPHONEOS_DEPLOYMENT_TARGET = 8.0;\nLD_RUNPATH_SEARCH_PATHS = \"$(inherited) @executable_path/Frameworks @loader_path/Frameworks\";\n- LIBRARY_SEARCH_PATHS = (\n- \"$(inherited)\",\n- \"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n+ OTHER_LDFLAGS = (\n+ \"-ObjC\",\n+ \"-lc++\",\n);\nPRODUCT_NAME = \"$(TARGET_NAME)\";\nTEST_HOST = \"$(BUILT_PRODUCTS_DIR)/SquadCal.app/SquadCal\";\nINFOPLIST_FILE = SquadCalTests/Info.plist;\nIPHONEOS_DEPLOYMENT_TARGET = 8.0;\nLD_RUNPATH_SEARCH_PATHS = \"$(inherited) @executable_path/Frameworks @loader_path/Frameworks\";\n- LIBRARY_SEARCH_PATHS = (\n- \"$(inherited)\",\n- \"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n+ OTHER_LDFLAGS = (\n+ \"-ObjC\",\n+ \"-lc++\",\n);\nPRODUCT_NAME = \"$(TARGET_NAME)\";\nTEST_HOST = \"$(BUILT_PRODUCTS_DIR)/SquadCal.app/SquadCal\";\n};\nname = Release;\n};\n+ 2D02E4971E0B4A5E006451C7 /* Debug */ = {\n+ isa = XCBuildConfiguration;\n+ buildSettings = {\n+ ASSETCATALOG_COMPILER_APPICON_NAME = \"App Icon & Top Shelf Image\";\n+ ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;\n+ CLANG_ANALYZER_NONNULL = YES;\n+ CLANG_WARN_DOCUMENTATION_COMMENTS = YES;\n+ CLANG_WARN_INFINITE_RECURSION = YES;\n+ CLANG_WARN_SUSPICIOUS_MOVE = YES;\n+ DEBUG_INFORMATION_FORMAT = dwarf;\n+ ENABLE_TESTABILITY = YES;\n+ GCC_NO_COMMON_BLOCKS = YES;\n+ INFOPLIST_FILE = \"SquadCal-tvOS/Info.plist\";\n+ LD_RUNPATH_SEARCH_PATHS = \"$(inherited) @executable_path/Frameworks\";\n+ OTHER_LDFLAGS = (\n+ \"-ObjC\",\n+ \"-lc++\",\n+ );\n+ PRODUCT_BUNDLE_IDENTIFIER = \"com.facebook.REACT.SquadCal-tvOS\";\n+ PRODUCT_NAME = \"$(TARGET_NAME)\";\n+ SDKROOT = appletvos;\n+ TARGETED_DEVICE_FAMILY = 3;\n+ TVOS_DEPLOYMENT_TARGET = 9.2;\n+ };\n+ name = Debug;\n+ };\n+ 2D02E4981E0B4A5E006451C7 /* Release */ = {\n+ isa = XCBuildConfiguration;\n+ buildSettings = {\n+ ASSETCATALOG_COMPILER_APPICON_NAME = \"App Icon & Top Shelf Image\";\n+ ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;\n+ CLANG_ANALYZER_NONNULL = YES;\n+ CLANG_WARN_DOCUMENTATION_COMMENTS = YES;\n+ CLANG_WARN_INFINITE_RECURSION = YES;\n+ CLANG_WARN_SUSPICIOUS_MOVE = YES;\n+ COPY_PHASE_STRIP = NO;\n+ DEBUG_INFORMATION_FORMAT = \"dwarf-with-dsym\";\n+ GCC_NO_COMMON_BLOCKS = YES;\n+ INFOPLIST_FILE = \"SquadCal-tvOS/Info.plist\";\n+ LD_RUNPATH_SEARCH_PATHS = \"$(inherited) @executable_path/Frameworks\";\n+ OTHER_LDFLAGS = (\n+ \"-ObjC\",\n+ \"-lc++\",\n+ );\n+ PRODUCT_BUNDLE_IDENTIFIER = \"com.facebook.REACT.SquadCal-tvOS\";\n+ PRODUCT_NAME = \"$(TARGET_NAME)\";\n+ SDKROOT = appletvos;\n+ TARGETED_DEVICE_FAMILY = 3;\n+ TVOS_DEPLOYMENT_TARGET = 9.2;\n+ };\n+ name = Release;\n+ };\n+ 2D02E4991E0B4A5E006451C7 /* Debug */ = {\n+ isa = XCBuildConfiguration;\n+ buildSettings = {\n+ BUNDLE_LOADER = \"$(TEST_HOST)\";\n+ CLANG_ANALYZER_NONNULL = YES;\n+ CLANG_WARN_DOCUMENTATION_COMMENTS = YES;\n+ CLANG_WARN_INFINITE_RECURSION = YES;\n+ CLANG_WARN_SUSPICIOUS_MOVE = YES;\n+ DEBUG_INFORMATION_FORMAT = dwarf;\n+ ENABLE_TESTABILITY = YES;\n+ GCC_NO_COMMON_BLOCKS = YES;\n+ INFOPLIST_FILE = \"SquadCal-tvOSTests/Info.plist\";\n+ LD_RUNPATH_SEARCH_PATHS = \"$(inherited) @executable_path/Frameworks @loader_path/Frameworks\";\n+ PRODUCT_BUNDLE_IDENTIFIER = \"com.facebook.REACT.SquadCal-tvOSTests\";\n+ PRODUCT_NAME = \"$(TARGET_NAME)\";\n+ SDKROOT = appletvos;\n+ TEST_HOST = \"$(BUILT_PRODUCTS_DIR)/SquadCal-tvOS.app/SquadCal-tvOS\";\n+ TVOS_DEPLOYMENT_TARGET = 10.1;\n+ };\n+ name = Debug;\n+ };\n+ 2D02E49A1E0B4A5E006451C7 /* Release */ = {\n+ isa = XCBuildConfiguration;\n+ buildSettings = {\n+ BUNDLE_LOADER = \"$(TEST_HOST)\";\n+ CLANG_ANALYZER_NONNULL = YES;\n+ CLANG_WARN_DOCUMENTATION_COMMENTS = YES;\n+ CLANG_WARN_INFINITE_RECURSION = YES;\n+ CLANG_WARN_SUSPICIOUS_MOVE = YES;\n+ COPY_PHASE_STRIP = NO;\n+ DEBUG_INFORMATION_FORMAT = \"dwarf-with-dsym\";\n+ GCC_NO_COMMON_BLOCKS = YES;\n+ INFOPLIST_FILE = \"SquadCal-tvOSTests/Info.plist\";\n+ LD_RUNPATH_SEARCH_PATHS = \"$(inherited) @executable_path/Frameworks @loader_path/Frameworks\";\n+ PRODUCT_BUNDLE_IDENTIFIER = \"com.facebook.REACT.SquadCal-tvOSTests\";\n+ PRODUCT_NAME = \"$(TARGET_NAME)\";\n+ SDKROOT = appletvos;\n+ TEST_HOST = \"$(BUILT_PRODUCTS_DIR)/SquadCal-tvOS.app/SquadCal-tvOS\";\n+ TVOS_DEPLOYMENT_TARGET = 10.1;\n+ };\n+ name = Release;\n+ };\n83CBBA201A601CBA00E9B192 /* Debug */ = {\nisa = XCBuildConfiguration;\nbuildSettings = {\ndefaultConfigurationIsVisible = 0;\ndefaultConfigurationName = Release;\n};\n+ 2D02E4BA1E0B4A5E006451C7 /* Build configuration list for PBXNativeTarget \"SquadCal-tvOS\" */ = {\n+ isa = XCConfigurationList;\n+ buildConfigurations = (\n+ 2D02E4971E0B4A5E006451C7 /* Debug */,\n+ 2D02E4981E0B4A5E006451C7 /* Release */,\n+ );\n+ defaultConfigurationIsVisible = 0;\n+ defaultConfigurationName = Release;\n+ };\n+ 2D02E4BB1E0B4A5E006451C7 /* Build configuration list for PBXNativeTarget \"SquadCal-tvOSTests\" */ = {\n+ isa = XCConfigurationList;\n+ buildConfigurations = (\n+ 2D02E4991E0B4A5E006451C7 /* Debug */,\n+ 2D02E49A1E0B4A5E006451C7 /* Release */,\n+ );\n+ defaultConfigurationIsVisible = 0;\n+ defaultConfigurationName = Release;\n+ };\n83CBB9FA1A601CBA00E9B192 /* Build configuration list for PBXProject \"SquadCal\" */ = {\nisa = XCConfigurationList;\nbuildConfigurations = (\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/ios/SquadCal.xcodeproj/xcshareddata/xcschemes/SquadCal-tvOS.xcscheme",
"diff": "+<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n+<Scheme\n+ LastUpgradeVersion = \"0820\"\n+ version = \"1.3\">\n+ <BuildAction\n+ parallelizeBuildables = \"NO\"\n+ buildImplicitDependencies = \"YES\">\n+ <BuildActionEntries>\n+ <BuildActionEntry\n+ buildForTesting = \"YES\"\n+ buildForRunning = \"YES\"\n+ buildForProfiling = \"YES\"\n+ buildForArchiving = \"YES\"\n+ buildForAnalyzing = \"YES\">\n+ <BuildableReference\n+ BuildableIdentifier = \"primary\"\n+ BlueprintIdentifier = \"2D2A28121D9B038B00D4039D\"\n+ BuildableName = \"libReact.a\"\n+ BlueprintName = \"React-tvOS\"\n+ ReferencedContainer = \"container:../node_modules/react-native/React/React.xcodeproj\">\n+ </BuildableReference>\n+ </BuildActionEntry>\n+ <BuildActionEntry\n+ buildForTesting = \"YES\"\n+ buildForRunning = \"YES\"\n+ buildForProfiling = \"YES\"\n+ buildForArchiving = \"YES\"\n+ buildForAnalyzing = \"YES\">\n+ <BuildableReference\n+ BuildableIdentifier = \"primary\"\n+ BlueprintIdentifier = \"2D02E47A1E0B4A5D006451C7\"\n+ BuildableName = \"SquadCal-tvOS.app\"\n+ BlueprintName = \"SquadCal-tvOS\"\n+ ReferencedContainer = \"container:SquadCal.xcodeproj\">\n+ </BuildableReference>\n+ </BuildActionEntry>\n+ <BuildActionEntry\n+ buildForTesting = \"YES\"\n+ buildForRunning = \"YES\"\n+ buildForProfiling = \"NO\"\n+ buildForArchiving = \"NO\"\n+ buildForAnalyzing = \"YES\">\n+ <BuildableReference\n+ BuildableIdentifier = \"primary\"\n+ BlueprintIdentifier = \"2D02E48F1E0B4A5D006451C7\"\n+ BuildableName = \"SquadCal-tvOSTests.xctest\"\n+ BlueprintName = \"SquadCal-tvOSTests\"\n+ ReferencedContainer = \"container:SquadCal.xcodeproj\">\n+ </BuildableReference>\n+ </BuildActionEntry>\n+ </BuildActionEntries>\n+ </BuildAction>\n+ <TestAction\n+ buildConfiguration = \"Debug\"\n+ selectedDebuggerIdentifier = \"Xcode.DebuggerFoundation.Debugger.LLDB\"\n+ selectedLauncherIdentifier = \"Xcode.DebuggerFoundation.Launcher.LLDB\"\n+ shouldUseLaunchSchemeArgsEnv = \"YES\">\n+ <Testables>\n+ <TestableReference\n+ skipped = \"NO\">\n+ <BuildableReference\n+ BuildableIdentifier = \"primary\"\n+ BlueprintIdentifier = \"2D02E48F1E0B4A5D006451C7\"\n+ BuildableName = \"SquadCal-tvOSTests.xctest\"\n+ BlueprintName = \"SquadCal-tvOSTests\"\n+ ReferencedContainer = \"container:SquadCal.xcodeproj\">\n+ </BuildableReference>\n+ </TestableReference>\n+ </Testables>\n+ <MacroExpansion>\n+ <BuildableReference\n+ BuildableIdentifier = \"primary\"\n+ BlueprintIdentifier = \"2D02E47A1E0B4A5D006451C7\"\n+ BuildableName = \"SquadCal-tvOS.app\"\n+ BlueprintName = \"SquadCal-tvOS\"\n+ ReferencedContainer = \"container:SquadCal.xcodeproj\">\n+ </BuildableReference>\n+ </MacroExpansion>\n+ <AdditionalOptions>\n+ </AdditionalOptions>\n+ </TestAction>\n+ <LaunchAction\n+ buildConfiguration = \"Debug\"\n+ selectedDebuggerIdentifier = \"Xcode.DebuggerFoundation.Debugger.LLDB\"\n+ selectedLauncherIdentifier = \"Xcode.DebuggerFoundation.Launcher.LLDB\"\n+ launchStyle = \"0\"\n+ useCustomWorkingDirectory = \"NO\"\n+ ignoresPersistentStateOnLaunch = \"NO\"\n+ debugDocumentVersioning = \"YES\"\n+ debugServiceExtension = \"internal\"\n+ allowLocationSimulation = \"YES\">\n+ <BuildableProductRunnable\n+ runnableDebuggingMode = \"0\">\n+ <BuildableReference\n+ BuildableIdentifier = \"primary\"\n+ BlueprintIdentifier = \"2D02E47A1E0B4A5D006451C7\"\n+ BuildableName = \"SquadCal-tvOS.app\"\n+ BlueprintName = \"SquadCal-tvOS\"\n+ ReferencedContainer = \"container:SquadCal.xcodeproj\">\n+ </BuildableReference>\n+ </BuildableProductRunnable>\n+ <AdditionalOptions>\n+ </AdditionalOptions>\n+ </LaunchAction>\n+ <ProfileAction\n+ buildConfiguration = \"Release\"\n+ shouldUseLaunchSchemeArgsEnv = \"YES\"\n+ savedToolIdentifier = \"\"\n+ useCustomWorkingDirectory = \"NO\"\n+ debugDocumentVersioning = \"YES\">\n+ <BuildableProductRunnable\n+ runnableDebuggingMode = \"0\">\n+ <BuildableReference\n+ BuildableIdentifier = \"primary\"\n+ BlueprintIdentifier = \"2D02E47A1E0B4A5D006451C7\"\n+ BuildableName = \"SquadCal-tvOS.app\"\n+ BlueprintName = \"SquadCal-tvOS\"\n+ ReferencedContainer = \"container:SquadCal.xcodeproj\">\n+ </BuildableReference>\n+ </BuildableProductRunnable>\n+ </ProfileAction>\n+ <AnalyzeAction\n+ buildConfiguration = \"Debug\">\n+ </AnalyzeAction>\n+ <ArchiveAction\n+ buildConfiguration = \"Release\"\n+ revealArchiveInOrganizer = \"YES\">\n+ </ArchiveAction>\n+</Scheme>\n"
},
{
"change_type": "MODIFY",
"old_path": "native/package.json",
"new_path": "native/package.json",
"diff": "},\n\"dependencies\": {\n\"react\": \"15.4.2\",\n- \"react-native\": \"0.40.0\",\n+ \"react-native\": \"^0.41.2\",\n\"react-native-vector-icons\": \"^4.0.0\",\n\"react-navigation\": \"^1.0.0-beta.3\"\n},\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Upgrade react-native versions |
129,187 | 15.02.2017 17:43:06 | 18,000 | cc8efc16d9929290dc1181f8535ecb636cea0b48 | Add Redux into native! | [
{
"change_type": "MODIFY",
"old_path": "lib/reducers/master-reducer.js",
"new_path": "lib/reducers/master-reducer.js",
"diff": "@@ -6,7 +6,7 @@ import { reduceLoadingStatuses } from './loading-reducer';\nimport { reduceEntryInfos } from './entry-reducer';\nimport reduceUserInfo from './user-reducer';\nimport reduceCalendarInfos from './calendar-reducer';\n-import reduceNavInfo from './nav-reducer';\n+import reduceBaseNavInfo from './nav-reducer';\nexport default function baseReducer<T: BaseAppState>(\nstate: T,\n@@ -14,7 +14,7 @@ export default function baseReducer<T: BaseAppState>(\n): T {\n// NavInfo has to be handled differently because of the covariance\n// (see comment about \"+\" in redux-types.js)\n- const baseNavInfo = reduceNavInfo(state.navInfo, action);\n+ const baseNavInfo = reduceBaseNavInfo(state.navInfo, action);\nconst navInfo = baseNavInfo === state.navInfo\n? state.navInfo\n: { ...state.navInfo, ...baseNavInfo };\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/reducers/nav-reducer.js",
"new_path": "lib/reducers/nav-reducer.js",
"diff": "@@ -6,7 +6,7 @@ import type {\n} from '../types/redux-types';\nimport type { BaseNavInfo } from '../types/nav-types';\n-export default function reduceNavInfo<T: BaseAppState>(\n+export default function reduceBaseNavInfo<T: BaseAppState>(\nstate: BaseNavInfo,\naction: BaseAction<T>,\n) {\n"
},
{
"change_type": "MODIFY",
"old_path": "native/app.react.js",
"new_path": "native/app.react.js",
"diff": "// @flow\n+import type { NavigationState } from './navigation-setup';\n+import { navigationState } from './navigation-setup';\n+import type { Dispatch } from 'lib/types/redux-types';\n+import type { AppState, Action } from './redux-setup';\n+\nimport React from 'react';\n-import {\n- AppRegistry,\n- StyleSheet,\n- Text,\n- View,\n-} from 'react-native';\n-import Icon from 'react-native-vector-icons/FontAwesome';\n-import { TabNavigator } from 'react-navigation';\n-\n-import Calendar from './calendar/calendar.react';\n-import Chat from './chat/chat.react';\n-import More from './more/more.react';\n-\n-const App = TabNavigator({\n- Calendar: { screen: Calendar },\n- Chat: { screen: Chat },\n- More: { screen: More },\n+import { createStore } from 'redux';\n+import { Provider, connect } from 'react-redux';\n+import { AppRegistry } from 'react-native';\n+import { addNavigationHelpers } from 'react-navigation';\n+\n+import { AppNavigator } from './navigation-setup';\n+import { reducer } from './redux-setup';\n+\n+class AppWithNavigationState extends React.PureComponent {\n+\n+ static propTypes = {\n+ navigationState: navigationState,\n+ dispatch: React.PropTypes.func.isRequired,\n+ };\n+ props: {\n+ navigationState: NavigationState,\n+ dispatch: Dispatch<AppState, Action>,\n+ };\n+\n+ render() {\n+ const navigation = addNavigationHelpers({\n+ dispatch: this.props.dispatch,\n+ state: this.props.navigationState,\n});\n+ return <AppNavigator navigation={navigation} />;\n+ }\n+\n+}\n+\n+const ConnectedAppWithNavigationState = connect(\n+ (state: AppState) => ({\n+ navigationState: state.navInfo.navigationState,\n+ }),\n+)(AppWithNavigationState);\n+const store = createStore(reducer);\n+const App = (props: {}) =>\n+ <Provider store={store}>\n+ <ConnectedAppWithNavigationState />\n+ </Provider>;\nAppRegistry.registerComponent('SquadCal', () => App);\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/navigation-setup.js",
"diff": "+// @flow\n+\n+import React from 'react';\n+import { TabNavigator } from 'react-navigation';\n+\n+import Calendar from './calendar/calendar.react';\n+import Chat from './chat/chat.react';\n+import More from './more/more.react';\n+\n+type NavigationRoute = {\n+ key: string,\n+ title?: string,\n+};\n+\n+export type NavigationState = {\n+ index: number,\n+ routes: NavigationRoute[],\n+};\n+\n+const navigationRoute = React.PropTypes.shape({\n+ key: React.PropTypes.string.isRequired,\n+});\n+\n+export const navigationState = React.PropTypes.shape({\n+ index: React.PropTypes.number.isRequired,\n+ routes: React.PropTypes.arrayOf(navigationRoute),\n+});\n+\n+export const AppNavigator = TabNavigator({\n+ Calendar: { screen: Calendar },\n+ Chat: { screen: Chat },\n+ More: { screen: More },\n+});\n"
},
{
"change_type": "MODIFY",
"old_path": "native/package.json",
"new_path": "native/package.json",
"diff": "\"test\": \"jest\"\n},\n\"dependencies\": {\n+ \"invariant\": \"^2.2.2\",\n\"react\": \"15.4.2\",\n\"react-native\": \"^0.41.2\",\n\"react-native-vector-icons\": \"^4.0.0\",\n- \"react-navigation\": \"^1.0.0-beta.3\"\n+ \"react-navigation\": \"^1.0.0-beta.3\",\n+ \"react-redux\": \"^5.0.2\",\n+ \"redux\": \"^3.6.0\"\n},\n\"devDependencies\": {\n\"babel-jest\": \"18.0.0\",\n\"babel-preset-react-native\": \"1.9.1\",\n\"flow\": \"^0.2.3\",\n- \"flow-bin\": \"^0.36.0\",\n+ \"flow-bin\": \"^0.37.0\",\n\"jest\": \"18.1.0\",\n\"react-test-renderer\": \"15.4.2\"\n},\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/redux-setup.js",
"diff": "+// @flow\n+\n+import type { CalendarInfo } from 'lib/types/calendar-types';\n+import type { EntryInfo } from 'lib/types/entry-types';\n+import type { BaseAction } from 'lib/types/redux-types';\n+import type { LoadingStatus } from 'lib/types/loading-types';\n+import type { UserInfo } from 'lib/types/user-types';\n+import type { BaseNavInfo } from 'lib/types/nav-types';\n+import type { NavigationState } from './navigation-setup';\n+import { navigationState } from './navigation-setup';\n+\n+import React from 'react';\n+import invariant from 'invariant';\n+\n+import baseReducer from 'lib/reducers/master-reducer';\n+\n+import { AppNavigator } from './navigation-setup';\n+\n+export type NavInfo = {\n+ home: bool,\n+ calendarID: ?string,\n+ navigationState: NavigationState,\n+};\n+\n+export const navInfoPropType = React.PropTypes.shape({\n+ home: React.PropTypes.bool.isRequired,\n+ calendarID: React.PropTypes.string,\n+ navigationState: navigationState,\n+});\n+\n+export type AppState = {\n+ navInfo: NavInfo,\n+ userInfo: ?UserInfo,\n+ entryInfos: {[id: string]: EntryInfo},\n+ daysToEntries: {[day: string]: string[]},\n+ calendarInfos: {[id: string]: CalendarInfo},\n+ loadingStatuses: {[key: string]: {[idx: number]: LoadingStatus}},\n+};\n+\n+export type Action = BaseAction<AppState>;\n+\n+function reduceNavInfo(state: ?NavInfo, action: Action) {\n+ if (!state) {\n+ invariant(\n+ action.type === \"@@redux/INIT\",\n+ \"Redux store should already be initialized\",\n+ );\n+ return {\n+ home: true,\n+ calendarID: null,\n+ navigationState: AppNavigator.router.getStateForAction(\n+ action,\n+ undefined,\n+ ),\n+ };\n+ }\n+ return state;\n+}\n+\n+export function reducer(state: ?AppState, action: Action) {\n+ const possiblyMutatedState = {\n+ ...state,\n+ navInfo: reduceNavInfo(state && state.navInfo, action),\n+ };\n+ return baseReducer(possiblyMutatedState, action);\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "web/redux-setup.js",
"new_path": "web/redux-setup.js",
"diff": "@@ -6,10 +6,10 @@ import type { BaseAction } from 'lib/types/redux-types';\nimport type { LoadingStatus } from 'lib/types/loading-types';\nimport type { UserInfo } from 'lib/types/user-types';\n-import baseReducer from 'lib/reducers/master-reducer';\n-\nimport React from 'react';\n+import baseReducer from 'lib/reducers/master-reducer';\n+\nexport type NavInfo = {\nyear: number,\nmonth: number, // 1-indexed\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Add Redux into native! |
129,187 | 17.02.2017 01:27:55 | 18,000 | 492392cd7880fdef0e6c4c7c35459d63d265bd58 | Update react-navigation, add an extra layer for the log in part, create LogInModal | [
{
"change_type": "MODIFY",
"old_path": "lib/reducers/calendar-reducer.js",
"new_path": "lib/reducers/calendar-reducer.js",
"diff": "@@ -14,12 +14,9 @@ export default function reduceCalendarInfos<T: BaseAppState>(\naction: BaseAction<T>,\n): {[id: string]: CalendarInfo} {\nif (!state) {\n- invariant(\n- action.type === \"@@redux/INIT\",\n- \"Redux store should already be initialized\",\n- );\n- return {};\n- } else if (\n+ state = {};\n+ }\n+ if (\naction.type === \"LOG_OUT_SUCCESS\" ||\naction.type === \"DELETE_ACCOUNT_SUCCESS\"\n) {\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/reducers/entry-reducer.js",
"new_path": "lib/reducers/entry-reducer.js",
"diff": "@@ -36,15 +36,17 @@ function reduceEntryInfos<T: BaseAppState>(\ninputDaysToEntries: ?{[id: string]: string[]},\naction: BaseAction<T>,\n) {\n- const entryInfos = inputEntryInfos;\n- const daysToEntries = inputDaysToEntries;\n+ let entryInfos = inputEntryInfos;\n+ let daysToEntries = inputDaysToEntries;\nif (!entryInfos || !daysToEntries) {\ninvariant(\n- !entryInfos && !daysToEntries && action.type === \"@@redux/INIT\",\n- \"Redux store should already be initialized\",\n+ !entryInfos && !daysToEntries,\n+ \"entryInfos should be initialized iff daysToEntries is\",\n);\n- return [{}, {}];\n- } else if (\n+ entryInfos = {};\n+ daysToEntries = {};\n+ }\n+ if (\naction.type === \"LOG_OUT_SUCCESS\" ||\naction.type === \"DELETE_ACCOUNT_SUCCESS\"\n) {\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/reducers/loading-reducer.js",
"new_path": "lib/reducers/loading-reducer.js",
"diff": "@@ -19,11 +19,7 @@ function reduceLoadingStatuses<T: BaseAppState>(\naction: BaseAction<T>,\n): {[key: string]: {[idx: number]: LoadingStatus}} {\nif (!state) {\n- invariant(\n- action.type === \"@@redux/INIT\",\n- \"Redux store should already be initialized\",\n- );\n- return {};\n+ state = {};\n}\nconst startMatch = action.type.match(/(.*)_STARTED/);\nif (startMatch && fetchKeyRegistry.has(startMatch[1])) {\n"
},
{
"change_type": "MODIFY",
"old_path": "native/.flowconfig",
"new_path": "native/.flowconfig",
"diff": ".*/Libraries/react-native/React.js\n.*/Libraries/react-native/ReactNative.js\n-; These guys...\n-.*/node_modules/react-navigation/.*\n-\n[include]\n[libs]\n@@ -44,7 +41,5 @@ suppress_comment=\\\\(.\\\\|\\n\\\\)*\\\\$FlowFixedInNextDeploy\nunsafe.enable_getters_and_setters=true\n-module.name_mapper='^react-navigation$' -> 'emptyObject'\n-\n[version]\n^0.37.0\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/account/log-in-modal.react.js",
"diff": "+// @flow\n+\n+import type { NavigationScreenProp } from 'react-navigation';\n+\n+import React from 'react';\n+import { View, StyleSheet, Text, Button } from 'react-native';\n+\n+class LogInModal extends React.PureComponent {\n+\n+ props: {\n+ navigation: NavigationScreenProp<*, *>,\n+ };\n+ state: {};\n+\n+ static propTypes = {\n+ navigation: React.PropTypes.shape({\n+ navigate: React.PropTypes.func.isRequired,\n+ }).isRequired,\n+ };\n+\n+ render() {\n+ return (\n+ <View style={styles.container}>\n+ <Text style={styles.instructions}>\n+ log in please??\n+ </Text>\n+ <Button\n+ onPress={this.onPress}\n+ title=\"Log in\"\n+ />\n+ </View>\n+ );\n+ }\n+\n+ onPress = () => {\n+ this.props.navigation.goBack();\n+ }\n+\n+}\n+\n+const styles = StyleSheet.create({\n+ container: {\n+ flex: 1,\n+ justifyContent: 'center',\n+ alignItems: 'center',\n+ backgroundColor: '#F5FCFF',\n+ },\n+ instructions: {\n+ textAlign: 'center',\n+ color: '#333333',\n+ marginBottom: 5,\n+ },\n+});\n+\n+export default LogInModal;\n"
},
{
"change_type": "MODIFY",
"old_path": "native/app.react.js",
"new_path": "native/app.react.js",
"diff": "// @flow\n-import type { NavigationState } from './navigation-setup';\n-import { navigationState } from './navigation-setup';\n+import type { NavigationState } from 'react-navigation';\n+import { ReactNavigationPropTypes } from 'react-navigation';\nimport type { Dispatch } from 'lib/types/redux-types';\nimport type { AppState, Action } from './redux-setup';\nimport React from 'react';\n-import { createStore } from 'redux';\n+import { createStore, applyMiddleware } from 'redux';\nimport { Provider, connect } from 'react-redux';\nimport { AppRegistry } from 'react-native';\nimport { addNavigationHelpers } from 'react-navigation';\n+import { composeWithDevTools } from 'remote-redux-devtools';\n+import thunk from 'redux-thunk';\n-import { AppNavigator } from './navigation-setup';\n+import { RootNavigator } from './navigation-setup';\nimport { reducer } from './redux-setup';\nclass AppWithNavigationState extends React.PureComponent {\nstatic propTypes = {\n- navigationState: navigationState,\n+ navigationState: ReactNavigationPropTypes.navigationState,\ndispatch: React.PropTypes.func.isRequired,\n};\nprops: {\n@@ -30,7 +32,7 @@ class AppWithNavigationState extends React.PureComponent {\ndispatch: this.props.dispatch,\nstate: this.props.navigationState,\n});\n- return <AppNavigator navigation={navigation} />;\n+ return <RootNavigator navigation={navigation} />;\n}\n}\n@@ -40,7 +42,10 @@ const ConnectedAppWithNavigationState = connect(\nnavigationState: state.navInfo.navigationState,\n}),\n)(AppWithNavigationState);\n-const store = createStore(reducer);\n+const store = createStore(\n+ reducer,\n+ composeWithDevTools(applyMiddleware(thunk)),\n+);\nconst App = (props: {}) =>\n<Provider store={store}>\n<ConnectedAppWithNavigationState />\n"
},
{
"change_type": "MODIFY",
"old_path": "native/more/more.react.js",
"new_path": "native/more/more.react.js",
"diff": "// @flow\n+import type { NavigationScreenProp } from 'react-navigation';\n+\nimport React from 'react';\n-import { View, StyleSheet, Text } from 'react-native';\n+import { View, StyleSheet, Text, Button } from 'react-native';\nimport Icon from 'react-native-vector-icons/FontAwesome';\n-type Props = {\n-};\n-type State = {\n-};\n-\nclass More extends React.PureComponent {\n- props: Props;\n- state: State;\n+ props: {\n+ navigation: NavigationScreenProp<*, *>,\n+ };\n+ state: {};\n+\n+ static propTypes = {\n+ navigation: React.PropTypes.shape({\n+ navigate: React.PropTypes.func.isRequired,\n+ }).isRequired,\n+ };\nstatic navigationOptions = {\ntabBar: {\n@@ -33,10 +38,18 @@ class More extends React.PureComponent {\nPress Cmd+R to reload,{'\\n'}\nCmd+D or shake for dev menu\n</Text>\n+ <Button\n+ onPress={this.onPress}\n+ title=\"Log out\"\n+ />\n</View>\n);\n}\n+ onPress = () => {\n+ this.props.navigation.navigate('LogIn');\n+ }\n+\n}\nconst styles = StyleSheet.create({\n"
},
{
"change_type": "MODIFY",
"old_path": "native/navigation-setup.js",
"new_path": "native/navigation-setup.js",
"diff": "// @flow\n-import React from 'react';\n-import { TabNavigator } from 'react-navigation';\n+import { TabNavigator, StackNavigator } from 'react-navigation';\nimport Calendar from './calendar/calendar.react';\nimport Chat from './chat/chat.react';\nimport More from './more/more.react';\n+import LogIn from './account/log-in-modal.react';\n-type NavigationRoute = {\n- key: string,\n- title?: string,\n-};\n-\n-export type NavigationState = {\n- index: number,\n- routes: NavigationRoute[],\n-};\n-\n-const navigationRoute = React.PropTypes.shape({\n- key: React.PropTypes.string.isRequired,\n-});\n-\n-export const navigationState = React.PropTypes.shape({\n- index: React.PropTypes.number.isRequired,\n- routes: React.PropTypes.arrayOf(navigationRoute),\n-});\n-\n-export const AppNavigator = TabNavigator({\n+const AppNavigator = TabNavigator(\n+ {\nCalendar: { screen: Calendar },\nChat: { screen: Chat },\nMore: { screen: More },\n-});\n+ },\n+ {\n+ initialRouteName: 'Calendar',\n+ },\n+);\n+\n+export const RootNavigator = StackNavigator(\n+ {\n+ LogIn: { screen: LogIn },\n+ App: { screen: AppNavigator },\n+ },\n+ {\n+ headerMode: 'none',\n+ mode: 'modal',\n+ },\n+);\n"
},
{
"change_type": "MODIFY",
"old_path": "native/package.json",
"new_path": "native/package.json",
"diff": "\"react\": \"15.4.2\",\n\"react-native\": \"^0.41.2\",\n\"react-native-vector-icons\": \"^4.0.0\",\n- \"react-navigation\": \"^1.0.0-beta.3\",\n+ \"react-navigation\": \"^1.0.0-beta.5\",\n\"react-redux\": \"^5.0.2\",\n- \"redux\": \"^3.6.0\"\n+ \"redux\": \"^3.6.0\",\n+ \"redux-thunk\": \"^2.2.0\"\n},\n\"devDependencies\": {\n\"babel-jest\": \"18.0.0\",\n\"flow\": \"^0.2.3\",\n\"flow-bin\": \"^0.37.0\",\n\"jest\": \"18.1.0\",\n- \"react-test-renderer\": \"15.4.2\"\n+ \"react-test-renderer\": \"15.4.2\",\n+ \"remote-redux-devtools\": \"^0.5.7\"\n},\n\"jest\": {\n\"preset\": \"react-native\"\n"
},
{
"change_type": "MODIFY",
"old_path": "native/redux-setup.js",
"new_path": "native/redux-setup.js",
"diff": "@@ -6,15 +6,15 @@ import type { BaseAction } from 'lib/types/redux-types';\nimport type { LoadingStatus } from 'lib/types/loading-types';\nimport type { UserInfo } from 'lib/types/user-types';\nimport type { BaseNavInfo } from 'lib/types/nav-types';\n-import type { NavigationState } from './navigation-setup';\n-import { navigationState } from './navigation-setup';\n+import type { NavigationState } from 'react-navigation';\n+import { ReactNavigationPropTypes } from 'react-navigation';\nimport React from 'react';\nimport invariant from 'invariant';\nimport baseReducer from 'lib/reducers/master-reducer';\n-import { AppNavigator } from './navigation-setup';\n+import { RootNavigator } from './navigation-setup';\nexport type NavInfo = {\nhome: bool,\n@@ -25,7 +25,7 @@ export type NavInfo = {\nexport const navInfoPropType = React.PropTypes.shape({\nhome: React.PropTypes.bool.isRequired,\ncalendarID: React.PropTypes.string,\n- navigationState: navigationState,\n+ navigationState: ReactNavigationPropTypes.navigationState,\n});\nexport type AppState = {\n@@ -41,17 +41,36 @@ export type Action = BaseAction<AppState>;\nfunction reduceNavInfo(state: ?NavInfo, action: Action) {\nif (!state) {\n- invariant(\n- action.type === \"@@redux/INIT\",\n- \"Redux store should already be initialized\",\n- );\n- return {\n+ const initialState = {\n+ index: 1,\n+ routes: [\n+ {\n+ key: 'App',\n+ routeName: 'App',\n+ index: 0,\n+ routes: [\n+ { key: 'Calendar', routeName: 'Calendar' },\n+ { key: 'Chat', routeName: 'Chat' },\n+ { key: 'More', routeName: 'More' },\n+ ],\n+ },\n+ { key: 'LogIn', routeName: 'LogIn' },\n+ ],\n+ };\n+ state = {\nhome: true,\ncalendarID: null,\n- navigationState: AppNavigator.router.getStateForAction(\n+ navigationState: initialState,\n+ };\n+ }\n+ const navigationState = RootNavigator.router.getStateForAction(\naction,\n- undefined,\n- ),\n+ state.navigationState,\n+ )\n+ if (navigationState && navigationState !== state.navigationState) {\n+ return {\n+ ...state,\n+ navigationState,\n};\n}\nreturn state;\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Update react-navigation, add an extra layer for the log in part, create LogInModal |
129,187 | 17.02.2017 02:30:05 | 18,000 | 20af578b8715f12ba586e23e57ef718bbdde08c3 | Redo the approach a little bit | [
{
"change_type": "MODIFY",
"old_path": "lib/reducers/calendar-reducer.js",
"new_path": "lib/reducers/calendar-reducer.js",
"diff": "@@ -10,12 +10,9 @@ import invariant from 'invariant';\nimport _omitBy from 'lodash/fp/omitBy';\nexport default function reduceCalendarInfos<T: BaseAppState>(\n- state: ?{[id: string]: CalendarInfo},\n+ state: {[id: string]: CalendarInfo},\naction: BaseAction<T>,\n): {[id: string]: CalendarInfo} {\n- if (!state) {\n- state = {};\n- }\nif (\naction.type === \"LOG_OUT_SUCCESS\" ||\naction.type === \"DELETE_ACCOUNT_SUCCESS\"\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/reducers/entry-reducer.js",
"new_path": "lib/reducers/entry-reducer.js",
"diff": "@@ -32,20 +32,12 @@ function daysToEntriesFromEntryInfos(entryInfos: EntryInfo[]) {\n}\nfunction reduceEntryInfos<T: BaseAppState>(\n- inputEntryInfos: ?{[id: string]: EntryInfo},\n- inputDaysToEntries: ?{[id: string]: string[]},\n+ inputEntryInfos: {[id: string]: EntryInfo},\n+ inputDaysToEntries: {[id: string]: string[]},\naction: BaseAction<T>,\n) {\n- let entryInfos = inputEntryInfos;\n- let daysToEntries = inputDaysToEntries;\n- if (!entryInfos || !daysToEntries) {\n- invariant(\n- !entryInfos && !daysToEntries,\n- \"entryInfos should be initialized iff daysToEntries is\",\n- );\n- entryInfos = {};\n- daysToEntries = {};\n- }\n+ const entryInfos = inputEntryInfos;\n+ const daysToEntries = inputDaysToEntries;\nif (\naction.type === \"LOG_OUT_SUCCESS\" ||\naction.type === \"DELETE_ACCOUNT_SUCCESS\"\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/reducers/loading-reducer.js",
"new_path": "lib/reducers/loading-reducer.js",
"diff": "@@ -15,12 +15,9 @@ const registerFetchKey = (fetchKey: string) => {\n};\nfunction reduceLoadingStatuses<T: BaseAppState>(\n- state: ?{[key: string]: {[idx: number]: LoadingStatus}},\n+ state: {[key: string]: {[idx: number]: LoadingStatus}},\naction: BaseAction<T>,\n): {[key: string]: {[idx: number]: LoadingStatus}} {\n- if (!state) {\n- state = {};\n- }\nconst startMatch = action.type.match(/(.*)_STARTED/);\nif (startMatch && fetchKeyRegistry.has(startMatch[1])) {\ninvariant(\n"
},
{
"change_type": "MODIFY",
"old_path": "native/app.react.js",
"new_path": "native/app.react.js",
"diff": "// @flow\nimport type { NavigationState } from 'react-navigation';\n-import { ReactNavigationPropTypes } from 'react-navigation';\n+import ReactNavigationPropTypes from 'react-navigation/lib/PropTypes';\nimport type { Dispatch } from 'lib/types/redux-types';\nimport type { AppState, Action } from './redux-setup';\n@@ -14,7 +14,7 @@ import { composeWithDevTools } from 'remote-redux-devtools';\nimport thunk from 'redux-thunk';\nimport { RootNavigator } from './navigation-setup';\n-import { reducer } from './redux-setup';\n+import { reducer, defaultState } from './redux-setup';\nclass AppWithNavigationState extends React.PureComponent {\n@@ -44,6 +44,7 @@ const ConnectedAppWithNavigationState = connect(\n)(AppWithNavigationState);\nconst store = createStore(\nreducer,\n+ defaultState,\ncomposeWithDevTools(applyMiddleware(thunk)),\n);\nconst App = (props: {}) =>\n"
},
{
"change_type": "MODIFY",
"old_path": "native/flow-typed/npm/babel-jest_vx.x.x.js",
"new_path": "native/flow-typed/npm/babel-jest_vx.x.x.js",
"diff": "-// flow-typed signature: f020effc4fc1883123311789d8d4e434\n-// flow-typed version: <<STUB>>/babel-jest_v18.0.0/flow_v0.36.0\n+// flow-typed signature: a64a20ddbccd052f3ab98ce368b182fb\n+// flow-typed version: <<STUB>>/babel-jest_v18.0.0/flow_v0.37.0\n/**\n* This is an autogenerated libdef stub for:\n"
},
{
"change_type": "MODIFY",
"old_path": "native/flow-typed/npm/babel-preset-react-native_vx.x.x.js",
"new_path": "native/flow-typed/npm/babel-preset-react-native_vx.x.x.js",
"diff": "-// flow-typed signature: 7bffb48740813ac4532f0399975c119f\n-// flow-typed version: <<STUB>>/babel-preset-react-native_v1.9.1/flow_v0.36.0\n+// flow-typed signature: 637191e1cc76c311a921c62af65be404\n+// flow-typed version: <<STUB>>/babel-preset-react-native_v1.9.1/flow_v0.37.0\n/**\n* This is an autogenerated libdef stub for:\n"
},
{
"change_type": "MODIFY",
"old_path": "native/flow-typed/npm/flow_vx.x.x.js",
"new_path": "native/flow-typed/npm/flow_vx.x.x.js",
"diff": "-// flow-typed signature: bc566c631f778066753f163032c37385\n-// flow-typed version: <<STUB>>/flow_v^0.2.3/flow_v0.36.0\n+// flow-typed signature: c8340dd2bcaa9d9337e944a7cea42b0b\n+// flow-typed version: <<STUB>>/flow_v^0.2.3/flow_v0.37.0\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: 8f6b48ea04edb32d9ec99c2c65f004d0\n-// flow-typed version: <<STUB>>/react-native-vector-icons_v^4.0.0/flow_v0.36.0\n+// flow-typed signature: d9df9cb59eb77574af20d9467d8aefd6\n+// flow-typed version: <<STUB>>/react-native-vector-icons_v^4.0.0/flow_v0.37.0\n/**\n* This is an autogenerated libdef stub for:\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/flow-typed/npm/react-redux_v5.x.x.js",
"diff": "+// flow-typed signature: 0ed284c5a2e97a9e3c0e87af3dedc09d\n+// flow-typed version: bdf1e66252/react-redux_v5.x.x/flow_>=v0.30.x\n+\n+import type { Dispatch, Store } from 'redux'\n+\n+declare module 'react-redux' {\n+\n+ /*\n+\n+ S = State\n+ A = Action\n+ OP = OwnProps\n+ SP = StateProps\n+ DP = DispatchProps\n+\n+ */\n+\n+ declare type MapStateToProps<S, OP: Object, SP: Object> = (state: S, ownProps: OP) => SP | MapStateToProps<S, OP, SP>;\n+\n+ declare type MapDispatchToProps<A, OP: Object, DP: Object> = ((dispatch: Dispatch<A>, ownProps: OP) => DP) | DP;\n+\n+ declare type MergeProps<SP, DP: Object, OP: Object, P: Object> = (stateProps: SP, dispatchProps: DP, ownProps: OP) => P;\n+\n+ declare type StatelessComponent<P> = (props: P) => ?React$Element<any>;\n+\n+ declare class ConnectedComponent<OP, P, Def, St> extends React$Component<void, OP, void> {\n+ static WrappedComponent: Class<React$Component<Def, P, St>>;\n+ getWrappedInstance(): React$Component<Def, P, St>;\n+ static defaultProps: void;\n+ props: OP;\n+ state: void;\n+ }\n+\n+ declare type ConnectedComponentClass<OP, P, Def, St> = Class<ConnectedComponent<OP, P, Def, St>>;\n+\n+ declare type Connector<OP, P> = {\n+ (component: StatelessComponent<P>): ConnectedComponentClass<OP, P, void, void>;\n+ <Def, St>(component: Class<React$Component<Def, P, St>>): ConnectedComponentClass<OP, P, Def, St>;\n+ };\n+\n+ declare class Provider<S, A> extends React$Component<void, { store: Store<S, A>, children?: any }, void> { }\n+\n+ declare type ConnectOptions = {\n+ pure?: boolean,\n+ withRef?: boolean\n+ };\n+\n+ declare type Null = null | void;\n+\n+ declare function connect<A, OP>(\n+ ...rest: Array<void> // <= workaround for https://github.com/facebook/flow/issues/2360\n+ ): Connector<OP, $Supertype<{ dispatch: Dispatch<A> } & OP>>;\n+\n+ declare function connect<A, OP>(\n+ mapStateToProps: Null,\n+ mapDispatchToProps: Null,\n+ mergeProps: Null,\n+ options: ConnectOptions\n+ ): Connector<OP, $Supertype<{ dispatch: Dispatch<A> } & OP>>;\n+\n+ declare function connect<S, A, OP, SP>(\n+ mapStateToProps: MapStateToProps<S, OP, SP>,\n+ mapDispatchToProps: Null,\n+ mergeProps: Null,\n+ options?: ConnectOptions\n+ ): Connector<OP, $Supertype<SP & { dispatch: Dispatch<A> } & OP>>;\n+\n+ declare function connect<A, OP, DP>(\n+ mapStateToProps: Null,\n+ mapDispatchToProps: MapDispatchToProps<A, OP, DP>,\n+ mergeProps: Null,\n+ options?: ConnectOptions\n+ ): Connector<OP, $Supertype<DP & OP>>;\n+\n+ declare function connect<S, A, OP, SP, DP>(\n+ mapStateToProps: MapStateToProps<S, OP, SP>,\n+ mapDispatchToProps: MapDispatchToProps<A, OP, DP>,\n+ mergeProps: Null,\n+ options?: ConnectOptions\n+ ): Connector<OP, $Supertype<SP & DP & OP>>;\n+\n+ declare function connect<S, A, OP, SP, DP, P>(\n+ mapStateToProps: MapStateToProps<S, OP, SP>,\n+ mapDispatchToProps: MapDispatchToProps<A, OP, DP>,\n+ mergeProps: MergeProps<SP, DP, OP, P>,\n+ options?: ConnectOptions\n+ ): Connector<OP, P>;\n+\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "native/flow-typed/npm/react-test-renderer_vx.x.x.js",
"new_path": "native/flow-typed/npm/react-test-renderer_vx.x.x.js",
"diff": "-// flow-typed signature: bdfef7dcc8ec6fcf5fe63e36d053a000\n-// flow-typed version: <<STUB>>/react-test-renderer_v15.4.2/flow_v0.36.0\n+// flow-typed signature: 47c9cbc55c5e213b4de1097fb9571d60\n+// flow-typed version: <<STUB>>/react-test-renderer_v15.4.2/flow_v0.37.0\n/**\n* This is an autogenerated libdef stub for:\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/flow-typed/npm/redux-thunk_vx.x.x.js",
"diff": "+// flow-typed signature: 1e75f8eb240814412762c537809fa778\n+// flow-typed version: <<STUB>>/redux-thunk_v^2.2.0/flow_v0.37.0\n+\n+/**\n+ * This is an autogenerated libdef stub for:\n+ *\n+ * 'redux-thunk'\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-thunk' {\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-thunk/dist/redux-thunk' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'redux-thunk/dist/redux-thunk.min' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'redux-thunk/es/index' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'redux-thunk/lib/index' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'redux-thunk/src/index' {\n+ declare module.exports: any;\n+}\n+\n+// Filename aliases\n+declare module 'redux-thunk/dist/redux-thunk.js' {\n+ declare module.exports: $Exports<'redux-thunk/dist/redux-thunk'>;\n+}\n+declare module 'redux-thunk/dist/redux-thunk.min.js' {\n+ declare module.exports: $Exports<'redux-thunk/dist/redux-thunk.min'>;\n+}\n+declare module 'redux-thunk/es/index.js' {\n+ declare module.exports: $Exports<'redux-thunk/es/index'>;\n+}\n+declare module 'redux-thunk/lib/index.js' {\n+ declare module.exports: $Exports<'redux-thunk/lib/index'>;\n+}\n+declare module 'redux-thunk/src/index.js' {\n+ declare module.exports: $Exports<'redux-thunk/src/index'>;\n+}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/flow-typed/npm/redux_v3.x.x.js",
"diff": "+// flow-typed signature: ba132c96664f1a05288f3eb2272a3c35\n+// flow-typed version: c4bbd91cfc/redux_v3.x.x/flow_>=v0.33.x\n+\n+declare module 'redux' {\n+\n+ /*\n+\n+ S = State\n+ A = Action\n+\n+ */\n+\n+ declare type Dispatch<A: { type: $Subtype<string> }> = (action: A) => A;\n+\n+ declare type MiddlewareAPI<S, A> = {\n+ dispatch: Dispatch<A>;\n+ getState(): S;\n+ };\n+\n+ declare type Store<S, A> = {\n+ // rewrite MiddlewareAPI members in order to get nicer error messages (intersections produce long messages)\n+ dispatch: Dispatch<A>;\n+ getState(): S;\n+ subscribe(listener: () => void): () => void;\n+ replaceReducer(nextReducer: Reducer<S, A>): void\n+ };\n+\n+ declare type Reducer<S, A> = (state: S, action: A) => S;\n+\n+ declare type Middleware<S, A> =\n+ (api: MiddlewareAPI<S, A>) =>\n+ (next: Dispatch<A>) => Dispatch<A>;\n+\n+ declare type StoreCreator<S, A> = {\n+ (reducer: Reducer<S, A>, enhancer?: StoreEnhancer<S, A>): Store<S, A>;\n+ (reducer: Reducer<S, A>, preloadedState: S, enhancer?: StoreEnhancer<S, A>): Store<S, A>;\n+ };\n+\n+ declare type StoreEnhancer<S, A> = (next: StoreCreator<S, A>) => StoreCreator<S, A>;\n+\n+ declare function createStore<S, A>(reducer: Reducer<S, A>, enhancer?: StoreEnhancer<S, A>): Store<S, A>;\n+ declare function createStore<S, A>(reducer: Reducer<S, A>, preloadedState: S, enhancer?: StoreEnhancer<S, A>): Store<S, A>;\n+\n+ declare function applyMiddleware<S, A>(...middlewares: Array<Middleware<S, A>>): StoreEnhancer<S, A>;\n+\n+ declare type ActionCreator<A, B> = (...args: Array<B>) => A;\n+ declare type ActionCreators<K, A> = { [key: K]: ActionCreator<A, any> };\n+\n+ declare function bindActionCreators<A, C: ActionCreator<A, any>>(actionCreator: C, dispatch: Dispatch<A>): C;\n+ declare function bindActionCreators<A, K, C: ActionCreators<K, A>>(actionCreators: C, dispatch: Dispatch<A>): C;\n+\n+ declare function combineReducers<O: Object, A>(reducers: O): Reducer<$ObjMap<O, <S>(r: Reducer<S, any>) => S>, A>;\n+\n+ declare function compose<S, A>(...fns: Array<StoreEnhancer<S, A>>): Function;\n+\n+}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/flow-typed/npm/remote-redux-devtools_vx.x.x.js",
"diff": "+// flow-typed signature: 827833fa538a29bc76ba045177ed6956\n+// flow-typed version: <<STUB>>/remote-redux-devtools_v^0.5.7/flow_v0.37.0\n+\n+/**\n+ * This is an autogenerated libdef stub for:\n+ *\n+ * 'remote-redux-devtools'\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 'remote-redux-devtools' {\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 'remote-redux-devtools/lib/configureStore' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'remote-redux-devtools/lib/constants' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'remote-redux-devtools/lib/devTools' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'remote-redux-devtools/lib/index' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'remote-redux-devtools/lib/utils/reactNative' {\n+ declare module.exports: any;\n+}\n+\n+// Filename aliases\n+declare module 'remote-redux-devtools/lib/configureStore.js' {\n+ declare module.exports: $Exports<'remote-redux-devtools/lib/configureStore'>;\n+}\n+declare module 'remote-redux-devtools/lib/constants.js' {\n+ declare module.exports: $Exports<'remote-redux-devtools/lib/constants'>;\n+}\n+declare module 'remote-redux-devtools/lib/devTools.js' {\n+ declare module.exports: $Exports<'remote-redux-devtools/lib/devTools'>;\n+}\n+declare module 'remote-redux-devtools/lib/index.js' {\n+ declare module.exports: $Exports<'remote-redux-devtools/lib/index'>;\n+}\n+declare module 'remote-redux-devtools/lib/utils/reactNative.js' {\n+ declare module.exports: $Exports<'remote-redux-devtools/lib/utils/reactNative'>;\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "native/redux-setup.js",
"new_path": "native/redux-setup.js",
"diff": "@@ -7,7 +7,7 @@ import type { LoadingStatus } from 'lib/types/loading-types';\nimport type { UserInfo } from 'lib/types/user-types';\nimport type { BaseNavInfo } from 'lib/types/nav-types';\nimport type { NavigationState } from 'react-navigation';\n-import { ReactNavigationPropTypes } from 'react-navigation';\n+import ReactNavigationPropTypes from 'react-navigation/lib/PropTypes';\nimport React from 'react';\nimport invariant from 'invariant';\n@@ -16,7 +16,7 @@ import baseReducer from 'lib/reducers/master-reducer';\nimport { RootNavigator } from './navigation-setup';\n-export type NavInfo = {\n+export type NavInfo = BaseNavInfo & {\nhome: bool,\ncalendarID: ?string,\nnavigationState: NavigationState,\n@@ -39,9 +39,22 @@ export type AppState = {\nexport type Action = BaseAction<AppState>;\n-function reduceNavInfo(state: ?NavInfo, action: Action) {\n- if (!state) {\n- const initialState = {\n+function reduceNavInfo(state: NavInfo, action: Action): NavInfo {\n+ const navigationState = RootNavigator.router.getStateForAction(\n+ action,\n+ state.navigationState,\n+ )\n+ if (navigationState && navigationState !== state.navigationState) {\n+ return { ...state, navigationState };\n+ }\n+ return state;\n+}\n+\n+export const defaultState = ({\n+ navInfo: {\n+ home: true,\n+ calendarID: null,\n+ navigationState: {\nindex: 1,\nroutes: [\n{\n@@ -56,30 +69,19 @@ function reduceNavInfo(state: ?NavInfo, action: Action) {\n},\n{ key: 'LogIn', routeName: 'LogIn' },\n],\n- };\n- state = {\n- home: true,\n- calendarID: null,\n- navigationState: initialState,\n- };\n- }\n- const navigationState = RootNavigator.router.getStateForAction(\n- action,\n- state.navigationState,\n- )\n- if (navigationState && navigationState !== state.navigationState) {\n- return {\n- ...state,\n- navigationState,\n- };\n- }\n- return state;\n-}\n+ },\n+ },\n+ userInfo: null,\n+ entryInfos: {},\n+ daysToEntries: {},\n+ calendarInfos: {},\n+ loadingStatuses: {},\n+}: AppState);\n-export function reducer(state: ?AppState, action: Action) {\n- const possiblyMutatedState = {\n- ...state,\n- navInfo: reduceNavInfo(state && state.navInfo, action),\n- };\n- return baseReducer(possiblyMutatedState, action);\n+export function reducer(state: AppState, action: Action) {\n+ const navInfo = reduceNavInfo(state && state.navInfo, action);\n+ if (navInfo && navInfo !== state.navInfo) {\n+ state = { ...state, navInfo };\n+ }\n+ return baseReducer(state, action);\n}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Redo the approach a little bit |
129,187 | 19.02.2017 14:40:24 | 18,000 | a8fe2cff6b6a282fccdb67634d72d75b191f9a23 | Progress on native login modal | [
{
"change_type": "MODIFY",
"old_path": "native/account/logged-out-modal.react.js",
"new_path": "native/account/logged-out-modal.react.js",
"diff": "import type { NavigationScreenProp } from 'react-navigation';\nimport React from 'react';\n-import { View, StyleSheet, Text, Button } from 'react-native';\n+import {\n+ View,\n+ StyleSheet,\n+ Text,\n+ TouchableHighlight,\n+ LayoutAnimation,\n+} from 'react-native';\nclass LoggedOutModal extends React.PureComponent {\nprops: {\nnavigation: NavigationScreenProp<*, *>,\n};\n+\nstate: {\nmode: \"prompt\" | \"log-in\" | \"register\",\n+ } = {\n+ mode: \"prompt\",\n};\nstatic propTypes = {\n@@ -20,37 +29,98 @@ class LoggedOutModal extends React.PureComponent {\n}).isRequired,\n};\n+ static navigationOptions = {\n+ cardStack: {\n+ gesturesEnabled: false,\n+ },\n+ };\n+\n+ componentWillUpdate() {\n+ LayoutAnimation.spring();\n+ }\n+\nrender() {\n+ const alignSelf = this.state.mode === \"prompt\" ? \"center\" : \"flex-start\";\nreturn (\n<View style={styles.container}>\n- <Text style={styles.instructions}>\n- log in please??\n+ <View style={styles.headerContainer}>\n+ <Text style={[styles.header, { alignSelf }]}>\n+ SquadCal\n+ </Text>\n+ </View>\n+ <TouchableHighlight\n+ onPress={this.onPressLogIn}\n+ style={styles.button}\n+ underlayColor='#E0E0E0'\n+ activeOpacity={1}\n+ >\n+ <Text style={styles.buttonText}>\n+ LOG IN\n</Text>\n- <Button\n- onPress={this.onPress}\n- title=\"Log in\"\n- />\n+ </TouchableHighlight>\n+ <TouchableHighlight\n+ onPress={this.onPressRegister}\n+ style={styles.button}\n+ underlayColor='#E0E0E0'\n+ activeOpacity={1}\n+ >\n+ <Text style={styles.buttonText}>\n+ REGISTER\n+ </Text>\n+ </TouchableHighlight>\n</View>\n);\n}\n- onPress = () => {\n+ onPressLogIn = () => {\nthis.props.navigation.goBack();\n}\n+ onPressRegister = () => {\n+ this.setState({ mode: \"register\" });\n+ }\n+\n}\nconst styles = StyleSheet.create({\ncontainer: {\nflex: 1,\n- justifyContent: 'center',\n+ justifyContent: 'space-between',\nalignItems: 'center',\n- backgroundColor: '#257BAB',\n+ backgroundColor: '#f88742',\n+ paddingTop: 50,\n+ paddingBottom: 50,\n+ },\n+ headerContainer: {\n+ flex: 4,\n+ flexDirection: 'row',\n+ alignItems: 'flex-start',\n+ },\n+ header: {\n+ flex: 1,\n+ fontFamily: 'Anaheim-Regular',\n+ color: 'white',\n+ fontSize: 48,\n+ textAlign: 'center',\n+ },\n+ button: {\n+ paddingBottom: 6,\n+ paddingTop: 6,\n+ paddingLeft: 18,\n+ paddingRight: 18,\n+ marginLeft: 40,\n+ marginRight: 40,\n+ marginTop: 10,\n+ marginBottom: 10,\n+ borderRadius: 12,\n+ backgroundColor: 'white',\n+ alignSelf: 'stretch',\n},\n- instructions: {\n+ buttonText: {\n+ fontSize: 22,\n+ fontFamily: 'OpenSans-Semibold',\n+ color: '#f88742',\ntextAlign: 'center',\n- color: '#333333',\n- marginBottom: 5,\n},\n});\n"
},
{
"change_type": "ADD",
"old_path": "native/android/app/src/main/assets/fonts/Anaheim-Regular.ttf",
"new_path": "native/android/app/src/main/assets/fonts/Anaheim-Regular.ttf",
"diff": "Binary files /dev/null and b/native/android/app/src/main/assets/fonts/Anaheim-Regular.ttf differ\n"
},
{
"change_type": "ADD",
"old_path": "native/android/app/src/main/assets/fonts/OpenSans-Regular.ttf",
"new_path": "native/android/app/src/main/assets/fonts/OpenSans-Regular.ttf",
"diff": "Binary files /dev/null and b/native/android/app/src/main/assets/fonts/OpenSans-Regular.ttf differ\n"
},
{
"change_type": "ADD",
"old_path": "native/android/app/src/main/assets/fonts/OpenSans-Semibold.ttf",
"new_path": "native/android/app/src/main/assets/fonts/OpenSans-Semibold.ttf",
"diff": "Binary files /dev/null and b/native/android/app/src/main/assets/fonts/OpenSans-Semibold.ttf differ\n"
},
{
"change_type": "MODIFY",
"old_path": "native/app.react.js",
"new_path": "native/app.react.js",
"diff": "// @flow\nimport type { NavigationState } from 'react-navigation';\n-import ReactNavigationPropTypes from 'react-navigation/lib/PropTypes';\n+import { PropTypes as ReactNavigationPropTypes } from 'react-navigation';\nimport type { Dispatch } from 'lib/types/redux-types';\nimport type { AppState, Action } from './redux-setup';\n"
},
{
"change_type": "MODIFY",
"old_path": "native/index.android.js",
"new_path": "native/index.android.js",
"diff": "// @flow\n+import { UIManager } from 'react-native';\n+\n+UIManager.setLayoutAnimationEnabledExperimental &&\n+ UIManager.setLayoutAnimationEnabledExperimental(true);\n+\nimport './app.react';\n"
},
{
"change_type": "ADD",
"old_path": "native/ios/Anaheim-Regular.ttf",
"new_path": "native/ios/Anaheim-Regular.ttf",
"diff": "Binary files /dev/null and b/native/ios/Anaheim-Regular.ttf differ\n"
},
{
"change_type": "ADD",
"old_path": "native/ios/OpenSans-Regular.ttf",
"new_path": "native/ios/OpenSans-Regular.ttf",
"diff": "Binary files /dev/null and b/native/ios/OpenSans-Regular.ttf differ\n"
},
{
"change_type": "ADD",
"old_path": "native/ios/OpenSans-Semibold.ttf",
"new_path": "native/ios/OpenSans-Semibold.ttf",
"diff": "Binary files /dev/null and b/native/ios/OpenSans-Semibold.ttf differ\n"
},
{
"change_type": "MODIFY",
"old_path": "native/ios/SquadCal.xcodeproj/project.pbxproj",
"new_path": "native/ios/SquadCal.xcodeproj/project.pbxproj",
"diff": "146834051AC3E58100842450 /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 146834041AC3E56700842450 /* libReact.a */; };\n1AB3FA5006B7410FB4C0C308 /* Zocial.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 74BC06F2619F4105BB8D473C /* Zocial.ttf */; };\n24B72AE3C09241F9A274374B /* SimpleLineIcons.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 72CCB14CB9C744758BCC6EE2 /* SimpleLineIcons.ttf */; };\n- 545521FF2565416A81948191 /* Entypo.ttf in Resources */ = {isa = PBXBuildFile; fileRef = D8C2220A10374037B86EF5C7 /* Entypo.ttf */; };\n2D02E4BC1E0B4A80006451C7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB01A68108700A75B9A /* AppDelegate.m */; };\n2D02E4BD1E0B4A84006451C7 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; };\n2D02E4BF1E0B4AB3006451C7 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; };\n2D02E4C81E0B4AEC006451C7 /* libRCTWebSocket-tvOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3DAD3E991DF850E9000B6D8A /* libRCTWebSocket-tvOS.a */; };\n2D02E4C91E0B4AEC006451C7 /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3DAD3EA31DF850E9000B6D8A /* libReact.a */; };\n2DCD954D1E0B4F2C00145EB5 /* SquadCalTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 00E356F21AD99517003FC87E /* SquadCalTests.m */; };\n+ 545521FF2565416A81948191 /* Entypo.ttf in Resources */ = {isa = PBXBuildFile; fileRef = D8C2220A10374037B86EF5C7 /* Entypo.ttf */; };\n5E9157361DD0AC6A00FF2AA8 /* libRCTAnimation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5E9157331DD0AC6500FF2AA8 /* libRCTAnimation.a */; };\n6280BFDC755A423EA3F9F1F3 /* EvilIcons.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 25382D0B9DF641E5980C767A /* EvilIcons.ttf */; };\n73AC2D19D21A429F82DFEF39 /* MaterialIcons.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 252B3C4EBB754456AC3DA62B /* MaterialIcons.ttf */; };\n77D2353FC71C4C1283BE5F9A /* FontAwesome.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 3FA5703B95A944A3B8C2A544 /* FontAwesome.ttf */; };\n7A44EE7A2A5D4F4C903A7E48 /* Octicons.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 46133BB826CA47C8896F9081 /* Octicons.ttf */; };\n+ 7F13BDF71E57819900ECB29F /* Anaheim-Regular.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 7F13BDF61E57819900ECB29F /* Anaheim-Regular.ttf */; };\n+ 7F13BDF81E57819900ECB29F /* Anaheim-Regular.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 7F13BDF61E57819900ECB29F /* Anaheim-Regular.ttf */; };\n+ 7F13BE131E5781D000ECB29F /* Zocial.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 74BC06F2619F4105BB8D473C /* Zocial.ttf */; };\n+ 7F13BE141E5781D200ECB29F /* SimpleLineIcons.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 72CCB14CB9C744758BCC6EE2 /* SimpleLineIcons.ttf */; };\n+ 7F13BE151E5781D400ECB29F /* Octicons.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 46133BB826CA47C8896F9081 /* Octicons.ttf */; };\n+ 7F13BE161E5781D700ECB29F /* MaterialIcons.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 252B3C4EBB754456AC3DA62B /* MaterialIcons.ttf */; };\n+ 7F13BE171E5781D900ECB29F /* MaterialCommunityIcons.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 162F25141CC74F879C317D6E /* MaterialCommunityIcons.ttf */; };\n+ 7F13BE181E5781DC00ECB29F /* Ionicons.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 3CF8E5A2C4D7400DABC42E1C /* Ionicons.ttf */; };\n+ 7F13BE191E5781DE00ECB29F /* Foundation.ttf in Resources */ = {isa = PBXBuildFile; fileRef = E83C60E8FCA347949CDB3123 /* Foundation.ttf */; };\n+ 7F13BE1A1E5781E000ECB29F /* FontAwesome.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 3FA5703B95A944A3B8C2A544 /* FontAwesome.ttf */; };\n+ 7F13BE1B1E5781E200ECB29F /* EvilIcons.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 25382D0B9DF641E5980C767A /* EvilIcons.ttf */; };\n+ 7F13BE1C1E5781E400ECB29F /* Entypo.ttf in Resources */ = {isa = PBXBuildFile; fileRef = D8C2220A10374037B86EF5C7 /* Entypo.ttf */; };\n+ 7F13BE1E1E57A64E00ECB29F /* OpenSans-Regular.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 7F13BE1D1E57A64E00ECB29F /* OpenSans-Regular.ttf */; };\n+ 7F13BE1F1E57A64E00ECB29F /* OpenSans-Regular.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 7F13BE1D1E57A64E00ECB29F /* OpenSans-Regular.ttf */; };\n+ 7F13BE211E57A7D400ECB29F /* OpenSans-Semibold.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 7F13BE201E57A7D400ECB29F /* OpenSans-Semibold.ttf */; };\n+ 7F13BE221E57A7D400ECB29F /* OpenSans-Semibold.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 7F13BE201E57A7D400ECB29F /* OpenSans-Semibold.ttf */; };\n832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 832341B51AAA6A8300B99B32 /* libRCTText.a */; };\n851963C193B7411FAEEC4714 /* Ionicons.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 3CF8E5A2C4D7400DABC42E1C /* Ionicons.ttf */; };\nA9EFE97073954695944460FC /* libRNVectorIcons.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 88BB026037E849E0920826D5 /* libRNVectorIcons.a */; };\n1C4D176DFCDA44B88714287C /* 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>\"; };\n252B3C4EBB754456AC3DA62B /* 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>\"; };\n25382D0B9DF641E5980C767A /* 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+ 2D02E47B1E0B4A5D006451C7 /* SquadCal-tvOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = \"SquadCal-tvOS.app\"; sourceTree = BUILT_PRODUCTS_DIR; };\n+ 2D02E4901E0B4A5D006451C7 /* SquadCal-tvOSTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = \"SquadCal-tvOSTests.xctest\"; sourceTree = BUILT_PRODUCTS_DIR; };\n3CF8E5A2C4D7400DABC42E1C /* 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>\"; };\n3FA5703B95A944A3B8C2A544 /* 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>\"; };\n46133BB826CA47C8896F9081 /* 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- 2D02E47B1E0B4A5D006451C7 /* SquadCal-tvOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = \"SquadCal-tvOS.app\"; sourceTree = BUILT_PRODUCTS_DIR; };\n- 2D02E4901E0B4A5D006451C7 /* SquadCal-tvOSTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = \"SquadCal-tvOSTests.xctest\"; 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>\"; };\n72CCB14CB9C744758BCC6EE2 /* 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>\"; };\n74BC06F2619F4105BB8D473C /* 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>\"; };\n78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = \"wrapper.pb-project\"; name = RCTLinking.xcodeproj; path = \"../node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj\"; sourceTree = \"<group>\"; };\n+ 7F13BDF61E57819900ECB29F /* Anaheim-Regular.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = \"Anaheim-Regular.ttf\"; sourceTree = \"<group>\"; };\n+ 7F13BE1D1E57A64E00ECB29F /* OpenSans-Regular.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = \"OpenSans-Regular.ttf\"; sourceTree = \"<group>\"; };\n+ 7F13BE201E57A7D400ECB29F /* OpenSans-Semibold.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = \"OpenSans-Semibold.ttf\"; sourceTree = \"<group>\"; };\n832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = \"wrapper.pb-project\"; name = RCTText.xcodeproj; path = \"../node_modules/react-native/Libraries/Text/RCTText.xcodeproj\"; sourceTree = \"<group>\"; };\n88BB026037E849E0920826D5 /* libRNVectorIcons.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRNVectorIcons.a; sourceTree = \"<group>\"; };\nD8C2220A10374037B86EF5C7 /* 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>\"; };\n46133BB826CA47C8896F9081 /* Octicons.ttf */,\n72CCB14CB9C744758BCC6EE2 /* SimpleLineIcons.ttf */,\n74BC06F2619F4105BB8D473C /* Zocial.ttf */,\n+ 7F13BDF61E57819900ECB29F /* Anaheim-Regular.ttf */,\n+ 7F13BE1D1E57A64E00ECB29F /* OpenSans-Regular.ttf */,\n+ 7F13BE201E57A7D400ECB29F /* OpenSans-Semibold.ttf */,\n);\nname = Resources;\nsourceTree = \"<group>\";\nisa = PBXResourcesBuildPhase;\nbuildActionMask = 2147483647;\nfiles = (\n+ 7F13BDF71E57819900ECB29F /* Anaheim-Regular.ttf in Resources */,\n13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */,\n13B07FBD1A68108700A75B9A /* LaunchScreen.xib in Resources */,\n545521FF2565416A81948191 /* Entypo.ttf in Resources */,\nBC85221B39F244FA925E8159 /* Foundation.ttf in Resources */,\n851963C193B7411FAEEC4714 /* Ionicons.ttf in Resources */,\nE030B977C62947F2AF06A930 /* MaterialCommunityIcons.ttf in Resources */,\n+ 7F13BE211E57A7D400ECB29F /* OpenSans-Semibold.ttf in Resources */,\n73AC2D19D21A429F82DFEF39 /* MaterialIcons.ttf in Resources */,\n+ 7F13BE1E1E57A64E00ECB29F /* OpenSans-Regular.ttf in Resources */,\n7A44EE7A2A5D4F4C903A7E48 /* Octicons.ttf in Resources */,\n24B72AE3C09241F9A274374B /* SimpleLineIcons.ttf in Resources */,\n1AB3FA5006B7410FB4C0C308 /* Zocial.ttf in Resources */,\nisa = PBXResourcesBuildPhase;\nbuildActionMask = 2147483647;\nfiles = (\n+ 7F13BE151E5781D400ECB29F /* Octicons.ttf in Resources */,\n+ 7F13BE1C1E5781E400ECB29F /* Entypo.ttf in Resources */,\n+ 7F13BE1B1E5781E200ECB29F /* EvilIcons.ttf in Resources */,\n+ 7F13BE1A1E5781E000ECB29F /* FontAwesome.ttf in Resources */,\n+ 7F13BE171E5781D900ECB29F /* MaterialCommunityIcons.ttf in Resources */,\n+ 7F13BE181E5781DC00ECB29F /* Ionicons.ttf in Resources */,\n+ 7F13BE191E5781DE00ECB29F /* Foundation.ttf in Resources */,\n2D02E4BD1E0B4A84006451C7 /* Images.xcassets in Resources */,\n+ 7F13BE161E5781D700ECB29F /* MaterialIcons.ttf in Resources */,\n+ 7F13BE141E5781D200ECB29F /* SimpleLineIcons.ttf in Resources */,\n+ 7F13BE131E5781D000ECB29F /* Zocial.ttf in Resources */,\n+ 7F13BE1F1E57A64E00ECB29F /* OpenSans-Regular.ttf in Resources */,\n+ 7F13BE221E57A7D400ECB29F /* OpenSans-Semibold.ttf in Resources */,\n+ 7F13BDF81E57819900ECB29F /* Anaheim-Regular.ttf in Resources */,\n);\nrunOnlyForDeploymentPostprocessing = 0;\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "native/ios/SquadCal/Info.plist",
"new_path": "native/ios/SquadCal/Info.plist",
"diff": "<key>UIViewControllerBasedStatusBarAppearance</key>\n<false/>\n<key>NSLocationWhenInUseUsageDescription</key>\n- <string/>\n+ <string></string>\n<key>NSAppTransportSecurity</key>\n<dict>\n<key>NSExceptionDomains</key>\n</dict>\n<key>UIAppFonts</key>\n<array>\n+ <string>OpenSans-Semibold.ttf</string>\n+ <string>OpenSans-Regular.ttf</string>\n+ <string>Anaheim-Regular.ttf</string>\n<string>Entypo.ttf</string>\n<string>EvilIcons.ttf</string>\n<string>FontAwesome.ttf</string>\n"
},
{
"change_type": "MODIFY",
"old_path": "native/more/more.react.js",
"new_path": "native/more/more.react.js",
"diff": "@@ -47,7 +47,7 @@ class More extends React.PureComponent {\n}\nonPress = () => {\n- this.props.navigation.navigate('LogIn');\n+ this.props.navigation.navigate('LoggedOutModal');\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "native/redux-setup.js",
"new_path": "native/redux-setup.js",
"diff": "@@ -7,7 +7,7 @@ import type { LoadingStatus } from 'lib/types/loading-types';\nimport type { UserInfo } from 'lib/types/user-types';\nimport type { BaseNavInfo } from 'lib/types/nav-types';\nimport type { NavigationState } from 'react-navigation';\n-import ReactNavigationPropTypes from 'react-navigation/lib/PropTypes';\n+import { PropTypes as ReactNavigationPropTypes } from 'react-navigation';\nimport React from 'react';\nimport invariant from 'invariant';\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Progress on native login modal |
129,187 | 20.02.2017 17:12:55 | 18,000 | 0c339f947036d3848234628dc8d95fe91cc687e2 | Refinement of log-in screen, consistent on iOS/Android | [
{
"change_type": "MODIFY",
"old_path": "native/account/logged-out-modal.react.js",
"new_path": "native/account/logged-out-modal.react.js",
"diff": "@@ -7,8 +7,10 @@ import {\nView,\nStyleSheet,\nText,\n- TouchableHighlight,\n- LayoutAnimation,\n+ TouchableOpacity,\n+ Animated,\n+ Easing,\n+ Image,\n} from 'react-native';\nclass LoggedOutModal extends React.PureComponent {\n@@ -19,8 +21,10 @@ class LoggedOutModal extends React.PureComponent {\nstate: {\nmode: \"prompt\" | \"log-in\" | \"register\",\n+ paddingTop: Animated.Value,\n} = {\nmode: \"prompt\",\n+ paddingTop: new Animated.Value(200),\n};\nstatic propTypes = {\n@@ -35,39 +39,37 @@ class LoggedOutModal extends React.PureComponent {\n},\n};\n- componentWillUpdate() {\n- LayoutAnimation.spring();\n- }\n-\nrender() {\n- const alignSelf = this.state.mode === \"prompt\" ? \"center\" : \"flex-start\";\n+ const padding = { paddingTop: this.state.paddingTop };\nreturn (\n<View style={styles.container}>\n- <View style={styles.headerContainer}>\n- <Text style={[styles.header, { alignSelf }]}>\n+ <Image\n+ source={require(\"../img/logged-out-modal-background.jpg\")}\n+ style={styles.loggedOutModalBackgroundContainer}\n+ />\n+ <Animated.Text style={[styles.header, padding]}>\nSquadCal\n- </Text>\n- </View>\n- <TouchableHighlight\n+ </Animated.Text>\n+ <View style={styles.buttonContainer}>\n+ <TouchableOpacity\nonPress={this.onPressLogIn}\nstyle={styles.button}\n- underlayColor='#E0E0E0'\n- activeOpacity={1}\n+ activeOpacity={0.6}\n>\n<Text style={styles.buttonText}>\nLOG IN\n</Text>\n- </TouchableHighlight>\n- <TouchableHighlight\n+ </TouchableOpacity>\n+ <TouchableOpacity\nonPress={this.onPressRegister}\nstyle={styles.button}\n- underlayColor='#E0E0E0'\n- activeOpacity={1}\n+ activeOpacity={0.6}\n>\n<Text style={styles.buttonText}>\nREGISTER\n</Text>\n- </TouchableHighlight>\n+ </TouchableOpacity>\n+ </View>\n</View>\n);\n}\n@@ -77,32 +79,40 @@ class LoggedOutModal extends React.PureComponent {\n}\nonPressRegister = () => {\n- this.setState({ mode: \"register\" });\n+ Animated.timing(\n+ this.state.paddingTop,\n+ {\n+ easing: Easing.out(Easing.exp),\n+ toValue: 40,\n+ },\n+ ).start();\n}\n}\nconst styles = StyleSheet.create({\n+ loggedOutModalBackgroundContainer: {\n+ position: 'absolute',\n+ },\ncontainer: {\nflex: 1,\n- justifyContent: 'space-between',\n- alignItems: 'center',\n- backgroundColor: '#f88742',\npaddingTop: 50,\npaddingBottom: 50,\n- },\n- headerContainer: {\n- flex: 4,\n- flexDirection: 'row',\n- alignItems: 'flex-start',\n+ backgroundColor: 'transparent',\n},\nheader: {\n- flex: 1,\nfontFamily: 'Anaheim-Regular',\ncolor: 'white',\nfontSize: 48,\ntextAlign: 'center',\n},\n+ buttonContainer: {\n+ position: 'absolute',\n+ bottom: 0,\n+ left: 0,\n+ right: 0,\n+ paddingBottom: 20,\n+ },\nbutton: {\npaddingBottom: 6,\npaddingTop: 6,\n@@ -112,15 +122,14 @@ const styles = StyleSheet.create({\nmarginRight: 40,\nmarginTop: 10,\nmarginBottom: 10,\n- borderRadius: 12,\n- backgroundColor: 'white',\n- alignSelf: 'stretch',\n+ borderRadius: 6,\n+ backgroundColor: '#FFFFFFAA',\n},\nbuttonText: {\nfontSize: 22,\nfontFamily: 'OpenSans-Semibold',\n- color: '#f88742',\ntextAlign: 'center',\n+ color: '#000000FF',\n},\n});\n"
},
{
"change_type": "ADD",
"old_path": "native/img/logged-out-modal-background.jpg",
"new_path": "native/img/logged-out-modal-background.jpg",
"diff": "Binary files /dev/null and b/native/img/logged-out-modal-background.jpg differ\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Refinement of log-in screen, consistent on iOS/Android |
129,187 | 03.03.2017 11:32:17 | 28,800 | efc5c9141a8ca761c09a3028a26b19a4304403cb | jquery-param extracted, new "config" concept so we can customize endpoint, move fetch around (since it's already there in React Native), and updated iOS config | [
{
"change_type": "MODIFY",
"old_path": "lib/package.json",
"new_path": "lib/package.json",
"diff": "\"dependencies\": {\n\"invariant\": \"^2.2.2\",\n\"isomorphic-fetch\": \"^2.2.1\",\n- \"jquery\": \"^3.1.1\",\n+ \"jquery-param\": \"^0.2.0\",\n\"lodash\": \"^4.17.4\",\n\"react\": \"^15.4.2\",\n\"redux\": \"^3.6.0\",\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "lib/utils/config.js",
"diff": "+// @flow\n+\n+import invariant from 'invariant';\n+\n+export type Config = {\n+ urlPrefix: string,\n+};\n+\n+let registeredConfig: ?Config = null;\n+\n+const registerConfig = (config: Config) => {\n+ registeredConfig = config;\n+};\n+\n+const getConfig = (): Config => {\n+ invariant(registeredConfig, \"config should be set\");\n+ return registeredConfig;\n+};\n+\n+export {\n+ registerConfig,\n+ getConfig,\n+};\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/utils/fetch-json.js",
"new_path": "lib/utils/fetch-json.js",
"diff": "// @flow\n-import 'isomorphic-fetch'; // side-effect: window.fetch\n-import { param } from 'jquery';\n+import $param from 'jquery-param';\nimport { ServerError } from './fetch-utils';\n+import { getConfig } from './config';\nasync function fetchJSON(\nurl: string,\ndata: {[key: string]: mixed},\n) {\n+ url = getConfig().urlPrefix + url;\nconst response = await fetch(url, {\n// Flow gets confused by some enum type, so we need this cast\n'method': ('POST': MethodType),\n@@ -18,10 +19,7 @@ async function fetchJSON(\n'Accept': 'application/json',\n'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',\n},\n- // We need to use jQuery to create URL-encoded form data for PHP.\n- // There is a polyfill we could use for URLSearchParams, which supports\n- // URL-encoding form data. But it doesn't support nested structure.\n- 'body': param(data),\n+ 'body': $param(data),\n});\nconst json = await response.json();\nconsole.log(json);\n"
},
{
"change_type": "MODIFY",
"old_path": "native/app.react.js",
"new_path": "native/app.react.js",
"diff": "@@ -8,10 +8,13 @@ import type { AppState, Action } from './redux-setup';\nimport React from 'react';\nimport { createStore, applyMiddleware } from 'redux';\nimport { Provider, connect } from 'react-redux';\n-import { AppRegistry } from 'react-native';\n+import { AppRegistry, Platform, UIManager } from 'react-native';\nimport { addNavigationHelpers } from 'react-navigation';\nimport { composeWithDevTools } from 'remote-redux-devtools';\nimport thunk from 'redux-thunk';\n+import invariant from 'invariant';\n+\n+import { registerConfig } from 'lib/utils/config';\nimport { RootNavigator } from './navigation-setup';\nimport { reducer, defaultState } from './redux-setup';\n@@ -37,6 +40,25 @@ class AppWithNavigationState extends React.PureComponent {\n}\n+let urlPrefix;\n+if (!__DEV__) {\n+ urlPrefix = \"https://squadcal.org/\";\n+} else if (Platform.OS === \"android\") {\n+ // This is a magic IP address that forwards to the emulator's host\n+ urlPrefix = \"http://10.0.2.2/~ashoat/squadcal/\";\n+} else if (Platform.OS === \"ios\") {\n+ // Since iOS is simulated and not emulated, we can use localhost\n+ urlPrefix = \"http://localhost/~ashoat/squadcal/\";\n+} else {\n+ invariant(false, \"unsupported platform\");\n+}\n+registerConfig({ urlPrefix });\n+\n+if (Platform.OS === \"android\") {\n+ UIManager.setLayoutAnimationEnabledExperimental &&\n+ UIManager.setLayoutAnimationEnabledExperimental(true);\n+}\n+\nconst ConnectedAppWithNavigationState = connect(\n(state: AppState) => ({\nnavigationState: state.navInfo.navigationState,\n"
},
{
"change_type": "MODIFY",
"old_path": "native/index.android.js",
"new_path": "native/index.android.js",
"diff": "// @flow\n-import { UIManager } from 'react-native';\n-\n-UIManager.setLayoutAnimationEnabledExperimental &&\n- UIManager.setLayoutAnimationEnabledExperimental(true);\n-\nimport './app.react';\n"
},
{
"change_type": "MODIFY",
"old_path": "native/ios/SquadCal.xcodeproj/project.pbxproj",
"new_path": "native/ios/SquadCal.xcodeproj/project.pbxproj",
"diff": "TargetAttributes = {\n00E356ED1AD99517003FC87E = {\nCreatedOnToolsVersion = 6.2;\n+ DevelopmentTeam = CW2BC4VSCP;\nTestTargetID = 13B07F861A680F5B00A75B9A;\n};\n+ 13B07F861A680F5B00A75B9A = {\n+ DevelopmentTeam = CW2BC4VSCP;\n+ };\n2D02E47A1E0B4A5D006451C7 = {\nCreatedOnToolsVersion = 8.2.1;\nProvisioningStyle = Automatic;\nisa = XCBuildConfiguration;\nbuildSettings = {\nBUNDLE_LOADER = \"$(TEST_HOST)\";\n+ DEVELOPMENT_TEAM = CW2BC4VSCP;\nGCC_PREPROCESSOR_DEFINITIONS = (\n\"DEBUG=1\",\n\"$(inherited)\",\nbuildSettings = {\nBUNDLE_LOADER = \"$(TEST_HOST)\";\nCOPY_PHASE_STRIP = NO;\n+ DEVELOPMENT_TEAM = CW2BC4VSCP;\nINFOPLIST_FILE = SquadCalTests/Info.plist;\nIPHONEOS_DEPLOYMENT_TARGET = 8.0;\nLD_RUNPATH_SEARCH_PATHS = \"$(inherited) @executable_path/Frameworks @loader_path/Frameworks\";\nASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;\nCURRENT_PROJECT_VERSION = 1;\nDEAD_CODE_STRIPPING = NO;\n+ DEVELOPMENT_TEAM = CW2BC4VSCP;\nINFOPLIST_FILE = SquadCal/Info.plist;\nLD_RUNPATH_SEARCH_PATHS = \"$(inherited) @executable_path/Frameworks\";\nOTHER_LDFLAGS = (\n\"-ObjC\",\n\"-lc++\",\n);\n+ PRODUCT_BUNDLE_IDENTIFIER = org.squadcal.ios;\nPRODUCT_NAME = SquadCal;\nVERSIONING_SYSTEM = \"apple-generic\";\n};\nbuildSettings = {\nASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;\nCURRENT_PROJECT_VERSION = 1;\n+ DEVELOPMENT_TEAM = CW2BC4VSCP;\nINFOPLIST_FILE = SquadCal/Info.plist;\nLD_RUNPATH_SEARCH_PATHS = \"$(inherited) @executable_path/Frameworks\";\nOTHER_LDFLAGS = (\n\"-ObjC\",\n\"-lc++\",\n);\n+ PRODUCT_BUNDLE_IDENTIFIER = org.squadcal.ios;\nPRODUCT_NAME = SquadCal;\nVERSIONING_SYSTEM = \"apple-generic\";\n};\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"
},
{
"change_type": "MODIFY",
"old_path": "native/ios/SquadCal/Info.plist",
"new_path": "native/ios/SquadCal/Info.plist",
"diff": "<key>CFBundleExecutable</key>\n<string>$(EXECUTABLE_NAME)</string>\n<key>CFBundleIdentifier</key>\n- <string>org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)</string>\n+ <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>\n<key>CFBundleInfoDictionaryVersion</key>\n<string>6.0</string>\n<key>CFBundleName</key>\n<key>CFBundlePackageType</key>\n<string>APPL</string>\n<key>CFBundleShortVersionString</key>\n- <string>1.0</string>\n+ <string>0.1</string>\n<key>CFBundleSignature</key>\n<string>????</string>\n<key>CFBundleVersion</key>\n<string>1</string>\n<key>LSRequiresIPhoneOS</key>\n<true/>\n- <key>UILaunchStoryboardName</key>\n- <string>LaunchScreen</string>\n- <key>UIRequiredDeviceCapabilities</key>\n- <array>\n- <string>armv7</string>\n- </array>\n- <key>UISupportedInterfaceOrientations</key>\n- <array>\n- <string>UIInterfaceOrientationPortrait</string>\n- <string>UIInterfaceOrientationLandscapeLeft</string>\n- <string>UIInterfaceOrientationLandscapeRight</string>\n- </array>\n- <key>UIViewControllerBasedStatusBarAppearance</key>\n- <false/>\n- <key>NSLocationWhenInUseUsageDescription</key>\n- <string></string>\n<key>NSAppTransportSecurity</key>\n<dict>\n<key>NSExceptionDomains</key>\n</dict>\n</dict>\n</dict>\n+ <key>NSLocationWhenInUseUsageDescription</key>\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>UILaunchStoryboardName</key>\n+ <string>LaunchScreen</string>\n+ <key>UIRequiredDeviceCapabilities</key>\n+ <array>\n+ <string>armv7</string>\n+ </array>\n+ <key>UISupportedInterfaceOrientations</key>\n+ <array>\n+ <string>UIInterfaceOrientationPortrait</string>\n+ <string>UIInterfaceOrientationLandscapeLeft</string>\n+ <string>UIInterfaceOrientationLandscapeRight</string>\n+ </array>\n+ <key>UIViewControllerBasedStatusBarAppearance</key>\n+ <false/>\n</dict>\n</plist>\n"
},
{
"change_type": "MODIFY",
"old_path": "web/script.js",
"new_path": "web/script.js",
"diff": "// @flow\nimport 'babel-polyfill';\n+import 'isomorphic-fetch';\nimport type { Store } from 'redux';\nimport type { CalendarInfo } from 'lib/types/calendar-types';\n@@ -20,6 +21,7 @@ import {\nimport _keyBy from 'lodash/fp/keyBy';\nimport { daysToEntriesFromEntryInfos } from 'lib/reducers/entry-reducer';\n+import { registerConfig } from 'lib/utils/config';\nimport { reducer } from './redux-setup';\n@@ -43,6 +45,8 @@ declare var reset_password_username: string;\ndeclare var home: bool;\ndeclare var calendar_id: ?string;\n+registerConfig({ urlPrefix: \"\" });\n+\nconst sessionID = Math.floor(0x80000000 * Math.random()).toString(36);\nconst userInfo = email\n? { username, email, emailVerified: email_verified }\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | jquery-param extracted, new "config" concept so we can customize endpoint, move fetch around (since it's already there in React Native), and updated iOS config |
129,187 | 03.03.2017 11:34:46 | 28,800 | 4e5990c6613d9dc97d3550525a72188f64dd27d9 | Progress on log in/register on mobile | [
{
"change_type": "MODIFY",
"old_path": "lib/selectors/loading-selectors.js",
"new_path": "lib/selectors/loading-selectors.js",
"diff": "@@ -10,14 +10,9 @@ import _memoize from 'lodash/memoize';\nimport { registerFetchKey } from '../reducers/loading-reducer';\n-const baseCreateLoadingStatusSelector = (key: string, overrideKey?: string) => {\n- // This makes sure that reduceLoadingStatuses tracks this action key\n- registerFetchKey(key);\n- // This is the key used to store the Promise state in Redux\n- const trackingKey = overrideKey ? overrideKey : key;\n- return createSelector(\n- (state: BaseAppState) => state.loadingStatuses[trackingKey],\n- (loadingStatusInfo: {[idx: number]: LoadingStatus}): LoadingStatus => {\n+function loadingStatusFromInfo(\n+ loadingStatusInfo: {[idx: number]: LoadingStatus},\n+): LoadingStatus {\nif (_isEmpty(loadingStatusInfo)) {\nreturn \"inactive\";\n} else if (_includes(\"error\")(loadingStatusInfo)) {\n@@ -25,7 +20,17 @@ const baseCreateLoadingStatusSelector = (key: string, overrideKey?: string) => {\n} else {\nreturn \"loading\";\n}\n- },\n+}\n+\n+const baseCreateLoadingStatusSelector = (key: string, overrideKey?: string) => {\n+ // This makes sure that reduceLoadingStatuses tracks this action key\n+ registerFetchKey(key);\n+ // This is the key used to store the Promise state in Redux\n+ const trackingKey = overrideKey ? overrideKey : key;\n+ return createSelector(\n+ (state: BaseAppState) => state.loadingStatuses[trackingKey],\n+ (loadingStatusInfo: {[idx: number]: LoadingStatus}) =>\n+ loadingStatusFromInfo(loadingStatusInfo),\n);\n};\n@@ -34,6 +39,26 @@ const createLoadingStatusSelector = _memoize(\n(key: string, overrideKey: ?string) => overrideKey ? overrideKey : key,\n);\n+const globalLoadingStatusSelector = createSelector(\n+ (state: BaseAppState) => state.loadingStatuses,\n+ (\n+ loadingStatusInfos: {[key: string]: {[idx: number]: LoadingStatus}},\n+ ): LoadingStatus => {\n+ let errorExists = false;\n+ for (const idx in loadingStatusInfos) {\n+ const loadingStatus = loadingStatusFromInfo(loadingStatusInfos[idx]);\n+ if (loadingStatus === \"loading\") {\n+ return \"loading\";\n+ }\n+ if (loadingStatus === \"error\") {\n+ errorExists = true;\n+ }\n+ }\n+ return errorExists ? \"error\" : \"inactive\";\n+ },\n+);\n+\nexport {\ncreateLoadingStatusSelector,\n+ globalLoadingStatusSelector,\n};\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/account/log-in-panel.react.js",
"diff": "+// @flow\n+\n+import type { DispatchActionPromise } from 'lib/utils/action-utils';\n+import type { AppState } from '../redux-setup';\n+import type { LoadingStatus } from 'lib/types/loading-types';\n+import type { LogInResult } from 'lib/actions/user-actions';\n+\n+import React from 'react';\n+import {\n+ View,\n+ StyleSheet,\n+ TouchableHighlight,\n+ Text,\n+ Platform,\n+ ActivityIndicator,\n+ Alert,\n+ Keyboard,\n+} from 'react-native';\n+import Icon from 'react-native-vector-icons/FontAwesome';\n+import { connect } from 'react-redux';\n+import invariant from 'invariant';\n+\n+import {\n+ validUsernameRegex,\n+ validEmailRegex,\n+} from 'lib/shared/account-regexes';\n+import {\n+ includeDispatchActionProps,\n+ createBoundServerCallSelector,\n+} from 'lib/utils/action-utils';\n+import { logInActionType, logIn } from 'lib/actions/user-actions';\n+import { createLoadingStatusSelector } from 'lib/selectors/loading-selectors';\n+import sleep from 'lib/utils/sleep';\n+\n+import { TextInput } from '../modal-components.react';\n+\n+class LogInPanel extends React.PureComponent {\n+\n+ props: {\n+ navigateToApp: () => void,\n+ // Redux state\n+ loadingStatus: LoadingStatus,\n+ // Redux dispatch functions\n+ dispatchActionPromise: DispatchActionPromise,\n+ // async functions that hit server APIs\n+ logIn: (\n+ username: string,\n+ password: string,\n+ ) => Promise<LogInResult>,\n+ };\n+ static propTypes = {\n+ navigateToApp: React.PropTypes.func.isRequired,\n+ loadingStatus: React.PropTypes.string.isRequired,\n+ dispatchActionPromise: React.PropTypes.func.isRequired,\n+ logIn: React.PropTypes.func.isRequired,\n+ };\n+ state: {\n+ usernameOrEmailInputText: string,\n+ passwordInputText: string,\n+ } = {\n+ usernameOrEmailInputText: \"\",\n+ passwordInputText: \"\",\n+ };\n+ usernameOrEmailInput: ?TextInput;\n+ passwordInput: ?TextInput;\n+\n+ render() {\n+ let buttonIcon;\n+ if (this.props.loadingStatus === \"loading\") {\n+ buttonIcon = (\n+ <View style={styles.loadingIndicatorContainer}>\n+ <ActivityIndicator color=\"#555\" />\n+ </View>\n+ );\n+ } else {\n+ buttonIcon = (\n+ <View style={styles.submitContentIconContainer}>\n+ <Icon name=\"arrow-right\" size={16} color=\"#555\" />\n+ </View>\n+ );\n+ }\n+ return (\n+ <View style={styles.container}>\n+ <View>\n+ <Icon name=\"user\" size={22} color=\"#777\" style={styles.icon} />\n+ <TextInput\n+ style={styles.input}\n+ value={this.state.usernameOrEmailInputText}\n+ onChangeText={this.onChangeUsernameOrEmailInputText}\n+ placeholder=\"Username or email address\"\n+ autoFocus={true}\n+ autoCorrect={false}\n+ autoCapitalize=\"none\"\n+ keyboardType=\"ascii-capable\"\n+ returnKeyType='next'\n+ blurOnSubmit={false}\n+ onSubmitEditing={this.focusPasswordInput}\n+ editable={this.props.loadingStatus !== \"loading\"}\n+ ref={this.usernameOrEmailInputRef}\n+ />\n+ </View>\n+ <View>\n+ <Icon name=\"lock\" size={22} color=\"#777\" style={styles.icon} />\n+ <TextInput\n+ style={styles.input}\n+ value={this.state.passwordInputText}\n+ onChangeText={this.onChangePasswordInputText}\n+ placeholder=\"Password\"\n+ secureTextEntry={true}\n+ returnKeyType='go'\n+ blurOnSubmit={false}\n+ onSubmitEditing={this.onSubmit}\n+ editable={this.props.loadingStatus !== \"loading\"}\n+ ref={this.passwordInputRef}\n+ />\n+ </View>\n+ <TouchableHighlight\n+ onPress={this.onSubmit}\n+ style={styles.submitButton}\n+ underlayColor=\"#A0A0A0DD\"\n+ >\n+ <View style={styles.submitContentContainer}>\n+ <Text style={styles.submitContentText}>LOG IN</Text>\n+ {buttonIcon}\n+ </View>\n+ </TouchableHighlight>\n+ </View>\n+ );\n+ }\n+\n+ usernameOrEmailInputRef = (usernameOrEmailInput: ?TextInput) => {\n+ this.usernameOrEmailInput = usernameOrEmailInput;\n+ }\n+\n+ passwordInputRef = (passwordInput: ?TextInput) => {\n+ this.passwordInput = passwordInput;\n+ }\n+\n+ focusPasswordInput = () => {\n+ invariant(this.passwordInput, \"ref should be set\");\n+ this.passwordInput.focus();\n+ }\n+\n+ onChangeUsernameOrEmailInputText = (text: string) => {\n+ this.setState({ usernameOrEmailInputText: text });\n+ }\n+\n+ onChangePasswordInputText = (text: string) => {\n+ this.setState({ passwordInputText: text });\n+ }\n+\n+ onSubmit = () => {\n+ if (\n+ this.state.usernameOrEmailInputText.search(validUsernameRegex) === -1 &&\n+ this.state.usernameOrEmailInputText.search(validEmailRegex) === -1\n+ ) {\n+ Alert.alert(\n+ 'Invalid username',\n+ 'Alphanumeric usernames or emails only',\n+ [\n+ { text: 'OK', onPress: this.onInvalidUsernameAlertAcknowledged },\n+ ],\n+ { cancelable: false },\n+ );\n+ return;\n+ }\n+\n+ Keyboard.dismiss();\n+ this.props.dispatchActionPromise(logInActionType, this.logInAction());\n+ }\n+\n+ onInvalidUsernameAlertAcknowledged = () => {\n+ this.setState(\n+ {\n+ usernameOrEmailInputText: \"\",\n+ },\n+ () => {\n+ invariant(this.usernameOrEmailInput, \"ref should exist\");\n+ this.usernameOrEmailInput.focus();\n+ },\n+ );\n+ }\n+\n+ async logInAction() {\n+ try {\n+ await sleep(500);\n+ const result = await this.props.logIn(\n+ this.state.usernameOrEmailInputText,\n+ this.state.passwordInputText,\n+ );\n+ this.props.navigateToApp();\n+ return result;\n+ } catch (e) {\n+ if (e.message === 'invalid_parameters') {\n+ Alert.alert(\n+ 'Invalid username',\n+ \"User doesn't exist\",\n+ [\n+ { text: 'OK', onPress: this.onInvalidParametersAlertAcknowledged },\n+ ],\n+ { cancelable: false },\n+ );\n+ } else if (e.message === 'invalid_credentials') {\n+ Alert.alert(\n+ 'Incorrect password',\n+ 'The password you entered is incorrect',\n+ [\n+ { text: 'OK', onPress: this.onInvalidCredentialsAlertAcknowledged },\n+ ],\n+ { cancelable: false },\n+ );\n+ } else {\n+ Alert.alert(\n+ 'Unknown error',\n+ 'Uhh... try again?',\n+ [\n+ { text: 'OK', onPress: this.onUnknownErrorAlertAcknowledged },\n+ ],\n+ { cancelable: false },\n+ );\n+ }\n+ throw e;\n+ }\n+ }\n+\n+ onInvalidParametersAlertAcknowledged = () => {\n+ this.setState(\n+ {\n+ usernameOrEmailInputText: \"\",\n+ },\n+ () => {\n+ invariant(this.usernameOrEmailInput, \"ref should exist\");\n+ this.usernameOrEmailInput.focus();\n+ },\n+ );\n+ }\n+\n+ onInvalidCredentialsAlertAcknowledged = () => {\n+ this.setState(\n+ {\n+ passwordInputText: \"\",\n+ },\n+ () => {\n+ invariant(this.passwordInput, \"passwordInput ref unset\");\n+ this.passwordInput.focus();\n+ },\n+ );\n+ }\n+\n+ onUnknownErrorAlertAcknowledged = () => {\n+ this.setState(\n+ {\n+ usernameOrEmailInputText: \"\",\n+ passwordInputText: \"\",\n+ },\n+ () => {\n+ invariant(this.usernameOrEmailInput, \"ref should exist\");\n+ this.usernameOrEmailInput.focus();\n+ },\n+ );\n+ }\n+\n+\n+}\n+\n+const styles = StyleSheet.create({\n+ container: {\n+ paddingBottom: 37,\n+ paddingTop: 6,\n+ paddingLeft: 18,\n+ paddingRight: 18,\n+ marginLeft: 20,\n+ marginRight: 20,\n+ marginTop: 40,\n+ borderRadius: 6,\n+ backgroundColor: '#FFFFFFAA',\n+ },\n+ input: {\n+ paddingLeft: 35,\n+ },\n+ icon: {\n+ position: 'absolute',\n+ bottom: 8,\n+ left: 4,\n+ },\n+ submitButton: {\n+ position: 'absolute',\n+ bottom: 0,\n+ right: 0,\n+ borderBottomRightRadius: 6,\n+ },\n+ submitContentContainer: {\n+ flexDirection: 'row',\n+ alignItems: 'flex-end',\n+ paddingLeft: 18,\n+ paddingTop: 6,\n+ paddingRight: 18,\n+ paddingBottom: 6,\n+ },\n+ submitContentText: {\n+ fontSize: 18,\n+ fontFamily: 'OpenSans-Semibold',\n+ color: \"#555\",\n+ paddingRight: 7,\n+ },\n+ submitContentIconContainer: {\n+ width: 14,\n+ paddingBottom: 5,\n+ },\n+ loadingIndicatorContainer: {\n+ width: 14,\n+ paddingBottom: 2,\n+ },\n+});\n+\n+const logInServerCallSelector = createBoundServerCallSelector(logIn);\n+const loadingStatusSelector = createLoadingStatusSelector(logInActionType);\n+\n+export default connect(\n+ (state: AppState) => ({\n+ loadingStatus: loadingStatusSelector(state),\n+ logIn: logInServerCallSelector(state),\n+ }),\n+ includeDispatchActionProps({ dispatchActionPromise: true }),\n+)(LogInPanel);\n+\n"
},
{
"change_type": "MODIFY",
"old_path": "native/account/logged-out-modal.react.js",
"new_path": "native/account/logged-out-modal.react.js",
"diff": "@@ -13,6 +13,10 @@ import {\nImage,\n} from 'react-native';\n+import LogInPanel from './log-in-panel.react';\n+import RegisterPanel from './register-panel.react';\n+import ConnectedStatusBar from '../connected-status-bar.react';\n+\nclass LoggedOutModal extends React.PureComponent {\nprops: {\n@@ -41,6 +45,12 @@ class LoggedOutModal extends React.PureComponent {\nrender() {\nconst padding = { paddingTop: this.state.paddingTop };\n+ let content = null;\n+ if (this.state.mode === \"log-in\") {\n+ content = <LogInPanel navigateToApp={this.props.navigation.goBack} />;\n+ } else if (this.state.mode === \"register\") {\n+ content = <RegisterPanel navigateToApp={this.props.navigation.goBack} />;\n+ }\nreturn (\n<View style={styles.container}>\n<Image\n@@ -50,6 +60,7 @@ class LoggedOutModal extends React.PureComponent {\n<Animated.Text style={[styles.header, padding]}>\nSquadCal\n</Animated.Text>\n+ {content}\n<View style={styles.buttonContainer}>\n<TouchableOpacity\nonPress={this.onPressLogIn}\n@@ -66,16 +77,24 @@ class LoggedOutModal extends React.PureComponent {\nactiveOpacity={0.6}\n>\n<Text style={styles.buttonText}>\n- REGISTER\n+ SIGN UP\n</Text>\n</TouchableOpacity>\n</View>\n+ <ConnectedStatusBar barStyle=\"light-content\" />\n</View>\n);\n}\nonPressLogIn = () => {\n- this.props.navigation.goBack();\n+ Animated.timing(\n+ this.state.paddingTop,\n+ {\n+ easing: Easing.out(Easing.exp),\n+ toValue: 0,\n+ },\n+ ).start();\n+ this.setState({ mode: \"log-in\" });\n}\nonPressRegister = () => {\n@@ -83,9 +102,10 @@ class LoggedOutModal extends React.PureComponent {\nthis.state.paddingTop,\n{\neasing: Easing.out(Easing.exp),\n- toValue: 40,\n+ toValue: 0,\n},\n).start();\n+ this.setState({ mode: \"register\" });\n}\n}\n@@ -96,7 +116,7 @@ const styles = StyleSheet.create({\n},\ncontainer: {\nflex: 1,\n- paddingTop: 50,\n+ paddingTop: 40,\npaddingBottom: 50,\nbackgroundColor: 'transparent',\n},\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/account/register-panel.react.js",
"diff": "+// @flow\n+\n+import type { DispatchActionPromise } from 'lib/utils/action-utils';\n+import type { AppState } from '../redux-setup';\n+import type { LoadingStatus } from 'lib/types/loading-types';\n+import type { RegisterResult } from 'lib/actions/user-actions';\n+\n+import React from 'react';\n+import {\n+ View,\n+ StyleSheet,\n+ TouchableHighlight,\n+ Text,\n+ Platform,\n+ ActivityIndicator,\n+ Keyboard,\n+} from 'react-native';\n+import Icon from 'react-native-vector-icons/FontAwesome';\n+import { connect } from 'react-redux';\n+import invariant from 'invariant';\n+\n+import {\n+ includeDispatchActionProps,\n+ createBoundServerCallSelector,\n+} from 'lib/utils/action-utils';\n+import { registerActionType, register } from 'lib/actions/user-actions';\n+import { createLoadingStatusSelector } from 'lib/selectors/loading-selectors';\n+import sleep from 'lib/utils/sleep';\n+\n+import { TextInput } from '../modal-components.react';\n+\n+class RegisterPanel extends React.PureComponent {\n+\n+ props: {\n+ navigateToApp: () => void,\n+ // Redux state\n+ loadingStatus: LoadingStatus,\n+ // Redux dispatch functions\n+ dispatchActionPromise: DispatchActionPromise,\n+ // async functions that hit server APIs\n+ register: (\n+ username: string,\n+ email: string,\n+ password: string,\n+ ) => Promise<RegisterResult>,\n+ };\n+ static propTypes = {\n+ navigateToApp: React.PropTypes.func.isRequired,\n+ loadingStatus: React.PropTypes.string.isRequired,\n+ dispatchActionPromise: React.PropTypes.func.isRequired,\n+ register: React.PropTypes.func.isRequired,\n+ };\n+ state: {\n+ usernameInputText: string,\n+ emailInputText: string,\n+ passwordInputText: string,\n+ confirmPasswordInputText: string,\n+ } = {\n+ usernameInputText: \"\",\n+ emailInputText: \"\",\n+ passwordInputText: \"\",\n+ confirmPasswordInputText: \"\",\n+ };\n+ usernameInput: ?TextInput;\n+ emailInput: ?TextInput;\n+ passwordInput: ?TextInput;\n+ confirmPasswordInput: ?TextInput;\n+\n+ render() {\n+ let buttonIcon;\n+ if (this.props.loadingStatus === \"loading\") {\n+ buttonIcon = (\n+ <View style={styles.loadingIndicatorContainer}>\n+ <ActivityIndicator color=\"#555\" />\n+ </View>\n+ );\n+ } else {\n+ buttonIcon = (\n+ <View style={styles.submitContentIconContainer}>\n+ <Icon\n+ name=\"arrow-right\"\n+ size={16}\n+ color=\"#555\"\n+ />\n+ </View>\n+ );\n+ }\n+ return (\n+ <View style={styles.container}>\n+ <View>\n+ <Icon name=\"user\" size={22} color=\"#777\" style={styles.icon} />\n+ <TextInput\n+ style={styles.input}\n+ value={this.state.usernameInputText}\n+ onChangeText={this.onChangeUsernameInputText}\n+ placeholder=\"Username\"\n+ autoFocus={true}\n+ autoCorrect={false}\n+ autoCapitalize=\"none\"\n+ keyboardType=\"ascii-capable\"\n+ returnKeyType='next'\n+ blurOnSubmit={false}\n+ onSubmitEditing={this.focusEmailInput}\n+ editable={this.props.loadingStatus !== \"loading\"}\n+ ref={this.usernameInputRef}\n+ />\n+ </View>\n+ <View>\n+ <Icon\n+ name=\"envelope\"\n+ size={18}\n+ color=\"#777\"\n+ style={[styles.icon, styles.envelopeIcon]}\n+ />\n+ <TextInput\n+ style={styles.input}\n+ value={this.state.emailInputText}\n+ onChangeText={this.onChangeEmailInputText}\n+ placeholder=\"Email address\"\n+ autoCorrect={false}\n+ autoCapitalize=\"none\"\n+ keyboardType=\"email-address\"\n+ returnKeyType='next'\n+ blurOnSubmit={false}\n+ onSubmitEditing={this.focusPasswordInput}\n+ editable={this.props.loadingStatus !== \"loading\"}\n+ ref={this.emailInputRef}\n+ />\n+ </View>\n+ <View>\n+ <Icon name=\"lock\" size={22} color=\"#777\" style={styles.icon} />\n+ <TextInput\n+ style={styles.input}\n+ value={this.state.passwordInputText}\n+ onChangeText={this.onChangePasswordInputText}\n+ placeholder=\"Password\"\n+ secureTextEntry={true}\n+ returnKeyType='next'\n+ blurOnSubmit={false}\n+ onSubmitEditing={this.focusConfirmPasswordInput}\n+ editable={this.props.loadingStatus !== \"loading\"}\n+ ref={this.passwordInputRef}\n+ />\n+ </View>\n+ <View>\n+ <TextInput\n+ style={styles.input}\n+ value={this.state.confirmPasswordInputText}\n+ onChangeText={this.onChangeConfirmPasswordInputText}\n+ placeholder=\"Confirm password\"\n+ secureTextEntry={true}\n+ returnKeyType='go'\n+ blurOnSubmit={false}\n+ onSubmitEditing={this.onSubmit}\n+ editable={this.props.loadingStatus !== \"loading\"}\n+ ref={this.confirmPasswordInputRef}\n+ />\n+ </View>\n+ <TouchableHighlight\n+ onPress={this.onSubmit}\n+ style={styles.submitButton}\n+ underlayColor=\"#A0A0A0DD\"\n+ >\n+ <View style={styles.submitContentContainer}>\n+ <Text style={styles.submitContentText}>SIGN UP</Text>\n+ {buttonIcon}\n+ </View>\n+ </TouchableHighlight>\n+ </View>\n+ );\n+ }\n+\n+ usernameInputRef = (usernameInput: ?TextInput) => {\n+ this.usernameInput = usernameInput;\n+ }\n+\n+ emailInputRef = (emailInput: ?TextInput) => {\n+ this.emailInput = emailInput;\n+ }\n+\n+ passwordInputRef = (passwordInput: ?TextInput) => {\n+ this.passwordInput = passwordInput;\n+ }\n+\n+ confirmPasswordInputRef = (confirmPasswordInput: ?TextInput) => {\n+ this.confirmPasswordInput = confirmPasswordInput;\n+ }\n+\n+ focusEmailInput = () => {\n+ invariant(this.emailInput, \"ref should be set\");\n+ this.emailInput.focus();\n+ }\n+\n+ focusPasswordInput = () => {\n+ invariant(this.passwordInput, \"ref should be set\");\n+ this.passwordInput.focus();\n+ }\n+\n+ focusConfirmPasswordInput = () => {\n+ invariant(this.confirmPasswordInput, \"ref should be set\");\n+ this.confirmPasswordInput.focus();\n+ }\n+\n+ onChangeUsernameInputText = (text: string) => {\n+ this.setState({ usernameInputText: text });\n+ }\n+\n+ onChangeEmailInputText = (text: string) => {\n+ this.setState({ emailInputText: text });\n+ }\n+\n+ onChangePasswordInputText = (text: string) => {\n+ this.setState({ passwordInputText: text });\n+ }\n+\n+ onChangeConfirmPasswordInputText = (text: string) => {\n+ this.setState({ confirmPasswordInputText: text });\n+ }\n+\n+ onSubmit = () => {\n+ Keyboard.dismiss();\n+ this.props.dispatchActionPromise(registerActionType, this.registerAction());\n+ }\n+\n+ async registerAction() {\n+ try {\n+ await sleep(500);\n+ const result = await this.props.register(\n+ this.state.usernameInputText,\n+ this.state.emailInputText,\n+ this.state.passwordInputText,\n+ );\n+ this.props.navigateToApp();\n+ return result;\n+ } catch (e) {\n+ throw e;\n+ }\n+ }\n+\n+}\n+\n+const styles = StyleSheet.create({\n+ container: {\n+ paddingBottom: Platform.OS === 'ios' ? 37 : 36,\n+ paddingTop: 6,\n+ paddingLeft: 18,\n+ paddingRight: 18,\n+ marginLeft: 20,\n+ marginRight: 20,\n+ marginTop: 40,\n+ borderRadius: 6,\n+ backgroundColor: '#FFFFFFAA',\n+ zIndex: 2,\n+ },\n+ input: {\n+ paddingLeft: 35,\n+ },\n+ icon: {\n+ position: 'absolute',\n+ bottom: 8,\n+ left: 4,\n+ },\n+ envelopeIcon: {\n+ left: 3,\n+ bottom: 10,\n+ },\n+ submitButton: {\n+ position: 'absolute',\n+ bottom: 0,\n+ right: 0,\n+ borderBottomRightRadius: 6,\n+ },\n+ submitContentContainer: {\n+ flexDirection: 'row',\n+ alignItems: 'flex-end',\n+ paddingLeft: 18,\n+ paddingTop: 6,\n+ paddingRight: 18,\n+ paddingBottom: 6,\n+ },\n+ submitContentText: {\n+ fontSize: 18,\n+ fontFamily: 'OpenSans-Semibold',\n+ color: \"#555\",\n+ paddingRight: 7,\n+ },\n+ submitContentIconContainer: {\n+ width: 14,\n+ paddingBottom: 5,\n+ },\n+ loadingIndicatorContainer: {\n+ width: 14,\n+ paddingBottom: 2,\n+ },\n+});\n+\n+const registerServerCallSelector = createBoundServerCallSelector(register);\n+const loadingStatusSelector = createLoadingStatusSelector(registerActionType);\n+\n+export default connect(\n+ (state: AppState) => ({\n+ loadingStatus: loadingStatusSelector(state),\n+ register: registerServerCallSelector(state),\n+ }),\n+ includeDispatchActionProps({ dispatchActionPromise: true }),\n+)(RegisterPanel);\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/connected-status-bar.react.js",
"diff": "+// @flow\n+\n+import type { AppState } from './redux-setup';\n+import type { LoadingStatus } from 'lib/types/loading-types';\n+\n+import React from 'react';\n+import { connect } from 'react-redux';\n+import { StatusBar } from 'react-native';\n+\n+import { globalLoadingStatusSelector } from 'lib/selectors/loading-selectors';\n+\n+class ConnectedStatusBar extends React.PureComponent {\n+\n+ props: Object;\n+ static propTypes = {\n+ globalLoadingStatus: React.PropTypes.string.isRequired,\n+ };\n+\n+ render() {\n+ const fetchingSomething = this.props.globalLoadingStatus === \"loading\";\n+ return (\n+ <StatusBar\n+ {...this.props}\n+ networkActivityIndicatorVisible={fetchingSomething}\n+ />\n+ );\n+ }\n+\n+}\n+\n+export default connect((state: AppState) => ({\n+ globalLoadingStatus: globalLoadingStatusSelector(state),\n+}))(ConnectedStatusBar);\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/modal-components.react.js",
"diff": "+// @flow\n+\n+import React from 'react';\n+import {\n+ TextInput as BaseTextInput,\n+ View,\n+ StyleSheet,\n+ Platform,\n+} from 'react-native';\n+import invariant from 'invariant';\n+\n+class TextInput extends React.PureComponent {\n+\n+ props: Object;\n+ innerTextInput: ?BaseTextInput;\n+\n+ render() {\n+ const style = [styles.textInput, this.props.style];\n+ return (\n+ <View style={styles.textInputWrapperView}>\n+ <BaseTextInput\n+ underlineColorAndroid=\"transparent\"\n+ placeholderTextColor=\"#888888\"\n+ {...this.props}\n+ style={style}\n+ ref={this.innerTextInputRef}\n+ />\n+ </View>\n+ );\n+ }\n+\n+ innerTextInputRef = (innerTextInput: ?BaseTextInput) => {\n+ this.innerTextInput = innerTextInput;\n+ }\n+\n+ focus() {\n+ invariant(this.innerTextInput, \"ref should exist\");\n+ this.innerTextInput.focus();\n+ }\n+\n+}\n+\n+const styles = StyleSheet.create({\n+ textInputWrapperView: {\n+ borderBottomWidth: 1,\n+ borderBottomColor: '#BBBBBB',\n+ },\n+ textInput: {\n+ height: 40,\n+ fontSize: 20,\n+ padding: 0,\n+ margin: 0,\n+ },\n+});\n+\n+export {\n+ TextInput,\n+};\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Progress on log in/register on mobile |
129,187 | 08.03.2017 19:20:39 | 21,600 | 99146b29cf9f587736d06ec97659483987bcde1f | Small hack for cookies in Android local development | [
{
"change_type": "MODIFY",
"old_path": "server/auth.php",
"new_path": "server/auth.php",
"diff": "@@ -209,8 +209,16 @@ function delete_cookie($name) {\nfunction set_cookie($name, $value, $expiration_time) {\nglobal $base_url, $base_domain, $https;\n+ if (DEV && $_SERVER['HTTP_HOST'] == '10.0.2.2') {\n+ // Since Android for local development runs on an emulator (as opposed to a\n+ // simulator), it can't access the local server via localhost. Instead,\n+ // there's a magic IP (10.0.2.2) that forwards to the local server. We need\n+ // to set the hostname on the cookie correspondingly so Android keeps it.\n+ $domain = \"10.0.2.2\";\n+ } else {\n$domain = parse_url($base_domain, PHP_URL_HOST);\n$domain = preg_replace(\"/^www\\.(.*)/\", \"$1\", $domain);\n+ }\nsetcookie(\n$name,\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Small hack for cookies in Android local development |
129,187 | 15.03.2017 11:34:18 | 14,400 | d8fa16fac417844a979d4d8ecf70eff01f980903 | Uhhhhhh intermediate commit? Mostly action-utils updates | [
{
"change_type": "MODIFY",
"old_path": "lib/package.json",
"new_path": "lib/package.json",
"diff": "\"react\": \"^15.4.2\",\n\"redux\": \"^3.6.0\",\n\"reselect\": \"^2.5.4\",\n+ \"set-cookie-parser\": \"^2.0.0\",\n\"tokenize-text\": \"^1.1.3\",\n\"whatwg-fetch\": \"^2.0.2\"\n}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "lib/reducers/cookie-reducer.js",
"diff": "+// @flow\n+\n+import type {\n+ BaseAppState,\n+ BaseAction,\n+} from '../types/redux-types';\n+\n+export default function reduceCookie<T: BaseAppState>(\n+ state: ?string,\n+ action: BaseAction<T>,\n+) {\n+ // If the cookie is undefined, that means we're deferring to the environment\n+ // to handle cookies. See comment in fetch-json.js.\n+ if (state === undefined) {\n+ return state;\n+ }\n+ if (\n+ action.type === \"LOG_OUT_SUCCESS\" ||\n+ action.type === \"DELETE_ACCOUNT_SUCCESS\"\n+ ) {\n+ return null;\n+ } else if (action.type === \"SET_COOKIE\") {\n+ return action.payload;\n+ }\n+ return state;\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/reducers/master-reducer.js",
"new_path": "lib/reducers/master-reducer.js",
"diff": "@@ -7,6 +7,7 @@ import { reduceEntryInfos } from './entry-reducer';\nimport reduceUserInfo from './user-reducer';\nimport reduceCalendarInfos from './calendar-reducer';\nimport reduceBaseNavInfo from './nav-reducer';\n+import reduceCookie from './cookie-reducer';\nexport default function baseReducer<T: BaseAppState>(\nstate: T,\n@@ -31,6 +32,7 @@ export default function baseReducer<T: BaseAppState>(\nloadingStatuses: reduceLoadingStatuses(state.loadingStatuses, action),\nuserInfo: reduceUserInfo(state.userInfo, action),\ncalendarInfos: reduceCalendarInfos(state.calendarInfos, action),\n+ cookie: reduceCookie(state.cookie, action),\n};\nreturn test;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/types/redux-types.js",
"new_path": "lib/types/redux-types.js",
"diff": "@@ -278,6 +278,9 @@ export type BaseAction<T: BaseAppState> =\nnewSubscribed: bool,\n},\nloadingInfo: LoadingInfo,\n+ } | {\n+ type: \"SET_COOKIE\",\n+ payload: ?string,\n};\ntype ThunkedAction<T: BaseAppState, A> = (dispatch: Dispatch<T, A>) => void;\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/utils/action-utils.js",
"new_path": "lib/utils/action-utils.js",
"diff": "@@ -4,7 +4,7 @@ import type { Dispatch, BaseAppState } from '../types/redux-types';\nimport type { LoadingOptions, LoadingInfo } from '../types/loading-types';\nimport type { FetchJSON } from './fetch-json';\n-import { createSelector } from 'reselect';\n+import _mapValues from 'lodash/fp/mapValues';\nimport fetchJSON from './fetch-json';\n@@ -68,48 +68,40 @@ type DispatchActionHelperProps = {\ndispatchActionPayload?: bool,\ndispatchActionPromise?: bool,\n};\n+type BoundActions<T: BaseAppState, A> = {\n+ dispatch: Dispatch<T, A>,\n+ dispatchActionPayload?: DispatchActionPayload,\n+ dispatchActionPromise?: DispatchActionPromise,\n+};\nfunction includeDispatchActionProps<T: BaseAppState, A, P>(\nwhichOnes: DispatchActionHelperProps,\n-) {\n+): (dispatch: Dispatch<T, A>) => BoundActions<T, A> {\nreturn (dispatch: Dispatch<T, A>) => {\n- if (whichOnes.dispatchActionPromise && whichOnes.dispatchActionPayload) {\n- return {\n- dispatchActionPayload: (actionType: string, payload: P) =>\n- dispatch({ type: actionType, payload }),\n- dispatchActionPromise: (\n+ const boundActions: BoundActions<T, A> = { dispatch };\n+ if (whichOnes.dispatchActionPromise) {\n+ boundActions.dispatchActionPromise =\n+ (\nactionType: string,\npromise: Promise<P>,\nloadingOptions?: LoadingOptions,\nstartingPayload?: any,\n+ // Redux middleware can actually change dispatch's return type, and\n+ // redux-thunk does this. However, the Redux flow-typed config does not\n+ // consider this. We silence this error here to get around it.\n+ // $FlowFixMe\n) => dispatch(wrapActionPromise(\nactionType,\npromise,\nloadingOptions,\nstartingPayload,\n- )),\n- };\n- } else if (whichOnes.dispatchActionPayload) {\n- return {\n- dispatchActionPayload: (actionType: string, payload: P) =>\n- dispatch({ type: actionType, payload }),\n- };\n- } else if (whichOnes.dispatchActionPromise) {\n- return {\n- dispatchActionPromise: (\n- actionType: string,\n- promise: Promise<P>,\n- loadingOptions?: LoadingOptions,\n- startingPayload?: any,\n- ) => dispatch(wrapActionPromise(\n- actionType,\n- promise,\n- loadingOptions,\n- startingPayload,\n- )),\n- };\n- } else {\n- return {};\n+ ));\n+ }\n+ if (whichOnes.dispatchActionPayload) {\n+ boundActions.dispatchActionPayload =\n+ (actionType: string, payload: P) =>\n+ dispatch({ type: actionType, payload });\n}\n+ return boundActions;\n};\n}\n@@ -121,29 +113,52 @@ function includeDispatchActionProps<T: BaseAppState, A, P>(\n// onto fetchJSON within react-redux's connect's mapStateToProps function, and\n// then pass that \"bound\" fetchJSON that no longer needs the cookie as a\n// parameter on to the server call.\n-function bindServerCall<B>(\n+function bindCookieAndUtilsIntoServerCall<T: BaseAppState, A, B>(\nactionFunc: (fetchJSON: FetchJSON, ...rest: any) => Promise<B>,\n+ dispatch: Dispatch<T, A>,\ncookie: ?string,\n-): ((...rest: any) => Promise<B>) {\n+) {\n+ const setCookie = (newCookie: ?string) => {\n+ if (newCookie !== cookie) {\n+ dispatch({ type: \"SET_COOKIE\", payload: newCookie });\n+ }\n+ };\nconst boundFetchJSON = (async (url: string, data: Object) => {\n- return await fetchJSON(cookie, url, data);\n+ return await fetchJSON(cookie, setCookie, url, data);\n});\nreturn (async (...rest: any) => {\nreturn await actionFunc(boundFetchJSON, ...rest);\n});\n}\n-// A memoized version of the above function, to make sure we don't trigger a\n-// React update unless the cookie actually changes\n-const createBoundServerCallSelector = <B>(\n- actionFunc: (fetchJSON: FetchJSON, ...rest: any) => Promise<B>,\n-) => createSelector(\n- (state: BaseAppState) => state.cookie,\n- (cookie: ?string): ((...rest: any) => Promise<B>) =>\n- bindServerCall(actionFunc, cookie),\n-);\n+function bindServerCalls<T: BaseAppState, A>(\n+ serverCalls:\n+ {[name: string]: (fetchJSON: FetchJSON, ...rest: any) => Promise<any>},\n+) {\n+ return (\n+ stateProps: { cookie: ?string },\n+ dispatchProps: { dispatch: Dispatch<T, A> },\n+ ownProps: {[propName: string]: mixed},\n+ ) => {\n+ const { cookie, ...restStateProps } = stateProps;\n+ const boundServerCalls = _mapValues(\n+ (serverCall: (fetchJSON: FetchJSON, ...rest: any) => Promise<any>) =>\n+ bindCookieAndUtilsIntoServerCall(\n+ serverCall,\n+ dispatchProps.dispatch,\n+ cookie,\n+ ),\n+ )(serverCalls);\n+ return {\n+ ...ownProps,\n+ ...restStateProps,\n+ ...dispatchProps,\n+ ...boundServerCalls,\n+ };\n+ };\n+}\nexport {\nincludeDispatchActionProps,\n- createBoundServerCallSelector,\n+ bindServerCalls,\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/utils/fetch-json.js",
"new_path": "lib/utils/fetch-json.js",
"diff": "// @flow\nimport $param from 'jquery-param';\n+import setCookie from 'set-cookie-parser';\n+import invariant from 'invariant';\n+import _map from 'lodash/fp/map';\n+import _find from 'lodash/fp/find';\n+import _filter from 'lodash/fp/filter';\nimport { ServerError } from './fetch-utils';\nimport { getConfig } from './config';\n+function parseSetCookieHeader(setCookieHeader: string) {\n+ // We can't simply split by commas, because the \"expires\" clause can have a\n+ // comma in it. We can't simply split by semicolons, since then two clauses\n+ // from different cookies will appear as one. We can't simply split by equals\n+ // signs because some clauses (httponly) don't have them. And there isn't a\n+ // single npm package out there that can handle all of these things without\n+ // relying on Node.js. What has the world come to?\n+ const parts = setCookieHeader.split(/(anonymous)|(user)/).filter(a => a);\n+ invariant(parts.length % 2 === 0, \"should be even\");\n+ const cookieMap = {};\n+ for (let i = 0; i < parts.length; i += 2) {\n+ cookieMap[parts[i]] = parts[i + 1];\n+ }\n+ const individualCookieClauses =\n+ _map.convert({ cap: false })((value, key) => key + value)(cookieMap);\n+ return setCookie.parse(individualCookieClauses);\n+}\n+\n+// TODO update all createBoundServerCallSelector to bindServerCalls\n+// TODO make sure no errors occur on web and cookie isn't set\n+// TODO do we always want to send credentials: same-origin?\n+// TODO try to type bindServerCalls a bit better (TupleMap?)\n+// TODO actually trigger a LOG_OUT action when log out is clicked in native\n+// TODO make sure no cookie headers are actually set when cookie = null\n+\n+// If cookie is undefined, then we will defer to the underlying environment to\n+// handle cookies, and we won't worry about them. We do this on the web since\n+// our cookies are httponly to protect against XSS attacks. On the other hand,\n+// on native we want to keep track of the cookies since we don't trust the\n+// underlying implementations and prefer for things to be explicit, and XSS\n+// isn't a thing on native. Note that for native, cookie might be null\n+// (indicating we don't have one), and we will then set an empty Cookie header.\nasync function fetchJSON(\ncookie: ?string,\n+ setCookieCallback: (newCookie: ?string) => void,\nurl: string,\ndata: {[key: string]: mixed},\n) {\nurl = getConfig().urlPrefix + url;\n+ const headers: {[name: string]: string} = {\n+ 'Accept': 'application/json',\n+ 'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',\n+ };\n+ if (cookie !== undefined) {\n+ headers['Cookie'] = cookie ? cookie : \"\";\n+ }\nconst response = await fetch(url, {\n// Flow gets confused by some enum type, so we need this cast\n'method': ('POST': MethodType),\n// This is necessary to allow cookie headers to get passed down to us\n'credentials': 'same-origin',\n- 'headers': {\n- 'Accept': 'application/json',\n- 'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',\n- },\n'body': $param(data),\n+ headers,\n});\n+\n+ const setCookieHeader = response.headers.get('Set-Cookie');\n+ if (setCookieHeader) {\n+ const cookies = parseSetCookieHeader(setCookieHeader);\n+ const now = new Date();\n+ const activeCookies = _filter((cookie) => cookie.expires > now)(cookies);\n+ const userCookie = _find(['name', 'user'])(activeCookies);\n+ if (userCookie) {\n+ setCookieCallback(\"user=\" + userCookie.value);\n+ } else {\n+ const anonymousCookie = _find(['name', 'anonymous'])(activeCookies);\n+ if (anonymousCookie) {\n+ setCookieCallback(\"anonymous=\" + anonymousCookie.value);\n+ }\n+ }\n+ }\n+\nconst json = await response.json();\nconsole.log(json);\nif (json.error) {\n"
},
{
"change_type": "MODIFY",
"old_path": "native/.gitignore",
"new_path": "native/.gitignore",
"diff": "@@ -28,7 +28,8 @@ local.properties\n# node.js\n#\n-node_modules/\n+node_modules/*\n+!node_modules/lib\nnpm-debug.log\nyarn-error.log\n"
},
{
"change_type": "MODIFY",
"old_path": "native/account/log-in-panel.react.js",
"new_path": "native/account/log-in-panel.react.js",
"diff": "@@ -26,7 +26,7 @@ import {\n} from 'lib/shared/account-regexes';\nimport {\nincludeDispatchActionProps,\n- createBoundServerCallSelector,\n+ bindServerCalls,\n} from 'lib/utils/action-utils';\nimport { logInActionType, logIn } from 'lib/actions/user-actions';\nimport { createLoadingStatusSelector } from 'lib/selectors/loading-selectors';\n@@ -313,14 +313,13 @@ const styles = StyleSheet.create({\n},\n});\n-const logInServerCallSelector = createBoundServerCallSelector(logIn);\nconst loadingStatusSelector = createLoadingStatusSelector(logInActionType);\nexport default connect(\n(state: AppState) => ({\n+ cookie: state.cookie,\nloadingStatus: loadingStatusSelector(state),\n- logIn: logInServerCallSelector(state),\n}),\nincludeDispatchActionProps({ dispatchActionPromise: true }),\n+ bindServerCalls({ logIn }),\n)(LogInPanel);\n-\n"
},
{
"change_type": "MODIFY",
"old_path": "native/account/register-panel.react.js",
"new_path": "native/account/register-panel.react.js",
"diff": "@@ -21,7 +21,7 @@ import invariant from 'invariant';\nimport {\nincludeDispatchActionProps,\n- createBoundServerCallSelector,\n+ bindServerCalls,\n} from 'lib/utils/action-utils';\nimport { registerActionType, register } from 'lib/actions/user-actions';\nimport { createLoadingStatusSelector } from 'lib/selectors/loading-selectors';\n@@ -294,13 +294,13 @@ const styles = StyleSheet.create({\n},\n});\n-const registerServerCallSelector = createBoundServerCallSelector(register);\nconst loadingStatusSelector = createLoadingStatusSelector(registerActionType);\nexport default connect(\n(state: AppState) => ({\n+ cookie: state.cookie,\nloadingStatus: loadingStatusSelector(state),\n- register: registerServerCallSelector(state),\n}),\nincludeDispatchActionProps({ dispatchActionPromise: true }),\n+ bindServerCalls({ register }),\n)(RegisterPanel);\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/node_modules/lib",
"diff": "+../../lib/\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "native/redux-setup.js",
"new_path": "native/redux-setup.js",
"diff": "@@ -62,7 +62,7 @@ export const defaultState = ({\ndaysToEntries: {},\ncalendarInfos: {},\nloadingStatuses: {},\n- cookie: \"\",\n+ cookie: null,\n}: AppState);\nexport function reducer(state: AppState, action: Action) {\n"
},
{
"change_type": "MODIFY",
"old_path": "web/script.js",
"new_path": "web/script.js",
"diff": "@@ -72,7 +72,7 @@ const store: Store<AppState, Action> = createStore(\ndaysToEntries,\ncalendarInfos: calendar_infos,\nloadingStatuses: {},\n- cookie: null,\n+ cookie: undefined,\n}: AppState),\ncomposeWithDevTools({})(applyMiddleware(thunk)),\n);\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Uhhhhhh intermediate commit? Mostly action-utils updates |
129,187 | 15.03.2017 13:54:20 | 14,400 | 1e32317d0d1297e24eb06a46b107da1cac59d552 | More stuff!!!!!! | [
{
"change_type": "MODIFY",
"old_path": "lib/reducers/cookie-reducer.js",
"new_path": "lib/reducers/cookie-reducer.js",
"diff": "@@ -11,12 +11,7 @@ export default function reduceCookie(state: ?string, action: BaseAction) {\nif (state === undefined) {\nreturn state;\n}\n- if (\n- action.type === \"LOG_OUT_SUCCESS\" ||\n- action.type === \"DELETE_ACCOUNT_SUCCESS\"\n- ) {\n- return null;\n- } else if (action.type === \"SET_COOKIE\") {\n+ if (action.type === \"SET_COOKIE\") {\nreturn action.payload;\n}\nreturn state;\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/utils/fetch-json.js",
"new_path": "lib/utils/fetch-json.js",
"diff": "@@ -28,12 +28,8 @@ function parseSetCookieHeader(setCookieHeader: string) {\nreturn setCookie.parse(individualCookieClauses);\n}\n-// TODO update all createBoundServerCallSelector to bindServerCalls\n-// TODO make sure no errors occur on web and cookie isn't set\n-// TODO do we always want to send credentials: same-origin?\n-// TODO try to type bindServerCalls a bit better (TupleMap?)\n-// TODO actually trigger a LOG_OUT action when log out is clicked in native\n// TODO make sure no cookie headers are actually set when cookie = null\n+// TODO actually trigger a LOG_OUT action when log out is clicked on native\n// If cookie is undefined, then we will defer to the underlying environment to\n// handle cookies, and we won't worry about them. We do this on the web since\n@@ -54,7 +50,7 @@ async function fetchJSON(\n'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',\n};\nif (cookie !== undefined) {\n- headers['Cookie'] = cookie ? cookie : \"\";\n+ headers['Cookie'] = cookie;\n}\nconst response = await fetch(url, {\n// Flow gets confused by some enum type, so we need this cast\n"
},
{
"change_type": "MODIFY",
"old_path": "native/account/log-in-panel.react.js",
"new_path": "native/account/log-in-panel.react.js",
"diff": "@@ -30,7 +30,6 @@ import {\n} from 'lib/utils/action-utils';\nimport { logInActionType, logIn } from 'lib/actions/user-actions';\nimport { createLoadingStatusSelector } from 'lib/selectors/loading-selectors';\n-import sleep from 'lib/utils/sleep';\nimport { TextInput } from '../modal-components.react';\n@@ -183,7 +182,6 @@ class LogInPanel extends React.PureComponent {\nasync logInAction() {\ntry {\n- await sleep(500);\nconst result = await this.props.logIn(\nthis.state.usernameOrEmailInputText,\nthis.state.passwordInputText,\n"
},
{
"change_type": "MODIFY",
"old_path": "native/account/register-panel.react.js",
"new_path": "native/account/register-panel.react.js",
"diff": "@@ -25,7 +25,6 @@ import {\n} from 'lib/utils/action-utils';\nimport { registerActionType, register } from 'lib/actions/user-actions';\nimport { createLoadingStatusSelector } from 'lib/selectors/loading-selectors';\n-import sleep from 'lib/utils/sleep';\nimport { TextInput } from '../modal-components.react';\n@@ -224,7 +223,6 @@ class RegisterPanel extends React.PureComponent {\nasync registerAction() {\ntry {\n- await sleep(500);\nconst result = await this.props.register(\nthis.state.usernameInputText,\nthis.state.emailInputText,\n"
},
{
"change_type": "MODIFY",
"old_path": "native/more/more.react.js",
"new_path": "native/more/more.react.js",
"diff": "// @flow\nimport type { NavigationScreenProp } from 'react-navigation';\n+import type { DispatchActionPromise } from 'lib/utils/action-utils';\n+import type { AppState } from '../redux-setup';\n+import type { CalendarInfo } from 'lib/types/calendar-types';\nimport React from 'react';\nimport { View, StyleSheet, Text, Button } from 'react-native';\nimport Icon from 'react-native-vector-icons/FontAwesome';\n+import { connect } from 'react-redux';\n+\n+import { registerFetchKey } from 'lib/reducers/loading-reducer';\n+import {\n+ includeDispatchActionProps,\n+ bindServerCalls,\n+} from 'lib/utils/action-utils';\n+import { logOutActionType, logOut } from 'lib/actions/user-actions';\n+\n+import ConnectedStatusBar from '../connected-status-bar.react';\nclass More extends React.PureComponent {\nprops: {\nnavigation: NavigationScreenProp<*, *>,\n+ // Redux state\n+ // Redux dispatch functions\n+ dispatchActionPromise: DispatchActionPromise,\n+ // async functions that hit server APIs\n+ logOut: () => Promise<CalendarInfo[]>,\n};\nstate: {};\n@@ -17,6 +35,8 @@ class More extends React.PureComponent {\nnavigation: React.PropTypes.shape({\nnavigate: React.PropTypes.func.isRequired,\n}).isRequired,\n+ dispatchActionPromise: React.PropTypes.func.isRequired,\n+ logOut: React.PropTypes.func.isRequired,\n};\nstatic navigationOptions = {\n@@ -42,11 +62,17 @@ class More extends React.PureComponent {\nonPress={this.onPress}\ntitle=\"Log out\"\n/>\n+ <ConnectedStatusBar />\n</View>\n);\n}\nonPress = () => {\n+ this.props.dispatchActionPromise(logOutActionType, this.logOutAction());\n+ }\n+\n+ async logOutAction() {\n+ await this.props.logOut();\nthis.props.navigation.navigate('LoggedOutModal');\n}\n@@ -69,4 +95,12 @@ const styles = StyleSheet.create({\n},\n});\n-export default More;\n+registerFetchKey(logOutActionType);\n+\n+export default connect(\n+ (state: AppState) => ({\n+ cookie: state.cookie,\n+ }),\n+ includeDispatchActionProps({ dispatchActionPromise: true }),\n+ bindServerCalls({ logOut }),\n+)(More);\n"
},
{
"change_type": "MODIFY",
"old_path": "server/forgot_password.php",
"new_path": "server/forgot_password.php",
"diff": "@@ -13,11 +13,8 @@ if ($https && !isset($_SERVER['HTTPS'])) {\n)));\n}\n-if (user_logged_in()) {\n- exit(json_encode(array(\n- 'error' => 'already_logged_in',\n- )));\n-}\n+get_viewer_info();\n+\nif (!isset($_POST['username'])) {\nexit(json_encode(array(\n'error' => 'invalid_parameters',\n"
},
{
"change_type": "MODIFY",
"old_path": "server/login.php",
"new_path": "server/login.php",
"diff": "@@ -13,11 +13,8 @@ if ($https && !isset($_SERVER['HTTPS'])) {\n)));\n}\n-if (user_logged_in()) {\n- exit(json_encode(array(\n- 'error' => 'already_logged_in',\n- )));\n-}\n+get_viewer_info();\n+\nif (!isset($_POST['username']) || !isset($_POST['password'])) {\nexit(json_encode(array(\n'error' => 'invalid_parameters',\n"
},
{
"change_type": "MODIFY",
"old_path": "server/register.php",
"new_path": "server/register.php",
"diff": "@@ -13,11 +13,8 @@ if ($https && !isset($_SERVER['HTTPS'])) {\n)));\n}\n-if (user_logged_in()) {\n- exit(json_encode(array(\n- 'error' => 'already_logged_in',\n- )));\n-}\n+get_viewer_info();\n+\nif (\n!isset($_POST['username']) ||\n!isset($_POST['email']) ||\n"
},
{
"change_type": "MODIFY",
"old_path": "server/reset_password.php",
"new_path": "server/reset_password.php",
"diff": "@@ -14,11 +14,7 @@ if ($https && !isset($_SERVER['HTTPS'])) {\n)));\n}\n-if (user_logged_in()) {\n- exit(json_encode(array(\n- 'error' => 'already_logged_in',\n- )));\n-}\n+get_viewer_info();\nif (!isset($_POST['password']) || !isset($_POST['code'])) {\nexit(json_encode(array(\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | More stuff!!!!!! |
129,187 | 19.03.2017 20:10:51 | 14,400 | 36bf927e1f08c4b612606e79e56464729ad1c437 | Uhhhhh why is React Native doing this???? | [
{
"change_type": "MODIFY",
"old_path": "native/account/log-in-panel.react.js",
"new_path": "native/account/log-in-panel.react.js",
"diff": "@@ -37,6 +37,7 @@ class LogInPanel extends React.PureComponent {\nprops: {\nnavigateToApp: () => void,\n+ setActiveAlert: (activeAlert: bool) => void,\n// Redux state\nloadingStatus: LoadingStatus,\n// Redux dispatch functions\n@@ -49,6 +50,7 @@ class LogInPanel extends React.PureComponent {\n};\nstatic propTypes = {\nnavigateToApp: React.PropTypes.func.isRequired,\n+ setActiveAlert: React.PropTypes.func.isRequired,\nloadingStatus: React.PropTypes.string.isRequired,\ndispatchActionPromise: React.PropTypes.func.isRequired,\nlogIn: React.PropTypes.func.isRequired,\n@@ -153,6 +155,7 @@ class LogInPanel extends React.PureComponent {\nthis.state.usernameOrEmailInputText.search(validUsernameRegex) === -1 &&\nthis.state.usernameOrEmailInputText.search(validEmailRegex) === -1\n) {\n+ this.props.setActiveAlert(true);\nAlert.alert(\n\"Invalid username\",\n\"Alphanumeric usernames or emails only\",\n@@ -169,6 +172,7 @@ class LogInPanel extends React.PureComponent {\n}\nonUsernameOrEmailAlertAcknowledged = () => {\n+ this.props.setActiveAlert(false);\nthis.setState(\n{\nusernameOrEmailInputText: \"\",\n@@ -189,6 +193,7 @@ class LogInPanel extends React.PureComponent {\nthis.props.navigateToApp();\nreturn result;\n} catch (e) {\n+ this.props.setActiveAlert(true);\nif (e.message === 'invalid_parameters') {\nAlert.alert(\n\"Invalid username\",\n@@ -222,6 +227,7 @@ class LogInPanel extends React.PureComponent {\n}\nonPasswordAlertAcknowledged = () => {\n+ this.props.setActiveAlert(false);\nthis.setState(\n{\npasswordInputText: \"\",\n@@ -234,6 +240,7 @@ class LogInPanel extends React.PureComponent {\n}\nonUnknownErrorAlertAcknowledged = () => {\n+ this.props.setActiveAlert(false);\nthis.setState(\n{\nusernameOrEmailInputText: \"\",\n"
},
{
"change_type": "MODIFY",
"old_path": "native/account/logged-out-modal.react.js",
"new_path": "native/account/logged-out-modal.react.js",
"diff": "@@ -14,6 +14,8 @@ import {\nEmitterSubscription,\nKeyboard,\nAlert,\n+ Platform,\n+ Dimensions,\n} from 'react-native';\nimport invariant from 'invariant';\n@@ -30,21 +32,20 @@ type KeyboardEvent = {\nscreenY: number,\n},\n};\n-\n-class LoggedOutModal extends React.PureComponent {\n-\n- props: {\n+type LoggedOutMode = \"prompt\" | \"log-in\" | \"register\";\n+type Props = {\nnavigation: NavigationScreenProp<*, *>,\n};\n-\n- state: {\n- mode: \"prompt\" | \"log-in\" | \"register\",\n+type State = {\n+ mode: LoggedOutMode,\n+ activeAlert: bool,\npaddingTop: Animated.Value,\n- } = {\n- mode: \"prompt\",\n- paddingTop: new Animated.Value(250),\n};\n+class LoggedOutModal extends React.PureComponent {\n+\n+ props: Props;\n+ state: State;\nstatic propTypes = {\nnavigation: React.PropTypes.shape({\nnavigate: React.PropTypes.func.isRequired,\n@@ -57,57 +58,107 @@ class LoggedOutModal extends React.PureComponent {\n},\n};\n- keyboardDidShowListener: ?EmitterSubscription;\n- keyboardDidHideListener: ?EmitterSubscription;\n+ keyboardShowListener: ?EmitterSubscription;\n+ keyboardHideListener: ?EmitterSubscription;\n+\n+ constructor(props: Props) {\n+ super(props);\n+ this.state = {\n+ mode: \"prompt\",\n+ activeAlert: false,\n+ paddingTop: new Animated.Value(\n+ LoggedOutModal.currentPaddingTop(\"prompt\", 0),\n+ ),\n+ };\n+ }\ncomponentWillMount() {\n- this.keyboardDidShowListener = Keyboard.addListener(\n- 'keyboardWillShow',\n- this.keyboardDidShow,\n+ this.keyboardShowListener = Keyboard.addListener(\n+ Platform.OS === \"ios\" ? \"keyboardWillShow\" : \"keyboardDidShow\",\n+ this.keyboardShow,\n);\n- this.keyboardDidHideListener = Keyboard.addListener(\n- 'keyboardWillHide',\n- this.keyboardDidHide,\n+ this.keyboardHideListener = Keyboard.addListener(\n+ Platform.OS === \"ios\" ? \"keyboardWillHide\" : \"keyboardDidHide\",\n+ this.keyboardHide,\n);\n}\ncomponentWillUnmount() {\n- invariant(this.keyboardDidShowListener, \"should be set\");\n- this.keyboardDidShowListener.remove();\n- invariant(this.keyboardDidHideListener, \"should be set\");\n- this.keyboardDidHideListener.remove();\n+ invariant(this.keyboardShowListener, \"should be set\");\n+ this.keyboardShowListener.remove();\n+ invariant(this.keyboardHideListener, \"should be set\");\n+ this.keyboardHideListener.remove();\n}\n- keyboardDidShow = (event: KeyboardEvent) => {\n+ static currentPaddingTop(\n+ mode: LoggedOutMode,\n+ keyboardHeight: number,\n+ ) {\n+ const { height } = Dimensions.get('window');\n+ const heightWithoutPadding = height - 90;\n+ let containerSize = Platform.OS === \"ios\" ? 62 : 59;\n+ if (mode === \"log-in\") {\n+ containerSize += 165;\n+ } else if (mode === \"register\") {\n+ containerSize += 246;\n+ }\n+ const test = (heightWithoutPadding - containerSize - keyboardHeight) / 2;\n+ console.log(test);\n+ return test;\n+ }\n+\n+ keyboardShow = (event: KeyboardEvent) => {\n+ const duration = event.duration ? event.duration : 250;\nAnimated.timing(\nthis.state.paddingTop,\n{\n- duration: event.duration,\n+ duration,\neasing: Easing.inOut(Easing.ease),\n- toValue: 250 - event.endCoordinates.height,\n+ toValue: LoggedOutModal.currentPaddingTop(\n+ this.state.mode,\n+ event.endCoordinates.height,\n+ ),\n},\n).start();\n}\n- keyboardDidHide = (event: KeyboardEvent) => {\n+ keyboardHide = (event: ?KeyboardEvent) => {\n+ if (this.state.activeAlert) {\n+ return;\n+ }\n+ const duration = (event && event.duration) ? event.duration : 250;\nAnimated.timing(\nthis.state.paddingTop,\n{\n- duration: event.duration,\n+ duration,\neasing: Easing.inOut(Easing.ease),\n- toValue: 250,\n+ toValue: LoggedOutModal.currentPaddingTop(this.state.mode, 0),\n},\n).start();\n}\n+ setActiveAlert = (activeAlert: bool) => {\n+ this.setState({ activeAlert });\n+ }\n+\nrender() {\nconst padding = { paddingTop: this.state.paddingTop };\nlet content = null;\nlet buttons = null;\nif (this.state.mode === \"log-in\") {\n- content = <LogInPanel navigateToApp={this.props.navigation.goBack} />;\n+ content = (\n+ <LogInPanel\n+ navigateToApp={this.props.navigation.goBack}\n+ setActiveAlert={this.setActiveAlert}\n+ />\n+ );\n} else if (this.state.mode === \"register\") {\n- content = <RegisterPanel navigateToApp={this.props.navigation.goBack} />;\n+ content = (\n+ <RegisterPanel\n+ navigateToApp={this.props.navigation.goBack}\n+ setActiveAlert={this.setActiveAlert}\n+ />\n+ );\n} else {\nbuttons = (\n<View style={styles.buttonContainer}>\n"
},
{
"change_type": "MODIFY",
"old_path": "native/account/register-panel.react.js",
"new_path": "native/account/register-panel.react.js",
"diff": "@@ -37,6 +37,7 @@ class RegisterPanel extends React.PureComponent {\nprops: {\nnavigateToApp: () => void,\n+ setActiveAlert: (activeAlert: bool) => void,\n// Redux state\nloadingStatus: LoadingStatus,\n// Redux dispatch functions\n@@ -50,6 +51,7 @@ class RegisterPanel extends React.PureComponent {\n};\nstatic propTypes = {\nnavigateToApp: React.PropTypes.func.isRequired,\n+ setActiveAlert: React.PropTypes.func.isRequired,\nloadingStatus: React.PropTypes.string.isRequired,\ndispatchActionPromise: React.PropTypes.func.isRequired,\nregister: React.PropTypes.func.isRequired,\n@@ -223,6 +225,7 @@ class RegisterPanel extends React.PureComponent {\nonSubmit = () => {\nif (this.state.passwordInputText === '') {\n+ this.props.setActiveAlert(true);\nAlert.alert(\n\"Empty password\",\n\"Password cannot be empty\",\n@@ -234,6 +237,7 @@ class RegisterPanel extends React.PureComponent {\n} else if (\nthis.state.passwordInputText !== this.state.confirmPasswordInputText\n) {\n+ this.props.setActiveAlert(true);\nAlert.alert(\n\"Passwords don't match\",\n\"Password fields must contain the same password\",\n@@ -243,6 +247,7 @@ class RegisterPanel extends React.PureComponent {\n{ cancelable: false },\n);\n} else if (this.state.usernameInputText.search(validUsernameRegex) === -1) {\n+ this.props.setActiveAlert(true);\nAlert.alert(\n\"Invalid username\",\n\"Alphanumeric usernames only\",\n@@ -252,6 +257,7 @@ class RegisterPanel extends React.PureComponent {\n{ cancelable: false },\n);\n} else if (this.state.emailInputText.search(validEmailRegex) === -1) {\n+ this.props.setActiveAlert(true);\nAlert.alert(\n\"Invalid email address\",\n\"Valid email addresses only\",\n@@ -270,6 +276,7 @@ class RegisterPanel extends React.PureComponent {\n}\nonPasswordAlertAcknowledged = () => {\n+ this.props.setActiveAlert(false);\nthis.setState(\n{\npasswordInputText: \"\",\n@@ -283,6 +290,7 @@ class RegisterPanel extends React.PureComponent {\n}\nonUsernameAlertAcknowledged = () => {\n+ this.props.setActiveAlert(false);\nthis.setState(\n{\nusernameInputText: \"\",\n@@ -316,6 +324,7 @@ class RegisterPanel extends React.PureComponent {\nthis.props.navigateToApp();\nreturn result;\n} catch (e) {\n+ this.props.setActiveAlert(true);\nif (e.message === 'username_taken') {\nAlert.alert(\n\"Username taken\",\n@@ -349,6 +358,7 @@ class RegisterPanel extends React.PureComponent {\n}\nonUnknownErrorAlertAcknowledged = () => {\n+ this.props.setActiveAlert(false);\nthis.setState(\n{\nusernameInputText: \"\",\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Uhhhhh why is React Native doing this???? |
129,187 | 20.03.2017 21:55:55 | 14,400 | 92af8dd96fb676d9e581325148e0aae75c8572c0 | omg logged out modal is mostly working sort of | [
{
"change_type": "MODIFY",
"old_path": "native/account/log-in-panel.react.js",
"new_path": "native/account/log-in-panel.react.js",
"diff": "@@ -15,6 +15,8 @@ import {\nActivityIndicator,\nAlert,\nKeyboard,\n+ Animated,\n+ TouchableNativeFeedback,\n} from 'react-native';\nimport Icon from 'react-native-vector-icons/FontAwesome';\nimport { connect } from 'react-redux';\n@@ -38,6 +40,7 @@ class LogInPanel extends React.PureComponent {\nprops: {\nnavigateToApp: () => void,\nsetActiveAlert: (activeAlert: bool) => void,\n+ opacityValue: Animated.Value,\n// Redux state\nloadingStatus: LoadingStatus,\n// Redux dispatch functions\n@@ -51,6 +54,7 @@ class LogInPanel extends React.PureComponent {\nstatic propTypes = {\nnavigateToApp: React.PropTypes.func.isRequired,\nsetActiveAlert: React.PropTypes.func.isRequired,\n+ opacityValue: React.PropTypes.object.isRequired,\nloadingStatus: React.PropTypes.string.isRequired,\ndispatchActionPromise: React.PropTypes.func.isRequired,\nlogIn: React.PropTypes.func.isRequired,\n@@ -80,8 +84,33 @@ class LogInPanel extends React.PureComponent {\n</View>\n);\n}\n+ let submitButton;\n+ if (Platform.OS === \"android\") {\n+ submitButton = (\n+ <TouchableNativeFeedback onPress={this.onSubmit}>\n+ <View style={[styles.submitContentContainer, styles.submitButton]}>\n+ <Text style={styles.submitContentText}>LOG IN</Text>\n+ {buttonIcon}\n+ </View>\n+ </TouchableNativeFeedback>\n+ );\n+ } else {\n+ submitButton = (\n+ <TouchableHighlight\n+ onPress={this.onSubmit}\n+ style={styles.submitButton}\n+ underlayColor=\"#A0A0A0DD\"\n+ >\n+ <View style={styles.submitContentContainer}>\n+ <Text style={styles.submitContentText}>LOG IN</Text>\n+ {buttonIcon}\n+ </View>\n+ </TouchableHighlight>\n+ );\n+ }\n+ const opacityStyle = { opacity: this.props.opacityValue };\nreturn (\n- <View style={styles.container}>\n+ <Animated.View style={[styles.container, opacityStyle]}>\n<View>\n<Icon name=\"user\" size={22} color=\"#777\" style={styles.icon} />\n<TextInput\n@@ -115,17 +144,8 @@ class LogInPanel extends React.PureComponent {\nref={this.passwordInputRef}\n/>\n</View>\n- <TouchableHighlight\n- onPress={this.onSubmit}\n- style={styles.submitButton}\n- underlayColor=\"#A0A0A0DD\"\n- >\n- <View style={styles.submitContentContainer}>\n- <Text style={styles.submitContentText}>LOG IN</Text>\n- {buttonIcon}\n- </View>\n- </TouchableHighlight>\n- </View>\n+ {submitButton}\n+ </Animated.View>\n);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "native/account/logged-out-modal.react.js",
"new_path": "native/account/logged-out-modal.react.js",
"diff": "@@ -16,8 +16,10 @@ import {\nAlert,\nPlatform,\nDimensions,\n+ BackAndroid,\n} from 'react-native';\nimport invariant from 'invariant';\n+import Icon from 'react-native-vector-icons/FontAwesome';\nimport LogInPanel from './log-in-panel.react';\nimport RegisterPanel from './register-panel.react';\n@@ -38,8 +40,8 @@ type Props = {\n};\ntype State = {\nmode: LoggedOutMode,\n- activeAlert: bool,\npaddingTop: Animated.Value,\n+ opacityValue: Animated.Value,\n};\nclass LoggedOutModal extends React.PureComponent {\n@@ -61,14 +63,22 @@ class LoggedOutModal extends React.PureComponent {\nkeyboardShowListener: ?EmitterSubscription;\nkeyboardHideListener: ?EmitterSubscription;\n+ opacityHitsZeroListenerID: number;\n+\n+ nextMode: LoggedOutMode = \"prompt\";\n+ activeAlert: bool = false;\n+ activeKeyboard: bool = false;\n+ opacityChangeQueued: bool = false;\n+ keyboardHeight: number = 0;\n+\nconstructor(props: Props) {\nsuper(props);\nthis.state = {\nmode: \"prompt\",\n- activeAlert: false,\npaddingTop: new Animated.Value(\nLoggedOutModal.currentPaddingTop(\"prompt\", 0),\n),\n+ opacityValue: new Animated.Value(0),\n};\n}\n@@ -81,6 +91,7 @@ class LoggedOutModal extends React.PureComponent {\nPlatform.OS === \"ios\" ? \"keyboardWillHide\" : \"keyboardDidHide\",\nthis.keyboardHide,\n);\n+ BackAndroid.addEventListener('hardwareBackPress', this.hardwareBack);\n}\ncomponentWillUnmount() {\n@@ -88,75 +99,168 @@ class LoggedOutModal extends React.PureComponent {\nthis.keyboardShowListener.remove();\ninvariant(this.keyboardHideListener, \"should be set\");\nthis.keyboardHideListener.remove();\n+ BackAndroid.removeEventListener('hardwareBackPress', this.hardwareBack);\n+ }\n+\n+ hardwareBack = () => {\n+ if (this.nextMode !== \"prompt\") {\n+ this.goBackToPrompt();\n+ return true;\n+ }\n+ return false;\n}\nstatic currentPaddingTop(\nmode: LoggedOutMode,\nkeyboardHeight: number,\n) {\n- const { height } = Dimensions.get('window');\n- const heightWithoutPadding = height - 90;\n- let containerSize = Platform.OS === \"ios\" ? 62 : 59;\n+ let { height } = Dimensions.get('window');\n+ if (Platform.OS === \"android\") {\n+ // Android's Dimensions.get doesn't include the status bar\n+ height -= 24;\n+ }\n+ let containerSize = Platform.OS === \"ios\" ? 62 : 59; // header height\nif (mode === \"log-in\") {\ncontainerSize += 165;\n} else if (mode === \"register\") {\ncontainerSize += 246;\n+ } else {\n+ // This is arbitrary and artificial... actually centering just looks a bit\n+ // weird because the buttons are at the bottom\n+ containerSize += 80;\n}\n- const test = (heightWithoutPadding - containerSize - keyboardHeight) / 2;\n- console.log(test);\n- return test;\n+ return (height - containerSize - keyboardHeight) / 2;\n}\n- keyboardShow = (event: KeyboardEvent) => {\n- const duration = event.duration ? event.duration : 250;\n+ animateToSecondMode(inputDuration: ?number) {\n+ const duration = inputDuration ? inputDuration : 150;\n+ const animations = [\nAnimated.timing(\nthis.state.paddingTop,\n{\nduration,\n- easing: Easing.inOut(Easing.ease),\n+ easing: Easing.out(Easing.ease),\ntoValue: LoggedOutModal.currentPaddingTop(\nthis.state.mode,\n- event.endCoordinates.height,\n+ this.keyboardHeight,\n),\n},\n- ).start();\n+ ),\n+ ];\n+ if (this.opacityChangeQueued) {\n+ animations.push(\n+ Animated.timing(\n+ this.state.opacityValue,\n+ {\n+ duration,\n+ easing: Easing.out(Easing.ease),\n+ toValue: 1,\n+ },\n+ ),\n+ );\n+ }\n+ Animated.parallel(animations).start();\n}\n- keyboardHide = (event: ?KeyboardEvent) => {\n- if (this.state.activeAlert) {\n+ keyboardShow = (event: KeyboardEvent) => {\n+ this.keyboardHeight = event.endCoordinates.height;\n+ if (this.activeKeyboard) {\n+ // We do this because the Android keyboard can change in height and we\n+ // don't want to bother animating between those events\nreturn;\n}\n- const duration = (event && event.duration) ? event.duration : 250;\n+ this.activeKeyboard = true;\n+ this.animateToSecondMode(event.duration);\n+ this.opacityChangeQueued = false;\n+ }\n+\n+ animateBackToPrompt(inputDuration: ?number) {\n+ const duration = inputDuration ? inputDuration : 250;\n+ const animations = [\nAnimated.timing(\nthis.state.paddingTop,\n{\nduration,\n- easing: Easing.inOut(Easing.ease),\n- toValue: LoggedOutModal.currentPaddingTop(this.state.mode, 0),\n+ easing: Easing.out(Easing.ease),\n+ toValue: LoggedOutModal.currentPaddingTop(this.nextMode, 0),\n},\n- ).start();\n+ ),\n+ ];\n+ if (this.opacityChangeQueued) {\n+ animations.push(\n+ Animated.timing(\n+ this.state.opacityValue,\n+ {\n+ duration,\n+ easing: Easing.out(Easing.ease),\n+ toValue: 0,\n+ },\n+ ),\n+ );\n+ }\n+ Animated.parallel(animations).start();\n+ }\n+\n+ keyboardHide = (event: ?KeyboardEvent) => {\n+ this.keyboardHeight = 0;\n+ if (this.activeAlert) {\n+ return;\n+ }\n+ this.activeKeyboard = false;\n+ this.animateBackToPrompt(event && event.duration);\n+ this.opacityChangeQueued = false;\n}\nsetActiveAlert = (activeAlert: bool) => {\n- this.setState({ activeAlert });\n+ this.activeAlert = activeAlert;\n+ }\n+\n+ goBackToPrompt = () => {\n+ this.opacityHitsZeroListenerID =\n+ this.state.opacityValue.addListener(this.opacityListener);\n+ this.opacityChangeQueued = true;\n+ this.nextMode = \"prompt\";\n+ if (this.activeKeyboard) {\n+ // If keyboard is currently active, keyboardHide will handle the\n+ // animation. This is so we can run all animations in parallel\n+ Keyboard.dismiss();\n+ } else {\n+ this.animateBackToPrompt(null);\n+ }\n+ }\n+\n+ opacityListener = (animatedUpdate: { value: number }) => {\n+ if (animatedUpdate.value === 0) {\n+ this.setState({ mode: \"prompt\" });\n+ this.state.opacityValue.removeListener(this.opacityHitsZeroListenerID);\n+ }\n}\nrender() {\n- const padding = { paddingTop: this.state.paddingTop };\n- let content = null;\n+ const statusBar = <ConnectedStatusBar barStyle=\"light-content\" />;\n+ const background = (\n+ <Image\n+ source={require(\"../img/logged-out-modal-background.jpg\")}\n+ style={styles.loggedOutModalBackgroundContainer}\n+ />\n+ );\n+\n+ let panel = null;\nlet buttons = null;\nif (this.state.mode === \"log-in\") {\n- content = (\n+ panel = (\n<LogInPanel\nnavigateToApp={this.props.navigation.goBack}\nsetActiveAlert={this.setActiveAlert}\n+ opacityValue={this.state.opacityValue}\n/>\n);\n} else if (this.state.mode === \"register\") {\n- content = (\n+ panel = (\n<RegisterPanel\nnavigateToApp={this.props.navigation.goBack}\nsetActiveAlert={this.setActiveAlert}\n+ opacityValue={this.state.opacityValue}\n/>\n);\n} else {\n@@ -183,28 +287,72 @@ class LoggedOutModal extends React.PureComponent {\n</View>\n);\n}\n- return (\n- <View style={styles.container}>\n- <ConnectedStatusBar barStyle=\"light-content\" />\n- <Image\n- source={require(\"../img/logged-out-modal-background.jpg\")}\n- style={styles.loggedOutModalBackgroundContainer}\n- />\n+\n+ const padding = { paddingTop: this.state.paddingTop };\n+ const opacity = { opacity: this.state.opacityValue };\n+ const animatedContent = (\n<Animated.View style={[styles.animationContainer, padding]}>\n+ <View>\n<Text style={styles.header}>SquadCal</Text>\n- {content}\n+ <Animated.View style={[styles.backButton, opacity]}>\n+ <TouchableOpacity activeOpacity={0.6} onPress={this.goBackToPrompt}>\n+ <Icon\n+ name=\"arrow-circle-o-left\"\n+ size={36}\n+ color=\"#FFFFFFAA\"\n+ />\n+ </TouchableOpacity>\n+ </Animated.View>\n+ </View>\n+ {panel}\n</Animated.View>\n+ );\n+\n+ // Man, you gotta wonder sometimes if React Native is really worth it.\n+ // The iOS order causes some extremely strange layout bugs on Android.\n+ // The Android order makes the buttons in prompt mode not clickable.\n+ let content;\n+ if (Platform.OS === \"ios\") {\n+ return (\n+ <View style={styles.container}>\n+ {statusBar}\n+ {background}\n+ {animatedContent}\n+ {buttons}\n+ </View>\n+ );\n+ } else {\n+ return (\n+ <View style={styles.container}>\n+ {statusBar}\n+ {background}\n{buttons}\n+ {animatedContent}\n</View>\n);\n}\n+ }\nonPressLogIn = () => {\n+ this.opacityChangeQueued = true;\n+ this.nextMode = \"log-in\";\nthis.setState({ mode: \"log-in\" });\n+ if (this.activeKeyboard) {\n+ // If keyboard isn't currently active, keyboardShow will handle the\n+ // animation. This is so we can run all animations in parallel\n+ this.animateToSecondMode(null);\n+ }\n}\nonPressRegister = () => {\n+ this.opacityChangeQueued = true;\n+ this.nextMode = \"register\";\nthis.setState({ mode: \"register\" });\n+ if (this.activeKeyboard) {\n+ // If keyboard isn't currently active, keyboardShow will handle the\n+ // animation. This is so we can run all animations in parallel\n+ this.animateToSecondMode(null);\n+ }\n}\n}\n@@ -215,8 +363,6 @@ const styles = StyleSheet.create({\n},\ncontainer: {\nflex: 1,\n- paddingTop: 40,\n- paddingBottom: 50,\nbackgroundColor: 'transparent',\n},\nanimationContainer: {\n@@ -228,6 +374,11 @@ const styles = StyleSheet.create({\nfontSize: 48,\ntextAlign: 'center',\n},\n+ backButton: {\n+ position: 'absolute',\n+ left: 40,\n+ top: 13,\n+ },\nbuttonContainer: {\nposition: 'absolute',\nbottom: 0,\n"
},
{
"change_type": "MODIFY",
"old_path": "native/account/register-panel.react.js",
"new_path": "native/account/register-panel.react.js",
"diff": "@@ -15,6 +15,8 @@ import {\nActivityIndicator,\nKeyboard,\nAlert,\n+ Animated,\n+ TouchableNativeFeedback,\n} from 'react-native';\nimport Icon from 'react-native-vector-icons/FontAwesome';\nimport { connect } from 'react-redux';\n@@ -38,6 +40,7 @@ class RegisterPanel extends React.PureComponent {\nprops: {\nnavigateToApp: () => void,\nsetActiveAlert: (activeAlert: bool) => void,\n+ opacityValue: Animated.Value,\n// Redux state\nloadingStatus: LoadingStatus,\n// Redux dispatch functions\n@@ -52,6 +55,7 @@ class RegisterPanel extends React.PureComponent {\nstatic propTypes = {\nnavigateToApp: React.PropTypes.func.isRequired,\nsetActiveAlert: React.PropTypes.func.isRequired,\n+ opacityValue: React.PropTypes.object.isRequired,\nloadingStatus: React.PropTypes.string.isRequired,\ndispatchActionPromise: React.PropTypes.func.isRequired,\nregister: React.PropTypes.func.isRequired,\n@@ -91,8 +95,33 @@ class RegisterPanel extends React.PureComponent {\n</View>\n);\n}\n+ let submitButton;\n+ if (Platform.OS === \"android\") {\n+ submitButton = (\n+ <TouchableNativeFeedback onPress={this.onSubmit}>\n+ <View style={[styles.submitContentContainer, styles.submitButton]}>\n+ <Text style={styles.submitContentText}>SIGN UP</Text>\n+ {buttonIcon}\n+ </View>\n+ </TouchableNativeFeedback>\n+ );\n+ } else {\n+ submitButton = (\n+ <TouchableHighlight\n+ onPress={this.onSubmit}\n+ style={styles.submitButton}\n+ underlayColor=\"#A0A0A0DD\"\n+ >\n+ <View style={styles.submitContentContainer}>\n+ <Text style={styles.submitContentText}>SIGN UP</Text>\n+ {buttonIcon}\n+ </View>\n+ </TouchableHighlight>\n+ );\n+ }\n+ const opacityStyle = { opacity: this.props.opacityValue };\nreturn (\n- <View style={styles.container}>\n+ <Animated.View style={[styles.container, opacityStyle]}>\n<View>\n<Icon name=\"user\" size={22} color=\"#777\" style={styles.icon} />\n<TextInput\n@@ -162,17 +191,8 @@ class RegisterPanel extends React.PureComponent {\nref={this.confirmPasswordInputRef}\n/>\n</View>\n- <TouchableHighlight\n- onPress={this.onSubmit}\n- style={styles.submitButton}\n- underlayColor=\"#A0A0A0DD\"\n- >\n- <View style={styles.submitContentContainer}>\n- <Text style={styles.submitContentText}>SIGN UP</Text>\n- {buttonIcon}\n- </View>\n- </TouchableHighlight>\n- </View>\n+ {submitButton}\n+ </Animated.View>\n);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "native/ios/SquadCal.xcodeproj/project.pbxproj",
"new_path": "native/ios/SquadCal.xcodeproj/project.pbxproj",
"diff": "TargetAttributes = {\n00E356ED1AD99517003FC87E = {\nCreatedOnToolsVersion = 6.2;\n+ DevelopmentTeam = CW2BC4VSCP;\nTestTargetID = 13B07F861A680F5B00A75B9A;\n};\n+ 13B07F861A680F5B00A75B9A = {\n+ DevelopmentTeam = CW2BC4VSCP;\n+ };\n2D02E47A1E0B4A5D006451C7 = {\nCreatedOnToolsVersion = 8.2.1;\n+ DevelopmentTeam = CW2BC4VSCP;\nProvisioningStyle = Automatic;\n};\n2D02E48F1E0B4A5D006451C7 = {\nCreatedOnToolsVersion = 8.2.1;\n+ DevelopmentTeam = CW2BC4VSCP;\nProvisioningStyle = Automatic;\nTestTargetID = 2D02E47A1E0B4A5D006451C7;\n};\nisa = XCBuildConfiguration;\nbuildSettings = {\nBUNDLE_LOADER = \"$(TEST_HOST)\";\n+ DEVELOPMENT_TEAM = CW2BC4VSCP;\nGCC_PREPROCESSOR_DEFINITIONS = (\n\"DEBUG=1\",\n\"$(inherited)\",\nbuildSettings = {\nBUNDLE_LOADER = \"$(TEST_HOST)\";\nCOPY_PHASE_STRIP = NO;\n+ DEVELOPMENT_TEAM = CW2BC4VSCP;\nHEADER_SEARCH_PATHS = (\n\"$(inherited)\",\n\"$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager\",\nASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;\nCURRENT_PROJECT_VERSION = 1;\nDEAD_CODE_STRIPPING = NO;\n+ DEVELOPMENT_TEAM = CW2BC4VSCP;\nHEADER_SEARCH_PATHS = (\n\"$(inherited)\",\n\"$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager\",\nbuildSettings = {\nASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;\nCURRENT_PROJECT_VERSION = 1;\n+ DEVELOPMENT_TEAM = CW2BC4VSCP;\nHEADER_SEARCH_PATHS = (\n\"$(inherited)\",\n\"$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager\",\nCLANG_WARN_INFINITE_RECURSION = YES;\nCLANG_WARN_SUSPICIOUS_MOVE = YES;\nDEBUG_INFORMATION_FORMAT = dwarf;\n+ DEVELOPMENT_TEAM = CW2BC4VSCP;\nENABLE_TESTABILITY = YES;\nGCC_NO_COMMON_BLOCKS = YES;\nHEADER_SEARCH_PATHS = (\nCLANG_WARN_SUSPICIOUS_MOVE = YES;\nCOPY_PHASE_STRIP = NO;\nDEBUG_INFORMATION_FORMAT = \"dwarf-with-dsym\";\n+ DEVELOPMENT_TEAM = CW2BC4VSCP;\nGCC_NO_COMMON_BLOCKS = YES;\nHEADER_SEARCH_PATHS = (\n\"$(inherited)\",\nCLANG_WARN_INFINITE_RECURSION = YES;\nCLANG_WARN_SUSPICIOUS_MOVE = YES;\nDEBUG_INFORMATION_FORMAT = dwarf;\n+ DEVELOPMENT_TEAM = CW2BC4VSCP;\nENABLE_TESTABILITY = YES;\nGCC_NO_COMMON_BLOCKS = YES;\nINFOPLIST_FILE = \"SquadCal-tvOSTests/Info.plist\";\nCLANG_WARN_SUSPICIOUS_MOVE = YES;\nCOPY_PHASE_STRIP = NO;\nDEBUG_INFORMATION_FORMAT = \"dwarf-with-dsym\";\n+ DEVELOPMENT_TEAM = CW2BC4VSCP;\nGCC_NO_COMMON_BLOCKS = YES;\nINFOPLIST_FILE = \"SquadCal-tvOSTests/Info.plist\";\nLD_RUNPATH_SEARCH_PATHS = \"$(inherited) @executable_path/Frameworks @loader_path/Frameworks\";\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | omg logged out modal is mostly working sort of |
129,187 | 20.03.2017 23:19:40 | 14,400 | 575bc3b5b3a5cd3b4d9c9bb81915f748b277da7e | OnePassword support for iOS. Wow, that was easy! | [
{
"change_type": "MODIFY",
"old_path": "native/account/log-in-panel.react.js",
"new_path": "native/account/log-in-panel.react.js",
"diff": "@@ -17,10 +17,13 @@ import {\nKeyboard,\nAnimated,\nTouchableNativeFeedback,\n+ Image,\n+ TouchableWithoutFeedback,\n} from 'react-native';\nimport Icon from 'react-native-vector-icons/FontAwesome';\nimport { connect } from 'react-redux';\nimport invariant from 'invariant';\n+import OnePassword from 'react-native-onepassword';\nimport {\nvalidUsernameRegex,\n@@ -41,6 +44,7 @@ class LogInPanel extends React.PureComponent {\nnavigateToApp: () => void,\nsetActiveAlert: (activeAlert: bool) => void,\nopacityValue: Animated.Value,\n+ onePasswordSupported: bool,\n// Redux state\nloadingStatus: LoadingStatus,\n// Redux dispatch functions\n@@ -55,6 +59,7 @@ class LogInPanel extends React.PureComponent {\nnavigateToApp: React.PropTypes.func.isRequired,\nsetActiveAlert: React.PropTypes.func.isRequired,\nopacityValue: React.PropTypes.object.isRequired,\n+ onePasswordSupported: React.PropTypes.bool.isRequired,\nloadingStatus: React.PropTypes.string.isRequired,\ndispatchActionPromise: React.PropTypes.func.isRequired,\nlogIn: React.PropTypes.func.isRequired,\n@@ -108,6 +113,19 @@ class LogInPanel extends React.PureComponent {\n</TouchableHighlight>\n);\n}\n+ let onePassword = null;\n+ let passwordStyle = {};\n+ if (this.props.onePasswordSupported) {\n+ onePassword = (\n+ <TouchableWithoutFeedback onPress={this.onPressOnePassword}>\n+ <Image\n+ source={require(\"../img/onepassword.png\")}\n+ style={styles.onePasswordImage}\n+ />\n+ </TouchableWithoutFeedback>\n+ );\n+ passwordStyle = { paddingRight: 30 };\n+ }\nconst opacityStyle = { opacity: this.props.opacityValue };\nreturn (\n<Animated.View style={[styles.container, opacityStyle]}>\n@@ -132,7 +150,7 @@ class LogInPanel extends React.PureComponent {\n<View>\n<Icon name=\"lock\" size={22} color=\"#777\" style={styles.icon} />\n<TextInput\n- style={styles.input}\n+ style={[styles.input, passwordStyle]}\nvalue={this.state.passwordInputText}\nonChangeText={this.onChangePasswordInputText}\nplaceholder=\"Password\"\n@@ -143,6 +161,7 @@ class LogInPanel extends React.PureComponent {\neditable={this.props.loadingStatus !== \"loading\"}\nref={this.passwordInputRef}\n/>\n+ {onePassword}\n</View>\n{submitButton}\n</Animated.View>\n@@ -273,6 +292,17 @@ class LogInPanel extends React.PureComponent {\n);\n}\n+ onPressOnePassword = async () => {\n+ try {\n+ const credentials = await OnePassword.findLogin(\"https://squadcal.org\");\n+ this.setState({\n+ usernameOrEmailInputText: credentials.username,\n+ passwordInputText: credentials.password,\n+ });\n+ this.onSubmit();\n+ } catch (e) { }\n+ }\n+\n}\nconst styles = StyleSheet.create({\n@@ -323,6 +353,14 @@ const styles = StyleSheet.create({\nwidth: 14,\npaddingBottom: 2,\n},\n+ onePasswordImage: {\n+ position: 'absolute',\n+ top: 8,\n+ right: 5,\n+ width: 24,\n+ height: 24,\n+ opacity: 0.6,\n+ },\n});\nconst loadingStatusSelector = createLoadingStatusSelector(logInActionType);\n"
},
{
"change_type": "MODIFY",
"old_path": "native/account/logged-out-modal.react.js",
"new_path": "native/account/logged-out-modal.react.js",
"diff": "@@ -20,6 +20,7 @@ import {\n} from 'react-native';\nimport invariant from 'invariant';\nimport Icon from 'react-native-vector-icons/FontAwesome';\n+import OnePassword from 'react-native-onepassword';\nimport LogInPanel from './log-in-panel.react';\nimport RegisterPanel from './register-panel.react';\n@@ -42,6 +43,7 @@ type State = {\nmode: LoggedOutMode,\npaddingTop: Animated.Value,\nopacityValue: Animated.Value,\n+ onePasswordSupported: bool,\n};\nclass LoggedOutModal extends React.PureComponent {\n@@ -66,10 +68,10 @@ class LoggedOutModal extends React.PureComponent {\nopacityHitsZeroListenerID: number;\nnextMode: LoggedOutMode = \"prompt\";\n- activeAlert: bool = false;\n- activeKeyboard: bool = false;\n- opacityChangeQueued: bool = false;\n- keyboardHeight: number = 0;\n+ activeAlert = false;\n+ activeKeyboard = false;\n+ opacityChangeQueued = false;\n+ keyboardHeight = 0;\nconstructor(props: Props) {\nsuper(props);\n@@ -79,7 +81,19 @@ class LoggedOutModal extends React.PureComponent {\nLoggedOutModal.currentPaddingTop(\"prompt\", 0),\n),\nopacityValue: new Animated.Value(0),\n+ onePasswordSupported: false,\n};\n+ this.determineOnePasswordSupport().then();\n+ }\n+\n+ async determineOnePasswordSupport() {\n+ let onePasswordSupported;\n+ try {\n+ onePasswordSupported = await OnePassword.isSupported();\n+ } catch (e) {\n+ onePasswordSupported = false;\n+ }\n+ this.setState({ onePasswordSupported });\n}\ncomponentWillMount() {\n@@ -253,6 +267,7 @@ class LoggedOutModal extends React.PureComponent {\nnavigateToApp={this.props.navigation.goBack}\nsetActiveAlert={this.setActiveAlert}\nopacityValue={this.state.opacityValue}\n+ onePasswordSupported={this.state.onePasswordSupported}\n/>\n);\n} else if (this.state.mode === \"register\") {\n@@ -261,6 +276,7 @@ class LoggedOutModal extends React.PureComponent {\nnavigateToApp={this.props.navigation.goBack}\nsetActiveAlert={this.setActiveAlert}\nopacityValue={this.state.opacityValue}\n+ onePasswordSupported={this.state.onePasswordSupported}\n/>\n);\n} else {\n"
},
{
"change_type": "MODIFY",
"old_path": "native/account/register-panel.react.js",
"new_path": "native/account/register-panel.react.js",
"diff": "@@ -17,10 +17,13 @@ import {\nAlert,\nAnimated,\nTouchableNativeFeedback,\n+ Image,\n+ TouchableWithoutFeedback,\n} from 'react-native';\nimport Icon from 'react-native-vector-icons/FontAwesome';\nimport { connect } from 'react-redux';\nimport invariant from 'invariant';\n+import OnePassword from 'react-native-onepassword';\nimport {\nincludeDispatchActionProps,\n@@ -41,6 +44,7 @@ class RegisterPanel extends React.PureComponent {\nnavigateToApp: () => void,\nsetActiveAlert: (activeAlert: bool) => void,\nopacityValue: Animated.Value,\n+ onePasswordSupported: bool,\n// Redux state\nloadingStatus: LoadingStatus,\n// Redux dispatch functions\n@@ -56,6 +60,7 @@ class RegisterPanel extends React.PureComponent {\nnavigateToApp: React.PropTypes.func.isRequired,\nsetActiveAlert: React.PropTypes.func.isRequired,\nopacityValue: React.PropTypes.object.isRequired,\n+ onePasswordSupported: React.PropTypes.bool.isRequired,\nloadingStatus: React.PropTypes.string.isRequired,\ndispatchActionPromise: React.PropTypes.func.isRequired,\nregister: React.PropTypes.func.isRequired,\n@@ -119,6 +124,19 @@ class RegisterPanel extends React.PureComponent {\n</TouchableHighlight>\n);\n}\n+ let onePassword = null;\n+ let passwordStyle = {};\n+ if (this.props.onePasswordSupported) {\n+ onePassword = (\n+ <TouchableWithoutFeedback onPress={this.onPressOnePassword}>\n+ <Image\n+ source={require(\"../img/onepassword.png\")}\n+ style={styles.onePasswordImage}\n+ />\n+ </TouchableWithoutFeedback>\n+ );\n+ passwordStyle = { paddingRight: 30 };\n+ }\nconst opacityStyle = { opacity: this.props.opacityValue };\nreturn (\n<Animated.View style={[styles.container, opacityStyle]}>\n@@ -165,7 +183,7 @@ class RegisterPanel extends React.PureComponent {\n<View>\n<Icon name=\"lock\" size={22} color=\"#777\" style={styles.icon} />\n<TextInput\n- style={styles.input}\n+ style={[styles.input, passwordStyle]}\nvalue={this.state.passwordInputText}\nonChangeText={this.onChangePasswordInputText}\nplaceholder=\"Password\"\n@@ -176,6 +194,7 @@ class RegisterPanel extends React.PureComponent {\neditable={this.props.loadingStatus !== \"loading\"}\nref={this.passwordInputRef}\n/>\n+ {onePassword}\n</View>\n<View>\n<TextInput\n@@ -393,6 +412,23 @@ class RegisterPanel extends React.PureComponent {\n);\n}\n+ onPressOnePassword = async () => {\n+ try {\n+ const credentials = await OnePassword.findLogin(\"https://squadcal.org\");\n+ this.setState({\n+ usernameInputText: credentials.username,\n+ passwordInputText: credentials.password,\n+ confirmPasswordInputText: credentials.password,\n+ });\n+ if (this.state.emailInputText) {\n+ this.onSubmit();\n+ } else {\n+ invariant(this.emailInput, \"ref should exist\");\n+ this.emailInput.focus();\n+ }\n+ } catch (e) { }\n+ }\n+\n}\nconst styles = StyleSheet.create({\n@@ -448,6 +484,14 @@ const styles = StyleSheet.create({\nwidth: 14,\npaddingBottom: 2,\n},\n+ onePasswordImage: {\n+ position: 'absolute',\n+ top: 8,\n+ right: 5,\n+ width: 24,\n+ height: 24,\n+ opacity: 0.6,\n+ },\n});\nconst loadingStatusSelector = createLoadingStatusSelector(registerActionType);\n"
},
{
"change_type": "ADD",
"old_path": "native/img/onepassword@2x.png",
"new_path": "native/img/onepassword@2x.png",
"diff": "Binary files /dev/null and b/native/img/onepassword@2x.png differ\n"
},
{
"change_type": "ADD",
"old_path": "native/img/onepassword@3x.png",
"new_path": "native/img/onepassword@3x.png",
"diff": "Binary files /dev/null and b/native/img/onepassword@3x.png differ\n"
},
{
"change_type": "MODIFY",
"old_path": "native/ios/SquadCal.xcodeproj/project.pbxproj",
"new_path": "native/ios/SquadCal.xcodeproj/project.pbxproj",
"diff": "2D02E4C91E0B4AEC006451C7 /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3DAD3EA31DF850E9000B6D8A /* libReact.a */; };\n2DCD954D1E0B4F2C00145EB5 /* SquadCalTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 00E356F21AD99517003FC87E /* SquadCalTests.m */; };\n2E5ADC2BAEA24F1AAD81E147 /* Zocial.ttf in Resources */ = {isa = PBXBuildFile; fileRef = EBD8879422144B0188A8336F /* Zocial.ttf */; };\n+ 3ACC3CE62D76452D871EE584 /* libOnePassword.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 45E5772A9A1B46B9B488B032 /* libOnePassword.a */; };\n569C48070423498795574595 /* EvilIcons.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 3430816A291640AEACA13234 /* EvilIcons.ttf */; };\n5E9157361DD0AC6A00FF2AA8 /* libRCTAnimation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5E9157331DD0AC6500FF2AA8 /* libRCTAnimation.a */; };\n781ED432789E4AFC93FA578A /* Entypo.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 1E94F1BD692B4E6EBE1BFBFB /* Entypo.ttf */; };\nremoteGlobalIDString = 5DBEB1501B18CEA900B34395;\nremoteInfo = RNVectorIcons;\n};\n+ 7FB58AD31E80C21000B4C1B1 /* PBXContainerItemProxy */ = {\n+ isa = PBXContainerItemProxy;\n+ containerPortal = E7D7D614C3184B1BB95EE661 /* OnePassword.xcodeproj */;\n+ proxyType = 2;\n+ remoteGlobalIDString = 52E319201C0655C200265D56;\n+ remoteInfo = OnePassword;\n+ };\n832341B41AAA6A8300B99B32 /* PBXContainerItemProxy */ = {\nisa = PBXContainerItemProxy;\ncontainerPortal = 832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */;\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>\"; };\n3430816A291640AEACA13234 /* EvilIcons.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = EvilIcons.ttf; path = \"../node_modules/react-native-vector-icons/Fonts/EvilIcons.ttf\"; sourceTree = \"<group>\"; };\n414381A5DC394FE6BF2D28F3 /* libRNVectorIcons.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRNVectorIcons.a; sourceTree = \"<group>\"; };\n+ 45E5772A9A1B46B9B488B032 /* libOnePassword.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libOnePassword.a; sourceTree = \"<group>\"; };\n4AB1FC0EFD3A4ED1A082E32F /* FontAwesome.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = FontAwesome.ttf; path = \"../node_modules/react-native-vector-icons/Fonts/FontAwesome.ttf\"; sourceTree = \"<group>\"; };\n4ACC468F28D944F293B91ACC /* Ionicons.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = Ionicons.ttf; path = \"../node_modules/react-native-vector-icons/Fonts/Ionicons.ttf\"; sourceTree = \"<group>\"; };\n5E91572D1DD0AC6500FF2AA8 /* RCTAnimation.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = \"wrapper.pb-project\"; name = RCTAnimation.xcodeproj; path = \"../node_modules/react-native/Libraries/NativeAnimation/RCTAnimation.xcodeproj\"; sourceTree = \"<group>\"; };\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>\"; };\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>\"; };\n+ E7D7D614C3184B1BB95EE661 /* 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/* End PBXFileReference section */\n00C302EA1ABCBA2D00DB3ED1 /* libRCTVibration.a in Frameworks */,\n139FDEF61B0652A700C62182 /* libRCTWebSocket.a in Frameworks */,\n98856FAEFDD5420882A5C010 /* libRNVectorIcons.a in Frameworks */,\n+ 3ACC3CE62D76452D871EE584 /* libOnePassword.a in Frameworks */,\n);\nrunOnlyForDeploymentPostprocessing = 0;\n};\nname = Products;\nsourceTree = \"<group>\";\n};\n+ 7FB58AD01E80C21000B4C1B1 /* Products */ = {\n+ isa = PBXGroup;\n+ children = (\n+ 7FB58AD41E80C21000B4C1B1 /* libOnePassword.a */,\n+ );\n+ name = Products;\n+ sourceTree = \"<group>\";\n+ };\n832341AE1AAA6A7D00B99B32 /* Libraries */ = {\nisa = PBXGroup;\nchildren = (\n00C302DF1ABCB9EE00DB3ED1 /* RCTVibration.xcodeproj */,\n139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */,\nC3BA31E561EB497494D7882F /* RNVectorIcons.xcodeproj */,\n+ E7D7D614C3184B1BB95EE661 /* OnePassword.xcodeproj */,\n);\nname = Libraries;\nsourceTree = \"<group>\";\nproductRefGroup = 83CBBA001A601CBA00E9B192 /* Products */;\nprojectDirPath = \"\";\nprojectReferences = (\n+ {\n+ ProductGroup = 7FB58AD01E80C21000B4C1B1 /* Products */;\n+ ProjectRef = E7D7D614C3184B1BB95EE661 /* OnePassword.xcodeproj */;\n+ },\n{\nProductGroup = 00C302A81ABCB8CE00DB3ED1 /* Products */;\nProjectRef = 00C302A71ABCB8CE00DB3ED1 /* RCTActionSheet.xcodeproj */;\nremoteRef = 7FB58AB91E7F6B4400B4C1B1 /* PBXContainerItemProxy */;\nsourceTree = BUILT_PRODUCTS_DIR;\n};\n+ 7FB58AD41E80C21000B4C1B1 /* libOnePassword.a */ = {\n+ isa = PBXReferenceProxy;\n+ fileType = archive.ar;\n+ path = libOnePassword.a;\n+ remoteRef = 7FB58AD31E80C21000B4C1B1 /* PBXContainerItemProxy */;\n+ sourceTree = BUILT_PRODUCTS_DIR;\n+ };\n832341B51AAA6A8300B99B32 /* libRCTText.a */ = {\nisa = PBXReferenceProxy;\nfileType = archive.ar;\nHEADER_SEARCH_PATHS = (\n\"$(inherited)\",\n\"$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager\",\n+ \"$(SRCROOT)/../node_modules/react-native-onepassword\",\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\",\nHEADER_SEARCH_PATHS = (\n\"$(inherited)\",\n\"$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager\",\n+ \"$(SRCROOT)/../node_modules/react-native-onepassword\",\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\",\nHEADER_SEARCH_PATHS = (\n\"$(inherited)\",\n\"$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager\",\n+ \"$(SRCROOT)/../node_modules/react-native-onepassword\",\n);\nINFOPLIST_FILE = SquadCal/Info.plist;\nLD_RUNPATH_SEARCH_PATHS = \"$(inherited) @executable_path/Frameworks\";\nHEADER_SEARCH_PATHS = (\n\"$(inherited)\",\n\"$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager\",\n+ \"$(SRCROOT)/../node_modules/react-native-onepassword\",\n);\nINFOPLIST_FILE = SquadCal/Info.plist;\nLD_RUNPATH_SEARCH_PATHS = \"$(inherited) @executable_path/Frameworks\";\nHEADER_SEARCH_PATHS = (\n\"$(inherited)\",\n\"$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager\",\n+ \"$(SRCROOT)/../node_modules/react-native-onepassword\",\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\",\nHEADER_SEARCH_PATHS = (\n\"$(inherited)\",\n\"$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager\",\n+ \"$(SRCROOT)/../node_modules/react-native-onepassword\",\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/Info.plist",
"new_path": "native/ios/SquadCal/Info.plist",
"diff": "<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n+ <key>LSApplicationQueriesSchemes</key>\n+ <array>\n+ <string>org-appextension-feature-password-management</string>\n+ </array>\n<key>CFBundleDevelopmentRegion</key>\n<string>en</string>\n<key>CFBundleDisplayName</key>\n<string>1</string>\n<key>LSRequiresIPhoneOS</key>\n<true/>\n- <key>UILaunchStoryboardName</key>\n- <string>LaunchScreen</string>\n- <key>UIRequiredDeviceCapabilities</key>\n- <array>\n- <string>armv7</string>\n- </array>\n- <key>UISupportedInterfaceOrientations</key>\n- <array>\n- <string>UIInterfaceOrientationPortrait</string>\n- <string>UIInterfaceOrientationLandscapeLeft</string>\n- <string>UIInterfaceOrientationLandscapeRight</string>\n- </array>\n- <key>UIViewControllerBasedStatusBarAppearance</key>\n- <false/>\n- <key>NSLocationWhenInUseUsageDescription</key>\n- <string></string>\n<key>NSAppTransportSecurity</key>\n<dict>\n<key>NSExceptionDomains</key>\n</dict>\n</dict>\n</dict>\n+ <key>NSLocationWhenInUseUsageDescription</key>\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>UILaunchStoryboardName</key>\n+ <string>LaunchScreen</string>\n+ <key>UIRequiredDeviceCapabilities</key>\n+ <array>\n+ <string>armv7</string>\n+ </array>\n+ <key>UISupportedInterfaceOrientations</key>\n+ <array>\n+ <string>UIInterfaceOrientationPortrait</string>\n+ </array>\n+ <key>UIViewControllerBasedStatusBarAppearance</key>\n+ <false/>\n</dict>\n</plist>\n"
},
{
"change_type": "MODIFY",
"old_path": "native/package.json",
"new_path": "native/package.json",
"diff": "\"invariant\": \"^2.2.2\",\n\"react\": \"15.4.2\",\n\"react-native\": \"^0.42.3\",\n+ \"react-native-onepassword\": \"^1.0.4\",\n\"react-native-vector-icons\": \"^4.0.0\",\n\"react-navigation\": \"^1.0.0-beta.7\",\n\"react-redux\": \"^5.0.2\",\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | OnePassword support for iOS. Wow, that was easy! |
129,187 | 22.03.2017 18:55:07 | 14,400 | 006f9ef62ba908fe51f520e5ecf3d5435cfc553d | Some iOS universal deep linking stuff | [
{
"change_type": "MODIFY",
"old_path": "native/ios/SquadCal.xcodeproj/project.pbxproj",
"new_path": "native/ios/SquadCal.xcodeproj/project.pbxproj",
"diff": "7FB58ABB1E7F6BC600B4C1B1 /* Anaheim-Regular.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = \"Anaheim-Regular.ttf\"; sourceTree = \"<group>\"; };\n7FB58ABC1E7F6BC600B4C1B1 /* OpenSans-Regular.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = \"OpenSans-Regular.ttf\"; sourceTree = \"<group>\"; };\n7FB58ABD1E7F6BC600B4C1B1 /* OpenSans-Semibold.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = \"OpenSans-Semibold.ttf\"; sourceTree = \"<group>\"; };\n+ 7FCFD8BD1E81B8DF00629B0E /* SquadCal.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; name = SquadCal.entitlements; path = SquadCal/SquadCal.entitlements; sourceTree = \"<group>\"; };\n832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = \"wrapper.pb-project\"; name = RCTText.xcodeproj; path = \"../node_modules/react-native/Libraries/Text/RCTText.xcodeproj\"; sourceTree = \"<group>\"; };\n8D919BA72D8545CBBBF6B74F /* MaterialCommunityIcons.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = MaterialCommunityIcons.ttf; path = \"../node_modules/react-native-vector-icons/Fonts/MaterialCommunityIcons.ttf\"; 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>\"; };\n13B07FAE1A68108700A75B9A /* SquadCal */ = {\nisa = PBXGroup;\nchildren = (\n+ 7FCFD8BD1E81B8DF00629B0E /* SquadCal.entitlements */,\n008F07F21AC5B25A0029DE68 /* main.jsbundle */,\n13B07FAF1A68108700A75B9A /* AppDelegate.h */,\n13B07FB01A68108700A75B9A /* AppDelegate.m */,\nTestTargetID = 13B07F861A680F5B00A75B9A;\n};\n13B07F861A680F5B00A75B9A = {\n- DevelopmentTeam = CW2BC4VSCP;\n+ DevelopmentTeam = 6BF4H9TU5U;\n+ ProvisioningStyle = Automatic;\n+ SystemCapabilities = {\n+ com.apple.SafariKeychain = {\n+ enabled = 1;\n+ };\n+ };\n};\n2D02E47A1E0B4A5D006451C7 = {\nCreatedOnToolsVersion = 8.2.1;\nisa = XCBuildConfiguration;\nbuildSettings = {\nASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;\n+ CODE_SIGN_ENTITLEMENTS = SquadCal/SquadCal.entitlements;\n+ \"CODE_SIGN_IDENTITY[sdk=iphoneos*]\" = \"iPhone Developer\";\nCURRENT_PROJECT_VERSION = 1;\nDEAD_CODE_STRIPPING = NO;\n- DEVELOPMENT_TEAM = CW2BC4VSCP;\n+ DEVELOPMENT_TEAM = 6BF4H9TU5U;\nHEADER_SEARCH_PATHS = (\n\"$(inherited)\",\n\"$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager\",\n\"-ObjC\",\n\"-lc++\",\n);\n+ PRODUCT_BUNDLE_IDENTIFIER = org.squadcal.app;\nPRODUCT_NAME = SquadCal;\n+ TARGETED_DEVICE_FAMILY = 1;\nVERSIONING_SYSTEM = \"apple-generic\";\n};\nname = Debug;\nisa = XCBuildConfiguration;\nbuildSettings = {\nASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;\n+ CODE_SIGN_ENTITLEMENTS = SquadCal/SquadCal.entitlements;\n+ \"CODE_SIGN_IDENTITY[sdk=iphoneos*]\" = \"iPhone Developer\";\nCURRENT_PROJECT_VERSION = 1;\n- DEVELOPMENT_TEAM = CW2BC4VSCP;\n+ DEVELOPMENT_TEAM = 6BF4H9TU5U;\nHEADER_SEARCH_PATHS = (\n\"$(inherited)\",\n\"$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager\",\n\"-ObjC\",\n\"-lc++\",\n);\n+ PRODUCT_BUNDLE_IDENTIFIER = org.squadcal.app;\nPRODUCT_NAME = SquadCal;\n+ TARGETED_DEVICE_FAMILY = 1;\nVERSIONING_SYSTEM = \"apple-generic\";\n};\nname = Release;\n"
},
{
"change_type": "MODIFY",
"old_path": "native/ios/SquadCal/Info.plist",
"new_path": "native/ios/SquadCal/Info.plist",
"diff": "<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n- <key>LSApplicationQueriesSchemes</key>\n- <array>\n- <string>org-appextension-feature-password-management</string>\n- </array>\n<key>CFBundleDevelopmentRegion</key>\n<string>en</string>\n<key>CFBundleDisplayName</key>\n<key>CFBundleExecutable</key>\n<string>$(EXECUTABLE_NAME)</string>\n<key>CFBundleIdentifier</key>\n- <string>org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)</string>\n+ <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>\n<key>CFBundleInfoDictionaryVersion</key>\n<string>6.0</string>\n<key>CFBundleName</key>\n<string>????</string>\n<key>CFBundleVersion</key>\n<string>1</string>\n+ <key>LSApplicationQueriesSchemes</key>\n+ <array>\n+ <string>org-appextension-feature-password-management</string>\n+ </array>\n<key>LSRequiresIPhoneOS</key>\n<true/>\n<key>NSAppTransportSecurity</key>\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/ios/SquadCal/SquadCal.entitlements",
"diff": "+<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n+<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n+<plist version=\"1.0\">\n+<dict>\n+ <key>com.apple.developer.associated-domains</key>\n+ <array>\n+ <string>applinks:squadcal.org</string>\n+ <string>applinks:*.squadcal.org</string>\n+ </array>\n+</dict>\n+</plist>\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "server/.well-known/apple-app-site-association",
"diff": "+{\n+ \"applinks\": {\n+ \"apps\": [],\n+ \"details\": [\n+ {\n+ \"appID\": \"6BF4H9TU5U.org.squadcal.app\",\n+ \"paths\": [ \"*\" ],\n+ },\n+ ],\n+ },\n+}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Some iOS universal deep linking stuff |
129,187 | 23.03.2017 12:34:43 | 14,400 | 1783fbdb8d01c9d34c3875890aaa5f506fe4017c | A bunch of deep linking ("universal links") stuff | [
{
"change_type": "ADD",
"old_path": null,
"new_path": "lib/utils/url-utils.js",
"diff": "+// @flow\n+\n+import invariant from 'invariant';\n+\n+export type PartialNavInfo = {\n+ year?: number,\n+ month?: number, // 1-indexed\n+ home?: bool,\n+ calendarID?: string,\n+ verify?: string,\n+};\n+\n+function partialNavInfoFromURL(url: string): PartialNavInfo {\n+ const yearMatches = new RegExp('(/|^)year/([0-9]+)(/|$)', 'i').exec(url);\n+ const monthMatches = new RegExp('(/|^)month/([0-9]+)(/|$)', 'i').exec(url);\n+ const calendarMatches = new RegExp('(/|^)calendar/([0-9]+)(/|$)', 'i')\n+ .exec(url);\n+ const verifyMatches = new RegExp('(/|^)verify/([a-f0-9]+)(/|$)', 'i')\n+ .exec(url);\n+ const homeTest = new RegExp('(/|^)home(/|$)', 'i').test(url);\n+ invariant(\n+ !homeTest || !calendarMatches,\n+ 'home and calendar should never be set at the same time',\n+ );\n+ const returnObj = {};\n+ if (yearMatches) {\n+ returnObj.year = parseInt(yearMatches[2]);\n+ }\n+ if (monthMatches) {\n+ returnObj.month = parseInt(monthMatches[2]);\n+ }\n+ if (calendarMatches) {\n+ returnObj.calendarID = calendarMatches[2];\n+ }\n+ if (verifyMatches) {\n+ returnObj.verify = verifyMatches[2];\n+ }\n+ if (homeTest) {\n+ returnObj.home = true;\n+ }\n+ return returnObj;\n+}\n+\n+export {\n+ partialNavInfoFromURL,\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "native/account/logged-out-modal.react.js",
"new_path": "native/account/logged-out-modal.react.js",
"diff": "// @flow\nimport type { NavigationScreenProp } from 'react-navigation';\n+import type { DispatchActionPayload } from 'lib/utils/action-utils';\nimport React from 'react';\nimport {\n@@ -17,10 +18,14 @@ import {\nPlatform,\nDimensions,\nBackAndroid,\n+ Linking,\n} from 'react-native';\nimport invariant from 'invariant';\nimport Icon from 'react-native-vector-icons/FontAwesome';\nimport OnePassword from 'react-native-onepassword';\n+import { connect } from 'react-redux';\n+\n+import { includeDispatchActionProps } from 'lib/utils/action-utils';\nimport LogInPanel from './log-in-panel.react';\nimport RegisterPanel from './register-panel.react';\n@@ -38,6 +43,8 @@ type KeyboardEvent = {\ntype LoggedOutMode = \"prompt\" | \"log-in\" | \"register\";\ntype Props = {\nnavigation: NavigationScreenProp<*, *>,\n+ // Redux dispatch functions\n+ dispatchActionPayload: DispatchActionPayload,\n};\ntype State = {\nmode: LoggedOutMode,\n@@ -54,6 +61,7 @@ class LoggedOutModal extends React.PureComponent {\nnavigation: React.PropTypes.shape({\nnavigate: React.PropTypes.func.isRequired,\n}).isRequired,\n+ dispatchActionPayload: React.PropTypes.func.isRequired,\n};\nstatic navigationOptions = {\n@@ -65,7 +73,7 @@ class LoggedOutModal extends React.PureComponent {\nkeyboardShowListener: ?EmitterSubscription;\nkeyboardHideListener: ?EmitterSubscription;\n- opacityHitsZeroListenerID: number;\n+ opacityHitsZeroListenerID: ?number;\nnextMode: LoggedOutMode = \"prompt\";\nactiveAlert = false;\n@@ -106,6 +114,26 @@ class LoggedOutModal extends React.PureComponent {\nthis.keyboardHide,\n);\nBackAndroid.addEventListener('hardwareBackPress', this.hardwareBack);\n+ this.handleInitialURL().then();\n+ Linking.addEventListener('url', this.handleURLChange);\n+ }\n+\n+ async handleInitialURL() {\n+ const url = await Linking.getInitialURL();\n+ if (url) {\n+ this.dispatchActionForURL(url);\n+ }\n+ }\n+\n+ handleURLChange = (event: { url: string }) => {\n+ this.dispatchActionForURL(event.url);\n+ }\n+\n+ dispatchActionForURL(url: string) {\n+ if (!url.startsWith(\"http\")) {\n+ return;\n+ }\n+ this.props.dispatchActionPayload(\"HANDLE_URL\", url);\n}\ncomponentWillUnmount() {\n@@ -114,6 +142,7 @@ class LoggedOutModal extends React.PureComponent {\ninvariant(this.keyboardHideListener, \"should be set\");\nthis.keyboardHideListener.remove();\nBackAndroid.removeEventListener('hardwareBackPress', this.hardwareBack);\n+ Linking.removeEventListener('url', this.handleURLChange);\n}\nhardwareBack = () => {\n@@ -255,7 +284,7 @@ class LoggedOutModal extends React.PureComponent {\nconst background = (\n<Image\nsource={require(\"../img/logged-out-modal-background.jpg\")}\n- style={styles.loggedOutModalBackgroundContainer}\n+ style={styles.modalBackgroundContainer}\n/>\n);\n@@ -374,7 +403,7 @@ class LoggedOutModal extends React.PureComponent {\n}\nconst styles = StyleSheet.create({\n- loggedOutModalBackgroundContainer: {\n+ modalBackgroundContainer: {\nposition: 'absolute',\n},\ncontainer: {\n@@ -422,4 +451,7 @@ const styles = StyleSheet.create({\n},\n});\n-export default LoggedOutModal;\n+export default connect(\n+ null,\n+ includeDispatchActionProps({ dispatchActionPayload: true }),\n+)(LoggedOutModal);\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/account/verification-modal.react.js",
"diff": "+// @flow\n+\n+import type { NavigationScreenProp } from 'react-navigation';\n+\n+import React from 'react';\n+import {\n+ Image,\n+ Text,\n+ View,\n+ StyleSheet,\n+} from 'react-native';\n+\n+import ConnectedStatusBar from '../connected-status-bar.react';\n+\n+type VerificationModalNavProps = {\n+ verifyCode: string,\n+};\n+type Props = {\n+ navigation: NavigationScreenProp<VerificationModalNavProps, *>,\n+};\n+class VerificationModal extends React.PureComponent {\n+\n+ static propTypes = {\n+ navigation: React.PropTypes.shape({\n+ state: React.PropTypes.shape({\n+ params: React.PropTypes.shape({\n+ verifyCode: React.PropTypes.string.isRequired,\n+ }).isRequired,\n+ }).isRequired,\n+ }).isRequired,\n+ };\n+\n+ props: Props;\n+\n+ render() {\n+ const statusBar = <ConnectedStatusBar barStyle=\"light-content\" />;\n+ const background = (\n+ <Image\n+ source={require(\"../img/logged-out-modal-background.jpg\")}\n+ style={styles.modalBackgroundContainer}\n+ />\n+ );\n+ const header = (\n+ <Text style={styles.header}>\n+ {this.props.navigation.state.params.verifyCode}\n+ </Text>\n+ );\n+ return (\n+ <View style={styles.container}>\n+ {statusBar}\n+ {background}\n+ {header}\n+ </View>\n+ );\n+ }\n+\n+}\n+\n+const styles = StyleSheet.create({\n+ modalBackgroundContainer: {\n+ position: 'absolute',\n+ },\n+ container: {\n+ flex: 1,\n+ backgroundColor: 'transparent',\n+ },\n+ header: {\n+ fontFamily: 'Anaheim-Regular',\n+ color: 'white',\n+ fontSize: 48,\n+ textAlign: 'center',\n+ },\n+});\n+\n+export default VerificationModal;\n"
},
{
"change_type": "MODIFY",
"old_path": "native/android/app/build.gradle",
"new_path": "native/android/app/build.gradle",
"diff": "@@ -87,7 +87,7 @@ android {\nbuildToolsVersion \"23.0.1\"\ndefaultConfig {\n- applicationId \"com.squadcal\"\n+ applicationId \"org.squadcal\"\nminSdkVersion 16\ntargetSdkVersion 22\nversionCode 1\n"
},
{
"change_type": "MODIFY",
"old_path": "native/android/app/src/main/AndroidManifest.xml",
"new_path": "native/android/app/src/main/AndroidManifest.xml",
"diff": "<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n- package=\"com.squadcal\"\n+ package=\"org.squadcal\"\nandroid:versionCode=\"1\"\nandroid:versionName=\"1.0\">\nandroid:theme=\"@style/AppTheme\">\n<activity\nandroid:name=\".MainActivity\"\n+ android:launchMode=\"singleTask\"\nandroid:label=\"@string/app_name\"\nandroid:configChanges=\"keyboard|keyboardHidden|orientation|screenSize\"\nandroid:windowSoftInputMode=\"adjustResize\">\n<action android:name=\"android.intent.action.MAIN\" />\n<category android:name=\"android.intent.category.LAUNCHER\" />\n</intent-filter>\n+ <intent-filter android:autoVerify=\"true\">\n+ <action android:name=\"android.intent.action.VIEW\" />\n+ <category android:name=\"android.intent.category.DEFAULT\" />\n+ <category android:name=\"android.intent.category.BROWSABLE\" />\n+ <data android:scheme=\"http\" android:host=\"squadcal.org\" />\n+ <data android:scheme=\"https\" android:host=\"squadcal.org\" />\n+ <data android:scheme=\"http\" android:host=\"www.squadcal.org\" />\n+ <data android:scheme=\"https\" android:host=\"www.squadcal.org\" />\n+ </intent-filter>\n</activity>\n<activity android:name=\"com.facebook.react.devsupport.DevSettingsActivity\" />\n</application>\n"
},
{
"change_type": "RENAME",
"old_path": "native/android/app/src/main/java/com/squadcal/MainActivity.java",
"new_path": "native/android/app/src/main/java/org/squadcal/MainActivity.java",
"diff": "-package com.squadcal;\n+package org.squadcal;\nimport com.facebook.react.ReactActivity;\n"
},
{
"change_type": "RENAME",
"old_path": "native/android/app/src/main/java/com/squadcal/MainApplication.java",
"new_path": "native/android/app/src/main/java/org/squadcal/MainApplication.java",
"diff": "-package com.squadcal;\n+package org.squadcal;\nimport android.app.Application;\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+ 7FF0870D1E833C3F000A1ACF /* GameKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7FF0870C1E833C3F000A1ACF /* GameKit.framework */; };\n+ 7FF0870F1E833C47000A1ACF /* StoreKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7FF0870E1E833C47000A1ACF /* StoreKit.framework */; };\n832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 832341B51AAA6A8300B99B32 /* libRCTText.a */; };\n8894ACD632254222B23F69E2 /* Ionicons.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 4ACC468F28D944F293B91ACC /* Ionicons.ttf */; };\n98856FAEFDD5420882A5C010 /* libRNVectorIcons.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 414381A5DC394FE6BF2D28F3 /* libRNVectorIcons.a */; };\n7FB58ABC1E7F6BC600B4C1B1 /* OpenSans-Regular.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = \"OpenSans-Regular.ttf\"; sourceTree = \"<group>\"; };\n7FB58ABD1E7F6BC600B4C1B1 /* OpenSans-Semibold.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = \"OpenSans-Semibold.ttf\"; sourceTree = \"<group>\"; };\n7FCFD8BD1E81B8DF00629B0E /* SquadCal.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; name = SquadCal.entitlements; path = SquadCal/SquadCal.entitlements; sourceTree = \"<group>\"; };\n+ 7FF0870C1E833C3F000A1ACF /* GameKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GameKit.framework; path = System/Library/Frameworks/GameKit.framework; sourceTree = SDKROOT; };\n+ 7FF0870E1E833C47000A1ACF /* StoreKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = StoreKit.framework; path = System/Library/Frameworks/StoreKit.framework; sourceTree = SDKROOT; };\n832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = \"wrapper.pb-project\"; name = RCTText.xcodeproj; path = \"../node_modules/react-native/Libraries/Text/RCTText.xcodeproj\"; sourceTree = \"<group>\"; };\n8D919BA72D8545CBBBF6B74F /* MaterialCommunityIcons.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = MaterialCommunityIcons.ttf; path = \"../node_modules/react-native-vector-icons/Fonts/MaterialCommunityIcons.ttf\"; 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>\"; };\n00C302E91ABCBA2D00DB3ED1 /* libRCTNetwork.a in Frameworks */,\n139105C61AF99C1200B5F7CC /* libRCTSettings.a in Frameworks */,\n832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */,\n+ 7FF0870D1E833C3F000A1ACF /* GameKit.framework in Frameworks */,\n00C302EA1ABCBA2D00DB3ED1 /* libRCTVibration.a in Frameworks */,\n139FDEF61B0652A700C62182 /* libRCTWebSocket.a in Frameworks */,\n+ 7FF0870F1E833C47000A1ACF /* StoreKit.framework in Frameworks */,\n98856FAEFDD5420882A5C010 /* libRNVectorIcons.a in Frameworks */,\n3ACC3CE62D76452D871EE584 /* libOnePassword.a in Frameworks */,\n);\nname = Products;\nsourceTree = \"<group>\";\n};\n+ 7FF0870B1E833C3F000A1ACF /* Frameworks */ = {\n+ isa = PBXGroup;\n+ children = (\n+ 7FF0870E1E833C47000A1ACF /* StoreKit.framework */,\n+ 7FF0870C1E833C3F000A1ACF /* GameKit.framework */,\n+ );\n+ name = Frameworks;\n+ sourceTree = \"<group>\";\n+ };\n832341AE1AAA6A7D00B99B32 /* Libraries */ = {\nisa = PBXGroup;\nchildren = (\n00E356EF1AD99517003FC87E /* SquadCalTests */,\n83CBBA001A601CBA00E9B192 /* Products */,\n6534411766BE4CA4B0AB0A78 /* Resources */,\n+ 7FF0870B1E833C3F000A1ACF /* Frameworks */,\n);\nindentWidth = 2;\nsourceTree = \"<group>\";\nisa = PBXProject;\nattributes = {\nLastUpgradeCheck = 610;\n- ORGANIZATIONNAME = Facebook;\n+ ORGANIZATIONNAME = SquadCal;\nTargetAttributes = {\n00E356ED1AD99517003FC87E = {\nCreatedOnToolsVersion = 6.2;\n- DevelopmentTeam = CW2BC4VSCP;\n+ DevelopmentTeam = 6BF4H9TU5U;\nTestTargetID = 13B07F861A680F5B00A75B9A;\n};\n13B07F861A680F5B00A75B9A = {\nDevelopmentTeam = 6BF4H9TU5U;\nProvisioningStyle = Automatic;\nSystemCapabilities = {\n+ com.apple.GameCenter = {\n+ enabled = 1;\n+ };\n+ com.apple.InAppPurchase = {\n+ enabled = 1;\n+ };\n+ com.apple.Push = {\n+ enabled = 0;\n+ };\ncom.apple.SafariKeychain = {\nenabled = 1;\n};\n};\n2D02E47A1E0B4A5D006451C7 = {\nCreatedOnToolsVersion = 8.2.1;\n- DevelopmentTeam = CW2BC4VSCP;\n+ DevelopmentTeam = 6BF4H9TU5U;\nProvisioningStyle = Automatic;\n};\n2D02E48F1E0B4A5D006451C7 = {\nCreatedOnToolsVersion = 8.2.1;\n- DevelopmentTeam = CW2BC4VSCP;\n+ DevelopmentTeam = 6BF4H9TU5U;\nProvisioningStyle = Automatic;\nTestTargetID = 2D02E47A1E0B4A5D006451C7;\n};\nisa = XCBuildConfiguration;\nbuildSettings = {\nBUNDLE_LOADER = \"$(TEST_HOST)\";\n- DEVELOPMENT_TEAM = CW2BC4VSCP;\n+ DEVELOPMENT_TEAM = 6BF4H9TU5U;\nGCC_PREPROCESSOR_DEFINITIONS = (\n\"DEBUG=1\",\n\"$(inherited)\",\nbuildSettings = {\nBUNDLE_LOADER = \"$(TEST_HOST)\";\nCOPY_PHASE_STRIP = NO;\n- DEVELOPMENT_TEAM = CW2BC4VSCP;\n+ DEVELOPMENT_TEAM = 6BF4H9TU5U;\nHEADER_SEARCH_PATHS = (\n\"$(inherited)\",\n\"$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager\",\n\"$(inherited)\",\n\"$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager\",\n\"$(SRCROOT)/../node_modules/react-native-onepassword\",\n+ \"$(SRCROOT)/../node_modules/react-native/Libraries/LinkingIOS\",\n);\nINFOPLIST_FILE = SquadCal/Info.plist;\nLD_RUNPATH_SEARCH_PATHS = \"$(inherited) @executable_path/Frameworks\";\n\"$(inherited)\",\n\"$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager\",\n\"$(SRCROOT)/../node_modules/react-native-onepassword\",\n+ \"$(SRCROOT)/../node_modules/react-native/Libraries/LinkingIOS\",\n);\nINFOPLIST_FILE = SquadCal/Info.plist;\nLD_RUNPATH_SEARCH_PATHS = \"$(inherited) @executable_path/Frameworks\";\nCLANG_WARN_INFINITE_RECURSION = YES;\nCLANG_WARN_SUSPICIOUS_MOVE = YES;\nDEBUG_INFORMATION_FORMAT = dwarf;\n- DEVELOPMENT_TEAM = CW2BC4VSCP;\n+ DEVELOPMENT_TEAM = 6BF4H9TU5U;\nENABLE_TESTABILITY = YES;\nGCC_NO_COMMON_BLOCKS = YES;\nHEADER_SEARCH_PATHS = (\nCLANG_WARN_SUSPICIOUS_MOVE = YES;\nCOPY_PHASE_STRIP = NO;\nDEBUG_INFORMATION_FORMAT = \"dwarf-with-dsym\";\n- DEVELOPMENT_TEAM = CW2BC4VSCP;\n+ DEVELOPMENT_TEAM = 6BF4H9TU5U;\nGCC_NO_COMMON_BLOCKS = YES;\nHEADER_SEARCH_PATHS = (\n\"$(inherited)\",\nCLANG_WARN_INFINITE_RECURSION = YES;\nCLANG_WARN_SUSPICIOUS_MOVE = YES;\nDEBUG_INFORMATION_FORMAT = dwarf;\n- DEVELOPMENT_TEAM = CW2BC4VSCP;\n+ DEVELOPMENT_TEAM = 6BF4H9TU5U;\nENABLE_TESTABILITY = YES;\nGCC_NO_COMMON_BLOCKS = YES;\nINFOPLIST_FILE = \"SquadCal-tvOSTests/Info.plist\";\nCLANG_WARN_SUSPICIOUS_MOVE = YES;\nCOPY_PHASE_STRIP = NO;\nDEBUG_INFORMATION_FORMAT = \"dwarf-with-dsym\";\n- DEVELOPMENT_TEAM = CW2BC4VSCP;\n+ DEVELOPMENT_TEAM = 6BF4H9TU5U;\nGCC_NO_COMMON_BLOCKS = YES;\nINFOPLIST_FILE = \"SquadCal-tvOSTests/Info.plist\";\nLD_RUNPATH_SEARCH_PATHS = \"$(inherited) @executable_path/Frameworks @loader_path/Frameworks\";\n"
},
{
"change_type": "MODIFY",
"old_path": "native/ios/SquadCal/AppDelegate.m",
"new_path": "native/ios/SquadCal/AppDelegate.m",
"diff": "*/\n#import \"AppDelegate.h\"\n+#import \"RCTLinkingManager.h\"\n#import <React/RCTBundleURLProvider.h>\n#import <React/RCTRootView.h>\nreturn YES;\n}\n+- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity\n+ restorationHandler:(void (^)(NSArray * _Nullable))restorationHandler\n+{\n+ return [RCTLinkingManager application:application\n+ continueUserActivity:userActivity\n+ restorationHandler:restorationHandler];\n+}\n+\n@end\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"
},
{
"change_type": "MODIFY",
"old_path": "native/ios/SquadCal/Info.plist",
"new_path": "native/ios/SquadCal/Info.plist",
"diff": "<key>UIRequiredDeviceCapabilities</key>\n<array>\n<string>armv7</string>\n+ <string>gamekit</string>\n</array>\n<key>UISupportedInterfaceOrientations</key>\n<array>\n"
},
{
"change_type": "MODIFY",
"old_path": "native/navigation-setup.js",
"new_path": "native/navigation-setup.js",
"diff": "@@ -6,6 +6,7 @@ import Calendar from './calendar/calendar.react';\nimport Chat from './chat/chat.react';\nimport More from './more/more.react';\nimport LoggedOutModal from './account/logged-out-modal.react';\n+import VerificationModal from './account/verification-modal.react';\nconst AppNavigator = TabNavigator(\n{\n@@ -21,6 +22,7 @@ const AppNavigator = TabNavigator(\nexport const RootNavigator = StackNavigator(\n{\nLoggedOutModal: { screen: LoggedOutModal },\n+ VerificationModal: { screen: VerificationModal },\nApp: { screen: AppNavigator },\n},\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "native/redux-setup.js",
"new_path": "native/redux-setup.js",
"diff": "@@ -13,6 +13,7 @@ import React from 'react';\nimport invariant from 'invariant';\nimport baseReducer from 'lib/reducers/master-reducer';\n+import { partialNavInfoFromURL } from 'lib/utils/url-utils';\nimport { RootNavigator, defaultNavigationState } from './navigation-setup';\n@@ -38,9 +39,11 @@ export type AppState = {\ncookie: ?string,\n};\n-export type Action = BaseAction;\n+export type Action = BaseAction |\n+ { type: \"HANDLE_URL\", payload: string };\nfunction reduceNavInfo(state: NavInfo, action: Action): NavInfo {\n+ // React Navigation actions\nconst navigationState = RootNavigator.router.getStateForAction(\naction,\nstate.navigationState,\n@@ -48,6 +51,49 @@ function reduceNavInfo(state: NavInfo, action: Action): NavInfo {\nif (navigationState && navigationState !== state.navigationState) {\nreturn { ...state, navigationState };\n}\n+ // Deep linking\n+ if (action.type === \"HANDLE_URL\") {\n+ // Handle verification links. TODO also handle other URLs\n+ const partialNavInfo = partialNavInfoFromURL(action.payload);\n+ if (partialNavInfo.verify) {\n+ // Special-case behavior if there's already a VerificationModal\n+ const currentRoute =\n+ state.navigationState.routes[state.navigationState.index];\n+ if (currentRoute.key === 'VerificationModal') {\n+ const newRoute = {\n+ ...currentRoute,\n+ params: {\n+ verifyCode: partialNavInfo.verify,\n+ },\n+ };\n+ const newRoutes = [...state.navigationState.routes];\n+ newRoutes[state.navigationState.index] = newRoute;\n+ return {\n+ ...state,\n+ navigationState: {\n+ index: state.navigationState.index,\n+ routes: newRoutes,\n+ },\n+ };\n+ }\n+ return {\n+ ...state,\n+ navigationState: {\n+ index: state.navigationState.index + 1,\n+ routes: [\n+ ...state.navigationState.routes,\n+ {\n+ key: 'VerificationModal',\n+ routeName: 'VerificationModal',\n+ params: {\n+ verifyCode: partialNavInfo.verify,\n+ },\n+ },\n+ ],\n+ },\n+ };\n+ }\n+ }\nreturn state;\n}\n@@ -70,5 +116,8 @@ export function reducer(state: AppState, action: Action) {\nif (navInfo && navInfo !== state.navInfo) {\nstate = { ...state, navInfo };\n}\n+ if (action.type === \"HANDLE_URL\") {\n+ return state;\n+ }\nreturn baseReducer(state, action);\n}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "server/.well-known/assetlinks.json",
"diff": "+[\n+ {\n+ \"relation\": [\"delegate_permission/common.handle_all_urls\"],\n+ \"target\": {\n+ \"namespace\": \"android_app\",\n+ \"package_name\": \"org.squadcal\",\n+ \"sha256_cert_fingerprints\": [\n+ \"A8:81:32:91:5C:9A:D9:9E:14:68:1B:10:EA:5D:4E:D0:62:D0:BF:13:15:77:AA:BF:1D:C9:E6:67:ED:AD:E7:6F\",\n+ ],\n+ },\n+ },\n+]\n"
},
{
"change_type": "MODIFY",
"old_path": "web/url-utils.js",
"new_path": "web/url-utils.js",
"diff": "@@ -6,6 +6,8 @@ import type { NavInfo, AppState, Action } from './redux-setup';\nimport invariant from 'invariant';\nimport { createSelector } from 'reselect';\n+import { partialNavInfoFromURL } from 'lib/utils/url-utils';\n+\nfunction urlForYearAndMonth(year: number, month: number) {\nreturn `year/${year}/month/${month}/`;\n}\n@@ -38,46 +40,6 @@ const thisURL = createSelector(\nthisNavURLFragment + monthURL,\n);\n-\n-type PartialNavInfo = {\n- year?: number,\n- month?: number, // 1-indexed\n- home?: bool,\n- calendarID?: string,\n- verify?: string,\n-};\n-\n-function partialNavInfoFromURL(url: string): PartialNavInfo {\n- const yearMatches = new RegExp('(/|^)year/([0-9]+)(/|$)', 'i').exec(url);\n- const monthMatches = new RegExp('(/|^)month/([0-9]+)(/|$)', 'i').exec(url);\n- const calendarMatches = new RegExp('(/|^)calendar/([0-9]+)(/|$)', 'i')\n- .exec(url);\n- const verifyMatches = new RegExp('(/|^)verify/([a-f0-9]+)(/|$)', 'i')\n- .exec(url);\n- const homeTest = new RegExp('(/|^)home(/|$)', 'i').test(url);\n- invariant(\n- !homeTest || !calendarMatches,\n- 'home and calendar should never be set at the same time',\n- );\n- const returnObj = {};\n- if (yearMatches) {\n- returnObj.year = parseInt(yearMatches[2]);\n- }\n- if (monthMatches) {\n- returnObj.month = parseInt(monthMatches[2]);\n- }\n- if (calendarMatches) {\n- returnObj.calendarID = calendarMatches[2];\n- }\n- if (verifyMatches) {\n- returnObj.verify = verifyMatches[2];\n- }\n- if (homeTest) {\n- returnObj.home = true;\n- }\n- return returnObj;\n-}\n-\nfunction canonicalURLFromReduxState(navInfo: NavInfo, currentURL: string) {\nconst partialNavInfo = partialNavInfoFromURL(currentURL);\nlet newURL = urlForHomeAndCalendarID(navInfo.home, navInfo.calendarID);\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | A bunch of deep linking ("universal links") stuff |
129,187 | 23.03.2017 12:57:22 | 14,400 | e154c3b604c6fe7c3b6b31ccd60a4f73c4df880f | This one works at least | [
{
"change_type": "MODIFY",
"old_path": "server/.well-known/assetlinks.json",
"new_path": "server/.well-known/assetlinks.json",
"diff": "-[\n- {\n+[{\n\"relation\": [\"delegate_permission/common.handle_all_urls\"],\n\"target\": {\n\"namespace\": \"android_app\",\n\"package_name\": \"org.squadcal\",\n- \"sha256_cert_fingerprints\": [\n- \"A8:81:32:91:5C:9A:D9:9E:14:68:1B:10:EA:5D:4E:D0:62:D0:BF:13:15:77:AA:BF:1D:C9:E6:67:ED:AD:E7:6F\",\n- ],\n- },\n- },\n-]\n+ \"sha256_cert_fingerprints\": [\"A8:81:32:91:5C:9A:D9:9E:14:68:1B:10:EA:5D:4E:D0:62:D0:BF:13:15:77:AA:BF:1D:C9:E6:67:ED:AD:E7:6F\"]\n+ }\n+}]\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | This one works at least |
129,187 | 23.03.2017 12:59:54 | 14,400 | 70580bf73428149ab4fb1fd04094149344ee3df0 | Okay last update on this file until release signing hopefully | [
{
"change_type": "MODIFY",
"old_path": "server/.well-known/assetlinks.json",
"new_path": "server/.well-known/assetlinks.json",
"diff": "-[{\n- \"relation\": [\"delegate_permission/common.handle_all_urls\"],\n+[\n+ {\n+ \"relation\": [\n+ \"delegate_permission/common.handle_all_urls\",\n+ ],\n\"target\": {\n\"namespace\": \"android_app\",\n\"package_name\": \"org.squadcal\",\n- \"sha256_cert_fingerprints\": [\"A8:81:32:91:5C:9A:D9:9E:14:68:1B:10:EA:5D:4E:D0:62:D0:BF:13:15:77:AA:BF:1D:C9:E6:67:ED:AD:E7:6F\"]\n- }\n-}]\n+ \"sha256_cert_fingerprints\": [\n+ \"A8:81:32:91:5C:9A:D9:9E:14:68:1B:10:EA:5D:4E:D0:62:D0:BF:13:15:77:AA:BF:1D:C9:E6:67:ED:AD:E7:6F\",\n+ ],\n+ },\n+ },\n+]\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Okay last update on this file until release signing hopefully |
129,187 | 27.03.2017 17:10:02 | 14,400 | 23d4e6ba033d77020028ccba99ed35fad1caabc6 | Make sure to disable all panel buttons after they're clicked | [
{
"change_type": "MODIFY",
"old_path": "native/account/log-in-panel.react.js",
"new_path": "native/account/log-in-panel.react.js",
"diff": "@@ -90,7 +90,10 @@ class LogInPanel extends React.PureComponent {\nlet submitButton;\nif (Platform.OS === \"android\") {\nsubmitButton = (\n- <TouchableNativeFeedback onPress={this.onSubmit}>\n+ <TouchableNativeFeedback\n+ onPress={this.onSubmit}\n+ disabled={this.props.loadingStatus === \"loading\"}\n+ >\n<View style={[styles.submitContentContainer, styles.submitButton]}>\n<Text style={styles.submitContentText}>LOG IN</Text>\n{buttonIcon}\n@@ -103,6 +106,7 @@ class LogInPanel extends React.PureComponent {\nonPress={this.onSubmit}\nstyle={styles.submitButton}\nunderlayColor=\"#A0A0A0DD\"\n+ disabled={this.props.loadingStatus === \"loading\"}\n>\n<View style={styles.submitContentContainer}>\n<Text style={styles.submitContentText}>LOG IN</Text>\n"
},
{
"change_type": "MODIFY",
"old_path": "native/account/register-panel.react.js",
"new_path": "native/account/register-panel.react.js",
"diff": "@@ -101,7 +101,10 @@ class RegisterPanel extends React.PureComponent {\nlet submitButton;\nif (Platform.OS === \"android\") {\nsubmitButton = (\n- <TouchableNativeFeedback onPress={this.onSubmit}>\n+ <TouchableNativeFeedback\n+ onPress={this.onSubmit}\n+ disabled={this.props.loadingStatus === \"loading\"}\n+ >\n<View style={[styles.submitContentContainer, styles.submitButton]}>\n<Text style={styles.submitContentText}>SIGN UP</Text>\n{buttonIcon}\n@@ -114,6 +117,7 @@ class RegisterPanel extends React.PureComponent {\nonPress={this.onSubmit}\nstyle={styles.submitButton}\nunderlayColor=\"#A0A0A0DD\"\n+ disabled={this.props.loadingStatus === \"loading\"}\n>\n<View style={styles.submitContentContainer}>\n<Text style={styles.submitContentText}>SIGN UP</Text>\n"
},
{
"change_type": "MODIFY",
"old_path": "native/account/reset-password-panel.react.js",
"new_path": "native/account/reset-password-panel.react.js",
"diff": "@@ -92,7 +92,10 @@ class ResetPasswordPanel extends React.PureComponent {\nlet submitButton;\nif (Platform.OS === \"android\") {\nsubmitButton = (\n- <TouchableNativeFeedback onPress={this.onSubmit}>\n+ <TouchableNativeFeedback\n+ onPress={this.onSubmit}\n+ disabled={this.props.loadingStatus === \"loading\"}\n+ >\n<View style={[styles.submitContentContainer, styles.submitButton]}>\n<Text style={styles.submitContentText}>RESET PASSWORD</Text>\n{buttonIcon}\n@@ -105,6 +108,7 @@ class ResetPasswordPanel extends React.PureComponent {\nonPress={this.onSubmit}\nstyle={styles.submitButton}\nunderlayColor=\"#A0A0A0DD\"\n+ disabled={this.props.loadingStatus === \"loading\"}\n>\n<View style={styles.submitContentContainer}>\n<Text style={styles.submitContentText}>RESET PASSWORD</Text>\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Make sure to disable all panel buttons after they're clicked |
129,187 | 28.03.2017 21:50:29 | 14,400 | ef056dd278e19f87b34f6c3fd32ddb3f323cb6f4 | Forgot password modal! | [
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/account/forgot-password-panel.react.js",
"diff": "+// @flow\n+\n+import type { AppState } from '../redux-setup';\n+import type { LoadingStatus } from 'lib/types/loading-types';\n+import type { DispatchActionPromise } from 'lib/utils/action-utils';\n+\n+import React from 'react';\n+import { connect } from 'react-redux';\n+import {\n+ StyleSheet,\n+ View,\n+ ActivityIndicator,\n+ Platform,\n+ TouchableNativeFeedback,\n+ TouchableHighlight,\n+ Text,\n+ Animated,\n+ Alert,\n+ Keyboard,\n+} from 'react-native';\n+import Icon from 'react-native-vector-icons/FontAwesome';\n+import invariant from 'invariant';\n+\n+import { createLoadingStatusSelector } from 'lib/selectors/loading-selectors';\n+import {\n+ forgotPasswordActionType,\n+ forgotPassword,\n+} from 'lib/actions/user-actions';\n+import {\n+ includeDispatchActionProps,\n+ bindServerCalls,\n+} from 'lib/utils/action-utils';\n+import {\n+ validUsernameRegex,\n+ validEmailRegex,\n+} from 'lib/shared/account-regexes';\n+\n+import { TextInput } from '../modal-components.react';\n+\n+class ForgotPasswordPanel extends React.PureComponent {\n+\n+ props: {\n+ setActiveAlert: (activeAlert: bool) => void,\n+ opacityValue: Animated.Value,\n+ onSuccess: () => void,\n+ // Redux state\n+ loadingStatus: LoadingStatus,\n+ // Redux dispatch functions\n+ dispatchActionPromise: DispatchActionPromise,\n+ // async functions that hit server APIs\n+ forgotPassword: (usernameOrEmail: string) => Promise<void>,\n+ };\n+ static propTypes = {\n+ setActiveAlert: React.PropTypes.func.isRequired,\n+ opacityValue: React.PropTypes.object.isRequired,\n+ onSuccess: React.PropTypes.func.isRequired,\n+ loadingStatus: React.PropTypes.string.isRequired,\n+ dispatchActionPromise: React.PropTypes.func.isRequired,\n+ forgotPassword: React.PropTypes.func.isRequired,\n+ };\n+ state: {\n+ usernameOrEmailInputText: string,\n+ } = {\n+ usernameOrEmailInputText: \"\",\n+ };\n+ usernameOrEmailInput: ?TextInput;\n+\n+ render() {\n+ let buttonIcon;\n+ if (this.props.loadingStatus === \"loading\") {\n+ buttonIcon = (\n+ <View style={styles.loadingIndicatorContainer}>\n+ <ActivityIndicator color=\"#555\" />\n+ </View>\n+ );\n+ } else {\n+ buttonIcon = (\n+ <View style={styles.submitContentIconContainer}>\n+ <Icon name=\"arrow-right\" size={16} color=\"#555\" />\n+ </View>\n+ );\n+ }\n+ let submitButton;\n+ if (Platform.OS === \"android\") {\n+ submitButton = (\n+ <TouchableNativeFeedback\n+ onPress={this.onSubmit}\n+ disabled={this.props.loadingStatus === \"loading\"}\n+ >\n+ <View style={[styles.submitContentContainer, styles.submitButton]}>\n+ <Text style={styles.submitContentText}>RESET PASSWORD</Text>\n+ {buttonIcon}\n+ </View>\n+ </TouchableNativeFeedback>\n+ );\n+ } else {\n+ submitButton = (\n+ <TouchableHighlight\n+ onPress={this.onSubmit}\n+ style={styles.submitButton}\n+ underlayColor=\"#A0A0A0DD\"\n+ disabled={this.props.loadingStatus === \"loading\"}\n+ >\n+ <View style={styles.submitContentContainer}>\n+ <Text style={styles.submitContentText}>RESET PASSWORD</Text>\n+ {buttonIcon}\n+ </View>\n+ </TouchableHighlight>\n+ );\n+ }\n+ const opacityStyle = { opacity: this.props.opacityValue };\n+ return (\n+ <Animated.View style={[styles.container, opacityStyle]}>\n+ <View>\n+ <Icon name=\"user\" size={22} color=\"#777\" style={styles.icon} />\n+ <TextInput\n+ style={styles.input}\n+ value={this.state.usernameOrEmailInputText}\n+ onChangeText={this.onChangeUsernameOrEmailInputText}\n+ placeholder=\"Username or email address\"\n+ autoFocus={true}\n+ autoCorrect={false}\n+ autoCapitalize=\"none\"\n+ keyboardType=\"ascii-capable\"\n+ returnKeyType='go'\n+ blurOnSubmit={false}\n+ onSubmitEditing={this.onSubmit}\n+ editable={this.props.loadingStatus !== \"loading\"}\n+ ref={this.usernameOrEmailInputRef}\n+ />\n+ </View>\n+ {submitButton}\n+ </Animated.View>\n+ );\n+ }\n+\n+ usernameOrEmailInputRef = (usernameOrEmailInput: ?TextInput) => {\n+ this.usernameOrEmailInput = usernameOrEmailInput;\n+ }\n+\n+ onChangeUsernameOrEmailInputText = (text: string) => {\n+ this.setState({ usernameOrEmailInputText: text });\n+ }\n+\n+ onSubmit = () => {\n+ this.props.setActiveAlert(true);\n+ if (\n+ this.state.usernameOrEmailInputText.search(validUsernameRegex) === -1 &&\n+ this.state.usernameOrEmailInputText.search(validEmailRegex) === -1\n+ ) {\n+ Alert.alert(\n+ \"Invalid username\",\n+ \"Alphanumeric usernames or emails only\",\n+ [\n+ { text: 'OK', onPress: this.onUsernameOrEmailAlertAcknowledged },\n+ ],\n+ { cancelable: false },\n+ );\n+ return;\n+ }\n+\n+ Keyboard.dismiss();\n+ this.props.dispatchActionPromise(\n+ forgotPasswordActionType,\n+ this.forgotPasswordAction(),\n+ );\n+ }\n+\n+ onUsernameOrEmailAlertAcknowledged = () => {\n+ this.props.setActiveAlert(false);\n+ this.setState(\n+ {\n+ usernameOrEmailInputText: \"\",\n+ },\n+ () => {\n+ invariant(this.usernameOrEmailInput, \"ref should exist\");\n+ this.usernameOrEmailInput.focus();\n+ },\n+ );\n+ }\n+\n+ async forgotPasswordAction() {\n+ try {\n+ await this.props.forgotPassword(this.state.usernameOrEmailInputText);\n+ this.props.setActiveAlert(false);\n+ this.props.onSuccess();\n+ } catch (e) {\n+ if (e.message === 'invalid_user') {\n+ Alert.alert(\n+ \"User doesn't exist\",\n+ \"No user with that username or email exists\",\n+ [\n+ { text: 'OK', onPress: this.onUsernameOrEmailAlertAcknowledged },\n+ ],\n+ { cancelable: false },\n+ );\n+ } else {\n+ Alert.alert(\n+ \"Unknown error\",\n+ \"Uhh... try again?\",\n+ [\n+ { text: 'OK', onPress: this.onUsernameOrEmailAlertAcknowledged },\n+ ],\n+ { cancelable: false },\n+ );\n+ }\n+ throw e;\n+ }\n+ }\n+\n+}\n+\n+const styles = StyleSheet.create({\n+ submitContentIconContainer: {\n+ width: 14,\n+ paddingBottom: 5,\n+ },\n+ loadingIndicatorContainer: {\n+ width: 14,\n+ paddingBottom: 2,\n+ },\n+ submitButton: {\n+ position: 'absolute',\n+ bottom: 0,\n+ right: 0,\n+ borderBottomRightRadius: 6,\n+ },\n+ submitContentContainer: {\n+ flexDirection: 'row',\n+ alignItems: 'flex-end',\n+ paddingLeft: 18,\n+ paddingTop: 6,\n+ paddingRight: 18,\n+ paddingBottom: 6,\n+ },\n+ submitContentText: {\n+ fontSize: 18,\n+ fontFamily: 'OpenSans-Semibold',\n+ color: \"#555\",\n+ paddingRight: 7,\n+ },\n+ container: {\n+ paddingBottom: 37,\n+ paddingTop: 6,\n+ paddingLeft: 18,\n+ paddingRight: 18,\n+ marginLeft: 20,\n+ marginRight: 20,\n+ marginTop: 40,\n+ borderRadius: 6,\n+ backgroundColor: '#FFFFFFAA',\n+ },\n+ input: {\n+ paddingLeft: 35,\n+ },\n+ icon: {\n+ position: 'absolute',\n+ bottom: 8,\n+ left: 4,\n+ },\n+});\n+\n+const loadingStatusSelector\n+ = createLoadingStatusSelector(forgotPasswordActionType);\n+\n+export default connect(\n+ (state: AppState) => ({\n+ cookie: state.cookie,\n+ loadingStatus: loadingStatusSelector(state),\n+ }),\n+ includeDispatchActionProps({ dispatchActionPromise: true }),\n+ bindServerCalls({ forgotPassword }),\n+)(ForgotPasswordPanel);\n"
},
{
"change_type": "MODIFY",
"old_path": "native/account/log-in-panel.react.js",
"new_path": "native/account/log-in-panel.react.js",
"diff": "@@ -44,6 +44,7 @@ class LogInPanel extends React.PureComponent {\nsetActiveAlert: (activeAlert: bool) => void,\nopacityValue: Animated.Value,\nonePasswordSupported: bool,\n+ innerRef: (logInPanel: LogInPanel) => void,\n// Redux state\nloadingStatus: LoadingStatus,\n// Redux dispatch functions\n@@ -58,6 +59,7 @@ class LogInPanel extends React.PureComponent {\nsetActiveAlert: React.PropTypes.func.isRequired,\nopacityValue: React.PropTypes.object.isRequired,\nonePasswordSupported: React.PropTypes.bool.isRequired,\n+ innerRef: React.PropTypes.func.isRequired,\nloadingStatus: React.PropTypes.string.isRequired,\ndispatchActionPromise: React.PropTypes.func.isRequired,\nlogIn: React.PropTypes.func.isRequired,\n@@ -72,6 +74,10 @@ class LogInPanel extends React.PureComponent {\nusernameOrEmailInput: ?TextInput;\npasswordInput: ?TextInput;\n+ componentDidMount() {\n+ this.props.innerRef(this);\n+ }\n+\nrender() {\nlet buttonIcon;\nif (this.props.loadingStatus === \"loading\") {\n@@ -174,6 +180,11 @@ class LogInPanel extends React.PureComponent {\nthis.usernameOrEmailInput = usernameOrEmailInput;\n}\n+ focusUsernameOrEmailInput = () => {\n+ invariant(this.usernameOrEmailInput, \"ref should be set\");\n+ this.usernameOrEmailInput.focus();\n+ }\n+\npasswordInputRef = (passwordInput: ?TextInput) => {\nthis.passwordInput = passwordInput;\n}\n@@ -192,11 +203,11 @@ class LogInPanel extends React.PureComponent {\n}\nonSubmit = () => {\n+ this.props.setActiveAlert(true);\nif (\nthis.state.usernameOrEmailInputText.search(validUsernameRegex) === -1 &&\nthis.state.usernameOrEmailInputText.search(validEmailRegex) === -1\n) {\n- this.props.setActiveAlert(true);\nAlert.alert(\n\"Invalid username\",\n\"Alphanumeric usernames or emails only\",\n@@ -227,12 +238,13 @@ class LogInPanel extends React.PureComponent {\nasync logInAction() {\ntry {\n- return await this.props.logIn(\n+ const result = await this.props.logIn(\nthis.state.usernameOrEmailInputText,\nthis.state.passwordInputText,\n);\n+ this.props.setActiveAlert(false);\n+ return result;\n} catch (e) {\n- this.props.setActiveAlert(true);\nif (e.message === 'invalid_parameters') {\nAlert.alert(\n\"Invalid username\",\n@@ -305,6 +317,8 @@ class LogInPanel extends React.PureComponent {\n}\n+export type InnerLogInPanel = LogInPanel;\n+\nconst styles = StyleSheet.create({\ncontainer: {\npaddingBottom: 37,\n"
},
{
"change_type": "MODIFY",
"old_path": "native/account/logged-out-modal.react.js",
"new_path": "native/account/logged-out-modal.react.js",
"diff": "import type { NavigationScreenProp } from 'react-navigation';\nimport type { DispatchActionPayload } from 'lib/utils/action-utils';\n+import type { InnerLogInPanel } from './log-in-panel.react';\nimport React from 'react';\nimport {\n@@ -16,9 +17,9 @@ import {\nKeyboard,\nAlert,\nPlatform,\n- Dimensions,\nBackAndroid,\nLinking,\n+ Dimensions,\n} from 'react-native';\nimport invariant from 'invariant';\nimport Icon from 'react-native-vector-icons/FontAwesome';\n@@ -26,9 +27,12 @@ import OnePassword from 'react-native-onepassword';\nimport { connect } from 'react-redux';\nimport { includeDispatchActionProps } from 'lib/utils/action-utils';\n+import sleep from 'lib/utils/sleep';\n+import { windowHeight, windowWidth } from '../dimensions';\nimport LogInPanel from './log-in-panel.react';\nimport RegisterPanel from './register-panel.react';\n+import ForgotPasswordPanel from './forgot-password-panel.react';\nimport ConnectedStatusBar from '../connected-status-bar.react';\ntype KeyboardEvent = {\n@@ -41,6 +45,7 @@ type KeyboardEvent = {\n},\n};\ntype LoggedOutMode = \"prompt\" | \"log-in\" | \"register\";\n+type LogInMode = \"log-in\" | \"forgot-password\" | \"forgot-password-success\";\ntype Props = {\nnavigation: NavigationScreenProp<*, *>,\n// Redux dispatch functions\n@@ -48,8 +53,13 @@ type Props = {\n};\ntype State = {\nmode: LoggedOutMode,\n- paddingTop: Animated.Value,\n- opacityValue: Animated.Value,\n+ logInMode: LogInMode,\n+ nextLogInMode: LogInMode,\n+ panelPaddingTop: Animated.Value,\n+ footerPaddingTop: Animated.Value,\n+ panelOpacity: Animated.Value,\n+ forgotPasswordLinkOpacity: Animated.Value,\n+ logInPanelTransition: Animated.Value,\nonePasswordSupported: bool,\n};\n@@ -58,10 +68,17 @@ class LoggedOutModal extends React.PureComponent {\nprops: Props;\nstate: State = {\nmode: \"prompt\",\n- paddingTop: new Animated.Value(\n- LoggedOutModal.currentPaddingTop(\"prompt\", 0),\n+ logInMode: \"log-in\",\n+ nextLogInMode: \"log-in\",\n+ panelPaddingTop: new Animated.Value(\n+ LoggedOutModal.calculatePanelPaddingTop(\"prompt\", 0),\n),\n- opacityValue: new Animated.Value(0),\n+ footerPaddingTop: new Animated.Value(\n+ LoggedOutModal.calculateFooterPaddingTop(0),\n+ ),\n+ panelOpacity: new Animated.Value(0),\n+ forgotPasswordLinkOpacity: new Animated.Value(0),\n+ logInPanelTransition: new Animated.Value(0),\nonePasswordSupported: false,\n};\nstatic propTypes = {\n@@ -81,13 +98,13 @@ class LoggedOutModal extends React.PureComponent {\nkeyboardShowListener: ?EmitterSubscription;\nkeyboardHideListener: ?EmitterSubscription;\n- opacityHitsZeroListenerID: ?number;\n-\nnextMode: LoggedOutMode = \"prompt\";\nactiveAlert = false;\nactiveKeyboard = false;\nopacityChangeQueued = false;\nkeyboardHeight = 0;\n+ lastPanelPaddingTopValue: ?number = null;\n+ logInPanel: ?InnerLogInPanel = null;\nconstructor(props: Props) {\nsuper(props);\n@@ -146,6 +163,12 @@ class LoggedOutModal extends React.PureComponent {\n}\nhardwareBack = () => {\n+ if (this.nextMode === \"log-in\") {\n+ const returnValue = this.backFromLogInMode();\n+ if (returnValue) {\n+ return true;\n+ }\n+ }\nif (this.nextMode !== \"prompt\") {\nthis.goBackToPrompt();\nreturn true;\n@@ -153,15 +176,10 @@ class LoggedOutModal extends React.PureComponent {\nreturn false;\n}\n- static currentPaddingTop(\n+ static calculatePanelPaddingTop(\nmode: LoggedOutMode,\nkeyboardHeight: number,\n) {\n- let { height } = Dimensions.get('window');\n- if (Platform.OS === \"android\") {\n- // Android's Dimensions.get doesn't include the status bar\n- height -= 24;\n- }\nlet containerSize = Platform.OS === \"ios\" ? 62 : 59; // header height\nif (mode === \"log-in\") {\ncontainerSize += 165;\n@@ -172,28 +190,61 @@ class LoggedOutModal extends React.PureComponent {\n// weird because the buttons are at the bottom\ncontainerSize += 80;\n}\n- return (height - containerSize - keyboardHeight) / 2;\n+ return (windowHeight - containerSize - keyboardHeight) / 2;\n+ }\n+\n+ static calculateFooterPaddingTop(keyboardHeight: number) {\n+ const textHeight = Platform.OS === \"ios\" ? 17 : 19;\n+ return windowHeight - keyboardHeight - textHeight - 20;\n}\n- animateToSecondMode(inputDuration: ?number) {\n+ animateToSecondMode(inputDuration: ?number, realKeyboardHeight: ?number) {\nconst duration = inputDuration ? inputDuration : 150;\n- const animations = [\n+ if (!realKeyboardHeight) {\n+ realKeyboardHeight = this.keyboardHeight;\n+ }\n+ const animations = [];\n+ const newPanelPaddingTopValue = LoggedOutModal.calculatePanelPaddingTop(\n+ this.state.mode,\n+ this.keyboardHeight,\n+ );\n+ if (newPanelPaddingTopValue !== this.lastPanelPaddingTopValue) {\n+ this.lastPanelPaddingTopValue = newPanelPaddingTopValue;\n+ animations.push(\nAnimated.timing(\n- this.state.paddingTop,\n+ this.state.panelPaddingTop,\n{\nduration,\neasing: Easing.out(Easing.ease),\n- toValue: LoggedOutModal.currentPaddingTop(\n- this.state.mode,\n- this.keyboardHeight,\n+ toValue: newPanelPaddingTopValue,\n+ },\n),\n+ );\n+ }\n+ animations.push(\n+ Animated.timing(\n+ this.state.footerPaddingTop,\n+ {\n+ duration,\n+ easing: Easing.out(Easing.ease),\n+ toValue: LoggedOutModal.calculateFooterPaddingTop(realKeyboardHeight),\n},\n),\n- ];\n+ );\nif (this.opacityChangeQueued) {\nanimations.push(\nAnimated.timing(\n- this.state.opacityValue,\n+ this.state.panelOpacity,\n+ {\n+ duration,\n+ easing: Easing.out(Easing.ease),\n+ toValue: 1,\n+ },\n+ ),\n+ );\n+ animations.push(\n+ Animated.timing(\n+ this.state.forgotPasswordLinkOpacity,\n{\nduration,\neasing: Easing.out(Easing.ease),\n@@ -206,33 +257,56 @@ class LoggedOutModal extends React.PureComponent {\n}\nkeyboardShow = (event: KeyboardEvent) => {\n- this.keyboardHeight = event.endCoordinates.height;\n- if (this.activeKeyboard) {\n+ if (!this.activeKeyboard) {\n// We do this because the Android keyboard can change in height and we\n- // don't want to bother animating between those events\n- return;\n+ // don't want to bother moving the panel between those events\n+ this.keyboardHeight = event.endCoordinates.height;\n}\nthis.activeKeyboard = true;\n- this.animateToSecondMode(event.duration);\n+ this.animateToSecondMode(event.duration, event.endCoordinates.height);\nthis.opacityChangeQueued = false;\n}\nanimateKeyboardDownOrBackToPrompt(inputDuration: ?number) {\nconst duration = inputDuration ? inputDuration : 250;\n+ this.lastPanelPaddingTopValue = LoggedOutModal.calculatePanelPaddingTop(\n+ this.nextMode,\n+ 0,\n+ );\nconst animations = [\nAnimated.timing(\n- this.state.paddingTop,\n+ this.state.panelPaddingTop,\n{\nduration,\neasing: Easing.out(Easing.ease),\n- toValue: LoggedOutModal.currentPaddingTop(this.nextMode, 0),\n+ toValue: this.lastPanelPaddingTopValue,\n+ },\n+ ),\n+ Animated.timing(\n+ this.state.footerPaddingTop,\n+ {\n+ duration,\n+ easing: Easing.out(Easing.ease),\n+ toValue: LoggedOutModal.calculateFooterPaddingTop(\n+ this.keyboardHeight,\n+ ),\n},\n),\n];\nif (this.opacityChangeQueued) {\nanimations.push(\nAnimated.timing(\n- this.state.opacityValue,\n+ this.state.panelOpacity,\n+ {\n+ duration,\n+ easing: Easing.out(Easing.ease),\n+ toValue: 0,\n+ },\n+ ),\n+ );\n+ animations.push(\n+ Animated.timing(\n+ this.state.forgotPasswordLinkOpacity,\n{\nduration,\neasing: Easing.out(Easing.ease),\n@@ -246,10 +320,10 @@ class LoggedOutModal extends React.PureComponent {\nkeyboardHide = (event: ?KeyboardEvent) => {\nthis.keyboardHeight = 0;\n+ this.activeKeyboard = false;\nif (this.activeAlert) {\nreturn;\n}\n- this.activeKeyboard = false;\nthis.animateKeyboardDownOrBackToPrompt(event && event.duration);\nthis.opacityChangeQueued = false;\n}\n@@ -259,10 +333,18 @@ class LoggedOutModal extends React.PureComponent {\n}\ngoBackToPrompt = () => {\n- this.opacityHitsZeroListenerID =\n- this.state.opacityValue.addListener(this.opacityListener);\n+ let opacityListenerID = -1;\n+ const opacityListener = (animatedUpdate: { value: number }) => {\n+ if (animatedUpdate.value === 0) {\n+ this.setState({ mode: this.nextMode });\n+ this.state.panelOpacity.removeListener(opacityListenerID);\n+ }\n+ }\n+ opacityListenerID = this.state.panelOpacity.addListener(opacityListener);\n+\nthis.opacityChangeQueued = true;\nthis.nextMode = \"prompt\";\n+\nif (this.activeKeyboard) {\n// If keyboard is currently active, keyboardHide will handle the\n// animation. This is so we can run all animations in parallel\n@@ -272,13 +354,6 @@ class LoggedOutModal extends React.PureComponent {\n}\n}\n- opacityListener = (animatedUpdate: { value: number }) => {\n- if (animatedUpdate.value === 0) {\n- this.setState({ mode: this.nextMode });\n- this.state.opacityValue.removeListener(this.opacityHitsZeroListenerID);\n- }\n- }\n-\nrender() {\nconst statusBar = <ConnectedStatusBar barStyle=\"light-content\" />;\nconst background = (\n@@ -291,18 +366,97 @@ class LoggedOutModal extends React.PureComponent {\nlet panel = null;\nlet buttons = null;\nif (this.state.mode === \"log-in\") {\n- panel = (\n+ const logInPanelDynamicStyle = {\n+ left: this.state.logInPanelTransition.interpolate({\n+ inputRange: [0, 2],\n+ outputRange: [0, windowWidth * -2],\n+ }),\n+ right: this.state.logInPanelTransition.interpolate({\n+ inputRange: [0, 2],\n+ outputRange: [0, windowWidth * 2],\n+ }),\n+ };\n+ const logInPanel = (\n+ <Animated.View style={[styles.logInSubPanel, logInPanelDynamicStyle]}>\n<LogInPanel\nsetActiveAlert={this.setActiveAlert}\n- opacityValue={this.state.opacityValue}\n+ opacityValue={this.state.panelOpacity}\nonePasswordSupported={this.state.onePasswordSupported}\n+ innerRef={this.logInPanelRef}\n+ />\n+ </Animated.View>\n+ );\n+ let forgotPasswordPanel = null;\n+ if (\n+ this.state.nextLogInMode !== \"log-in\" ||\n+ this.state.logInMode !== \"log-in\"\n+ ) {\n+ const forgotPasswordPanelDynamicStyle = {\n+ left: this.state.logInPanelTransition.interpolate({\n+ inputRange: [0, 2],\n+ outputRange: [windowWidth, windowWidth * -1],\n+ }),\n+ right: this.state.logInPanelTransition.interpolate({\n+ inputRange: [0, 2],\n+ outputRange: [windowWidth * -1, windowWidth],\n+ }),\n+ };\n+ forgotPasswordPanel = (\n+ <Animated.View\n+ style={[styles.logInSubPanel, forgotPasswordPanelDynamicStyle]}\n+ >\n+ <ForgotPasswordPanel\n+ setActiveAlert={this.setActiveAlert}\n+ opacityValue={this.state.panelOpacity}\n+ onSuccess={this.onForgotPasswordSuccess}\n+ />\n+ </Animated.View>\n+ );\n+ }\n+ let forgotPasswordSuccess = null;\n+ if (\n+ this.state.nextLogInMode === \"forgot-password-success\" ||\n+ this.state.logInMode === \"forgot-password-success\"\n+ ) {\n+ const forgotPasswordSuccessDynamicStyle = {\n+ left: this.state.logInPanelTransition.interpolate({\n+ inputRange: [0, 2],\n+ outputRange: [windowWidth * 2, 0],\n+ }),\n+ right: this.state.logInPanelTransition.interpolate({\n+ inputRange: [0, 2],\n+ outputRange: [windowWidth * -2, 0],\n+ }),\n+ };\n+ forgotPasswordSuccess = (\n+ <Animated.View\n+ style={[styles.logInSubPanel, forgotPasswordSuccessDynamicStyle]}\n+ >\n+ <Icon\n+ name=\"check-circle\"\n+ size={48}\n+ color=\"#88FF88DD\"\n+ style={styles.forgotPasswordSuccessIcon}\n/>\n+ <Text style={styles.forgotPasswordSuccessText}>\n+ Okay, we've sent that account an email. Check your inbox to\n+ complete the process.\n+ </Text>\n+ </Animated.View>\n+ );\n+ }\n+ panel = (\n+ <View>\n+ {logInPanel}\n+ {forgotPasswordPanel}\n+ {forgotPasswordSuccess}\n+ </View>\n);\n} else if (this.state.mode === \"register\") {\npanel = (\n<RegisterPanel\nsetActiveAlert={this.setActiveAlert}\n- opacityValue={this.state.opacityValue}\n+ opacityValue={this.state.panelOpacity}\nonePasswordSupported={this.state.onePasswordSupported}\n/>\n);\n@@ -331,14 +485,34 @@ class LoggedOutModal extends React.PureComponent {\n);\n}\n- const padding = { paddingTop: this.state.paddingTop };\n- const opacity = { opacity: this.state.opacityValue };\n+ let forgotPasswordLink = null;\n+ if (this.state.mode === \"log-in\") {\n+ const dynamicStyle = {\n+ opacity: this.state.forgotPasswordLinkOpacity,\n+ top: this.state.footerPaddingTop,\n+ };\n+ forgotPasswordLink = (\n+ <Animated.View\n+ style={[styles.forgotPasswordTextContainer, dynamicStyle]}\n+ >\n+ <TouchableOpacity\n+ activeOpacity={0.6}\n+ onPress={this.onPressForgotPassword}\n+ >\n+ <Text style={styles.forgotPasswordText}>Forgot password?</Text>\n+ </TouchableOpacity>\n+ </Animated.View>\n+ );\n+ }\n+\n+ const padding = { paddingTop: this.state.panelPaddingTop };\n+ const opacity = { opacity: this.state.panelOpacity };\nconst animatedContent = (\n<Animated.View style={[styles.animationContainer, padding]}>\n<View>\n<Text style={styles.header}>SquadCal</Text>\n<Animated.View style={[styles.backButton, opacity]}>\n- <TouchableOpacity activeOpacity={0.6} onPress={this.goBackToPrompt}>\n+ <TouchableOpacity activeOpacity={0.6} onPress={this.hardwareBack}>\n<Icon\nname=\"arrow-circle-o-left\"\nsize={36}\n@@ -362,6 +536,7 @@ class LoggedOutModal extends React.PureComponent {\n{background}\n{animatedContent}\n{buttons}\n+ {forgotPasswordLink}\n</View>\n);\n} else {\n@@ -371,11 +546,16 @@ class LoggedOutModal extends React.PureComponent {\n{background}\n{buttons}\n{animatedContent}\n+ {forgotPasswordLink}\n</View>\n);\n}\n}\n+ logInPanelRef = (logInPanel: ?InnerLogInPanel) => {\n+ this.logInPanel = logInPanel;\n+ }\n+\nonPressLogIn = () => {\nthis.opacityChangeQueued = true;\nthis.nextMode = \"log-in\";\n@@ -398,6 +578,121 @@ class LoggedOutModal extends React.PureComponent {\n}\n}\n+ onPressForgotPassword = () => {\n+ this.setState({ nextLogInMode: \"forgot-password\" });\n+\n+ const duration = 350;\n+ const animations = [\n+ Animated.timing(\n+ this.state.forgotPasswordLinkOpacity,\n+ {\n+ duration,\n+ easing: Easing.out(Easing.ease),\n+ toValue: 0,\n+ },\n+ ),\n+ Animated.timing(\n+ this.state.logInPanelTransition,\n+ {\n+ duration,\n+ easing: Easing.out(Easing.ease),\n+ toValue: 1,\n+ },\n+ ),\n+ ];\n+\n+ let listenerID = -1;\n+ const listener = (animatedUpdate: { value: number }) => {\n+ if (animatedUpdate.value === 1) {\n+ this.setState({ logInMode: this.state.nextLogInMode });\n+ this.state.logInPanelTransition.removeListener(listenerID);\n+ }\n+ }\n+ listenerID = this.state.logInPanelTransition.addListener(listener);\n+\n+ Animated.parallel(animations).start();\n+ }\n+\n+ backFromLogInMode = () => {\n+ if (this.state.nextLogInMode === \"log-in\") {\n+ return false;\n+ }\n+\n+ this.setState({\n+ logInMode: this.state.nextLogInMode,\n+ nextLogInMode: \"log-in\",\n+ });\n+ invariant(this.logInPanel, \"ref should be set\");\n+ this.logInPanel.focusUsernameOrEmailInput();\n+\n+ const duration = 350;\n+ const animations = [\n+ Animated.timing(\n+ this.state.forgotPasswordLinkOpacity,\n+ {\n+ duration,\n+ easing: Easing.out(Easing.ease),\n+ toValue: 1,\n+ },\n+ ),\n+ Animated.timing(\n+ this.state.logInPanelTransition,\n+ {\n+ duration,\n+ easing: Easing.out(Easing.ease),\n+ toValue: 0,\n+ },\n+ ),\n+ ];\n+\n+ let listenerID = -1;\n+ const listener = (animatedUpdate: { value: number }) => {\n+ if (animatedUpdate.value === 0) {\n+ this.setState({ logInMode: this.state.nextLogInMode });\n+ this.state.logInPanelTransition.removeListener(listenerID);\n+ }\n+ }\n+ listenerID = this.state.logInPanelTransition.addListener(listener);\n+\n+ Animated.parallel(animations).start();\n+ return true;\n+ }\n+\n+ onForgotPasswordSuccess = () => {\n+ if (this.state.nextLogInMode === \"log-in\") {\n+ return;\n+ }\n+\n+ this.setState({ nextLogInMode: \"forgot-password-success\" });\n+\n+ const duration = 350;\n+\n+ let listenerID = -1;\n+ const listener = (animatedUpdate: { value: number }) => {\n+ if (animatedUpdate.value === 2) {\n+ this.setState({ logInMode: this.state.nextLogInMode });\n+ this.state.logInPanelTransition.removeListener(listenerID);\n+ }\n+ }\n+ listenerID = this.state.logInPanelTransition.addListener(listener);\n+\n+ Animated.timing(\n+ this.state.logInPanelTransition,\n+ {\n+ duration,\n+ easing: Easing.out(Easing.ease),\n+ toValue: 2,\n+ },\n+ ).start();\n+\n+ this.inCoupleSecondsNavigateToLogIn().then();\n+ }\n+\n+ async inCoupleSecondsNavigateToLogIn() {\n+ await sleep(2350);\n+ this.backFromLogInMode();\n+ }\n+\n}\nconst styles = StyleSheet.create({\n@@ -447,6 +742,31 @@ const styles = StyleSheet.create({\ntextAlign: 'center',\ncolor: '#000000FF',\n},\n+ forgotPasswordTextContainer: {\n+ position: 'absolute',\n+ alignSelf: 'flex-end',\n+ right: 20,\n+ },\n+ forgotPasswordText: {\n+ color: '#8899FF',\n+ },\n+ logInSubPanel: {\n+ position: 'absolute',\n+ left: 0,\n+ right: 0,\n+ },\n+ forgotPasswordSuccessIcon: {\n+ marginTop: 40,\n+ textAlign: 'center',\n+ },\n+ forgotPasswordSuccessText: {\n+ marginTop: 10,\n+ marginLeft: 20,\n+ marginRight: 20,\n+ textAlign: 'center',\n+ color: 'white',\n+ fontSize: 18,\n+ },\n});\nexport default connect(\n"
},
{
"change_type": "MODIFY",
"old_path": "native/account/register-panel.react.js",
"new_path": "native/account/register-panel.react.js",
"diff": "@@ -265,8 +265,8 @@ class RegisterPanel extends React.PureComponent {\n}\nonSubmit = () => {\n- if (this.state.passwordInputText === '') {\nthis.props.setActiveAlert(true);\n+ if (this.state.passwordInputText === '') {\nAlert.alert(\n\"Empty password\",\n\"Password cannot be empty\",\n@@ -278,7 +278,6 @@ class RegisterPanel extends React.PureComponent {\n} else if (\nthis.state.passwordInputText !== this.state.confirmPasswordInputText\n) {\n- this.props.setActiveAlert(true);\nAlert.alert(\n\"Passwords don't match\",\n\"Password fields must contain the same password\",\n@@ -288,7 +287,6 @@ class RegisterPanel extends React.PureComponent {\n{ cancelable: false },\n);\n} else if (this.state.usernameInputText.search(validUsernameRegex) === -1) {\n- this.props.setActiveAlert(true);\nAlert.alert(\n\"Invalid username\",\n\"Alphanumeric usernames only\",\n@@ -298,7 +296,6 @@ class RegisterPanel extends React.PureComponent {\n{ cancelable: false },\n);\n} else if (this.state.emailInputText.search(validEmailRegex) === -1) {\n- this.props.setActiveAlert(true);\nAlert.alert(\n\"Invalid email address\",\n\"Valid email addresses only\",\n@@ -357,13 +354,14 @@ class RegisterPanel extends React.PureComponent {\nasync registerAction() {\ntry {\n- return await this.props.register(\n+ const result = await this.props.register(\nthis.state.usernameInputText,\nthis.state.emailInputText,\nthis.state.passwordInputText,\n);\n+ this.props.setActiveAlert(false);\n+ return result;\n} catch (e) {\n- this.props.setActiveAlert(true);\nif (e.message === 'username_taken') {\nAlert.alert(\n\"Username taken\",\n"
},
{
"change_type": "MODIFY",
"old_path": "native/account/reset-password-panel.react.js",
"new_path": "native/account/reset-password-panel.react.js",
"diff": "@@ -197,8 +197,8 @@ class ResetPasswordPanel extends React.PureComponent {\n}\nonSubmit = () => {\n- if (this.state.passwordInputText === '') {\nthis.props.setActiveAlert(true);\n+ if (this.state.passwordInputText === '') {\nAlert.alert(\n\"Empty password\",\n\"Password cannot be empty\",\n@@ -211,7 +211,6 @@ class ResetPasswordPanel extends React.PureComponent {\n} else if (\nthis.state.passwordInputText !== this.state.confirmPasswordInputText\n) {\n- this.props.setActiveAlert(true);\nAlert.alert(\n\"Passwords don't match\",\n\"Password fields must contain the same password\",\n@@ -245,12 +244,13 @@ class ResetPasswordPanel extends React.PureComponent {\nasync resetPasswordAction() {\ntry {\n- const response = await this.props.resetPassword(\n+ const result = await this.props.resetPassword(\nthis.props.verifyCode,\nthis.state.passwordInputText,\n);\n+ this.props.setActiveAlert(false);\nthis.props.onSuccess();\n- return response;\n+ return result;\n} catch (e) {\nAlert.alert(\n\"Unknown error\",\n"
},
{
"change_type": "MODIFY",
"old_path": "native/account/verification-modal.react.js",
"new_path": "native/account/verification-modal.react.js",
"diff": "@@ -19,7 +19,6 @@ import {\nActivityIndicator,\nAnimated,\nPlatform,\n- Dimensions,\nKeyboard,\nTouchableHighlight,\nEmitterSubscription,\n@@ -42,6 +41,7 @@ import {\nimport { verifyField } from 'lib/utils/verify-utils';\nimport sleep from 'lib/utils/sleep';\n+import { windowHeight } from '../dimensions';\nimport ConnectedStatusBar from '../connected-status-bar.react';\nimport ResetPasswordPanel from './reset-password-panel.react';\n@@ -109,7 +109,6 @@ class VerificationModal extends React.PureComponent {\nactiveKeyboard = false;\nopacityChangeQueued = false;\nkeyboardHeight = 0;\n- opacityHitsZeroListenerID: ?number;\nnextMode: VerificationModalMode = \"simple-text\";\nconstructor(props: Props) {\n@@ -185,12 +184,22 @@ class VerificationModal extends React.PureComponent {\n}\nonResetPasswordSuccess = () => {\n- this.opacityHitsZeroListenerID =\n- this.state.resetPasswordPanelOpacityValue.addListener(\n- this.opacityListener,\n+ let opacityListenerID = -1;\n+ const opacityListener = (animatedUpdate: { value: number }) => {\n+ if (animatedUpdate.value === 0) {\n+ this.setState({ mode: this.nextMode });\n+ this.state.resetPasswordPanelOpacityValue.removeListener(\n+ opacityListenerID,\n);\n+ }\n+ }\n+ opacityListenerID = this.state.resetPasswordPanelOpacityValue.addListener(\n+ opacityListener,\n+ );\n+\nthis.opacityChangeQueued = true;\nthis.nextMode = \"simple-text\";\n+\nif (this.activeKeyboard) {\n// If keyboard is currently active, keyboardHide will handle the\n// animation. This is so we can run all animations in parallel\n@@ -198,6 +207,7 @@ class VerificationModal extends React.PureComponent {\n} else {\nthis.animateKeyboardDownOrBackToSimpleText(null);\n}\n+\nthis.inCoupleSecondsNavigateToApp().then();\n}\n@@ -206,15 +216,6 @@ class VerificationModal extends React.PureComponent {\nthis.props.dispatchActionPayload(\"NAVIGATE_TO_APP\", null);\n}\n- opacityListener = (animatedUpdate: { value: number }) => {\n- if (animatedUpdate.value === 0) {\n- this.setState({ mode: this.nextMode });\n- this.state.resetPasswordPanelOpacityValue.removeListener(\n- this.opacityHitsZeroListenerID,\n- );\n- }\n- }\n-\nasync handleVerificationCodeAction(code: string) {\ntry {\nconst result = await this.props.handleVerificationCode(code);\n@@ -248,18 +249,13 @@ class VerificationModal extends React.PureComponent {\nmode: VerificationModalMode,\nkeyboardHeight: number,\n) {\n- let { height } = Dimensions.get('window');\n- if (Platform.OS === \"android\") {\n- // Android's Dimensions.get doesn't include the status bar\n- height -= 24;\n- }\nlet containerSize = 0;\nif (mode === \"simple-text\") {\ncontainerSize = 90;\n} else if (mode === \"reset-password\") {\ncontainerSize = 165;\n}\n- return (height - containerSize - keyboardHeight) / 2;\n+ return (windowHeight - containerSize - keyboardHeight) / 2;\n}\nanimateToResetPassword(inputDuration: ?number) {\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/dimensions.js",
"diff": "+// @flow\n+\n+import { Dimensions, Platform } from 'react-native';\n+\n+let { height, width } = Dimensions.get('window');\n+if (Platform.OS === \"android\") {\n+ // Android's Dimensions.get doesn't include the status bar\n+ height -= 24;\n+}\n+const windowHeight = height;\n+const windowWidth = width;\n+\n+export {\n+ windowHeight,\n+ windowWidth,\n+};\n"
},
{
"change_type": "MODIFY",
"old_path": "web/modals/account/forgot-password-modal.react.js",
"new_path": "web/modals/account/forgot-password-modal.react.js",
"diff": "@@ -159,7 +159,6 @@ class ForgotPasswordModal extends React.PureComponent {\n);\nthrow e;\n}\n-\n}\n}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Forgot password modal! |
129,187 | 28.03.2017 23:36:19 | 14,400 | 5376c1a122b05a7190695da6178c0c1ec8988b68 | A couple bugfixes after testing the whole forgot password/reset password flow | [
{
"change_type": "MODIFY",
"old_path": "native/account/verification-modal.react.js",
"new_path": "native/account/verification-modal.react.js",
"diff": "@@ -133,6 +133,7 @@ class VerificationModal extends React.PureComponent {\nhandleVerificationCodeActionType,\nthis.handleVerificationCodeAction(code),\n);\n+ Keyboard.dismiss();\nthis.keyboardShowListener = Keyboard.addListener(\nPlatform.OS === \"ios\" ? \"keyboardWillShow\" : \"keyboardDidShow\",\nthis.keyboardShow,\n@@ -329,10 +330,10 @@ class VerificationModal extends React.PureComponent {\nkeyboardHide = (event: ?KeyboardEvent) => {\nthis.keyboardHeight = 0;\n+ this.activeKeyboard = false;\nif (this.activeAlert) {\nreturn;\n}\n- this.activeKeyboard = false;\nthis.animateKeyboardDownOrBackToSimpleText(event && event.duration);\nthis.opacityChangeQueued = false;\n}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | A couple bugfixes after testing the whole forgot password/reset password flow |
129,187 | 29.03.2017 18:34:29 | 14,400 | 2620b3247ff72e38c3e053bea716bfcb68380a9b | Factor out some panel logic | [
{
"change_type": "MODIFY",
"old_path": "native/account/forgot-password-panel.react.js",
"new_path": "native/account/forgot-password-panel.react.js",
"diff": "@@ -9,11 +9,6 @@ import { connect } from 'react-redux';\nimport {\nStyleSheet,\nView,\n- ActivityIndicator,\n- Platform,\n- TouchableNativeFeedback,\n- TouchableHighlight,\n- Text,\nAnimated,\nAlert,\nKeyboard,\n@@ -36,6 +31,11 @@ import {\n} from 'lib/shared/account-regexes';\nimport { TextInput } from '../modal-components.react';\n+import {\n+ PanelButton,\n+ PanelOnePasswordButton,\n+ Panel,\n+} from './panel-components.react';\nclass ForgotPasswordPanel extends React.PureComponent {\n@@ -66,51 +66,8 @@ class ForgotPasswordPanel extends React.PureComponent {\nusernameOrEmailInput: ?TextInput;\nrender() {\n- let buttonIcon;\n- if (this.props.loadingStatus === \"loading\") {\n- buttonIcon = (\n- <View style={styles.loadingIndicatorContainer}>\n- <ActivityIndicator color=\"#555\" />\n- </View>\n- );\n- } else {\n- buttonIcon = (\n- <View style={styles.submitContentIconContainer}>\n- <Icon name=\"arrow-right\" size={16} color=\"#555\" />\n- </View>\n- );\n- }\n- let submitButton;\n- if (Platform.OS === \"android\") {\n- submitButton = (\n- <TouchableNativeFeedback\n- onPress={this.onSubmit}\n- disabled={this.props.loadingStatus === \"loading\"}\n- >\n- <View style={[styles.submitContentContainer, styles.submitButton]}>\n- <Text style={styles.submitContentText}>RESET PASSWORD</Text>\n- {buttonIcon}\n- </View>\n- </TouchableNativeFeedback>\n- );\n- } else {\n- submitButton = (\n- <TouchableHighlight\n- onPress={this.onSubmit}\n- style={styles.submitButton}\n- underlayColor=\"#A0A0A0DD\"\n- disabled={this.props.loadingStatus === \"loading\"}\n- >\n- <View style={styles.submitContentContainer}>\n- <Text style={styles.submitContentText}>RESET PASSWORD</Text>\n- {buttonIcon}\n- </View>\n- </TouchableHighlight>\n- );\n- }\n- const opacityStyle = { opacity: this.props.opacityValue };\nreturn (\n- <Animated.View style={[styles.container, opacityStyle]}>\n+ <Panel opacityValue={this.props.opacityValue}>\n<View>\n<Icon name=\"user\" size={22} color=\"#777\" style={styles.icon} />\n<TextInput\n@@ -129,8 +86,12 @@ class ForgotPasswordPanel extends React.PureComponent {\nref={this.usernameOrEmailInputRef}\n/>\n</View>\n- {submitButton}\n- </Animated.View>\n+ <PanelButton\n+ text=\"RESET PASSWORD\"\n+ loadingStatus={this.props.loadingStatus}\n+ onSubmit={this.onSubmit}\n+ />\n+ </Panel>\n);\n}\n@@ -211,45 +172,6 @@ class ForgotPasswordPanel extends React.PureComponent {\n}\nconst styles = StyleSheet.create({\n- submitContentIconContainer: {\n- width: 14,\n- paddingBottom: 5,\n- },\n- loadingIndicatorContainer: {\n- width: 14,\n- paddingBottom: 2,\n- },\n- submitButton: {\n- position: 'absolute',\n- bottom: 0,\n- right: 0,\n- borderBottomRightRadius: 6,\n- },\n- submitContentContainer: {\n- flexDirection: 'row',\n- alignItems: 'flex-end',\n- paddingLeft: 18,\n- paddingTop: 6,\n- paddingRight: 18,\n- paddingBottom: 6,\n- },\n- submitContentText: {\n- fontSize: 18,\n- fontFamily: 'OpenSans-Semibold',\n- color: \"#555\",\n- paddingRight: 7,\n- },\n- container: {\n- paddingBottom: 37,\n- paddingTop: 6,\n- paddingLeft: 18,\n- paddingRight: 18,\n- marginLeft: 20,\n- marginRight: 20,\n- marginTop: 40,\n- borderRadius: 6,\n- backgroundColor: '#FFFFFFAA',\n- },\ninput: {\npaddingLeft: 35,\n},\n"
},
{
"change_type": "MODIFY",
"old_path": "native/account/log-in-panel.react.js",
"new_path": "native/account/log-in-panel.react.js",
"diff": "@@ -9,16 +9,9 @@ import React from 'react';\nimport {\nView,\nStyleSheet,\n- TouchableHighlight,\n- Text,\n- Platform,\n- ActivityIndicator,\nAlert,\nKeyboard,\nAnimated,\n- TouchableNativeFeedback,\n- Image,\n- TouchableWithoutFeedback,\n} from 'react-native';\nimport Icon from 'react-native-vector-icons/FontAwesome';\nimport { connect } from 'react-redux';\n@@ -37,6 +30,11 @@ import { logInActionType, logIn } from 'lib/actions/user-actions';\nimport { createLoadingStatusSelector } from 'lib/selectors/loading-selectors';\nimport { TextInput } from '../modal-components.react';\n+import {\n+ PanelButton,\n+ PanelOnePasswordButton,\n+ Panel,\n+} from './panel-components.react';\nclass LogInPanel extends React.PureComponent {\n@@ -79,64 +77,16 @@ class LogInPanel extends React.PureComponent {\n}\nrender() {\n- let buttonIcon;\n- if (this.props.loadingStatus === \"loading\") {\n- buttonIcon = (\n- <View style={styles.loadingIndicatorContainer}>\n- <ActivityIndicator color=\"#555\" />\n- </View>\n- );\n- } else {\n- buttonIcon = (\n- <View style={styles.submitContentIconContainer}>\n- <Icon name=\"arrow-right\" size={16} color=\"#555\" />\n- </View>\n- );\n- }\n- let submitButton;\n- if (Platform.OS === \"android\") {\n- submitButton = (\n- <TouchableNativeFeedback\n- onPress={this.onSubmit}\n- disabled={this.props.loadingStatus === \"loading\"}\n- >\n- <View style={[styles.submitContentContainer, styles.submitButton]}>\n- <Text style={styles.submitContentText}>LOG IN</Text>\n- {buttonIcon}\n- </View>\n- </TouchableNativeFeedback>\n- );\n- } else {\n- submitButton = (\n- <TouchableHighlight\n- onPress={this.onSubmit}\n- style={styles.submitButton}\n- underlayColor=\"#A0A0A0DD\"\n- disabled={this.props.loadingStatus === \"loading\"}\n- >\n- <View style={styles.submitContentContainer}>\n- <Text style={styles.submitContentText}>LOG IN</Text>\n- {buttonIcon}\n- </View>\n- </TouchableHighlight>\n- );\n- }\nlet onePassword = null;\nlet passwordStyle = {};\nif (this.props.onePasswordSupported) {\nonePassword = (\n- <TouchableWithoutFeedback onPress={this.onPressOnePassword}>\n- <Image\n- source={require(\"../img/onepassword.png\")}\n- style={styles.onePasswordImage}\n- />\n- </TouchableWithoutFeedback>\n+ <PanelOnePasswordButton onPress={this.onPressOnePassword} />\n);\npasswordStyle = { paddingRight: 30 };\n}\n- const opacityStyle = { opacity: this.props.opacityValue };\nreturn (\n- <Animated.View style={[styles.container, opacityStyle]}>\n+ <Panel opacityValue={this.props.opacityValue}>\n<View>\n<Icon name=\"user\" size={22} color=\"#777\" style={styles.icon} />\n<TextInput\n@@ -171,8 +121,12 @@ class LogInPanel extends React.PureComponent {\n/>\n{onePassword}\n</View>\n- {submitButton}\n- </Animated.View>\n+ <PanelButton\n+ text=\"LOG IN\"\n+ loadingStatus={this.props.loadingStatus}\n+ onSubmit={this.onSubmit}\n+ />\n+ </Panel>\n);\n}\n@@ -320,17 +274,6 @@ class LogInPanel extends React.PureComponent {\nexport type InnerLogInPanel = LogInPanel;\nconst styles = StyleSheet.create({\n- container: {\n- paddingBottom: 37,\n- paddingTop: 6,\n- paddingLeft: 18,\n- paddingRight: 18,\n- marginLeft: 20,\n- marginRight: 20,\n- marginTop: 40,\n- borderRadius: 6,\n- backgroundColor: '#FFFFFFAA',\n- },\ninput: {\npaddingLeft: 35,\n},\n@@ -339,42 +282,6 @@ const styles = StyleSheet.create({\nbottom: 8,\nleft: 4,\n},\n- submitButton: {\n- position: 'absolute',\n- bottom: 0,\n- right: 0,\n- borderBottomRightRadius: 6,\n- },\n- submitContentContainer: {\n- flexDirection: 'row',\n- alignItems: 'flex-end',\n- paddingLeft: 18,\n- paddingTop: 6,\n- paddingRight: 18,\n- paddingBottom: 6,\n- },\n- submitContentText: {\n- fontSize: 18,\n- fontFamily: 'OpenSans-Semibold',\n- color: \"#555\",\n- paddingRight: 7,\n- },\n- submitContentIconContainer: {\n- width: 14,\n- paddingBottom: 5,\n- },\n- loadingIndicatorContainer: {\n- width: 14,\n- paddingBottom: 2,\n- },\n- onePasswordImage: {\n- position: 'absolute',\n- top: 8,\n- right: 5,\n- width: 24,\n- height: 24,\n- opacity: 0.6,\n- },\n});\nconst loadingStatusSelector = createLoadingStatusSelector(logInActionType);\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/account/panel-components.react.js",
"diff": "+// @flow\n+\n+import type { LoadingStatus } from 'lib/types/loading-types';\n+\n+import React from 'react';\n+import {\n+ Platform,\n+ View,\n+ ActivityIndicator,\n+ TouchableNativeFeedback,\n+ Text,\n+ TouchableHighlight,\n+ StyleSheet,\n+ TouchableWithoutFeedback,\n+ Image,\n+ Animated,\n+} from 'react-native';\n+import Icon from 'react-native-vector-icons/FontAwesome';\n+\n+class PanelButton extends React.PureComponent {\n+\n+ props: {\n+ text: string,\n+ loadingStatus: LoadingStatus,\n+ onSubmit: () => void,\n+ };\n+ static propTypes = {\n+ text: React.PropTypes.string.isRequired,\n+ loadingStatus: React.PropTypes.string.isRequired,\n+ onSubmit: React.PropTypes.func.isRequired,\n+ };\n+\n+ render() {\n+ let buttonIcon;\n+ if (this.props.loadingStatus === \"loading\") {\n+ buttonIcon = (\n+ <View style={styles.loadingIndicatorContainer}>\n+ <ActivityIndicator color=\"#555\" />\n+ </View>\n+ );\n+ } else {\n+ buttonIcon = (\n+ <View style={styles.submitContentIconContainer}>\n+ <Icon name=\"arrow-right\" size={16} color=\"#555\" />\n+ </View>\n+ );\n+ }\n+ if (Platform.OS === \"android\") {\n+ return (\n+ <TouchableNativeFeedback\n+ onPress={this.props.onSubmit}\n+ disabled={this.props.loadingStatus === \"loading\"}\n+ >\n+ <View style={[styles.submitContentContainer, styles.submitButton]}>\n+ <Text style={styles.submitContentText}>{this.props.text}</Text>\n+ {buttonIcon}\n+ </View>\n+ </TouchableNativeFeedback>\n+ );\n+ } else {\n+ return (\n+ <TouchableHighlight\n+ onPress={this.props.onSubmit}\n+ style={styles.submitButton}\n+ underlayColor=\"#A0A0A0DD\"\n+ disabled={this.props.loadingStatus === \"loading\"}\n+ >\n+ <View style={styles.submitContentContainer}>\n+ <Text style={styles.submitContentText}>{this.props.text}</Text>\n+ {buttonIcon}\n+ </View>\n+ </TouchableHighlight>\n+ );\n+ }\n+ }\n+\n+}\n+\n+function PanelOnePasswordButton(props: { onPress: () => Promise<void> }) {\n+ return (\n+ <TouchableWithoutFeedback onPress={props.onPress}>\n+ <Image\n+ source={require(\"../img/onepassword.png\")}\n+ style={styles.onePasswordImage}\n+ />\n+ </TouchableWithoutFeedback>\n+ );\n+}\n+\n+type PanelProps = {\n+ opacityValue: Animated.Value,\n+ children?: React.Element<any>,\n+ style?: StyleSheet.Styles,\n+};\n+function Panel(props: PanelProps) {\n+ const opacityStyle = { opacity: props.opacityValue };\n+ return (\n+ <Animated.View style={[styles.container, opacityStyle, props.style]}>\n+ {props.children}\n+ </Animated.View>\n+ );\n+}\n+\n+const styles = StyleSheet.create({\n+ loadingIndicatorContainer: {\n+ width: 14,\n+ paddingBottom: 2,\n+ },\n+ submitContentIconContainer: {\n+ width: 14,\n+ paddingBottom: 5,\n+ },\n+ submitButton: {\n+ position: 'absolute',\n+ bottom: 0,\n+ right: 0,\n+ borderBottomRightRadius: 6,\n+ },\n+ submitContentContainer: {\n+ flexDirection: 'row',\n+ alignItems: 'flex-end',\n+ paddingLeft: 18,\n+ paddingTop: 6,\n+ paddingRight: 18,\n+ paddingBottom: 6,\n+ },\n+ submitContentText: {\n+ fontSize: 18,\n+ fontFamily: 'OpenSans-Semibold',\n+ color: \"#555\",\n+ paddingRight: 7,\n+ },\n+ onePasswordImage: {\n+ position: 'absolute',\n+ top: 8,\n+ right: 5,\n+ width: 24,\n+ height: 24,\n+ opacity: 0.6,\n+ },\n+ container: {\n+ paddingBottom: 37,\n+ paddingTop: 6,\n+ paddingLeft: 18,\n+ paddingRight: 18,\n+ marginLeft: 20,\n+ marginRight: 20,\n+ marginTop: 40,\n+ borderRadius: 6,\n+ backgroundColor: '#FFFFFFAA',\n+ },\n+});\n+\n+export {\n+ PanelButton,\n+ PanelOnePasswordButton,\n+ Panel,\n+};\n"
},
{
"change_type": "MODIFY",
"old_path": "native/account/register-panel.react.js",
"new_path": "native/account/register-panel.react.js",
"diff": "@@ -9,16 +9,10 @@ import React from 'react';\nimport {\nView,\nStyleSheet,\n- TouchableHighlight,\n- Text,\nPlatform,\n- ActivityIndicator,\nKeyboard,\nAlert,\nAnimated,\n- TouchableNativeFeedback,\n- Image,\n- TouchableWithoutFeedback,\n} from 'react-native';\nimport Icon from 'react-native-vector-icons/FontAwesome';\nimport { connect } from 'react-redux';\n@@ -37,6 +31,11 @@ import {\n} from 'lib/shared/account-regexes';\nimport { TextInput } from '../modal-components.react';\n+import {\n+ PanelButton,\n+ PanelOnePasswordButton,\n+ Panel,\n+} from './panel-components.react';\nclass RegisterPanel extends React.PureComponent {\n@@ -80,68 +79,16 @@ class RegisterPanel extends React.PureComponent {\nconfirmPasswordInput: ?TextInput;\nrender() {\n- let buttonIcon;\n- if (this.props.loadingStatus === \"loading\") {\n- buttonIcon = (\n- <View style={styles.loadingIndicatorContainer}>\n- <ActivityIndicator color=\"#555\" />\n- </View>\n- );\n- } else {\n- buttonIcon = (\n- <View style={styles.submitContentIconContainer}>\n- <Icon\n- name=\"arrow-right\"\n- size={16}\n- color=\"#555\"\n- />\n- </View>\n- );\n- }\n- let submitButton;\n- if (Platform.OS === \"android\") {\n- submitButton = (\n- <TouchableNativeFeedback\n- onPress={this.onSubmit}\n- disabled={this.props.loadingStatus === \"loading\"}\n- >\n- <View style={[styles.submitContentContainer, styles.submitButton]}>\n- <Text style={styles.submitContentText}>SIGN UP</Text>\n- {buttonIcon}\n- </View>\n- </TouchableNativeFeedback>\n- );\n- } else {\n- submitButton = (\n- <TouchableHighlight\n- onPress={this.onSubmit}\n- style={styles.submitButton}\n- underlayColor=\"#A0A0A0DD\"\n- disabled={this.props.loadingStatus === \"loading\"}\n- >\n- <View style={styles.submitContentContainer}>\n- <Text style={styles.submitContentText}>SIGN UP</Text>\n- {buttonIcon}\n- </View>\n- </TouchableHighlight>\n- );\n- }\nlet onePassword = null;\nlet passwordStyle = {};\nif (this.props.onePasswordSupported) {\nonePassword = (\n- <TouchableWithoutFeedback onPress={this.onPressOnePassword}>\n- <Image\n- source={require(\"../img/onepassword.png\")}\n- style={styles.onePasswordImage}\n- />\n- </TouchableWithoutFeedback>\n+ <PanelOnePasswordButton onPress={this.onPressOnePassword} />\n);\npasswordStyle = { paddingRight: 30 };\n}\n- const opacityStyle = { opacity: this.props.opacityValue };\nreturn (\n- <Animated.View style={[styles.container, opacityStyle]}>\n+ <Panel opacityValue={this.props.opacityValue} style={styles.container}>\n<View>\n<Icon name=\"user\" size={22} color=\"#777\" style={styles.icon} />\n<TextInput\n@@ -212,8 +159,12 @@ class RegisterPanel extends React.PureComponent {\nref={this.confirmPasswordInputRef}\n/>\n</View>\n- {submitButton}\n- </Animated.View>\n+ <PanelButton\n+ text=\"SIGN UP\"\n+ loadingStatus={this.props.loadingStatus}\n+ onSubmit={this.onSubmit}\n+ />\n+ </Panel>\n);\n}\n@@ -432,14 +383,6 @@ class RegisterPanel extends React.PureComponent {\nconst styles = StyleSheet.create({\ncontainer: {\npaddingBottom: Platform.OS === 'ios' ? 37 : 36,\n- paddingTop: 6,\n- paddingLeft: 18,\n- paddingRight: 18,\n- marginLeft: 20,\n- marginRight: 20,\n- marginTop: 40,\n- borderRadius: 6,\n- backgroundColor: '#FFFFFFAA',\nzIndex: 2,\n},\ninput: {\n@@ -454,42 +397,6 @@ const styles = StyleSheet.create({\nleft: 3,\nbottom: 10,\n},\n- submitButton: {\n- position: 'absolute',\n- bottom: 0,\n- right: 0,\n- borderBottomRightRadius: 6,\n- },\n- submitContentContainer: {\n- flexDirection: 'row',\n- alignItems: 'flex-end',\n- paddingLeft: 18,\n- paddingTop: 6,\n- paddingRight: 18,\n- paddingBottom: 6,\n- },\n- submitContentText: {\n- fontSize: 18,\n- fontFamily: 'OpenSans-Semibold',\n- color: \"#555\",\n- paddingRight: 7,\n- },\n- submitContentIconContainer: {\n- width: 14,\n- paddingBottom: 5,\n- },\n- loadingIndicatorContainer: {\n- width: 14,\n- paddingBottom: 2,\n- },\n- onePasswordImage: {\n- position: 'absolute',\n- top: 8,\n- right: 5,\n- width: 24,\n- height: 24,\n- opacity: 0.6,\n- },\n});\nconst loadingStatusSelector = createLoadingStatusSelector(registerActionType);\n"
},
{
"change_type": "MODIFY",
"old_path": "native/account/reset-password-panel.react.js",
"new_path": "native/account/reset-password-panel.react.js",
"diff": "@@ -12,13 +12,7 @@ import {\nAnimated,\nKeyboard,\nView,\n- ActivityIndicator,\n- Platform,\n- TouchableNativeFeedback,\nText,\n- TouchableHighlight,\n- Image,\n- TouchableWithoutFeedback,\n} from 'react-native';\nimport { connect } from 'react-redux';\nimport invariant from 'invariant';\n@@ -36,6 +30,11 @@ import {\n} from 'lib/utils/action-utils';\nimport { TextInput } from '../modal-components.react';\n+import {\n+ PanelButton,\n+ PanelOnePasswordButton,\n+ Panel,\n+} from './panel-components.react';\nclass ResetPasswordPanel extends React.PureComponent {\n@@ -75,64 +74,16 @@ class ResetPasswordPanel extends React.PureComponent {\nconfirmPasswordInput: ?TextInput;\nrender() {\n- let buttonIcon;\n- if (this.props.loadingStatus === \"loading\") {\n- buttonIcon = (\n- <View style={styles.loadingIndicatorContainer}>\n- <ActivityIndicator color=\"#555\" />\n- </View>\n- );\n- } else {\n- buttonIcon = (\n- <View style={styles.submitContentIconContainer}>\n- <Icon name=\"arrow-right\" size={16} color=\"#555\" />\n- </View>\n- );\n- }\n- let submitButton;\n- if (Platform.OS === \"android\") {\n- submitButton = (\n- <TouchableNativeFeedback\n- onPress={this.onSubmit}\n- disabled={this.props.loadingStatus === \"loading\"}\n- >\n- <View style={[styles.submitContentContainer, styles.submitButton]}>\n- <Text style={styles.submitContentText}>RESET PASSWORD</Text>\n- {buttonIcon}\n- </View>\n- </TouchableNativeFeedback>\n- );\n- } else {\n- submitButton = (\n- <TouchableHighlight\n- onPress={this.onSubmit}\n- style={styles.submitButton}\n- underlayColor=\"#A0A0A0DD\"\n- disabled={this.props.loadingStatus === \"loading\"}\n- >\n- <View style={styles.submitContentContainer}>\n- <Text style={styles.submitContentText}>RESET PASSWORD</Text>\n- {buttonIcon}\n- </View>\n- </TouchableHighlight>\n- );\n- }\nlet onePassword = null;\nlet passwordStyle = { paddingRight: 0 };\nif (this.props.onePasswordSupported) {\nonePassword = (\n- <TouchableWithoutFeedback onPress={this.onPressOnePassword}>\n- <Image\n- source={require(\"../img/onepassword.png\")}\n- style={styles.onePasswordImage}\n- />\n- </TouchableWithoutFeedback>\n+ <PanelOnePasswordButton onPress={this.onPressOnePassword} />\n);\npasswordStyle = { paddingRight: 30 };\n}\n- const opacityStyle = { opacity: this.props.opacityValue };\nreturn (\n- <Animated.View style={[styles.container, opacityStyle]}>\n+ <Panel opacityValue={this.props.opacityValue} style={styles.container}>\n<View>\n<Icon name=\"user\" size={22} color=\"#777\" style={styles.icon} />\n<View style={styles.usernameContainer}>\n@@ -170,8 +121,12 @@ class ResetPasswordPanel extends React.PureComponent {\nref={this.confirmPasswordInputRef}\n/>\n</View>\n- {submitButton}\n- </Animated.View>\n+ <PanelButton\n+ text=\"RESET PASSWORD\"\n+ loadingStatus={this.props.loadingStatus}\n+ onSubmit={this.onSubmit}\n+ />\n+ </Panel>\n);\n}\n@@ -278,51 +233,8 @@ class ResetPasswordPanel extends React.PureComponent {\n}\nconst styles = StyleSheet.create({\n- submitContentIconContainer: {\n- width: 14,\n- paddingBottom: 5,\n- },\n- loadingIndicatorContainer: {\n- width: 14,\n- paddingBottom: 2,\n- },\n- submitButton: {\n- position: 'absolute',\n- bottom: 0,\n- right: 0,\n- borderBottomRightRadius: 6,\n- },\n- submitContentContainer: {\n- flexDirection: 'row',\n- alignItems: 'flex-end',\n- paddingLeft: 18,\n- paddingTop: 6,\n- paddingRight: 18,\n- paddingBottom: 6,\n- },\n- submitContentText: {\n- fontSize: 18,\n- fontFamily: 'OpenSans-Semibold',\n- color: \"#555\",\n- paddingRight: 7,\n- },\n- onePasswordImage: {\n- position: 'absolute',\n- top: 8,\n- right: 5,\n- width: 24,\n- height: 24,\n- opacity: 0.6,\n- },\ncontainer: {\n- paddingBottom: 37,\n- paddingTop: 6,\n- paddingLeft: 18,\n- paddingRight: 18,\n- marginLeft: 20,\n- marginRight: 20,\n- borderRadius: 6,\n- backgroundColor: '#FFFFFFAA',\n+ marginTop: 0,\n},\ninput: {\npaddingLeft: 35,\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Factor out some panel logic |
129,187 | 29.03.2017 19:48:32 | 14,400 | 3bb660cc349413adf9f66534c954d36eb500b435 | Factor LogInPanelContainer out of LoggedOutModal because the latter is too big | [
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/account/log-in-panel-container.react.js",
"diff": "+// @flow\n+\n+import type { InnerLogInPanel } from './log-in-panel.react';\n+\n+import React from 'react';\n+import {\n+ View,\n+ Animated,\n+ Text,\n+ Easing,\n+ StyleSheet,\n+} from 'react-native';\n+import Icon from 'react-native-vector-icons/FontAwesome';\n+import invariant from 'invariant';\n+\n+import sleep from 'lib/utils/sleep';\n+\n+import { windowWidth } from '../dimensions';\n+import LogInPanel from './log-in-panel.react';\n+import ForgotPasswordPanel from './forgot-password-panel.react';\n+\n+type LogInMode = \"log-in\" | \"forgot-password\" | \"forgot-password-success\";\n+\n+class LogInPanelContainer extends React.PureComponent {\n+\n+ props: {\n+ onePasswordSupported: bool,\n+ setActiveAlert: (activeAlert: bool) => void,\n+ opacityValue: Animated.Value,\n+ forgotPasswordLinkOpacity: Animated.Value,\n+ };\n+ static propTypes = {\n+ onePasswordSupported: React.PropTypes.bool.isRequired,\n+ setActiveAlert: React.PropTypes.func.isRequired,\n+ opacityValue: React.PropTypes.object.isRequired,\n+ forgotPasswordLinkOpacity: React.PropTypes.object.isRequired,\n+ };\n+ state: {\n+ panelTransition: Animated.Value,\n+ logInMode: LogInMode,\n+ nextLogInMode: LogInMode,\n+ } = {\n+ panelTransition: new Animated.Value(0),\n+ logInMode: \"log-in\",\n+ nextLogInMode: \"log-in\",\n+ };\n+ logInPanel: ?InnerLogInPanel = null;\n+\n+ render() {\n+ const logInPanelDynamicStyle = {\n+ left: this.state.panelTransition.interpolate({\n+ inputRange: [0, 2],\n+ outputRange: [0, windowWidth * -2],\n+ }),\n+ right: this.state.panelTransition.interpolate({\n+ inputRange: [0, 2],\n+ outputRange: [0, windowWidth * 2],\n+ }),\n+ };\n+ const logInPanel = (\n+ <Animated.View style={[styles.panel, logInPanelDynamicStyle]}>\n+ <LogInPanel\n+ setActiveAlert={this.props.setActiveAlert}\n+ opacityValue={this.props.opacityValue}\n+ onePasswordSupported={this.props.onePasswordSupported}\n+ innerRef={this.logInPanelRef}\n+ />\n+ </Animated.View>\n+ );\n+ let forgotPasswordPanel = null;\n+ if (\n+ this.state.nextLogInMode !== \"log-in\" ||\n+ this.state.logInMode !== \"log-in\"\n+ ) {\n+ const forgotPasswordPanelDynamicStyle = {\n+ left: this.state.panelTransition.interpolate({\n+ inputRange: [0, 2],\n+ outputRange: [windowWidth, windowWidth * -1],\n+ }),\n+ right: this.state.panelTransition.interpolate({\n+ inputRange: [0, 2],\n+ outputRange: [windowWidth * -1, windowWidth],\n+ }),\n+ };\n+ forgotPasswordPanel = (\n+ <Animated.View style={[styles.panel, forgotPasswordPanelDynamicStyle]}>\n+ <ForgotPasswordPanel\n+ setActiveAlert={this.props.setActiveAlert}\n+ opacityValue={this.props.opacityValue}\n+ onSuccess={this.onForgotPasswordSuccess}\n+ />\n+ </Animated.View>\n+ );\n+ }\n+ let forgotPasswordSuccess = null;\n+ if (\n+ this.state.nextLogInMode === \"forgot-password-success\" ||\n+ this.state.logInMode === \"forgot-password-success\"\n+ ) {\n+ const forgotPasswordSuccessDynamicStyle = {\n+ left: this.state.panelTransition.interpolate({\n+ inputRange: [0, 2],\n+ outputRange: [windowWidth * 2, 0],\n+ }),\n+ right: this.state.panelTransition.interpolate({\n+ inputRange: [0, 2],\n+ outputRange: [windowWidth * -2, 0],\n+ }),\n+ };\n+ forgotPasswordSuccess = (\n+ <Animated.View\n+ style={[styles.panel, forgotPasswordSuccessDynamicStyle]}\n+ >\n+ <Icon\n+ name=\"check-circle\"\n+ size={48}\n+ color=\"#88FF88DD\"\n+ style={styles.forgotPasswordSuccessIcon}\n+ />\n+ <Text style={styles.forgotPasswordSuccessText}>\n+ Okay, we've sent that account an email. Check your inbox to\n+ complete the process.\n+ </Text>\n+ </Animated.View>\n+ );\n+ }\n+ return (\n+ <View>\n+ {logInPanel}\n+ {forgotPasswordPanel}\n+ {forgotPasswordSuccess}\n+ </View>\n+ );\n+ }\n+\n+ logInPanelRef = (logInPanel: ?InnerLogInPanel) => {\n+ this.logInPanel = logInPanel;\n+ }\n+\n+ onPressForgotPassword = () => {\n+ this.setState({ nextLogInMode: \"forgot-password\" });\n+\n+ const duration = 350;\n+ const animations = [\n+ Animated.timing(\n+ this.props.forgotPasswordLinkOpacity,\n+ {\n+ duration,\n+ easing: Easing.out(Easing.ease),\n+ toValue: 0,\n+ },\n+ ),\n+ Animated.timing(\n+ this.state.panelTransition,\n+ {\n+ duration,\n+ easing: Easing.out(Easing.ease),\n+ toValue: 1,\n+ },\n+ ),\n+ ];\n+\n+ let listenerID = -1;\n+ const listener = (animatedUpdate: { value: number }) => {\n+ if (animatedUpdate.value === 1) {\n+ this.setState({ logInMode: this.state.nextLogInMode });\n+ this.state.panelTransition.removeListener(listenerID);\n+ }\n+ }\n+ listenerID = this.state.panelTransition.addListener(listener);\n+\n+ Animated.parallel(animations).start();\n+ }\n+\n+ backFromLogInMode = () => {\n+ if (this.state.nextLogInMode === \"log-in\") {\n+ return false;\n+ }\n+\n+ this.setState({\n+ logInMode: this.state.nextLogInMode,\n+ nextLogInMode: \"log-in\",\n+ });\n+ invariant(this.logInPanel, \"ref should be set\");\n+ this.logInPanel.focusUsernameOrEmailInput();\n+\n+ const duration = 350;\n+ const animations = [\n+ Animated.timing(\n+ this.props.forgotPasswordLinkOpacity,\n+ {\n+ duration,\n+ easing: Easing.out(Easing.ease),\n+ toValue: 1,\n+ },\n+ ),\n+ Animated.timing(\n+ this.state.panelTransition,\n+ {\n+ duration,\n+ easing: Easing.out(Easing.ease),\n+ toValue: 0,\n+ },\n+ ),\n+ ];\n+\n+ let listenerID = -1;\n+ const listener = (animatedUpdate: { value: number }) => {\n+ if (animatedUpdate.value === 0) {\n+ this.setState({ logInMode: this.state.nextLogInMode });\n+ this.state.panelTransition.removeListener(listenerID);\n+ }\n+ }\n+ listenerID = this.state.panelTransition.addListener(listener);\n+\n+ Animated.parallel(animations).start();\n+ return true;\n+ }\n+\n+ onForgotPasswordSuccess = () => {\n+ if (this.state.nextLogInMode === \"log-in\") {\n+ return;\n+ }\n+\n+ this.setState({ nextLogInMode: \"forgot-password-success\" });\n+\n+ const duration = 350;\n+\n+ let listenerID = -1;\n+ const listener = (animatedUpdate: { value: number }) => {\n+ if (animatedUpdate.value === 2) {\n+ this.setState({ logInMode: this.state.nextLogInMode });\n+ this.state.panelTransition.removeListener(listenerID);\n+ }\n+ }\n+ listenerID = this.state.panelTransition.addListener(listener);\n+\n+ Animated.timing(\n+ this.state.panelTransition,\n+ {\n+ duration,\n+ easing: Easing.out(Easing.ease),\n+ toValue: 2,\n+ },\n+ ).start();\n+\n+ this.inCoupleSecondsNavigateToLogIn().then();\n+ }\n+\n+ async inCoupleSecondsNavigateToLogIn() {\n+ await sleep(2350);\n+ this.backFromLogInMode();\n+ }\n+\n+}\n+\n+const styles = StyleSheet.create({\n+ panel: {\n+ position: 'absolute',\n+ left: 0,\n+ right: 0,\n+ },\n+ forgotPasswordSuccessIcon: {\n+ marginTop: 40,\n+ textAlign: 'center',\n+ },\n+ forgotPasswordSuccessText: {\n+ marginTop: 10,\n+ marginLeft: 20,\n+ marginRight: 20,\n+ textAlign: 'center',\n+ color: 'white',\n+ fontSize: 18,\n+ },\n+});\n+\n+export default LogInPanelContainer;\n"
},
{
"change_type": "MODIFY",
"old_path": "native/account/logged-out-modal.react.js",
"new_path": "native/account/logged-out-modal.react.js",
"diff": "import type { NavigationScreenProp } from 'react-navigation';\nimport type { DispatchActionPayload } from 'lib/utils/action-utils';\n-import type { InnerLogInPanel } from './log-in-panel.react';\nimport React from 'react';\nimport {\n@@ -15,11 +14,9 @@ import {\nImage,\nEmitterSubscription,\nKeyboard,\n- Alert,\nPlatform,\nBackAndroid,\nLinking,\n- Dimensions,\n} from 'react-native';\nimport invariant from 'invariant';\nimport Icon from 'react-native-vector-icons/FontAwesome';\n@@ -27,12 +24,10 @@ import OnePassword from 'react-native-onepassword';\nimport { connect } from 'react-redux';\nimport { includeDispatchActionProps } from 'lib/utils/action-utils';\n-import sleep from 'lib/utils/sleep';\n-import { windowHeight, windowWidth } from '../dimensions';\n-import LogInPanel from './log-in-panel.react';\n+import { windowHeight } from '../dimensions';\n+import LogInPanelContainer from './log-in-panel-container.react';\nimport RegisterPanel from './register-panel.react';\n-import ForgotPasswordPanel from './forgot-password-panel.react';\nimport ConnectedStatusBar from '../connected-status-bar.react';\ntype KeyboardEvent = {\n@@ -45,7 +40,6 @@ type KeyboardEvent = {\n},\n};\ntype LoggedOutMode = \"prompt\" | \"log-in\" | \"register\";\n-type LogInMode = \"log-in\" | \"forgot-password\" | \"forgot-password-success\";\ntype Props = {\nnavigation: NavigationScreenProp<*, *>,\n// Redux dispatch functions\n@@ -53,13 +47,10 @@ type Props = {\n};\ntype State = {\nmode: LoggedOutMode,\n- logInMode: LogInMode,\n- nextLogInMode: LogInMode,\npanelPaddingTop: Animated.Value,\nfooterPaddingTop: Animated.Value,\npanelOpacity: Animated.Value,\nforgotPasswordLinkOpacity: Animated.Value,\n- logInPanelTransition: Animated.Value,\nonePasswordSupported: bool,\n};\n@@ -68,8 +59,6 @@ class LoggedOutModal extends React.PureComponent {\nprops: Props;\nstate: State = {\nmode: \"prompt\",\n- logInMode: \"log-in\",\n- nextLogInMode: \"log-in\",\npanelPaddingTop: new Animated.Value(\nLoggedOutModal.calculatePanelPaddingTop(\"prompt\", 0),\n),\n@@ -78,7 +67,6 @@ class LoggedOutModal extends React.PureComponent {\n),\npanelOpacity: new Animated.Value(0),\nforgotPasswordLinkOpacity: new Animated.Value(0),\n- logInPanelTransition: new Animated.Value(0),\nonePasswordSupported: false,\n};\nstatic propTypes = {\n@@ -104,7 +92,7 @@ class LoggedOutModal extends React.PureComponent {\nopacityChangeQueued = false;\nkeyboardHeight = 0;\nlastPanelPaddingTopValue: ?number = null;\n- logInPanel: ?InnerLogInPanel = null;\n+ logInPanelContainer: ?LogInPanelContainer = null;\nconstructor(props: Props) {\nsuper(props);\n@@ -164,7 +152,8 @@ class LoggedOutModal extends React.PureComponent {\nhardwareBack = () => {\nif (this.nextMode === \"log-in\") {\n- const returnValue = this.backFromLogInMode();\n+ invariant(this.logInPanelContainer, \"ref should be set\");\n+ const returnValue = this.logInPanelContainer.backFromLogInMode();\nif (returnValue) {\nreturn true;\n}\n@@ -366,91 +355,14 @@ class LoggedOutModal extends React.PureComponent {\nlet panel = null;\nlet buttons = null;\nif (this.state.mode === \"log-in\") {\n- const logInPanelDynamicStyle = {\n- left: this.state.logInPanelTransition.interpolate({\n- inputRange: [0, 2],\n- outputRange: [0, windowWidth * -2],\n- }),\n- right: this.state.logInPanelTransition.interpolate({\n- inputRange: [0, 2],\n- outputRange: [0, windowWidth * 2],\n- }),\n- };\n- const logInPanel = (\n- <Animated.View style={[styles.logInSubPanel, logInPanelDynamicStyle]}>\n- <LogInPanel\n- setActiveAlert={this.setActiveAlert}\n- opacityValue={this.state.panelOpacity}\n+ panel = (\n+ <LogInPanelContainer\nonePasswordSupported={this.state.onePasswordSupported}\n- innerRef={this.logInPanelRef}\n- />\n- </Animated.View>\n- );\n- let forgotPasswordPanel = null;\n- if (\n- this.state.nextLogInMode !== \"log-in\" ||\n- this.state.logInMode !== \"log-in\"\n- ) {\n- const forgotPasswordPanelDynamicStyle = {\n- left: this.state.logInPanelTransition.interpolate({\n- inputRange: [0, 2],\n- outputRange: [windowWidth, windowWidth * -1],\n- }),\n- right: this.state.logInPanelTransition.interpolate({\n- inputRange: [0, 2],\n- outputRange: [windowWidth * -1, windowWidth],\n- }),\n- };\n- forgotPasswordPanel = (\n- <Animated.View\n- style={[styles.logInSubPanel, forgotPasswordPanelDynamicStyle]}\n- >\n- <ForgotPasswordPanel\nsetActiveAlert={this.setActiveAlert}\nopacityValue={this.state.panelOpacity}\n- onSuccess={this.onForgotPasswordSuccess}\n- />\n- </Animated.View>\n- );\n- }\n- let forgotPasswordSuccess = null;\n- if (\n- this.state.nextLogInMode === \"forgot-password-success\" ||\n- this.state.logInMode === \"forgot-password-success\"\n- ) {\n- const forgotPasswordSuccessDynamicStyle = {\n- left: this.state.logInPanelTransition.interpolate({\n- inputRange: [0, 2],\n- outputRange: [windowWidth * 2, 0],\n- }),\n- right: this.state.logInPanelTransition.interpolate({\n- inputRange: [0, 2],\n- outputRange: [windowWidth * -2, 0],\n- }),\n- };\n- forgotPasswordSuccess = (\n- <Animated.View\n- style={[styles.logInSubPanel, forgotPasswordSuccessDynamicStyle]}\n- >\n- <Icon\n- name=\"check-circle\"\n- size={48}\n- color=\"#88FF88DD\"\n- style={styles.forgotPasswordSuccessIcon}\n+ forgotPasswordLinkOpacity={this.state.forgotPasswordLinkOpacity}\n+ ref={this.logInPanelContainerRef}\n/>\n- <Text style={styles.forgotPasswordSuccessText}>\n- Okay, we've sent that account an email. Check your inbox to\n- complete the process.\n- </Text>\n- </Animated.View>\n- );\n- }\n- panel = (\n- <View>\n- {logInPanel}\n- {forgotPasswordPanel}\n- {forgotPasswordSuccess}\n- </View>\n);\n} else if (this.state.mode === \"register\") {\npanel = (\n@@ -552,8 +464,8 @@ class LoggedOutModal extends React.PureComponent {\n}\n}\n- logInPanelRef = (logInPanel: ?InnerLogInPanel) => {\n- this.logInPanel = logInPanel;\n+ logInPanelContainerRef = (logInPanelContainer: ?LogInPanelContainer) => {\n+ this.logInPanelContainer = logInPanelContainer;\n}\nonPressLogIn = () => {\n@@ -579,118 +491,8 @@ class LoggedOutModal extends React.PureComponent {\n}\nonPressForgotPassword = () => {\n- this.setState({ nextLogInMode: \"forgot-password\" });\n-\n- const duration = 350;\n- const animations = [\n- Animated.timing(\n- this.state.forgotPasswordLinkOpacity,\n- {\n- duration,\n- easing: Easing.out(Easing.ease),\n- toValue: 0,\n- },\n- ),\n- Animated.timing(\n- this.state.logInPanelTransition,\n- {\n- duration,\n- easing: Easing.out(Easing.ease),\n- toValue: 1,\n- },\n- ),\n- ];\n-\n- let listenerID = -1;\n- const listener = (animatedUpdate: { value: number }) => {\n- if (animatedUpdate.value === 1) {\n- this.setState({ logInMode: this.state.nextLogInMode });\n- this.state.logInPanelTransition.removeListener(listenerID);\n- }\n- }\n- listenerID = this.state.logInPanelTransition.addListener(listener);\n-\n- Animated.parallel(animations).start();\n- }\n-\n- backFromLogInMode = () => {\n- if (this.state.nextLogInMode === \"log-in\") {\n- return false;\n- }\n-\n- this.setState({\n- logInMode: this.state.nextLogInMode,\n- nextLogInMode: \"log-in\",\n- });\n- invariant(this.logInPanel, \"ref should be set\");\n- this.logInPanel.focusUsernameOrEmailInput();\n-\n- const duration = 350;\n- const animations = [\n- Animated.timing(\n- this.state.forgotPasswordLinkOpacity,\n- {\n- duration,\n- easing: Easing.out(Easing.ease),\n- toValue: 1,\n- },\n- ),\n- Animated.timing(\n- this.state.logInPanelTransition,\n- {\n- duration,\n- easing: Easing.out(Easing.ease),\n- toValue: 0,\n- },\n- ),\n- ];\n-\n- let listenerID = -1;\n- const listener = (animatedUpdate: { value: number }) => {\n- if (animatedUpdate.value === 0) {\n- this.setState({ logInMode: this.state.nextLogInMode });\n- this.state.logInPanelTransition.removeListener(listenerID);\n- }\n- }\n- listenerID = this.state.logInPanelTransition.addListener(listener);\n-\n- Animated.parallel(animations).start();\n- return true;\n- }\n-\n- onForgotPasswordSuccess = () => {\n- if (this.state.nextLogInMode === \"log-in\") {\n- return;\n- }\n-\n- this.setState({ nextLogInMode: \"forgot-password-success\" });\n-\n- const duration = 350;\n-\n- let listenerID = -1;\n- const listener = (animatedUpdate: { value: number }) => {\n- if (animatedUpdate.value === 2) {\n- this.setState({ logInMode: this.state.nextLogInMode });\n- this.state.logInPanelTransition.removeListener(listenerID);\n- }\n- }\n- listenerID = this.state.logInPanelTransition.addListener(listener);\n-\n- Animated.timing(\n- this.state.logInPanelTransition,\n- {\n- duration,\n- easing: Easing.out(Easing.ease),\n- toValue: 2,\n- },\n- ).start();\n-\n- this.inCoupleSecondsNavigateToLogIn().then();\n- }\n-\n- async inCoupleSecondsNavigateToLogIn() {\n- await sleep(2350);\n- this.backFromLogInMode();\n+ invariant(this.logInPanelContainer, \"ref should be set\");\n+ this.logInPanelContainer.onPressForgotPassword();\n}\n}\n@@ -750,23 +552,6 @@ const styles = StyleSheet.create({\nforgotPasswordText: {\ncolor: '#8899FF',\n},\n- logInSubPanel: {\n- position: 'absolute',\n- left: 0,\n- right: 0,\n- },\n- forgotPasswordSuccessIcon: {\n- marginTop: 40,\n- textAlign: 'center',\n- },\n- forgotPasswordSuccessText: {\n- marginTop: 10,\n- marginLeft: 20,\n- marginRight: 20,\n- textAlign: 'center',\n- color: 'white',\n- fontSize: 18,\n- },\n});\nexport default connect(\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Factor LogInPanelContainer out of LoggedOutModal because the latter is too big |
129,187 | 30.03.2017 12:47:29 | 14,400 | 06f484f3db7728b64a452f78b842548b9c9d34a4 | Mid-progress on keychain and shared web credentials stuff; committing to get apple-app-site-association filed updated | [
{
"change_type": "MODIFY",
"old_path": "native/account/log-in-panel.react.js",
"new_path": "native/account/log-in-panel.react.js",
"diff": "@@ -17,6 +17,7 @@ import Icon from 'react-native-vector-icons/FontAwesome';\nimport { connect } from 'react-redux';\nimport invariant from 'invariant';\nimport OnePassword from 'react-native-onepassword';\n+import { getInternetCredentials } from 'react-native-keychain';\nimport {\nvalidUsernameRegex,\n@@ -74,6 +75,12 @@ class LogInPanel extends React.PureComponent {\ncomponentDidMount() {\nthis.props.innerRef(this);\n+ this.attemptToFetchCredentials().then();\n+ }\n+\n+ async attemptToFetchCredentials() {\n+ const credentials = await getInternetCredentials(\"squadcal.org\");\n+ console.log(credentials);\n}\nrender() {\n"
},
{
"change_type": "MODIFY",
"old_path": "native/android/app/build.gradle",
"new_path": "native/android/app/build.gradle",
"diff": "@@ -126,6 +126,7 @@ android {\n}\ndependencies {\n+ compile project(':react-native-keychain')\ncompile project(':react-native-vector-icons')\ncompile fileTree(dir: \"libs\", include: [\"*.jar\"])\ncompile \"com.android.support:appcompat-v7:23.0.1\"\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,6 +3,7 @@ package org.squadcal;\nimport android.app.Application;\nimport com.facebook.react.ReactApplication;\n+import com.oblador.keychain.KeychainPackage;\nimport com.oblador.vectoricons.VectorIconsPackage;\nimport com.facebook.react.ReactNativeHost;\nimport com.facebook.react.ReactPackage;\n@@ -24,6 +25,7 @@ public class MainApplication extends Application implements ReactApplication {\nprotected List<ReactPackage> getPackages() {\nreturn Arrays.<ReactPackage>asList(\nnew MainReactPackage(),\n+ new KeychainPackage(),\nnew VectorIconsPackage()\n);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "native/android/settings.gradle",
"new_path": "native/android/settings.gradle",
"diff": "rootProject.name = 'SquadCal'\n+include ':react-native-keychain'\n+project(':react-native-keychain').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-keychain/android')\ninclude ':react-native-vector-icons'\nproject(':react-native-vector-icons').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-vector-icons/android')\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- 7FF0870D1E833C3F000A1ACF /* GameKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7FF0870C1E833C3F000A1ACF /* GameKit.framework */; };\n- 7FF0870F1E833C47000A1ACF /* StoreKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7FF0870E1E833C47000A1ACF /* StoreKit.framework */; };\n832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 832341B51AAA6A8300B99B32 /* libRCTText.a */; };\n8894ACD632254222B23F69E2 /* Ionicons.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 4ACC468F28D944F293B91ACC /* Ionicons.ttf */; };\n98856FAEFDD5420882A5C010 /* 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 */; };\nFA7F2215AD7646E2BE985BF3 /* SimpleLineIcons.ttf in Resources */ = {isa = PBXBuildFile; fileRef = AE31AFFF88FB4112A29ADE33 /* SimpleLineIcons.ttf */; };\n/* End PBXBuildFile section */\nremoteGlobalIDString = 52E319201C0655C200265D56;\nremoteInfo = OnePassword;\n};\n+ 7FEB2DEB1E8D64D200C4B763 /* PBXContainerItemProxy */ = {\n+ isa = PBXContainerItemProxy;\n+ containerPortal = 95EEFC35D4D14053ACA7E064 /* RNKeychain.xcodeproj */;\n+ proxyType = 2;\n+ remoteGlobalIDString = 5D82366F1B0CE05B005A9EF3;\n+ remoteInfo = RNKeychain;\n+ };\n832341B41AAA6A8300B99B32 /* PBXContainerItemProxy */ = {\nisa = PBXContainerItemProxy;\ncontainerPortal = 832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */;\n7FB58ABC1E7F6BC600B4C1B1 /* OpenSans-Regular.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = \"OpenSans-Regular.ttf\"; sourceTree = \"<group>\"; };\n7FB58ABD1E7F6BC600B4C1B1 /* OpenSans-Semibold.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = \"OpenSans-Semibold.ttf\"; sourceTree = \"<group>\"; };\n7FCFD8BD1E81B8DF00629B0E /* SquadCal.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; name = SquadCal.entitlements; path = SquadCal/SquadCal.entitlements; sourceTree = \"<group>\"; };\n- 7FF0870C1E833C3F000A1ACF /* GameKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GameKit.framework; path = System/Library/Frameworks/GameKit.framework; sourceTree = SDKROOT; };\n- 7FF0870E1E833C47000A1ACF /* StoreKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = StoreKit.framework; path = System/Library/Frameworks/StoreKit.framework; sourceTree = SDKROOT; };\n832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = \"wrapper.pb-project\"; name = RCTText.xcodeproj; path = \"../node_modules/react-native/Libraries/Text/RCTText.xcodeproj\"; sourceTree = \"<group>\"; };\n8D919BA72D8545CBBBF6B74F /* MaterialCommunityIcons.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = MaterialCommunityIcons.ttf; path = \"../node_modules/react-native-vector-icons/Fonts/MaterialCommunityIcons.ttf\"; sourceTree = \"<group>\"; };\n+ 95EEFC35D4D14053ACA7E064 /* 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>\"; };\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 */\n00C302E91ABCBA2D00DB3ED1 /* libRCTNetwork.a in Frameworks */,\n139105C61AF99C1200B5F7CC /* libRCTSettings.a in Frameworks */,\n832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */,\n- 7FF0870D1E833C3F000A1ACF /* GameKit.framework in Frameworks */,\n00C302EA1ABCBA2D00DB3ED1 /* libRCTVibration.a in Frameworks */,\n139FDEF61B0652A700C62182 /* libRCTWebSocket.a in Frameworks */,\n- 7FF0870F1E833C47000A1ACF /* StoreKit.framework in Frameworks */,\n98856FAEFDD5420882A5C010 /* libRNVectorIcons.a in Frameworks */,\n3ACC3CE62D76452D871EE584 /* libOnePassword.a in Frameworks */,\n+ A1F391C5F8A84FB28AEA9876 /* libRNKeychain.a in Frameworks */,\n);\nrunOnlyForDeploymentPostprocessing = 0;\n};\nname = Products;\nsourceTree = \"<group>\";\n};\n+ 7FEB2DCE1E8D64D200C4B763 /* Products */ = {\n+ isa = PBXGroup;\n+ children = (\n+ 7FEB2DEC1E8D64D200C4B763 /* libRNKeychain.a */,\n+ );\n+ name = Products;\n+ sourceTree = \"<group>\";\n+ };\n7FF0870B1E833C3F000A1ACF /* Frameworks */ = {\nisa = PBXGroup;\nchildren = (\n- 7FF0870E1E833C47000A1ACF /* StoreKit.framework */,\n- 7FF0870C1E833C3F000A1ACF /* GameKit.framework */,\n);\nname = Frameworks;\nsourceTree = \"<group>\";\n139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */,\nC3BA31E561EB497494D7882F /* RNVectorIcons.xcodeproj */,\nE7D7D614C3184B1BB95EE661 /* OnePassword.xcodeproj */,\n+ 95EEFC35D4D14053ACA7E064 /* RNKeychain.xcodeproj */,\n);\nname = Libraries;\nsourceTree = \"<group>\";\nProvisioningStyle = Automatic;\nSystemCapabilities = {\ncom.apple.GameCenter = {\n- enabled = 1;\n+ enabled = 0;\n};\ncom.apple.InAppPurchase = {\n+ enabled = 0;\n+ };\n+ com.apple.Keychain = {\nenabled = 1;\n};\ncom.apple.Push = {\nProductGroup = 146834001AC3E56700842450 /* Products */;\nProjectRef = 146833FF1AC3E56700842450 /* React.xcodeproj */;\n},\n+ {\n+ ProductGroup = 7FEB2DCE1E8D64D200C4B763 /* Products */;\n+ ProjectRef = 95EEFC35D4D14053ACA7E064 /* RNKeychain.xcodeproj */;\n+ },\n{\nProductGroup = 7FB58A9D1E7F6B4300B4C1B1 /* Products */;\nProjectRef = C3BA31E561EB497494D7882F /* RNVectorIcons.xcodeproj */;\nremoteRef = 7FB58AD31E80C21000B4C1B1 /* PBXContainerItemProxy */;\nsourceTree = BUILT_PRODUCTS_DIR;\n};\n+ 7FEB2DEC1E8D64D200C4B763 /* libRNKeychain.a */ = {\n+ isa = PBXReferenceProxy;\n+ fileType = archive.ar;\n+ path = libRNKeychain.a;\n+ remoteRef = 7FEB2DEB1E8D64D200C4B763 /* PBXContainerItemProxy */;\n+ sourceTree = BUILT_PRODUCTS_DIR;\n+ };\n832341B51AAA6A8300B99B32 /* libRCTText.a */ = {\nisa = PBXReferenceProxy;\nfileType = archive.ar;\n\"$(inherited)\",\n\"$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager\",\n\"$(SRCROOT)/../node_modules/react-native-onepassword\",\n+ \"$(SRCROOT)/../node_modules/react-native-keychain/RNKeychainManager\",\n);\nINFOPLIST_FILE = SquadCalTests/Info.plist;\nIPHONEOS_DEPLOYMENT_TARGET = 8.0;\n\"$(inherited)\",\n\"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n\"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n+ \"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n);\nOTHER_LDFLAGS = (\n\"-ObjC\",\n\"$(inherited)\",\n\"$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager\",\n\"$(SRCROOT)/../node_modules/react-native-onepassword\",\n+ \"$(SRCROOT)/../node_modules/react-native-keychain/RNKeychainManager\",\n);\nINFOPLIST_FILE = SquadCalTests/Info.plist;\nIPHONEOS_DEPLOYMENT_TARGET = 8.0;\n\"$(inherited)\",\n\"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n\"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n+ \"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n);\nOTHER_LDFLAGS = (\n\"-ObjC\",\n\"$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager\",\n\"$(SRCROOT)/../node_modules/react-native-onepassword\",\n\"$(SRCROOT)/../node_modules/react-native/Libraries/LinkingIOS\",\n+ \"$(SRCROOT)/../node_modules/react-native-keychain/RNKeychainManager\",\n);\nINFOPLIST_FILE = SquadCal/Info.plist;\nLD_RUNPATH_SEARCH_PATHS = \"$(inherited) @executable_path/Frameworks\";\n\"$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager\",\n\"$(SRCROOT)/../node_modules/react-native-onepassword\",\n\"$(SRCROOT)/../node_modules/react-native/Libraries/LinkingIOS\",\n+ \"$(SRCROOT)/../node_modules/react-native-keychain/RNKeychainManager\",\n);\nINFOPLIST_FILE = SquadCal/Info.plist;\nLD_RUNPATH_SEARCH_PATHS = \"$(inherited) @executable_path/Frameworks\";\n\"$(inherited)\",\n\"$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager\",\n\"$(SRCROOT)/../node_modules/react-native-onepassword\",\n+ \"$(SRCROOT)/../node_modules/react-native-keychain/RNKeychainManager\",\n);\nINFOPLIST_FILE = \"SquadCal-tvOS/Info.plist\";\nLD_RUNPATH_SEARCH_PATHS = \"$(inherited) @executable_path/Frameworks\";\n\"$(inherited)\",\n\"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n\"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n+ \"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n);\nOTHER_LDFLAGS = (\n\"-ObjC\",\n\"$(inherited)\",\n\"$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager\",\n\"$(SRCROOT)/../node_modules/react-native-onepassword\",\n+ \"$(SRCROOT)/../node_modules/react-native-keychain/RNKeychainManager\",\n);\nINFOPLIST_FILE = \"SquadCal-tvOS/Info.plist\";\nLD_RUNPATH_SEARCH_PATHS = \"$(inherited) @executable_path/Frameworks\";\n\"$(inherited)\",\n\"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n\"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n+ \"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n);\nOTHER_LDFLAGS = (\n\"-ObjC\",\n\"$(inherited)\",\n\"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n\"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n+ \"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n);\nPRODUCT_BUNDLE_IDENTIFIER = \"com.facebook.REACT.SquadCal-tvOSTests\";\nPRODUCT_NAME = \"$(TARGET_NAME)\";\n\"$(inherited)\",\n\"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n\"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n+ \"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n);\nPRODUCT_BUNDLE_IDENTIFIER = \"com.facebook.REACT.SquadCal-tvOSTests\";\nPRODUCT_NAME = \"$(TARGET_NAME)\";\n"
},
{
"change_type": "MODIFY",
"old_path": "native/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<key>UIRequiredDeviceCapabilities</key>\n<array>\n<string>armv7</string>\n- <string>gamekit</string>\n</array>\n<key>UISupportedInterfaceOrientations</key>\n<array>\n"
},
{
"change_type": "MODIFY",
"old_path": "native/ios/SquadCal/SquadCal.entitlements",
"new_path": "native/ios/SquadCal/SquadCal.entitlements",
"diff": "<array>\n<string>applinks:squadcal.org</string>\n<string>applinks:*.squadcal.org</string>\n+ <string>webcredentials:squadcal.org</string>\n+ <string>webcredentials:*.squadcal.org</string>\n+ </array>\n+ <key>keychain-access-groups</key>\n+ <array>\n+ <string>$(AppIdentifierPrefix)org.squadcal.app</string>\n</array>\n</dict>\n</plist>\n"
},
{
"change_type": "MODIFY",
"old_path": "native/package.json",
"new_path": "native/package.json",
"diff": "\"invariant\": \"^2.2.2\",\n\"react\": \"15.4.2\",\n\"react-native\": \"^0.42.3\",\n+ \"react-native-keychain\": \"^1.1.0\",\n\"react-native-onepassword\": \"^1.0.4\",\n\"react-native-vector-icons\": \"^4.0.0\",\n\"react-navigation\": \"^1.0.0-beta.7\",\n"
},
{
"change_type": "MODIFY",
"old_path": "server/.well-known/apple-app-site-association",
"new_path": "server/.well-known/apple-app-site-association",
"diff": "{\n+ \"webcredentials\": {\n+ \"apps\": [ \"6BF4H9TU5U.org.squadcal.app\" ],\n+ },\n\"applinks\": {\n\"apps\": [],\n\"details\": [\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Mid-progress on keychain and shared web credentials stuff; committing to get apple-app-site-association filed updated |
129,187 | 31.03.2017 17:12:43 | 14,400 | b7cd9fb8147363e85cbbced49ca6b1d39ce26b3d | Working keychain credentials and "shared web credentials" on iOS | [
{
"change_type": "MODIFY",
"old_path": "native/account/log-in-panel.react.js",
"new_path": "native/account/log-in-panel.react.js",
"diff": "@@ -17,7 +17,6 @@ import Icon from 'react-native-vector-icons/FontAwesome';\nimport { connect } from 'react-redux';\nimport invariant from 'invariant';\nimport OnePassword from 'react-native-onepassword';\n-import { getInternetCredentials } from 'react-native-keychain';\nimport {\nvalidUsernameRegex,\n@@ -36,6 +35,10 @@ import {\nPanelOnePasswordButton,\nPanel,\n} from './panel-components.react';\n+import {\n+ fetchNativeCredentials,\n+ setNativeCredentials,\n+} from './native-credentials';\nclass LogInPanel extends React.PureComponent {\n@@ -79,8 +82,13 @@ class LogInPanel extends React.PureComponent {\n}\nasync attemptToFetchCredentials() {\n- const credentials = await getInternetCredentials(\"squadcal.org\");\n- console.log(credentials);\n+ const credentials = await fetchNativeCredentials();\n+ if (credentials) {\n+ this.setState({\n+ usernameOrEmailInputText: credentials.username,\n+ passwordInputText: credentials.password,\n+ });\n+ }\n}\nrender() {\n@@ -204,6 +212,10 @@ class LogInPanel extends React.PureComponent {\nthis.state.passwordInputText,\n);\nthis.props.setActiveAlert(false);\n+ await setNativeCredentials({\n+ username: result.userInfo.username,\n+ password: this.state.passwordInputText,\n+ });\nreturn result;\n} catch (e) {\nif (e.message === 'invalid_parameters') {\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/account/native-credentials.js",
"diff": "+// @flow\n+\n+import { Platform } from 'react-native';\n+import {\n+ getInternetCredentials,\n+ requestSharedWebCredentials,\n+ setInternetCredentials,\n+ setSharedWebCredentials,\n+ resetInternetCredentials,\n+} from 'react-native-keychain';\n+\n+type Credentials = {\n+ username: string,\n+ password: string,\n+};\n+type StoredCredentials = {\n+ state: \"undetermined\" | \"determined\" | \"unsupported\",\n+ credentials: ?Credentials,\n+};\n+let storedNativeKeychainCredentials = {\n+ state: \"undetermined\",\n+ credentials: null,\n+};\n+let storedSharedWebCredentials = {\n+ state: Platform.OS === \"ios\" ? \"undetermined\" : \"unsupported\",\n+ credentials: null,\n+};\n+\n+async function fetchNativeKeychainCredentials(): Promise<?Credentials> {\n+ if (storedNativeKeychainCredentials.state === \"determined\") {\n+ return storedNativeKeychainCredentials.credentials;\n+ }\n+ try {\n+ let credentials = await getInternetCredentials(\"squadcal.org\");\n+ credentials = credentials ? credentials : undefined;\n+ storedNativeKeychainCredentials = { state: \"determined\", credentials };\n+ return credentials;\n+ } catch (e) {\n+ const credentials = null;\n+ storedNativeKeychainCredentials = { state: \"unsupported\", credentials };\n+ return credentials;\n+ }\n+}\n+\n+async function fetchNativeSharedWebCredentials(): Promise<?Credentials> {\n+ if (Platform.OS !== \"ios\") {\n+ return null;\n+ }\n+ if (storedSharedWebCredentials.state === \"determined\") {\n+ return storedSharedWebCredentials.credentials;\n+ }\n+ try {\n+ let credentials = await requestSharedWebCredentials(\"squadcal.org\");\n+ credentials = credentials ? credentials : undefined;\n+ storedSharedWebCredentials = { state: \"determined\", credentials };\n+ return credentials;\n+ } catch (e) {\n+ const credentials = null;\n+ storedSharedWebCredentials = { state: \"unsupported\", credentials };\n+ return credentials;\n+ }\n+}\n+\n+async function fetchNativeCredentials(): Promise<?Credentials> {\n+ const keychainCredentials = await fetchNativeKeychainCredentials();\n+ if (keychainCredentials) {\n+ return keychainCredentials;\n+ }\n+ return await fetchNativeSharedWebCredentials();\n+}\n+\n+async function setNativeKeychainCredentials(credentials: Credentials) {\n+ const current = await fetchNativeKeychainCredentials();\n+ if (\n+ current &&\n+ credentials.username === current.username &&\n+ credentials.password === current.password\n+ ) {\n+ return;\n+ }\n+ try {\n+ await setInternetCredentials(\n+ \"squadcal.org\",\n+ credentials.username,\n+ credentials.password,\n+ );\n+ storedNativeKeychainCredentials = { state: \"determined\", credentials };\n+ } catch (e) {\n+ storedNativeKeychainCredentials = {\n+ state: \"unsupported\",\n+ credentials: null,\n+ };\n+ }\n+}\n+\n+async function setNativeSharedWebCredentials(credentials: Credentials) {\n+ if (Platform.OS !== \"ios\") {\n+ return;\n+ }\n+ const current = await fetchNativeSharedWebCredentials();\n+ if (\n+ current &&\n+ credentials.username === current.username &&\n+ credentials.password === current.password\n+ ) {\n+ return;\n+ }\n+ try {\n+ await setSharedWebCredentials(\n+ \"squadcal.org\",\n+ credentials.username,\n+ credentials.password,\n+ );\n+ storedSharedWebCredentials = { state: \"determined\", credentials };\n+ } catch (e) {\n+ storedSharedWebCredentials = { state: \"unsupported\", credentials: null };\n+ }\n+}\n+\n+async function setNativeCredentials(credentials: Credentials) {\n+ await Promise.all([\n+ setNativeKeychainCredentials(credentials),\n+ setNativeSharedWebCredentials(credentials),\n+ ]);\n+}\n+\n+async function deleteNativeKeychainCredentials() {\n+ try {\n+ await resetInternetCredentials(\"squadcal.org\");\n+ storedNativeKeychainCredentials = {\n+ state: \"determined\",\n+ credentials: undefined,\n+ };\n+ } catch(e) {\n+ storedNativeKeychainCredentials = {\n+ state: \"unsupported\",\n+ credentials: null,\n+ };\n+ }\n+}\n+\n+async function deleteNativeSharedWebCredentialsFor(username: string) {\n+ if (Platform.OS !== \"ios\") {\n+ return;\n+ }\n+ try {\n+ // This native call will display a modal iff credentials are non-null,\n+ // so we don't need to worry about checking our current state\n+ await setSharedWebCredentials(\"squadcal.org\", username, null);\n+ storedSharedWebCredentials = {\n+ state: \"determined\",\n+ credentials: undefined,\n+ };\n+ } catch(e) {\n+ storedSharedWebCredentials = {\n+ state: \"unsupported\",\n+ credentials: null,\n+ };\n+ }\n+}\n+\n+async function deleteNativeCredentialsFor(username: string) {\n+ await Promise.all([\n+ deleteNativeKeychainCredentials(),\n+ deleteNativeSharedWebCredentialsFor(username),\n+ ]);\n+}\n+\n+export {\n+ fetchNativeCredentials,\n+ fetchNativeSharedWebCredentials,\n+ setNativeCredentials,\n+ deleteNativeCredentialsFor,\n+};\n"
},
{
"change_type": "MODIFY",
"old_path": "native/account/register-panel.react.js",
"new_path": "native/account/register-panel.react.js",
"diff": "@@ -36,6 +36,7 @@ import {\nPanelOnePasswordButton,\nPanel,\n} from './panel-components.react';\n+import { setNativeCredentials } from './native-credentials';\nclass RegisterPanel extends React.PureComponent {\n@@ -311,6 +312,10 @@ class RegisterPanel extends React.PureComponent {\nthis.state.passwordInputText,\n);\nthis.props.setActiveAlert(false);\n+ await setNativeCredentials({\n+ username: result.username,\n+ password: this.state.passwordInputText,\n+ });\nreturn result;\n} catch (e) {\nif (e.message === 'username_taken') {\n"
},
{
"change_type": "MODIFY",
"old_path": "native/more/more.react.js",
"new_path": "native/more/more.react.js",
"diff": "@@ -6,9 +6,10 @@ import type { AppState } from '../redux-setup';\nimport type { CalendarInfo } from 'lib/types/calendar-types';\nimport React from 'react';\n-import { View, StyleSheet, Text, Button } from 'react-native';\n+import { View, StyleSheet, Text, Button, Alert, Platform } from 'react-native';\nimport Icon from 'react-native-vector-icons/FontAwesome';\nimport { connect } from 'react-redux';\n+import invariant from 'invariant';\nimport { registerFetchKey } from 'lib/reducers/loading-reducer';\nimport {\n@@ -18,12 +19,17 @@ import {\nimport { logOutActionType, logOut } from 'lib/actions/user-actions';\nimport ConnectedStatusBar from '../connected-status-bar.react';\n+import {\n+ fetchNativeSharedWebCredentials,\n+ deleteNativeCredentialsFor,\n+} from '../account/native-credentials';\nclass More extends React.PureComponent {\nprops: {\nnavigation: NavigationScreenProp<*, *>,\n// Redux state\n+ username: ?string,\n// Redux dispatch functions\ndispatchActionPromise: DispatchActionPromise,\n// async functions that hit server APIs\n@@ -35,6 +41,7 @@ class More extends React.PureComponent {\nnavigation: React.PropTypes.shape({\nnavigate: React.PropTypes.func.isRequired,\n}).isRequired,\n+ username: React.PropTypes.string,\ndispatchActionPromise: React.PropTypes.func.isRequired,\nlogOut: React.PropTypes.func.isRequired,\n};\n@@ -67,15 +74,60 @@ class More extends React.PureComponent {\n);\n}\n- onPress = () => {\n- this.props.dispatchActionPromise(logOutActionType, this.logOutAction());\n+ onPress = async () => {\n+ const alertTitle = Platform.OS === \"ios\"\n+ ? \"Keep Login Info in Keychain\"\n+ : \"Keep Login Info\";\n+ const sharedWebCredentials = await fetchNativeSharedWebCredentials();\n+ const alertDescription = sharedWebCredentials\n+ ? \"We will automatically fill out log-in forms with your credentials \" +\n+ \"in the app and keep them available on squadcal.org in Safari.\"\n+ : \"We will automatically fill out log-in forms with your credentials \" +\n+ \"in the app.\";\n+ Alert.alert(\n+ alertTitle,\n+ alertDescription,\n+ [\n+ { text: 'Keep', onPress: this.logOutButKeepNativeCredentialsWrapper },\n+ {\n+ text: 'Remove',\n+ onPress: this.logOutAndDeleteNativeCredentialsWrapper,\n+ style: 'destructive',\n+ },\n+ ],\n+ { cancelable: false },\n+ );\n+ }\n+\n+ logOutButKeepNativeCredentialsWrapper = () => {\n+ this.props.dispatchActionPromise(\n+ logOutActionType,\n+ this.logOutButKeepNativeCredentials(),\n+ );\n}\n- async logOutAction() {\n+ async logOutButKeepNativeCredentials() {\nawait this.props.logOut();\nthis.props.navigation.navigate('LoggedOutModal');\n}\n+ logOutAndDeleteNativeCredentialsWrapper = () => {\n+ this.props.dispatchActionPromise(\n+ logOutActionType,\n+ this.logOutAndDeleteNativeCredentials(),\n+ );\n+ }\n+\n+ async logOutAndDeleteNativeCredentials() {\n+ const username = this.props.username;\n+ invariant(username, \"can't log out if not logged in\");\n+ await Promise.all([\n+ this.props.logOut(),\n+ deleteNativeCredentialsFor(username),\n+ ]);\n+ this.props.navigation.navigate('LoggedOutModal');\n+ }\n+\n}\nconst styles = StyleSheet.create({\n@@ -100,6 +152,7 @@ registerFetchKey(logOutActionType);\nexport default connect(\n(state: AppState) => ({\ncookie: state.cookie,\n+ username: state.userInfo && state.userInfo.username,\n}),\nincludeDispatchActionProps({ dispatchActionPromise: true }),\nbindServerCalls({ logOut }),\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Working keychain credentials and "shared web credentials" on iOS |
129,187 | 31.03.2017 17:34:10 | 14,400 | fafe33d9e397c56321b48f1c90f79cef5c95b8b0 | Make LOG_OUT_SUCCESS action handle nav stuff instead of doing it in a separate action | [
{
"change_type": "MODIFY",
"old_path": "native/more/more.react.js",
"new_path": "native/more/more.react.js",
"diff": "@@ -102,15 +102,10 @@ class More extends React.PureComponent {\nlogOutButKeepNativeCredentialsWrapper = () => {\nthis.props.dispatchActionPromise(\nlogOutActionType,\n- this.logOutButKeepNativeCredentials(),\n+ this.props.logOut(),\n);\n}\n- async logOutButKeepNativeCredentials() {\n- await this.props.logOut();\n- this.props.navigation.navigate('LoggedOutModal');\n- }\n-\nlogOutAndDeleteNativeCredentialsWrapper = () => {\nthis.props.dispatchActionPromise(\nlogOutActionType,\n@@ -125,7 +120,6 @@ class More extends React.PureComponent {\nthis.props.logOut(),\ndeleteNativeCredentialsFor(username),\n]);\n- this.props.navigation.navigate('LoggedOutModal');\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "native/navigation-setup.js",
"new_path": "native/navigation-setup.js",
"diff": "@@ -6,6 +6,7 @@ import type { NavigationState } from 'react-navigation';\nimport { TabNavigator, StackNavigator } from 'react-navigation';\nimport invariant from 'invariant';\n+import _findIndex from 'lodash/fp/findIndex';\nimport { partialNavInfoFromURL } from 'lib/utils/url-utils';\n@@ -89,6 +90,11 @@ function reduceNavInfo(state: NavInfo, action: Action): NavInfo {\n...state,\nnavigationState: removeModals(state.navigationState),\n};\n+ } else if (action.type === \"LOG_OUT_SUCCESS\") {\n+ return {\n+ ...state,\n+ navigationState: ensureLoggedOutModalPresence(state.navigationState),\n+ };\n}\nreturn state;\n}\n@@ -159,6 +165,26 @@ function removeModals(state: NavigationState): NavigationState {\n}\n}\n+function ensureLoggedOutModalPresence(state: NavigationState): NavigationState {\n+ const currentModalIndex =\n+ _findIndex(['routeName', 'LoggedOutModal'])(state.routes);\n+ if (currentModalIndex >= 0 && state.index >= currentModalIndex) {\n+ return state;\n+ } else if (currentModalIndex >= 0) {\n+ return {\n+ index: currentModalIndex,\n+ routes: state.routes,\n+ };\n+ }\n+ return {\n+ index: state.routes.length,\n+ routes: [\n+ ...state.routes,\n+ { key: 'LoggedOutModal', routeName: 'LoggedOutModal' },\n+ ],\n+ };\n+}\n+\nexport {\nRootNavigator,\ndefaultNavigationState,\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Make LOG_OUT_SUCCESS action handle nav stuff instead of doing it in a separate action |
129,187 | 01.04.2017 11:47:57 | 14,400 | 0e98b44ca46e311250152b3b284725433f405988 | Create ping endpoint | [
{
"change_type": "ADD",
"old_path": null,
"new_path": "server/ping.php",
"diff": "+<?php\n+\n+require_once('async_lib.php');\n+require_once('config.php');\n+require_once('auth.php');\n+require_once('calendar_lib.php');\n+\n+async_start();\n+\n+$viewer_id = get_viewer_id();\n+$user_logged_in = user_logged_in();\n+\n+$user_info = null;\n+if ($user_logged_in) {\n+ $result = $conn->query(\n+ \"SELECT username, email, email_verified FROM users WHERE id = $viewer_id\"\n+ );\n+ $user_row = $result->fetch_assoc();\n+ if (!$user_row) {\n+ async_end(array(\n+ 'error' => 'unknown_error',\n+ ));\n+ }\n+ $user_info = array(\n+ 'username' => $user_row['username'],\n+ 'email' => $user_row['email'],\n+ 'email_verified' => (bool)$user_row['email_verified'],\n+ );\n+}\n+\n+async_end(array(\n+ 'user_info' => $user_info,\n+ 'calendar_infos' => get_calendar_infos(),\n+));\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Create ping endpoint |
129,187 | 01.04.2017 16:17:10 | 14,400 | 482cb67f3cd6c6c351ae2360a93c97a9c32a7a66 | Show LoggedOutModal immediately upon logout and also fix up some shared web credentials behavior to avoid unnecessary modal alerts on iOS | [
{
"change_type": "MODIFY",
"old_path": "native/account/native-credentials.js",
"new_path": "native/account/native-credentials.js",
"diff": "@@ -42,6 +42,16 @@ async function fetchNativeKeychainCredentials(): Promise<?Credentials> {\n}\n}\n+function getNativeSharedWebCredentials(): ?Credentials {\n+ if (Platform.OS !== \"ios\") {\n+ return null;\n+ }\n+ if (storedSharedWebCredentials.state !== \"determined\") {\n+ return null;\n+ }\n+ return storedSharedWebCredentials.credentials;\n+}\n+\nasync function fetchNativeSharedWebCredentials(): Promise<?Credentials> {\nif (Platform.OS !== \"ios\") {\nreturn null;\n@@ -97,11 +107,30 @@ async function setNativeSharedWebCredentials(credentials: Credentials) {\nif (Platform.OS !== \"ios\") {\nreturn;\n}\n- const current = await fetchNativeSharedWebCredentials();\n+ const currentKeychainCredentials = await fetchNativeKeychainCredentials();\n+ // If the password entered is the same as what we've got in the native\n+ // keychain, then assume that nothing has been changed. We exit early here\n+ // because if there are already shared web credentials, the\n+ // setSharedWebCredentials call below will pop up an alert regardless of\n+ // whether the credentials we pass it are the same as what it already has.\nif (\n- current &&\n- credentials.username === current.username &&\n- credentials.password === current.password\n+ currentKeychainCredentials &&\n+ credentials.username === currentKeychainCredentials.username &&\n+ credentials.password === currentKeychainCredentials.password\n+ ) {\n+ return;\n+ }\n+ // You might think we should just check fetchNativeSharedWebCredentials to\n+ // see if the new shared web credentials we are about to pass to\n+ // setSharedWebCredentials are the same as what it already has. But it turns\n+ // out that that will trigger an alert too, which isn't worth it because we're\n+ // only checking it to prevent an unnecessary alert. The smart thing we can do\n+ // is check our internal cache.\n+ const cachedSharedWebCredentials = getNativeSharedWebCredentials();\n+ if (\n+ cachedSharedWebCredentials &&\n+ credentials.username === cachedSharedWebCredentials.username &&\n+ credentials.password === cachedSharedWebCredentials.password\n) {\nreturn;\n}\n@@ -168,7 +197,7 @@ async function deleteNativeCredentialsFor(username: string) {\nexport {\nfetchNativeCredentials,\n- fetchNativeSharedWebCredentials,\n+ getNativeSharedWebCredentials,\nsetNativeCredentials,\ndeleteNativeCredentialsFor,\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "native/more/more.react.js",
"new_path": "native/more/more.react.js",
"diff": "@@ -20,7 +20,7 @@ import { logOutActionType, logOut } from 'lib/actions/user-actions';\nimport ConnectedStatusBar from '../connected-status-bar.react';\nimport {\n- fetchNativeSharedWebCredentials,\n+ getNativeSharedWebCredentials,\ndeleteNativeCredentialsFor,\n} from '../account/native-credentials';\n@@ -78,7 +78,7 @@ class More extends React.PureComponent {\nconst alertTitle = Platform.OS === \"ios\"\n? \"Keep Login Info in Keychain\"\n: \"Keep Login Info\";\n- const sharedWebCredentials = await fetchNativeSharedWebCredentials();\n+ const sharedWebCredentials = await getNativeSharedWebCredentials();\nconst alertDescription = sharedWebCredentials\n? \"We will automatically fill out log-in forms with your credentials \" +\n\"in the app and keep them available on squadcal.org in Safari.\"\n"
},
{
"change_type": "MODIFY",
"old_path": "native/navigation-setup.js",
"new_path": "native/navigation-setup.js",
"diff": "@@ -90,7 +90,7 @@ function reduceNavInfo(state: NavInfo, action: Action): NavInfo {\n...state,\nnavigationState: removeModals(state.navigationState),\n};\n- } else if (action.type === \"LOG_OUT_SUCCESS\") {\n+ } else if (action.type === \"LOG_OUT_STARTED\") {\nreturn {\n...state,\nnavigationState: ensureLoggedOutModalPresence(state.navigationState),\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Show LoggedOutModal immediately upon logout and also fix up some shared web credentials behavior to avoid unnecessary modal alerts on iOS |
129,187 | 01.04.2017 17:33:41 | 14,400 | c2cfcf06f09643c2ac6b8c84c73ba9c284c0297a | Ping boilerplate and a bugfix for the last commit | [
{
"change_type": "ADD",
"old_path": null,
"new_path": "lib/actions/ping-actions.js",
"diff": "+// @flow\n+\n+import type { FetchJSON } from '../utils/fetch-json';\n+\n+const pingActionType = \"PING\";\n+async function ping(fetchJSON: FetchJSON): Promise<void> {\n+ await fetchJSON('ping.php', {});\n+}\n+\n+export {\n+ pingActionType,\n+ ping,\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/types/redux-types.js",
"new_path": "lib/types/redux-types.js",
"diff": "@@ -300,6 +300,17 @@ export type BaseAction =\n// a cookie invalidation\ncookieInvalidated: bool,\n},\n+ } | {\n+ type: \"PING_STARTED\",\n+ loadingInfo: LoadingInfo,\n+ } | {\n+ type: \"PING_FAILED\",\n+ error: true,\n+ payload: Error,\n+ loadingInfo: LoadingInfo,\n+ } | {\n+ type: \"PING_SUCCESS\",\n+ loadingInfo: LoadingInfo,\n};\ntype ThunkedAction<T: BaseAppState, A> = (dispatch: Dispatch<T, A>) => void;\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/utils/action-utils.js",
"new_path": "lib/utils/action-utils.js",
"diff": "@@ -118,13 +118,14 @@ function bindCookieAndUtilsIntoServerCall<B>(\ncookie: ?string,\n) {\nconst setCookie = (newCookie: ?string, response: Object) => {\n+ if (newCookie !== cookie) {\ninvariant(\nresponse.cookie_change &&\nresponse.cookie_change.calendar_infos &&\ntypeof response.cookie_change.cookie_invalidated === \"boolean\",\n- \"all server calls that return a new cookie should include cookie_change\",\n+ \"all server calls that return a new cookie should include a valid\" +\n+ \"cookie_change object in their payload\",\n);\n- if (newCookie !== cookie) {\ndispatch({\ntype: \"SET_COOKIE\",\npayload: {\n"
},
{
"change_type": "MODIFY",
"old_path": "native/more/more.react.js",
"new_path": "native/more/more.react.js",
"diff": "@@ -17,6 +17,7 @@ import {\nbindServerCalls,\n} from 'lib/utils/action-utils';\nimport { logOutActionType, logOut } from 'lib/actions/user-actions';\n+import { pingActionType, ping } from 'lib/actions/ping-actions';\nimport ConnectedStatusBar from '../connected-status-bar.react';\nimport {\n@@ -34,6 +35,7 @@ class More extends React.PureComponent {\ndispatchActionPromise: DispatchActionPromise,\n// async functions that hit server APIs\nlogOut: () => Promise<CalendarInfo[]>,\n+ ping: () => Promise<void>,\n};\nstate: {};\n@@ -44,6 +46,7 @@ class More extends React.PureComponent {\nusername: React.PropTypes.string,\ndispatchActionPromise: React.PropTypes.func.isRequired,\nlogOut: React.PropTypes.func.isRequired,\n+ ping: React.PropTypes.func.isRequired,\n};\nstatic navigationOptions = {\n@@ -66,15 +69,19 @@ class More extends React.PureComponent {\nCmd+D or shake for dev menu\n</Text>\n<Button\n- onPress={this.onPress}\n+ onPress={this.onPressLogOut}\ntitle=\"Log out\"\n/>\n+ <Button\n+ onPress={this.onPressPing}\n+ title=\"Ping\"\n+ />\n<ConnectedStatusBar />\n</View>\n);\n}\n- onPress = async () => {\n+ onPressLogOut = async () => {\nconst alertTitle = Platform.OS === \"ios\"\n? \"Keep Login Info in Keychain\"\n: \"Keep Login Info\";\n@@ -122,6 +129,13 @@ class More extends React.PureComponent {\n]);\n}\n+ onPressPing = () => {\n+ this.props.dispatchActionPromise(\n+ pingActionType,\n+ this.props.ping(),\n+ );\n+ }\n+\n}\nconst styles = StyleSheet.create({\n@@ -149,5 +163,5 @@ export default connect(\nusername: state.userInfo && state.userInfo.username,\n}),\nincludeDispatchActionProps({ dispatchActionPromise: true }),\n- bindServerCalls({ logOut }),\n+ bindServerCalls({ logOut, ping }),\n)(More);\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Ping boilerplate and a bugfix for the last commit |
129,187 | 03.04.2017 17:04:05 | 14,400 | 2fd7eddd6376420425f92ba01571a8a92a1b7568 | redux-persist! Prioritize redux-persist's cookie over native | [
{
"change_type": "MODIFY",
"old_path": "lib/reducers/cookie-reducer.js",
"new_path": "lib/reducers/cookie-reducer.js",
"diff": "// @flow\n-import type {\n- BaseAppState,\n- BaseAction,\n-} from '../types/redux-types';\n+import type { BaseAppState, BaseAction } from '../types/redux-types';\nexport default function reduceCookie(state: ?string, action: BaseAction) {\n// If the cookie is undefined, that means we're deferring to the environment\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/types/redux-types.js",
"new_path": "lib/types/redux-types.js",
"diff": "@@ -320,9 +320,9 @@ type ThunkedAction<T: BaseAppState, A> = (dispatch: Dispatch<T, A>) => void;\ntype PromisedAction<T: BaseAppState, A> =\n(dispatch: Dispatch<T, A>) => Promise<void>;\nexport type Dispatch<T: BaseAppState, A> =\n- ((action: A) => void) &\n- ((action: BaseAction) => void) &\n- ((thunkedAction: ThunkedAction<T, A>) => void) &\n- ((thunkedAction: ThunkedAction<T, BaseAction>) => void) &\n+ ((promisedAction: PromisedAction<T, BaseAction>) => Promise<void>) &\n((promisedAction: PromisedAction<T, A>) => Promise<void>) &\n- ((promisedAction: PromisedAction<T, BaseAction>) => Promise<void>);\n+ ((thunkedAction: ThunkedAction<T, BaseAction>) => void) &\n+ ((thunkedAction: ThunkedAction<T, A>) => void) &\n+ ((action: BaseAction) => BaseAction) &\n+ ((action: A) => A);\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/utils/action-utils.js",
"new_path": "lib/utils/action-utils.js",
"diff": "@@ -87,8 +87,6 @@ function includeDispatchActionProps<T: BaseAppState, A, P>(\npromise: Promise<P>,\nloadingOptions?: LoadingOptions,\nstartingPayload?: any,\n- // Flow can't handle how Redux middleware like redux-thunk\n- // can change dispatch's return type $FlowFixMe\n) => dispatch(wrapActionPromise(\nactionType,\npromise,\n@@ -98,8 +96,9 @@ function includeDispatchActionProps<T: BaseAppState, A, P>(\n}\nif (whichOnes.dispatchActionPayload) {\nboundActions.dispatchActionPayload =\n- (actionType: string, payload: P) =>\n+ (actionType: string, payload: P) => {\ndispatch({ type: actionType, payload });\n+ };\n}\nreturn boundActions;\n};\n@@ -112,7 +111,7 @@ export type DispatchRecoveryAttempt =\n(actionType: string, promise: Promise<*>) => Promise<?string>;\nfunction setCookie(\n- dispatch: (action: BaseAction) => void,\n+ dispatch: (action: BaseAction) => BaseAction,\ncurrentCookie: ?string,\nnewCookie: ?string,\nresponse: ?Object,\n@@ -146,8 +145,8 @@ function setCookie(\n// Third param is optional and gets called with newCookie if we get a new cookie\n// Necessary to propagate cookie in cookieInvalidationRecovery below\n-function bindCookieAndUtilsIntoFetchJSON(\n- dispatch: (action: BaseAction) => void,\n+function bindCookieAndUtilsIntoFetchJSON<T: BaseAppState, A>(\n+ dispatch: Dispatch<T, A>,\ncookie: ?string,\n): FetchJSON {\nconst boundSetCookie = (newCookie: ?string, response: Object) => {\n@@ -205,8 +204,6 @@ function bindCookieAndUtilsIntoFetchJSON(\nactionType: string,\npromise: Promise<*>,\n) => {\n- // Flow can't handle how Redux middleware like redux-thunk\n- // can change dispatch's return type $FlowFixMe\ndispatch(wrapActionPromise(\nactionType,\npromise,\n@@ -269,9 +266,9 @@ function bindCookieAndUtilsIntoFetchJSON(\n// onto fetchJSON within react-redux's connect's mapStateToProps function, and\n// then pass that \"bound\" fetchJSON that no longer needs the cookie as a\n// parameter on to the server call.\n-function bindCookieAndUtilsIntoServerCall<B>(\n+function bindCookieAndUtilsIntoServerCall<T: BaseAppState, A, B>(\nactionFunc: (fetchJSON: FetchJSON, ...rest: any) => Promise<B>,\n- dispatch: (action: BaseAction) => void,\n+ dispatch: Dispatch<T, A>,\ncookie: ?string,\n) {\nconst boundFetchJSON = bindCookieAndUtilsIntoFetchJSON(dispatch, cookie);\n@@ -284,10 +281,6 @@ function bindServerCalls(\nserverCalls:\n{[name: string]: (fetchJSON: FetchJSON, ...rest: any) => Promise<any>},\n) {\n- // Flow can't handle when I type dispatchProps correctly. I think it's because\n- // our dispatch is incompatible with the flow-typed one, since the flow-typed\n- // one doesn't consider redux-thunk. It seems that Flow can't handle how Redux\n- // middleware like redux-thunk can change dispatch's return type.\nreturn (\nstateProps: { cookie: ?string },\ndispatchProps: Object,\n"
},
{
"change_type": "MODIFY",
"old_path": "native/.flowconfig",
"new_path": "native/.flowconfig",
"diff": ".*/Libraries/react-native/ReactNative.js\n[include]\n+../lib\n[libs]\nnode_modules/react-native/Libraries/react-native/react-native-interface.js\n@@ -32,6 +33,7 @@ experimental.strict_type_args=true\nmunge_underscores=true\nmodule.name_mapper='^[./a-zA-Z0-9$_-]+\\.\\(bmp\\|gif\\|jpg\\|jpeg\\|png\\|psd\\|svg\\|webp\\|m4v\\|mov\\|mp4\\|mpeg\\|mpg\\|webm\\|aac\\|aiff\\|caf\\|m4a\\|mp3\\|wav\\|html\\|pdf\\)$' -> 'RelativeImageStub'\n+module.name_mapper='^lib/(.*)$' -> '<PROJECT_ROOT>/../lib/\\1'\nsuppress_type=$FlowIssue\nsuppress_type=$FlowFixMe\n"
},
{
"change_type": "MODIFY",
"old_path": "native/account/native-credentials.js",
"new_path": "native/account/native-credentials.js",
"diff": "@@ -267,9 +267,7 @@ function setNativeCookie(cookie: string) {\nCookieManager.setFromResponse(\ngetConfig().urlPrefix,\nconstructedCookieHeader,\n- response => response\n- ? resolve()\n- : reject(new Error(\"failed to set native cookie\")),\n+ alwaysNull => resolve(),\n);\n});\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "native/app.react.js",
"new_path": "native/app.react.js",
"diff": "@@ -9,11 +9,12 @@ import type { Action } from './navigation-setup';\nimport React from 'react';\nimport { createStore, applyMiddleware } from 'redux';\nimport { Provider, connect } from 'react-redux';\n-import { AppRegistry, Platform, UIManager } from 'react-native';\n+import { AppRegistry, Platform, UIManager, AsyncStorage } from 'react-native';\nimport { addNavigationHelpers } from 'react-navigation';\nimport { composeWithDevTools } from 'remote-redux-devtools';\nimport thunk from 'redux-thunk';\nimport invariant from 'invariant';\n+import { autoRehydrate, persistStore } from 'redux-persist';\nimport { registerConfig } from 'lib/utils/config';\nimport { setCookie } from 'lib/utils/action-utils';\n@@ -26,49 +27,16 @@ import {\nsetNativeCookie,\n} from './account/native-credentials';\n-type AppProps = {\n- navigationState: NavigationState,\n- cookie: ?string,\n- dispatch: Dispatch<AppState, Action>,\n-};\nclass AppWithNavigationState extends React.PureComponent {\nstatic propTypes = {\nnavigationState: ReactNavigationPropTypes.navigationState,\n- cookie: React.PropTypes.string,\ndispatch: React.PropTypes.func.isRequired,\n};\n- props: AppProps;\n-\n- constructor(props: AppProps) {\n- super(props);\n- this.getInitialNativeCookie().then();\n- }\n-\n- async getInitialNativeCookie() {\n- // In general, when the app starts we preference the cookie from the native\n- // store rather than what we have in Redux. The exception is when the cookie\n- // in Redux represents a higher level of authentication. This situation can\n- // happen if redux-persist persists faster than the native Android cookie\n- // manager, which can take up to 10s to persist new cookies.\n- const nativeCookie = await getNativeCookie();\n- if (\n- nativeCookie &&\n- (\n- nativeCookie.startsWith(\"user=\") ||\n- !this.props.cookie ||\n- !this.props.cookie.startsWith(\"user=\")\n- )\n- ) {\n- setCookie(this.props.dispatch, this.props.cookie, nativeCookie, null);\n- } else if (nativeCookie !== this.props.cookie) {\n- invariant(\n- this.props.cookie,\n- \"flow can't tell, but the conditionals guarantee this\",\n- );\n- await setNativeCookie(this.props.cookie);\n- }\n- }\n+ props: {\n+ navigationState: NavigationState,\n+ dispatch: Dispatch<AppState, Action>,\n+ };\nrender() {\nconst navigation = addNavigationHelpers({\n@@ -108,13 +76,15 @@ if (Platform.OS === \"android\") {\nconst ConnectedAppWithNavigationState = connect(\n(state: AppState) => ({\nnavigationState: state.navInfo.navigationState,\n- cookie: state.cookie,\n}),\n)(AppWithNavigationState);\nconst store = createStore(\nreducer,\ndefaultState,\n- composeWithDevTools(applyMiddleware(thunk)),\n+ composeWithDevTools(\n+ applyMiddleware(thunk),\n+ autoRehydrate(),\n+ ),\n);\nconst App = (props: {}) =>\n<Provider store={store}>\n@@ -122,3 +92,20 @@ const App = (props: {}) =>\n</Provider>;\nAppRegistry.registerComponent('SquadCal', () => App);\n+\n+const postRehydrationCallback = async () => {\n+ const cookie = store.getState().cookie;\n+ if (cookie) {\n+ await setNativeCookie(cookie);\n+ } else {\n+ const nativeCookie = await getNativeCookie();\n+ if (nativeCookie) {\n+ setCookie(store.dispatch, cookie, nativeCookie, null);\n+ }\n+ }\n+};\n+persistStore(\n+ store,\n+ { storage: AsyncStorage },\n+ () => postRehydrationCallback().then(),\n+);\n"
},
{
"change_type": "MODIFY",
"old_path": "native/package.json",
"new_path": "native/package.json",
"diff": "\"react-navigation\": \"^1.0.0-beta.7\",\n\"react-redux\": \"^5.0.2\",\n\"redux\": \"^3.6.0\",\n+ \"redux-persist\": \"^4.6.0\",\n\"redux-thunk\": \"^2.2.0\",\n\"url-parse\": \"^1.1.8\"\n},\n"
},
{
"change_type": "MODIFY",
"old_path": "web/.flowconfig",
"new_path": "web/.flowconfig",
"diff": ".*/node_modules/fbjs/.*\n[include]\n+../lib\n[libs]\n[options]\nmodule.name_mapper.extension='css' -> '<PROJECT_ROOT>/flow/CSSModule.js.flow'\n+module.name_mapper='^lib/(.*)$' -> '<PROJECT_ROOT>/../lib/\\1'\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | redux-persist! Prioritize redux-persist's cookie over native |
129,187 | 03.04.2017 23:46:40 | 14,400 | 92082c29a83022157de6baf90bcff6ca76940080 | Apparently CookieManager.setFromResponse takes a different input type between iOS and Android. Weird. Also, added a cancel button to the log-out prompt | [
{
"change_type": "MODIFY",
"old_path": "native/account/native-credentials.js",
"new_path": "native/account/native-credentials.js",
"diff": "@@ -263,10 +263,13 @@ function setNativeCookie(cookie: string) {\nconst constructedCookieHeader =\n`${encodedCookie}; domain=${parsedURL.host}; path=${parsedURL.pathname}; ` +\n`expires=${date.toUTCString()}; Max-Age=${maxAge}; ${secure}httponly`;\n+ const cookieInput = Platform.OS === \"ios\"\n+ ? { 'Set-Cookie': constructedCookieHeader }\n+ : constructedCookieHeader;\nreturn new Promise((resolve, reject) => {\nCookieManager.setFromResponse(\ngetConfig().urlPrefix,\n- constructedCookieHeader,\n+ cookieInput,\nalwaysNull => resolve(),\n);\n});\n"
},
{
"change_type": "MODIFY",
"old_path": "native/more/more.react.js",
"new_path": "native/more/more.react.js",
"diff": "@@ -95,6 +95,7 @@ class More extends React.PureComponent {\nalertTitle,\nalertDescription,\n[\n+ { text: 'Cancel', style: 'cancel' },\n{ text: 'Keep', onPress: this.logOutButKeepNativeCredentialsWrapper },\n{\ntext: 'Remove',\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Apparently CookieManager.setFromResponse takes a different input type between iOS and Android. Weird. Also, added a cancel button to the log-out prompt |
129,187 | 05.04.2017 16:49:19 | 14,400 | 41f915cbefccddd2e6604e1be0988d94cc738644 | Fix some weird JSON behavior hopefully | [
{
"change_type": "MODIFY",
"old_path": "server/async_lib.php",
"new_path": "server/async_lib.php",
"diff": "require_once('config.php');\nrequire_once('auth.php');\nrequire_once('calendar_lib.php');\n+require_once('json_lib.php');\nfunction async_exit($payload) {\n- exit(json_encode($payload));\n+ exit(utf8_json_encode($payload));\n}\nfunction async_start() {\n"
},
{
"change_type": "MODIFY",
"old_path": "server/delete_account.php",
"new_path": "server/delete_account.php",
"diff": "@@ -7,9 +7,9 @@ require_once('auth.php');\nasync_start();\nif (!user_logged_in()) {\n- exit(json_encode(array(\n+ async_end(array(\n'error' => 'not_logged_in',\n- )));\n+ ));\n}\nif (!isset($_POST['password'])) {\nasync_end(array(\n"
},
{
"change_type": "MODIFY",
"old_path": "server/index.php",
"new_path": "server/index.php",
"diff": "@@ -4,6 +4,7 @@ require_once('config.php');\nrequire_once('auth.php');\nrequire_once('verify_lib.php');\nrequire_once('calendar_lib.php');\n+require_once('json_lib.php');\nif ($https && !isset($_SERVER['HTTPS'])) {\n// We're using mod_rewrite .htaccess for HTTPS redirect; this shouldn't happen\n@@ -191,8 +192,8 @@ HTML;\nvar username = \"<?=$username?>\";\nvar email = \"<?=$email?>\";\nvar email_verified = <?=($email_verified ? \"true\" : \"false\")?>;\n- var calendar_infos = <?=json_encode($calendar_infos, JSON_FORCE_OBJECT)?>;\n- var entry_infos = <?=json_encode($entries)?>;\n+ var calendar_infos = <?=utf8_json_encode($calendar_infos, JSON_FORCE_OBJECT)?>;\n+ var entry_infos = <?=utf8_json_encode($entries)?>;\nvar month = <?=$month?>;\nvar year = <?=$year?>;\nvar base_url = \"<?=$base_url?>\";\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "server/json_lib.php",
"diff": "+<?php\n+\n+function recursive_utf8_encode($payload) {\n+ if (is_array($payload)) {\n+ foreach ($payload as $key => $value) {\n+ $payload[$key] = recursive_utf8_encode($value);\n+ }\n+ } else if (is_string($payload)) {\n+ return utf8_encode($payload);\n+ }\n+ return $payload;\n+}\n+\n+function utf8_json_encode($payload, $options = 0) {\n+ return json_encode(recursive_utf8_encode($payload, $options));\n+}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Fix some weird JSON behavior hopefully |
129,187 | 05.04.2017 18:02:45 | 14,400 | c3ba5793ff874b3479a837ffea1b23715c120afe | Gonna remove a couple files in a sec | [
{
"change_type": "MODIFY",
"old_path": "lib/utils/fetch-json.js",
"new_path": "lib/utils/fetch-json.js",
"diff": "@@ -49,7 +49,6 @@ async function fetchJSON(\n},\n});\nconst json = await response.json();\n- console.log(json);\nconst getNativeCookie = getConfig().getNativeCookie;\nif (getNativeCookie) {\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "lib/utils/string-utils.js",
"diff": "+// @flow\n+\n+// Only works on simple JSON\n+// Operates in-place!\n+function recursive_utf8_decode(mixed: mixed) {\n+ if (mixed === null) {\n+ return mixed;\n+ } else if (typeof mixed === \"object\") {\n+ for (let prop in mixed) {\n+ mixed[prop] = recursive_utf8_decode(mixed[prop]);\n+ }\n+ return mixed;\n+ } else if (typeof mixed === \"string\") {\n+ const test = decodeURIComponent(escape(mixed));\n+ return test;\n+ } else {\n+ return mixed;\n+ }\n+}\n+\n+export {\n+ recursive_utf8_decode,\n+};\n"
},
{
"change_type": "MODIFY",
"old_path": "server/async_lib.php",
"new_path": "server/async_lib.php",
"diff": "require_once('config.php');\nrequire_once('auth.php');\nrequire_once('calendar_lib.php');\n-require_once('json_lib.php');\nfunction async_exit($payload) {\n- exit(utf8_json_encode($payload));\n+ exit(json_encode($payload));\n}\nfunction async_start() {\n"
},
{
"change_type": "MODIFY",
"old_path": "server/index.php",
"new_path": "server/index.php",
"diff": "@@ -4,7 +4,6 @@ require_once('config.php');\nrequire_once('auth.php');\nrequire_once('verify_lib.php');\nrequire_once('calendar_lib.php');\n-require_once('json_lib.php');\nif ($https && !isset($_SERVER['HTTPS'])) {\n// We're using mod_rewrite .htaccess for HTTPS redirect; this shouldn't happen\n@@ -192,8 +191,8 @@ HTML;\nvar username = \"<?=$username?>\";\nvar email = \"<?=$email?>\";\nvar email_verified = <?=($email_verified ? \"true\" : \"false\")?>;\n- var calendar_infos = <?=utf8_json_encode($calendar_infos, JSON_FORCE_OBJECT)?>;\n- var entry_infos = <?=utf8_json_encode($entries)?>;\n+ var calendar_infos = <?=json_encode($calendar_infos, JSON_FORCE_OBJECT)?>;\n+ var entry_infos = <?=json_encode($entries)?>;\nvar month = <?=$month?>;\nvar year = <?=$year?>;\nvar base_url = \"<?=$base_url?>\";\n"
},
{
"change_type": "MODIFY",
"old_path": "server/json_lib.php",
"new_path": "server/json_lib.php",
"diff": "@@ -5,12 +5,14 @@ function recursive_utf8_encode($payload) {\nforeach ($payload as $key => $value) {\n$payload[$key] = recursive_utf8_encode($value);\n}\n+ return $payload;\n} else if (is_string($payload)) {\n- return utf8_encode($payload);\n+ return utf8_decode($payload);\n}\nreturn $payload;\n}\nfunction utf8_json_encode($payload, $options = 0) {\n- return json_encode(recursive_utf8_encode($payload, $options));\n+ //return json_encode(recursive_utf8_encode($payload), $options | JSON_HEX_APOS|JSON_HEX_QUOT);\n+ return json_encode($payload, $options/* | JSON_HEX_APOS|JSON_HEX_QUOT*/);\n}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Gonna remove a couple files in a sec |
129,187 | 05.04.2017 18:05:48 | 14,400 | 1d28dbc96cad81d5a347a915d251e831a2d4ec94 | Remove those files | [
{
"change_type": "DELETE",
"old_path": "lib/utils/string-utils.js",
"new_path": null,
"diff": "-// @flow\n-\n-// Only works on simple JSON\n-// Operates in-place!\n-function recursive_utf8_decode(mixed: mixed) {\n- if (mixed === null) {\n- return mixed;\n- } else if (typeof mixed === \"object\") {\n- for (let prop in mixed) {\n- mixed[prop] = recursive_utf8_decode(mixed[prop]);\n- }\n- return mixed;\n- } else if (typeof mixed === \"string\") {\n- const test = decodeURIComponent(escape(mixed));\n- return test;\n- } else {\n- return mixed;\n- }\n-}\n-\n-export {\n- recursive_utf8_decode,\n-};\n"
},
{
"change_type": "DELETE",
"old_path": "server/json_lib.php",
"new_path": null,
"diff": "-<?php\n-\n-function recursive_utf8_encode($payload) {\n- if (is_array($payload)) {\n- foreach ($payload as $key => $value) {\n- $payload[$key] = recursive_utf8_encode($value);\n- }\n- return $payload;\n- } else if (is_string($payload)) {\n- return utf8_decode($payload);\n- }\n- return $payload;\n-}\n-\n-function utf8_json_encode($payload, $options = 0) {\n- //return json_encode(recursive_utf8_encode($payload), $options | JSON_HEX_APOS|JSON_HEX_QUOT);\n- return json_encode($payload, $options/* | JSON_HEX_APOS|JSON_HEX_QUOT*/);\n-}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Remove those files |
129,187 | 13.04.2017 13:09:38 | 25,200 | 4915273639d1dbec65eb320bfc22350be103b775 | Tested the app startup code, fixed some bugs, and made sure a ping happens on app start | [
{
"change_type": "MODIFY",
"old_path": "native/account/logged-out-modal.react.js",
"new_path": "native/account/logged-out-modal.react.js",
"diff": "@@ -125,6 +125,7 @@ class LoggedOutModal extends React.PureComponent {\nsuper(props);\nif (props.rehydrateConcluded) {\nthis.state.mode = \"prompt\";\n+ this.state.buttonOpacity = new Animated.Value(1);\nthis.nextMode = \"prompt\";\n}\nthis.determineOnePasswordSupport().then();\n@@ -192,6 +193,8 @@ class LoggedOutModal extends React.PureComponent {\nif (nextProps.loggedIn) {\nif (cookie && cookie.startsWith(\"user=\")) {\nnextProps.dispatchActionPayload(\"NAVIGATE_TO_APP\", null);\n+ // Send out a ping to check if our cookie is invalidated\n+ LoggedOutModal.dispatchPing(nextProps, cookie, () => {});\nreturn;\n}\n// This is an unusual error state that should never happen\n@@ -214,26 +217,35 @@ class LoggedOutModal extends React.PureComponent {\n// We are here either because the user cookie exists but Redux says we're\n// not logged in, or because Redux says we're logged in but we don't have\n// a user cookie and we failed to acquire one above\n+ LoggedOutModal.dispatchPing(nextProps, cookie, showPrompt);\n+ }\n+\n+ static dispatchPing(props: Props, cookie: ?string, callback: () => void) {\nconst boundPing = bindCookieAndUtilsIntoServerCall(\nping,\n- nextProps.dispatch,\n+ props.dispatch,\ncookie,\n);\n- nextProps.dispatchActionPromise(\n+ props.dispatchActionPromise(\npingActionType,\n- (async () => {\n+ LoggedOutModal.pingAction(boundPing, callback),\n+ );\n+ }\n+\n+ static async pingAction(\n+ ping: () => Promise<PingResult>,\n+ callback: () => void,\n+ ) {\ntry {\n- const result = await boundPing();\n+ const result = await ping();\nif (!result.userInfo) {\n- showPrompt();\n+ callback();\n}\nreturn result;\n} catch (e) {\n- showPrompt();\n+ callback();\nthrow e;\n}\n- })(),\n- );\n}\ncomponentWillMount() {\n"
},
{
"change_type": "MODIFY",
"old_path": "native/more/more.react.js",
"new_path": "native/more/more.react.js",
"diff": "@@ -4,6 +4,7 @@ import type { NavigationScreenProp } from 'react-navigation';\nimport type { DispatchActionPromise } from 'lib/utils/action-utils';\nimport type { AppState } from '../redux-setup';\nimport type { CalendarInfo } from 'lib/types/calendar-types';\n+import type { PingResult } from 'lib/actions/ping-actions';\nimport React from 'react';\nimport { View, StyleSheet, Text, Button, Alert, Platform } from 'react-native';\n@@ -35,7 +36,7 @@ class More extends React.PureComponent {\ndispatchActionPromise: DispatchActionPromise,\n// async functions that hit server APIs\nlogOut: () => Promise<CalendarInfo[]>,\n- ping: () => Promise<void>,\n+ ping: () => Promise<PingResult>,\n};\nstate: {};\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Tested the app startup code, fixed some bugs, and made sure a ping happens on app start |
129,187 | 13.04.2017 14:24:31 | 25,200 | 2d1b5217f6003a986cebfb290052d2f561d9172d | Move native Redux store construction logic from app.react.js to redux-setup.js | [
{
"change_type": "MODIFY",
"old_path": "native/app.react.js",
"new_path": "native/app.react.js",
"diff": "@@ -7,46 +7,20 @@ import type { AppState } from './redux-setup';\nimport type { Action } from './navigation-setup';\nimport React from 'react';\n-import { createStore, applyMiddleware } from 'redux';\nimport { Provider, connect } from 'react-redux';\n-import { AppRegistry, Platform, UIManager, AsyncStorage } from 'react-native';\n+import { AppRegistry, Platform, UIManager } from 'react-native';\nimport { addNavigationHelpers } from 'react-navigation';\n-import { composeWithDevTools } from 'remote-redux-devtools';\n-import thunk from 'redux-thunk';\nimport invariant from 'invariant';\n-import { autoRehydrate, persistStore } from 'redux-persist';\nimport { registerConfig } from 'lib/utils/config';\n-import { setCookie } from 'lib/utils/action-utils';\nimport { RootNavigator } from './navigation-setup';\n-import { reducer, defaultState, reduxBlacklist } from './redux-setup';\n+import { store } from './redux-setup';\nimport {\nresolveInvalidatedCookie,\ngetNativeCookie,\n} from './account/native-credentials';\n-class AppWithNavigationState extends React.PureComponent {\n-\n- static propTypes = {\n- navigationState: ReactNavigationPropTypes.navigationState,\n- dispatch: React.PropTypes.func.isRequired,\n- };\n- props: {\n- navigationState: NavigationState,\n- dispatch: Dispatch<AppState, Action>,\n- };\n-\n- render() {\n- const navigation = addNavigationHelpers({\n- dispatch: this.props.dispatch,\n- state: this.props.navigationState,\n- });\n- return <RootNavigator navigation={navigation} />;\n- }\n-\n-}\n-\nlet urlPrefix;\nif (!__DEV__) {\nurlPrefix = \"https://squadcal.org/\";\n@@ -72,27 +46,34 @@ if (Platform.OS === \"android\") {\nUIManager.setLayoutAnimationEnabledExperimental(true);\n}\n+class AppWithNavigationState extends React.PureComponent {\n+\n+ static propTypes = {\n+ navigationState: ReactNavigationPropTypes.navigationState,\n+ dispatch: React.PropTypes.func.isRequired,\n+ };\n+ props: {\n+ navigationState: NavigationState,\n+ dispatch: Dispatch<AppState, Action>,\n+ };\n+\n+ render() {\n+ const navigation = addNavigationHelpers({\n+ dispatch: this.props.dispatch,\n+ state: this.props.navigationState,\n+ });\n+ return <RootNavigator navigation={navigation} />;\n+ }\n+\n+}\n+\nconst ConnectedAppWithNavigationState = connect(\n(state: AppState) => ({\nnavigationState: state.navInfo.navigationState,\n}),\n)(AppWithNavigationState);\n-const store = createStore(\n- reducer,\n- defaultState,\n- composeWithDevTools(\n- applyMiddleware(thunk),\n- autoRehydrate(),\n- ),\n-);\nconst App = (props: {}) =>\n<Provider store={store}>\n<ConnectedAppWithNavigationState />\n</Provider>;\n-\nAppRegistry.registerComponent('SquadCal', () => App);\n-\n-persistStore(\n- store,\n- { storage: AsyncStorage, blacklist: reduxBlacklist },\n-);\n"
},
{
"change_type": "MODIFY",
"old_path": "native/redux-setup.js",
"new_path": "native/redux-setup.js",
"diff": "@@ -10,6 +10,11 @@ import type { NavInfo, Action } from './navigation-setup';\nimport React from 'react';\nimport invariant from 'invariant';\nimport { REHYDRATE } from 'redux-persist/constants';\n+import thunk from 'redux-thunk';\n+import { AsyncStorage } from 'react-native';\n+import { createStore, applyMiddleware } from 'redux';\n+import { composeWithDevTools } from 'remote-redux-devtools';\n+import { autoRehydrate, persistStore } from 'redux-persist';\nimport baseReducer from 'lib/reducers/master-reducer';\n@@ -19,7 +24,7 @@ import {\nreduceNavInfo,\n} from './navigation-setup';\n-export const navInfoPropType = React.PropTypes.shape({\n+const navInfoPropType = React.PropTypes.shape({\nhome: React.PropTypes.bool.isRequired,\ncalendarID: React.PropTypes.string,\nnavigationState: ReactNavigationPropTypes.navigationState,\n@@ -36,7 +41,7 @@ export type AppState = {\nrehydrateConcluded: bool,\n};\n-export const defaultState = ({\n+const defaultState = ({\nnavInfo: {\nhome: true,\ncalendarID: null,\n@@ -51,11 +56,11 @@ export const defaultState = ({\nrehydrateConcluded: false,\n}: AppState);\n-export const reduxBlacklist = __DEV__\n+const blacklist = __DEV__\n? ['loadingStatuses', 'rehydrateConcluded']\n: ['loadingStatuses', 'rehydrateConcluded', 'navInfo'];\n-export function reducer(state: AppState, action: Action) {\n+function reducer(state: AppState, action: Action) {\nconst navInfo = reduceNavInfo(state && state.navInfo, action);\nif (navInfo && navInfo !== state.navInfo) {\nstate = { ...state, navInfo };\n@@ -71,3 +76,18 @@ export function reducer(state: AppState, action: Action) {\n}\nreturn baseReducer(state, action);\n}\n+\n+const store = createStore(\n+ reducer,\n+ defaultState,\n+ composeWithDevTools(\n+ applyMiddleware(thunk),\n+ autoRehydrate(),\n+ ),\n+);\n+const persistor = persistStore(store, { storage: AsyncStorage, blacklist });\n+\n+export {\n+ store,\n+ persistor,\n+};\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Move native Redux store construction logic from app.react.js to redux-setup.js |
129,187 | 14.04.2017 16:09:15 | 14,400 | bb724d82a8d162bf3354686948e256adb8a18a0a | Ping on app foregrounding to preemptively catch cookie invalidations and make sure Redux state is updated and consistent | [
{
"change_type": "MODIFY",
"old_path": "native/app.react.js",
"new_path": "native/app.react.js",
"diff": "@@ -5,14 +5,26 @@ import { PropTypes as ReactNavigationPropTypes } from 'react-navigation';\nimport type { Dispatch } from 'lib/types/redux-types';\nimport type { AppState } from './redux-setup';\nimport type { Action } from './navigation-setup';\n+import type { PingResult } from 'lib/actions/ping-actions';\n+import type { DispatchActionPromise } from 'lib/utils/action-utils';\nimport React from 'react';\nimport { Provider, connect } from 'react-redux';\n-import { AppRegistry, Platform, UIManager } from 'react-native';\n+import {\n+ AppRegistry,\n+ Platform,\n+ UIManager,\n+ AppState as NativeAppState,\n+} from 'react-native';\nimport { addNavigationHelpers } from 'react-navigation';\nimport invariant from 'invariant';\nimport { registerConfig } from 'lib/utils/config';\n+import {\n+ includeDispatchActionProps,\n+ bindServerCalls,\n+} from 'lib/utils/action-utils';\n+import { pingActionType, ping } from 'lib/actions/ping-actions';\nimport { RootNavigator } from './navigation-setup';\nimport { store } from './redux-setup';\n@@ -48,14 +60,47 @@ if (Platform.OS === \"android\") {\nclass AppWithNavigationState extends React.PureComponent {\n- static propTypes = {\n- navigationState: ReactNavigationPropTypes.navigationState,\n- dispatch: React.PropTypes.func.isRequired,\n- };\nprops: {\n+ // Redux state\n+ cookie: ?string,\nnavigationState: NavigationState,\n+ loggedIn: bool,\n+ // Redux dispatch functions\ndispatch: Dispatch<AppState, Action>,\n+ dispatchActionPromise: DispatchActionPromise,\n+ // async functions that hit server APIs\n+ ping: () => Promise<PingResult>,\n};\n+ static propTypes = {\n+ cookie: React.PropTypes.string,\n+ navigationState: ReactNavigationPropTypes.navigationState,\n+ loggedIn: React.PropTypes.bool.isRequired,\n+ dispatch: React.PropTypes.func.isRequired,\n+ dispatchActionPromise: React.PropTypes.func.isRequired,\n+ ping: React.PropTypes.func.isRequired,\n+ };\n+ currentState: ?string = NativeAppState.currentState;\n+\n+ componentDidMount() {\n+ NativeAppState.addEventListener('change', this.handleAppStateChange);\n+ }\n+\n+ componentWillUnmount() {\n+ NativeAppState.removeEventListener('change', this.handleAppStateChange);\n+ }\n+\n+ handleAppStateChange = (nextAppState: ?string) => {\n+ if (\n+ this.currentState &&\n+ this.currentState.match(/inactive|background/) &&\n+ nextAppState === \"active\" &&\n+ (this.props.loggedIn ||\n+ (this.props.cookie && this.props.cookie.startsWith(\"user=\")))\n+ ) {\n+ this.props.dispatchActionPromise(pingActionType, this.props.ping());\n+ }\n+ this.currentState = nextAppState;\n+ }\nrender() {\nconst navigation = addNavigationHelpers({\n@@ -69,8 +114,12 @@ class AppWithNavigationState extends React.PureComponent {\nconst ConnectedAppWithNavigationState = connect(\n(state: AppState) => ({\n+ cookie: state.cookie,\nnavigationState: state.navInfo.navigationState,\n+ loggedIn: !!state.userInfo,\n}),\n+ includeDispatchActionProps({ dispatchActionPromise: true }),\n+ bindServerCalls({ ping }),\n)(AppWithNavigationState);\nconst App = (props: {}) =>\n<Provider store={store}>\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Ping on app foregrounding to preemptively catch cookie invalidations and make sure Redux state is updated and consistent |
129,187 | 14.04.2017 17:07:38 | 14,400 | f15bf8d6ccc2a8d7e31ac87a144133ba879f9bce | Move deep linking stuff from LoggedOutModal to App | [
{
"change_type": "MODIFY",
"old_path": "native/account/logged-out-modal.react.js",
"new_path": "native/account/logged-out-modal.react.js",
"diff": "@@ -23,7 +23,6 @@ import {\nKeyboard,\nPlatform,\nBackAndroid,\n- Linking,\nActivityIndicator,\n} from 'react-native';\nimport invariant from 'invariant';\n@@ -258,26 +257,6 @@ class LoggedOutModal extends React.PureComponent {\nthis.keyboardHide,\n);\nBackAndroid.addEventListener('hardwareBackPress', this.hardwareBack);\n- this.handleInitialURL().then();\n- Linking.addEventListener('url', this.handleURLChange);\n- }\n-\n- async handleInitialURL() {\n- const url = await Linking.getInitialURL();\n- if (url) {\n- this.dispatchActionForURL(url);\n- }\n- }\n-\n- handleURLChange = (event: { url: string }) => {\n- this.dispatchActionForURL(event.url);\n- }\n-\n- dispatchActionForURL(url: string) {\n- if (!url.startsWith(\"http\")) {\n- return;\n- }\n- this.props.dispatchActionPayload(\"HANDLE_URL\", url);\n}\ncomponentWillUnmount() {\n@@ -286,7 +265,6 @@ class LoggedOutModal extends React.PureComponent {\ninvariant(this.keyboardHideListener, \"should be set\");\nthis.keyboardHideListener.remove();\nBackAndroid.removeEventListener('hardwareBackPress', this.hardwareBack);\n- Linking.removeEventListener('url', this.handleURLChange);\n}\nhardwareBack = () => {\n"
},
{
"change_type": "MODIFY",
"old_path": "native/app.react.js",
"new_path": "native/app.react.js",
"diff": "@@ -6,7 +6,10 @@ import type { Dispatch } from 'lib/types/redux-types';\nimport type { AppState } from './redux-setup';\nimport type { Action } from './navigation-setup';\nimport type { PingResult } from 'lib/actions/ping-actions';\n-import type { DispatchActionPromise } from 'lib/utils/action-utils';\n+import type {\n+ DispatchActionPayload,\n+ DispatchActionPromise,\n+} from 'lib/utils/action-utils';\nimport React from 'react';\nimport { Provider, connect } from 'react-redux';\n@@ -15,6 +18,7 @@ import {\nPlatform,\nUIManager,\nAppState as NativeAppState,\n+ Linking,\n} from 'react-native';\nimport { addNavigationHelpers } from 'react-navigation';\nimport invariant from 'invariant';\n@@ -67,6 +71,7 @@ class AppWithNavigationState extends React.PureComponent {\nloggedIn: bool,\n// Redux dispatch functions\ndispatch: Dispatch<AppState, Action>,\n+ dispatchActionPayload: DispatchActionPayload,\ndispatchActionPromise: DispatchActionPromise,\n// async functions that hit server APIs\nping: () => Promise<PingResult>,\n@@ -76,6 +81,7 @@ class AppWithNavigationState extends React.PureComponent {\nnavigationState: ReactNavigationPropTypes.navigationState,\nloggedIn: React.PropTypes.bool.isRequired,\ndispatch: React.PropTypes.func.isRequired,\n+ dispatchActionPayload: React.PropTypes.func.isRequired,\ndispatchActionPromise: React.PropTypes.func.isRequired,\nping: React.PropTypes.func.isRequired,\n};\n@@ -83,10 +89,31 @@ class AppWithNavigationState extends React.PureComponent {\ncomponentDidMount() {\nNativeAppState.addEventListener('change', this.handleAppStateChange);\n+ this.handleInitialURL().then();\n+ Linking.addEventListener('url', this.handleURLChange);\n+ }\n+\n+ async handleInitialURL() {\n+ const url = await Linking.getInitialURL();\n+ if (url) {\n+ this.dispatchActionForURL(url);\n+ }\n+ }\n+\n+ handleURLChange = (event: { url: string }) => {\n+ this.dispatchActionForURL(event.url);\n+ }\n+\n+ dispatchActionForURL(url: string) {\n+ if (!url.startsWith(\"http\")) {\n+ return;\n+ }\n+ this.props.dispatchActionPayload(\"HANDLE_URL\", url);\n}\ncomponentWillUnmount() {\nNativeAppState.removeEventListener('change', this.handleAppStateChange);\n+ Linking.removeEventListener('url', this.handleURLChange);\n}\nhandleAppStateChange = (nextAppState: ?string) => {\n@@ -118,9 +145,13 @@ const ConnectedAppWithNavigationState = connect(\nnavigationState: state.navInfo.navigationState,\nloggedIn: !!state.userInfo,\n}),\n- includeDispatchActionProps({ dispatchActionPromise: true }),\n+ includeDispatchActionProps({\n+ dispatchActionPayload: true,\n+ dispatchActionPromise: true,\n+ }),\nbindServerCalls({ ping }),\n)(AppWithNavigationState);\n+\nconst App = (props: {}) =>\n<Provider store={store}>\n<ConnectedAppWithNavigationState />\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Move deep linking stuff from LoggedOutModal to App |
129,187 | 14.04.2017 17:19:23 | 14,400 | 27bc8d4ecd1adda73cdd82740147628d6a3ff040 | Make sure PING_SUCCESS doesn't remove VerificationModal | [
{
"change_type": "MODIFY",
"old_path": "native/navigation-setup.js",
"new_path": "native/navigation-setup.js",
"diff": "@@ -9,6 +9,7 @@ import type { PingResult } from 'lib/actions/ping-actions';\nimport { TabNavigator, StackNavigator } from 'react-navigation';\nimport invariant from 'invariant';\nimport _findIndex from 'lodash/fp/findIndex';\n+import _includes from 'lodash/fp/includes';\nimport { Alert } from 'react-native';\nimport { partialNavInfoFromURL } from 'lib/utils/url-utils';\n@@ -160,15 +161,15 @@ function handleURL(\n};\n}\n-function removeModals(state: NavigationState): NavigationState {\n+function removeModals(\n+ state: NavigationState,\n+ modals: string[] = ['LoggedOutModal', 'VerificationModal'],\n+): NavigationState {\nconst newRoutes = [];\nlet index = state.index;\nfor (let i = 0; i < state.routes.length; i++) {\nconst route = state.routes[i];\n- if (\n- route.routeName === 'LoggedOutModal' ||\n- route.routeName === 'VerificationModal'\n- ) {\n+ if (_includes(route.routeName)(modals)) {\nif (i <= state.index) {\ninvariant(index !== 0, 'Attempting to remove only route');\nindex--;\n@@ -237,7 +238,7 @@ function removeModalsIfPingIndicatesLoggedIn(\n// cookie invalidation triggered by a ping server call\nreturn state;\n}\n- return removeModals(state);\n+ return removeModals(state, ['LoggedOutModal']);\n}\nexport {\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Make sure PING_SUCCESS doesn't remove VerificationModal |
129,187 | 14.04.2017 22:30:22 | 14,400 | 3fc3548bc3a479df2c86dbb41e056dd8021d8917 | Strip console statements on native for production release | [
{
"change_type": "MODIFY",
"old_path": "lib/utils/fetch-json.js",
"new_path": "lib/utils/fetch-json.js",
"diff": "@@ -49,6 +49,7 @@ async function fetchJSON(\n},\n});\nconst json = await response.json();\n+ console.log(json);\nconst getNativeCookie = getConfig().getNativeCookie;\nif (getNativeCookie) {\n"
},
{
"change_type": "MODIFY",
"old_path": "native/.babelrc",
"new_path": "native/.babelrc",
"diff": "{\n-\"presets\": [\"react-native\"]\n+ presets: ['react-native'],\n+ env: {\n+ production: {\n+ plugins: ['transform-remove-console'],\n+ },\n+ },\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "native/app.react.js",
"new_path": "native/app.react.js",
"diff": "@@ -37,6 +37,14 @@ import {\ngetNativeCookie,\n} from './account/native-credentials';\n+// We have transform-remove-console in .babelrc, but it doesn't work (RN#10412)\n+if (!__DEV__) {\n+ console = {\n+ log: () => {},\n+ error: () => {},\n+ };\n+}\n+\nlet urlPrefix;\nif (!__DEV__) {\nurlPrefix = \"https://squadcal.org/\";\n"
},
{
"change_type": "MODIFY",
"old_path": "native/package.json",
"new_path": "native/package.json",
"diff": "},\n\"devDependencies\": {\n\"babel-jest\": \"18.0.0\",\n+ \"babel-plugin-transform-remove-console\": \"^6.8.1\",\n\"babel-preset-react-native\": \"1.9.1\",\n\"flow\": \"^0.2.3\",\n\"flow-bin\": \"^0.38.0\",\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Strip console statements on native for production release |
129,187 | 15.04.2017 00:29:33 | 14,400 | 358553d81fb202835fc18aec9423a44e4d8d4b7e | Make sure modal BackAndroids are only active when those modals are in the foreground | [
{
"change_type": "MODIFY",
"old_path": "native/account/logged-out-modal.react.js",
"new_path": "native/account/logged-out-modal.react.js",
"diff": "@@ -42,6 +42,7 @@ import LogInPanelContainer from './log-in-panel-container.react';\nimport RegisterPanel from './register-panel.react';\nimport ConnectedStatusBar from '../connected-status-bar.react';\nimport { getNativeCookie, setNativeCookie } from './native-credentials';\n+import { createIsForegroundSelector } from '../nav-selectors';\ntype KeyboardEvent = {\nduration: number,\n@@ -59,6 +60,7 @@ type Props = {\nrehydrateConcluded: bool,\ncookie: ?string,\nloggedIn: bool,\n+ isForeground: bool,\n// Redux dispatch functions\ndispatch: Dispatch<AppState, Action>,\ndispatchActionPayload: DispatchActionPayload,\n@@ -74,16 +76,16 @@ type State = {\nonePasswordSupported: bool,\n};\n-class LoggedOutModal extends React.PureComponent {\n+class InnerLoggedOutModal extends React.PureComponent {\nprops: Props;\nstate: State = {\nmode: \"loading\",\npanelPaddingTop: new Animated.Value(\n- LoggedOutModal.calculatePanelPaddingTop(\"prompt\", 0),\n+ InnerLoggedOutModal.calculatePanelPaddingTop(\"prompt\", 0),\n),\nfooterPaddingTop: new Animated.Value(\n- LoggedOutModal.calculateFooterPaddingTop(0),\n+ InnerLoggedOutModal.calculateFooterPaddingTop(0),\n),\npanelOpacity: new Animated.Value(0),\nforgotPasswordLinkOpacity: new Animated.Value(0),\n@@ -98,6 +100,7 @@ class LoggedOutModal extends React.PureComponent {\nrehydrateConcluded: React.PropTypes.bool.isRequired,\ncookie: React.PropTypes.string,\nloggedIn: React.PropTypes.bool.isRequired,\n+ isForeground: React.PropTypes.bool.isRequired,\ndispatch: React.PropTypes.func.isRequired,\ndispatchActionPayload: React.PropTypes.func.isRequired,\ndispatchActionPromise: React.PropTypes.func.isRequired,\n@@ -140,10 +143,43 @@ class LoggedOutModal extends React.PureComponent {\nthis.setState({ onePasswordSupported });\n}\n+ componentDidMount() {\n+ if (this.props.isForeground) {\n+ this.onForeground();\n+ }\n+ }\n+\ncomponentWillReceiveProps(nextProps: Props) {\nif (!this.props.rehydrateConcluded && nextProps.rehydrateConcluded) {\nthis.onInitialAppLoad(nextProps).then();\n}\n+ if (!this.props.isForeground && nextProps.isForeground) {\n+ this.onForeground();\n+ } else if (this.props.isForeground && !nextProps.isForeground) {\n+ this.onBackground();\n+ }\n+ }\n+\n+ onForeground() {\n+ this.keyboardShowListener = Keyboard.addListener(\n+ Platform.OS === \"ios\" ? \"keyboardWillShow\" : \"keyboardDidShow\",\n+ this.keyboardShow,\n+ );\n+ this.keyboardHideListener = Keyboard.addListener(\n+ Platform.OS === \"ios\" ? \"keyboardWillHide\" : \"keyboardDidHide\",\n+ this.keyboardHide,\n+ );\n+ BackAndroid.addEventListener('hardwareBackPress', this.hardwareBack);\n+ }\n+\n+ onBackground() {\n+ if (this.keyboardShowListener) {\n+ this.keyboardShowListener.remove();\n+ }\n+ if (this.keyboardHideListener) {\n+ this.keyboardHideListener.remove();\n+ }\n+ BackAndroid.removeEventListener('hardwareBackPress', this.hardwareBack);\n}\n// This gets triggered when an app is killed and restarted\n@@ -193,7 +229,7 @@ class LoggedOutModal extends React.PureComponent {\nif (cookie && cookie.startsWith(\"user=\")) {\nnextProps.dispatchActionPayload(\"NAVIGATE_TO_APP\", null);\n// Send out a ping to check if our cookie is invalidated\n- LoggedOutModal.dispatchPing(nextProps, cookie, () => {});\n+ InnerLoggedOutModal.dispatchPing(nextProps, cookie, () => {});\nreturn;\n}\n// This is an unusual error state that should never happen\n@@ -216,7 +252,7 @@ class LoggedOutModal extends React.PureComponent {\n// We are here either because the user cookie exists but Redux says we're\n// not logged in, or because Redux says we're logged in but we don't have\n// a user cookie and we failed to acquire one above\n- LoggedOutModal.dispatchPing(nextProps, cookie, showPrompt);\n+ InnerLoggedOutModal.dispatchPing(nextProps, cookie, showPrompt);\n}\nstatic dispatchPing(props: Props, cookie: ?string, callback: () => void) {\n@@ -227,7 +263,7 @@ class LoggedOutModal extends React.PureComponent {\n);\nprops.dispatchActionPromise(\npingActionType,\n- LoggedOutModal.pingAction(boundPing, callback),\n+ InnerLoggedOutModal.pingAction(boundPing, callback),\n);\n}\n@@ -247,26 +283,6 @@ class LoggedOutModal extends React.PureComponent {\n}\n}\n- componentWillMount() {\n- this.keyboardShowListener = Keyboard.addListener(\n- Platform.OS === \"ios\" ? \"keyboardWillShow\" : \"keyboardDidShow\",\n- this.keyboardShow,\n- );\n- this.keyboardHideListener = Keyboard.addListener(\n- Platform.OS === \"ios\" ? \"keyboardWillHide\" : \"keyboardDidHide\",\n- this.keyboardHide,\n- );\n- BackAndroid.addEventListener('hardwareBackPress', this.hardwareBack);\n- }\n-\n- componentWillUnmount() {\n- invariant(this.keyboardShowListener, \"should be set\");\n- this.keyboardShowListener.remove();\n- invariant(this.keyboardHideListener, \"should be set\");\n- this.keyboardHideListener.remove();\n- BackAndroid.removeEventListener('hardwareBackPress', this.hardwareBack);\n- }\n-\nhardwareBack = () => {\nif (this.nextMode === \"log-in\") {\ninvariant(this.logInPanelContainer, \"ref should be set\");\n@@ -310,7 +326,8 @@ class LoggedOutModal extends React.PureComponent {\nrealKeyboardHeight = this.keyboardHeight;\n}\nconst animations = [];\n- const newPanelPaddingTopValue = LoggedOutModal.calculatePanelPaddingTop(\n+ const newPanelPaddingTopValue =\n+ InnerLoggedOutModal.calculatePanelPaddingTop(\nthis.state.mode,\nthis.keyboardHeight,\n);\n@@ -333,7 +350,9 @@ class LoggedOutModal extends React.PureComponent {\n{\nduration,\neasing: Easing.out(Easing.ease),\n- toValue: LoggedOutModal.calculateFooterPaddingTop(realKeyboardHeight),\n+ toValue: InnerLoggedOutModal.calculateFooterPaddingTop(\n+ realKeyboardHeight,\n+ ),\n},\n),\n);\n@@ -375,7 +394,8 @@ class LoggedOutModal extends React.PureComponent {\nanimateKeyboardDownOrBackToPrompt(inputDuration: ?number) {\nconst duration = inputDuration ? inputDuration : 250;\n- this.lastPanelPaddingTopValue = LoggedOutModal.calculatePanelPaddingTop(\n+ this.lastPanelPaddingTopValue =\n+ InnerLoggedOutModal.calculatePanelPaddingTop(\nthis.nextMode,\n0,\n);\n@@ -393,7 +413,7 @@ class LoggedOutModal extends React.PureComponent {\n{\nduration,\neasing: Easing.out(Easing.ease),\n- toValue: LoggedOutModal.calculateFooterPaddingTop(\n+ toValue: InnerLoggedOutModal.calculateFooterPaddingTop(\nthis.keyboardHeight,\n),\n},\n@@ -683,14 +703,23 @@ const styles = StyleSheet.create({\n},\n});\n-export default connect(\n+const LoggedOutModalRouteName = 'LoggedOutModal';\n+const isForegroundSelector =\n+ createIsForegroundSelector(LoggedOutModalRouteName);\n+const LoggedOutModal = connect(\n(state: AppState) => ({\nrehydrateConcluded: state.rehydrateConcluded,\ncookie: state.cookie,\nloggedIn: !!state.userInfo,\n+ isForeground: isForegroundSelector(state),\n}),\nincludeDispatchActionProps({\ndispatchActionPayload: true,\ndispatchActionPromise: true,\n}),\n-)(LoggedOutModal);\n+)(InnerLoggedOutModal);\n+\n+export {\n+ LoggedOutModal,\n+ LoggedOutModalRouteName,\n+};\n"
},
{
"change_type": "MODIFY",
"old_path": "native/account/verification-modal.react.js",
"new_path": "native/account/verification-modal.react.js",
"diff": "@@ -44,6 +44,7 @@ import sleep from 'lib/utils/sleep';\nimport { windowHeight } from '../dimensions';\nimport ConnectedStatusBar from '../connected-status-bar.react';\nimport ResetPasswordPanel from './reset-password-panel.react';\n+import { createIsForegroundSelector } from '../nav-selectors';\ntype KeyboardEvent = {\nduration: number,\n@@ -60,6 +61,8 @@ type VerificationModalNavProps = {\n};\ntype Props = {\nnavigation: NavigationScreenProp<VerificationModalNavProps, *>,\n+ // Redux state\n+ isForeground: bool,\n// Redux dispatch functions\ndispatchActionPayload: DispatchActionPayload,\ndispatchActionPromise: DispatchActionPromise,\n@@ -76,7 +79,7 @@ type State = {\nresetPasswordPanelOpacityValue: Animated.Value,\nonePasswordSupported: bool,\n};\n-class VerificationModal extends React.PureComponent {\n+class InnerVerificationModal extends React.PureComponent {\nprops: Props;\nstatic propTypes = {\n@@ -88,6 +91,7 @@ class VerificationModal extends React.PureComponent {\n}).isRequired,\ngoBack: React.PropTypes.func.isRequired,\n}).isRequired,\n+ isForeground: React.PropTypes.bool.isRequired,\ndispatchActionPayload: React.PropTypes.func.isRequired,\ndispatchActionPromise: React.PropTypes.func.isRequired,\nhandleVerificationCode: React.PropTypes.func.isRequired,\n@@ -95,7 +99,7 @@ class VerificationModal extends React.PureComponent {\nstate: State = {\nmode: \"simple-text\",\npaddingTop: new Animated.Value(\n- VerificationModal.currentPaddingTop(\"simple-text\", 0),\n+ InnerVerificationModal.currentPaddingTop(\"simple-text\", 0),\n),\nverifyField: null,\nerrorMessage: null,\n@@ -127,46 +131,28 @@ class VerificationModal extends React.PureComponent {\n}\ncomponentWillMount() {\n- BackAndroid.addEventListener('hardwareBackPress', this.hardwareBack);\nconst code = this.props.navigation.state.params.verifyCode;\nthis.props.dispatchActionPromise(\nhandleVerificationCodeActionType,\nthis.handleVerificationCodeAction(code),\n);\nKeyboard.dismiss();\n- this.keyboardShowListener = Keyboard.addListener(\n- Platform.OS === \"ios\" ? \"keyboardWillShow\" : \"keyboardDidShow\",\n- this.keyboardShow,\n- );\n- this.keyboardHideListener = Keyboard.addListener(\n- Platform.OS === \"ios\" ? \"keyboardWillHide\" : \"keyboardDidHide\",\n- this.keyboardHide,\n- );\n}\n- componentWillUnmount() {\n- BackAndroid.removeEventListener('hardwareBackPress', this.hardwareBack);\n- invariant(this.keyboardShowListener, \"should be set\");\n- this.keyboardShowListener.remove();\n- invariant(this.keyboardHideListener, \"should be set\");\n- this.keyboardHideListener.remove();\n+ componentDidMount() {\n+ if (this.props.isForeground) {\n+ this.onForeground();\n}\n-\n- hardwareBack = () => {\n- this.props.navigation.goBack();\n- return true;\n}\ncomponentWillReceiveProps(nextProps: Props) {\nconst nextCode = nextProps.navigation.state.params.verifyCode;\n- if (nextCode === this.props.navigation.state.params.verifyCode) {\n- return;\n- }\n+ if (nextCode !== this.props.navigation.state.params.verifyCode) {\nKeyboard.dismiss();\nthis.setState({\nmode: \"simple-text\",\npaddingTop: new Animated.Value(\n- VerificationModal.currentPaddingTop(\"simple-text\", 0),\n+ InnerVerificationModal.currentPaddingTop(\"simple-text\", 0),\n),\nverifyField: null,\nerrorMessage: null,\n@@ -177,6 +163,39 @@ class VerificationModal extends React.PureComponent {\nthis.handleVerificationCodeAction(nextCode),\n);\n}\n+ if (!this.props.isForeground && nextProps.isForeground) {\n+ this.onForeground();\n+ } else if (this.props.isForeground && !nextProps.isForeground) {\n+ this.onBackground();\n+ }\n+ }\n+\n+ onForeground() {\n+ this.keyboardShowListener = Keyboard.addListener(\n+ Platform.OS === \"ios\" ? \"keyboardWillShow\" : \"keyboardDidShow\",\n+ this.keyboardShow,\n+ );\n+ this.keyboardHideListener = Keyboard.addListener(\n+ Platform.OS === \"ios\" ? \"keyboardWillHide\" : \"keyboardDidHide\",\n+ this.keyboardHide,\n+ );\n+ BackAndroid.addEventListener('hardwareBackPress', this.hardwareBack);\n+ }\n+\n+ onBackground() {\n+ if (this.keyboardShowListener) {\n+ this.keyboardShowListener.remove();\n+ }\n+ if (this.keyboardHideListener) {\n+ this.keyboardHideListener.remove();\n+ }\n+ BackAndroid.removeEventListener('hardwareBackPress', this.hardwareBack);\n+ }\n+\n+ hardwareBack = () => {\n+ this.props.navigation.goBack();\n+ return true;\n+ }\ncomponentWillUpdate(nextProps: Props, nextState: State) {\nif (nextState.verifyField === verifyField.EMAIL) {\n@@ -267,7 +286,7 @@ class VerificationModal extends React.PureComponent {\n{\nduration,\neasing: Easing.out(Easing.ease),\n- toValue: VerificationModal.currentPaddingTop(\n+ toValue: InnerVerificationModal.currentPaddingTop(\nthis.state.mode,\nthis.keyboardHeight,\n),\n@@ -309,7 +328,7 @@ class VerificationModal extends React.PureComponent {\n{\nduration,\neasing: Easing.out(Easing.ease),\n- toValue: VerificationModal.currentPaddingTop(this.nextMode, 0),\n+ toValue: InnerVerificationModal.currentPaddingTop(this.nextMode, 0),\n},\n),\n];\n@@ -477,13 +496,22 @@ const styles = StyleSheet.create({\nregisterFetchKey(handleVerificationCodeActionType);\n-export default connect(\n+const VerificationModalRouteName = 'VerificationModal';\n+const isForegroundSelector =\n+ createIsForegroundSelector(VerificationModalRouteName);\n+const VerificationModal = connect(\n(state: AppState) => ({\ncookie: state.cookie,\n+ isForeground: isForegroundSelector(state),\n}),\nincludeDispatchActionProps({\ndispatchActionPayload: true,\ndispatchActionPromise: true,\n}),\nbindServerCalls({ handleVerificationCode }),\n-)(VerificationModal);\n+)(InnerVerificationModal);\n+\n+export {\n+ VerificationModal,\n+ VerificationModalRouteName,\n+};\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/nav-selectors.js",
"diff": "+// @flow\n+\n+import type { AppState } from './redux-setup';\n+import type { NavigationState } from 'react-navigation';\n+\n+import { createSelector } from 'reselect';\n+\n+const createIsForegroundSelector = (routeName: string) => createSelector(\n+ (state: AppState) => state.navInfo.navigationState,\n+ (navigationState: NavigationState) =>\n+ navigationState.routes[navigationState.index].routeName === routeName,\n+);\n+\n+export {\n+ createIsForegroundSelector,\n+};\n"
},
{
"change_type": "MODIFY",
"old_path": "native/navigation-setup.js",
"new_path": "native/navigation-setup.js",
"diff": "@@ -17,8 +17,14 @@ import { partialNavInfoFromURL } from 'lib/utils/url-utils';\nimport Calendar from './calendar/calendar.react';\nimport Chat from './chat/chat.react';\nimport More from './more/more.react';\n-import LoggedOutModal from './account/logged-out-modal.react';\n-import VerificationModal from './account/verification-modal.react';\n+import {\n+ LoggedOutModal,\n+ LoggedOutModalRouteName,\n+} from './account/logged-out-modal.react';\n+import {\n+ VerificationModal,\n+ VerificationModalRouteName,\n+} from './account/verification-modal.react';\nexport type NavInfo = BaseNavInfo & {\nhome: bool,\n@@ -43,8 +49,8 @@ const AppNavigator = TabNavigator(\nconst RootNavigator = StackNavigator(\n{\n- LoggedOutModal: { screen: LoggedOutModal },\n- VerificationModal: { screen: VerificationModal },\n+ [LoggedOutModalRouteName]: { screen: LoggedOutModal },\n+ [VerificationModalRouteName]: { screen: VerificationModal },\nApp: { screen: AppNavigator },\n},\n{\n@@ -66,7 +72,7 @@ const defaultNavigationState = {\n{ key: 'More', routeName: 'More' },\n],\n},\n- { key: 'LoggedOutModal', routeName: 'LoggedOutModal' },\n+ { key: 'LoggedOutModal', routeName: LoggedOutModalRouteName },\n],\n};\n@@ -163,13 +169,14 @@ function handleURL(\nfunction removeModals(\nstate: NavigationState,\n- modals: string[] = ['LoggedOutModal', 'VerificationModal'],\n+ modalRouteNames: string[]\n+ = [LoggedOutModalRouteName, VerificationModalRouteName],\n): NavigationState {\nconst newRoutes = [];\nlet index = state.index;\nfor (let i = 0; i < state.routes.length; i++) {\nconst route = state.routes[i];\n- if (_includes(route.routeName)(modals)) {\n+ if (_includes(route.routeName)(modalRouteNames)) {\nif (i <= state.index) {\ninvariant(index !== 0, 'Attempting to remove only route');\nindex--;\n@@ -187,7 +194,7 @@ function removeModals(\nfunction ensureLoggedOutModalPresence(state: NavigationState): NavigationState {\nconst currentModalIndex =\n- _findIndex(['routeName', 'LoggedOutModal'])(state.routes);\n+ _findIndex(['routeName', LoggedOutModalRouteName])(state.routes);\nif (currentModalIndex >= 0 && state.index >= currentModalIndex) {\nreturn state;\n} else if (currentModalIndex >= 0) {\n@@ -200,7 +207,7 @@ function ensureLoggedOutModalPresence(state: NavigationState): NavigationState {\nindex: state.routes.length,\nroutes: [\n...state.routes,\n- { key: 'LoggedOutModal', routeName: 'LoggedOutModal' },\n+ { key: 'LoggedOutModal', routeName: LoggedOutModalRouteName },\n],\n};\n}\n@@ -238,11 +245,13 @@ function removeModalsIfPingIndicatesLoggedIn(\n// cookie invalidation triggered by a ping server call\nreturn state;\n}\n- return removeModals(state, ['LoggedOutModal']);\n+ return removeModals(state, [LoggedOutModalRouteName]);\n}\nexport {\nRootNavigator,\ndefaultNavigationState,\nreduceNavInfo,\n+ LoggedOutModalRouteName,\n+ VerificationModalRouteName,\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "native/package.json",
"new_path": "native/package.json",
"diff": "\"redux\": \"^3.6.0\",\n\"redux-persist\": \"^4.6.0\",\n\"redux-thunk\": \"^2.2.0\",\n+ \"reselect\": \"^3.0.0\",\n\"url-parse\": \"^1.1.8\"\n},\n\"devDependencies\": {\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Make sure modal BackAndroids are only active when those modals are in the foreground |
129,187 | 17.04.2017 00:21:10 | 14,400 | ac0185aff722368c9ff879e8e7370d71af59662c | Add BackAndroid handling for AppNavigator (the tab screen) | [
{
"change_type": "MODIFY",
"old_path": "native/navigation-setup.js",
"new_path": "native/navigation-setup.js",
"diff": "import type { BaseAction } from 'lib/types/redux-types';\nimport type { BaseNavInfo } from 'lib/types/nav-types';\nimport type { CalendarInfo } from 'lib/types/calendar-types';\n-import type { NavigationState } from 'react-navigation';\n+import type {\n+ NavigationState,\n+ NavigationScreenProp,\n+ NavigationRoute,\n+ NavigationAction,\n+ NavigationRouter,\n+} from 'react-navigation';\nimport type { PingResult } from 'lib/actions/ping-actions';\n+import type { AppState } from './redux-setup';\nimport { TabNavigator, StackNavigator } from 'react-navigation';\nimport invariant from 'invariant';\nimport _findIndex from 'lodash/fp/findIndex';\nimport _includes from 'lodash/fp/includes';\n-import { Alert } from 'react-native';\n+import { Alert, BackAndroid } from 'react-native';\n+import React from 'react';\n+import PropTypes from 'prop-types';\n+import { connect } from 'react-redux';\nimport { partialNavInfoFromURL } from 'lib/utils/url-utils';\n@@ -25,6 +35,7 @@ import {\nVerificationModal,\nVerificationModalRouteName,\n} from './account/verification-modal.react';\n+import { createIsForegroundSelector } from './nav-selectors';\nexport type NavInfo = BaseNavInfo & {\nhome: bool,\n@@ -46,12 +57,70 @@ const AppNavigator = TabNavigator(\ninitialRouteName: 'Calendar',\n},\n);\n+type WrappedAppNavigatorProps = {\n+ navigation: NavigationScreenProp<NavigationRoute, NavigationAction>,\n+ isForeground: bool,\n+ atInitialRoute: bool,\n+};\n+class WrappedAppNavigator extends React.PureComponent {\n+\n+ props: WrappedAppNavigatorProps;\n+ static propTypes = {\n+ navigation: PropTypes.shape({\n+ goBack: PropTypes.func.isRequired,\n+ }).isRequired,\n+ isForeground: PropTypes.bool.isRequired,\n+ atInitialRoute: PropTypes.bool.isRequired,\n+ };\n+\n+ componentDidMount() {\n+ if (this.props.isForeground) {\n+ this.onForeground();\n+ }\n+ }\n+\n+ componentWillReceiveProps(nextProps: WrappedAppNavigatorProps) {\n+ if (!this.props.isForeground && nextProps.isForeground) {\n+ this.onForeground();\n+ } else if (this.props.isForeground && !nextProps.isForeground) {\n+ this.onBackground();\n+ }\n+ }\n+\n+ onForeground() {\n+ BackAndroid.addEventListener('hardwareBackPress', this.hardwareBack);\n+ }\n+\n+ onBackground() {\n+ BackAndroid.removeEventListener('hardwareBackPress', this.hardwareBack);\n+ }\n+\n+ hardwareBack = () => {\n+ if (this.props.atInitialRoute) {\n+ return false;\n+ }\n+ this.props.navigation.goBack(null);\n+ return true;\n+ }\n+\n+ render() {\n+ return <AppNavigator navigation={this.props.navigation} />;\n+ }\n+\n+}\n+const AppRouteName = 'App';\n+const isForegroundSelector = createIsForegroundSelector(AppRouteName);\n+const ReduxWrappedAppNavigator = connect((state: AppState) => ({\n+ isForeground: isForegroundSelector(state),\n+ atInitialRoute: state.navInfo.navigationState.routes[0].index === 0,\n+}))(WrappedAppNavigator);\n+ReduxWrappedAppNavigator.router = AppNavigator.router;\nconst RootNavigator = StackNavigator(\n{\n[LoggedOutModalRouteName]: { screen: LoggedOutModal },\n[VerificationModalRouteName]: { screen: VerificationModal },\n- App: { screen: AppNavigator },\n+ [AppRouteName]: { screen: ReduxWrappedAppNavigator },\n},\n{\nheaderMode: 'none',\n@@ -64,7 +133,7 @@ const defaultNavigationState = {\nroutes: [\n{\nkey: 'App',\n- routeName: 'App',\n+ routeName: AppRouteName,\nindex: 0,\nroutes: [\n{ key: 'Calendar', routeName: 'Calendar' },\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Add BackAndroid handling for AppNavigator (the tab screen) |
129,187 | 18.04.2017 20:33:33 | 14,400 | e5fcc1e0c2f0f0d2559596ebf6e6f067bb0b2add | Replace day_history.php and month_entries.php with fetch_entries.php | [
{
"change_type": "MODIFY",
"old_path": "lib/actions/entry-actions.js",
"new_path": "lib/actions/entry-actions.js",
"diff": "@@ -5,6 +5,8 @@ import type { EntryInfo } from '../types/entry-types';\nimport type { FetchJSON } from '../utils/fetch-json';\nimport type { HistoryRevisionInfo } from '../types/history-types';\n+import { padMonthOrDay, daysInMonth} from '../utils/date-utils';\n+\nconst fetchAllEntriesForDayActionType = \"FETCH_ALL_DAY_ENTRIES\";\nasync function fetchAllEntriesForDay(\nfetchJSON: FetchJSON,\n@@ -13,11 +15,14 @@ async function fetchAllEntriesForDay(\nday: number,\nnavID: string,\n): Promise<EntryInfo[]> {\n- const response = await fetchJSON('day_history.php', {\n- 'year': year,\n- 'month': month,\n- 'day': day,\n+ const paddedMonth = padMonthOrDay(month);\n+ const paddedDay = padMonthOrDay(day);\n+ const date = `${year}-${paddedMonth}-${paddedDay}`;\n+ const response = await fetchJSON('fetch_entries.php', {\n'nav': navID,\n+ 'start_date': date,\n+ 'end_date': date,\n+ 'include_deleted': true,\n});\nreturn response.result;\n}\n@@ -29,10 +34,11 @@ async function fetchEntriesForMonth(\nmonth: number,\nnavID: string,\n): Promise<EntryInfo[]> {\n- const response = await fetchJSON('month_entries.php', {\n- 'month': month,\n- 'year': year,\n+ const paddedMonth = padMonthOrDay(month);\n+ const response = await fetchJSON('fetch_entries.php', {\n'nav': navID,\n+ 'start_date': `${year}-${paddedMonth}-01`,\n+ 'end_date': `${year}-${paddedMonth}-${daysInMonth(year, month)}`,\n});\nreturn response.result;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/utils/date-utils.js",
"new_path": "lib/utils/date-utils.js",
"diff": "@@ -9,4 +9,28 @@ function getDate(\nreturn new Date(yearInput, monthInput - 1, dayOfMonth);\n}\n-export { getDate }\n+function padMonthOrDay(n: number) {\n+ return (n < 10) ? (\"0\" + n) : n;\n+}\n+\n+function daysInMonth(year: number, month: number) {\n+ switch (month) {\n+ case 2:\n+ return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0\n+ ? 29\n+ : 28;\n+ case 4:\n+ case 6:\n+ case 9:\n+ case 11:\n+ return 30;\n+ default:\n+ return 31;\n+ }\n+}\n+\n+export {\n+ getDate,\n+ padMonthOrDay,\n+ daysInMonth,\n+}\n"
},
{
"change_type": "DELETE",
"old_path": "server/day_history.php",
"new_path": null,
"diff": "-<?php\n-\n-require_once('async_lib.php');\n-require_once('config.php');\n-require_once('auth.php');\n-require_once('calendar_lib.php');\n-\n-async_start();\n-\n-if (\n- !isset($_POST['day']) ||\n- !isset($_POST['month']) ||\n- !isset($_POST['year']) ||\n- !isset($_POST['nav'])\n-) {\n- async_end(array(\n- 'error' => 'invalid_parameters',\n- ));\n-}\n-$day = intval($_POST['day']);\n-$month = intval($_POST['month']);\n-$year = intval($_POST['year']);\n-\n-$home = null;\n-$calendar = null;\n-if ($_POST['nav'] === \"home\") {\n- $home = true;\n-} else {\n- $home = false;\n- $calendar = intval($_POST['nav']);\n-}\n-\n-$additional_condition = $home ? \"r.subscribed = 1\" : \"d.calendar = $calendar\";\n-$viewer_id = get_viewer_id();\n-$result = $conn->query(\n- \"SELECT e.id, u.username AS creator, e.text, e.deleted, \".\n- \"d.calendar AS calendarID, e.creation_time AS creationTime FROM entries e \".\n- \"LEFT JOIN users u ON u.id = e.creator \".\n- \"LEFT JOIN days d ON d.id = e.day \".\n- \"LEFT JOIN calendars c ON c.id = d.calendar \".\n- \"LEFT JOIN roles r ON r.calendar = d.calendar AND r.user = $viewer_id \".\n- \"WHERE MONTH(d.date) = $month AND YEAR(d.date) = $year AND \".\n- \"DAY(d.date) = $day AND (c.visibility_rules < \".VISIBILITY_CLOSED.\" OR \".\n- \"(r.calendar IS NOT NULL AND r.role >= \".ROLE_SUCCESSFUL_AUTH.\")) AND \".\n- $additional_condition.\" \".\n- \"ORDER BY e.creation_time DESC\"\n-);\n-\n-$entries = array();\n-while ($row = $result->fetch_assoc()) {\n- $row['day'] = $day;\n- $row['year'] = $year;\n- $row['month'] = $month;\n- $row['deleted'] = !!$row['deleted'];\n- $row['creationTime'] = intval($row['creationTime']);\n- $entries[] = $row;\n-}\n-\n-async_end(array(\n- 'success' => true,\n- 'result' => $entries,\n-));\n"
},
{
"change_type": "RENAME",
"old_path": "server/month_entries.php",
"new_path": "server/fetch_entries.php",
"diff": "@@ -7,9 +7,12 @@ require_once('calendar_lib.php');\nasync_start();\n+// Be careful with the regex below; bad validation could lead to SQL injection\nif (\n- !isset($_POST['month']) ||\n- !isset($_POST['year']) ||\n+ !isset($_POST['start_date']) ||\n+ !isset($_POST['end_date']) ||\n+ !preg_match(\"/^[0-9]{4}-[0-1][0-9]-[0-3][0-9]$/\", $_POST['start_date']) ||\n+ !preg_match(\"/^[0-9]{4}-[0-1][0-9]-[0-3][0-9]$/\", $_POST['end_date']) ||\n!isset($_POST['nav'])\n) {\nasync_end(array(\n@@ -17,8 +20,9 @@ if (\n));\n}\n-$month = intval($_POST['month']);\n-$year = intval($_POST['year']);\n+$start_date = $_POST['start_date'];\n+$end_date = $_POST['end_date'];\n+$include_deleted = !empty($_POST['include_deleted']);\n$home = null;\n$calendar = null;\n@@ -30,17 +34,19 @@ if ($_POST['nav'] === \"home\") {\n}\n$additional_condition = $home ? \"r.subscribed = 1\" : \"d.calendar = $calendar\";\n+$deleted_condition = $include_deleted ? \"\" : \"AND e.deleted = 0 \";\n$viewer_id = get_viewer_id();\n$result = $conn->query(\n- \"SELECT e.id, DAY(d.date) AS day, e.text, e.creation_time AS creationTime, \".\n- \"d.calendar AS calendarID, e.deleted, u.username AS creator \".\n+ \"SELECT DAY(d.date) AS day, MONTH(d.date) AS month, YEAR(d.date) AS year, \".\n+ \"e.id, e.text, e.creation_time AS creationTime, d.calendar AS calendarID, \".\n+ \"e.deleted, u.username AS creator \".\n\"FROM entries e \".\n\"LEFT JOIN days d ON d.id = e.day \".\n\"LEFT JOIN calendars c ON c.id = d.calendar \".\n\"LEFT JOIN roles r ON r.calendar = d.calendar AND r.user = $viewer_id \".\n\"LEFT JOIN users u ON u.id = e.creator \".\n- \"WHERE MONTH(d.date) = $month AND YEAR(d.date) = $year AND \".\n- \"e.deleted = 0 AND (c.visibility_rules < \".VISIBILITY_CLOSED.\" OR \".\n+ \"WHERE d.date BETWEEN '$start_date' AND '$end_date' $deleted_condition\".\n+ \"AND (c.visibility_rules < \".VISIBILITY_CLOSED.\" OR \".\n\"(r.calendar IS NOT NULL AND r.role >= \".ROLE_SUCCESSFUL_AUTH.\")) AND \".\n$additional_condition.\" \".\n\"ORDER BY e.creation_time DESC\"\n@@ -62,8 +68,8 @@ if ($calendar !== null) {\n$entries = array();\nwhile ($row = $result->fetch_assoc()) {\n$row['day'] = intval($row['day']);\n- $row['year'] = $year;\n- $row['month'] = $month;\n+ $row['year'] = intval($row['year']);\n+ $row['month'] = intval($row['month']);\n$row['creationTime'] = intval($row['creationTime']);\n$row['deleted'] = (bool)$row['deleted'];\n$row['creator'] = $row['creator'] ?: null;\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Replace day_history.php and month_entries.php with fetch_entries.php |
129,187 | 20.04.2017 18:50:00 | 14,400 | b800941b6c92edb1cec918426c7a40bdb2c39d4a | Factor out entry fetch and make it possible to ask for entries in login.php, ping.php, and reset_password.php | [
{
"change_type": "ADD",
"old_path": null,
"new_path": "server/entry_lib.php",
"diff": "+<?php\n+\n+require_once('config.php');\n+require_once('auth.php');\n+require_once('calendar_lib.php');\n+\n+// $input should be an array that contains:\n+// - start_date key with date formatted like 2017-04-20\n+// - end_date key with same date format\n+// - nav key that is either calendar ID or \"home\"\n+// - (optional) include_deleted key whether deleted entries should be included\n+// be careful! $input isn't sanitized before being passed it\n+function get_entry_infos($input) {\n+ global $conn;\n+\n+ // Be careful with the regex below; bad validation could lead to SQL injection\n+ if (\n+ !is_array($input) ||\n+ !isset($input['start_date']) ||\n+ !isset($input['end_date']) ||\n+ !preg_match(\"/^[0-9]{4}-[0-1][0-9]-[0-3][0-9]$/\", $input['start_date']) ||\n+ !preg_match(\"/^[0-9]{4}-[0-1][0-9]-[0-3][0-9]$/\", $input['end_date']) ||\n+ !isset($input['nav'])\n+ ) {\n+ return null;\n+ }\n+\n+ $start_date = $input['start_date'];\n+ $end_date = $input['end_date'];\n+ $include_deleted = !empty($input['include_deleted']);\n+ $home = null;\n+ $calendar = null;\n+ if ($input['nav'] === \"home\") {\n+ $home = true;\n+ } else {\n+ $home = false;\n+ $calendar = intval($input['nav']);\n+ }\n+\n+ $additional_condition = $home ? \"r.subscribed = 1\" : \"d.calendar = $calendar\";\n+ $deleted_condition = $include_deleted ? \"\" : \"AND e.deleted = 0 \";\n+ $viewer_id = get_viewer_id();\n+ $result = $conn->query(\n+ \"SELECT DAY(d.date) AS day, MONTH(d.date) AS month, YEAR(d.date) AS year, \".\n+ \"e.id, e.text, e.creation_time AS creationTime, d.calendar AS calendarID, \".\n+ \"e.deleted, u.username AS creator \".\n+ \"FROM entries e \".\n+ \"LEFT JOIN days d ON d.id = e.day \".\n+ \"LEFT JOIN calendars c ON c.id = d.calendar \".\n+ \"LEFT JOIN roles r ON r.calendar = d.calendar AND r.user = $viewer_id \".\n+ \"LEFT JOIN users u ON u.id = e.creator \".\n+ \"WHERE d.date BETWEEN '$start_date' AND '$end_date' $deleted_condition\".\n+ \"AND (c.visibility_rules < \".VISIBILITY_CLOSED.\" OR \".\n+ \"(r.calendar IS NOT NULL AND r.role >= \".ROLE_SUCCESSFUL_AUTH.\")) AND \".\n+ $additional_condition.\" \".\n+ \"ORDER BY e.creation_time DESC\"\n+ );\n+\n+ if ($calendar !== null) {\n+ $time = round(microtime(true) * 1000); // in milliseconds\n+ $conn->query(\n+ \"INSERT INTO roles(calendar, user, \".\n+ \"creation_time, last_view, role, subscribed) \".\n+ \"VALUES ($calendar, $viewer_id, $time, $time, \".\n+ ROLE_VIEWED.\", 0) ON DUPLICATE KEY UPDATE \".\n+ \"creation_time = LEAST(VALUES(creation_time), creation_time), \".\n+ \"last_view = GREATEST(VALUES(last_view), last_view), \".\n+ \"role = GREATEST(VALUES(role), role)\"\n+ );\n+ }\n+\n+ $entries = array();\n+ while ($row = $result->fetch_assoc()) {\n+ $row['day'] = intval($row['day']);\n+ $row['year'] = intval($row['year']);\n+ $row['month'] = intval($row['month']);\n+ $row['creationTime'] = intval($row['creationTime']);\n+ $row['deleted'] = (bool)$row['deleted'];\n+ $row['creator'] = $row['creator'] ?: null;\n+ $entries[] = $row;\n+ }\n+ return $entries;\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "server/fetch_entries.php",
"new_path": "server/fetch_entries.php",
"diff": "<?php\nrequire_once('async_lib.php');\n-require_once('config.php');\n-require_once('auth.php');\n-require_once('calendar_lib.php');\n+require_once('entry_lib.php');\nasync_start();\n-// Be careful with the regex below; bad validation could lead to SQL injection\n-if (\n- !isset($_POST['start_date']) ||\n- !isset($_POST['end_date']) ||\n- !preg_match(\"/^[0-9]{4}-[0-1][0-9]-[0-3][0-9]$/\", $_POST['start_date']) ||\n- !preg_match(\"/^[0-9]{4}-[0-1][0-9]-[0-3][0-9]$/\", $_POST['end_date']) ||\n- !isset($_POST['nav'])\n-) {\n+$entries = get_entry_infos($_POST);\n+\n+if ($entries === null) {\nasync_end(array(\n'error' => 'invalid_parameters',\n));\n}\n-$start_date = $_POST['start_date'];\n-$end_date = $_POST['end_date'];\n-$include_deleted = !empty($_POST['include_deleted']);\n-\n-$home = null;\n-$calendar = null;\n-if ($_POST['nav'] === \"home\") {\n- $home = true;\n-} else {\n- $home = false;\n- $calendar = intval($_POST['nav']);\n-}\n-\n-$additional_condition = $home ? \"r.subscribed = 1\" : \"d.calendar = $calendar\";\n-$deleted_condition = $include_deleted ? \"\" : \"AND e.deleted = 0 \";\n-$viewer_id = get_viewer_id();\n-$result = $conn->query(\n- \"SELECT DAY(d.date) AS day, MONTH(d.date) AS month, YEAR(d.date) AS year, \".\n- \"e.id, e.text, e.creation_time AS creationTime, d.calendar AS calendarID, \".\n- \"e.deleted, u.username AS creator \".\n- \"FROM entries e \".\n- \"LEFT JOIN days d ON d.id = e.day \".\n- \"LEFT JOIN calendars c ON c.id = d.calendar \".\n- \"LEFT JOIN roles r ON r.calendar = d.calendar AND r.user = $viewer_id \".\n- \"LEFT JOIN users u ON u.id = e.creator \".\n- \"WHERE d.date BETWEEN '$start_date' AND '$end_date' $deleted_condition\".\n- \"AND (c.visibility_rules < \".VISIBILITY_CLOSED.\" OR \".\n- \"(r.calendar IS NOT NULL AND r.role >= \".ROLE_SUCCESSFUL_AUTH.\")) AND \".\n- $additional_condition.\" \".\n- \"ORDER BY e.creation_time DESC\"\n-);\n-\n-if ($calendar !== null) {\n- $time = round(microtime(true) * 1000); // in milliseconds\n- $conn->query(\n- \"INSERT INTO roles(calendar, user, \".\n- \"creation_time, last_view, role, subscribed) \".\n- \"VALUES ($calendar, $viewer_id, $time, $time, \".\n- ROLE_VIEWED.\", 0) ON DUPLICATE KEY UPDATE \".\n- \"creation_time = LEAST(VALUES(creation_time), creation_time), \".\n- \"last_view = GREATEST(VALUES(last_view), last_view), \".\n- \"role = GREATEST(VALUES(role), role)\"\n- );\n-}\n-\n-$entries = array();\n-while ($row = $result->fetch_assoc()) {\n- $row['day'] = intval($row['day']);\n- $row['year'] = intval($row['year']);\n- $row['month'] = intval($row['month']);\n- $row['creationTime'] = intval($row['creationTime']);\n- $row['deleted'] = (bool)$row['deleted'];\n- $row['creator'] = $row['creator'] ?: null;\n- $entries[] = $row;\n-}\n-\nasync_end(array(\n'success' => true,\n'result' => $entries,\n"
},
{
"change_type": "MODIFY",
"old_path": "server/login.php",
"new_path": "server/login.php",
"diff": "require_once('async_lib.php');\nrequire_once('config.php');\nrequire_once('auth.php');\n+require_once('entry_lib.php');\nasync_start();\n@@ -33,11 +34,20 @@ if (!password_verify($password, $user_row['hash'])) {\n$id = intval($user_row['id']);\ncreate_user_cookie($id);\n-async_end(array(\n+$return = array(\n'success' => true,\n'user_info' => array(\n'username' => $user_row['username'],\n'email' => $user_row['email'],\n'email_verified' => (bool)$user_row['email_verified'],\n),\n-));\n+);\n+\n+if (!empty($_POST['inner_entry_query'])) {\n+ $entries = get_entry_infos($_POST['inner_entry_query']);\n+ if ($entries !== null) {\n+ $return['entries'] = $entries;\n+ }\n+}\n+\n+async_end($return);\n"
},
{
"change_type": "MODIFY",
"old_path": "server/ping.php",
"new_path": "server/ping.php",
"diff": "@@ -4,6 +4,7 @@ require_once('async_lib.php');\nrequire_once('config.php');\nrequire_once('auth.php');\nrequire_once('calendar_lib.php');\n+require_once('entry_lib.php');\nasync_start();\n@@ -28,7 +29,17 @@ if ($user_logged_in) {\n);\n}\n-async_end(array(\n+$return = array(\n+ 'success' => true,\n'user_info' => $user_info,\n'calendar_infos' => get_calendar_infos(),\n-));\n+);\n+\n+if (!empty($_POST['inner_entry_query'])) {\n+ $entries = get_entry_infos($_POST['inner_entry_query']);\n+ if ($entries !== null) {\n+ $return['entries'] = $entries;\n+ }\n+}\n+\n+async_end($return);\n"
},
{
"change_type": "MODIFY",
"old_path": "server/reset_password.php",
"new_path": "server/reset_password.php",
"diff": "@@ -4,6 +4,7 @@ require_once('async_lib.php');\nrequire_once('config.php');\nrequire_once('auth.php');\nrequire_once('verify_lib.php');\n+require_once('entry_lib.php');\nasync_start();\n@@ -52,11 +53,20 @@ create_user_cookie($user);\nclear_verify_codes($user, VERIFY_FIELD_RESET_PASSWORD);\n-async_end(array(\n+$return = array(\n'success' => true,\n'user_info' => array(\n'username' => $user_row['username'],\n'email' => $user_row['email'],\n'email_verified' => (bool)$user_row['email_verified'],\n),\n-));\n+);\n+\n+if (!empty($_POST['inner_entry_query'])) {\n+ $entries = get_entry_infos($_POST['inner_entry_query']);\n+ if ($entries !== null) {\n+ $return['entries'] = $entries;\n+ }\n+}\n+\n+async_end($return);\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Factor out entry fetch and make it possible to ask for entries in login.php, ping.php, and reset_password.php |
129,187 | 20.04.2017 19:15:51 | 14,400 | aeb378070c2872c1d099434244b45c34306281a1 | Make sure that a log out, delete account, and any invalidation reset navInfo
Previously we just guaranteed that it pushes a new modal, but it should reset all of navInfo | [
{
"change_type": "MODIFY",
"old_path": "native/navigation-setup.js",
"new_path": "native/navigation-setup.js",
"diff": "@@ -12,6 +12,7 @@ import type {\n} from 'react-navigation';\nimport type { PingResult } from 'lib/actions/ping-actions';\nimport type { AppState } from './redux-setup';\n+import { PropTypes as ReactNavigationPropTypes } from 'react-navigation';\nimport { TabNavigator, StackNavigator } from 'react-navigation';\nimport invariant from 'invariant';\n@@ -42,6 +43,11 @@ export type NavInfo = BaseNavInfo & {\ncalendarID: ?string,\nnavigationState: NavigationState,\n};\n+const navInfoPropType = PropTypes.shape({\n+ home: PropTypes.bool.isRequired,\n+ calendarID: PropTypes.string,\n+ navigationState: ReactNavigationPropTypes.navigationState,\n+});\nexport type Action = BaseAction |\n{ type: \"HANDLE_URL\", payload: string } |\n@@ -144,6 +150,11 @@ const defaultNavigationState = {\n{ key: 'LoggedOutModal', routeName: LoggedOutModalRouteName },\n],\n};\n+const defaultNavInfo = {\n+ home: true,\n+ calendarID: null,\n+ navigationState: defaultNavigationState,\n+};\nfunction reduceNavInfo(state: NavInfo, action: Action): NavInfo {\n// React Navigation actions\n@@ -169,19 +180,13 @@ function reduceNavInfo(state: NavInfo, action: Action): NavInfo {\n...state,\nnavigationState: removeModals(state.navigationState),\n};\n- } else if (action.type === \"LOG_OUT_STARTED\") {\n- return {\n- ...state,\n- navigationState: ensureLoggedOutModalPresence(state.navigationState),\n- };\n+ } else if (\n+ action.type === \"LOG_OUT_STARTED\" ||\n+ action.type === \"DELETE_SUCCESS\"\n+ ) {\n+ return resetNavInfoAndEnsureLoggedOutModalPresence(state);\n} else if (action.type === \"SET_COOKIE\") {\n- return {\n- ...state,\n- navigationState: logOutIfCookieInvalidated(\n- state.navigationState,\n- action.payload,\n- ),\n- };\n+ return logOutIfCookieInvalidated(state, action.payload);\n} else if (action.type === \"PING_SUCCESS\") {\nreturn {\n...state,\n@@ -261,23 +266,36 @@ function removeModals(\n}\n}\n-function ensureLoggedOutModalPresence(state: NavigationState): NavigationState {\n+function resetNavInfoAndEnsureLoggedOutModalPresence(state: NavInfo): NavInfo {\n+ const navigationState = {\n+ ...state.navigationState,\n+ routes: [\n+ ...state.navigationState.routes,\n+ ],\n+ };\n+ navigationState.routes[0] = defaultNavInfo.navigationState.routes[0];\nconst currentModalIndex =\n- _findIndex(['routeName', LoggedOutModalRouteName])(state.routes);\n- if (currentModalIndex >= 0 && state.index >= currentModalIndex) {\n- return state;\n+ _findIndex(['routeName', LoggedOutModalRouteName])(navigationState.routes);\n+ if (currentModalIndex >= 0 && navigationState.index >= currentModalIndex) {\n+ return { ...defaultNavInfo, navigationState };\n} else if (currentModalIndex >= 0) {\nreturn {\n+ ...defaultNavInfo,\n+ navigationState: {\n+ ...navigationState,\nindex: currentModalIndex,\n- routes: state.routes,\n+ },\n};\n}\nreturn {\n- index: state.routes.length,\n+ ...defaultNavInfo,\n+ navigationState: {\n+ index: navigationState.routes.length,\nroutes: [\n- ...state.routes,\n+ ...navigationState.routes,\n{ key: 'LoggedOutModal', routeName: LoggedOutModalRouteName },\n],\n+ },\n};\n}\n@@ -287,11 +305,11 @@ type SetCookiePayload = {\ncookieInvalidated?: bool,\n};\nfunction logOutIfCookieInvalidated(\n- state: NavigationState,\n+ state: NavInfo,\npayload: SetCookiePayload,\n-): NavigationState {\n+): NavInfo {\nif (payload.cookieInvalidated) {\n- const newState = ensureLoggedOutModalPresence(state);\n+ const newState = resetNavInfoAndEnsureLoggedOutModalPresence(state);\nif (state !== newState) {\nAlert.alert(\n\"Session invalidated\",\n@@ -318,8 +336,9 @@ function removeModalsIfPingIndicatesLoggedIn(\n}\nexport {\n+ navInfoPropType,\nRootNavigator,\n- defaultNavigationState,\n+ defaultNavInfo,\nreduceNavInfo,\nLoggedOutModalRouteName,\nVerificationModalRouteName,\n"
},
{
"change_type": "MODIFY",
"old_path": "native/redux-setup.js",
"new_path": "native/redux-setup.js",
"diff": "@@ -4,7 +4,6 @@ import type { CalendarInfo } from 'lib/types/calendar-types';\nimport type { EntryInfo } from 'lib/types/entry-types';\nimport type { LoadingStatus } from 'lib/types/loading-types';\nimport type { UserInfo } from 'lib/types/user-types';\n-import { PropTypes as ReactNavigationPropTypes } from 'react-navigation';\nimport type { NavInfo, Action } from './navigation-setup';\nimport React from 'react';\n@@ -21,16 +20,10 @@ import baseReducer from 'lib/reducers/master-reducer';\nimport {\nRootNavigator,\n- defaultNavigationState,\n+ defaultNavInfo,\nreduceNavInfo,\n} from './navigation-setup';\n-const navInfoPropType = PropTypes.shape({\n- home: PropTypes.bool.isRequired,\n- calendarID: PropTypes.string,\n- navigationState: ReactNavigationPropTypes.navigationState,\n-});\n-\nexport type AppState = {\nnavInfo: NavInfo,\nuserInfo: ?UserInfo,\n@@ -43,11 +36,7 @@ export type AppState = {\n};\nconst defaultState = ({\n- navInfo: {\n- home: true,\n- calendarID: null,\n- navigationState: defaultNavigationState,\n- },\n+ navInfo: defaultNavInfo,\nuserInfo: null,\nentryInfos: {},\ndaysToEntries: {},\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Make sure that a log out, delete account, and any invalidation reset navInfo
Previously we just guaranteed that it pushes a new modal, but it should reset all of navInfo |
129,187 | 27.04.2017 11:19:20 | 14,400 | 3c6a9e4d29544157c54f4bb76d6f352b84a36ec9 | Make it possible for log in and reset password actions to include an inner entry query | [
{
"change_type": "MODIFY",
"old_path": "lib/actions/user-actions.js",
"new_path": "lib/actions/user-actions.js",
"diff": "@@ -4,6 +4,9 @@ import type { FetchJSON } from '../utils/fetch-json';\nimport type { CalendarInfo } from '../types/calendar-types';\nimport type { VerifyField } from '../utils/verify-utils';\nimport type { UserInfo } from '../types/user-types';\n+import type { EntryInfo } from '../types/entry-types';\n+\n+import dateFormat from 'dateformat';\nimport { verifyField } from '../utils/verify-utils';\n@@ -40,6 +43,7 @@ async function register(\nexport type LogInResult = {\ncalendarInfos: {[id: string]: CalendarInfo},\nuserInfo: UserInfo,\n+ entryInfos?: EntryInfo[],\n};\nconst logInActionType = \"LOG_IN\";\nasync function logIn(\n@@ -58,6 +62,39 @@ async function logIn(\n};\n}\n+function currentInnerEntryQuery() {\n+ const fifteenDaysEarlier = new Date();\n+ fifteenDaysEarlier.setDate(fifteenDaysEarlier.getDate() - 15);\n+ const fifteenDaysLater = new Date();\n+ fifteenDaysLater.setDate(fifteenDaysLater.getDate() + 15);\n+ return {\n+ 'nav': 'home',\n+ 'start_date': dateFormat(fifteenDaysEarlier, \"yyyy-mm-dd\"),\n+ 'end_date': dateFormat(fifteenDaysLater, \"yyyy-mm-dd\"),\n+ };\n+}\n+\n+async function logInAndFetchEntries(\n+ fetchJSON: FetchJSON,\n+ username: string,\n+ password: string,\n+): Promise<LogInResult> {\n+ const response = await fetchJSON('login.php', {\n+ username,\n+ password,\n+ 'inner_entry_query': currentInnerEntryQuery(),\n+ });\n+ return {\n+ calendarInfos: response.cookie_change.calendar_infos,\n+ userInfo: {\n+ email: response.user_info.email,\n+ username: response.user_info.username,\n+ emailVerified: response.user_info.email_verified,\n+ },\n+ entryInfos: response.entries,\n+ };\n+}\n+\nconst resetPasswordActionType = \"RESET_PASSWORD\";\nasync function resetPassword(\nfetchJSON: FetchJSON,\n@@ -75,6 +112,27 @@ async function resetPassword(\n};\n}\n+async function resetPasswordAndFetchEntries(\n+ fetchJSON: FetchJSON,\n+ code: string,\n+ password: string,\n+): Promise<LogInResult> {\n+ const response = await fetchJSON('reset_password.php', {\n+ code,\n+ password,\n+ 'inner_entry_query': currentInnerEntryQuery(),\n+ });\n+ return {\n+ calendarInfos: response.cookie_change.calendar_infos,\n+ userInfo: {\n+ email: response.user_info.email,\n+ username: response.user_info.username,\n+ emailVerified: response.user_info.email_verified,\n+ },\n+ entryInfos: response.entries,\n+ };\n+}\n+\nconst forgotPasswordActionType = \"FORGOT_PASSWORD\";\nasync function forgotPassword(\nfetchJSON: FetchJSON,\n@@ -138,8 +196,10 @@ export {\nregister,\nlogInActionType,\nlogIn,\n+ logInAndFetchEntries,\nresetPasswordActionType,\nresetPassword,\n+ resetPasswordAndFetchEntries,\nforgotPasswordActionType,\nforgotPassword,\nchangeUserSettingsActionType,\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/package.json",
"new_path": "lib/package.json",
"diff": "\"flow\": \"flow; test $? -eq 0 -o $? -eq 2\"\n},\n\"dependencies\": {\n+ \"dateformat\": \"^2.0.0\",\n\"invariant\": \"^2.2.2\",\n\"isomorphic-fetch\": \"^2.2.1\",\n\"jquery-param\": \"^0.2.0\",\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/reducers/entry-reducer.js",
"new_path": "lib/reducers/entry-reducer.js",
"diff": "@@ -42,6 +42,37 @@ function filterExistingDaysToEntriesWithNewEntryInfos(\n)(oldDaysToEntries);\n}\n+function mergeNewEntryInfos(\n+ oldEntryInfos: {[id: string]: EntryInfo},\n+ oldDaysToEntries: {[id: string]: string[]},\n+ newEntryInfos: EntryInfo[],\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.\n+ const addedEntryInfos = _flow(\n+ _map((entryInfo: EntryInfo) => {\n+ invariant(entryInfo.id, \"new entryInfos should have serverID\");\n+ const currentEntryInfo = oldEntryInfos[entryInfo.id];\n+ if (currentEntryInfo && currentEntryInfo.localID) {\n+ // Setting directly like this is okay because it's a new object\n+ // anyways\n+ entryInfo.localID = currentEntryInfo.localID;\n+ }\n+ return entryInfo;\n+ }),\n+ _keyBy('id'),\n+ )(newEntryInfos);\n+ const mergedEntryInfos = { ...oldEntryInfos, ...addedEntryInfos };\n+ const addedDaysToEntries = daysToEntriesFromEntryInfos(mergedEntryInfos);\n+ // This mutates addedDaysToEntries, but it's okay since it's a new object\n+ const mergedDaysToEntries = _mergeWith(\n+ (addedEntryIDs, originalEntryIDs) => _isArray(addedEntryIDs)\n+ ? _union(addedEntryIDs)(originalEntryIDs)\n+ : undefined,\n+ )(addedDaysToEntries)(oldDaysToEntries);\n+ return [mergedEntryInfos, mergedDaysToEntries];\n+}\n+\nfunction reduceEntryInfos(\ninputEntryInfos: {[id: string]: EntryInfo},\ninputDaysToEntries: {[id: string]: string[]},\n@@ -88,30 +119,7 @@ function reduceEntryInfos(\naction.type === \"FETCH_MONTH_ENTRIES_SUCCESS\" ||\naction.type === \"FETCH_ALL_DAY_ENTRIES_SUCCESS\"\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.\n- const addedEntryInfos = _flow(\n- _map((entryInfo: EntryInfo) => {\n- invariant(entryInfo.id, \"new entryInfos should have serverID\");\n- const currentEntryInfo = entryInfos[entryInfo.id];\n- if (currentEntryInfo && currentEntryInfo.localID) {\n- // Setting directly like this is okay because it's a new object\n- // anyways\n- entryInfo.localID = currentEntryInfo.localID;\n- }\n- return entryInfo;\n- }),\n- _keyBy('id'),\n- )(action.payload);\n- const newEntryInfos = { ...entryInfos, ...addedEntryInfos };\n- const addedDaysToEntries = daysToEntriesFromEntryInfos(action.payload);\n- // This mutates addedDaysToEntries, but it's okay since it's a new object\n- const newDaysToEntries = _mergeWith(\n- (addedEntryIDs, originalEntryIDs) => _isArray(addedEntryIDs)\n- ? _union(addedEntryIDs)(originalEntryIDs)\n- : undefined,\n- )(addedDaysToEntries)(daysToEntries);\n- return [newEntryInfos, newDaysToEntries];\n+ return mergeNewEntryInfos(entryInfos, daysToEntries, action.payload);\n} else if (action.type === \"CREATE_LOCAL_ENTRY\") {\nconst entryInfo = action.payload;\ninvariant(entryInfo.localID, \"localID should be set in CREATE_LOCAL_ENTRY\");\n@@ -227,6 +235,14 @@ function reduceEntryInfos(\n},\n};\nreturn [newEntryInfos, daysToEntries];\n+ } else if (\n+ action.type === \"LOG_IN_SUCCESS\" ||\n+ action.type === \"RESET_PASSWORD_SUCCESS\"\n+ ) {\n+ const newEntryInfos = action.payload.entryInfos;\n+ if (newEntryInfos) {\n+ return mergeNewEntryInfos(entryInfos, daysToEntries, newEntryInfos);\n+ }\n}\nreturn [entryInfos, daysToEntries];\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "native/account/log-in-panel.react.js",
"new_path": "native/account/log-in-panel.react.js",
"diff": "@@ -27,7 +27,10 @@ import {\nincludeDispatchActionProps,\nbindServerCalls,\n} from 'lib/utils/action-utils';\n-import { logInActionType, logIn } from 'lib/actions/user-actions';\n+import {\n+ logInActionType,\n+ logInAndFetchEntries,\n+} from 'lib/actions/user-actions';\nimport { createLoadingStatusSelector } from 'lib/selectors/loading-selectors';\nimport { TextInput } from '../modal-components.react';\n@@ -53,7 +56,7 @@ class LogInPanel extends React.PureComponent {\n// Redux dispatch functions\ndispatchActionPromise: DispatchActionPromise,\n// async functions that hit server APIs\n- logIn: (\n+ logInAndFetchEntries: (\nusername: string,\npassword: string,\n) => Promise<LogInResult>,\n@@ -65,7 +68,7 @@ class LogInPanel extends React.PureComponent {\ninnerRef: PropTypes.func.isRequired,\nloadingStatus: PropTypes.string.isRequired,\ndispatchActionPromise: PropTypes.func.isRequired,\n- logIn: PropTypes.func.isRequired,\n+ logInAndFetchEntries: PropTypes.func.isRequired,\n};\nstate: {\nusernameOrEmailInputText: string,\n@@ -208,7 +211,7 @@ class LogInPanel extends React.PureComponent {\nasync logInAction() {\ntry {\n- const result = await this.props.logIn(\n+ const result = await this.props.logInAndFetchEntries(\nthis.state.usernameOrEmailInputText,\nthis.state.passwordInputText,\n);\n@@ -312,5 +315,5 @@ export default connect(\nloadingStatus: loadingStatusSelector(state),\n}),\nincludeDispatchActionProps({ dispatchActionPromise: true }),\n- bindServerCalls({ logIn }),\n+ bindServerCalls({ logInAndFetchEntries }),\n)(LogInPanel);\n"
},
{
"change_type": "MODIFY",
"old_path": "native/account/reset-password-panel.react.js",
"new_path": "native/account/reset-password-panel.react.js",
"diff": "@@ -23,7 +23,7 @@ import PropTypes from 'prop-types';\nimport { createLoadingStatusSelector } from 'lib/selectors/loading-selectors';\nimport {\nresetPasswordActionType,\n- resetPassword,\n+ resetPasswordAndFetchEntries,\n} from 'lib/actions/user-actions';\nimport {\nincludeDispatchActionProps,\n@@ -51,7 +51,10 @@ class ResetPasswordPanel extends React.PureComponent {\n// Redux dispatch functions\ndispatchActionPromise: DispatchActionPromise,\n// async functions that hit server APIs\n- resetPassword: (code: string, password: string) => Promise<LogInResult>,\n+ resetPasswordAndFetchEntries: (\n+ code: string,\n+ password: string,\n+ ) => Promise<LogInResult>,\n};\nstatic propTypes = {\nverifyCode: PropTypes.string.isRequired,\n@@ -62,7 +65,7 @@ class ResetPasswordPanel extends React.PureComponent {\nopacityValue: PropTypes.object.isRequired,\nloadingStatus: PropTypes.string.isRequired,\ndispatchActionPromise: PropTypes.func.isRequired,\n- resetPassword: PropTypes.func.isRequired,\n+ resetPasswordAndFetchEntries: PropTypes.func.isRequired,\n};\nstate: {\npasswordInputText: string,\n@@ -200,7 +203,7 @@ class ResetPasswordPanel extends React.PureComponent {\nasync resetPasswordAction() {\ntry {\n- const result = await this.props.resetPassword(\n+ const result = await this.props.resetPasswordAndFetchEntries(\nthis.props.verifyCode,\nthis.state.passwordInputText,\n);\n@@ -267,5 +270,5 @@ export default connect(\nloadingStatus: loadingStatusSelector(state),\n}),\nincludeDispatchActionProps({ dispatchActionPromise: true }),\n- bindServerCalls({ resetPassword }),\n+ bindServerCalls({ resetPasswordAndFetchEntries }),\n)(ResetPasswordPanel);\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Make it possible for log in and reset password actions to include an inner entry query |
129,187 | 27.04.2017 13:58:21 | 14,400 | a74b132c10e1a28a6cd9add6994b13574dafd1c7 | Add pingAndFetchEntries action | [
{
"change_type": "MODIFY",
"old_path": "lib/actions/ping-actions.js",
"new_path": "lib/actions/ping-actions.js",
"diff": "import type { FetchJSON } from '../utils/fetch-json';\nimport type { CalendarInfo } from '../types/calendar-types';\nimport type { UserInfo } from '../types/user-types';\n+import type { EntryInfo } from '../types/entry-types';\n+import type { InnerEntryQuery } from '../utils/entry-utils';\nexport type PingResult = {\ncalendarInfos: {[id: string]: CalendarInfo},\nuserInfo: ?UserInfo,\n+ entryInfos?: EntryInfo[],\n};\nconst pingActionType = \"PING\";\nasync function ping(fetchJSON: FetchJSON): Promise<PingResult> {\n@@ -21,7 +24,29 @@ async function ping(fetchJSON: FetchJSON): Promise<PingResult> {\nreturn { calendarInfos: response.calendar_infos, userInfo };\n}\n+async function pingAndFetchEntries(\n+ fetchJSON: FetchJSON,\n+ innerEntryQuery: InnerEntryQuery,\n+): Promise<PingResult> {\n+ const response = await fetchJSON('ping.php', {\n+ 'inner_entry_query': innerEntryQuery,\n+ });\n+ const userInfo = response.user_info\n+ ? {\n+ email: response.user_info.email,\n+ username: response.user_info.username,\n+ emailVerified: response.user_info.email_verified,\n+ }\n+ : null;\n+ return {\n+ calendarInfos: response.calendar_infos,\n+ userInfo,\n+ entryInfos: response.entries,\n+ };\n+}\n+\nexport {\npingActionType,\nping,\n+ pingAndFetchEntries,\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/actions/user-actions.js",
"new_path": "lib/actions/user-actions.js",
"diff": "@@ -6,9 +6,8 @@ import type { VerifyField } from '../utils/verify-utils';\nimport type { UserInfo } from '../types/user-types';\nimport type { EntryInfo } from '../types/entry-types';\n-import dateFormat from 'dateformat';\n-\nimport { verifyField } from '../utils/verify-utils';\n+import { currentInnerEntryQuery } from '../utils/entry-utils';\nconst logOutActionType = \"LOG_OUT\";\nasync function logOut(\n@@ -62,18 +61,6 @@ async function logIn(\n};\n}\n-function currentInnerEntryQuery() {\n- const fifteenDaysEarlier = new Date();\n- fifteenDaysEarlier.setDate(fifteenDaysEarlier.getDate() - 15);\n- const fifteenDaysLater = new Date();\n- fifteenDaysLater.setDate(fifteenDaysLater.getDate() + 15);\n- return {\n- 'nav': 'home',\n- 'start_date': dateFormat(fifteenDaysEarlier, \"yyyy-mm-dd\"),\n- 'end_date': dateFormat(fifteenDaysLater, \"yyyy-mm-dd\"),\n- };\n-}\n-\nasync function logInAndFetchEntries(\nfetchJSON: FetchJSON,\nusername: string,\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/reducers/entry-reducer.js",
"new_path": "lib/reducers/entry-reducer.js",
"diff": "@@ -237,7 +237,8 @@ function reduceEntryInfos(\nreturn [newEntryInfos, daysToEntries];\n} else if (\naction.type === \"LOG_IN_SUCCESS\" ||\n- action.type === \"RESET_PASSWORD_SUCCESS\"\n+ action.type === \"RESET_PASSWORD_SUCCESS\" ||\n+ action.type === \"PING_SUCCESS\"\n) {\nconst newEntryInfos = action.payload.entryInfos;\nif (newEntryInfos) {\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "lib/utils/entry-utils.js",
"diff": "+// @flow\n+\n+import dateFormat from 'dateformat';\n+\n+export type InnerEntryQuery = {\n+ nav: string,\n+ start_date: string,\n+ end_date: string,\n+};\n+\n+function currentInnerEntryQuery(): InnerEntryQuery {\n+ const fifteenDaysEarlier = new Date();\n+ fifteenDaysEarlier.setDate(fifteenDaysEarlier.getDate() - 15);\n+ const fifteenDaysLater = new Date();\n+ fifteenDaysLater.setDate(fifteenDaysLater.getDate() + 15);\n+ return {\n+ 'nav': 'home',\n+ 'start_date': dateFormat(fifteenDaysEarlier, \"yyyy-mm-dd\"),\n+ 'end_date': dateFormat(fifteenDaysLater, \"yyyy-mm-dd\"),\n+ };\n+}\n+\n+export {\n+ currentInnerEntryQuery,\n+};\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Add pingAndFetchEntries action |
129,187 | 30.04.2017 09:20:05 | 14,400 | 630a5ccf5b22f2b49e48ab984d935e5b5fc97a4d | Update react-native and react-navigation | [
{
"change_type": "MODIFY",
"old_path": "native/account/logged-out-modal.react.js",
"new_path": "native/account/logged-out-modal.react.js",
"diff": "@@ -108,9 +108,7 @@ class InnerLoggedOutModal extends React.PureComponent {\n};\nstatic navigationOptions = {\n- cardStack: {\ngesturesEnabled: false,\n- },\n};\nkeyboardShowListener: ?EmitterSubscription;\n"
},
{
"change_type": "MODIFY",
"old_path": "native/app.react.js",
"new_path": "native/app.react.js",
"diff": "// @flow\nimport type { NavigationState } from 'react-navigation';\n-import { PropTypes as ReactNavigationPropTypes } from 'react-navigation';\nimport type { Dispatch } from 'lib/types/redux-types';\nimport type { AppState } from './redux-setup';\nimport type { Action } from './navigation-setup';\n@@ -87,7 +86,7 @@ class AppWithNavigationState extends React.PureComponent {\n};\nstatic propTypes = {\ncookie: PropTypes.string,\n- navigationState: ReactNavigationPropTypes.navigationState,\n+ navigationState: PropTypes.object.isRequired,\nloggedIn: PropTypes.bool.isRequired,\ndispatch: PropTypes.func.isRequired,\ndispatchActionPayload: PropTypes.func.isRequired,\n"
},
{
"change_type": "MODIFY",
"old_path": "native/calendar/calendar.react.js",
"new_path": "native/calendar/calendar.react.js",
"diff": "@@ -17,15 +17,13 @@ class Calendar extends React.PureComponent {\nstate: State;\nstatic navigationOptions = {\n- tabBar: {\n- label: 'Calendar',\n- icon: ({ tintColor }) => (\n+ tabBarLabel: 'Calendar',\n+ tabBarIcon: ({ tintColor }) => (\n<Icon\nname=\"calendar\"\nstyle={[styles.icon, { color: tintColor }]}\n/>\n),\n- },\n};\nconstructor(props: Props) {\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/chat.react.js",
"new_path": "native/chat/chat.react.js",
"diff": "@@ -15,15 +15,13 @@ class Chat extends React.PureComponent {\nstate: State;\nstatic navigationOptions = {\n- tabBar: {\n- label: 'Chat',\n- icon: ({ tintColor }) => (\n+ tabBarLabel: 'Chat',\n+ tabBarIcon: ({ tintColor }) => (\n<Icon\nname=\"comments-o\"\nstyle={[styles.icon, { color: tintColor }]}\n/>\n),\n- },\n};\nrender() {\n"
},
{
"change_type": "MODIFY",
"old_path": "native/more/more.react.js",
"new_path": "native/more/more.react.js",
"diff": "@@ -52,15 +52,13 @@ class More extends React.PureComponent {\n};\nstatic navigationOptions = {\n- tabBar: {\n- label: 'More',\n- icon: ({ tintColor }) => (\n+ tabBarLabel: 'More',\n+ tabBarIcon: ({ tintColor }) => (\n<Icon\nname=\"bars\"\nstyle={[styles.icon, { color: tintColor }]}\n/>\n),\n- },\n};\nrender() {\n"
},
{
"change_type": "MODIFY",
"old_path": "native/navigation-setup.js",
"new_path": "native/navigation-setup.js",
"diff": "@@ -12,7 +12,6 @@ import type {\n} from 'react-navigation';\nimport type { PingResult } from 'lib/actions/ping-actions';\nimport type { AppState } from './redux-setup';\n-import { PropTypes as ReactNavigationPropTypes } from 'react-navigation';\nimport { TabNavigator, StackNavigator } from 'react-navigation';\nimport invariant from 'invariant';\n"
},
{
"change_type": "MODIFY",
"old_path": "native/package.json",
"new_path": "native/package.json",
"diff": "\"dependencies\": {\n\"invariant\": \"^2.2.2\",\n\"react\": \"^16.0.0-alpha.6\",\n- \"react-native\": \"^0.43.3\",\n+ \"react-native\": \"^0.43.4\",\n\"react-native-cookies\": \"^2.0.0\",\n\"react-native-keychain\": \"^1.2.0\",\n\"react-native-onepassword\": \"^1.0.4\",\n\"react-native-vector-icons\": \"^4.0.1\",\n- \"react-navigation\": \"git+https://github.com/react-community/react-navigation.git#7edd9a7\",\n+ \"react-navigation\": \"^1.0.0-beta.9\",\n\"react-redux\": \"^5.0.4\",\n\"redux\": \"^3.6.0\",\n\"redux-persist\": \"^4.6.0\",\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Update react-native and react-navigation |
129,187 | 03.05.2017 13:50:47 | 14,400 | bc8b9af056bf8e0fa976c69c22941193ba48e2e2 | Upgrade to react-native 0.44.0, find that doesn't have the thing I want, go to master instead, find a bunch of new Flow errors, fix them | [
{
"change_type": "MODIFY",
"old_path": "native/.flowconfig",
"new_path": "native/.flowconfig",
"diff": "@@ -39,12 +39,12 @@ suppress_type=$FlowIssue\nsuppress_type=$FlowFixMe\nsuppress_type=$FixMe\n-suppress_comment=\\\\(.\\\\|\\n\\\\)*\\\\$FlowFixMe\\\\($\\\\|[^(]\\\\|(\\\\(>=0\\\\.\\\\(4[0-0]\\\\|[1-3][0-9]\\\\|[0-9]\\\\).[0-9]\\\\)? *\\\\(site=[a-z,_]*react_native[a-z,_]*\\\\)?)\\\\)\n-suppress_comment=\\\\(.\\\\|\\n\\\\)*\\\\$FlowIssue\\\\((\\\\(>=0\\\\.\\\\(4[0-0]\\\\|[1-3][0-9]\\\\|[0-9]\\\\).[0-9]\\\\)? *\\\\(site=[a-z,_]*react_native[a-z,_]*\\\\)?)\\\\)?:? #[0-9]+\n+suppress_comment=\\\\(.\\\\|\\n\\\\)*\\\\$FlowFixMe\\\\($\\\\|[^(]\\\\|(\\\\(>=0\\\\.\\\\(4[0-2]\\\\|[1-3][0-9]\\\\|[0-9]\\\\).[0-9]\\\\)? *\\\\(site=[a-z,_]*react_native[a-z,_]*\\\\)?)\\\\)\n+suppress_comment=\\\\(.\\\\|\\n\\\\)*\\\\$FlowIssue\\\\((\\\\(>=0\\\\.\\\\(4[0-2]\\\\|[1-3][0-9]\\\\|[0-9]\\\\).[0-9]\\\\)? *\\\\(site=[a-z,_]*react_native[a-z,_]*\\\\)?)\\\\)?:? #[0-9]+\nsuppress_comment=\\\\(.\\\\|\\n\\\\)*\\\\$FlowFixedInNextDeploy\nsuppress_comment=\\\\(.\\\\|\\n\\\\)*\\\\$FlowExpectedError\nunsafe.enable_getters_and_setters=true\n[version]\n-^0.40.0\n+^0.42.0\n"
},
{
"change_type": "MODIFY",
"old_path": "native/account/logged-out-modal.react.js",
"new_path": "native/account/logged-out-modal.react.js",
"diff": "@@ -21,10 +21,9 @@ import {\nAnimated,\nEasing,\nImage,\n- EmitterSubscription,\nKeyboard,\nPlatform,\n- BackAndroid,\n+ BackHandler,\nActivityIndicator,\n} from 'react-native';\nimport invariant from 'invariant';\n@@ -116,8 +115,8 @@ class InnerLoggedOutModal extends React.PureComponent {\ngesturesEnabled: false,\n};\n- keyboardShowListener: ?EmitterSubscription;\n- keyboardHideListener: ?EmitterSubscription;\n+ keyboardShowListener: ?Object;\n+ keyboardHideListener: ?Object;\nnextMode: LoggedOutMode = \"loading\";\nactiveAlert = false;\n@@ -173,7 +172,7 @@ class InnerLoggedOutModal extends React.PureComponent {\nPlatform.OS === \"ios\" ? \"keyboardWillHide\" : \"keyboardDidHide\",\nthis.keyboardHide,\n);\n- BackAndroid.addEventListener('hardwareBackPress', this.hardwareBack);\n+ BackHandler.addEventListener('hardwareBackPress', this.hardwareBack);\n}\nonBackground() {\n@@ -183,7 +182,7 @@ class InnerLoggedOutModal extends React.PureComponent {\nif (this.keyboardHideListener) {\nthis.keyboardHideListener.remove();\n}\n- BackAndroid.removeEventListener('hardwareBackPress', this.hardwareBack);\n+ BackHandler.removeEventListener('hardwareBackPress', this.hardwareBack);\n}\n// This gets triggered when an app is killed and restarted\n@@ -406,18 +405,19 @@ class InnerLoggedOutModal extends React.PureComponent {\nanimateKeyboardDownOrBackToPrompt(inputDuration: ?number) {\nconst duration = inputDuration ? inputDuration : 250;\n- this.lastPanelPaddingTopValue =\n+ const newLastPanelPaddingTopValue =\nInnerLoggedOutModal.calculatePanelPaddingTop(\nthis.nextMode,\n0,\n);\n+ this.lastPanelPaddingTopValue = newLastPanelPaddingTopValue;\nconst animations = [\nAnimated.timing(\nthis.state.panelPaddingTop,\n{\nduration,\neasing: Easing.out(Easing.ease),\n- toValue: this.lastPanelPaddingTopValue,\n+ toValue: newLastPanelPaddingTopValue,\n},\n),\nAnimated.timing(\n@@ -471,10 +471,11 @@ class InnerLoggedOutModal extends React.PureComponent {\n}\ngoBackToPrompt = () => {\n- let opacityListenerID = -1;\n+ let opacityListenerID: ?string = null;\nconst opacityListener = (animatedUpdate: { value: number }) => {\nif (animatedUpdate.value === 0) {\nthis.setState({ mode: this.nextMode });\n+ invariant(opacityListenerID, \"should be set\");\nthis.state.panelOpacity.removeListener(opacityListenerID);\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "native/account/panel-components.react.js",
"new_path": "native/account/panel-components.react.js",
"diff": "// @flow\nimport type { LoadingStatus } from 'lib/types/loading-types';\n+import type { StyleObj } from 'react-native/Libraries/StyleSheet/StyleSheetTypes';\nimport React from 'react';\nimport {\n@@ -91,7 +92,7 @@ function PanelOnePasswordButton(props: { onPress: () => Promise<void> }) {\ntype PanelProps = {\nopacityValue: Animated.Value,\nchildren?: React.Element<any>,\n- style?: StyleSheet.Styles,\n+ style?: StyleObj,\n};\nfunction Panel(props: PanelProps) {\nconst opacityStyle = { opacity: props.opacityValue };\n"
},
{
"change_type": "MODIFY",
"old_path": "native/account/verification-modal.react.js",
"new_path": "native/account/verification-modal.react.js",
"diff": "@@ -15,13 +15,12 @@ import {\nText,\nView,\nStyleSheet,\n- BackAndroid,\n+ BackHandler,\nActivityIndicator,\nAnimated,\nPlatform,\nKeyboard,\nTouchableHighlight,\n- EmitterSubscription,\nEasing,\n} from 'react-native';\nimport { connect } from 'react-redux';\n@@ -109,8 +108,8 @@ class InnerVerificationModal extends React.PureComponent {\nonePasswordSupported: false,\n};\nactiveAlert = false;\n- keyboardShowListener: ?EmitterSubscription;\n- keyboardHideListener: ?EmitterSubscription;\n+ keyboardShowListener: ?Object;\n+ keyboardHideListener: ?Object;\nactiveKeyboard = false;\nopacityChangeQueued = false;\nkeyboardHeight = 0;\n@@ -180,7 +179,7 @@ class InnerVerificationModal extends React.PureComponent {\nPlatform.OS === \"ios\" ? \"keyboardWillHide\" : \"keyboardDidHide\",\nthis.keyboardHide,\n);\n- BackAndroid.addEventListener('hardwareBackPress', this.hardwareBack);\n+ BackHandler.addEventListener('hardwareBackPress', this.hardwareBack);\n}\nonBackground() {\n@@ -190,7 +189,7 @@ class InnerVerificationModal extends React.PureComponent {\nif (this.keyboardHideListener) {\nthis.keyboardHideListener.remove();\n}\n- BackAndroid.removeEventListener('hardwareBackPress', this.hardwareBack);\n+ BackHandler.removeEventListener('hardwareBackPress', this.hardwareBack);\n}\nhardwareBack = () => {\n@@ -205,10 +204,11 @@ class InnerVerificationModal extends React.PureComponent {\n}\nonResetPasswordSuccess = () => {\n- let opacityListenerID = -1;\n+ let opacityListenerID: ?string = null;\nconst opacityListener = (animatedUpdate: { value: number }) => {\nif (animatedUpdate.value === 0) {\nthis.setState({ mode: this.nextMode });\n+ invariant(opacityListenerID, \"should be set\");\nthis.state.resetPasswordPanelOpacityValue.removeListener(\nopacityListenerID,\n);\n"
},
{
"change_type": "MODIFY",
"old_path": "native/android/app/build.gradle",
"new_path": "native/android/app/build.gradle",
"diff": "@@ -58,7 +58,7 @@ import com.android.build.OutputFile\n* inputExcludes: [\"android/**\", \"ios/**\"],\n*\n* // override which node gets called and with what additional arguments\n- * nodeExecutableAndArgs: [\"node\"]\n+ * nodeExecutableAndArgs: [\"node\"],\n*\n* // supply additional arguments to the packager\n* extraPackagerArgs: []\n"
},
{
"change_type": "MODIFY",
"old_path": "native/android/app/proguard-rules.pro",
"new_path": "native/android/app/proguard-rules.pro",
"diff": "-dontwarn com.facebook.react.**\n+# TextLayoutBuilder uses a non-public Android constructor within StaticLayout.\n+# See libs/proxy/src/main/java/com/facebook/fbui/textlayoutbuilder/proxy for details.\n+-dontwarn android.text.StaticLayout\n+\n# okhttp\n-keepattributes Signature\n"
},
{
"change_type": "MODIFY",
"old_path": "native/ios/SquadCalTests/SquadCalTests.m",
"new_path": "native/ios/SquadCalTests/SquadCalTests.m",
"diff": "- (void)testRendersWelcomeScreen\n{\n- UIViewController *vc = [[[[UIApplication sharedApplication] delegate] window] rootViewController];\n+ UIViewController *vc = [[[RCTSharedApplication() delegate] window] rootViewController];\nNSDate *date = [NSDate dateWithTimeIntervalSinceNow:TIMEOUT_SECONDS];\nBOOL foundElement = NO;\n"
},
{
"change_type": "MODIFY",
"old_path": "native/navigation-setup.js",
"new_path": "native/navigation-setup.js",
"diff": "@@ -17,7 +17,7 @@ import { TabNavigator, StackNavigator } from 'react-navigation';\nimport invariant from 'invariant';\nimport _findIndex from 'lodash/fp/findIndex';\nimport _includes from 'lodash/fp/includes';\n-import { Alert, BackAndroid } from 'react-native';\n+import { Alert, BackHandler } from 'react-native';\nimport React from 'react';\nimport PropTypes from 'prop-types';\nimport { connect } from 'react-redux';\n@@ -87,11 +87,11 @@ class WrappedAppNavigator extends React.PureComponent {\n}\nonForeground() {\n- BackAndroid.addEventListener('hardwareBackPress', this.hardwareBack);\n+ BackHandler.addEventListener('hardwareBackPress', this.hardwareBack);\n}\nonBackground() {\n- BackAndroid.removeEventListener('hardwareBackPress', this.hardwareBack);\n+ BackHandler.removeEventListener('hardwareBackPress', this.hardwareBack);\n}\nhardwareBack = () => {\n"
},
{
"change_type": "MODIFY",
"old_path": "native/package.json",
"new_path": "native/package.json",
"diff": "\"dependencies\": {\n\"invariant\": \"^2.2.2\",\n\"react\": \"^16.0.0-alpha.6\",\n- \"react-native\": \"^0.43.4\",\n+ \"react-native\": \"^0.44.0\",\n\"react-native-cookies\": \"^2.0.0\",\n\"react-native-keychain\": \"^1.2.0\",\n\"react-native-onepassword\": \"^1.0.4\",\n\"babel-jest\": \"19.0.0\",\n\"babel-plugin-transform-remove-console\": \"^6.8.1\",\n\"babel-preset-react-native\": \"1.9.1\",\n- \"flow-bin\": \"^0.40.0\",\n+ \"flow-bin\": \"^0.42.0\",\n\"jest\": \"^19.0.2\",\n\"react-devtools\": \"^2.0.12\",\n\"react-test-renderer\": \"^15.5.4\",\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Upgrade to react-native 0.44.0, find that doesn't have the thing I want, go to master instead, find a bunch of new Flow errors, fix them |
129,187 | 03.05.2017 19:14:52 | 14,400 | 47038dbce075d247271ae5344137f731c6574543 | Uhh... cookies stopped working in React Native 0.44.0 on iOS, so I'm just gonna like pass the cookie values directly
It's not like SSL/TLS works better on the Cookie header than on the contents anyways
On web we won't do this though so we can keep our cookies httponly | [
{
"change_type": "MODIFY",
"old_path": "lib/utils/action-utils.js",
"new_path": "lib/utils/action-utils.js",
"diff": "@@ -162,6 +162,7 @@ async function fetchNewCookieFromNativeCredentials<T: BaseAppState, A>(\n};\ntry {\nconst result = await fetchJSON(\n+ cookie,\ninnerBoundSetCookie,\n() => new Promise(r => r(null)),\n(someCookie: ?string) => new Promise(r => r(null)),\n@@ -258,6 +259,7 @@ function bindCookieAndUtilsIntoFetchJSON<T: BaseAppState, A>(\nreturn (async (url: string, data: Object) => {\nreturn await fetchJSON(\n+ cookie,\nboundSetCookie,\nwaitIfCookieInvalidated,\ncookieInvalidationRecovery,\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/utils/config.js",
"new_path": "lib/utils/config.js",
"diff": "@@ -10,7 +10,7 @@ export type Config = {\nfetchJSON: FetchJSON,\ndispatchRecoveryAttempt: DispatchRecoveryAttempt,\n) => Promise<void>),\n- getNativeCookie: ?(() => Promise<?string>),\n+ getNewCookie: ?((response: Object) => Promise<?string>),\ncalendarRangeInactivityLimit: ?number,\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/utils/fetch-json.js",
"new_path": "lib/utils/fetch-json.js",
"diff": "@@ -23,6 +23,7 @@ export type FetchJSON = (url: string, data: Object) => Promise<Object>;\n// isn't a thing on native. Note that for native, cookie might be null\n// (indicating we don't have one), and we will then set an empty Cookie header.\nasync function fetchJSON(\n+ cookie: ?string,\nsetCookieCallback: (newCookie: ?string, response: Object) => void,\nwaitIfCookieInvalidated: () => Promise<?FetchJSON>,\ncookieInvalidationRecovery:\n@@ -35,13 +36,14 @@ async function fetchJSON(\nreturn await possibleReplacement(url, data);\n}\n+ const mergedData = { ...data, cookie };\nconst prefixedURL = getConfig().urlPrefix + url;\nconst response = await fetch(prefixedURL, {\n// Flow gets confused by some enum type, so we need this cast\n'method': ('POST': MethodType),\n// This is necessary to allow cookie headers to get passed down to us\n'credentials': 'same-origin',\n- 'body': $param(data),\n+ 'body': $param(mergedData),\n'headers': {\n'Accept': 'application/json',\n'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',\n@@ -50,9 +52,9 @@ async function fetchJSON(\nconst json = await response.json();\nconsole.log(json);\n- const getNativeCookie = getConfig().getNativeCookie;\n- if (getNativeCookie) {\n- const newCookie = await getNativeCookie();\n+ const getNewCookie = getConfig().getNewCookie;\n+ if (getNewCookie) {\n+ const newCookie = await getNewCookie(json);\nif (newCookie) {\nif (json.cookie_change && json.cookie_change.cookie_invalidated) {\nconst possibleReplacement = await cookieInvalidationRecovery(newCookie);\n"
},
{
"change_type": "MODIFY",
"old_path": "native/app.react.js",
"new_path": "native/app.react.js",
"diff": "@@ -66,7 +66,12 @@ if (!__DEV__) {\nregisterConfig({\nurlPrefix,\nresolveInvalidatedCookie,\n- getNativeCookie,\n+ getNewCookie: async (response: Object) => {\n+ if (response.cookie_change && response.cookie_change.cookie) {\n+ return response.cookie_change.cookie;\n+ }\n+ return null;\n+ },\ncalendarRangeInactivityLimit: sessionInactivityLimit,\n});\n"
},
{
"change_type": "MODIFY",
"old_path": "native/package.json",
"new_path": "native/package.json",
"diff": "\"invariant\": \"^2.2.2\",\n\"react\": \"^16.0.0-alpha.6\",\n\"react-native\": \"^0.44.0\",\n- \"react-native-cookies\": \"^2.0.0\",\n+ \"react-native-cookies\": \"^3.0.0\",\n\"react-native-keychain\": \"^1.2.0\",\n\"react-native-onepassword\": \"^1.0.4\",\n\"react-native-vector-icons\": \"^4.0.1\",\n"
},
{
"change_type": "MODIFY",
"old_path": "server/async_lib.php",
"new_path": "server/async_lib.php",
"diff": "@@ -37,6 +37,10 @@ function async_end($payload) {\n'calendar_infos' => get_calendar_infos(),\n'cookie_invalidated' => $cookie_invalidated,\n);\n+ // Only include in the raw response since on web we want it to be httponly\n+ if (isset($_POST['cookie'])) {\n+ $payload['cookie_change']['cookie'] = get_viewer_info()[2];\n+ }\n}\nasync_exit($payload);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "server/auth.php",
"new_path": "server/auth.php",
"diff": "@@ -61,6 +61,36 @@ function cookie_has_changed() {\nreturn $original_viewer_info[2] !== $current_viewer_info[2];\n}\n+function get_input_user_cookie() {\n+ if (isset($_COOKIE['user'])) {\n+ return $_COOKIE['user'];\n+ }\n+ if (!isset($_POST['cookie'])) {\n+ return null;\n+ }\n+ $matches = array();\n+ $num_matches = preg_match(\"/user=(.+)/\", $_POST['cookie'], $matches);\n+ if (!$num_matches) {\n+ return null;\n+ }\n+ return $matches[1];\n+}\n+\n+function get_input_anonymous_cookie() {\n+ if (isset($_COOKIE['anonymous'])) {\n+ return $_COOKIE['anonymous'];\n+ }\n+ if (!isset($_POST['cookie'])) {\n+ return null;\n+ }\n+ $matches = array();\n+ $num_matches = preg_match(\"/anonymous=(.+)/\", $_POST['cookie'], $matches);\n+ if (!$num_matches) {\n+ return null;\n+ }\n+ return $matches[1];\n+}\n+\n// Returns array(\n// int: either a user ID or a cookie ID (for anonymous),\n// bool: whether or not the viewer is a user\n@@ -71,11 +101,12 @@ function init_cookie() {\n$current_viewer_info,\n$inbound_cookie_invalidated;\n- if (!isset($_COOKIE['user'])) {\n+ $user_cookie = get_input_user_cookie();\n+ if ($user_cookie === null) {\ninit_anonymous_cookie(true);\nreturn;\n}\n- list($cookie_id, $cookie_password) = explode(':', $_COOKIE['user']);\n+ list($cookie_id, $cookie_password) = explode(':', $user_cookie);\n$cookie_id = intval($cookie_id);\n$result = $conn->query(\n\"SELECT hash, user, last_update FROM cookies \".\n@@ -230,17 +261,24 @@ function get_anonymous_cookie($initial_run) {\n$cookie_sent_from_client;\n// First, let's see if we already have a valid cookie\n- if (!isset($_COOKIE['anonymous'])) {\n+ $anonymous_cookie = get_input_anonymous_cookie();\n+ if ($anonymous_cookie === null) {\n// If we get here on the first run, that means there was no cookie sent by\n// the client at all\nif ($initial_run) {\n+ // Note that this function (get_anonymous_cookie) can get called with\n+ // $initial_run === true in situations where a user cookie was specified,\n+ // but it was invalid. In those situations setting\n+ // $cookie_sent_from_client to false isn't quite correct, but it doesn't\n+ // matter since in all those situations $inbound_cookie_invalidated gets\n+ // set to true anyways, and $cookie_sent_from_client is thus irrelevant.\n$cookie_sent_from_client = false;\n}\nreturn array(null, null);\n}\n// We already have a cookie! Let's look up the session\n- list($cookie_id, $cookie_password) = explode(':', $_COOKIE['anonymous']);\n+ list($cookie_id, $cookie_password) = explode(':', $anonymous_cookie);\n$cookie_id = intval($cookie_id);\n$result = $conn->query(\n\"SELECT last_update, hash FROM cookies \".\n"
},
{
"change_type": "MODIFY",
"old_path": "web/script.js",
"new_path": "web/script.js",
"diff": "@@ -55,7 +55,7 @@ registerConfig({\nresolveInvalidatedCookie: null,\n// We use httponly cookies on web to protect against XSS attacks, so we have\n// no access to the cookies from JavaScript\n- getNativeCookie: null,\n+ getNewCookie: null,\n// Never reset the calendar range\ncalendarRangeInactivityLimit: null,\n});\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Uhh... cookies stopped working in React Native 0.44.0 on iOS, so I'm just gonna like pass the cookie values directly
It's not like SSL/TLS works better on the Cookie header than on the contents anyways
On web we won't do this though so we can keep our cookies httponly |
129,187 | 04.05.2017 17:06:22 | 14,400 | 77851ec5e8431a42a154436e8d5e6acac2eaa15d | Native package updates | [
{
"change_type": "MODIFY",
"old_path": "native/package.json",
"new_path": "native/package.json",
"diff": "\"react-native-cookies\": \"^3.0.0\",\n\"react-native-keychain\": \"^1.2.0\",\n\"react-native-onepassword\": \"^1.0.4\",\n- \"react-native-vector-icons\": \"^4.0.1\",\n+ \"react-native-vector-icons\": \"^4.1.0\",\n\"react-navigation\": \"^1.0.0-beta.9\",\n\"react-redux\": \"^5.0.4\",\n\"redux\": \"^3.6.0\",\n- \"redux-persist\": \"^4.6.0\",\n+ \"redux-persist\": \"^4.7.1\",\n\"redux-thunk\": \"^2.2.0\",\n\"reselect\": \"^3.0.0\",\n\"url-parse\": \"^1.1.8\"\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Native package updates |
129,187 | 04.05.2017 17:51:02 | 14,400 | 25d2a6c66aa846614ddf1f48f07499717283d04a | Working really early calendar implementation | [
{
"change_type": "MODIFY",
"old_path": "lib/utils/date-utils.js",
"new_path": "lib/utils/date-utils.js",
"diff": "@@ -63,6 +63,10 @@ function fifteenDaysLater() {\nreturn dateString(fifteenDaysLater);\n}\n+function prettyDate(dayString: string): string {\n+ return dateFormat(dateFromString(dayString), \"dddd, mmmm dS, yyyy\");\n+}\n+\nfunction dateFromString(dayString: string): Date {\nconst matches = dayString.match(/^([0-9]{4})-([0-1][0-9])-([0-3][0-9])$/);\ninvariant(matches && matches.length === 4, `invalid dayString ${dayString}`);\n@@ -81,5 +85,6 @@ export {\nendDateForYearAndMonth,\nfifteenDaysEarlier,\nfifteenDaysLater,\n+ prettyDate,\ndateFromString,\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "native/calendar/calendar.react.js",
"new_path": "native/calendar/calendar.react.js",
"diff": "// @flow\n+import type { EntryInfo } from 'lib/types/entry-types';\n+import { entryInfoPropType } from 'lib/types/entry-types';\n+import type { AppState } from '../redux-setup';\n+import type { CalendarItem } from '../selectors/entry-selectors';\n+\nimport React from 'react';\n-import { View, StyleSheet, Text } from 'react-native';\n+import { View, StyleSheet, Text, SectionList } from 'react-native';\nimport Icon from 'react-native-vector-icons/FontAwesome';\n+import { connect } from 'react-redux';\n+import PropTypes from 'prop-types';\n+import invariant from 'invariant';\n-import * as TypeaheadText from 'lib/shared/typeahead-text.js';\n+import { entryKey } from 'lib/shared/entry-utils';\n+import { prettyDate } from 'lib/utils/date-utils';\n-type Props = {\n-};\n-type State = {\n-};\n+import Entry from './entry.react';\n+import { contentVerticalOffset } from '../dimensions';\n+import { calendarSectionListData } from '../selectors/entry-selectors';\nclass Calendar extends React.PureComponent {\n- props: Props;\n- state: State;\n+ props: {\n+ sectionListData: { data: CalendarItem[], key: string }[],\n+ };\n+ state: {};\n+ static propTypes = {\n+ sectionListData: PropTypes.arrayOf(PropTypes.shape({\n+ data: PropTypes.arrayOf(PropTypes.shape({\n+ entryInfo: entryInfoPropType,\n+ footerForDateString: PropTypes.string,\n+ })).isRequired,\n+ key: PropTypes.string.isRequired,\n+ })).isRequired,\n+ };\nstatic navigationOptions = {\ntabBarLabel: 'Calendar',\n@@ -26,25 +45,59 @@ class Calendar extends React.PureComponent {\n),\n};\n- constructor(props: Props) {\n- super(props);\n- this.state = {\n- };\n+ renderItem = (row) => {\n+ if (row.item.entryInfo) {\n+ return <Entry entryInfo={row.item.entryInfo} />;\n+ } else {\n+ return this.renderSectionFooter(row);\n+ }\n}\n- render() {\n+ renderSectionHeader = (row) => {\n+ invariant(row.section.key, \"should be set\");\nreturn (\n- <View style={styles.container}>\n- <Text style={styles.welcome}>\n- {`Welcome to ${TypeaheadText.homeText}`}\n+ <View style={styles.sectionHeader}>\n+ <Text style={styles.sectionHeaderText}>\n+ {prettyDate(row.section.key)}\n</Text>\n- <Text style={styles.instructions}>\n- To get started, edit index.ios.js\n+ </View>\n+ );\n+ }\n+\n+ renderSectionFooter = (row) => {\n+ // Eventually we will pass this function directly into SectionList, but\n+ // that functionality is only in RN master as of this time, and also there\n+ // is an issue (RN#13784) where empty sections don't render a footer.\n+ return (\n+ <View style={styles.sectionFooter}>\n+ <Text style={styles.sectionHeaderText}>\n+ test\n</Text>\n</View>\n);\n}\n+ keyExtractor = (item: CalendarItem) => {\n+ if (item.entryInfo) {\n+ return entryKey(item.entryInfo);\n+ } else {\n+ invariant(item.footerForDateString, \"should be set\");\n+ return item.footerForDateString + \"/footer\";\n+ }\n+ };\n+\n+ render() {\n+ return (\n+ <SectionList\n+ sections={this.props.sectionListData}\n+ renderItem={this.renderItem}\n+ renderSectionHeader={this.renderSectionHeader}\n+ keyExtractor={this.keyExtractor}\n+ style={styles.container}\n+ />\n+ );\n+ }\n+\n}\nconst styles = StyleSheet.create({\n@@ -53,20 +106,35 @@ const styles = StyleSheet.create({\n},\ncontainer: {\nflex: 1,\n- justifyContent: 'center',\n- alignItems: 'center',\nbackgroundColor: '#F5FCFF',\n+ marginTop: contentVerticalOffset,\n+ },\n+ sectionHeader: {\n+ marginTop: 5,\n+ marginLeft: 2,\n+ marginRight: 2,\n+ padding: 5,\n+ borderTopLeftRadius: 8,\n+ borderTopRightRadius: 8,\n+ backgroundColor: '#DDDDDD',\n},\n- welcome: {\n- fontSize: 20,\n- textAlign: 'center',\n- margin: 10,\n+ sectionHeaderText: {\n+ fontWeight: 'bold',\n},\n- instructions: {\n- textAlign: 'center',\n- color: '#333333',\n+ sectionFooter: {\nmarginBottom: 5,\n+ marginLeft: 2,\n+ marginRight: 2,\n+ padding: 5,\n+ borderBottomLeftRadius: 8,\n+ borderBottomRightRadius: 8,\n+ backgroundColor: '#DDDDDD',\n},\n});\n-export default Calendar;\n+export default connect(\n+ (state: AppState) => ({\n+ entryInfos: state.entryInfos,\n+ sectionListData: calendarSectionListData(state),\n+ }),\n+)(Calendar);\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/calendar/entry.react.js",
"diff": "+// @flow\n+\n+import type { EntryInfo } from 'lib/types/entry-types';\n+import { entryInfoPropType } from 'lib/types/entry-types';\n+import type { CalendarInfo } from 'lib/types/calendar-types';\n+import { calendarInfoPropType } from 'lib/types/calendar-types';\n+import type { AppState } from '../redux-setup';\n+\n+import React from 'react';\n+import { View, Text, StyleSheet } from 'react-native';\n+import { connect } from 'react-redux';\n+\n+import { colorIsDark } from 'lib/selectors/calendar-selectors';\n+\n+class Entry extends React.PureComponent {\n+\n+ props: {\n+ entryInfo: EntryInfo,\n+ calendarInfo: CalendarInfo,\n+ };\n+ static propTypes = {\n+ entryInfo: entryInfoPropType,\n+ calendarInfo: calendarInfoPropType,\n+ };\n+\n+ render() {\n+ const textStyle = {\n+ backgroundColor: `#${this.props.calendarInfo.color}`,\n+ color: colorIsDark(this.props.calendarInfo.color) ? 'white' : 'black',\n+ };\n+ return (\n+ <View style={styles.container}>\n+ <View style={styles.entry}>\n+ <Text style={[styles.text, textStyle]}>\n+ {this.props.entryInfo.text}\n+ </Text>\n+ </View>\n+ </View>\n+ );\n+ }\n+\n+}\n+\n+const styles = StyleSheet.create({\n+ container: {\n+ marginLeft: 2,\n+ marginRight: 2,\n+ backgroundColor: '#DDDDDD',\n+ },\n+ entry: {\n+ borderRadius: 8,\n+ margin: 5,\n+ overflow: 'hidden',\n+ },\n+ text: {\n+ padding: 5,\n+ color: '#333333',\n+ },\n+});\n+\n+export default connect(\n+ (state: AppState, ownProps: { entryInfo: EntryInfo }) => ({\n+ calendarInfo: state.calendarInfos[ownProps.entryInfo.calendarID],\n+ }),\n+)(Entry);\n"
},
{
"change_type": "MODIFY",
"old_path": "native/dimensions.js",
"new_path": "native/dimensions.js",
"diff": "@@ -10,7 +10,10 @@ if (Platform.OS === \"android\") {\nconst windowHeight = height;\nconst windowWidth = width;\n+const contentVerticalOffset = Platform.OS === \"ios\" ? 20 : 0;\n+\nexport {\nwindowHeight,\nwindowWidth,\n+ contentVerticalOffset,\n};\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/selectors/entry-selectors.js",
"diff": "+// @flow\n+\n+import type { EntryInfo } from 'lib/types/entry-types';\n+\n+import { currentDaysToEntries } from 'lib/selectors/calendar-selectors';\n+\n+import { createSelector } from 'reselect';\n+import _map from 'lodash/fp/map';\n+const _mapWithKeys = _map.convert({ cap: false });\n+\n+export type CalendarItem = {\n+ entryInfo?: EntryInfo,\n+ footerForDateString?: string,\n+};\n+\n+const calendarSectionListData = createSelector(\n+ currentDaysToEntries,\n+ (daysToEntries: {[dayString: string]: EntryInfo[]}) => _mapWithKeys(\n+ (entryInfos: EntryInfo[], dateString: string) => ({\n+ data: ([\n+ ..._map((entryInfo: EntryInfo) => ({ entryInfo }))(entryInfos),\n+ { footerForDateString: dateString },\n+ ]: CalendarItem[]),\n+ key: dateString,\n+ }),\n+ )(daysToEntries),\n+);\n+\n+export {\n+ calendarSectionListData,\n+};\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Working really early calendar implementation |
129,187 | 04.05.2017 18:39:20 | 14,400 | 828b1ea49b92ef95470403df2d6b56eb5e9681be | Committing this design for now but gonna revise | [
{
"change_type": "MODIFY",
"old_path": "native/calendar/calendar.react.js",
"new_path": "native/calendar/calendar.react.js",
"diff": "@@ -57,10 +57,12 @@ class Calendar extends React.PureComponent {\ninvariant(row.section.key, \"should be set\");\nreturn (\n<View style={styles.sectionHeader}>\n+ <View>\n<Text style={styles.sectionHeaderText}>\n{prettyDate(row.section.key)}\n</Text>\n</View>\n+ </View>\n);\n}\n@@ -70,9 +72,8 @@ class Calendar extends React.PureComponent {\n// is an issue (RN#13784) where empty sections don't render a footer.\nreturn (\n<View style={styles.sectionFooter}>\n- <Text style={styles.sectionHeaderText}>\n- test\n- </Text>\n+ <View>\n+ </View>\n</View>\n);\n}\n@@ -106,29 +107,38 @@ const styles = StyleSheet.create({\n},\ncontainer: {\nflex: 1,\n- backgroundColor: '#F5FCFF',\n+ backgroundColor: '#EEEEEE',\nmarginTop: contentVerticalOffset,\n},\nsectionHeader: {\nmarginTop: 5,\n- marginLeft: 2,\n- marginRight: 2,\n+ marginLeft: 5,\n+ marginRight: 5,\npadding: 5,\n- borderTopLeftRadius: 8,\n- borderTopRightRadius: 8,\n- backgroundColor: '#DDDDDD',\n+ backgroundColor: '#FFFFFF',\n+ borderLeftWidth: 2,\n+ borderRightWidth: 2,\n+ borderTopWidth: 2,\n+ borderColor: '#DDDDDD',\n+ borderTopLeftRadius: 4,\n+ borderTopRightRadius: 4,\n},\nsectionHeaderText: {\nfontWeight: 'bold',\n+ color: '#555555',\n},\nsectionFooter: {\nmarginBottom: 5,\n- marginLeft: 2,\n- marginRight: 2,\n+ marginLeft: 5,\n+ marginRight: 5,\npadding: 5,\n- borderBottomLeftRadius: 8,\n- borderBottomRightRadius: 8,\n- backgroundColor: '#DDDDDD',\n+ backgroundColor: '#FFFFFF',\n+ borderLeftWidth: 2,\n+ borderRightWidth: 2,\n+ borderBottomWidth: 2,\n+ borderColor: '#DDDDDD',\n+ borderBottomLeftRadius: 4,\n+ borderBottomRightRadius: 4,\n},\n});\n"
},
{
"change_type": "MODIFY",
"old_path": "native/calendar/entry.react.js",
"new_path": "native/calendar/entry.react.js",
"diff": "@@ -24,13 +24,15 @@ class Entry extends React.PureComponent {\n};\nrender() {\n- const textStyle = {\n+ const entryStyle = {\nbackgroundColor: `#${this.props.calendarInfo.color}`,\n+ };\n+ const textStyle = {\ncolor: colorIsDark(this.props.calendarInfo.color) ? 'white' : 'black',\n};\nreturn (\n<View style={styles.container}>\n- <View style={styles.entry}>\n+ <View style={[styles.entry, entryStyle]}>\n<Text style={[styles.text, textStyle]}>\n{this.props.entryInfo.text}\n</Text>\n@@ -43,9 +45,12 @@ class Entry extends React.PureComponent {\nconst styles = StyleSheet.create({\ncontainer: {\n- marginLeft: 2,\n- marginRight: 2,\n- backgroundColor: '#DDDDDD',\n+ marginLeft: 5,\n+ marginRight: 5,\n+ borderLeftWidth: 2,\n+ borderRightWidth: 2,\n+ borderColor: '#DDDDDD',\n+ backgroundColor: '#FFFFFF',\n},\nentry: {\nborderRadius: 8,\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Committing this design for now but gonna revise |
129,187 | 10.05.2017 00:40:28 | 14,400 | 6e4e72e0595ceaba1f1bfbc7b54701f7f43222cf | New react-native-vector-icons to get rid of warnings | [
{
"change_type": "MODIFY",
"old_path": "native/package.json",
"new_path": "native/package.json",
"diff": "\"react-native-cookies\": \"^3.0.0\",\n\"react-native-keychain\": \"^1.2.0\",\n\"react-native-onepassword\": \"^1.0.4\",\n- \"react-native-vector-icons\": \"^4.1.0\",\n+ \"react-native-vector-icons\": \"^4.1.1\",\n\"react-navigation\": \"^1.0.0-beta.9\",\n\"react-redux\": \"^5.0.4\",\n\"redux\": \"^3.6.0\",\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | New react-native-vector-icons to get rid of warnings |
129,187 | 10.05.2017 00:40:56 | 14,400 | 77489bfe35e886fb2750e13431d3b00c6534fff0 | This commit switches to using RN master so I can have access to FlatList.scrollToLocation | [
{
"change_type": "MODIFY",
"old_path": "native/.flowconfig",
"new_path": "native/.flowconfig",
"diff": "@@ -47,4 +47,4 @@ suppress_comment=\\\\(.\\\\|\\n\\\\)*\\\\$FlowExpectedError\nunsafe.enable_getters_and_setters=true\n[version]\n-^0.42.0\n+^0.45.0\n"
},
{
"change_type": "MODIFY",
"old_path": "native/package.json",
"new_path": "native/package.json",
"diff": "},\n\"dependencies\": {\n\"invariant\": \"^2.2.2\",\n- \"react\": \"^16.0.0-alpha.6\",\n- \"react-native\": \"^0.44.0\",\n+ \"react\": \"^16.0.0-alpha.12\",\n+ \"react-native\": \"git+https://github.com/facebook/react-native.git\",\n\"react-native-cookies\": \"^3.0.0\",\n\"react-native-keychain\": \"^1.2.0\",\n\"react-native-onepassword\": \"^1.0.4\",\n\"babel-jest\": \"19.0.0\",\n\"babel-plugin-transform-remove-console\": \"^6.8.1\",\n\"babel-preset-react-native\": \"1.9.1\",\n- \"flow-bin\": \"^0.42.0\",\n+ \"flow-bin\": \"^0.45.0\",\n\"jest\": \"^19.0.2\",\n\"react-devtools\": \"^2.0.12\",\n\"react-test-renderer\": \"^15.5.4\",\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | This commit switches to using RN master so I can have access to FlatList.scrollToLocation |
129,187 | 11.05.2017 01:08:04 | 14,400 | ce19320bf55feedf453002ceef1812f97e5bfc50 | A bunch of improvements to calendar, mostly trying to get it to load at the center | [
{
"change_type": "MODIFY",
"old_path": "lib/selectors/session-selectors.js",
"new_path": "lib/selectors/session-selectors.js",
"diff": "@@ -76,6 +76,7 @@ const sessionStartingPayload = createSelector(\n);\nexport {\n+ sessionExpired,\nnewSessionID,\nsessionInactivityLimit,\ncurrentSessionID,\n"
},
{
"change_type": "MODIFY",
"old_path": "native/calendar/calendar.react.js",
"new_path": "native/calendar/calendar.react.js",
"diff": "@@ -7,7 +7,13 @@ import type { CalendarItem } from '../selectors/entry-selectors';\nimport type { SectionBase } from '../react-native-types';\nimport React from 'react';\n-import { View, StyleSheet, Text, SectionList } from 'react-native';\n+import {\n+ View,\n+ StyleSheet,\n+ Text,\n+ SectionList,\n+ AppState as NativeAppState,\n+} from 'react-native';\nimport Icon from 'react-native-vector-icons/FontAwesome';\nimport { connect } from 'react-redux';\nimport PropTypes from 'prop-types';\n@@ -18,6 +24,7 @@ import _map from 'lodash/fp/map';\nimport { entryKey } from 'lib/shared/entry-utils';\nimport { dateString, prettyDate } from 'lib/utils/date-utils';\n+import { sessionExpired } from 'lib/selectors/session-selectors';\nimport Entry from './entry.react';\nimport { contentVerticalOffset } from '../dimensions';\n@@ -36,6 +43,8 @@ type SectionWithHeights = SectionBase<CalendarItemWithHeight>;\ntype Props = {\nsectionListData: $ReadOnlyArray<Section>,\ntabActive: bool,\n+ sessionID: string,\n+ sessionExpired: () => bool,\n};\nclass InnerCalendar extends React.PureComponent {\n@@ -43,6 +52,7 @@ class InnerCalendar extends React.PureComponent {\nstate: {\ntextToMeasure: string[],\nsectionListDataWithHeights: ?$ReadOnlyArray<SectionWithHeights>,\n+ readyToShowSectionList: bool,\n};\nstatic propTypes = {\nsectionListData: PropTypes.arrayOf(PropTypes.shape({\n@@ -53,6 +63,8 @@ class InnerCalendar extends React.PureComponent {\nkey: PropTypes.string.isRequired,\n})).isRequired,\ntabActive: PropTypes.bool.isRequired,\n+ sessionID: PropTypes.string.isRequired,\n+ sessionExpired: PropTypes.func.isRequired,\n};\nstatic navigationOptions = {\ntabBarLabel: 'Calendar',\n@@ -66,6 +78,8 @@ class InnerCalendar extends React.PureComponent {\ntextHeightMeasurer: ?TextHeightMeasurer = null;\nsectionList: ?SectionList<SectionWithHeights> = null;\ntextHeights: ?{ [text: string]: number } = null;\n+ currentState: ?string = NativeAppState.currentState;\n+ queuedScrollToToday = true;\nconstructor(props: Props) {\nsuper(props);\n@@ -75,6 +89,7 @@ class InnerCalendar extends React.PureComponent {\nthis.state = {\ntextToMeasure,\nsectionListDataWithHeights: null,\n+ readyToShowSectionList: false,\n};\n}\n@@ -92,23 +107,64 @@ class InnerCalendar extends React.PureComponent {\nreturn textToMeasure;\n}\n+ componentDidMount() {\n+ NativeAppState.addEventListener('change', this.handleAppStateChange);\n+ }\n+\n+ componentWillUnmount() {\n+ NativeAppState.removeEventListener('change', this.handleAppStateChange);\n+ }\n+\n+ handleAppStateChange = (nextAppState: ?string) => {\n+ // If upon foregrounding we find the session expired we scroll to today\n+ const lastState = this.currentState;\n+ this.currentState = nextAppState;\n+ if (\n+ lastState &&\n+ lastState.match(/inactive|background/) &&\n+ this.currentState === \"active\" &&\n+ this.props.sessionExpired() &&\n+ this.sectionList\n+ ) {\n+ this.scrollToToday();\n+ }\n+ }\n+\ncomponentWillReceiveProps(newProps: Props) {\n- //if (this.props.tabActive && !newProps.tabActive && this.sectionList) {\n- // this.scrollToToday();\n- //}\n+ // If the sessionID gets reset and the user isn't looking we scroll to today\n+ if (\n+ newProps.sessionID !== this.props.sessionID &&\n+ !newProps.tabActive &&\n+ this.sectionList\n+ ) {\n+ this.scrollToToday(false);\n+ }\n+ // When the sectionListData changes we may need to recalculate some heights\nif (newProps.sectionListData !== this.props.sectionListData) {\n+ // If we had no entries and just got some we'll scroll to today\n+ if (!this.queuedScrollToToday) {\n+ this.queuedScrollToToday = this.state.textToMeasure.length === 0;\n+ }\nconst newTextToMeasure = InnerCalendar.textToMeasureFromSectionListData(\nnewProps.sectionListData,\n);\nif (!_isEqual(this.state.textToMeasure)(newTextToMeasure)) {\n+ // In this case, we have new text and need to measure its height\n+ this.textHeights = null;\nthis.setState({ textToMeasure: newTextToMeasure });\n- } else {\n+ } else if (this.textHeights) {\n+ // In this case, we already have the height of all the text\nthis.mergeHeightsIntoSectionListData(newProps.sectionListData);\n+ } else {\n+ // In this case, the text is unchanged but we don't have its height yet\n+ // We don't do anything since we're still waiting on the text\n}\n}\n}\n- mergeHeightsIntoSectionListData(sectionListData: $ReadOnlyArray<Section>) {\n+ mergeHeightsIntoSectionListData(\n+ sectionListData: $ReadOnlyArray<Section>\n+ ) {\nconst sectionListDataWithHeights = _map((section: Section) => ({\n...section,\ndata: _map((calendarItem: CalendarItem) => {\n@@ -135,15 +191,31 @@ class InnerCalendar extends React.PureComponent {\nthis.setState({ sectionListDataWithHeights });\n}\n- scrollToToday() {\n+ scrollToToday = (animated: ?bool = undefined) => {\n+ if (animated === undefined) {\n+ animated = this.props.tabActive;\n+ }\n+ invariant(this.state.sectionListDataWithHeights, \"should be set\");\nconst todayIndex = _findIndex(['key', dateString(new Date())])\n- (this.props.sectionListData);\n- invariant(this.sectionList, \"sectionList should be set\");\n- this.sectionList.scrollToLocation({\n+ (this.state.sectionListDataWithHeights);\n+ const sectionList = this.sectionList;\n+ invariant(sectionList, \"sectionList should be set\");\n+ setTimeout(\n+ () => {\n+ sectionList.scrollToLocation({\nsectionIndex: todayIndex,\nitemIndex: 0,\n+ animated,\nviewPosition: 0.5,\n+ viewOffset: 29,\n});\n+ setTimeout(\n+ () => this.setState({ readyToShowSectionList: true }),\n+ 50,\n+ );\n+ },\n+ 550,\n+ );\n}\nrenderItem = (row) => {\n@@ -190,8 +262,8 @@ class InnerCalendar extends React.PureComponent {\n);\n}\n- onAdd = (dateString: string) => {\n- console.log(dateString);\n+ onAdd = (dayString: string) => {\n+ console.log(dayString);\n}\nstatic keyExtractor = (item: CalendarItem) => {\n@@ -250,16 +322,21 @@ class InnerCalendar extends React.PureComponent {\n}\nrender() {\n+ const sectionListDataWithHeights = this.state.sectionListDataWithHeights;\nlet sectionList = null;\n- if (this.state.sectionListDataWithHeights) {\n+ if (sectionListDataWithHeights) {\n+ const sectionListStyle = {\n+ opacity: this.state.readyToShowSectionList ? 1 : 0,\n+ };\nsectionList = (\n<SectionList\n- sections={this.state.sectionListDataWithHeights}\n+ sections={sectionListDataWithHeights}\nrenderItem={this.renderItem}\nrenderSectionHeader={InnerCalendar.renderSectionHeader}\nkeyExtractor={InnerCalendar.keyExtractor}\ngetItemLayout={InnerCalendar.getItemLayout}\n- style={styles.sectionList}\n+ style={[styles.sectionList, sectionListStyle]}\n+ onLayout={this.onSectionListLayout}\nref={this.sectionListRef}\n/>\n);\n@@ -285,7 +362,23 @@ class InnerCalendar extends React.PureComponent {\nthis.sectionList = sectionList;\n}\n- allHeightsMeasured = (newTextHeights: { [text: string]: number }) => {\n+ onSectionListLayout = (event: SyntheticEvent) => {\n+ invariant(this.sectionList, \"should be set\");\n+ if (this.queuedScrollToToday) {\n+ this.scrollToToday(false);\n+ this.queuedScrollToToday = false;\n+ } else {\n+ this.setState({ readyToShowSectionList: true });\n+ }\n+ }\n+\n+ allHeightsMeasured = (\n+ textToMeasure: string[],\n+ newTextHeights: { [text: string]: number },\n+ ) => {\n+ if (textToMeasure !== this.state.textToMeasure) {\n+ return;\n+ }\nthis.textHeights = newTextHeights;\nthis.mergeHeightsIntoSectionListData(this.props.sectionListData);\n}\n@@ -355,6 +448,8 @@ const Calendar = connect(\n(state: AppState) => ({\nsectionListData: calendarSectionListData(state),\ntabActive: activeTabSelector(state),\n+ sessionID: state.sessionID,\n+ sessionExpired: sessionExpired(state),\n}),\n)(InnerCalendar);\n"
},
{
"change_type": "MODIFY",
"old_path": "native/navigation-setup.js",
"new_path": "native/navigation-setup.js",
"diff": "@@ -138,7 +138,7 @@ const defaultNavigationState = {\nrouteName: AppRouteName,\nindex: 0,\nroutes: [\n- { key: 'Calendar', routeName: 'Calendar' },\n+ { key: 'Calendar', routeName: CalendarRouteName },\n{ key: 'Chat', routeName: 'Chat' },\n{ key: 'More', routeName: 'More' },\n],\n"
},
{
"change_type": "MODIFY",
"old_path": "native/text-height-measurer.react.js",
"new_path": "native/text-height-measurer.react.js",
"diff": "@@ -17,7 +17,10 @@ const measureBatchSize = 10;\ntype TextToHeight = { [text: string]: number };\ntype Props = {\ntextToMeasure: string[],\n- allHeightsMeasuredCallback: (heights: TextToHeight) => void,\n+ allHeightsMeasuredCallback: (\n+ textToMeasure: string[],\n+ heights: TextToHeight,\n+ ) => void,\nstyle: StyleObj,\n};\ntype State = {\n@@ -45,6 +48,10 @@ class TextHeightMeasurer extends React.PureComponent {\nthis.resetInternalState(this.props.textToMeasure);\n}\n+ componentDidMount() {\n+ this.newBatch();\n+ }\n+\ncomponentWillReceiveProps(nextProps: Props) {\nif (nextProps.textToMeasure === this.props.textToMeasure) {\nreturn;\n@@ -83,7 +90,10 @@ class TextHeightMeasurer extends React.PureComponent {\ninvariant(this.nextTextToHeight, \"nextTextToHeight should be set\");\nthis.currentTextToHeight = this.nextTextToHeight;\nthis.nextTextToHeight = null;\n- this.props.allHeightsMeasuredCallback(this.currentTextToHeight);\n+ this.props.allHeightsMeasuredCallback(\n+ this.props.textToMeasure,\n+ this.currentTextToHeight,\n+ );\nthis.setState({ currentlyMeasuring: null });\n} else if (this.leftInBatch === 0) {\nthis.newBatch();\n@@ -104,12 +114,13 @@ class TextHeightMeasurer extends React.PureComponent {\n}\nrender() {\n- if (_isEmpty(this.state.currentlyMeasuring)) {\n+ const set = this.state.currentlyMeasuring;\n+ if (_isEmpty(set)) {\nreturn null;\n}\n- const set = this.state.currentlyMeasuring;\ninvariant(set, \"should be set\");\n- const dummies = _map((text: string) => (\n+ const dummies =\n+ _toArray(this.state.currentlyMeasuring).map((text: string) => (\n<Text\nstyle={[styles.text, this.props.style]}\nonLayout={(event) => this.onTextLayout(text, event)}\n@@ -117,15 +128,13 @@ class TextHeightMeasurer extends React.PureComponent {\n>\n{text}\n</Text>\n- ))(_toArray(this.state.currentlyMeasuring));\n- return <View style={styles.container}>{dummies}</View>;\n+ ));\n+ return <View>{dummies}</View>;\n}\n}\nconst styles = StyleSheet.create({\n- container: {\n- },\ntext: {\nopacity: 0,\nposition: 'absolute',\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | A bunch of improvements to calendar, mostly trying to get it to load at the center |
129,187 | 11.05.2017 17:40:21 | 14,400 | dd77cb5a623d1ca27d24c9bc5ed75b72128ff6ba | Upgrade to react-native 0.45.0-rc0 | [
{
"change_type": "MODIFY",
"old_path": "native/package.json",
"new_path": "native/package.json",
"diff": "\"dependencies\": {\n\"invariant\": \"^2.2.2\",\n\"react\": \"^16.0.0-alpha.12\",\n- \"react-native\": \"git+https://github.com/facebook/react-native.git\",\n+ \"react-native\": \"^0.45.0-rc.0\",\n\"react-native-cookies\": \"^3.0.0\",\n\"react-native-keychain\": \"^1.2.0\",\n\"react-native-onepassword\": \"^1.0.4\",\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Upgrade to react-native 0.45.0-rc0 |
129,187 | 11.05.2017 17:50:34 | 14,400 | 61a14f91e82f718828e8814a3e486a09911693c4 | Improvements to TextHeightMeasurer, required for Android compatibility | [
{
"change_type": "MODIFY",
"old_path": "native/text-height-measurer.react.js",
"new_path": "native/text-height-measurer.react.js",
"diff": "@@ -9,8 +9,6 @@ import PropTypes from 'prop-types';\nimport { Text, View, StyleSheet } from 'react-native';\nimport invariant from 'invariant';\nimport _isEmpty from 'lodash/fp/isEmpty';\n-import _map from 'lodash/fp/map';\n-import _toArray from 'lodash/fp/toArray';\nconst measureBatchSize = 10;\n@@ -119,8 +117,7 @@ class TextHeightMeasurer extends React.PureComponent {\nreturn null;\n}\ninvariant(set, \"should be set\");\n- const dummies =\n- _toArray(this.state.currentlyMeasuring).map((text: string) => (\n+ const dummies = Array.from(set).map((text: string) => (\n<Text\nstyle={[styles.text, this.props.style]}\nonLayout={(event) => this.onTextLayout(text, event)}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Improvements to TextHeightMeasurer, required for Android compatibility |
129,187 | 12.05.2017 17:24:31 | 14,400 | 6e18e1ff41238954aef56fb1e86a1ff4bac3e9c6 | Working loading indicator for calendar SectionList, and started work on load-on-scroll | [
{
"change_type": "MODIFY",
"old_path": "lib/actions/entry-actions.js",
"new_path": "lib/actions/entry-actions.js",
"diff": "@@ -25,7 +25,8 @@ export type CalendarResult = {\ncalendarQuery: CalendarQuery,\n};\nconst fetchEntriesAndSetRangeActionType = \"FETCH_ENTRIES_AND_SET_RANGE\";\n-async function fetchEntriesAndSetRange(\n+const fetchEntriesAndAppendRangeActionType = \"FETCH_ENTRIES_AND_APPEND_RANGE\";\n+async function fetchEntriesWithRange(\nfetchJSON: FetchJSON,\ncalendarQuery: CalendarQuery,\n): Promise<CalendarResult> {\n@@ -136,7 +137,8 @@ export {\nfetchEntriesActionType,\nfetchEntries,\nfetchEntriesAndSetRangeActionType,\n- fetchEntriesAndSetRange,\n+ fetchEntriesAndAppendRangeActionType,\n+ fetchEntriesWithRange,\ncreateLocalEntryActionType,\ncreateLocalEntry,\nsaveEntryActionType,\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/reducers/entry-reducer.js",
"new_path": "lib/reducers/entry-reducer.js",
"diff": "@@ -122,7 +122,10 @@ function reduceEntryInfos(\n? 0\n: lastUserInteractionCalendar;\nreturn [newEntryInfos, newDaysToEntries, newLastUserInteractionCalendar];\n- } else if (action.type === \"FETCH_ENTRIES_AND_SET_RANGE_SUCCESS\") {\n+ } else if (\n+ action.type === \"FETCH_ENTRIES_AND_SET_RANGE_SUCCESS\" ||\n+ action.type === \"FETCH_ENTRIES_AND_APPEND_RANGE_SUCCESS\"\n+ ) {\nconst [updatedEntryInfos, updatedDaysToEntries] = mergeNewEntryInfos(\nentryInfos,\ndaysToEntries,\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/reducers/nav-reducer.js",
"new_path": "lib/reducers/nav-reducer.js",
"diff": "import type { BaseAction } from '../types/redux-types';\nimport type { BaseNavInfo } from '../types/nav-types';\n+import { dateFromString } from '../utils/date-utils';\n+\nexport default function reduceBaseNavInfo(\nstate: BaseNavInfo,\naction: BaseAction,\n@@ -25,6 +27,23 @@ export default function reduceBaseNavInfo(\nstartDate: action.payload.calendarQuery.startDate,\nendDate: action.payload.calendarQuery.endDate,\n};\n+ } else if (action.type === \"FETCH_ENTRIES_AND_APPEND_RANGE_SUCCESS\") {\n+ const queryStartDate =\n+ dateFromString(action.payload.calendarQuery.startDate);\n+ const reduxStartDate = dateFromString(state.startDate);\n+ const queryEndDate = dateFromString(action.payload.calendarQuery.endDate);\n+ const reduxEndDate = dateFromString(state.endDate);\n+ const startDate = queryStartDate > reduxStartDate\n+ ? state.startDate\n+ : action.payload.calendarQuery.startDate;\n+ const endDate = queryEndDate > reduxEndDate\n+ ? action.payload.calendarQuery.endDate\n+ : state.endDate;\n+ return {\n+ ...state,\n+ startDate,\n+ endDate,\n+ };\n} else if (\naction.type === \"LOG_IN_STARTED\" ||\naction.type === \"RESET_PASSWORD_STARTED\" ||\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/selectors/nav-selectors.js",
"new_path": "lib/selectors/nav-selectors.js",
"diff": "@@ -17,6 +17,18 @@ const subscriptionExists = createSelector(\n_some('subscribed')(calendarInfos),\n);\n+// never returns null; appropriate to use with server APIs\n+const simpleNavID = createSelector(\n+ (state: BaseAppState) => state.navInfo,\n+ (navInfo: BaseNavInfo) => {\n+ if (navInfo.home) {\n+ return \"home\";\n+ }\n+ invariant(navInfo.calendarID, \"either home or calendarID should be set\");\n+ return navInfo.calendarID;\n+ },\n+);\n+\nconst currentNavID = createSelector(\n(state: BaseAppState) => state.navInfo,\n(state: BaseAppState) => state.calendarInfos,\n@@ -106,6 +118,7 @@ const currentCalendarQuery = createSelector(\nexport {\nsubscriptionExists,\n+ simpleNavID,\ncurrentNavID,\ncurrentCalendarQuery,\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/types/redux-types.js",
"new_path": "lib/types/redux-types.js",
"diff": "@@ -338,6 +338,18 @@ export type BaseAction =\n} | {\ntype: \"NEW_SESSION_ID\",\npayload: string,\n+ } | {\n+ type: \"FETCH_ENTRIES_AND_APPEND_RANGE_STARTED\",\n+ loadingInfo: LoadingInfo,\n+ } | {\n+ type: \"FETCH_ENTRIES_AND_APPEND_RANGE_FAILED\",\n+ error: true,\n+ payload: Error,\n+ loadingInfo: LoadingInfo,\n+ } | {\n+ type: \"FETCH_ENTRIES_AND_APPEND_RANGE_SUCCESS\",\n+ payload: CalendarResult,\n+ loadingInfo: LoadingInfo,\n};\ntype ThunkedAction<T: BaseAppState, A> = (dispatch: Dispatch<T, A>) => void;\n"
},
{
"change_type": "MODIFY",
"old_path": "native/calendar/calendar.react.js",
"new_path": "native/calendar/calendar.react.js",
"diff": "@@ -5,6 +5,10 @@ import { entryInfoPropType } from 'lib/types/entry-types';\nimport type { AppState } from '../redux-setup';\nimport type { CalendarItem } from '../selectors/entry-selectors';\nimport type { SectionBase } from '../react-native-types';\n+import type { ViewToken } from 'react-native/Libraries/Lists/ViewabilityHelper';\n+import type { DispatchActionPromise } from 'lib/utils/action-utils';\n+import type { CalendarResult } from 'lib/actions/entry-actions';\n+import type { CalendarQuery } from 'lib/selectors/nav-selectors';\nimport React from 'react';\nimport {\n@@ -13,6 +17,8 @@ import {\nText,\nSectionList,\nAppState as NativeAppState,\n+ Platform,\n+ ActivityIndicator,\n} from 'react-native';\nimport Icon from 'react-native-vector-icons/FontAwesome';\nimport { connect } from 'react-redux';\n@@ -21,10 +27,20 @@ import invariant from 'invariant';\nimport _findIndex from 'lodash/fp/findIndex';\nimport _isEqual from 'lodash/fp/isEqual';\nimport _map from 'lodash/fp/map';\n+import _find from 'lodash/fp/find';\nimport { entryKey } from 'lib/shared/entry-utils';\n-import { dateString, prettyDate } from 'lib/utils/date-utils';\n+import { dateString, prettyDate, dateFromString } from 'lib/utils/date-utils';\nimport { sessionExpired } from 'lib/selectors/session-selectors';\n+import {\n+ fetchEntriesAndAppendRangeActionType,\n+ fetchEntriesWithRange,\n+} from 'lib/actions/entry-actions';\n+import {\n+ includeDispatchActionProps,\n+ bindServerCalls,\n+} from 'lib/utils/action-utils';\n+import { simpleNavID } from 'lib/selectors/nav-selectors';\nimport Entry from './entry.react';\nimport { contentVerticalOffset } from '../dimensions';\n@@ -32,19 +48,34 @@ import { calendarSectionListData } from '../selectors/entry-selectors';\nimport { Button } from '../shared-components';\nimport { createActiveTabSelector } from '../selectors/nav-selectors';\nimport TextHeightMeasurer from '../text-height-measurer.react';\n+import ListLoadingIndicator from './list-loading-indicator.react';\ntype Section = SectionBase<CalendarItem>;\nexport type EntryInfoWithHeight = EntryInfo & { textHeight: number };\n-export type CalendarItemWithHeight = {\n- entryInfo?: EntryInfoWithHeight,\n- footerForDateString?: string,\n+export type CalendarItemWithHeight =\n+ {\n+ itemType: \"entryInfo\",\n+ entryInfo: EntryInfoWithHeight,\n+ } | {\n+ itemType: \"footer\",\n+ dateString: string,\n};\ntype SectionWithHeights = SectionBase<CalendarItemWithHeight>;\ntype Props = {\n+ // Redux state\nsectionListData: $ReadOnlyArray<Section>,\ntabActive: bool,\nsessionID: string,\nsessionExpired: () => bool,\n+ startDate: string,\n+ endDate: string,\n+ simpleNavID: string,\n+ // Redux dispatch functions\n+ dispatchActionPromise: DispatchActionPromise,\n+ // async functions that hit server APIs\n+ fetchEntriesWithRange: (\n+ calendarQuery: CalendarQuery,\n+ ) => Promise<CalendarResult>,\n};\nclass InnerCalendar extends React.PureComponent {\n@@ -53,6 +84,8 @@ class InnerCalendar extends React.PureComponent {\ntextToMeasure: string[],\nsectionListDataWithHeights: ?$ReadOnlyArray<SectionWithHeights>,\nreadyToShowSectionList: bool,\n+ newStartDate: string,\n+ newEndDate: string,\n};\nstatic propTypes = {\nsectionListData: PropTypes.arrayOf(PropTypes.shape({\n@@ -65,6 +98,11 @@ class InnerCalendar extends React.PureComponent {\ntabActive: PropTypes.bool.isRequired,\nsessionID: PropTypes.string.isRequired,\nsessionExpired: PropTypes.func.isRequired,\n+ startDate: PropTypes.string.isRequired,\n+ endDate: PropTypes.string.isRequired,\n+ simpleNavID: PropTypes.string.isRequired,\n+ dispatchActionPromise: PropTypes.func.isRequired,\n+ fetchEntriesWithRange: PropTypes.func.isRequired,\n};\nstatic navigationOptions = {\ntabBarLabel: 'Calendar',\n@@ -90,6 +128,8 @@ class InnerCalendar extends React.PureComponent {\ntextToMeasure,\nsectionListDataWithHeights: null,\nreadyToShowSectionList: false,\n+ newStartDate: this.props.startDate,\n+ newEndDate: this.props.endDate,\n};\n}\n@@ -99,7 +139,7 @@ class InnerCalendar extends React.PureComponent {\nconst textToMeasure = [];\nfor (let section of sectionListData) {\nfor (let item of section.data) {\n- if (item.entryInfo) {\n+ if (item.itemType === \"entryInfo\") {\ntextToMeasure.push(item.entryInfo.text);\n}\n}\n@@ -160,6 +200,12 @@ class InnerCalendar extends React.PureComponent {\n// We don't do anything since we're still waiting on the text\n}\n}\n+ if (newProps.startDate !== this.state.newStartDate) {\n+ this.setState({ newStartDate: newProps.startDate });\n+ }\n+ if (newProps.endDate !== this.state.newEndDate) {\n+ this.setState({ newEndDate: newProps.endDate });\n+ }\n}\nmergeHeightsIntoSectionListData(\n@@ -168,11 +214,10 @@ class InnerCalendar extends React.PureComponent {\nconst sectionListDataWithHeights = _map((section: Section) => ({\n...section,\ndata: _map((calendarItem: CalendarItem) => {\n- if (calendarItem.footerForDateString) {\n+ if (calendarItem.itemType === \"footer\") {\nreturn calendarItem;\n}\nconst entryInfo = calendarItem.entryInfo;\n- invariant(entryInfo, \"entryInfo should be set\");\ninvariant(this.textHeights, \"textHeights should be set\");\nconst textHeight = this.textHeights[entryInfo.text];\ninvariant(\n@@ -198,24 +243,15 @@ class InnerCalendar extends React.PureComponent {\ninvariant(this.state.sectionListDataWithHeights, \"should be set\");\nconst todayIndex = _findIndex(['key', dateString(new Date())])\n(this.state.sectionListDataWithHeights);\n- const sectionList = this.sectionList;\n- invariant(sectionList, \"sectionList should be set\");\n- setTimeout(\n- () => {\n- sectionList.scrollToLocation({\n+ invariant(this.sectionList, \"sectionList should be set\");\n+ this.sectionList.scrollToLocation({\nsectionIndex: todayIndex,\nitemIndex: 0,\nanimated,\nviewPosition: 0.5,\n- viewOffset: 29,\n+ viewOffset: Platform.OS === \"ios\" ? 29 : 0,\n});\n- setTimeout(\n- () => this.setState({ readyToShowSectionList: true }),\n- 50,\n- );\n- },\n- 550,\n- );\n+ setTimeout(() => this.setState({ readyToShowSectionList: true }), 50);\n}\nrenderItem = (row) => {\n@@ -266,13 +302,19 @@ class InnerCalendar extends React.PureComponent {\nconsole.log(dayString);\n}\n- static keyExtractor = (item: CalendarItem) => {\n- if (item.entryInfo) {\n+ static keyExtractor = (item: CalendarItemWithHeight | SectionWithHeights) => {\n+ if (item.data) {\n+ invariant(typeof item.key === \"string\", \"key should be string\");\n+ // Something having to do with onViewableItemsChanged calls keyExtractor\n+ // with sections. This condition should only catch sections\n+ return item.key;\n+ } else if (item.itemType === \"entryInfo\") {\n+ invariant(item.entryInfo, 'test');\nreturn entryKey(item.entryInfo);\n- } else {\n- invariant(item.footerForDateString, \"should be set\");\n- return item.footerForDateString + \"/footer\";\n+ } else if (item.itemType === \"footer\") {\n+ return item.dateString + \"/footer\";\n}\n+ invariant(false, \"keyExtractor could not extract key\");\n}\nstatic getItemLayout = (\n@@ -311,13 +353,12 @@ class InnerCalendar extends React.PureComponent {\nreturn 29;\n}\ninvariant(calendarItem, \"should be set\");\n- if (calendarItem.footerForDateString) {\n+ if (calendarItem.itemType === \"footer\") {\n// handle section footer\nreturn 40;\n}\n// handle entry\nconst entryInfo = calendarItem.entryInfo;\n- invariant(entryInfo, \"should be set\");\nreturn 20 + entryInfo.textHeight;\n}\n@@ -328,6 +369,14 @@ class InnerCalendar extends React.PureComponent {\nconst sectionListStyle = {\nopacity: this.state.readyToShowSectionList ? 1 : 0,\n};\n+ const ListHeaderComponent =\n+ this.state.newStartDate === this.props.startDate\n+ ? undefined\n+ : ListLoadingIndicator;\n+ const ListFooterComponent =\n+ this.state.newEndDate === this.props.endDate\n+ ? undefined\n+ : ListLoadingIndicator;\nsectionList = (\n<SectionList\nsections={sectionListDataWithHeights}\n@@ -335,12 +384,28 @@ class InnerCalendar extends React.PureComponent {\nrenderSectionHeader={InnerCalendar.renderSectionHeader}\nkeyExtractor={InnerCalendar.keyExtractor}\ngetItemLayout={InnerCalendar.getItemLayout}\n- style={[styles.sectionList, sectionListStyle]}\nonLayout={this.onSectionListLayout}\n+ initialNumToRender={31}\n+ onViewableItemsChanged={this.onViewableItemsChanged}\n+ ListHeaderComponent={ListHeaderComponent}\n+ ListFooterComponent={ListFooterComponent}\n+ style={[styles.sectionList, sectionListStyle]}\nref={this.sectionListRef}\n/>\n);\n}\n+ let loadingIndicator = null;\n+ if (!sectionListDataWithHeights || !this.state.readyToShowSectionList) {\n+ loadingIndicator = (\n+ <View style={styles.loadingIndicatorContainer}>\n+ <ActivityIndicator\n+ color=\"black\"\n+ size=\"large\"\n+ style={styles.loadingIndicator}\n+ />\n+ </View>\n+ );\n+ }\nreturn (\n<View style={styles.container}>\n<TextHeightMeasurer\n@@ -349,6 +414,7 @@ class InnerCalendar extends React.PureComponent {\nstyle={styles.text}\nref={this.textHeightMeasurerRef}\n/>\n+ {loadingIndicator}\n{sectionList}\n</View>\n);\n@@ -383,6 +449,49 @@ class InnerCalendar extends React.PureComponent {\nthis.mergeHeightsIntoSectionListData(this.props.sectionListData);\n}\n+ onViewableItemsChanged = (info: {\n+ viewableItems: ViewToken[],\n+ changed: ViewToken[],\n+ }) => {\n+ if (!this.state.readyToShowSectionList) {\n+ return;\n+ }\n+ const firstItem =\n+ _find({ key: this.state.newStartDate })(info.viewableItems);\n+ const lastItem = _find({ key: this.state.newEndDate })(info.viewableItems);\n+ let start: ?Date = null;\n+ let end: ?Date = null;\n+ if (firstItem) {\n+ start = dateFromString(this.props.startDate);\n+ start.setDate(start.getDate() - 31);\n+ end = dateFromString(this.props.startDate);\n+ end.setDate(end.getDate() - 1);\n+ } else if (lastItem) {\n+ start = dateFromString(this.props.endDate);\n+ start.setDate(start.getDate() + 1);\n+ end = dateFromString(this.props.endDate);\n+ end.setDate(end.getDate() + 31);\n+ }\n+ if (!start || !end) {\n+ return;\n+ }\n+ const startDate = dateString(start);\n+ const endDate = dateString(end);\n+ if (firstItem) {\n+ this.setState({ newStartDate: startDate });\n+ } else if (lastItem) {\n+ this.setState({ newEndDate: endDate });\n+ }\n+ this.props.dispatchActionPromise(\n+ fetchEntriesAndAppendRangeActionType,\n+ this.props.fetchEntriesWithRange({\n+ navID: this.props.simpleNavID,\n+ startDate,\n+ endDate,\n+ }),\n+ );\n+ }\n+\n}\nconst styles = StyleSheet.create({\n@@ -440,6 +549,16 @@ const styles = StyleSheet.create({\nfontSize: 16,\nfontFamily: 'Arial',\n},\n+ loadingIndicator: {\n+ flex: 1,\n+ },\n+ loadingIndicatorContainer: {\n+ position: 'absolute',\n+ top: 0,\n+ bottom: 0,\n+ left: 0,\n+ right: 0,\n+ },\n});\nconst CalendarRouteName = 'Calendar';\n@@ -450,7 +569,13 @@ const Calendar = connect(\ntabActive: activeTabSelector(state),\nsessionID: state.sessionID,\nsessionExpired: sessionExpired(state),\n+ startDate: state.navInfo.startDate,\n+ endDate: state.navInfo.endDate,\n+ simpleNavID: simpleNavID(state),\n+ cookie: state.cookie,\n}),\n+ includeDispatchActionProps({ dispatchActionPromise: true }),\n+ bindServerCalls({ fetchEntriesWithRange }),\n)(InnerCalendar);\nexport {\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/calendar/list-loading-indicator.react.js",
"diff": "+// @flow\n+\n+import React from 'react';\n+import {\n+ ActivityIndicator,\n+ StyleSheet,\n+} from 'react-native';\n+\n+class ListLoadingIndicator extends React.PureComponent {\n+\n+ render() {\n+ return (\n+ <ActivityIndicator\n+ color=\"black\"\n+ size=\"large\"\n+ style={styles.loadingIndicator}\n+ />\n+ );\n+ }\n+\n+}\n+\n+const styles = StyleSheet.create({\n+ loadingIndicator: {\n+ flex: 1,\n+ backgroundColor: 'white',\n+ padding: 10,\n+ },\n+});\n+\n+export default ListLoadingIndicator;\n"
},
{
"change_type": "MODIFY",
"old_path": "native/selectors/entry-selectors.js",
"new_path": "native/selectors/entry-selectors.js",
"diff": "@@ -8,9 +8,13 @@ import { createSelector } from 'reselect';\nimport _map from 'lodash/fp/map';\nconst _mapWithKeys = _map.convert({ cap: false });\n-export type CalendarItem = {\n- entryInfo?: EntryInfo,\n- footerForDateString?: string,\n+export type CalendarItem =\n+ {\n+ itemType: \"entryInfo\",\n+ entryInfo: EntryInfo,\n+ } | {\n+ itemType: \"footer\",\n+ dateString: string,\n};\nconst calendarSectionListData = createSelector(\n@@ -18,8 +22,10 @@ const calendarSectionListData = createSelector(\n(daysToEntries: {[dayString: string]: EntryInfo[]}) => _mapWithKeys(\n(entryInfos: EntryInfo[], dateString: string) => ({\ndata: ([\n- ..._map((entryInfo: EntryInfo) => ({ entryInfo }))(entryInfos),\n- { footerForDateString: dateString },\n+ ..._map(\n+ (entryInfo: EntryInfo) => ({ itemType: \"entryInfo\", entryInfo }),\n+ )(entryInfos),\n+ { itemType: \"footer\", dateString: dateString },\n]: CalendarItem[]),\nkey: dateString,\n}),\n"
},
{
"change_type": "MODIFY",
"old_path": "native/text-height-measurer.react.js",
"new_path": "native/text-height-measurer.react.js",
"diff": "@@ -41,21 +41,14 @@ class TextHeightMeasurer extends React.PureComponent {\nleftToMeasure: Set<string> = new Set();\nleftInBatch = 0;\n- constructor(props: Props) {\n- super(props);\n- this.resetInternalState(this.props.textToMeasure);\n- }\n-\ncomponentDidMount() {\n- this.newBatch();\n+ this.resetInternalState(this.props.textToMeasure);\n}\ncomponentWillReceiveProps(nextProps: Props) {\n- if (nextProps.textToMeasure === this.props.textToMeasure) {\n- return;\n- }\n+ if (nextProps.textToMeasure !== this.props.textToMeasure) {\nthis.resetInternalState(nextProps.textToMeasure);\n- this.newBatch();\n+ }\n}\n// resets this.leftToMeasure and this.nextTextToHeight\n@@ -72,6 +65,11 @@ class TextHeightMeasurer extends React.PureComponent {\n}\n}\nthis.nextTextToHeight = nextNextTextToHeight;\n+ if (this.leftToMeasure.size === 0) {\n+ this.done(newTextToMeasure);\n+ } else {\n+ this.newBatch();\n+ }\n}\nonTextLayout(\n@@ -83,19 +81,23 @@ class TextHeightMeasurer extends React.PureComponent {\nthis.leftToMeasure.delete(text);\nthis.leftInBatch--;\nif (this.leftToMeasure.size === 0) {\n- // We're done!!\n+ this.done(this.props.textToMeasure);\n+ } else if (this.leftInBatch === 0) {\n+ this.newBatch();\n+ }\n+ }\n+\n+ done(textToMeasure: string[]) {\n+ invariant(this.leftToMeasure.size === 0, \"should be 0 left to measure\");\ninvariant(this.leftInBatch === 0, \"batch should be complete\");\ninvariant(this.nextTextToHeight, \"nextTextToHeight should be set\");\nthis.currentTextToHeight = this.nextTextToHeight;\nthis.nextTextToHeight = null;\nthis.props.allHeightsMeasuredCallback(\n- this.props.textToMeasure,\n+ textToMeasure,\nthis.currentTextToHeight,\n);\nthis.setState({ currentlyMeasuring: null });\n- } else if (this.leftInBatch === 0) {\n- this.newBatch();\n- }\n}\nnewBatch() {\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Working loading indicator for calendar SectionList, and started work on load-on-scroll |
129,187 | 13.05.2017 21:59:22 | 14,400 | 197e43de6324532d7f15cfe63fa71865b4ff11c7 | Latest Calendar SectionList. A little rough around the edges, but the only big problem remaining is scroll position when prepending new sections | [
{
"change_type": "MODIFY",
"old_path": "lib/reducers/entry-reducer.js",
"new_path": "lib/reducers/entry-reducer.js",
"diff": "@@ -19,6 +19,9 @@ import _mapKeys from 'lodash/fp/mapKeys';\nimport _groupBy from 'lodash/fp/groupBy';\nimport _keyBy from 'lodash/fp/keyBy';\nimport _without from 'lodash/fp/without';\n+import _isEqual from 'lodash/fp/isEqual';\n+import _compact from 'lodash/fp/compact';\n+import _isEmpty from 'lodash/fp/isEmpty';\nimport invariant from 'invariant';\nimport { dateString } from '../utils/date-utils';\n@@ -49,21 +52,30 @@ function mergeNewEntryInfos(\noldDaysToEntries: {[id: string]: string[]},\nnewEntryInfos: EntryInfo[],\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.\nconst addedEntryInfos = _flow(\n_map((entryInfo: EntryInfo) => {\ninvariant(entryInfo.id, \"new entryInfos should have serverID\");\nconst currentEntryInfo = oldEntryInfos[entryInfo.id];\nif (currentEntryInfo && currentEntryInfo.localID) {\n- // Setting directly like this is okay because it's a new object\n- // anyways\n- entryInfo.localID = currentEntryInfo.localID;\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.\n+ entryInfo = {\n+ ...entryInfo,\n+ localID: currentEntryInfo.localID,\n+ };\n}\n+ if (_isEqual(entryInfo, currentEntryInfo)) {\n+ return null;\n+ } else {\nreturn entryInfo;\n+ }\n}),\n+ _compact,\n_keyBy('id'),\n)(newEntryInfos);\n+ if (_isEmpty(addedEntryInfos)) {\n+ return [oldEntryInfos, oldDaysToEntries];\n+ }\nconst mergedEntryInfos = { ...oldEntryInfos, ...addedEntryInfos };\nconst addedDaysToEntries = daysToEntriesFromEntryInfos(mergedEntryInfos);\n// This mutates addedDaysToEntries, but it's okay since it's a new object\n"
},
{
"change_type": "MODIFY",
"old_path": "native/calendar/calendar.react.js",
"new_path": "native/calendar/calendar.react.js",
"diff": "@@ -28,6 +28,7 @@ import _findIndex from 'lodash/fp/findIndex';\nimport _isEqual from 'lodash/fp/isEqual';\nimport _map from 'lodash/fp/map';\nimport _find from 'lodash/fp/find';\n+import _difference from 'lodash/fp/difference';\nimport { entryKey } from 'lib/shared/entry-utils';\nimport { dateString, prettyDate, dateFromString } from 'lib/utils/date-utils';\n@@ -45,10 +46,10 @@ import { simpleNavID } from 'lib/selectors/nav-selectors';\nimport Entry from './entry.react';\nimport { contentVerticalOffset } from '../dimensions';\nimport { calendarSectionListData } from '../selectors/entry-selectors';\n-import { Button } from '../shared-components';\nimport { createActiveTabSelector } from '../selectors/nav-selectors';\nimport TextHeightMeasurer from '../text-height-measurer.react';\nimport ListLoadingIndicator from './list-loading-indicator.react';\n+import SectionFooter from './section-footer.react';\ntype Section = SectionBase<CalendarItem>;\nexport type EntryInfoWithHeight = EntryInfo & { textHeight: number };\n@@ -60,10 +61,10 @@ export type CalendarItemWithHeight =\nitemType: \"footer\",\ndateString: string,\n};\n-type SectionWithHeights = SectionBase<CalendarItemWithHeight>;\n+type SectionWithHeights = SectionBase<CalendarItemWithHeight> & { key: string };\ntype Props = {\n// Redux state\n- sectionListData: $ReadOnlyArray<Section>,\n+ sectionListData: ?$ReadOnlyArray<Section>,\ntabActive: bool,\nsessionID: string,\nsessionExpired: () => bool,\n@@ -77,24 +78,24 @@ type Props = {\ncalendarQuery: CalendarQuery,\n) => Promise<CalendarResult>,\n};\n-class InnerCalendar extends React.PureComponent {\n-\n- props: Props;\n- state: {\n+type State = {\ntextToMeasure: string[],\nsectionListDataWithHeights: ?$ReadOnlyArray<SectionWithHeights>,\nreadyToShowSectionList: bool,\n- newStartDate: string,\n- newEndDate: string,\n};\n+class InnerCalendar extends React.PureComponent {\n+\n+ props: Props;\n+ state: State;\nstatic propTypes = {\nsectionListData: PropTypes.arrayOf(PropTypes.shape({\ndata: PropTypes.arrayOf(PropTypes.shape({\n+ itemType: PropTypes.oneOf([\"entryInfo\", \"footer\"]),\nentryInfo: entryInfoPropType,\n- footerForDateString: PropTypes.string,\n+ dateString: PropTypes.string,\n})).isRequired,\nkey: PropTypes.string.isRequired,\n- })).isRequired,\n+ })),\ntabActive: PropTypes.bool.isRequired,\nsessionID: PropTypes.string.isRequired,\nsessionExpired: PropTypes.func.isRequired,\n@@ -117,19 +118,23 @@ class InnerCalendar extends React.PureComponent {\nsectionList: ?SectionList<SectionWithHeights> = null;\ntextHeights: ?{ [text: string]: number } = null;\ncurrentState: ?string = NativeAppState.currentState;\n- queuedScrollToToday = true;\n+ loadingNewEntriesFromScroll = false;\n+ sectionListShrinking = false;\nconstructor(props: Props) {\nsuper(props);\n- const textToMeasure = InnerCalendar.textToMeasureFromSectionListData(\n+ let textToMeasure = null;\n+ if (props.sectionListData) {\n+ textToMeasure = InnerCalendar.textToMeasureFromSectionListData(\nprops.sectionListData,\n);\n+ } else {\n+ textToMeasure = [];\n+ }\nthis.state = {\ntextToMeasure,\nsectionListDataWithHeights: null,\nreadyToShowSectionList: false,\n- newStartDate: this.props.startDate,\n- newEndDate: this.props.endDate,\n};\n}\n@@ -171,40 +176,80 @@ class InnerCalendar extends React.PureComponent {\n}\ncomponentWillReceiveProps(newProps: Props) {\n- // If the sessionID gets reset and the user isn't looking we scroll to today\n- if (\n- newProps.sessionID !== this.props.sessionID &&\n- !newProps.tabActive &&\n- this.sectionList\n- ) {\n- this.scrollToToday(false);\n- }\n// When the sectionListData changes we may need to recalculate some heights\nif (newProps.sectionListData !== this.props.sectionListData) {\n+ const newSectionListData = newProps.sectionListData;\n+ if (!newSectionListData) {\n+ this.setState({\n+ textToMeasure: [],\n+ sectionListDataWithHeights: null,\n+ readyToShowSectionList: false,\n+ });\n+ } else {\n// If we had no entries and just got some we'll scroll to today\n- if (!this.queuedScrollToToday) {\n- this.queuedScrollToToday = this.state.textToMeasure.length === 0;\n- }\nconst newTextToMeasure = InnerCalendar.textToMeasureFromSectionListData(\n- newProps.sectionListData,\n+ newSectionListData,\n);\n- if (!_isEqual(this.state.textToMeasure)(newTextToMeasure)) {\n- // In this case, we have new text and need to measure its height\n+\n+ let allTextAlreadyMeasured = false;\n+ if (this.textHeights) {\n+ allTextAlreadyMeasured = true;\n+ for (let text of newTextToMeasure) {\n+ if (this.textHeights[text] === undefined) {\n+ allTextAlreadyMeasured = false;\n+ break;\n+ }\n+ }\n+ }\n+\n+ if (allTextAlreadyMeasured) {\n+ this.mergeHeightsIntoSectionListData(newSectionListData);\n+ } else {\n+ const newText =\n+ _difference(newTextToMeasure)(this.state.textToMeasure);\n+ if (newText.length === 0) {\n+ // Since we don't have everything in textHeights, but we do have\n+ // everything in textToMeasure, we can conclude that we're just\n+ // waiting for the measurement to complete and then we'll be good.\n+ } else {\n+ // We set textHeights to null here since if a future set of text\n+ // came in before we completed text measurement that was a subset\n+ // of the earlier text, we would end up merging directly there, but\n+ // then when the measurement for the middle text came in it would\n+ // override the newer text heights.\nthis.textHeights = null;\nthis.setState({ textToMeasure: newTextToMeasure });\n- } else if (this.textHeights) {\n- // In this case, we already have the height of all the text\n- this.mergeHeightsIntoSectionListData(newProps.sectionListData);\n- } else {\n- // In this case, the text is unchanged but we don't have its height yet\n- // We don't do anything since we're still waiting on the text\n}\n}\n- if (newProps.startDate !== this.state.newStartDate) {\n- this.setState({ newStartDate: newProps.startDate });\n}\n- if (newProps.endDate !== this.state.newEndDate) {\n- this.setState({ newEndDate: newProps.endDate });\n+ }\n+ }\n+\n+ componentDidUpdate(prevProps: Props, prevState: State) {\n+ // If the sessionID gets reset and the user isn't looking we scroll to today\n+ if (\n+ this.props.sessionID !== prevProps.sessionID &&\n+ !this.props.tabActive &&\n+ this.sectionList\n+ ) {\n+ this.scrollToToday();\n+ }\n+ const lastSLDWH = prevState.sectionListDataWithHeights;\n+ const newSLDWH = this.state.sectionListDataWithHeights;\n+ if (lastSLDWH && newSLDWH) {\n+ if (newSLDWH.length < lastSLDWH.length) {\n+ // If there are fewer sections in our new data, which happens when the\n+ // current calendar query gets reset due to inactivity, let's reset the\n+ // scroll position to the center (today). Once we're done, we can allow\n+ // scrolling logic once again.\n+ setTimeout(() => this.scrollToToday(), 50);\n+ setTimeout(() => this.sectionListShrinking = false, 200);\n+ } else if (newSLDWH.length > lastSLDWH.length) {\n+ // If there are more sections in our new data, that means we just new\n+ // entries that were fetched in response to a scroll load, which means\n+ // we can reenable the scrollers.\n+ this.loadingNewEntriesFromScroll = false;\n+ }\n}\n}\n@@ -233,6 +278,18 @@ class InnerCalendar extends React.PureComponent {\n};\n})(section.data),\n}))(sectionListData);\n+ if (\n+ this.state.sectionListDataWithHeights &&\n+ sectionListDataWithHeights.length <\n+ this.state.sectionListDataWithHeights.length\n+ ) {\n+ // We know that this is going to shrink our SectionList, which may cause\n+ // either of the ListLoadingIndicators to come into view. When our\n+ // SectionList shrinks, componentDidUpdate will trigger scrollToToday (we\n+ // can't do it any earlier because of SectionList weirdness). After that\n+ // happens, we will reset this back.\n+ this.sectionListShrinking = true;\n+ }\nthis.setState({ sectionListDataWithHeights });\n}\n@@ -251,7 +308,6 @@ class InnerCalendar extends React.PureComponent {\nviewPosition: 0.5,\nviewOffset: Platform.OS === \"ios\" ? 29 : 0,\n});\n- setTimeout(() => this.setState({ readyToShowSectionList: true }), 50);\n}\nrenderItem = (row) => {\n@@ -264,6 +320,9 @@ class InnerCalendar extends React.PureComponent {\nstatic renderSectionHeader = (row) => {\ninvariant(row.section.key, \"should be set\");\n+ if (row.section.key === \"TopLoader\" || row.section.key === \"BottomLoader\") {\n+ return <ListLoadingIndicator />;\n+ }\nlet date = prettyDate(row.section.key);\nif (dateString(new Date()) === row.section.key) {\ndate += \" (today)\";\n@@ -282,19 +341,10 @@ class InnerCalendar extends React.PureComponent {\nrenderSectionFooter = (row) => {\n// Eventually we will pass this function directly into SectionList, but\n// that functionality is only in RN master as of this time, and also there\n- // is an issue (RN#13784) where empty sections don't render a footer.\n+ // is an issue (RN#13784) where empty sections don't render a footer. Also,\n+ // scrollToLocation doesn't take the renderSectionFooter prop into account.\nreturn (\n- <View style={styles.sectionFooter}>\n- <Button\n- onSubmit={() => this.onAdd(row.item.footerForDateString)}\n- style={styles.addButton}\n- >\n- <View style={styles.addButtonContents}>\n- <Icon name=\"plus\" style={styles.addIcon} />\n- <Text style={styles.actionLinksText}>Add</Text>\n- </View>\n- </Button>\n- </View>\n+ <SectionFooter dateString={row.item.dateString} onAdd={this.onAdd} />\n);\n}\n@@ -329,6 +379,7 @@ class InnerCalendar extends React.PureComponent {\noffset += InnerCalendar.itemHeight(\ncurItemIndex,\ndata[curSectionIndex].data[curItemIndex],\n+ data[curSectionIndex].key,\n);\ncurItemIndex++;\nif (curItemIndex === data[curSectionIndex].data.length) {\n@@ -339,6 +390,7 @@ class InnerCalendar extends React.PureComponent {\nconst length = InnerCalendar.itemHeight(\ncurItemIndex,\ndata[curSectionIndex].data[curItemIndex],\n+ data[curSectionIndex].key,\n);\nreturn { length, offset, index: flattenedIndex };\n}\n@@ -346,18 +398,24 @@ class InnerCalendar extends React.PureComponent {\nstatic itemHeight(\nitemIndex: number,\ncalendarItem: ?CalendarItemWithHeight,\n+ sectionKey: string,\n): number {\n// TODO test these values on Android\nif (itemIndex === -1) {\n+ if (sectionKey === \"TopLoader\" || sectionKey === \"BottomLoader\") {\n+ // handle ListLoadingIndicator\n+ return 56;\n+ } else {\n// handle section header\nreturn 29;\n}\n+ }\ninvariant(calendarItem, \"should be set\");\nif (calendarItem.itemType === \"footer\") {\n// handle section footer\nreturn 40;\n}\n- // handle entry\n+ // handle Entry\nconst entryInfo = calendarItem.entryInfo;\nreturn 20 + entryInfo.textHeight;\n}\n@@ -369,14 +427,6 @@ class InnerCalendar extends React.PureComponent {\nconst sectionListStyle = {\nopacity: this.state.readyToShowSectionList ? 1 : 0,\n};\n- const ListHeaderComponent =\n- this.state.newStartDate === this.props.startDate\n- ? undefined\n- : ListLoadingIndicator;\n- const ListFooterComponent =\n- this.state.newEndDate === this.props.endDate\n- ? undefined\n- : ListLoadingIndicator;\nsectionList = (\n<SectionList\nsections={sectionListDataWithHeights}\n@@ -387,8 +437,6 @@ class InnerCalendar extends React.PureComponent {\nonLayout={this.onSectionListLayout}\ninitialNumToRender={31}\nonViewableItemsChanged={this.onViewableItemsChanged}\n- ListHeaderComponent={ListHeaderComponent}\n- ListFooterComponent={ListFooterComponent}\nstyle={[styles.sectionList, sectionListStyle]}\nref={this.sectionListRef}\n/>\n@@ -429,13 +477,12 @@ class InnerCalendar extends React.PureComponent {\n}\nonSectionListLayout = (event: SyntheticEvent) => {\n- invariant(this.sectionList, \"should be set\");\n- if (this.queuedScrollToToday) {\n+ // This onLayout call should only trigger when the user logs in or starts\n+ // the app. We wait until now to scroll the calendar SectionList to today\n+ // because SectionList.scrollToLocation has some quirky behavior when you\n+ // call it before layout.\nthis.scrollToToday(false);\n- this.queuedScrollToToday = false;\n- } else {\n- this.setState({ readyToShowSectionList: true });\n- }\n+ setTimeout(() => this.setState({ readyToShowSectionList: true }), 50);\n}\nallHeightsMeasured = (\n@@ -446,19 +493,24 @@ class InnerCalendar extends React.PureComponent {\nreturn;\n}\nthis.textHeights = newTextHeights;\n+ if (this.props.sectionListData) {\nthis.mergeHeightsIntoSectionListData(this.props.sectionListData);\n}\n+ }\nonViewableItemsChanged = (info: {\nviewableItems: ViewToken[],\nchanged: ViewToken[],\n}) => {\n- if (!this.state.readyToShowSectionList) {\n+ if (\n+ !this.state.readyToShowSectionList ||\n+ this.loadingNewEntriesFromScroll ||\n+ this.sectionListShrinking\n+ ) {\nreturn;\n}\n- const firstItem =\n- _find({ key: this.state.newStartDate })(info.viewableItems);\n- const lastItem = _find({ key: this.state.newEndDate })(info.viewableItems);\n+ const firstItem = _find({ key: \"TopLoader\" })(info.viewableItems);\n+ const lastItem = _find({ key: \"BottomLoader\" })(info.viewableItems);\nlet start: ?Date = null;\nlet end: ?Date = null;\nif (firstItem) {\n@@ -471,23 +523,16 @@ class InnerCalendar extends React.PureComponent {\nstart.setDate(start.getDate() + 1);\nend = dateFromString(this.props.endDate);\nend.setDate(end.getDate() + 31);\n- }\n- if (!start || !end) {\n+ } else {\nreturn;\n}\n- const startDate = dateString(start);\n- const endDate = dateString(end);\n- if (firstItem) {\n- this.setState({ newStartDate: startDate });\n- } else if (lastItem) {\n- this.setState({ newEndDate: endDate });\n- }\n+ this.loadingNewEntriesFromScroll = true;\nthis.props.dispatchActionPromise(\nfetchEntriesAndAppendRangeActionType,\nthis.props.fetchEntriesWithRange({\nnavID: this.props.simpleNavID,\n- startDate,\n- endDate,\n+ startDate: dateString(start),\n+ endDate: dateString(end),\n}),\n);\n}\n@@ -516,33 +561,6 @@ const styles = StyleSheet.create({\nfontWeight: 'bold',\ncolor: '#555555',\n},\n- sectionFooter: {\n- backgroundColor: 'white',\n- height: 40,\n- },\n- addButton: {\n- position: 'absolute',\n- backgroundColor: '#EEEEEE',\n- paddingLeft: 10,\n- paddingRight: 10,\n- paddingTop: 5,\n- paddingBottom: 5,\n- borderRadius: 5,\n- margin: 5,\n- },\n- addButtonContents: {\n- flexDirection: 'row',\n- alignItems: 'center',\n- },\n- addIcon: {\n- fontSize: 14,\n- paddingRight: 6,\n- color: '#555555',\n- },\n- actionLinksText: {\n- fontWeight: 'bold',\n- color: '#555555',\n- },\ntext: {\nleft: 15,\nright: 15,\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/calendar/section-footer.react.js",
"diff": "+// @flow\n+\n+import React from 'react';\n+import {\n+ View,\n+ Text,\n+ StyleSheet,\n+} from 'react-native';\n+import Icon from 'react-native-vector-icons/FontAwesome';\n+import PropTypes from 'prop-types';\n+\n+import { Button } from '../shared-components';\n+\n+class SectionFooter extends React.PureComponent {\n+\n+ props: {\n+ dateString: string,\n+ onAdd: (dateString: string) => void,\n+ };\n+ static propTypes = {\n+ dateString: PropTypes.string.isRequired,\n+ onAdd: PropTypes.func.isRequired,\n+ };\n+\n+ render() {\n+ return (\n+ <View style={styles.sectionFooter}>\n+ <Button onSubmit={this.onSubmit} style={styles.addButton}>\n+ <View style={styles.addButtonContents}>\n+ <Icon name=\"plus\" style={styles.addIcon} />\n+ <Text style={styles.actionLinksText}>Add</Text>\n+ </View>\n+ </Button>\n+ </View>\n+ );\n+ }\n+\n+ onSubmit = () => {\n+ this.props.onAdd(this.props.dateString);\n+ }\n+\n+}\n+\n+const styles = StyleSheet.create({\n+ sectionFooter: {\n+ backgroundColor: 'white',\n+ height: 40,\n+ },\n+ addButton: {\n+ position: 'absolute',\n+ backgroundColor: '#EEEEEE',\n+ paddingLeft: 10,\n+ paddingRight: 10,\n+ paddingTop: 5,\n+ paddingBottom: 5,\n+ borderRadius: 5,\n+ margin: 5,\n+ },\n+ addButtonContents: {\n+ flexDirection: 'row',\n+ alignItems: 'center',\n+ },\n+ addIcon: {\n+ fontSize: 14,\n+ paddingRight: 6,\n+ color: '#555555',\n+ },\n+ actionLinksText: {\n+ fontWeight: 'bold',\n+ color: '#555555',\n+ },\n+});\n+\n+export default SectionFooter;\n"
},
{
"change_type": "MODIFY",
"old_path": "native/navigation-setup.js",
"new_path": "native/navigation-setup.js",
"diff": "@@ -56,6 +56,7 @@ const AppNavigator = TabNavigator(\nMore: { screen: More },\n},\n{\n+ lazy: false,\ninitialRouteName: CalendarRouteName,\n},\n);\n"
},
{
"change_type": "MODIFY",
"old_path": "native/selectors/entry-selectors.js",
"new_path": "native/selectors/entry-selectors.js",
"diff": "// @flow\n+import type { BaseAppState } from 'lib/types/redux-types';\nimport type { EntryInfo } from 'lib/types/entry-types';\n-import { currentDaysToEntries } from 'lib/selectors/calendar-selectors';\n-\nimport { createSelector } from 'reselect';\nimport _map from 'lodash/fp/map';\nconst _mapWithKeys = _map.convert({ cap: false });\n+import invariant from 'invariant';\n+\n+import { currentDaysToEntries } from 'lib/selectors/calendar-selectors';\n+import { dateString } from 'lib/utils/date-utils';\nexport type CalendarItem =\n{\n@@ -18,18 +21,36 @@ export type CalendarItem =\n};\nconst calendarSectionListData = createSelector(\n+ (state: BaseAppState) => !!state.userInfo,\ncurrentDaysToEntries,\n- (daysToEntries: {[dayString: string]: EntryInfo[]}) => _mapWithKeys(\n- (entryInfos: EntryInfo[], dateString: string) => ({\n+ (\n+ loggedIn: bool,\n+ daysToEntries: {[dayString: string]: EntryInfo[]},\n+ ) => {\n+ if (!loggedIn) {\n+ return null;\n+ }\n+ invariant(\n+ daysToEntries[dateString(new Date())] !== undefined,\n+ \"today should have an entry in currentDaysToEntries on native\",\n+ );\n+ const result = _mapWithKeys(\n+ (entryInfos: EntryInfo[], dayString: string) => ({\ndata: ([\n..._map(\n(entryInfo: EntryInfo) => ({ itemType: \"entryInfo\", entryInfo }),\n)(entryInfos),\n- { itemType: \"footer\", dateString: dateString },\n+ { itemType: \"footer\", dateString: dayString },\n]: CalendarItem[]),\n- key: dateString,\n+ key: dayString,\n}),\n- )(daysToEntries),\n+ )(daysToEntries);\n+ return [\n+ { data: [], key: \"TopLoader\" },\n+ ...result,\n+ { data: [], key: \"BottomLoader\" },\n+ ];\n+ },\n);\nexport {\n"
},
{
"change_type": "MODIFY",
"old_path": "native/text-height-measurer.react.js",
"new_path": "native/text-height-measurer.react.js",
"diff": "@@ -10,7 +10,7 @@ import { Text, View, StyleSheet } from 'react-native';\nimport invariant from 'invariant';\nimport _isEmpty from 'lodash/fp/isEmpty';\n-const measureBatchSize = 10;\n+const measureBatchSize = 50;\ntype TextToHeight = { [text: string]: number };\ntype Props = {\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Latest Calendar SectionList. A little rough around the edges, but the only big problem remaining is scroll position when prepending new sections |
129,187 | 15.05.2017 15:27:07 | 14,400 | 793f2d024da85df9cc5234b571cc47c48f3b6917 | Ugh sorta working but scroll up is still a pain because of React Native. Gonna try to move from SectionList to FlatList... | [
{
"change_type": "MODIFY",
"old_path": "native/calendar/calendar.react.js",
"new_path": "native/calendar/calendar.react.js",
"diff": "@@ -19,6 +19,7 @@ import {\nAppState as NativeAppState,\nPlatform,\nActivityIndicator,\n+ InteractionManager,\n} from 'react-native';\nimport Icon from 'react-native-vector-icons/FontAwesome';\nimport { connect } from 'react-redux';\n@@ -29,6 +30,7 @@ import _isEqual from 'lodash/fp/isEqual';\nimport _map from 'lodash/fp/map';\nimport _find from 'lodash/fp/find';\nimport _difference from 'lodash/fp/difference';\n+import _filter from 'lodash/fp/filter';\nimport { entryKey } from 'lib/shared/entry-utils';\nimport { dateString, prettyDate, dateFromString } from 'lib/utils/date-utils';\n@@ -82,6 +84,7 @@ type State = {\ntextToMeasure: string[],\nsectionListDataWithHeights: ?$ReadOnlyArray<SectionWithHeights>,\nreadyToShowSectionList: bool,\n+ initialNumToRender: number,\n};\nclass InnerCalendar extends React.PureComponent {\n@@ -120,6 +123,7 @@ class InnerCalendar extends React.PureComponent {\ncurrentState: ?string = NativeAppState.currentState;\nloadingNewEntriesFromScroll = false;\nsectionListShrinking = false;\n+ currentScrollPosition: ?number = null;\nconstructor(props: Props) {\nsuper(props);\n@@ -135,6 +139,7 @@ class InnerCalendar extends React.PureComponent {\ntextToMeasure,\nsectionListDataWithHeights: null,\nreadyToShowSectionList: false,\n+ initialNumToRender: 31,\n};\n}\n@@ -245,13 +250,62 @@ class InnerCalendar extends React.PureComponent {\nsetTimeout(() => this.scrollToToday(), 50);\nsetTimeout(() => this.sectionListShrinking = false, 200);\n} else if (newSLDWH.length > lastSLDWH.length) {\n- // If there are more sections in our new data, that means we just new\n- // entries that were fetched in response to a scroll load, which means\n- // we can reenable the scrollers.\n+ if (\n+ dateFromString(newSLDWH[1].key) < dateFromString(lastSLDWH[1].key)\n+ ) {\n+ this.updateScrollPositionAfterPrepend(lastSLDWH, newSLDWH);\n+ } else {\nthis.loadingNewEntriesFromScroll = false;\n}\n}\n}\n+ }\n+\n+ /**\n+ * When prepending list items, SectionList isn't smart about preserving scroll\n+ * position. If we're at the start of the list before prepending, SectionList\n+ * will just keep us at the front after prepending. But we want to preserve\n+ * the previous on-screen items, so we have to do a calculation to get the new\n+ * scroll position. (And deal with the inherent glitchiness of trying to time\n+ * that change with the items getting prepended... *sigh*.)\n+ */\n+ updateScrollPositionAfterPrepend(\n+ lastSLDWH: $ReadOnlyArray<SectionWithHeights>,\n+ newSLDWH: $ReadOnlyArray<SectionWithHeights>,\n+ ) {\n+ invariant(\n+ this.currentScrollPosition !== undefined &&\n+ this.currentScrollPosition !== null,\n+ \"currentScrollPosition should be set\",\n+ );\n+ const currentScrollPosition =\n+ Math.max(this.currentScrollPosition, 0);\n+ const existingKeys = new Set(\n+ _map((section: SectionWithHeights) => section.key)(lastSLDWH),\n+ );\n+ const newSections = _filter(\n+ (section: SectionWithHeights) => !existingKeys.has(section.key),\n+ )(newSLDWH);\n+ const heightOfNewSections =\n+ InnerCalendar.heightOfSections(newSections);\n+ const [itemIndex, sectionIndex, offset] =\n+ InnerCalendar.getScrollPositionParams(\n+ currentScrollPosition + heightOfNewSections,\n+ newSLDWH,\n+ );\n+ const sectionList = this.sectionList;\n+ invariant(sectionList, \"sectionList should be set\");\n+ sectionList.scrollToLocation({\n+ sectionIndex,\n+ itemIndex: itemIndex + 1,\n+ animated: false,\n+ viewPosition: 0,\n+ viewOffset: Platform.OS === \"ios\" ? (29 - offset) : offset * -1,\n+ });\n+ InteractionManager.runAfterInteractions(() => {\n+ this.loadingNewEntriesFromScroll = false;\n+ });\n+ }\nmergeHeightsIntoSectionListData(\nsectionListData: $ReadOnlyArray<Section>\n@@ -290,8 +344,12 @@ class InnerCalendar extends React.PureComponent {\n// happens, we will reset this back.\nthis.sectionListShrinking = true;\n}\n+ if (this.state.sectionListDataWithHeights) {\n+ this.setState({ sectionListDataWithHeights, initialNumToRender: 0 });\n+ } else {\nthis.setState({ sectionListDataWithHeights });\n}\n+ }\nscrollToToday = (animated: ?bool = undefined) => {\nif (animated === undefined) {\n@@ -420,6 +478,62 @@ class InnerCalendar extends React.PureComponent {\nreturn 20 + entryInfo.textHeight;\n}\n+ static getScrollPositionParams(\n+ currentScrollPosition: number,\n+ data: $ReadOnlyArray<SectionWithHeights>,\n+ ): [number, number, number] {\n+ let curPosition = 0;\n+ let curSectionIndex = 0;\n+ let curItemIndex = -1;\n+ while (true) {\n+ const curItemHeight = InnerCalendar.itemHeight(\n+ curItemIndex,\n+ data[curSectionIndex].data[curItemIndex],\n+ data[curSectionIndex].key,\n+ );\n+ if (curPosition + curItemHeight > currentScrollPosition) {\n+ break;\n+ }\n+ curPosition += curItemHeight;\n+ curItemIndex++;\n+ if (curItemIndex === data[curSectionIndex].data.length) {\n+ curItemIndex = -1;\n+ curSectionIndex++;\n+ }\n+ }\n+ return [curItemIndex, curSectionIndex, currentScrollPosition - curPosition];\n+ }\n+\n+ initialScrollIndex = () => {\n+ const data = this.state.sectionListDataWithHeights;\n+ invariant(data, \"should be set\");\n+ const todayIndex = _findIndex(['key', dateString(new Date())])(data);\n+ let flattenedIndex = 0;\n+ for (let sectionIndex = 0; sectionIndex < todayIndex; sectionIndex++) {\n+ flattenedIndex += data[sectionIndex].data.length + 1;\n+ }\n+ return flattenedIndex;\n+ }\n+\n+ static heightOfSections(data: $ReadOnlyArray<SectionWithHeights>): number {\n+ let height = 0;\n+ let curSectionIndex = 0;\n+ let curItemIndex = -1;\n+ while (curSectionIndex < data.length) {\n+ height += InnerCalendar.itemHeight(\n+ curItemIndex,\n+ data[curSectionIndex].data[curItemIndex],\n+ data[curSectionIndex].key,\n+ );\n+ curItemIndex++;\n+ if (curItemIndex === data[curSectionIndex].data.length) {\n+ curItemIndex = -1;\n+ curSectionIndex++;\n+ }\n+ }\n+ return height;\n+ }\n+\nrender() {\nconst sectionListDataWithHeights = this.state.sectionListDataWithHeights;\nlet sectionList = null;\n@@ -435,8 +549,9 @@ class InnerCalendar extends React.PureComponent {\nkeyExtractor={InnerCalendar.keyExtractor}\ngetItemLayout={InnerCalendar.getItemLayout}\nonLayout={this.onSectionListLayout}\n- initialNumToRender={31}\n+ initialNumToRender={this.state.initialNumToRender}\nonViewableItemsChanged={this.onViewableItemsChanged}\n+ onScroll={this.onScroll}\nstyle={[styles.sectionList, sectionListStyle]}\nref={this.sectionListRef}\n/>\n@@ -537,6 +652,10 @@ class InnerCalendar extends React.PureComponent {\n);\n}\n+ onScroll = (event: { nativeEvent: { contentOffset: { y: number } } }) => {\n+ this.currentScrollPosition = event.nativeEvent.contentOffset.y;\n+ }\n+\n}\nconst styles = StyleSheet.create({\n"
},
{
"change_type": "MODIFY",
"old_path": "native/calendar/entry.react.js",
"new_path": "native/calendar/entry.react.js",
"diff": "@@ -21,6 +21,9 @@ import {\nimport { connect } from 'react-redux';\nimport PropTypes from 'prop-types';\nimport invariant from 'invariant';\n+import shallowequal from 'shallowequal';\n+import _omit from 'lodash/fp/omit';\n+import _isEqual from 'lodash/fp/isEqual';\nimport { colorIsDark } from 'lib/selectors/calendar-selectors';\nimport {\n@@ -56,10 +59,18 @@ type Props = {\ncalendarID: string,\ncreationTime: number,\n) => Promise<SaveResult>,\n-}\n-class Entry extends React.PureComponent {\n+};\n+type State = {\n+ text: string,\n+ loadingStatus: LoadingStatus,\n+ focused: bool,\n+ height: number,\n+ color: string,\n+};\n+class Entry extends React.Component {\nprops: Props;\n+ state: State;\nstatic propTypes = {\nentryInfo: entryInfoPropType.isRequired,\ncalendarInfo: calendarInfoPropType,\n@@ -68,13 +79,6 @@ class Entry extends React.PureComponent {\ndispatchActionPromise: PropTypes.func.isRequired,\nsaveEntry: PropTypes.func.isRequired,\n};\n- state: {\n- text: string,\n- loadingStatus: LoadingStatus,\n- focused: bool,\n- height: number,\n- color: string,\n- };\ntextInput: ?TextInput;\ncreating = false;\nneedsUpdateAfterCreation = false;\n@@ -117,17 +121,30 @@ class Entry extends React.PureComponent {\n}\n}\n+ shouldComponentUpdate(nextProps: Props, nextState: State) {\n+ const omitEntryInfo = _omit([\"entryInfo\"]);\n+ return !shallowequal(nextState, this.state) ||\n+ !shallowequal(omitEntryInfo(nextProps), omitEntryInfo(this.props)) ||\n+ !_isEqual(nextProps.entryInfo, this.props.entryInfo);\n+ }\n+\ncomponentWillUnmount() {\nthis.mounted = false;\n}\nrender() {\n- const entryStyle = { backgroundColor: `#${this.state.color}` };\n+ const containerStyle = {\n+ height: this.state.height + 10,\n+ };\n+ const entryStyle = {\n+ backgroundColor: `#${this.state.color}`,\n+ height: this.state.height,\n+ };\nconst textColor = colorIsDark(this.state.color) ? 'white' : 'black';\nconst textStyle = { color: textColor };\nconst textInputStyle = { color: textColor, height: this.state.height };\nreturn (\n- <View style={styles.container}>\n+ <View style={[styles.container, containerStyle]}>\n<View style={[styles.entry, entryStyle]}>\n<TextInput\nstyle={[styles.textInput, textInputStyle]}\n"
},
{
"change_type": "MODIFY",
"old_path": "native/package.json",
"new_path": "native/package.json",
"diff": "\"redux-persist\": \"^4.7.1\",\n\"redux-thunk\": \"^2.2.0\",\n\"reselect\": \"^3.0.0\",\n+ \"shallowequal\": \"^0.2.2\",\n\"url-parse\": \"^1.1.8\"\n},\n\"devDependencies\": {\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Ugh sorta working but scroll up is still a pain because of React Native. Gonna try to move from SectionList to FlatList... |
129,187 | 15.05.2017 15:28:56 | 14,400 | 641bf4cba30e0e750e22562bce44e811a904cf2c | Remove initialScrollIndex | [
{
"change_type": "MODIFY",
"old_path": "native/calendar/calendar.react.js",
"new_path": "native/calendar/calendar.react.js",
"diff": "@@ -504,17 +504,6 @@ class InnerCalendar extends React.PureComponent {\nreturn [curItemIndex, curSectionIndex, currentScrollPosition - curPosition];\n}\n- initialScrollIndex = () => {\n- const data = this.state.sectionListDataWithHeights;\n- invariant(data, \"should be set\");\n- const todayIndex = _findIndex(['key', dateString(new Date())])(data);\n- let flattenedIndex = 0;\n- for (let sectionIndex = 0; sectionIndex < todayIndex; sectionIndex++) {\n- flattenedIndex += data[sectionIndex].data.length + 1;\n- }\n- return flattenedIndex;\n- }\n-\nstatic heightOfSections(data: $ReadOnlyArray<SectionWithHeights>): number {\nlet height = 0;\nlet curSectionIndex = 0;\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Remove initialScrollIndex |
129,187 | 15.05.2017 18:37:33 | 14,400 | 82fc202d88585b28ca45ae55682512a2bcd045e6 | Convert to FlatList. We lose sticky section headers on iOS, but it is so much more stable than SectionList | [
{
"change_type": "MODIFY",
"old_path": "native/calendar/calendar.react.js",
"new_path": "native/calendar/calendar.react.js",
"diff": "@@ -4,7 +4,6 @@ import type { EntryInfo } from 'lib/types/entry-types';\nimport { entryInfoPropType } from 'lib/types/entry-types';\nimport type { AppState } from '../redux-setup';\nimport type { CalendarItem } from '../selectors/entry-selectors';\n-import type { SectionBase } from '../react-native-types';\nimport type { ViewToken } from 'react-native/Libraries/Lists/ViewabilityHelper';\nimport type { DispatchActionPromise } from 'lib/utils/action-utils';\nimport type { CalendarResult } from 'lib/actions/entry-actions';\n@@ -15,7 +14,7 @@ import {\nView,\nStyleSheet,\nText,\n- SectionList,\n+ FlatList,\nAppState as NativeAppState,\nPlatform,\nActivityIndicator,\n@@ -31,6 +30,7 @@ import _map from 'lodash/fp/map';\nimport _find from 'lodash/fp/find';\nimport _difference from 'lodash/fp/difference';\nimport _filter from 'lodash/fp/filter';\n+import _sum from 'lodash/fp/sum';\nimport { entryKey } from 'lib/shared/entry-utils';\nimport { dateString, prettyDate, dateFromString } from 'lib/utils/date-utils';\n@@ -47,26 +47,30 @@ import { simpleNavID } from 'lib/selectors/nav-selectors';\nimport Entry from './entry.react';\nimport { contentVerticalOffset } from '../dimensions';\n-import { calendarSectionListData } from '../selectors/entry-selectors';\n+import { calendarListData } from '../selectors/entry-selectors';\nimport { createActiveTabSelector } from '../selectors/nav-selectors';\nimport TextHeightMeasurer from '../text-height-measurer.react';\nimport ListLoadingIndicator from './list-loading-indicator.react';\nimport SectionFooter from './section-footer.react';\n-type Section = SectionBase<CalendarItem>;\nexport type EntryInfoWithHeight = EntryInfo & { textHeight: number };\n-export type CalendarItemWithHeight =\n+type CalendarItemWithHeight =\n{\n+ itemType: \"loader\",\n+ key: string,\n+ } | {\n+ itemType: \"header\",\n+ dateString: string,\n+ } | {\nitemType: \"entryInfo\",\nentryInfo: EntryInfoWithHeight,\n} | {\nitemType: \"footer\",\ndateString: string,\n};\n-type SectionWithHeights = SectionBase<CalendarItemWithHeight> & { key: string };\ntype Props = {\n// Redux state\n- sectionListData: ?$ReadOnlyArray<Section>,\n+ listData: ?$ReadOnlyArray<CalendarItem>,\ntabActive: bool,\nsessionID: string,\nsessionExpired: () => bool,\n@@ -82,8 +86,8 @@ type Props = {\n};\ntype State = {\ntextToMeasure: string[],\n- sectionListDataWithHeights: ?$ReadOnlyArray<SectionWithHeights>,\n- readyToShowSectionList: bool,\n+ listDataWithHeights: ?$ReadOnlyArray<CalendarItemWithHeight>,\n+ readyToShowList: bool,\ninitialNumToRender: number,\n};\nclass InnerCalendar extends React.PureComponent {\n@@ -91,14 +95,24 @@ class InnerCalendar extends React.PureComponent {\nprops: Props;\nstate: State;\nstatic propTypes = {\n- sectionListData: PropTypes.arrayOf(PropTypes.shape({\n- data: PropTypes.arrayOf(PropTypes.shape({\n- itemType: PropTypes.oneOf([\"entryInfo\", \"footer\"]),\n- entryInfo: entryInfoPropType,\n- dateString: PropTypes.string,\n- })).isRequired,\n+ listData: PropTypes.arrayOf(PropTypes.oneOfType([\n+ PropTypes.shape({\n+ itemType: PropTypes.oneOf([\"loader\"]),\nkey: PropTypes.string.isRequired,\n- })),\n+ }),\n+ PropTypes.shape({\n+ itemType: PropTypes.oneOf([\"header\"]),\n+ dateString: PropTypes.string.isRequired,\n+ }),\n+ PropTypes.shape({\n+ itemType: PropTypes.oneOf([\"entryInfo\"]),\n+ entryInfo: entryInfoPropType.isRequired,\n+ }),\n+ PropTypes.shape({\n+ itemType: PropTypes.oneOf([\"footer\"]),\n+ dateString: PropTypes.string.isRequired,\n+ }),\n+ ])),\ntabActive: PropTypes.bool.isRequired,\nsessionID: PropTypes.string.isRequired,\nsessionExpired: PropTypes.func.isRequired,\n@@ -118,41 +132,33 @@ class InnerCalendar extends React.PureComponent {\n),\n};\ntextHeightMeasurer: ?TextHeightMeasurer = null;\n- sectionList: ?SectionList<SectionWithHeights> = null;\n+ flatList: ?FlatList<CalendarItemWithHeight> = null;\ntextHeights: ?{ [text: string]: number } = null;\ncurrentState: ?string = NativeAppState.currentState;\nloadingNewEntriesFromScroll = false;\n- sectionListShrinking = false;\n+ listShrinking = false;\ncurrentScrollPosition: ?number = null;\nconstructor(props: Props) {\nsuper(props);\n- let textToMeasure = null;\n- if (props.sectionListData) {\n- textToMeasure = InnerCalendar.textToMeasureFromSectionListData(\n- props.sectionListData,\n- );\n- } else {\n- textToMeasure = [];\n- }\n+ const textToMeasure = props.listData\n+ ? InnerCalendar.textToMeasureFromListData(props.listData)\n+ : [];\nthis.state = {\ntextToMeasure,\n- sectionListDataWithHeights: null,\n- readyToShowSectionList: false,\n+ listDataWithHeights: null,\n+ readyToShowList: false,\ninitialNumToRender: 31,\n};\n}\n- static textToMeasureFromSectionListData(\n- sectionListData: $ReadOnlyArray<Section>,\n- ) {\n+ static textToMeasureFromListData(listData: $ReadOnlyArray<CalendarItem>) {\nconst textToMeasure = [];\n- for (let section of sectionListData) {\n- for (let item of section.data) {\n- if (item.itemType === \"entryInfo\") {\n- textToMeasure.push(item.entryInfo.text);\n- }\n+ for (let item of listData) {\n+ if (item.itemType !== \"entryInfo\") {\n+ continue;\n}\n+ textToMeasure.push(item.entryInfo.text);\n}\nreturn textToMeasure;\n}\n@@ -174,26 +180,26 @@ class InnerCalendar extends React.PureComponent {\nlastState.match(/inactive|background/) &&\nthis.currentState === \"active\" &&\nthis.props.sessionExpired() &&\n- this.sectionList\n+ this.flatList\n) {\nthis.scrollToToday();\n}\n}\ncomponentWillReceiveProps(newProps: Props) {\n- // When the sectionListData changes we may need to recalculate some heights\n- if (newProps.sectionListData !== this.props.sectionListData) {\n- const newSectionListData = newProps.sectionListData;\n- if (!newSectionListData) {\n+ // When the listData changes we may need to recalculate some heights\n+ if (newProps.listData !== this.props.listData) {\n+ const newListData = newProps.listData;\n+ if (!newListData) {\nthis.setState({\ntextToMeasure: [],\n- sectionListDataWithHeights: null,\n- readyToShowSectionList: false,\n+ listDataWithHeights: null,\n+ readyToShowList: false,\n});\n} else {\n// If we had no entries and just got some we'll scroll to today\n- const newTextToMeasure = InnerCalendar.textToMeasureFromSectionListData(\n- newSectionListData,\n+ const newTextToMeasure = InnerCalendar.textToMeasureFromListData(\n+ newListData,\n);\nlet allTextAlreadyMeasured = false;\n@@ -208,7 +214,7 @@ class InnerCalendar extends React.PureComponent {\n}\nif (allTextAlreadyMeasured) {\n- this.mergeHeightsIntoSectionListData(newSectionListData);\n+ this.mergeHeightsIntoListData(newListData);\n} else {\nconst newText =\n_difference(newTextToMeasure)(this.state.textToMeasure);\n@@ -235,25 +241,35 @@ class InnerCalendar extends React.PureComponent {\nif (\nthis.props.sessionID !== prevProps.sessionID &&\n!this.props.tabActive &&\n- this.sectionList\n+ this.flatList\n) {\nthis.scrollToToday();\n}\n- const lastSLDWH = prevState.sectionListDataWithHeights;\n- const newSLDWH = this.state.sectionListDataWithHeights;\n- if (lastSLDWH && newSLDWH) {\n- if (newSLDWH.length < lastSLDWH.length) {\n- // If there are fewer sections in our new data, which happens when the\n+ const lastLDWH = prevState.listDataWithHeights;\n+ const newLDWH = this.state.listDataWithHeights;\n+ if (lastLDWH && newLDWH) {\n+ if (newLDWH.length < lastLDWH.length) {\n+ // If there are fewer items in our new data, which happens when the\n// current calendar query gets reset due to inactivity, let's reset the\n// scroll position to the center (today). Once we're done, we can allow\n// scrolling logic once again.\n- setTimeout(() => this.scrollToToday(), 50);\n- setTimeout(() => this.sectionListShrinking = false, 200);\n- } else if (newSLDWH.length > lastSLDWH.length) {\n+ this.scrollToToday();\n+ InteractionManager.runAfterInteractions(() => {\n+ this.listShrinking = false;\n+ });\n+ } else if (newLDWH.length > lastLDWH.length) {\n+ const lastSecondItem = lastLDWH[1];\n+ const newSecondItem = newLDWH[1];\n+ invariant(\n+ newSecondItem.itemType === \"header\" &&\n+ lastSecondItem.itemType === \"header\",\n+ \"second item in listData should be a header\",\n+ );\nif (\n- dateFromString(newSLDWH[1].key) < dateFromString(lastSLDWH[1].key)\n+ dateFromString(newSecondItem.dateString) <\n+ dateFromString(lastSecondItem.dateString)\n) {\n- this.updateScrollPositionAfterPrepend(lastSLDWH, newSLDWH);\n+ this.updateScrollPositionAfterPrepend(lastLDWH, newLDWH);\n} else {\nthis.loadingNewEntriesFromScroll = false;\n}\n@@ -262,16 +278,16 @@ class InnerCalendar extends React.PureComponent {\n}\n/**\n- * When prepending list items, SectionList isn't smart about preserving scroll\n- * position. If we're at the start of the list before prepending, SectionList\n+ * When prepending list items, FlatList isn't smart about preserving scroll\n+ * position. If we're at the start of the list before prepending, FlatList\n* will just keep us at the front after prepending. But we want to preserve\n* the previous on-screen items, so we have to do a calculation to get the new\n* scroll position. (And deal with the inherent glitchiness of trying to time\n* that change with the items getting prepended... *sigh*.)\n*/\nupdateScrollPositionAfterPrepend(\n- lastSLDWH: $ReadOnlyArray<SectionWithHeights>,\n- newSLDWH: $ReadOnlyArray<SectionWithHeights>,\n+ lastLDWH: $ReadOnlyArray<CalendarItemWithHeight>,\n+ newLDWH: $ReadOnlyArray<CalendarItemWithHeight>,\n) {\ninvariant(\nthis.currentScrollPosition !== undefined &&\n@@ -281,42 +297,31 @@ class InnerCalendar extends React.PureComponent {\nconst currentScrollPosition =\nMath.max(this.currentScrollPosition, 0);\nconst existingKeys = new Set(\n- _map((section: SectionWithHeights) => section.key)(lastSLDWH),\n- );\n- const newSections = _filter(\n- (section: SectionWithHeights) => !existingKeys.has(section.key),\n- )(newSLDWH);\n- const heightOfNewSections =\n- InnerCalendar.heightOfSections(newSections);\n- const [itemIndex, sectionIndex, offset] =\n- InnerCalendar.getScrollPositionParams(\n- currentScrollPosition + heightOfNewSections,\n- newSLDWH,\n+ _map((item: CalendarItemWithHeight) => InnerCalendar.keyExtractor(item))\n+ (lastLDWH),\n);\n- const sectionList = this.sectionList;\n- invariant(sectionList, \"sectionList should be set\");\n- sectionList.scrollToLocation({\n- sectionIndex,\n- itemIndex: itemIndex + 1,\n+ const newItems = _filter(\n+ (item: CalendarItemWithHeight) =>\n+ !existingKeys.has(InnerCalendar.keyExtractor(item)),\n+ )(newLDWH);\n+ const heightOfNewItems = InnerCalendar.heightOfItems(newItems);\n+ const flatList = this.flatList;\n+ invariant(flatList, \"flatList should be set\");\n+ flatList.scrollToOffset({\n+ offset: currentScrollPosition + heightOfNewItems,\nanimated: false,\n- viewPosition: 0,\n- viewOffset: Platform.OS === \"ios\" ? (29 - offset) : offset * -1,\n});\nInteractionManager.runAfterInteractions(() => {\nthis.loadingNewEntriesFromScroll = false;\n});\n}\n- mergeHeightsIntoSectionListData(\n- sectionListData: $ReadOnlyArray<Section>\n- ) {\n- const sectionListDataWithHeights = _map((section: Section) => ({\n- ...section,\n- data: _map((calendarItem: CalendarItem) => {\n- if (calendarItem.itemType === \"footer\") {\n- return calendarItem;\n+ mergeHeightsIntoListData(listData: $ReadOnlyArray<CalendarItem>) {\n+ const listDataWithHeights = _map((item: CalendarItem) => {\n+ if (item.itemType !== \"entryInfo\") {\n+ return item;\n}\n- const entryInfo = calendarItem.entryInfo;\n+ const entryInfo = item.entryInfo;\ninvariant(this.textHeights, \"textHeights should be set\");\nconst textHeight = this.textHeights[entryInfo.text];\ninvariant(\n@@ -324,30 +329,28 @@ class InnerCalendar extends React.PureComponent {\n`height for ${entryKey(entryInfo)} should be set`,\n);\nreturn {\n- ...calendarItem,\n+ ...item,\nentryInfo: {\n- ...calendarItem.entryInfo,\n+ ...item.entryInfo,\ntextHeight,\n},\n};\n- })(section.data),\n- }))(sectionListData);\n+ })(listData);\nif (\n- this.state.sectionListDataWithHeights &&\n- sectionListDataWithHeights.length <\n- this.state.sectionListDataWithHeights.length\n+ this.state.listDataWithHeights &&\n+ listDataWithHeights.length < this.state.listDataWithHeights.length\n) {\n- // We know that this is going to shrink our SectionList, which may cause\n+ // We know that this is going to shrink our FlatList, which may cause\n// either of the ListLoadingIndicators to come into view. When our\n- // SectionList shrinks, componentDidUpdate will trigger scrollToToday (we\n- // can't do it any earlier because of SectionList weirdness). After that\n+ // FlatList shrinks, componentDidUpdate will trigger scrollToToday (we\n+ // can't do it any earlier because of FlatList weirdness). After that\n// happens, we will reset this back.\n- this.sectionListShrinking = true;\n+ this.listShrinking = true;\n}\n- if (this.state.sectionListDataWithHeights) {\n- this.setState({ sectionListDataWithHeights, initialNumToRender: 0 });\n+ if (this.state.listDataWithHeights) {\n+ this.setState({ listDataWithHeights, initialNumToRender: 0 });\n} else {\n- this.setState({ sectionListDataWithHeights });\n+ this.setState({ listDataWithHeights });\n}\n}\n@@ -355,34 +358,34 @@ class InnerCalendar extends React.PureComponent {\nif (animated === undefined) {\nanimated = this.props.tabActive;\n}\n- invariant(this.state.sectionListDataWithHeights, \"should be set\");\n- const todayIndex = _findIndex(['key', dateString(new Date())])\n- (this.state.sectionListDataWithHeights);\n- invariant(this.sectionList, \"sectionList should be set\");\n- this.sectionList.scrollToLocation({\n- sectionIndex: todayIndex,\n- itemIndex: 0,\n+ invariant(this.state.listDataWithHeights, \"should be set\");\n+ const todayIndex = _findIndex(['dateString', dateString(new Date())])\n+ (this.state.listDataWithHeights);\n+ invariant(this.flatList, \"flatList should be set\");\n+ this.flatList.scrollToIndex({\n+ index: todayIndex,\nanimated,\nviewPosition: 0.5,\n- viewOffset: Platform.OS === \"ios\" ? 29 : 0,\n});\n}\n- renderItem = (row) => {\n- if (row.item.entryInfo) {\n+ renderItem = (row: { item: CalendarItemWithHeight }) => {\n+ if (row.item.itemType === \"loader\") {\n+ return <ListLoadingIndicator />;\n+ } else if (row.item.itemType === \"header\") {\n+ return InnerCalendar.renderSectionHeader(row);\n+ } else if (row.item.itemType === \"entryInfo\") {\nreturn <Entry entryInfo={row.item.entryInfo} />;\n- } else {\n+ } else if (row.item.itemType === \"footer\") {\nreturn this.renderSectionFooter(row);\n}\n+ invariant(false, \"renderItem conditions should be exhaustive\");\n}\n- static renderSectionHeader = (row) => {\n- invariant(row.section.key, \"should be set\");\n- if (row.section.key === \"TopLoader\" || row.section.key === \"BottomLoader\") {\n- return <ListLoadingIndicator />;\n- }\n- let date = prettyDate(row.section.key);\n- if (dateString(new Date()) === row.section.key) {\n+ static renderSectionHeader = (row: { item: CalendarItemWithHeight }) => {\n+ invariant(row.item.itemType === \"header\", \"itemType should be header\");\n+ let date = prettyDate(row.item.dateString);\n+ if (dateString(new Date()) === row.item.dateString) {\ndate += \" (today)\";\n}\nreturn (\n@@ -396,11 +399,8 @@ class InnerCalendar extends React.PureComponent {\n);\n}\n- renderSectionFooter = (row) => {\n- // Eventually we will pass this function directly into SectionList, but\n- // that functionality is only in RN master as of this time, and also there\n- // is an issue (RN#13784) where empty sections don't render a footer. Also,\n- // scrollToLocation doesn't take the renderSectionFooter prop into account.\n+ renderSectionFooter = (row: { item: CalendarItemWithHeight }) => {\n+ invariant(row.item.itemType === \"footer\", \"itemType should be footer\");\nreturn (\n<SectionFooter dateString={row.item.dateString} onAdd={this.onAdd} />\n);\n@@ -410,144 +410,73 @@ class InnerCalendar extends React.PureComponent {\nconsole.log(dayString);\n}\n- static keyExtractor = (item: CalendarItemWithHeight | SectionWithHeights) => {\n- if (item.data) {\n- invariant(typeof item.key === \"string\", \"key should be string\");\n- // Something having to do with onViewableItemsChanged calls keyExtractor\n- // with sections. This condition should only catch sections\n+ static keyExtractor = (item: CalendarItemWithHeight) => {\n+ if (item.itemType === \"loader\") {\nreturn item.key;\n+ } else if (item.itemType === \"header\") {\n+ return item.dateString + \"/header\";\n} else if (item.itemType === \"entryInfo\") {\n- invariant(item.entryInfo, 'test');\nreturn entryKey(item.entryInfo);\n} else if (item.itemType === \"footer\") {\nreturn item.dateString + \"/footer\";\n}\n- invariant(false, \"keyExtractor could not extract key\");\n+ invariant(false, \"keyExtractor conditions should be exhaustive\");\n}\nstatic getItemLayout = (\n- data: $ReadOnlyArray<SectionWithHeights>,\n+ data: $ReadOnlyArray<CalendarItemWithHeight>,\n// each section header, section footer, and entry gets its own index\n- flattenedIndex: number,\n+ index: number,\n) => {\n- let offset = 0;\n- let curSectionIndex = 0;\n- let curItemIndex = -1;\n- for (let i = 0; i < flattenedIndex; i++) {\n- offset += InnerCalendar.itemHeight(\n- curItemIndex,\n- data[curSectionIndex].data[curItemIndex],\n- data[curSectionIndex].key,\n- );\n- curItemIndex++;\n- if (curItemIndex === data[curSectionIndex].data.length) {\n- curItemIndex = -1;\n- curSectionIndex++;\n- }\n- }\n- const length = InnerCalendar.itemHeight(\n- curItemIndex,\n- data[curSectionIndex].data[curItemIndex],\n- data[curSectionIndex].key,\n- );\n- return { length, offset, index: flattenedIndex };\n+ const offset =\n+ InnerCalendar.heightOfItems(data.filter((_, i) => i < index));\n+ const item = data[index];\n+ const length = item ? InnerCalendar.itemHeight(item) : 0;\n+ return { length, offset, index };\n}\n- static itemHeight(\n- itemIndex: number,\n- calendarItem: ?CalendarItemWithHeight,\n- sectionKey: string,\n- ): number {\n+ static itemHeight(item: CalendarItemWithHeight): number {\n// TODO test these values on Android\n- if (itemIndex === -1) {\n- if (sectionKey === \"TopLoader\" || sectionKey === \"BottomLoader\") {\n- // handle ListLoadingIndicator\n+ if (item.itemType === \"loader\") {\nreturn 56;\n- } else {\n- // handle section header\n+ } else if (item.itemType === \"header\") {\nreturn 29;\n- }\n- }\n- invariant(calendarItem, \"should be set\");\n- if (calendarItem.itemType === \"footer\") {\n- // handle section footer\n+ } else if (item.itemType === \"entryInfo\") {\n+ return 20 + item.entryInfo.textHeight;\n+ } else if (item.itemType === \"footer\") {\nreturn 40;\n}\n- // handle Entry\n- const entryInfo = calendarItem.entryInfo;\n- return 20 + entryInfo.textHeight;\n- }\n-\n- static getScrollPositionParams(\n- currentScrollPosition: number,\n- data: $ReadOnlyArray<SectionWithHeights>,\n- ): [number, number, number] {\n- let curPosition = 0;\n- let curSectionIndex = 0;\n- let curItemIndex = -1;\n- while (true) {\n- const curItemHeight = InnerCalendar.itemHeight(\n- curItemIndex,\n- data[curSectionIndex].data[curItemIndex],\n- data[curSectionIndex].key,\n- );\n- if (curPosition + curItemHeight > currentScrollPosition) {\n- break;\n- }\n- curPosition += curItemHeight;\n- curItemIndex++;\n- if (curItemIndex === data[curSectionIndex].data.length) {\n- curItemIndex = -1;\n- curSectionIndex++;\n- }\n- }\n- return [curItemIndex, curSectionIndex, currentScrollPosition - curPosition];\n+ invariant(false, \"itemHeight conditions should be exhaustive\");\n}\n- static heightOfSections(data: $ReadOnlyArray<SectionWithHeights>): number {\n- let height = 0;\n- let curSectionIndex = 0;\n- let curItemIndex = -1;\n- while (curSectionIndex < data.length) {\n- height += InnerCalendar.itemHeight(\n- curItemIndex,\n- data[curSectionIndex].data[curItemIndex],\n- data[curSectionIndex].key,\n- );\n- curItemIndex++;\n- if (curItemIndex === data[curSectionIndex].data.length) {\n- curItemIndex = -1;\n- curSectionIndex++;\n- }\n- }\n- return height;\n+ static heightOfItems(data: $ReadOnlyArray<CalendarItemWithHeight>): number {\n+ return _sum(data.map(InnerCalendar.itemHeight));\n}\nrender() {\n- const sectionListDataWithHeights = this.state.sectionListDataWithHeights;\n- let sectionList = null;\n- if (sectionListDataWithHeights) {\n- const sectionListStyle = {\n- opacity: this.state.readyToShowSectionList ? 1 : 0,\n+ const listDataWithHeights = this.state.listDataWithHeights;\n+ let flatList = null;\n+ if (listDataWithHeights) {\n+ const flatListStyle = {\n+ opacity: this.state.readyToShowList ? 1 : 0,\n};\n- sectionList = (\n- <SectionList\n- sections={sectionListDataWithHeights}\n+ flatList = (\n+ <FlatList\n+ data={listDataWithHeights}\nrenderItem={this.renderItem}\n- renderSectionHeader={InnerCalendar.renderSectionHeader}\nkeyExtractor={InnerCalendar.keyExtractor}\ngetItemLayout={InnerCalendar.getItemLayout}\n- onLayout={this.onSectionListLayout}\n- initialNumToRender={this.state.initialNumToRender}\n+ onLayout={this.onListLayout}\nonViewableItemsChanged={this.onViewableItemsChanged}\nonScroll={this.onScroll}\n- style={[styles.sectionList, sectionListStyle]}\n- ref={this.sectionListRef}\n+ initialNumToRender={this.state.initialNumToRender}\n+ style={[styles.flatList, flatListStyle]}\n+ ref={this.flatListRef}\n/>\n);\n}\nlet loadingIndicator = null;\n- if (!sectionListDataWithHeights || !this.state.readyToShowSectionList) {\n+ if (!listDataWithHeights || !this.state.readyToShowList) {\nloadingIndicator = (\n<View style={styles.loadingIndicatorContainer}>\n<ActivityIndicator\n@@ -567,26 +496,34 @@ class InnerCalendar extends React.PureComponent {\nref={this.textHeightMeasurerRef}\n/>\n{loadingIndicator}\n- {sectionList}\n+ {flatList}\n</View>\n);\n}\n+ initialScrollIndex = () => {\n+ const data = this.state.listDataWithHeights;\n+ invariant(data, \"should be set\");\n+ return _findIndex(['dateString', dateString(new Date())])(data);\n+ }\n+\ntextHeightMeasurerRef = (textHeightMeasurer: ?TextHeightMeasurer) => {\nthis.textHeightMeasurer = textHeightMeasurer;\n}\n- sectionListRef = (sectionList: ?SectionList<SectionWithHeights>) => {\n- this.sectionList = sectionList;\n+ flatListRef = (flatList: ?FlatList<CalendarItemWithHeight>) => {\n+ this.flatList = flatList;\n}\n- onSectionListLayout = (event: SyntheticEvent) => {\n+ onListLayout = (event: SyntheticEvent) => {\n// This onLayout call should only trigger when the user logs in or starts\n- // the app. We wait until now to scroll the calendar SectionList to today\n- // because SectionList.scrollToLocation has some quirky behavior when you\n- // call it before layout.\n+ // the app. We wait until now to scroll the calendar FlatList to today\n+ // because FlatList.scrollToItem has some quirky behavior when you call it\n+ // before layout.\nthis.scrollToToday(false);\n- setTimeout(() => this.setState({ readyToShowSectionList: true }), 50);\n+ InteractionManager.runAfterInteractions(() => {\n+ this.setState({ readyToShowList: true });\n+ });\n}\nallHeightsMeasured = (\n@@ -597,8 +534,8 @@ class InnerCalendar extends React.PureComponent {\nreturn;\n}\nthis.textHeights = newTextHeights;\n- if (this.props.sectionListData) {\n- this.mergeHeightsIntoSectionListData(this.props.sectionListData);\n+ if (this.props.listData) {\n+ this.mergeHeightsIntoListData(this.props.listData);\n}\n}\n@@ -607,9 +544,9 @@ class InnerCalendar extends React.PureComponent {\nchanged: ViewToken[],\n}) => {\nif (\n- !this.state.readyToShowSectionList ||\n+ !this.state.readyToShowList ||\nthis.loadingNewEntriesFromScroll ||\n- this.sectionListShrinking\n+ this.listShrinking\n) {\nreturn;\n}\n@@ -654,7 +591,7 @@ const styles = StyleSheet.create({\ncontainer: {\nflex: 1,\n},\n- sectionList: {\n+ flatList: {\nflex: 1,\nbackgroundColor: '#EEEEEE',\nmarginTop: contentVerticalOffset,\n@@ -691,7 +628,7 @@ const CalendarRouteName = 'Calendar';\nconst activeTabSelector = createActiveTabSelector(CalendarRouteName);\nconst Calendar = connect(\n(state: AppState) => ({\n- sectionListData: calendarSectionListData(state),\n+ listData: calendarListData(state),\ntabActive: activeTabSelector(state),\nsessionID: state.sessionID,\nsessionExpired: sessionExpired(state),\n"
},
{
"change_type": "DELETE",
"old_path": "native/react-native-types.js",
"new_path": null,
"diff": "-// @flow\n-\n-import React from 'react';\n-\n-// from SectionList.js\n-export type SectionBase<SectionItemT> = {\n- data: $ReadOnlyArray<SectionItemT>,\n- key?: string,\n- renderItem?: ?(info: {\n- item: SectionItemT,\n- index: number,\n- section: SectionBase<SectionItemT>,\n- separators: {\n- highlight: () => void,\n- unhighlight: () => void,\n- updateProps: (select: 'leading' | 'trailing', newProps: Object) => void,\n- },\n- }) => ?React.Element<any>,\n- ItemSeparatorComponent?: ?ReactClass<any>,\n- keyExtractor?: (item: SectionItemT) => string,\n-};\n"
},
{
"change_type": "MODIFY",
"old_path": "native/selectors/entry-selectors.js",
"new_path": "native/selectors/entry-selectors.js",
"diff": "@@ -13,6 +13,12 @@ import { dateString } from 'lib/utils/date-utils';\nexport type CalendarItem =\n{\n+ itemType: \"loader\",\n+ key: string,\n+ } | {\n+ itemType: \"header\",\n+ dateString: string,\n+ } | {\nitemType: \"entryInfo\",\nentryInfo: EntryInfo,\n} | {\n@@ -20,7 +26,7 @@ export type CalendarItem =\ndateString: string,\n};\n-const calendarSectionListData = createSelector(\n+const calendarListData = createSelector(\n(state: BaseAppState) => !!state.userInfo,\ncurrentDaysToEntries,\n(\n@@ -34,25 +40,19 @@ const calendarSectionListData = createSelector(\ndaysToEntries[dateString(new Date())] !== undefined,\n\"today should have an entry in currentDaysToEntries on native\",\n);\n- const result = _mapWithKeys(\n- (entryInfos: EntryInfo[], dayString: string) => ({\n- data: ([\n- ..._map(\n- (entryInfo: EntryInfo) => ({ itemType: \"entryInfo\", entryInfo }),\n- )(entryInfos),\n- { itemType: \"footer\", dateString: dayString },\n- ]: CalendarItem[]),\n- key: dayString,\n- }),\n- )(daysToEntries);\n- return [\n- { data: [], key: \"TopLoader\" },\n- ...result,\n- { data: [], key: \"BottomLoader\" },\n- ];\n+ const items: CalendarItem[] = [{ itemType: \"loader\", key: \"TopLoader\" }];\n+ for (let dayString in daysToEntries) {\n+ items.push({ itemType: \"header\", dateString: dayString });\n+ for (let entryInfo of daysToEntries[dayString]) {\n+ items.push({ itemType: \"entryInfo\", entryInfo });\n+ }\n+ items.push({ itemType: \"footer\", dateString: dayString });\n+ }\n+ items.push({ itemType: \"loader\", key: \"BottomLoader\" });\n+ return items;\n},\n);\nexport {\n- calendarSectionListData,\n+ calendarListData,\n};\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Convert to FlatList. We lose sticky section headers on iOS, but it is so much more stable than SectionList |
129,187 | 15.05.2017 19:33:15 | 14,400 | 9a4f0c536abca44ac5c3360c220a9495ccaa67b2 | Touch up timing on scroll events | [
{
"change_type": "MODIFY",
"old_path": "native/calendar/calendar.react.js",
"new_path": "native/calendar/calendar.react.js",
"diff": "@@ -253,10 +253,8 @@ class InnerCalendar extends React.PureComponent {\n// current calendar query gets reset due to inactivity, let's reset the\n// scroll position to the center (today). Once we're done, we can allow\n// scrolling logic once again.\n- this.scrollToToday();\n- InteractionManager.runAfterInteractions(() => {\n- this.listShrinking = false;\n- });\n+ setTimeout(() => this.scrollToToday(), 50);\n+ setTimeout(() => this.listShrinking = false, 200);\n} else if (newLDWH.length > lastLDWH.length) {\nconst lastSecondItem = lastLDWH[1];\nconst newSecondItem = newLDWH[1];\n@@ -289,13 +287,6 @@ class InnerCalendar extends React.PureComponent {\nlastLDWH: $ReadOnlyArray<CalendarItemWithHeight>,\nnewLDWH: $ReadOnlyArray<CalendarItemWithHeight>,\n) {\n- invariant(\n- this.currentScrollPosition !== undefined &&\n- this.currentScrollPosition !== null,\n- \"currentScrollPosition should be set\",\n- );\n- const currentScrollPosition =\n- Math.max(this.currentScrollPosition, 0);\nconst existingKeys = new Set(\n_map((item: CalendarItemWithHeight) => InnerCalendar.keyExtractor(item))\n(lastLDWH),\n@@ -307,13 +298,30 @@ class InnerCalendar extends React.PureComponent {\nconst heightOfNewItems = InnerCalendar.heightOfItems(newItems);\nconst flatList = this.flatList;\ninvariant(flatList, \"flatList should be set\");\n+ const scrollAction = () => {\n+ invariant(\n+ this.currentScrollPosition !== undefined &&\n+ this.currentScrollPosition !== null,\n+ \"currentScrollPosition should be set\",\n+ );\n+ const currentScrollPosition =\n+ Math.max(this.currentScrollPosition, 0);\n+ let offset = currentScrollPosition + heightOfNewItems;\n+ if (Platform.OS === \"android\") {\n+ // I am not sure why we do this. I have no idea what's going on.\n+ offset += 74;\n+ }\nflatList.scrollToOffset({\n- offset: currentScrollPosition + heightOfNewItems,\n+ offset,\nanimated: false,\n});\n- InteractionManager.runAfterInteractions(() => {\n- this.loadingNewEntriesFromScroll = false;\n- });\n+ };\n+ if (Platform.OS === \"android\") {\n+ setTimeout(scrollAction, 0);\n+ } else {\n+ scrollAction();\n+ }\n+ setTimeout(() => this.loadingNewEntriesFromScroll = false, 1000);\n}\nmergeHeightsIntoListData(listData: $ReadOnlyArray<CalendarItem>) {\n@@ -521,9 +529,7 @@ class InnerCalendar extends React.PureComponent {\n// because FlatList.scrollToItem has some quirky behavior when you call it\n// before layout.\nthis.scrollToToday(false);\n- InteractionManager.runAfterInteractions(() => {\n- this.setState({ readyToShowList: true });\n- });\n+ setTimeout(() => this.setState({ readyToShowList: true }), 50);\n}\nallHeightsMeasured = (\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Touch up timing on scroll events |
129,187 | 16.05.2017 17:05:39 | 14,400 | e5fe2b3163011901b3995ad901200fcabfecd113 | Don't save entry on native unless the text actually changes | [
{
"change_type": "MODIFY",
"old_path": "native/calendar/entry.react.js",
"new_path": "native/calendar/entry.react.js",
"diff": "@@ -202,7 +202,7 @@ class Entry extends React.Component {\nthis.setState({ focused: false });\nif (this.state.text.trim() === \"\") {\nthis.delete(this.props.entryInfo.id);\n- } else {\n+ } else if (this.props.entryInfo.text !== this.state.text) {\nthis.save(this.props.entryInfo.id, this.state.text);\n}\n}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Don't save entry on native unless the text actually changes |
129,187 | 16.05.2017 17:16:05 | 14,400 | 82b71044fd6de17a1f7eabaae034241ac32f0c41 | Fix up the logic to detect when prepend/append/reset events occur on the calendar view | [
{
"change_type": "MODIFY",
"old_path": "native/calendar/calendar.react.js",
"new_path": "native/calendar/calendar.react.js",
"diff": "@@ -248,17 +248,13 @@ class InnerCalendar extends React.PureComponent {\n) {\nthis.scrollToToday();\n}\n+\nconst lastLDWH = prevState.listDataWithHeights;\nconst newLDWH = this.state.listDataWithHeights;\n- if (lastLDWH && newLDWH) {\n- if (newLDWH.length < lastLDWH.length) {\n- // If there are fewer items in our new data, which happens when the\n- // current calendar query gets reset due to inactivity, let's reset the\n- // scroll position to the center (today). Once we're done, we can allow\n- // scrolling logic once again.\n- setTimeout(() => this.scrollToToday(), 50);\n- setTimeout(() => this.listShrinking = false, 200);\n- } else if (newLDWH.length > lastLDWH.length) {\n+ if (!lastLDWH || !newLDWH) {\n+ return;\n+ }\n+\nconst lastSecondItem = lastLDWH[1];\nconst newSecondItem = newLDWH[1];\ninvariant(\n@@ -266,17 +262,32 @@ class InnerCalendar extends React.PureComponent {\nlastSecondItem.itemType === \"header\",\n\"second item in listData should be a header\",\n);\n- if (\n- dateFromString(newSecondItem.dateString) <\n- dateFromString(lastSecondItem.dateString)\n- ) {\n+ const lastStartDate = dateFromString(lastSecondItem.dateString);\n+ const newStartDate = dateFromString(newSecondItem.dateString);\n+\n+ const lastPenultimateItem = lastLDWH[lastLDWH.length - 2];\n+ const newPenultimateItem = newLDWH[newLDWH.length - 2];\n+ invariant(\n+ newPenultimateItem.itemType === \"footer\" &&\n+ lastPenultimateItem.itemType === \"footer\",\n+ \"penultimate item in listData should be a footer\",\n+ );\n+ const lastEndDate = dateFromString(lastPenultimateItem.dateString);\n+ const newEndDate = dateFromString(newPenultimateItem.dateString);\n+\n+ if (newStartDate > lastStartDate || newEndDate < lastEndDate) {\n+ // If there are fewer items in our new data, which happens when the\n+ // current calendar query gets reset due to inactivity, let's reset the\n+ // scroll position to the center (today). Once we're done, we can allow\n+ // scrolling logic once again.\n+ setTimeout(() => this.scrollToToday(), 50);\n+ setTimeout(() => this.listShrinking = false, 200);\n+ } else if (newStartDate < lastStartDate) {\nthis.updateScrollPositionAfterPrepend(lastLDWH, newLDWH);\n- } else {\n+ } else if (newEndDate > lastEndDate) {\nthis.loadingNewEntriesFromScroll = false;\n}\n}\n- }\n- }\n/**\n* When prepending list items, FlatList isn't smart about preserving scroll\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Fix up the logic to detect when prepend/append/reset events occur on the calendar view |
129,187 | 23.05.2017 21:35:04 | 14,400 | 2cc4ccf8893d066ef8a5911560aa5c997b30ab53 | Update to though annoyingly it has new Flow errors... | [
{
"change_type": "MODIFY",
"old_path": "native/package.json",
"new_path": "native/package.json",
"diff": "\"react-native-keychain\": \"^1.2.0\",\n\"react-native-onepassword\": \"^1.0.4\",\n\"react-native-vector-icons\": \"^4.1.1\",\n- \"react-navigation\": \"^1.0.0-beta.9\",\n+ \"react-navigation\": \"^1.0.0-beta.10\",\n\"react-redux\": \"^5.0.4\",\n\"redux\": \"^3.6.0\",\n\"redux-persist\": \"^4.7.1\",\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Update to react-navigation@1.0.0-beta.10, though annoyingly it has new Flow errors... |
129,187 | 24.05.2017 11:37:34 | 14,400 | 55763ec8de67ce012e4633417ef9240f00e79158 | Another react-navigation version bump | [
{
"change_type": "MODIFY",
"old_path": "native/package.json",
"new_path": "native/package.json",
"diff": "\"react-native-keychain\": \"^1.2.0\",\n\"react-native-onepassword\": \"^1.0.4\",\n\"react-native-vector-icons\": \"^4.1.1\",\n- \"react-navigation\": \"^1.0.0-beta.10\",\n+ \"react-navigation\": \"^1.0.0-beta.11\",\n\"react-redux\": \"^5.0.4\",\n\"redux\": \"^3.6.0\",\n\"redux-persist\": \"^4.7.1\",\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Another react-navigation version bump |
129,187 | 24.05.2017 18:23:50 | 14,400 | 3918858a0c3c319fc5329454da6e12c3ec868acf | Add action links and a delete button to the calendar view | [
{
"change_type": "MODIFY",
"old_path": "native/calendar/calendar.react.js",
"new_path": "native/calendar/calendar.react.js",
"diff": "@@ -31,6 +31,9 @@ import _find from 'lodash/fp/find';\nimport _difference from 'lodash/fp/difference';\nimport _filter from 'lodash/fp/filter';\nimport _sum from 'lodash/fp/sum';\n+import _pick from 'lodash/fp/pick';\n+import _size from 'lodash/fp/size';\n+import _compact from 'lodash/fp/compact';\nimport { entryKey } from 'lib/shared/entry-utils';\nimport { dateString, prettyDate, dateFromString } from 'lib/utils/date-utils';\n@@ -91,6 +94,11 @@ type State = {\nreadyToShowList: bool,\ninitialNumToRender: number,\npickerOpenForDateString: ?string,\n+ focusedEntries: {[key: string]: bool},\n+};\n+const viewabilityConfig = {\n+ viewAreaCoveragePercentThreshold: 100,\n+ waitForInteraction: true,\n};\nclass InnerCalendar extends React.PureComponent {\n@@ -152,6 +160,7 @@ class InnerCalendar extends React.PureComponent {\nreadyToShowList: false,\ninitialNumToRender: 31,\npickerOpenForDateString: null,\n+ focusedEntries: {},\n};\n}\n@@ -198,6 +207,7 @@ class InnerCalendar extends React.PureComponent {\ntextToMeasure: [],\nlistDataWithHeights: null,\nreadyToShowList: false,\n+ focusedEntries: {},\n});\n} else {\n// If we had no entries and just got some we'll scroll to today\n@@ -397,7 +407,13 @@ class InnerCalendar extends React.PureComponent {\n} else if (row.item.itemType === \"header\") {\nreturn InnerCalendar.renderSectionHeader(row);\n} else if (row.item.itemType === \"entryInfo\") {\n- return <Entry entryInfo={row.item.entryInfo} />;\n+ return (\n+ <Entry\n+ entryInfo={row.item.entryInfo}\n+ focused={!!this.state.focusedEntries[entryKey(row.item.entryInfo)]}\n+ onFocus={this.onEntryFocus}\n+ />\n+ );\n} else if (row.item.itemType === \"footer\") {\nreturn this.renderSectionFooter(row);\n}\n@@ -489,8 +505,10 @@ class InnerCalendar extends React.PureComponent {\ngetItemLayout={InnerCalendar.getItemLayout}\nonLayout={this.onListLayout}\nonViewableItemsChanged={this.onViewableItemsChanged}\n+ viewabilityConfig={viewabilityConfig}\nonScroll={this.onScroll}\ninitialNumToRender={this.state.initialNumToRender}\n+ extraData={this.state.focusedEntries}\nstyle={[styles.flatList, flatListStyle]}\nref={this.flatListRef}\n/>\n@@ -546,6 +564,10 @@ class InnerCalendar extends React.PureComponent {\nthis.flatList = flatList;\n}\n+ onEntryFocus = (key: string) => {\n+ this.setState({ focusedEntries: { [key]: true } });\n+ }\n+\nonListLayout = (event: SyntheticEvent) => {\n// This onLayout call should only trigger when the user logs in or starts\n// the app. We wait until now to scroll the calendar FlatList to today\n@@ -572,6 +594,16 @@ class InnerCalendar extends React.PureComponent {\nviewableItems: ViewToken[],\nchanged: ViewToken[],\n}) => {\n+ const viewableEntries = _compact(_map(\n+ (token: ViewToken) => token.item.itemType === \"entryInfo\"\n+ ? entryKey(token.item.entryInfo)\n+ : null,\n+ )(info.viewableItems));\n+ const newFocusedEntries = _pick(viewableEntries)(this.state.focusedEntries);\n+ if (_size(newFocusedEntries) < _size(this.state.focusedEntries)) {\n+ this.setState({ focusedEntries: newFocusedEntries });\n+ }\n+\nif (\n!this.state.readyToShowList ||\nthis.loadingNewEntriesFromScroll ||\n"
},
{
"change_type": "MODIFY",
"old_path": "native/calendar/entry.react.js",
"new_path": "native/calendar/entry.react.js",
"diff": "@@ -28,6 +28,7 @@ import invariant from 'invariant';\nimport shallowequal from 'shallowequal';\nimport _omit from 'lodash/fp/omit';\nimport _isEqual from 'lodash/fp/isEqual';\n+import Icon from 'react-native-vector-icons/FontAwesome';\nimport { colorIsDark } from 'lib/selectors/calendar-selectors';\nimport {\n@@ -47,9 +48,14 @@ import {\nbindServerCalls,\n} from 'lib/utils/action-utils';\nimport { ServerError } from 'lib/utils/fetch-utils';\n+import { entryKey } from 'lib/shared/entry-utils';\n+\n+import { Button } from '../shared-components';\ntype Props = {\nentryInfo: EntryInfoWithHeight,\n+ focused: bool,\n+ onFocus: (entryKey: string) => void,\n// Redux state\ncalendarInfo: CalendarInfo,\nsessionStartingPayload: () => { newSessionID?: string },\n@@ -79,7 +85,6 @@ type Props = {\ntype State = {\ntext: string,\nloadingStatus: LoadingStatus,\n- focused: bool,\nheight: number,\ncolor: string,\n};\n@@ -89,6 +94,8 @@ class Entry extends React.Component {\nstate: State;\nstatic propTypes = {\nentryInfo: entryInfoPropType.isRequired,\n+ focused: PropTypes.bool.isRequired,\n+ onFocus: PropTypes.func.isRequired,\ncalendarInfo: calendarInfoPropType.isRequired,\nsessionStartingPayload: PropTypes.func.isRequired,\nsessionID: PropTypes.func.isRequired,\n@@ -111,7 +118,6 @@ class Entry extends React.Component {\nthis.state = {\ntext: props.entryInfo.text,\nloadingStatus: \"inactive\",\n- focused: false,\nheight: props.entryInfo.textHeight + 10,\n// On log out, it's possible for the calendar to be deauthorized before\n// the log out animation completes. To avoid having rendering issues in\n@@ -123,9 +129,11 @@ class Entry extends React.Component {\ncomponentWillReceiveProps(nextProps: Props) {\nif (\n- !this.state.focused &&\n- nextProps.entryInfo.text !== this.props.entryInfo.text &&\n- nextProps.entryInfo.text !== this.state.text\n+ !this.props.focused &&\n+ (nextProps.entryInfo.text !== this.props.entryInfo.text &&\n+ nextProps.entryInfo.text !== this.state.text) ||\n+ (nextProps.entryInfo.textHeight !== this.props.entryInfo.textHeight &&\n+ nextProps.entryInfo.textHeight !== (this.state.height - 10))\n) {\nthis.setState({\ntext: nextProps.entryInfo.text,\n@@ -138,6 +146,9 @@ class Entry extends React.Component {\n) {\nthis.setState({ color: nextProps.calendarInfo.color });\n}\n+ if (!nextProps.focused && this.props.focused && this.textInput) {\n+ this.textInput.blur();\n+ }\n}\nshouldComponentUpdate(nextProps: Props, nextState: State) {\n@@ -160,18 +171,46 @@ class Entry extends React.Component {\n}\nrender() {\n- const containerStyle = {\n- height: this.state.height + 10,\n- };\n- const entryStyle = {\n- backgroundColor: `#${this.state.color}`,\n- height: this.state.height,\n- };\n- const textColor = colorIsDark(this.state.color) ? 'white' : 'black';\n+ const darkColor = colorIsDark(this.state.color);\n+ let actionLinks = null;\n+ if (this.props.focused) {\n+ const actionLinksColor = darkColor ? '#D3D3D3' : '#808080';\n+ const actionLinksTextStyle = { color: actionLinksColor };\n+ const actionLinksUnderlayColor = darkColor ? \"#AAAAAA88\" : \"#CCCCCCDD\";\n+ actionLinks = (\n+ <View style={styles.actionLinks}>\n+ <Button\n+ onSubmit={this.onPressDelete}\n+ underlayColor={actionLinksUnderlayColor}\n+ style={styles.deleteButton}\n+ >\n+ <View style={styles.deleteButtonContents}>\n+ <Icon\n+ name=\"close\"\n+ size={14}\n+ color={actionLinksColor}\n+ />\n+ <Text style={[styles.actionLinksText, actionLinksTextStyle]}>\n+ DELETE\n+ </Text>\n+ </View>\n+ </Button>\n+ </View>\n+ );\n+ }\n+ const entryStyle = { backgroundColor: `#${this.state.color}` };\n+ const textColor = darkColor ? 'white' : 'black';\nconst textStyle = { color: textColor };\n- const textInputStyle = { color: textColor, height: this.state.height };\n+ const textInputStyle: Object = {\n+ color: textColor,\n+ };\n+ if (this.props.focused) {\n+ textInputStyle.paddingBottom = 0;\n+ } else {\n+ textInputStyle.height = this.state.height;\n+ }\nreturn (\n- <View style={[styles.container, containerStyle]}>\n+ <View style={styles.container}>\n<View style={[styles.entry, entryStyle]}>\n<TextInput\nstyle={[styles.textInput, textInputStyle]}\n@@ -185,6 +224,7 @@ class Entry extends React.Component {\nonChange={this.onChange}\nref={this.textInputRef}\n/>\n+ {actionLinks}\n</View>\n</View>\n);\n@@ -195,11 +235,10 @@ class Entry extends React.Component {\n}\nonFocus = () => {\n- this.setState({ focused: true });\n+ this.props.onFocus(entryKey(this.props.entryInfo));\n}\nonBlur = (event: SyntheticEvent) => {\n- this.setState({ focused: false });\nif (this.state.text.trim() === \"\") {\nthis.delete(this.props.entryInfo.id);\n} else if (this.props.entryInfo.text !== this.state.text) {\n@@ -208,7 +247,7 @@ class Entry extends React.Component {\n}\nonContentSizeChange = (event) => {\n- if (!this.state.focused) {\n+ if (!this.props.focused) {\nreturn;\n}\nlet height = event.nativeEvent.contentSize.height;\n@@ -221,7 +260,7 @@ class Entry extends React.Component {\n// first rendered. Which is like, what? Anyways, instead you're supposed to\n// use onChange.\nonChange = (event) => {\n- if (!this.state.focused) {\n+ if (!this.props.focused) {\nreturn;\n}\nthis.setState({ height: event.nativeEvent.contentSize.height });\n@@ -326,6 +365,10 @@ class Entry extends React.Component {\n}\n}\n+ onPressDelete = () => {\n+ this.delete(this.props.entryInfo.id);\n+ }\n+\ndelete(serverID: ?string) {\nconst startingPayload: {[key: string]: ?string} = {\nlocalID: this.props.entryInfo.localID,\n@@ -376,6 +419,25 @@ const styles = StyleSheet.create({\ncolor: '#333333',\nfontFamily: 'Arial',\n},\n+ actionLinks: {\n+ flex: 1,\n+ flexDirection: 'row',\n+ },\n+ deleteButton: {\n+ paddingLeft: 10,\n+ paddingTop: 5,\n+ paddingBottom: 5,\n+ paddingRight: 10,\n+ },\n+ deleteButtonContents: {\n+ flex: 1,\n+ flexDirection: 'row',\n+ },\n+ actionLinksText: {\n+ paddingLeft: 5,\n+ fontWeight: 'bold',\n+ fontSize: 12,\n+ },\n});\nexport default connect(\n"
},
{
"change_type": "MODIFY",
"old_path": "native/shared-components.js",
"new_path": "native/shared-components.js",
"diff": "@@ -20,12 +20,14 @@ class Button extends React.PureComponent {\nonSubmit: () => void,\ndisabled?: bool,\nstyle?: StyleObj,\n+ underlayColor?: string,\nchildren?: React.Element<any>,\n};\nstatic propTypes = {\nonSubmit: PropTypes.func.isRequired,\ndisabled: PropTypes.bool,\nstyle: ViewPropTypes.style,\n+ underlayColor: PropTypes.string,\nchildren: PropTypes.object,\n};\n@@ -42,11 +44,14 @@ class Button extends React.PureComponent {\n</TouchableNativeFeedback>\n);\n} else {\n+ const underlayColor = this.props.underlayColor\n+ ? this.props.underlayColor\n+ : \"#CCCCCCDD\";\nreturn (\n<TouchableHighlight\nonPress={this.props.onSubmit}\nstyle={this.props.style}\n- underlayColor=\"#CCCCCCDD\"\n+ underlayColor={underlayColor}\ndisabled={!!this.props.disabled}\n>\n{this.props.children}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Add action links and a delete button to the calendar view |
129,187 | 24.05.2017 19:20:16 | 14,400 | bab00751f670ba11e342a382210702796df7874a | Some changes and bugfixes for cross-platform compatability | [
{
"change_type": "MODIFY",
"old_path": "native/calendar/calendar.react.js",
"new_path": "native/calendar/calendar.react.js",
"diff": "@@ -573,9 +573,11 @@ class InnerCalendar extends React.PureComponent {\n// the app. We wait until now to scroll the calendar FlatList to today\n// because FlatList.scrollToItem has some quirky behavior when you call it\n// before layout.\n+ if (!this.state.readyToShowList) {\nthis.scrollToToday(false);\nsetTimeout(() => this.setState({ readyToShowList: true }), 50);\n}\n+ }\nallHeightsMeasured = (\ntextToMeasure: string[],\n"
},
{
"change_type": "MODIFY",
"old_path": "native/calendar/entry.react.js",
"new_path": "native/calendar/entry.react.js",
"diff": "@@ -252,15 +252,15 @@ class Entry extends React.Component {\n}\nlet height = event.nativeEvent.contentSize.height;\n// iOS doesn't include the margin on this callback\n- height = Platform.OS === \"ios\" ? height + 10 : height;\n+ height = Platform.OS === \"ios\" ? height + 10 : height + 5;\nthis.setState({ height });\n}\n- // On around, onContentSizeChange only gets called once when the TextInput is\n+ // On Android, onContentSizeChange only gets called once when the TextInput is\n// first rendered. Which is like, what? Anyways, instead you're supposed to\n// use onChange.\nonChange = (event) => {\n- if (!this.props.focused) {\n+ if (Platform.OS !== \"android\" || !this.props.focused) {\nreturn;\n}\nthis.setState({ height: event.nativeEvent.contentSize.height });\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Some changes and bugfixes for cross-platform compatability |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.