Skip to content

refactor/fix(settings): Refactor animation settings retrieval to fix problem with refreshing. - #21284

Merged
ramonlsouza merged 1 commit into
bigbluebutton:v3.0.x-releasefrom
Scroody:i-21260
Sep 30, 2024
Merged

ramonlsouza merged 1 commit into
bigbluebutton:v3.0.x-releasefrom
Scroody:i-21260

Conversation

@Scroody

@Scroody Scroody commented Sep 30, 2024

Copy link
Copy Markdown
Contributor

What does this PR do?

This PR refactors a custom parameter/setting that was not persisting across page refreshes. It complements the changes introduced in PR 21255
.

Closes Issue(s)

#21260

How to test

  1. Start a meeting using custom parameters: bbb_prefer_dark_theme=true or bbb_show_animations_default=false
  2. Test one of the parameters above by trying to use animations or setting dark theme to off in the settings
  3. See if they persist

@coderabbitai

coderabbitai Bot commented Sep 30, 2024 •

Copy link
Copy Markdown
Contributor

Walkthrough

The changes involve modifications to the LayoutObserver component and the Settings class within the application. The LayoutObserver has simplified user settings management by removing animation-related logic and refining conditions for opening the sidebar. In the Settings class, default values for animations and dark theme preferences are now set based on user settings, enhancing the initialization process. Overall, these changes streamline the handling of user preferences and improve the control flow within the application.

Changes

File Path Change Summary
bigbluebutton-html5/imports/ui/components/layout/... Removed logic for handling animation settings in LayoutObserver, refined sidebar opening conditions.
bigbluebutton-html5/imports/ui/services/settings/... Added logic in Settings class to retrieve and set default values for animations alongside dark theme preferences.

Possibly related PRs

Suggested reviewers

  • ramonlsouza

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@Scroody Scroody added this to the Release 3.0 milestone Sep 30, 2024
@ramonlsouza
ramonlsouza self-requested a review September 30, 2024 13:48
@sonarqubecloud

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (1)
bigbluebutton-html5/imports/ui/services/settings/index.js (1)

36-40: LGTM! Consider a minor improvement for consistency.

The changes effectively address the persistence issue for the animation settings, aligning with the PR objectives. The implementation is consistent with how the dark theme setting is handled.

For improved consistency and readability, consider combining the animation and dark theme settings into a single block:

 const showAnimationsDefault = getFromUserSettings(
   'bbb_show_animations_default',
   window.meetingClientSettings.public.app.defaultSettings.application.animations,
 );

 const showDarkThemeDefault = getFromUserSettings(
   'bbb_prefer_dark_theme',
   window.meetingClientSettings.public.app.defaultSettings.application.darkTheme,
 );

-writableDefaultValues.application.animations = showAnimationsDefault;
-writableDefaultValues.application.darkTheme = showDarkThemeDefault;
+Object.assign(writableDefaultValues.application, {
+  animations: showAnimationsDefault,
+  darkTheme: showDarkThemeDefault,
+});

This change would group related settings together and make future additions more straightforward.

Also applies to: 46-46

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 580b80d and 4197d63.

📒 Files selected for processing (2)
  • bigbluebutton-html5/imports/ui/components/layout/observer.tsx (0 hunks)
  • bigbluebutton-html5/imports/ui/services/settings/index.js (1 hunks)
💤 Files with no reviewable changes (1)
  • bigbluebutton-html5/imports/ui/components/layout/observer.tsx
🔇 Additional comments (1)
bigbluebutton-html5/imports/ui/services/settings/index.js (1)

36-46: Verify persistence of animation settings across page refreshes.

The changes look good, but let's ensure that the loadChanged and save methods correctly handle the new animation setting for persistence across page refreshes.

Run the following script to verify the implementation:

This script will help us confirm that the animation settings are properly handled throughout the codebase, ensuring persistence across page refreshes as required by the PR objectives.

