Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix pending after first message #20

Merged
merged 2 commits into from
Jul 27, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/hooks/useCreateGroupChannel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,12 @@ export function useCreateGroupChannel(
message: firstMessage,
});
}
// let's wait for a second to make sure channel is created & ready
await delay(1000);
let count = 0;
while (groupChannel.lastMessage == null && count < 30) {
await delay(100);
count += 1;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit;

async function waitForLastMessage(groupChannel, maxRetries = 30, retryInterval = 100) {
  let count = 0;
  while (groupChannel.lastMessage == null && count < maxRetries) {
    await delay(retryInterval);
    count++;
  }
  await delay(500);
}

How about having this logic separately and call it in here?

// usage 
await waitForLastMessage(groupChannel);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AhyoungRyu Your suggestion is also good. Could you update it?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah sure will do.

await delay(500);
} catch (error) {
console.error(error);
} finally {
Expand Down
Loading