Skip to content

unifying the logic for fetching and setting the document title across the application #670

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

Merged
merged 19 commits into from
Mar 28, 2025

Conversation

anyulled
Copy link
Member

No description provided.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Hello @anyulled, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

Summary of Changes

This pull request focuses on unifying the logic for fetching speaker data across different components and sections of the application. The primary goal is to consolidate the useFetchSpeakers hook into a single location (src/views/Speakers) and ensure that all components that require speaker data utilize this unified hook. This involves modifying components such as SpeakerSwiper, SpeakerDetailContainer2023, Speakers2023, SpeakerDetailContainer2024, and MeetingDetailContainer to use the centralized hook and pass the appropriate sessionizeUrl from the conference data.

Highlights

  • Hook Consolidation: The useFetchSpeakers hook has been moved to src/views/Speakers to provide a single source of truth for fetching speaker data.
  • Component Updates: Multiple components have been updated to use the consolidated useFetchSpeakers hook, ensuring consistency in data fetching.
  • Data Source Configuration: The sessionizeUrl from the conference data (2023.json, 2024.json, 2025.json) is now passed to the useFetchSpeakers hook to specify the data source.
  • Test Removal: The pull request removes the now-obsolete test file src/2024/Speakers/UseFetchSpeakers.test.tsx.

Changelog

Click here to see the changelog
  • src/2023/Home/components/SpeakersCarousel/SpeakerSwiper.tsx
    • Updated import path for useFetchSpeakers from a local directory to the centralized location in src/views/Speakers.
    • Modified the useFetchSpeakers hook call to pass the sessionizeUrl from conferenceData.
  • src/2023/SpeakerDetail/SpeakerDetailContainer2023.tsx
    • Updated import path for useFetchSpeakers from a local directory to the centralized location in src/views/Speakers.
    • Modified the useFetchSpeakers hook call to pass the sessionizeUrl from conferenceData and the speaker id.
  • src/2023/Speakers/Speakers2023.tsx
    • Updated import path for useFetchSpeakers from a local directory to the centralized location in src/views/Speakers.
    • Modified the useFetchSpeakers hook call to pass the sessionizeUrl from webData.
    • Removed extra space at the end of slash lines.
  • src/2024/SpeakerDetail/SpeakerDetailContainer2024.tsx
    • Updated import path for useFetchSpeakers from a local directory to the centralized location in src/views/Speakers.
    • Modified the useFetchSpeakers hook call to pass the sessionizeUrl from conferenceData and the speaker id.
  • src/2024/Speakers/Speakers2024.tsx
    • Updated import path for useFetchSpeakers from a local directory to the centralized location in src/views/Speakers.
    • Modified the useFetchSpeakers hook call to pass the sessionizeUrl from webData.
    • Removed extra space at the end of slash lines.
  • src/2024/Speakers/UseFetchSpeakers.test.tsx
    • The UseFetchSpeakers.test.tsx file was removed.
  • src/2024/SpeakersCarousel/SpeakerSwiper.tsx
    • Updated import path for useFetchSpeakers from a local directory to the centralized location in src/views/Speakers.
    • Modified the useFetchSpeakers hook call to pass the sessionizeUrl from conferenceData.
  • src/2024/TalkDetail/MeetingDetailContainer.tsx
    • Updated import path for useFetchSpeakers from a local directory to the centralized location in src/views/Speakers.
    • Modified the useFetchSpeakers hook call to pass the sessionizeUrl from conferenceData.
  • src/App.test.tsx
    • Added mockedAxios and payload for testing.
  • src/data/2023.json
    • Added sessionizeUrl.
  • src/data/2024.json
    • Added sessionizeUrl.
  • src/data/2025.json
    • Added sessionizeUrl.
  • src/services/speakerAdapter.test.ts
    • Added test file for speakerAdapter.
  • src/views/Speakers/Speakers.tsx
    • Updated import path for useFetchSpeakers from a local directory to the centralized location in src/views/Speakers.
    • Modified the useFetchSpeakers hook call to pass the sessionizeUrl from webData.
    • Removed extra space at the end of slash lines.
  • src/views/Speakers/UseFetchSpeakers.test.tsx
    • Updated test file for useFetchSpeakers.
  • src/views/Speakers/UseFetchSpeakers.ts
    • The useFetchSpeakers hook is now the single source of truth for fetching speaker data.
    • The hook now accepts a url parameter to specify the data source.
    • The hook now includes Victor Rentea as a speaker.
  • src/views/Talks/useFetchTalks.test.tsx
    • Removed describe block for Fetch Live session talks.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.


