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

Support mutiple language for filter track #217

Merged

Conversation

odkhang
Copy link
Collaborator

@odkhang odkhang commented Aug 9, 2024

Similar with #213
to support mutiple language for track filter

Summary by Sourcery

Support multiple languages for track filter by introducing a method to retrieve track names based on the user's language preference.

New Features:

  • Add support for displaying track names in multiple languages based on user preferences.

Copy link

sourcery-ai bot commented Aug 9, 2024

Reviewer's Guide by Sourcery

This pull request adds support for multiple languages in the track filter of the schedule sessions view. The changes involve modifying the Vue component to dynamically display track names based on the user's language preference stored in localStorage.

File-Level Changes

Files Changes
webapp/src/views/schedule/sessions/index.vue Added support for multiple languages in the track filter by introducing a new method getTrackName that retrieves the track name based on the user's language preference.

Tips
  • Trigger a new Sourcery review by commenting @sourcery-ai review on the pull request.
  • Continue your discussion with Sourcery by replying directly to review comments.
  • You can change your review settings at any time by accessing your dashboard:
    • Enable or disable the Sourcery-generated pull request summary or reviewer's guide;
    • Change the review language;
  • You can always contact us if you have any questions or feedback.

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @odkhang - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 2 issues found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

Comment on lines +134 to +145
getTrackName(track) {
const language_track = localStorage.userLanguage;
if (typeof track.name === 'object' && track.name !== null) {
if (language_track && track.name[language_track]) {
return track.name[language_track];
} else {
return track.name.en || track.name;
}
} else {
return track.name;
}
},
Copy link

Choose a reason for hiding this comment

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

suggestion: Consider refactoring getTrackName for better robustness and Vue.js integration

The current implementation directly accesses localStorage and may not handle all cases correctly. Consider using Vuex for managing user preferences and ensure the function always returns a string. Also, think about moving this logic to a computed property or a more central location for reusability.

computed: {
  ...mapState(['userLanguage']),
  getTrackName() {
    return (track) => {
      if (typeof track.name === 'object' && track.name !== null) {
        return track.name[this.userLanguage] || track.name.en || Object.values(track.name)[0] || '';
      }
      return String(track.name || '');
    };
  }
},

@@ -39,7 +39,7 @@
h1 {{ $t('Tracks')}}
template(v-for="track in schedule.tracks")
Copy link

Choose a reason for hiding this comment

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

suggestion (performance): Add a key to the v-for loop for better performance

When using v-for, it's a Vue.js best practice to provide a unique key for each item. This helps Vue optimize rendering and improves performance, especially for large lists. Consider adding :key="track.id" to your v-for loop.

Suggested change
template(v-for="track in schedule.tracks")
template(v-for="track in schedule.tracks" :key="track.id")

@mariobehling mariobehling merged commit a33ab54 into fossasia:development Aug 12, 2024
2 of 3 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.

2 participants