New Idle timer; messages not marked read if user is idle
This commit is contained in:
parent
b77246a7e0
commit
8ccb89310b
11 changed files with 55 additions and 55 deletions
|
@ -61,7 +61,7 @@ type PropsActionsType = {
|
|||
loadOlderMessages: (messageId: string) => unknown;
|
||||
loadNewerMessages: (messageId: string) => unknown;
|
||||
loadNewestMessages: (messageId: string) => unknown;
|
||||
markMessageRead: (messageId: string, forceFocus?: boolean) => unknown;
|
||||
markMessageRead: (messageId: string) => unknown;
|
||||
} & MessageActionsType &
|
||||
SafetyNumberActionsType;
|
||||
|
||||
|
@ -402,7 +402,7 @@ export class Timeline extends React.PureComponent<Props, State> {
|
|||
|
||||
// tslint:disable-next-line member-ordering cyclomatic-complexity
|
||||
public updateWithVisibleRows = debounce(
|
||||
(forceFocus?: boolean) => {
|
||||
() => {
|
||||
const {
|
||||
unreadCount,
|
||||
haveNewest,
|
||||
|
@ -426,7 +426,7 @@ export class Timeline extends React.PureComponent<Props, State> {
|
|||
return;
|
||||
}
|
||||
|
||||
markMessageRead(newest.id, forceFocus);
|
||||
markMessageRead(newest.id);
|
||||
|
||||
const rowCount = this.getRowCount();
|
||||
|
||||
|
@ -710,19 +710,14 @@ export class Timeline extends React.PureComponent<Props, State> {
|
|||
public componentDidMount() {
|
||||
this.updateWithVisibleRows();
|
||||
// @ts-ignore
|
||||
window.registerForFocus(this.forceFocusVisibleRowUpdate);
|
||||
window.registerForActive(this.updateWithVisibleRows);
|
||||
}
|
||||
|
||||
public componentWillUnmount() {
|
||||
// @ts-ignore
|
||||
window.unregisterForFocus(this.forceFocusVisibleRowUpdate);
|
||||
window.unregisterForActive(this.updateWithVisibleRows);
|
||||
}
|
||||
|
||||
public forceFocusVisibleRowUpdate = () => {
|
||||
const forceFocus = true;
|
||||
this.updateWithVisibleRows(forceFocus);
|
||||
};
|
||||
|
||||
// tslint:disable-next-line cyclomatic-complexity max-func-body-length
|
||||
public componentDidUpdate(prevProps: Props) {
|
||||
const {
|
||||
|
|
|
@ -160,7 +160,7 @@ export type MessagesAddedActionType = {
|
|||
conversationId: string;
|
||||
messages: Array<MessageType>;
|
||||
isNewMessage: boolean;
|
||||
isFocused: boolean;
|
||||
isActive: boolean;
|
||||
};
|
||||
};
|
||||
export type MessagesResetActionType = {
|
||||
|
@ -357,7 +357,7 @@ function messagesAdded(
|
|||
conversationId: string,
|
||||
messages: Array<MessageType>,
|
||||
isNewMessage: boolean,
|
||||
isFocused: boolean
|
||||
isActive: boolean
|
||||
): MessagesAddedActionType {
|
||||
return {
|
||||
type: 'MESSAGES_ADDED',
|
||||
|
@ -365,7 +365,7 @@ function messagesAdded(
|
|||
conversationId,
|
||||
messages,
|
||||
isNewMessage,
|
||||
isFocused,
|
||||
isActive,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
@ -870,12 +870,7 @@ export function reducer(
|
|||
};
|
||||
}
|
||||
if (action.type === 'MESSAGES_ADDED') {
|
||||
const {
|
||||
conversationId,
|
||||
isFocused,
|
||||
isNewMessage,
|
||||
messages,
|
||||
} = action.payload;
|
||||
const { conversationId, isActive, isNewMessage, messages } = action.payload;
|
||||
const { messagesByConversation, messagesLookup } = state;
|
||||
|
||||
const existingConversation = messagesByConversation[conversationId];
|
||||
|
@ -937,7 +932,7 @@ export function reducer(
|
|||
const newMessageIds = difference(newIds, existingConversation.messageIds);
|
||||
const { isNearBottom } = existingConversation;
|
||||
|
||||
if ((!isNearBottom || !isFocused) && !oldestUnread) {
|
||||
if ((!isNearBottom || !isActive) && !oldestUnread) {
|
||||
const oldestId = newMessageIds.find(messageId => {
|
||||
const message = lookup[messageId];
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue