Skip to content

Commit

Permalink
Don't hide the app initially if a dialog is active
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyrrrz committed Apr 23, 2024
1 parent 98dee7e commit fc8a8e5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
3 changes: 3 additions & 0 deletions LightBulb/Services/UpdateService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ public class UpdateService(SettingsService settingsService) : IDisposable

public Version? TryGetLastPreparedUpdate()
{
if (!settingsService.IsAutoUpdateEnabled)
return null;

var version = _updateManager.GetPreparedUpdates().Max();
if (version <= _updateManager.Updatee.Version)
return null;
Expand Down
5 changes: 4 additions & 1 deletion LightBulb/Views/MainView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@
</Design.DataContext>

<Border BorderBrush="{DynamicResource MaterialPrimaryLightBrush}" BorderThickness="1">
<dialogHostAvalonia:DialogHost CloseOnClickAway="False">
<dialogHostAvalonia:DialogHost
x:Name="DialogHost"
CloseOnClickAway="False"
Loaded="DialogHost_OnLoaded">
<Grid RowDefinitions="Auto,*,Auto">
<!-- Header -->
<Border
Expand Down
8 changes: 5 additions & 3 deletions LightBulb/Views/MainView.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@ public partial class MainView : Window<MainViewModel>

private void Window_OnLoaded(object sender, RoutedEventArgs args)
{
if (StartOptions.Current.IsInitiallyHidden)
// If the app is set to start hidden, hide the window, unless a dialog is open
if (StartOptions.Current.IsInitiallyHidden && !DialogHost.IsOpen)
Hide();

DataContext.InitializeCommand.Execute(null);
}

private void Window_OnClosing(object sender, WindowClosingEventArgs args)
Expand All @@ -24,6 +23,9 @@ private void Window_OnClosing(object sender, WindowClosingEventArgs args)
Hide();
}

private void DialogHost_OnLoaded(object? sender, RoutedEventArgs args) =>
DataContext.InitializeCommand.Execute(null);

private void HeaderBorder_OnPointerPressed(object? sender, PointerPressedEventArgs args) =>
BeginMoveDrag(args);

Expand Down

0 comments on commit fc8a8e5

Please sign in to comment.