Fix out of order posts for admins plus two minor fixes (#6886)

Этот коммит содержится в:
Joram Wilander
2017-07-10 13:58:01 -04:00
коммит произвёл Saturnino Abril
родитель 9a7453e208
Коммит 45e7ad0c34
4 изменённых файлов: 18 добавлений и 11 удалений

Просмотреть файл

@@ -13,7 +13,7 @@ import {getProfilesByIds} from 'mattermost-redux/actions/users';
import * as EmojiActions from 'mattermost-redux/actions/emojis'; import * as EmojiActions from 'mattermost-redux/actions/emojis';
export async function loadEmoji(getProfiles = true) { export async function loadEmoji(getProfiles = true) {
const data = await EmojiActions.getAllCustomEmojis(10000)(dispatch, getState); const data = await EmojiActions.getAllCustomEmojis()(dispatch, getState);
if (data && getProfiles) { if (data && getProfiles) {
loadProfilesForEmoji(data); loadProfilesForEmoji(data);

Просмотреть файл

@@ -104,6 +104,7 @@ export default class PostList extends React.PureComponent {
this.previousScrollTop = Number.MAX_SAFE_INTEGER; this.previousScrollTop = Number.MAX_SAFE_INTEGER;
this.previousScrollHeight = 0; this.previousScrollHeight = 0;
this.previousClientHeight = 0; this.previousClientHeight = 0;
this.atBottom = false;
this.state = { this.state = {
atEnd: false, atEnd: false,
@@ -144,6 +145,7 @@ export default class PostList extends React.PureComponent {
this.hasScrolled = false; this.hasScrolled = false;
this.hasScrolledToFocusedPost = false; this.hasScrolledToFocusedPost = false;
this.hasScrolledToNewMessageSeparator = false; this.hasScrolledToNewMessageSeparator = false;
this.atBottom = false;
this.setState({atEnd: false}); this.setState({atEnd: false});
if (nextChannel.id) { if (nextChannel.id) {
@@ -152,7 +154,7 @@ export default class PostList extends React.PureComponent {
return; return;
} }
if (!this.wasAtBottom() && this.props.posts !== nextProps.posts && this.hasScrolledToNewMessageSeparator) { if (!this.atBottom && this.props.posts !== nextProps.posts && this.hasScrolledToNewMessageSeparator) {
const unViewedCount = nextProps.posts.reduce((count, post) => { const unViewedCount = nextProps.posts.reduce((count, post) => {
if (post.create_at > this.state.lastViewed && if (post.create_at > this.state.lastViewed &&
post.user_id !== nextProps.currentUserId && post.user_id !== nextProps.currentUserId &&
@@ -206,6 +208,7 @@ export default class PostList extends React.PureComponent {
return; return;
} else if (postList && !this.hasScrolledToNewMessageSeparator) { } else if (postList && !this.hasScrolledToNewMessageSeparator) {
postList.scrollTop = postList.scrollHeight; postList.scrollTop = postList.scrollHeight;
this.atBottom = true;
return; return;
} }
@@ -218,7 +221,7 @@ export default class PostList extends React.PureComponent {
const pendingPostId = posts[0].pending_post_id; const pendingPostId = posts[0].pending_post_id;
if (postId !== prevPostId && pendingPostId !== prevPostId) { if (postId !== prevPostId && pendingPostId !== prevPostId) {
// If already scrolled to bottom // If already scrolled to bottom
if (this.wasAtBottom()) { if (this.atBottom) {
doScrollToBottom = true; doScrollToBottom = true;
} }
@@ -229,6 +232,7 @@ export default class PostList extends React.PureComponent {
} }
if (doScrollToBottom) { if (doScrollToBottom) {
this.atBottom = true;
postList.scrollTop = postList.scrollHeight; postList.scrollTop = postList.scrollHeight;
return; return;
} }
@@ -246,13 +250,13 @@ export default class PostList extends React.PureComponent {
}); });
} }
wasAtBottom = () => { checkBottom = () => {
return this.previousClientHeight + this.previousScrollTop >= this.previousScrollHeight - CLOSE_TO_BOTTOM_SCROLL_MARGIN; return this.refs.postlist.clientHeight + this.refs.postlist.scrollTop >= this.refs.postlist.scrollHeight - CLOSE_TO_BOTTOM_SCROLL_MARGIN;
} }
handleResize = (forceScrollToBottom) => { handleResize = (forceScrollToBottom) => {
const postList = this.refs.postlist; const postList = this.refs.postlist;
const doScrollToBottom = this.wasAtBottom() || forceScrollToBottom; const doScrollToBottom = this.atBottom || forceScrollToBottom;
if (postList && doScrollToBottom) { if (postList && doScrollToBottom) {
postList.scrollTop = postList.scrollHeight; postList.scrollTop = postList.scrollHeight;
@@ -298,6 +302,9 @@ export default class PostList extends React.PureComponent {
handleScroll = () => { handleScroll = () => {
this.hasScrolled = true; this.hasScrolled = true;
this.previousScrollTop = this.refs.postlist.scrollTop; this.previousScrollTop = this.refs.postlist.scrollTop;
if (this.refs.postlist.scrollHeight === this.previousScrollHeight) {
this.atBottom = this.checkBottom();
}
this.updateFloatingTimestamp(); this.updateFloatingTimestamp();
@@ -307,7 +314,7 @@ export default class PostList extends React.PureComponent {
}); });
} }
if (this.wasAtBottom()) { if (this.atBottom) {
this.setState({ this.setState({
lastViewed: new Date().getTime(), lastViewed: new Date().getTime(),
unViewedCount: 0, unViewedCount: 0,
@@ -509,7 +516,7 @@ export default class PostList extends React.PureComponent {
/> />
<ScrollToBottomArrows <ScrollToBottomArrows
isScrolling={this.state.isScrolling} isScrolling={this.state.isScrolling}
atBottom={this.wasAtBottom()} atBottom={this.atBottom}
onClick={this.scrollToBottom} onClick={this.scrollToBottom}
/> />
<NewMessageIndicator <NewMessageIndicator

Просмотреть файл

@@ -24,7 +24,7 @@
"localforage": "1.5.0", "localforage": "1.5.0",
"marked": "mattermost/marked#8f5902fff9bad793cd6c66e0c44002c9e79e1317", "marked": "mattermost/marked#8f5902fff9bad793cd6c66e0c44002c9e79e1317",
"match-at": "0.1.0", "match-at": "0.1.0",
"mattermost-redux": "mattermost/mattermost-redux#webapp-master", "mattermost-redux": "mattermost/mattermost-redux#webapp-4.0",
"object-assign": "4.1.1", "object-assign": "4.1.1",
"pdfjs-dist": "1.8.474", "pdfjs-dist": "1.8.474",
"perfect-scrollbar": "0.7.1", "perfect-scrollbar": "0.7.1",

Просмотреть файл

@@ -5041,9 +5041,9 @@ math-expression-evaluator@^1.2.14:
version "1.2.16" version "1.2.16"
resolved "https://registry.yarnpkg.com/math-expression-evaluator/-/math-expression-evaluator-1.2.16.tgz#b357fa1ca9faefb8e48d10c14ef2bcb2d9f0a7c9" resolved "https://registry.yarnpkg.com/math-expression-evaluator/-/math-expression-evaluator-1.2.16.tgz#b357fa1ca9faefb8e48d10c14ef2bcb2d9f0a7c9"
mattermost-redux@mattermost/mattermost-redux#webapp-master: mattermost-redux@mattermost/mattermost-redux#webapp-4.0:
version "0.0.1" version "0.0.1"
resolved "https://codeload.github.com/mattermost/mattermost-redux/tar.gz/b4bab66d36f10ace06bcd3243d68807bfbca9c48" resolved "https://codeload.github.com/mattermost/mattermost-redux/tar.gz/cb3aee571a78c835ed0ff5629114e05fce41a5f5"
dependencies: dependencies:
deep-equal "1.0.1" deep-equal "1.0.1"
harmony-reflect "1.5.1" harmony-reflect "1.5.1"