{"action":"created","issue":{"url":"https://api.github.com/repos/mozilla/webmaker-core/issues/402","labels_url":"https://api.github.com/repos/mozilla/webmaker-core/issues/402/labels{/name}","comments_url":"https://api.github.com/repos/mozilla/webmaker-core/issues/402/comments","events_url":"https://api.github.com/repos/mozilla/webmaker-core/issues/402/events","html_url":"https://github.com/mozilla/webmaker-core/pull/402","id":96694184,"number":402,"title":"Change over page and element edits to an offline experience with single bulk sync call on exit","user":{"login":"Pomax","id":177243,"avatar_url":"https://avatars.githubusercontent.com/u/177243?v=3","gravatar_id":"","url":"https://api.github.com/users/Pomax","html_url":"https://github.com/Pomax","followers_url":"https://api.github.com/users/Pomax/followers","following_url":"https://api.github.com/users/Pomax/following{/other_user}","gists_url":"https://api.github.com/users/Pomax/gists{/gist_id}","starred_url":"https://api.github.com/users/Pomax/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Pomax/subscriptions","organizations_url":"https://api.github.com/users/Pomax/orgs","repos_url":"https://api.github.com/users/Pomax/repos","events_url":"https://api.github.com/users/Pomax/events{/privacy}","received_events_url":"https://api.github.com/users/Pomax/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/mozilla/webmaker-core/labels/PR%20Needs%20Work","name":"PR Needs Work","color":"e11d21"}],"state":"open","locked":false,"assignee":{"login":"Pomax","id":177243,"avatar_url":"https://avatars.githubusercontent.com/u/177243?v=3","gravatar_id":"","url":"https://api.github.com/users/Pomax","html_url":"https://github.com/Pomax","followers_url":"https://api.github.com/users/Pomax/followers","following_url":"https://api.github.com/users/Pomax/following{/other_user}","gists_url":"https://api.github.com/users/Pomax/gists{/gist_id}","starred_url":"https://api.github.com/users/Pomax/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Pomax/subscriptions","organizations_url":"https://api.github.com/users/Pomax/orgs","repos_url":"https://api.github.com/users/Pomax/repos","events_url":"https://api.github.com/users/Pomax/events{/privacy}","received_events_url":"https://api.github.com/users/Pomax/received_events","type":"User","site_admin":false},"milestone":null,"comments":6,"created_at":"2015-07-23T00:00:33Z","updated_at":"2015-08-04T23:37:57Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/mozilla/webmaker-core/pulls/402","html_url":"https://github.com/mozilla/webmaker-core/pull/402","diff_url":"https://github.com/mozilla/webmaker-core/pull/402.diff","patch_url":"https://github.com/mozilla/webmaker-core/pull/402.patch"},"body":"This code switches the following page operations from \"routed through api.wmo for every operation\" to a queued modification system, where all modifications are aggregated and then communicated all at once to api.wmo when the page view is left to return to the project view:\r\n\r\n1. element creation\r\n2. element deletion\r\n3. element modification en-place (translation, rotation, zoom)\r\n4. element modification by using the \"edit\" functionality\r\n\r\nThis patch relies on work done in https://github.com/cadecairos/api.webmaker.org/tree/bulk, as well as on https://github.com/pomax/webmaker-android/tree/javaapi. The first for obvious reasons, the second for a Java/JS bridge that allows any view to short-term cache data (keyed by a namespacing string) on the Java side while the app switching out its WebViews, so that the new view can retrieve the cached data and continue working with it. This is specifically used to allow a page to cache the \"to edit\" element on the Java side of our app, so that the Element editor view can then pluck it out of cache, for users to modify. Returning to the Page view then runs the process in reverse, caching the edited element in Java, which the page view can then fetch back out and update itself accordingly.\r\n\r\nDetailed instructions on how this patch can be tested in full can be found in the following gist: https://gist.github.com/Pomax/ef669245d93e3cba4bf4\r\n\r\nThe diagrams of how things work, with java-caching and bulk-save when leaving \"page\" for \"project:\r\n\r\n![page-01](https://cloud.githubusercontent.com/assets/177243/8913276/ec4babbe-344c-11e5-8fdf-17d9f7473cdb.jpg)\r\n\r\nUpdates via the element editor follow the same \"track change, only save as part of pre-leave-bulk-call\" concept, but getting the data into, and out of, the element editor is a little more work:\r\n\r\n![page-2](https://cloud.githubusercontent.com/assets/177243/8913294/0b16f0bc-344d-11e5-8037-8d7995dbc334.jpg)\r\n\r\nUpdates via tinker mode call `save` on the element before changing view to Tinker mode, so tinker mode simply checks java for data in the `edited-element` cache bin, and puts data back as `edit-element` (these correspond to what element.jsx and page.jsx use, too):\r\n\r\n![d2](https://cloud.githubusercontent.com/assets/177243/9016238/43fec3ca-3784-11e5-9566-6580254acd85.jpg)\r\n\r\nUpdates to the `link button` destination can occur in two different ways, one initiated via the link editor, the other via the \"set destination\" button while in page view:\r\n\r\n![destination](https://cloud.githubusercontent.com/assets/177243/9070389/4034794c-3aa4-11e5-876e-1bc005fb4a36.jpg)\r\n"},"comment":{"url":"https://api.github.com/repos/mozilla/webmaker-core/issues/comments/127796980","html_url":"https://github.com/mozilla/webmaker-core/pull/402#issuecomment-127796980","issue_url":"https://api.github.com/repos/mozilla/webmaker-core/issues/402","id":127796980,"user":{"login":"Pomax","id":177243,"avatar_url":"https://avatars.githubusercontent.com/u/177243?v=3","gravatar_id":"","url":"https://api.github.com/users/Pomax","html_url":"https://github.com/Pomax","followers_url":"https://api.github.com/users/Pomax/followers","following_url":"https://api.github.com/users/Pomax/following{/other_user}","gists_url":"https://api.github.com/users/Pomax/gists{/gist_id}","starred_url":"https://api.github.com/users/Pomax/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Pomax/subscriptions","organizations_url":"https://api.github.com/users/Pomax/orgs","repos_url":"https://api.github.com/users/Pomax/repos","events_url":"https://api.github.com/users/Pomax/events{/privacy}","received_events_url":"https://api.github.com/users/Pomax/received_events","type":"User","site_admin":false},"created_at":"2015-08-04T23:37:57Z","updated_at":"2015-08-04T23:37:57Z","body":"The last three commits have modified code so that we only load from DB on `componentDidMount` (which might short-circuit if there's anything in java cache), and loads from java cache on subsequent view loads that are caused by Android switching views due to application logic, or because it suspended the application and then resumed it.\r\n\r\nThe commits, in order, cover the `tinker`, `element` and `page` views respectively. "}}