✅ Verification successful

This script will help us gather more information about the implementation and usage of animation settings throughout the codebase.


This script will help us understand the project structure and locate the relevant files containing information about animation settings.


This script will help us examine the content of the key files we've identified as potentially relevant to the animation settings and their persistence.


Animation settings are properly implemented and persisted.

The codebase demonstrates a robust implementation of animation settings:

  1. The Settings class in settings/index.js handles loading and saving the animation setting, using either LocalStorage or SessionStorage based on the app configuration.

  2. The ApplicationMenu component in application/component.jsx provides a user interface to toggle the animation setting.

  3. The Base component in base.jsx applies the animation setting globally by adding or removing CSS classes on the HTML element.

  4. The save method in the Settings class ensures that changes to the animation setting are persisted, allowing them to survive page refreshes.

This implementation effectively addresses the concern about the persistence of animation settings across page refreshes.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the handling of animation settings in loadChanged and save methods.

# Test 1: Check if loadChanged method handles the animation setting
echo "Checking loadChanged method:"
rg --type js 'loadChanged.*animations'

# Test 2: Check if save method handles the animation setting
echo "Checking save method:"
rg --type js 'save.*animations'

# Test 3: Look for any direct uses of the animation setting
echo "Checking direct uses of the animation setting:"
rg --type js 'application\.animations'

# Test 4: Verify if the animation setting is used in React components
echo "Checking usage in React components:"
rg --type js 'useContext.*Settings.*animations'

Length of output: 400773


Script:

#!/bin/bash
# Description: Further investigate animation settings implementation and usage

# Check for loadChanged and save methods
echo "Checking for loadChanged and save methods:"
rg --type js 'function\s+(loadChanged|save)'

# Check for animation setting in settings-related files
echo "Checking for animation setting in settings-related files:"
rg --type js 'animations?' imports/ui/services/settings/

# Look for animation-related components
echo "Checking for animation-related components:"
rg --type js 'animations?' imports/ui/components/

# Check for animation setting usage in main application file
echo "Checking for animation setting usage in main application file:"
rg --type js 'animations?' imports/ui/components/app/component.jsx

# Look for any other files that might be handling animation settings
echo "Checking for other files handling animation settings:"
rg --type js 'animations?' imports/ui/

Length of output: 1276


Script:

#!/bin/bash
# Description: Explore project structure and locate relevant files

# List the contents of the root directory
echo "Contents of the root directory:"
ls -la

# Find all JavaScript files in the project
echo "Finding all JavaScript files:"
find . -name "*.js" -o -name "*.jsx"

# Search for settings-related files
echo "Searching for settings-related files:"
find . -type f \( -name "*.js" -o -name "*.jsx" \) -exec grep -l "settings" {} +

# Search for animation-related files
echo "Searching for animation-related files:"
find . -type f \( -name "*.js" -o -name "*.jsx" \) -exec grep -l "animation" {} +

# Search for the main application file
echo "Searching for the main application file:"
find . -name "app.jsx" -o -name "main.jsx" -o -name "index.jsx"

# Search for files containing both "settings" and "animation"
echo "Searching for files containing both 'settings' and 'animation':"
find . -type f \( -name "*.js" -o -name "*.jsx" \) -exec grep -l "settings" {} + | xargs grep -l "animation"

Length of output: 68828


Script:

#!/bin/bash
# Description: Examine key files related to animation settings

echo "Checking settings/index.js file:"
cat ./bigbluebutton-html5/imports/ui/services/settings/index.js

echo "\nChecking application component for animation settings:"
cat ./bigbluebutton-html5/imports/ui/components/settings/submenus/application/component.jsx

echo "\nChecking base.jsx for initialization of settings:"
cat ./bigbluebutton-html5/imports/startup/client/base.jsx

Length of output: 31567

@github-actions

Copy link
Copy Markdown

Automated tests Summary

✅ All the CI tests have 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