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

[WIP] Fix button saying server offline after it comes back. #3213

Open
wants to merge 16 commits into
base: master
Choose a base branch
from

Conversation

psybers
Copy link
Contributor

@psybers psybers commented Aug 7, 2024

This is an alternate fix for #3128. See #3164 for another approach.

@actual-github-bot actual-github-bot bot changed the title Fix button saying server offline after it comes back. [WIP] Fix button saying server offline after it comes back. Aug 7, 2024
Copy link

netlify bot commented Aug 7, 2024

Deploy Preview for actualbudget ready!

Name Link
🔨 Latest commit 372dc3d
🔍 Latest deploy log https://app.netlify.com/sites/actualbudget/deploys/66ecf2b3e49bb90008d0c843
😎 Deploy Preview https://deploy-preview-3213.demo.actualbudget.org
📱 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.

@psybers psybers changed the title [WIP] Fix button saying server offline after it comes back. Fix button saying server offline after it comes back. Aug 7, 2024
Copy link
Contributor

github-actions bot commented Aug 7, 2024

Bundle Stats — desktop-client

Hey there, this message comes from a GitHub action that helps you and reviewers to understand how these changes affect the size of this project's bundle.

As this PR is updated, I'll keep you updated on how the bundle size is impacted.

Total

Files count Total bundle size % Changed
9 5.28 MB → 5.28 MB (+145 B) +0.00%
Changeset
File Δ Size
src/components/LoggedInUser.tsx 📈 +60 B (+2.17%) 2.71 kB → 2.76 kB
src/components/Titlebar.tsx 📈 +85 B (+1.04%) 7.97 kB → 8.05 kB
View detailed bundle breakdown

Added

No assets were added

Removed

No assets were removed

Bigger

Asset File Size % Changed
static/js/index.js 3.31 MB → 3.31 MB (+145 B) +0.00%

Smaller

No assets were smaller

Unchanged

Asset File Size % Changed
static/js/indexeddb-main-thread-worker-e59fee74.js 13.5 kB 0%
static/js/resize-observer.js 18.37 kB 0%
static/js/AppliedFilters.js 20.97 kB 0%
static/js/BackgroundImage.js 122.29 kB 0%
static/js/usePreviewTransactions.js 1.59 kB 0%
static/js/narrow.js 80.95 kB 0%
static/js/wide.js 225.37 kB 0%
static/js/ReportRouter.js 1.5 MB 0%

Copy link
Contributor

github-actions bot commented Aug 7, 2024

Bundle Stats — loot-core

Hey there, this message comes from a GitHub action that helps you and reviewers to understand how these changes affect the size of this project's bundle.

As this PR is updated, I'll keep you updated on how the bundle size is impacted.

Total

Files count Total bundle size % Changed
1 1.19 MB 0%

Changeset

No files were changed

View detailed bundle breakdown

Added

No assets were added

Removed

No assets were removed

Bigger

No assets were bigger

Smaller

No assets were smaller

Unchanged

Asset File Size % Changed
kcab.worker.js 1.19 MB 0%

@MikesGlitch MikesGlitch added the ⚠️ Changes requested Pull Request needs changes before it can be reviewed again label Aug 7, 2024
@psybers
Copy link
Contributor Author

psybers commented Aug 9, 2024

@MikesGlitch What changes were requested? I see no review.

Copy link
Contributor

@MikesGlitch MikesGlitch left a comment

Choose a reason for hiding this comment

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

Apologies, I don't think you were able to see the comments because I didn't click the button 🤦‍♂️

