{"action":"closed","number":3504,"pull_request":{"url":"https://api.github.com/repos/status-im/status-react/pulls/3504","id":172386404,"html_url":"https://github.com/status-im/status-react/pull/3504","diff_url":"https://github.com/status-im/status-react/pull/3504.diff","patch_url":"https://github.com/status-im/status-react/pull/3504.patch","issue_url":"https://api.github.com/repos/status-im/status-react/issues/3504","number":3504,"state":"closed","locked":false,"title":"Bug/message ordering #2699","user":{"login":"janherich","id":1910609,"avatar_url":"https://avatars1.githubusercontent.com/u/1910609?v=4","gravatar_id":"","url":"https://api.github.com/users/janherich","html_url":"https://github.com/janherich","followers_url":"https://api.github.com/users/janherich/followers","following_url":"https://api.github.com/users/janherich/following{/other_user}","gists_url":"https://api.github.com/users/janherich/gists{/gist_id}","starred_url":"https://api.github.com/users/janherich/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/janherich/subscriptions","organizations_url":"https://api.github.com/users/janherich/orgs","repos_url":"https://api.github.com/users/janherich/repos","events_url":"https://api.github.com/users/janherich/events{/privacy}","received_events_url":"https://api.github.com/users/janherich/received_events","type":"User","site_admin":false},"body":"[comment]: # (Please replace ... with your information. Remove < and >)\r\n[comment]: # (To auto-close issue on merge, please insert the related issue number after # i.e fixes #566)\r\n\r\nfixes #2699 \r\n\r\n### Summary:\r\n\r\n[comment]: # (Summarise the problem and how the pull request solves it)\r\nThis PR implements work already done in `experiment/new-protocol-app` branch, definitely fixing message ordering in 1-1 chats. It's little bit more tricky for group chats, where it's still the old \"the messages are displayed in order they arrive\".\r\n\r\nDescription of the clock logic implemented in this PR (relevant only for 1-1 chats):\r\n\r\nWe start with [0 0] ([`from-clock-value` `to-clock-value`]) for each participant of 1-1 chat (local perspective on each device).\r\nNow for sending, we always increment the `to-clock-value` and include it in message payload being sent (so only `to-clock-value` is present in network message).\r\nLocally, the sent message always replicates the `latest-from-clock-value` of the chat.\r\nUpon receiving message, receiver reads the `to-clock-value` of the received message and sets that to be the `from-clock-value` locally (this will be also the new `latest-from-clock-value` of the chat), `to-clock-value` for the message is the `latest-to-clock-value` of the 1-1 chat`. \r\n\r\nAll this ensures, that there will be no [`from-clock-value` `to-clock-value`] duplicate in chat message on each device + the local order will appear consistent, even if it’s possible it won’t be the same on both devices (for example user A sends 5 messages, during the sending, he receives the message from user B, so his local order will be `A1, A2, B, A3, A4, A5`, but his messages will take a long time to reach user B, for some reason, so user B will see it as `B, A1, A2, A3, A4, A5`).\r\nI don’t think that’s very problematic and I don’t think we can do much about it without single source of truth where order received messages are serialised and definite order is established (server), it is the case even in the current implementation.\r\n\r\n### Testing notes (optional):\r\nTest the scenario described in the ticket + make sure that standard messaging in all types of chats work correctly (though it's not necessary to test all message types, commands/requests are unaffected, so testing with plain text messages is fully sufficient).\r\nEventually, we will need to support migration from previous versions, that doesn't currently work (old messages already in app before migration will have no definite order, only the new created after migration), opening it either way, as it's high priority to have this working in nightly build by offsite (and I will probably add migrations tomorrow).\r\n\r\nstatus: ready\r\n","created_at":"2018-03-01T23:46:25Z","updated_at":"2018-03-04T18:32:47Z","closed_at":"2018-03-04T18:32:46Z","merged_at":"2018-03-04T18:32:46Z","merge_commit_sha":"7efcdcb15046c6b6fdfa2d03965a3af00fb9c5a7","assignee":{"login":"janherich","id":1910609,"avatar_url":"https://avatars1.githubusercontent.com/u/1910609?v=4","gravatar_id":"","url":"https://api.github.com/users/janherich","html_url":"https://github.com/janherich","followers_url":"https://api.github.com/users/janherich/followers","following_url":"https://api.github.com/users/janherich/following{/other_user}","gists_url":"https://api.github.com/users/janherich/gists{/gist_id}","starred_url":"https://api.github.com/users/janherich/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/janherich/subscriptions","organizations_url":"https://api.github.com/users/janherich/orgs","repos_url":"https://api.github.com/users/janherich/repos","events_url":"https://api.github.com/users/janherich/events{/privacy}","received_events_url":"https://api.github.com/users/janherich/received_events","type":"User","site_admin":false},"assignees":[{"login":"janherich","id":1910609,"avatar_url":"https://avatars1.githubusercontent.com/u/1910609?v=4","gravatar_id":"","url":"https://api.github.com/users/janherich","html_url":"https://github.com/janherich","followers_url":"https://api.github.com/users/janherich/followers","following_url":"https://api.github.com/users/janherich/following{/other_user}","gists_url":"https://api.github.com/users/janherich/gists{/gist_id}","starred_url":"https://api.github.com/users/janherich/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/janherich/subscriptions","organizations_url":"https://api.github.com/users/janherich/orgs","repos_url":"https://api.github.com/users/janherich/repos","events_url":"https://api.github.com/users/janherich/events{/privacy}","received_events_url":"https://api.github.com/users/janherich/received_events","type":"User","site_admin":false},{"login":"annadanchenko","id":6584810,"avatar_url":"https://avatars0.githubusercontent.com/u/6584810?v=4","gravatar_id":"","url":"https://api.github.com/users/annadanchenko","html_url":"https://github.com/annadanchenko","followers_url":"https://api.github.com/users/annadanchenko/followers","following_url":"https://api.github.com/users/annadanchenko/following{/other_user}","gists_url":"https://api.github.com/users/annadanchenko/gists{/gist_id}","starred_url":"https://api.github.com/users/annadanchenko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/annadanchenko/subscriptions","organizations_url":"https://api.github.com/users/annadanchenko/orgs","repos_url":"https://api.github.com/users/annadanchenko/repos","events_url":"https://api.github.com/users/annadanchenko/events{/privacy}","received_events_url":"https://api.github.com/users/annadanchenko/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":613726715,"url":"https://api.github.com/repos/status-im/status-react/labels/Tested%20-%20Issues","name":"Tested - Issues","color":"d93f0b","default":false},{"id":523025415,"url":"https://api.github.com/repos/status-im/status-react/labels/bounty","name":"bounty","color":"FAFAD2","default":false},{"id":330296931,"url":"https://api.github.com/repos/status-im/status-react/labels/bug","name":"bug","color":"fc2929","default":true},{"id":763512954,"url":"https://api.github.com/repos/status-im/status-react/labels/fix%20them%20all","name":"fix them all","color":"472aaf","default":false},{"id":517247009,"url":"https://api.github.com/repos/status-im/status-react/labels/high-priority","name":"high-priority","color":"000000","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/status-im/status-react/pulls/3504/commits","review_comments_url":"https://api.github.com/repos/status-im/status-react/pulls/3504/comments","review_comment_url":"https://api.github.com/repos/status-im/status-react/pulls/comments{/number}","comments_url":"https://api.github.com/repos/status-im/status-react/issues/3504/comments","statuses_url":"https://api.github.com/repos/status-im/status-react/statuses/7efcdcb15046c6b6fdfa2d03965a3af00fb9c5a7","head":{"label":"status-im:bug/message-ordering-#2699","ref":"bug/message-ordering-#2699","sha":"7efcdcb15046c6b6fdfa2d03965a3af00fb9c5a7","user":{"login":"status-im","id":11767950,"avatar_url":"https://avatars1.githubusercontent.com/u/11767950?v=4","gravatar_id":"","url":"https://api.github.com/users/status-im","html_url":"https://github.com/status-im","followers_url":"https://api.github.com/users/status-im/followers","following_url":"https://api.github.com/users/status-im/following{/other_user}","gists_url":"https://api.github.com/users/status-im/gists{/gist_id}","starred_url":"https://api.github.com/users/status-im/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/status-im/subscriptions","organizations_url":"https://api.github.com/users/status-im/orgs","repos_url":"https://api.github.com/users/status-im/repos","events_url":"https://api.github.com/users/status-im/events{/privacy}","received_events_url":"https://api.github.com/users/status-im/received_events","type":"Organization","site_admin":false},"repo":{"id":52308441,"name":"status-react","full_name":"status-im/status-react","owner":{"login":"status-im","id":11767950,"avatar_url":"https://avatars1.githubusercontent.com/u/11767950?v=4","gravatar_id":"","url":"https://api.github.com/users/status-im","html_url":"https://github.com/status-im","followers_url":"https://api.github.com/users/status-im/followers","following_url":"https://api.github.com/users/status-im/following{/other_user}","gists_url":"https://api.github.com/users/status-im/gists{/gist_id}","starred_url":"https://api.github.com/users/status-im/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/status-im/subscriptions","organizations_url":"https://api.github.com/users/status-im/orgs","repos_url":"https://api.github.com/users/status-im/repos","events_url":"https://api.github.com/users/status-im/events{/privacy}","received_events_url":"https://api.github.com/users/status-im/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/status-im/status-react","description":"a free (libre) open source, mobile OS for Ethereum","fork":false,"url":"https://api.github.com/repos/status-im/status-react","forks_url":"https://api.github.com/repos/status-im/status-react/forks","keys_url":"https://api.github.com/repos/status-im/status-react/keys{/key_id}","collaborators_url":"https://api.github.com/repos/status-im/status-react/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/status-im/status-react/teams","hooks_url":"https://api.github.com/repos/status-im/status-react/hooks","issue_events_url":"https://api.github.com/repos/status-im/status-react/issues/events{/number}","events_url":"https://api.github.com/repos/status-im/status-react/events","assignees_url":"https://api.github.com/repos/status-im/status-react/assignees{/user}","branches_url":"https://api.github.com/repos/status-im/status-react/branches{/branch}","tags_url":"https://api.github.com/repos/status-im/status-react/tags","blobs_url":"https://api.github.com/repos/status-im/status-react/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/status-im/status-react/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/status-im/status-react/git/refs{/sha}","trees_url":"https://api.github.com/repos/status-im/status-react/git/trees{/sha}","statuses_url":"https://api.github.com/repos/status-im/status-react/statuses/{sha}","languages_url":"https://api.github.com/repos/status-im/status-react/languages","stargazers_url":"https://api.github.com/repos/status-im/status-react/stargazers","contributors_url":"https://api.github.com/repos/status-im/status-react/contributors","subscribers_url":"https://api.github.com/repos/status-im/status-react/subscribers","subscription_url":"https://api.github.com/repos/status-im/status-react/subscription","commits_url":"https://api.github.com/repos/status-im/status-react/commits{/sha}","git_commits_url":"https://api.github.com/repos/status-im/status-react/git/commits{/sha}","comments_url":"https://api.github.com/repos/status-im/status-react/comments{/number}","issue_comment_url":"https://api.github.com/repos/status-im/status-react/issues/comments{/number}","contents_url":"https://api.github.com/repos/status-im/status-react/contents/{+path}","compare_url":"https://api.github.com/repos/status-im/status-react/compare/{base}...{head}","merges_url":"https://api.github.com/repos/status-im/status-react/merges","archive_url":"https://api.github.com/repos/status-im/status-react/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/status-im/status-react/downloads","issues_url":"https://api.github.com/repos/status-im/status-react/issues{/number}","pulls_url":"https://api.github.com/repos/status-im/status-react/pulls{/number}","milestones_url":"https://api.github.com/repos/status-im/status-react/milestones{/number}","notifications_url":"https://api.github.com/repos/status-im/status-react/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/status-im/status-react/labels{/name}","releases_url":"https://api.github.com/repos/status-im/status-react/releases{/id}","deployments_url":"https://api.github.com/repos/status-im/status-react/deployments","created_at":"2016-02-22T21:48:48Z","updated_at":"2018-03-04T16:45:36Z","pushed_at":"2018-03-04T18:32:43Z","git_url":"git://github.com/status-im/status-react.git","ssh_url":"git@github.com:status-im/status-react.git","clone_url":"https://github.com/status-im/status-react.git","svn_url":"https://github.com/status-im/status-react","homepage":"https://status.im","size":51732,"stargazers_count":2028,"watchers_count":2028,"language":"Clojure","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":485,"mirror_url":null,"archived":false,"open_issues_count":568,"license":{"key":"mpl-2.0","name":"Mozilla Public License 2.0","spdx_id":"MPL-2.0","url":"https://api.github.com/licenses/mpl-2.0"},"forks":485,"open_issues":568,"watchers":2028,"default_branch":"develop"}},"base":{"label":"status-im:develop","ref":"develop","sha":"54546204ae18bd7fbe9b85b1b847db915efe7ead","user":{"login":"status-im","id":11767950,"avatar_url":"https://avatars1.githubusercontent.com/u/11767950?v=4","gravatar_id":"","url":"https://api.github.com/users/status-im","html_url":"https://github.com/status-im","followers_url":"https://api.github.com/users/status-im/followers","following_url":"https://api.github.com/users/status-im/following{/other_user}","gists_url":"https://api.github.com/users/status-im/gists{/gist_id}","starred_url":"https://api.github.com/users/status-im/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/status-im/subscriptions","organizations_url":"https://api.github.com/users/status-im/orgs","repos_url":"https://api.github.com/users/status-im/repos","events_url":"https://api.github.com/users/status-im/events{/privacy}","received_events_url":"https://api.github.com/users/status-im/received_events","type":"Organization","site_admin":false},"repo":{"id":52308441,"name":"status-react","full_name":"status-im/status-react","owner":{"login":"status-im","id":11767950,"avatar_url":"https://avatars1.githubusercontent.com/u/11767950?v=4","gravatar_id":"","url":"https://api.github.com/users/status-im","html_url":"https://github.com/status-im","followers_url":"https://api.github.com/users/status-im/followers","following_url":"https://api.github.com/users/status-im/following{/other_user}","gists_url":"https://api.github.com/users/status-im/gists{/gist_id}","starred_url":"https://api.github.com/users/status-im/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/status-im/subscriptions","organizations_url":"https://api.github.com/users/status-im/orgs","repos_url":"https://api.github.com/users/status-im/repos","events_url":"https://api.github.com/users/status-im/events{/privacy}","received_events_url":"https://api.github.com/users/status-im/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/status-im/status-react","description":"a free (libre) open source, mobile OS for Ethereum","fork":false,"url":"https://api.github.com/repos/status-im/status-react","forks_url":"https://api.github.com/repos/status-im/status-react/forks","keys_url":"https://api.github.com/repos/status-im/status-react/keys{/key_id}","collaborators_url":"https://api.github.com/repos/status-im/status-react/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/status-im/status-react/teams","hooks_url":"https://api.github.com/repos/status-im/status-react/hooks","issue_events_url":"https://api.github.com/repos/status-im/status-react/issues/events{/number}","events_url":"https://api.github.com/repos/status-im/status-react/events","assignees_url":"https://api.github.com/repos/status-im/status-react/assignees{/user}","branches_url":"https://api.github.com/repos/status-im/status-react/branches{/branch}","tags_url":"https://api.github.com/repos/status-im/status-react/tags","blobs_url":"https://api.github.com/repos/status-im/status-react/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/status-im/status-react/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/status-im/status-react/git/refs{/sha}","trees_url":"https://api.github.com/repos/status-im/status-react/git/trees{/sha}","statuses_url":"https://api.github.com/repos/status-im/status-react/statuses/{sha}","languages_url":"https://api.github.com/repos/status-im/status-react/languages","stargazers_url":"https://api.github.com/repos/status-im/status-react/stargazers","contributors_url":"https://api.github.com/repos/status-im/status-react/contributors","subscribers_url":"https://api.github.com/repos/status-im/status-react/subscribers","subscription_url":"https://api.github.com/repos/status-im/status-react/subscription","commits_url":"https://api.github.com/repos/status-im/status-react/commits{/sha}","git_commits_url":"https://api.github.com/repos/status-im/status-react/git/commits{/sha}","comments_url":"https://api.github.com/repos/status-im/status-react/comments{/number}","issue_comment_url":"https://api.github.com/repos/status-im/status-react/issues/comments{/number}","contents_url":"https://api.github.com/repos/status-im/status-react/contents/{+path}","compare_url":"https://api.github.com/repos/status-im/status-react/compare/{base}...{head}","merges_url":"https://api.github.com/repos/status-im/status-react/merges","archive_url":"https://api.github.com/repos/status-im/status-react/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/status-im/status-react/downloads","issues_url":"https://api.github.com/repos/status-im/status-react/issues{/number}","pulls_url":"https://api.github.com/repos/status-im/status-react/pulls{/number}","milestones_url":"https://api.github.com/repos/status-im/status-react/milestones{/number}","notifications_url":"https://api.github.com/repos/status-im/status-react/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/status-im/status-react/labels{/name}","releases_url":"https://api.github.com/repos/status-im/status-react/releases{/id}","deployments_url":"https://api.github.com/repos/status-im/status-react/deployments","created_at":"2016-02-22T21:48:48Z","updated_at":"2018-03-04T16:45:36Z","pushed_at":"2018-03-04T18:32:43Z","git_url":"git://github.com/status-im/status-react.git","ssh_url":"git@github.com:status-im/status-react.git","clone_url":"https://github.com/status-im/status-react.git","svn_url":"https://github.com/status-im/status-react","homepage":"https://status.im","size":51732,"stargazers_count":2028,"watchers_count":2028,"language":"Clojure","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":485,"mirror_url":null,"archived":false,"open_issues_count":568,"license":{"key":"mpl-2.0","name":"Mozilla Public License 2.0","spdx_id":"MPL-2.0","url":"https://api.github.com/licenses/mpl-2.0"},"forks":485,"open_issues":568,"watchers":2028,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/status-im/status-react/pulls/3504"},"html":{"href":"https://github.com/status-im/status-react/pull/3504"},"issue":{"href":"https://api.github.com/repos/status-im/status-react/issues/3504"},"comments":{"href":"https://api.github.com/repos/status-im/status-react/issues/3504/comments"},"review_comments":{"href":"https://api.github.com/repos/status-im/status-react/pulls/3504/comments"},"review_comment":{"href":"https://api.github.com/repos/status-im/status-react/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/status-im/status-react/pulls/3504/commits"},"statuses":{"href":"https://api.github.com/repos/status-im/status-react/statuses/7efcdcb15046c6b6fdfa2d03965a3af00fb9c5a7"}},"author_association":"MEMBER","merged":true,"mergeable":null,"rebaseable":null,"mergeable_state":"unknown","merged_by":{"login":"janherich","id":1910609,"avatar_url":"https://avatars1.githubusercontent.com/u/1910609?v=4","gravatar_id":"","url":"https://api.github.com/users/janherich","html_url":"https://github.com/janherich","followers_url":"https://api.github.com/users/janherich/followers","following_url":"https://api.github.com/users/janherich/following{/other_user}","gists_url":"https://api.github.com/users/janherich/gists{/gist_id}","starred_url":"https://api.github.com/users/janherich/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/janherich/subscriptions","organizations_url":"https://api.github.com/users/janherich/orgs","repos_url":"https://api.github.com/users/janherich/repos","events_url":"https://api.github.com/users/janherich/events{/privacy}","received_events_url":"https://api.github.com/users/janherich/received_events","type":"User","site_admin":false},"comments":11,"review_comments":0,"maintainer_can_modify":false,"commits":1,"additions":254,"deletions":122,"changed_files":11}}
{"actor":{"display_login":"janherich"}}