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:
Elias Nahum 2021-06-11 13:56:09 -04:00 committed by GitHub
parent 8894ee464f
commit 6335932883
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 24 additions and 18 deletions

View file

@ -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();

View file

@ -217,7 +217,7 @@ const PostList = ({
{...postProps}
/>
);
}, [postIds]);
}, [postIds, theme]);
const scrollToIndex = useCallback((index: number, animated = true) => {
flatListRef.current?.scrollToIndex({

View file

@ -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};
};

View file

@ -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'

View file

@ -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'

View file

@ -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'