{"action":"created","issue":{"url":"https://api.github.com/repos/toggl/mobileapp/issues/3176","repository_url":"https://api.github.com/repos/toggl/mobileapp","labels_url":"https://api.github.com/repos/toggl/mobileapp/issues/3176/labels{/name}","comments_url":"https://api.github.com/repos/toggl/mobileapp/issues/3176/comments","events_url":"https://api.github.com/repos/toggl/mobileapp/issues/3176/events","html_url":"https://github.com/toggl/mobileapp/pull/3176","id":357568976,"node_id":"MDExOlB1bGxSZXF1ZXN0MjEzNTUwNTg4","number":3176,"title":"Match realm entities by both id and original id","user":{"login":"amulware","id":3987892,"node_id":"MDQ6VXNlcjM5ODc4OTI=","avatar_url":"https://avatars2.githubusercontent.com/u/3987892?v=4","gravatar_id":"","url":"https://api.github.com/users/amulware","html_url":"https://github.com/amulware","followers_url":"https://api.github.com/users/amulware/followers","following_url":"https://api.github.com/users/amulware/following{/other_user}","gists_url":"https://api.github.com/users/amulware/gists{/gist_id}","starred_url":"https://api.github.com/users/amulware/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amulware/subscriptions","organizations_url":"https://api.github.com/users/amulware/orgs","repos_url":"https://api.github.com/users/amulware/repos","events_url":"https://api.github.com/users/amulware/events{/privacy}","received_events_url":"https://api.github.com/users/amulware/received_events","type":"User","site_admin":false},"labels":[{"id":951697697,"node_id":"MDU6TGFiZWw5NTE2OTc2OTc=","url":"https://api.github.com/repos/toggl/mobileapp/labels/storage","name":"storage","color":"0801ba","default":false},{"id":591497477,"node_id":"MDU6TGFiZWw1OTE0OTc0Nzc=","url":"https://api.github.com/repos/toggl/mobileapp/labels/wip","name":"wip","color":"fbca04","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-09-06T09:24:02Z","updated_at":"2018-09-06T11:13:44Z","closed_at":null,"author_association":"MEMBER","pull_request":{"url":"https://api.github.com/repos/toggl/mobileapp/pulls/3176","html_url":"https://github.com/toggl/mobileapp/pull/3176","diff_url":"https://github.com/toggl/mobileapp/pull/3176.diff","patch_url":"https://github.com/toggl/mobileapp/pull/3176.patch"},"body":"## What's this?\r\nThis fixes any and all bugs that can occur when editing entities while their creation is being synced.\r\n\r\n### Relationships\r\nAlternative to #3172 (we probably DO NOT want both)\r\nCloses #3165\r\n\r\n## Why do we want this?\r\nSo that users can go ahead and edit/delete/whatever their time entries and other entities even if their sync is slow.\r\n\r\n## How is it done?\r\nWe have the original id entity which we already use to resolve references in the `SetPropertiesFrom` methods of realm entities to resolve references. This uses it also when updating entities in the first place.\r\n\r\n*IMPORTANT:*\r\nThis is not done yet. We may also need to make some update to the mentioned `SetPropertiesFrom` methods, since those currently override IDs, which might cause issues (i.e. we would override an id we just got from backend, and then POST the same entity a second time.)\r\n\r\n### Why not another way?\r\nThe alternative (#3172) is listening to id changes of entities we are editing. However, that can still result in race conditions and generally uses more code than this approach. It also needs to be applied to every place where we'll allow editing of entities in the future. This fix here fixes all past and future cases in once.\r\n\r\n### Side effects\r\nThe only problem with this approach is that we're editing untested Realm code. Which is dangerous.\r\n\r\n## Review hints\r\nThis is untested code. We have to be very smart and really think this through before we go ahead.\r\n\r\nAlso, I want at least two approvals, ideally more.\r\n\r\n## :squid: Permissions\r\n@simonrozsival or me."},"comment":{"url":"https://api.github.com/repos/toggl/mobileapp/issues/comments/419056737","html_url":"https://github.com/toggl/mobileapp/pull/3176#issuecomment-419056737","issue_url":"https://api.github.com/repos/toggl/mobileapp/issues/3176","id":419056737,"node_id":"MDEyOklzc3VlQ29tbWVudDQxOTA1NjczNw==","user":{"login":"amulware","id":3987892,"node_id":"MDQ6VXNlcjM5ODc4OTI=","avatar_url":"https://avatars2.githubusercontent.com/u/3987892?v=4","gravatar_id":"","url":"https://api.github.com/users/amulware","html_url":"https://github.com/amulware","followers_url":"https://api.github.com/users/amulware/followers","following_url":"https://api.github.com/users/amulware/following{/other_user}","gists_url":"https://api.github.com/users/amulware/gists{/gist_id}","starred_url":"https://api.github.com/users/amulware/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amulware/subscriptions","organizations_url":"https://api.github.com/users/amulware/orgs","repos_url":"https://api.github.com/users/amulware/repos","events_url":"https://api.github.com/users/amulware/events{/privacy}","received_events_url":"https://api.github.com/users/amulware/received_events","type":"User","site_admin":false},"created_at":"2018-09-06T11:13:44Z","updated_at":"2018-09-06T11:13:44Z","author_association":"MEMBER","body":"See the *IMPORTANT* note above. Maybe I'm wrong about that, but it seems to me that on this branch now, we'd double create entities if we start editing them before the create sync finished, and stop editing them after the create sync finished."}}
{"actor":{"display_login":"amulware"}}