MM-45456 - Gekidou LoadingUnreads component keeps spinning (#6453)

* fix animation on LoadingUnreads component

* code clean up

* clean up

* revert change to action/websocket/index

* Update loading_unreads.tsx

* fix loader stop spinning on second server removal

* fix for stopping loader on addition of new server

* Update loading_unreads.tsx
This commit is contained in:
Avinash Lingaloo
2022-07-08 14:14:35 +04:00
committed by GitHub
parent dcfc6e7927
commit c6795e18fc
4 changed files with 15 additions and 16 deletions

View File

@@ -61,6 +61,7 @@ export type EntryResponse = {
}
const FETCH_MISSING_DM_TIMEOUT = 2500;
const FETCH_UNREADS_TIMEOUT = 2500;
export const teamsToRemove = async (serverUrl: string, removeTeamIds?: string[]) => {
const operator = DatabaseManager.serverDatabases[serverUrl]?.operator;
@@ -277,13 +278,15 @@ export async function deferredAppEntryActions(
initialTeamId?: string, initialChannelId?: string) {
// defer sidebar DM & GM profiles
let channelsToFetchProfiles: Set<Channel>|undefined;
if (chData?.channels?.length && chData.memberships?.length) {
const directChannels = chData.channels.filter(isDMorGM);
channelsToFetchProfiles = new Set<Channel>(directChannels);
setTimeout(async () => {
if (chData?.channels?.length && chData.memberships?.length) {
const directChannels = chData.channels.filter(isDMorGM);
channelsToFetchProfiles = new Set<Channel>(directChannels);
// defer fetching posts for unread channels on initial team
fetchPostsForUnreadChannels(serverUrl, chData.channels, chData.memberships, initialChannelId, true);
}
// defer fetching posts for unread channels on initial team
fetchPostsForUnreadChannels(serverUrl, chData.channels, chData.memberships, initialChannelId, true);
}
}, FETCH_UNREADS_TIMEOUT);
// defer fetch channels and unread posts for other teams
if (teamData.teams?.length && teamData.memberships?.length) {

View File

@@ -326,11 +326,6 @@ export async function fetchPostsForChannel(serverUrl: string, channelId: string,
}
export const fetchPostsForUnreadChannels = async (serverUrl: string, channels: Channel[], memberships: ChannelMembership[], excludeChannelId?: string, emitEvent = false) => {
const database = DatabaseManager.serverDatabases[serverUrl]?.database;
if (!database) {
return {error: `${serverUrl} database not found`};
}
try {
const promises = [];
if (emitEvent) {
@@ -347,6 +342,9 @@ export const fetchPostsForUnreadChannels = async (serverUrl: string, channels: C
DeviceEventEmitter.emit(Events.FETCHING_POSTS, false);
}
} catch (error) {
if (emitEvent) {
DeviceEventEmitter.emit(Events.FETCHING_POSTS, false);
}
return {error};
}

View File

@@ -40,10 +40,7 @@ const LoadingUnreads = () => {
useEffect(() => {
if (loading) {
opacity.value = 1;
rotation.value = withRepeat(
withTiming(360, {duration: 750, easing: Easing.ease}),
-1,
);
rotation.value = withRepeat(withTiming(360, {duration: 750, easing: Easing.ease}), -1);
} else {
opacity.value = withTiming(0, {duration: 300, easing: Easing.ease});
cancelAnimation(rotation);
@@ -62,7 +59,7 @@ const LoadingUnreads = () => {
});
return () => listener.remove();
}, [loading]);
}, []);
if (!loading) {
return null;

View File

@@ -193,6 +193,7 @@ export function resetToHome(passProps: LaunchProps = {launchType: LaunchType.Nor
dismissModal({componentId: Screens.LOGIN});
dismissModal({componentId: Screens.SSO});
dismissModal({componentId: Screens.BOTTOM_SHEET});
DeviceEventEmitter.emit(Events.FETCHING_POSTS, false);
return;
}