From ab67f6e257f6e8f08145a02a7b93550f99641be4 Mon Sep 17 00:00:00 2001 From: Joram Wilander Date: Sun, 18 Jun 2017 14:42:32 -0400 Subject: PLT-6215 Major post list refactor (#6501) * Major post list refactor * Fix post and thread deletion * Fix preferences not selecting correctly * Fix military time displaying * Fix UP key for editing posts * Fix ESLint error * Various fixes and updates per feedback * Fix for permalink view * Revert to old scrolling method and various fixes * Add floating timestamp, new message indicator, scroll arrows * Update post loading for focus mode and add visibility limit * Fix pinning posts and a react warning * Add loading UI updates from Asaad * Fix refreshing loop * Temporarily bump post visibility limit * Update infinite scrolling * Remove infinite scrolling --- webapp/actions/global_actions.jsx | 54 +++++++++------------------------------ 1 file changed, 12 insertions(+), 42 deletions(-) (limited to 'webapp/actions/global_actions.jsx') diff --git a/webapp/actions/global_actions.jsx b/webapp/actions/global_actions.jsx index a1b178d67..13d74c845 100644 --- a/webapp/actions/global_actions.jsx +++ b/webapp/actions/global_actions.jsx @@ -4,14 +4,13 @@ import AppDispatcher from 'dispatcher/app_dispatcher.jsx'; import ChannelStore from 'stores/channel_store.jsx'; -import PostStore from 'stores/post_store.jsx'; import UserStore from 'stores/user_store.jsx'; import BrowserStore from 'stores/browser_store.jsx'; import ErrorStore from 'stores/error_store.jsx'; import TeamStore from 'stores/team_store.jsx'; import SearchStore from 'stores/search_store.jsx'; -import {handleNewPost, loadPosts, loadPostsBefore, loadPostsAfter} from 'actions/post_actions.jsx'; +import {handleNewPost} from 'actions/post_actions.jsx'; import {loadProfilesForSidebar} from 'actions/user_actions.jsx'; import {loadChannelsForCurrentUser} from 'actions/channel_actions.jsx'; import {stopPeriodicStatusUpdates} from 'actions/status_actions.jsx'; @@ -59,7 +58,6 @@ export function emitChannelClickEvent(channel) { getMyChannelMemberPromise.then(() => { getChannelStats(chan.id)(dispatch, getState); viewChannel(chan.id, oldChannelId)(dispatch, getState); - loadPosts(chan.id); // Mark previous and next channel as read ChannelStore.resetCounts([chan.id, oldChannelId]); @@ -106,10 +104,15 @@ export function doFocusPost(channelId, postId, data) { channelId, post_list: data }); + + dispatch({ + type: ActionTypes.RECEIVED_FOCUSED_POST, + data: postId, + channelId + }); + loadChannelsForCurrentUser(); getChannelStats(channelId)(dispatch, getState); - loadPostsBefore(postId, 0, Constants.POST_FOCUS_CONTEXT_RADIUS, true); - loadPostsAfter(postId, 0, Constants.POST_FOCUS_CONTEXT_RADIUS, true); } export function emitPostFocusEvent(postId, onSuccess) { @@ -148,8 +151,10 @@ export function emitCloseRightHandSide() { SearchStore.storeSearchResults(null, false, false); SearchStore.emitSearchChange(); - PostStore.storeSelectedPostId(null); - PostStore.emitSelectedPostChange(false, false); + dispatch({ + type: ActionTypes.SELECT_POST, + postId: '' + }); } export function emitPostFocusRightHandSideFromSearch(post, isMentionSearch) { @@ -188,29 +193,6 @@ export function emitLeaveTeam() { removeUserFromTeam(TeamStore.getCurrentId(), UserStore.getCurrentId())(dispatch, getState); } -export function emitLoadMorePostsEvent() { - const id = ChannelStore.getCurrentId(); - loadMorePostsTop(id, false); -} - -export function emitLoadMorePostsFocusedTopEvent() { - const id = PostStore.getFocusedPostId(); - loadMorePostsTop(id, true); -} - -export function loadMorePostsTop(id, isFocusPost) { - const earliestPostId = PostStore.getEarliestPostFromPage(id).id; - if (PostStore.requestVisibilityIncrease(id, Constants.POST_CHUNK_SIZE)) { - loadPostsBefore(earliestPostId, 0, Constants.POST_CHUNK_SIZE, isFocusPost); - } -} - -export function emitLoadMorePostsFocusedBottomEvent() { - const id = PostStore.getFocusedPostId(); - const latestPostId = PostStore.getLatestPost(id).id; - loadPostsAfter(latestPostId, 0, Constants.POST_CHUNK_SIZE, Boolean(id)); -} - export function emitUserPostedEvent(post) { AppDispatcher.handleServerAction({ type: ActionTypes.CREATE_POST, @@ -225,13 +207,6 @@ export function emitUserCommentedEvent(post) { }); } -export function emitPostDeletedEvent(post) { - AppDispatcher.handleServerAction({ - type: ActionTypes.POST_DELETED, - post - }); -} - export function showDeletePostModal(post, commentCount = 0) { AppDispatcher.handleViewAction({ type: ActionTypes.TOGGLE_DELETE_POST_MODAL, @@ -421,11 +396,6 @@ export function loadDefaultLocale() { return newLocalizationSelected(locale); } -export function viewLoggedIn() { - // Clear pending posts (shouldn't have pending posts if we are loading) - PostStore.clearPendingPosts(); -} - let lastTimeTypingSent = 0; export function emitLocalUserTypingEvent(channelId, parentId) { const t = Date.now(); -- cgit v1.2.3-1-g7c22