style?: CSSProperties;
color?: string;
};
export function LoggedInUser({
hideIfNoServer,
syncState,
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice. This component is also used on the ManagementApp.jsx screen - can we pass the syncState from there too?

test2

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I should be able to do this there as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok so after looking into this area of the code, it definitely won't work.

This is making me rethink how that button works in general, and the approach used. Perhaps the button needs its own logic to determine the state instead of relying on other components.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is currently working in the latest master so if we merge this branch we'd be breaking it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, like I said it probably needs reworked.

@MikesGlitch MikesGlitch removed the ⚠️ Changes requested Pull Request needs changes before it can be reviewed again label Aug 13, 2024
@psybers psybers changed the title Fix button saying server offline after it comes back. [WIP] Fix button saying server offline after it comes back. Aug 13, 2024
Copy link
Contributor

👋 Hi! It looks like this PR has not had any changes for a week now. Would you like someone to review this PR? If so - please remove the "[WIP]" prefix from the PR title. That will let the community know that this PR is open for a review.

@github-actions github-actions bot added the Stale label Aug 29, 2024
@github-actions github-actions bot removed the Stale label Aug 30, 2024
Copy link
Contributor

👋 Hi! It looks like this PR has not had any changes for a week now. Would you like someone to review this PR? If so - please remove the "[WIP]" prefix from the PR title. That will let the community know that this PR is open for a review.

@github-actions github-actions bot added the Stale label Sep 10, 2024
@github-actions github-actions bot removed the Stale label Sep 11, 2024
Copy link
Contributor

👋 Hi! It looks like this PR has not had any changes for a week now. Would you like someone to review this PR? If so - please remove the "[WIP]" prefix from the PR title. That will let the community know that this PR is open for a review.

@github-actions github-actions bot added the Stale label Sep 18, 2024
Copy link

coderabbitai bot commented Sep 18, 2024

Walkthrough

The pull request introduces modifications to the LoggedInUser and Titlebar components, enhancing state management by adding a syncState prop. This new prop allows for a more accurate representation of synchronization status. The serverMessage function in LoggedInUser is refactored for performance optimization using useMemo. Additionally, the SyncButton in the Titlebar now manages its sync state externally. A bug fix in the release notes addresses an issue with the server status button, ensuring it reflects the correct connectivity state.

Changes

Files Change Summary
packages/desktop-client/src/components/LoggedInUser.tsx Added syncState prop to LoggedInUserProps, refactored serverMessage function to use useMemo, and updated rendering logic to utilize syncState.
packages/desktop-client/src/components/Titlebar.tsx Updated SyncButton to accept syncState and setSyncState props, and modified Titlebar to maintain its own syncState using useState, passing it to SyncButton.
upcoming-release-notes/3213.md Fixed a bug where the server status button incorrectly indicated "server offline" when the server was back online, ensuring accurate feedback on server connectivity.

Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between dcc4982 and 372dc3d.

Files selected for processing (2)
  • packages/desktop-client/src/components/LoggedInUser.tsx (5 hunks)
  • packages/desktop-client/src/components/Titlebar.tsx (4 hunks)
Files skipped from review as they are similar to previous changes (1)
  • packages/desktop-client/src/components/LoggedInUser.tsx
Additional comments not posted (5)
packages/desktop-client/src/components/Titlebar.tsx (5)

101-104: LGTM!

The addition of the syncState and setSyncState props to the SyncButtonProps type is a good approach to manage the synchronization state externally. This improves the flexibility and reusability of the SyncButton component.


107-112: Looks good!

The SyncButton component is correctly updated to accept the new syncState and setSyncState props, which is consistent with the changes made to the SyncButtonProps type.


276-278: Good state management!

Initializing the syncState in the Titlebar component using the useState hook is a good approach to manage the synchronization state locally. The union type ensures type safety by restricting the possible values for syncState.


349-355: Proper conditional rendering and prop passing!

Conditionally rendering the SyncButton based on the presence of a serverURL is a good practice to ensure that the button is only displayed when a server connection is available. Passing the syncState and setSyncState props from the Titlebar to the SyncButton allows for proper synchronization state management between the components.


356-356: Clarify the usage of syncState in LoggedInUser.

The LoggedInUser component now receives the syncState prop, suggesting that it may depend on the synchronization state for rendering or functionality. However, without more context about how the LoggedInUser component uses this prop, it's difficult to assess the impact of this change.

Could you please provide more information about how the syncState prop is used within the LoggedInUser component? This will help in understanding the purpose and necessity of passing this prop.


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.

Copy link

@coderabbitai coderabbitai bot left a comment

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)
upcoming-release-notes/3213.md (1)

1-6: Expand the release notes with more details.

The release notes accurately describe the bug fix at a high level. However, consider adding more details based on the information provided in the PR objectives and AI summary:

This will provide more context and technical details about the bug fix to the users reading the release notes.

Tools
LanguageTool

[uncategorized] ~6-~6: You might be missing the article “the” here.
Context: ...ory: Bugfix authors: [psybers] --- Fix button saying server offline after it comes ba...

(AI_EN_LECTOR_MISSING_DETERMINER_THE)

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 6e8cdb3 and dcc4982.

Files selected for processing (3)
  • packages/desktop-client/src/components/LoggedInUser.tsx (5 hunks)
  • packages/desktop-client/src/components/Titlebar.tsx (4 hunks)
  • upcoming-release-notes/3213.md (1 hunks)
Additional context used
LanguageTool
upcoming-release-notes/3213.md

[uncategorized] ~6-~6: You might be missing the article “the” here.
Context: ...ory: Bugfix authors: [psybers] --- Fix button saying server offline after it comes ba...

(AI_EN_LECTOR_MISSING_DETERMINER_THE)

Additional comments not posted (9)
packages/desktop-client/src/components/LoggedInUser.tsx (4)

16-16: LGTM!

The addition of the syncState prop to the LoggedInUserProps type is a good improvement. It allows the component to receive synchronization state information directly, replacing the previous reliance on user data from the Redux store. The possible values for syncState cover various synchronization states, providing more granular control over the component's behavior.


22-22: LGTM!

The LoggedInUser component signature has been updated to accept the new syncState prop, which is consistent with the modification made to the LoggedInUserProps type.


63-73: LGTM!

The refactoring of the serverMessage function into a memoized value using useMemo is a good optimization. It ensures that the message is recalculated only when serverUrl or syncState changes, improving performance.

The updated logic within the function accurately represents the current synchronization state based on the syncState prop, providing a more reliable server status message.

The memoized value correctly depends on serverUrl and syncState, ensuring that it updates when either of these values change.


102-102: LGTM!

The adjustments made to the rendering logic for the button and popover items, utilizing the new syncState prop, enhance the component's responsiveness to changes in server connectivity and user synchronization status.

Using the serverMessage memoized value for the button text ensures that the displayed message accurately reflects the current state, providing a better user experience.

Conditionally rendering the popover item for changing the password based on syncState improves the user experience by showing the option only when appropriate.

Also applies to: 114-117

packages/desktop-client/src/components/Titlebar.tsx (5)

99-102: LGTM!

The addition of the syncState and setSyncState props to the SyncButtonProps type is a good change. It allows the sync state to be managed externally and passed into the SyncButton component, enabling better control and communication of sync states between the SyncButton and its parent component.


105-110: LGTM!

The SyncButton component is correctly updated to accept the new syncState and setSyncState props, which are used to manage the sync state externally. The component signature looks good.


272-274: LGTM!

The Titlebar component now maintains its own syncState using the useState hook, which is initialized to null. This change allows the Titlebar to control the sync state and pass it down to the SyncButton component, improving the state management of the sync functionality.


345-351: LGTM!

The conditional rendering of the SyncButton based on the presence of a serverURL is a good practice. It ensures that the button is not displayed when there's no server connection. Additionally, the syncState and setSyncState props are correctly passed from the Titlebar to the SyncButton, enabling the Titlebar to control the sync state.


352-352: Verify the usage of the syncState prop in the LoggedInUser component.

The LoggedInUser component now receives the syncState prop, indicating a potential dependency on the sync status for rendering or functionality. Please ensure that the LoggedInUser component correctly handles the syncState prop and that it's being used for a valid purpose.

Run the following script to verify the usage of the syncState prop within the LoggedInUser component:

Verification successful

The syncState prop is correctly utilized in the LoggedInUser component.

After verifying the usage of the syncState prop within the LoggedInUser component, I can confirm that it is being used appropriately and for valid purposes:

  1. It's properly typed in the component's props.
  2. It's used to determine the server status message.
  3. It's included in the dependency array of a useMemo hook for proper reactivity.
  4. It's used to conditionally render menu items based on the sync state.

These usages align with the expected functionality of managing and displaying the sync state within the user interface.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of the `syncState` prop within the `LoggedInUser` component.

# Test: Search for the usage of the `syncState` prop. Expect: Relevant usage within the component.
rg --type typescript -A 5 $'syncState' $(fd LoggedInUser.tsx)

Length of output: 151


Script:

#!/bin/bash
# Description: Verify the usage of the `syncState` prop within the LoggedInUser component.

# Display the contents of LoggedInUser.tsx and search for syncState
cat packages/desktop-client/src/components/LoggedInUser.tsx | grep -n -C 5 "syncState"

Length of output: 1308

@github-actions github-actions bot removed the Stale label Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants