forked from Ivasoft/mattermost-mobile
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:
@@ -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) {
|
||||
|
||||
@@ -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};
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user