Skip to content

Conversation

Ashaba123
Copy link
Contributor

Fixes #661

My PR closes #661

πŸ‘¨β€πŸ’» Changes proposed

I moved all socket functions from
https://github.com/Dun-sin/Whisper/blob/dbec99c68f63c606647ea2cef1d458a72ae83b1b/client/src/components/BuddyMatcher.jsx and moved them into a file in lib folder called buddySocket.js.

βœ”οΈ Check List (Check all the applicable boxes)

  • My code follows the code style of this project.
  • This PR does not contain plagiarized content.
  • The title and description of the PR is clear and explains the approach.

Note to reviewers

πŸ“· Screenshots

Copy link

vercel bot commented Apr 24, 2025

Someone is attempting to deploy a commit to the dunsin's projects Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

PR Compliance Checks Passed!

@Ashaba123 Ashaba123 changed the title Move all socket function into a different file refactor(socket): move all socket functions to lib/buddySocket.js Apr 24, 2025
Copy link
Owner

@Dun-sin Dun-sin left a comment

Choose a reason for hiding this comment

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

sorry for getting this to come late.

But this is complete all socket functions are missing, the goal is to have a separation of concern

@Dun-sin
Copy link
Owner

Dun-sin commented May 5, 2025

you can take inspiration from this PR:
https://github.com/Dun-sin/Whisper/pull/744/files

- Move socket-related functions from BuddyMatcher to buddySocket
- Add reconnection attempt management in buddySocket
- Extract long components in BuddyMatcher for better readability
- Fix line length issues in both files
@Ashaba123 Ashaba123 requested a review from Dun-sin May 5, 2025 17:09
Copy link
Owner

@Dun-sin Dun-sin left a comment

Choose a reason for hiding this comment

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

sorry for reviewing this late, but it still doesn't move all the functions, i.e everything with a usecallback

@Dun-sin
Copy link
Owner

Dun-sin commented May 24, 2025

hi @Ashaba123 still interested in it

@Ashaba123
Copy link
Contributor Author

I thought moved every socket function. what is missing?

@Ashaba123
Copy link
Contributor Author

sorry for reviewing this late, but it still doesn't move all the functions, i.e everything with a usecallback

i wonder function i have missed

endSearch(currentChatId);
}, []);

const onConnect = useCallback(() => {
Copy link
Owner

Choose a reason for hiding this comment

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

basically everything that has a useCallback, like onConnect for example

Copy link
Contributor Author

Choose a reason for hiding this comment

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

so i move everything that has a useCallback to BuddySocket. let me do that now

- Move all socket-related functions from BuddyMatcher.jsx to buddySocket.js
- Create useSocketHandlers hook to manage all socket event handlers
- Move socket event handlers and their memoization to buddySocket.js
- Move socket reconnection logic to buddySocket.js
- Improve code organization and separation of concerns
- Enhance maintainability and reusability of socket functionality

The changes centralize all socket-related logic in buddySocket.js while keeping
BuddyMatcher.jsx focused on UI composition and component lifecycle management.
@Ashaba123 Ashaba123 requested a review from Dun-sin May 24, 2025 19:17
Copy link
Owner

@Dun-sin Dun-sin left a comment

Choose a reason for hiding this comment

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

@Ashaba123 thanks so much for accommodating the changes, will do a live test next and see how it holds up.

But it looks good code wise

Copy link

vercel bot commented May 26, 2025

The latest updates on your projects. Learn more about Vercel for Git β†—οΈŽ

Name Status Preview Comments Updated (UTC)
whisper-b2p2 βœ… Ready (Inspect) Visit Preview πŸ’¬ Add feedback May 26, 2025 5:26pm

@Dun-sin
Copy link
Owner

Dun-sin commented May 26, 2025

works good @Ashaba123,
You did great, thanks for contributing, I hope you will stick around and continue to contribute to this project.

Consider giving this project a star, sharing the project with your friends, and joining the community discord server if you haven't for more resources and opportunities to connect with others. πŸ‘‰πŸ½hereπŸ‘ˆπŸ½

@Dun-sin Dun-sin merged commit 3b41aed into Dun-sin:main May 26, 2025
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[OTHER] move all socket function into a different file
2 participants