diff --git a/fe1-web/src/features/linked-organizations/screens/LinkedOrganizationsScreen.tsx b/fe1-web/src/features/linked-organizations/screens/LinkedOrganizationsScreen.tsx index f7eecaafaf..276e961d57 100644 --- a/fe1-web/src/features/linked-organizations/screens/LinkedOrganizationsScreen.tsx +++ b/fe1-web/src/features/linked-organizations/screens/LinkedOrganizationsScreen.tsx @@ -50,11 +50,24 @@ const LinkedOrganizationsScreen = () => { useEffect(() => { const fetchData = async (linkedOrgId: Hash) => { const channel = channelFromIds(linkedOrgId); - await subscribeToChannel(linkedOrgId, dispatch, channel); - await catchup(channel); - // sometimes there are erros without the extra waiting time - temporary fix - await new Promise((f) => setTimeout(f, 1000)); - setLinkedLaoId(linkedOrgId); + let counter = 0; + const subscribeAndCatchup = async (): Promise => { + try { + await subscribeToChannel(linkedOrgId, dispatch, channel); + await catchup(channel); + await new Promise((resolve) => setTimeout(resolve, 2000)); + setLinkedLaoId(linkedOrgId); + } catch (error) { + console.log(error); + if (counter >= 10) { + return; + } + counter += 1; + await new Promise((resolve) => setTimeout(resolve, 5000)); // wait before retrying + await subscribeAndCatchup(); // retry by calling the function recursively + } + }; + await subscribeAndCatchup(); }; if ( recvChallengeState &&