From cac086ae22c1525f12c1e8d28393b894aa34fd1e Mon Sep 17 00:00:00 2001 From: JoramWilander Date: Thu, 11 Feb 2016 09:22:57 -0500 Subject: Fixing the elusive missing post bug --- web/react/utils/async_client.jsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'web/react/utils') diff --git a/web/react/utils/async_client.jsx b/web/react/utils/async_client.jsx index c8676f45d..c2b5fe9e5 100644 --- a/web/react/utils/async_client.jsx +++ b/web/react/utils/async_client.jsx @@ -521,18 +521,18 @@ export function getPosts(id) { return; } - if (PostStore.getAllPosts(channelId) == null) { + if ($.isEmptyObject(PostStore.getAllPosts(channelId))) { getPostsPage(channelId, Constants.POST_CHUNK_SIZE); return; } - const latestUpdate = PostStore.getLatestUpdate(channelId); + const latestPost = PostStore.getLatestPost(channelId); callTracker['getPosts_' + channelId] = utils.getTimestamp(); client.getPosts( channelId, - latestUpdate, + latestPost.update_at, (data, textStatus, xhr) => { if (xhr.status === 304 || !data) { return; -- cgit v1.2.3-1-g7c22 From 2747a99aef5a8c1b6f41222451451c1153cd7079 Mon Sep 17 00:00:00 2001 From: JoramWilander Date: Thu, 11 Feb 2016 10:52:12 -0500 Subject: Fix case where channel has a postlist but no posts --- web/react/utils/async_client.jsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'web/react/utils') diff --git a/web/react/utils/async_client.jsx b/web/react/utils/async_client.jsx index c2b5fe9e5..977fa8e7e 100644 --- a/web/react/utils/async_client.jsx +++ b/web/react/utils/async_client.jsx @@ -527,12 +527,17 @@ export function getPosts(id) { } const latestPost = PostStore.getLatestPost(channelId); + let latestPostTime = 0; + + if (latestPost != null && latestPost.update_at != null) { + latestPostTime = latestPost.update_at; + } callTracker['getPosts_' + channelId] = utils.getTimestamp(); client.getPosts( channelId, - latestPost.update_at, + latestPostTime, (data, textStatus, xhr) => { if (xhr.status === 304 || !data) { return; -- cgit v1.2.3-1-g7c22 From c5b2e8832cfa10fd425f493ad3259f0fa547d6b5 Mon Sep 17 00:00:00 2001 From: JoramWilander Date: Thu, 11 Feb 2016 12:52:01 -0500 Subject: If we have less than CHUNK_SIZE posts, then get the first page --- web/react/utils/async_client.jsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'web/react/utils') diff --git a/web/react/utils/async_client.jsx b/web/react/utils/async_client.jsx index 977fa8e7e..dc8013a6b 100644 --- a/web/react/utils/async_client.jsx +++ b/web/react/utils/async_client.jsx @@ -521,7 +521,9 @@ export function getPosts(id) { return; } - if ($.isEmptyObject(PostStore.getAllPosts(channelId))) { + const postList = PostStore.getAllPosts(channelId); + + if ($.isEmptyObject(postList) || postList.order.length < Constants.POST_CHUNK_SIZE) { getPostsPage(channelId, Constants.POST_CHUNK_SIZE); return; } -- cgit v1.2.3-1-g7c22 From 3a1ec7dbd76ecad556cca0cee54f574bf813c1fd Mon Sep 17 00:00:00 2001 From: JoramWilander Date: Thu, 11 Feb 2016 13:17:59 -0500 Subject: Switch to using create_at for latest post --- web/react/utils/async_client.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'web/react/utils') diff --git a/web/react/utils/async_client.jsx b/web/react/utils/async_client.jsx index dc8013a6b..45cdf699f 100644 --- a/web/react/utils/async_client.jsx +++ b/web/react/utils/async_client.jsx @@ -532,7 +532,7 @@ export function getPosts(id) { let latestPostTime = 0; if (latestPost != null && latestPost.update_at != null) { - latestPostTime = latestPost.update_at; + latestPostTime = latestPost.create_at; } callTracker['getPosts_' + channelId] = utils.getTimestamp(); -- cgit v1.2.3-1-g7c22 From b0252c9aa91ff9382600cd0cb66b69530f080941 Mon Sep 17 00:00:00 2001 From: Elias Nahum Date: Thu, 11 Feb 2016 16:29:52 -0300 Subject: Fix duplicate am/pm on last password update --- web/react/utils/utils.jsx | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'web/react/utils') diff --git a/web/react/utils/utils.jsx b/web/react/utils/utils.jsx index e2a5b9620..9880f252b 100644 --- a/web/react/utils/utils.jsx +++ b/web/react/utils/utils.jsx @@ -260,6 +260,10 @@ export function displayTimeFormatted(ticks) { ); } +export function useMilitaryTime() { + return PreferenceStore.getBool(Constants.Preferences.CATEGORY_DISPLAY_SETTINGS, 'use_military_time'); +} + export function displayDateTime(ticks) { var seconds = Math.floor((Date.now() - ticks) / 1000); -- cgit v1.2.3-1-g7c22 From ae8c67365de589238066237c667f5132ced13087 Mon Sep 17 00:00:00 2001 From: Elias Nahum Date: Thu, 11 Feb 2016 16:46:46 -0300 Subject: eslint no-shadow resolved --- web/react/utils/utils.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'web/react/utils') diff --git a/web/react/utils/utils.jsx b/web/react/utils/utils.jsx index 9880f252b..7f124149d 100644 --- a/web/react/utils/utils.jsx +++ b/web/react/utils/utils.jsx @@ -260,7 +260,7 @@ export function displayTimeFormatted(ticks) { ); } -export function useMilitaryTime() { +export function isMilitaryTime() { return PreferenceStore.getBool(Constants.Preferences.CATEGORY_DISPLAY_SETTINGS, 'use_military_time'); } -- cgit v1.2.3-1-g7c22