Did you know?

The term "hook" in React was inspired by the concept of "hooks" in functional programming, which allow you to "hook into" state and lifecycle features from function components.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request makes significant improvements to the codebase by unifying the speaker fetching logic. The changes are well-structured and address the issue of inconsistent data fetching across different components. However, it's crucial to ensure that all components that previously used the old useFetchSpeakers hook are updated to use the new hook and that the removal of the old hook doesn't break any existing functionality. Also, the slash inconsistencies should be addressed.

Summary of Findings

  • Unifying speaker fetch logic: The pull request aims to unify the speaker fetch logic by moving the useFetchSpeakers hook to a common directory (src/views/Speakers) and passing the sessionizeUrl from the conference data JSON files. This ensures consistency across different components and years.
  • Removal of UseFetchSpeakers.ts and UseFetchSpeakers.test.tsx: The original UseFetchSpeakers.ts and UseFetchSpeakers.test.tsx files in the src/2024/Speakers/ directory have been removed as part of the unification process. This might impact existing tests or require adjustments in components relying on the old hook location.
  • Slash consistency: There are some inconsistencies in the number of slashes used in the StyledSlash components across different files. While minor, maintaining consistency improves code aesthetics.

Merge Readiness

The pull request is almost ready for merging. Before merging, it's important to verify that all components that previously used the old useFetchSpeakers hook are updated to use the new hook and that the removal of the old hook doesn't break any existing functionality. Additionally, the slash inconsistencies should be addressed. I am unable to approve this pull request, and users should have others review and approve this code before merging.

Copy link

netlify bot commented Mar 17, 2025

Deploy Preview for dev-bcn ready!

Name Link
🔨 Latest commit 53963ad
🔍 Latest deploy log https://app.netlify.com/sites/dev-bcn/deploys/67e69a11fa65540008feb58a
😎 Deploy Preview https://deploy-preview-670--dev-bcn.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@anyulled anyulled force-pushed the test/unify-fetch-speaker-logic branch 2 times, most recently from f40e669 to 611b441 Compare March 18, 2025 14:19
@anyulled
Copy link
Member Author

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

The pull request unifies the logic for fetching speakers and updating document titles across the application. It introduces a useDocumentTitleUpdater hook to manage document titles and centralizes speaker fetching logic. Overall, the changes improve code maintainability and consistency.

Summary of Findings

  • Inconsistent Title Separator: The title separator varies across the application. It's recommended to use a consistent separator (e.g., '—') for better UI consistency.
  • Missing Error Handling: While the useSentryErrorReport hook is used, it's important to ensure that all potential errors are properly caught and reported to Sentry to maintain application stability.
  • Potential Performance Bottleneck: Shuffling the speaker array on every render in SpeakerSwiper might lead to performance issues. Consider caching the shuffled array or using a more efficient shuffling mechanism.

Merge Readiness

The pull request is almost ready for merging. However, there are a few issues that need to be addressed before merging. Specifically, the title separator inconsistency and potential performance bottleneck in SpeakerSwiper should be resolved. Additionally, ensure that all potential errors are properly caught and reported to Sentry. I am unable to directly approve this pull request, and recommend that others review and approve this code before merging. At a minimum, the high severity comments should be addressed before merging.

@anyulled anyulled force-pushed the test/unify-fetch-speaker-logic branch 2 times, most recently from 6275912 to 39d3559 Compare March 19, 2025 17:51
@anyulled anyulled force-pushed the test/unify-fetch-speaker-logic branch from 9aca883 to f26631f Compare March 26, 2025 16:10
@anyulled
Copy link
Member Author

/gemini summary

Copy link
Contributor

Summary of Changes

This pull request focuses on unifying the logic for fetching and setting the document title across the application. It introduces a new useDocumentTitleUpdater hook to handle this, replacing the direct document.title assignments and React.useEffect calls in various components. This change promotes consistency and reduces code duplication.

Highlights

  • New Hook: useDocumentTitleUpdater: Introduces a custom hook useDocumentTitleUpdater in src/services/useDocumentTitleUpdate.ts to encapsulate the logic for updating the document title.
  • Title Updates: Replaces direct document.title assignments and React.useEffect calls with the new useDocumentTitleUpdater hook in multiple components, including CfpSection2023, Communities2023, Diversity2023, Home2023Wrapper, JobOffers2023, Schedule2023, SessionFeedback2023, TalkDetail, CfpSection2024, HomeWrapper2024, SpeakerDetail, MeetingDetail, NotFoundError, About, AttendeeInformation, CodeOfConduct, Travel, and Kcd.
  • Component Updates: Updates several components to remove now-unnecessary useEffect hooks and import the useDocumentTitleUpdater hook.
  • Dependency Updates: Adds react-error-boundary to package.json and removes SpeakersCarousel.scss and SpeakersCarousel.tsx.

