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

Update webview theme on editor theme change #85

Merged
merged 5 commits into from
Sep 5, 2024
Merged

Conversation

abeatrix
Copy link
Collaborator

@abeatrix abeatrix commented Sep 5, 2024

CLOSE https://linear.app/sourcegraph/issue/CODY-3622/webview-theme-should-update-on-theme-changed

vs_theme_change.mp4

Test Plan:

Try following the steps shown in the demo video above to switch theme and confirm the webview is updated accordingly.

@abeatrix abeatrix requested review from PiotrKarczmarz and a team September 5, 2024 07:13
abeatrix and others added 2 commits September 5, 2024 05:53
  - added try/catch when handling theme change event
  - added logger for ThemeService and WebViewController

private async void HandleThemeChanges(ThemeChangedEventArgs e)
{
try
Copy link
Collaborator

@PiotrKarczmarz PiotrKarczmarz Sep 5, 2024

Choose a reason for hiding this comment

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

I've added try/catch here :) In general every code that is handling event should be in the try/catch.

Also Task.Delay(100).Wait() was blocking UI thread, so changed the method signature to allow awaiting it.

";

public void SetLogger(ILog logger)
{
Copy link
Collaborator

Choose a reason for hiding this comment

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

Controller can use logger now :)


public async void OnThemeChanged(object sender, IColorThemeChangedEvent e)
{
try
Copy link
Collaborator

Choose a reason for hiding this comment

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

Additional try/catch because we're handling event.

PiotrKarczmarz and others added 2 commits September 5, 2024 15:24
… UX) by increasing Task.Delay(1000) (from 100 ms):

  - Task.Delay() returns code execution to the main UI thread and IDE has enough time to change entire VS Theme
@abeatrix abeatrix merged commit 8c274b0 into main Sep 5, 2024
1 check passed
@abeatrix abeatrix deleted the bee/on-theme-change branch September 5, 2024 14:45
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