1.44 fixes (#5444)
* fix: get status as soon as appstate is in the foreground * re-render post list when theme changes * remove invalid userIds from get status request
This commit is contained in:
parent
8894ee464f
commit
6335932883
6 changed files with 24 additions and 18 deletions
|
|
@ -24,7 +24,7 @@ type Props = {
|
|||
initWebSocket: (additionalOptions: {forceConnection: boolean}) => void;
|
||||
markChannelViewedAndReadOnReconnect: (channelId: string) => void;
|
||||
setCurrentUserStatusOffline: () => void;
|
||||
startPeriodicStatusUpdates: () => void;
|
||||
startPeriodicStatusUpdates: (forceStatusUpdate: boolean) => void;
|
||||
status: string;
|
||||
stopPeriodicStatusUpdates: () => void;
|
||||
}
|
||||
|
|
@ -142,7 +142,7 @@ const NetworkIndicator = ({
|
|||
const handleWebSocket = (connect: boolean) => {
|
||||
if (connect) {
|
||||
initWebSocket({forceConnection: true});
|
||||
startPeriodicStatusUpdates();
|
||||
startPeriodicStatusUpdates(true);
|
||||
} else {
|
||||
closeWebSocket(true);
|
||||
stopPeriodicStatusUpdates();
|
||||
|
|
|
|||
|
|
@ -217,7 +217,7 @@ const PostList = ({
|
|||
{...postProps}
|
||||
/>
|
||||
);
|
||||
}, [postIds]);
|
||||
}, [postIds, theme]);
|
||||
|
||||
const scrollToIndex = useCallback((index: number, animated = true) => {
|
||||
flatListRef.current?.scrollToIndex({
|
||||
|
|
|
|||
|
|
@ -802,29 +802,32 @@ export function searchProfiles(term: string, options: any = {}): ActionFunc {
|
|||
}
|
||||
|
||||
let statusIntervalId: NodeJS.Timeout|null;
|
||||
export function startPeriodicStatusUpdates(): ActionFunc {
|
||||
export function startPeriodicStatusUpdates(forceStatusUpdate = false): ActionFunc {
|
||||
return async (dispatch: DispatchFunc, getState: GetStateFunc) => {
|
||||
if (statusIntervalId) {
|
||||
clearInterval(statusIntervalId);
|
||||
}
|
||||
|
||||
statusIntervalId = setInterval(
|
||||
() => {
|
||||
const {statuses} = getState().entities.users;
|
||||
const getStatusForUsers = () => {
|
||||
const {statuses} = getState().entities.users;
|
||||
|
||||
if (!statuses) {
|
||||
return;
|
||||
}
|
||||
if (!statuses) {
|
||||
return;
|
||||
}
|
||||
|
||||
const userIds = Object.keys(statuses);
|
||||
if (!userIds.length) {
|
||||
return;
|
||||
}
|
||||
const userIds = Object.keys(statuses).filter((u) => u);
|
||||
if (!userIds.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
dispatch(getStatusesByIds(userIds));
|
||||
},
|
||||
General.STATUS_INTERVAL,
|
||||
);
|
||||
dispatch(getStatusesByIds(userIds));
|
||||
};
|
||||
|
||||
statusIntervalId = setInterval(getStatusForUsers, General.STATUS_INTERVAL);
|
||||
|
||||
if (forceStatusUpdate) {
|
||||
getStatusForUsers();
|
||||
}
|
||||
|
||||
return {data: true};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -171,6 +171,7 @@ export default class PinnedPosts extends PureComponent {
|
|||
ref={this.setListRef}
|
||||
contentContainerStyle={style.sectionList}
|
||||
data={postIds}
|
||||
extraData={theme}
|
||||
keyExtractor={this.keyExtractor}
|
||||
keyboardShouldPersistTaps='always'
|
||||
keyboardDismissMode='interactive'
|
||||
|
|
|
|||
|
|
@ -171,6 +171,7 @@ export default class RecentMentions extends PureComponent {
|
|||
ref={this.setListRef}
|
||||
contentContainerStyle={style.sectionList}
|
||||
data={postIds}
|
||||
extraData={theme}
|
||||
keyExtractor={this.keyExtractor}
|
||||
keyboardShouldPersistTaps='always'
|
||||
keyboardDismissMode='interactive'
|
||||
|
|
|
|||
|
|
@ -173,6 +173,7 @@ export default class SavedPosts extends PureComponent {
|
|||
ref={this.setListRef}
|
||||
contentContainerStyle={style.sectionList}
|
||||
data={postIds}
|
||||
extraData={theme}
|
||||
keyExtractor={this.keyExtractor}
|
||||
keyboardShouldPersistTaps='always'
|
||||
keyboardDismissMode='interactive'
|
||||
|
|
|
|||
Loading…
Reference in a new issue