Changelog

Click here to see the changelog
  • package.json
    • Adds react-error-boundary as a dependency.
  • src/2023/Cfp/CfpSection2023.test.tsx
    • Updates the expected document title in the test to include the full conference name.
  • src/2023/Cfp/CfpSection2023.tsx
    • Removes React.useEffect for setting the document title.
    • Adds import and usage of useDocumentTitleUpdater.
  • src/2023/Communities/Communities2023.tsx
    • Removes React.useEffect for setting the document title.
    • Adds import and usage of useDocumentTitleUpdater.
  • src/2023/Diversity/Diversity2023.tsx
    • Removes useEffect import.
    • Removes React.useEffect for setting the document title.
    • Adds import and usage of useDocumentTitleUpdater.
  • src/2023/Home/Home2023Wrapper.tsx
    • Removes React.useEffect for setting the document title.
    • Adds import and usage of useDocumentTitleUpdater.
    • Updates import for SpeakersCarousel from a local file to ../../components/Swiper/SpeakersCarousel.
    • Adds import for ROUTE_2023_SPEAKERS from ../../constants/routes.
    • Passes speakersLink and sessionizeUrl props to SpeakersCarousel.
  • src/2023/JobOffers/JobOffers2023.tsx
    • Removes React.useEffect for setting the document title.
    • Adds import and usage of useDocumentTitleUpdater.
  • src/2023/Schedule/Schedule2023.tsx
    • Removes React.useEffect for setting the document title.
    • Adds import and usage of useDocumentTitleUpdater.
  • src/2023/SessionFeedback/SessionFeedback2023.tsx
    • Removes React.useEffect for setting the document title.
    • Adds import and usage of useDocumentTitleUpdater.
  • src/2023/TalkDetail/TalkDetail.tsx
    • Removes useEffect import.
    • Removes React.useEffect for setting the document title.
    • Adds import and usage of useDocumentTitleUpdater.
  • src/2024/Cfp/CfpSection.test.tsx
    • Updates the expected document title in the test to include the full conference name.
  • src/2024/Cfp/CfpSection2024.tsx
    • Removes React.useEffect for setting the document title.
    • Adds import and usage of useDocumentTitleUpdater.
  • src/2024/HomeWrapper2024.tsx
    • Removes React.useEffect for setting the document title.
    • Adds import and usage of useDocumentTitleUpdater.
    • Updates import for SpeakersCarousel from a local file to ../../components/Swiper/SpeakersCarousel.
    • Adds import for ROUTE_2024_SPEAKERS from ../constants/routes.
    • Passes speakersLink and sessionizeUrl props to SpeakersCarousel.
  • src/2024/SpeakerDetail/SpeakerDetail.tsx
    • Removes useEffect import.
    • Removes React.useEffect for setting the document title.
    • Adds import and usage of useDocumentTitleUpdater.
  • src/2024/SpeakersCarousel/SpeakersCarousel.scss
    • Removes the file.
  • src/2024/SpeakersCarousel/SpeakersCarousel.tsx
    • Removes the file.
  • src/2024/TalkDetail/MeetingDetail.tsx
    • Removes useEffect import.
    • Removes React.useEffect for setting the document title.
    • Adds import and usage of useDocumentTitleUpdater.
  • src/App.test.tsx
    • Adds mock implementation for axios get requests.
  • src/components/NotFoundError/NotFoundError.tsx
    • Removes useEffect import.
    • Removes React.useEffect for setting the document title.
    • Adds import and usage of useDocumentTitleUpdater.
  • src/components/Swiper/SpeakersCarousel.tsx
    • Updates import for LessThanBlueWhiteIcon from .././../../../assets/images/MoreThanBlueIcon.svg to ../../assets/images/LessThanBlueIcon.svg.
    • Removes import for ROUTE_2023_SPEAKERS from ../../../../constants/routes.
    • Adds speakersLink and sessionizeUrl props to the component.
    • Passes sessionizeUrl prop to SpeakerSwiper.
    • Updates Link component to use speakersLink prop.
  • src/data/2023.json
    • Adds sessionizeUrl property.
  • src/data/2024.json
    • Adds sessionizeUrl property.
  • src/data/2025.json
    • Adds sessionizeUrl property.
  • src/services/shuffleArray.ts
    • Adds a new file with a function to shuffle an array using the Fisher-Yates algorithm.
  • src/services/speakerAdapter.test.ts
    • Adds a new file with tests for the speaker adapter.
  • src/services/useDocumentTitleUpdate.ts
    • Adds a new file with a custom hook for updating the document title.
  • src/services/useSentryErrorReport.ts
    • Adds a new file with a custom hook for reporting errors to Sentry.
  • src/views/About/About.tsx
    • Removes React.useEffect for setting the document title.
    • Adds import and usage of useDocumentTitleUpdater.
  • src/views/Attendee/AttendeeInformation.tsx
    • Removes useEffect import.
    • Removes React.useEffect for setting the document title.
    • Adds import and usage of useDocumentTitleUpdater.
  • src/views/Cfp/CfpSection.test.tsx
    • Updates the expected document title in the test to include the full conference name.
  • src/views/Cfp/CfpSection.tsx
    • Removes React.useEffect for setting the document title.
    • Adds import and usage of useDocumentTitleUpdater.
  • src/views/CodeOfConduct/CodeOfConduct.tsx
    • Removes useEffect import.
    • Removes React.useEffect for setting the document title.
    • Adds import and usage of useDocumentTitleUpdater.
  • src/views/Communities/Communities.tsx
    • Removes React.useEffect for setting the document title.
    • Adds import and usage of useDocumentTitleUpdater.
  • src/views/Conditions/Conditions.tsx
    • Adds import and usage of useDocumentTitleUpdater.
    • Removes React.useEffect for setting the document title.
  • src/views/Diversity/Diversity.tsx
    • Removes useEffect import.
    • Removes React.useEffect for setting the document title.
    • Adds import and usage of useDocumentTitleUpdater.
  • src/views/Home/HomeWrapper.tsx
    • Removes React.useEffect for setting the document title.
    • Removes useEventEdition import and usage.
    • Adds import and usage of useDocumentTitleUpdater.
    • Updates import for SpeakersCarousel from a local file to ../../components/Swiper/SpeakersCarousel.
    • Adds import for ROUTE_SPEAKERS from ../../constants/routes.
    • Adds import for ErrorBoundary from react-error-boundary.
    • Wraps Home component with ErrorBoundary.
    • Passes sessionizeUrl and speakersLink props to SpeakersCarousel.
  • src/views/JobOffers/JobOffers.tsx
    • Removes React.useEffect for setting the document title.
    • Adds import and usage of useDocumentTitleUpdater.
  • src/views/MeetingDetail/MeetingDetail.tsx
    • Removes useEffect import.
    • Removes React.useEffect for setting the document title.
    • Adds import and usage of useDocumentTitleUpdater.
  • src/views/Schedule/Schedule.tsx
    • Removes React.useEffect for setting the document title.
    • Adds import and usage of useDocumentTitleUpdater.
  • src/views/SessionFeedback/SessionFeedback.tsx
    • Removes React.useEffect for setting the document title.
    • Adds import and usage of useDocumentTitleUpdater.
  • src/views/Travel/Travel.tsx
    • Adds import and usage of useDocumentTitleUpdater.
    • Removes React.useEffect for setting the document title.
  • src/views/kcd/Kcd.tsx
    • Removes useEffect import.
    • Removes React.useEffect for setting the document title.
    • Adds import and usage of useDocumentTitleUpdater.
  • src/views/sponsorship/Sponsorship.tsx
    • Adds import and usage of useDocumentTitleUpdater.
    • Removes React.useEffect for setting the document title.

Activity

  • netlify[bot] reported a failed deploy preview.
  • anyulled requested a review from gemini.
  • sonarqubecloud[bot] reported a failed Quality Gate due to coverage and duplication issues.
  • anyulled requested a summary from gemini.

@anyulled anyulled changed the title Test/unify fetch speaker logic unifying the logic for fetching and setting the document title across the application Mar 26, 2025
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
52.1% Coverage on New Code (required ≥ 75%)

See analysis details on SonarQube Cloud

@anyulled anyulled merged commit fde7c2f into main Mar 28, 2025
13 of 14 checks passed
@anyulled anyulled deleted the test/unify-fetch-speaker-logic branch March 28, 2025 22:09
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.

1 participant