Skip to content

Commit c768b17

Browse files
committed
feature: use -p:DisableUpdateDetection=true to disable built-in update detection feature (#819)
1 parent 707a227 commit c768b17

File tree

6 files changed

+24
-4
lines changed

6 files changed

+24
-4
lines changed

src/App.Commands.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,18 @@ public Command(Action<object> action)
2525
private Action<object> _action = null;
2626
}
2727

28+
public static bool IsCheckForUpdateCommandVisible
29+
{
30+
get
31+
{
32+
#if DISABLE_UPDATE_DETECTION
33+
return false;
34+
#else
35+
return true;
36+
#endif
37+
}
38+
}
39+
2840
public static readonly Command OpenPreferenceCommand = new Command(_ => OpenDialog(new Views.Preference()));
2941
public static readonly Command OpenHotkeysCommand = new Command(_ => OpenDialog(new Views.Hotkeys()));
3042
public static readonly Command OpenAppDataDirCommand = new Command(_ => Native.OS.OpenInFileManager(Native.OS.DataDir));

src/App.axaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
<NativeMenu>
3434
<NativeMenuItem Header="{DynamicResource Text.About.Menu}" Command="{x:Static s:App.OpenAboutCommand}"/>
3535
<NativeMenuItem Header="{DynamicResource Text.Hotkeys}" Command="{x:Static s:App.OpenHotkeysCommand}"/>
36-
<NativeMenuItem Header="{DynamicResource Text.SelfUpdate}" Command="{x:Static s:App.CheckForUpdateCommand}"/>
36+
<NativeMenuItem Header="{DynamicResource Text.SelfUpdate}" Command="{x:Static s:App.CheckForUpdateCommand}" IsVisible="{x:Static s:App.IsCheckForUpdateCommandVisible}"/>
3737
<NativeMenuItemSeparator/>
3838
<NativeMenuItem Header="{DynamicResource Text.Preference}" Command="{x:Static s:App.OpenPreferenceCommand}" Gesture="⌘+,"/>
3939
<NativeMenuItem Header="{DynamicResource Text.OpenAppDataDir}" Command="{x:Static s:App.OpenAppDataDirCommand}"/>

src/App.axaml.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,9 +548,11 @@ private void TryLaunchedAsNormal(IClassicDesktopStyleApplicationLifetime desktop
548548
_launcher = new ViewModels.Launcher(startupRepo);
549549
desktop.MainWindow = new Views.Launcher() { DataContext = _launcher };
550550

551+
#if !DISABLE_UPDATE_DETECTION
551552
var pref = ViewModels.Preference.Instance;
552553
if (pref.ShouldCheck4UpdateOnStartup())
553554
Check4Update();
555+
#endif
554556
}
555557

556558
private ViewModels.Launcher _launcher = null;

src/SourceGit.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626
<TrimMode>link</TrimMode>
2727
</PropertyGroup>
2828

29+
<PropertyGroup Condition="'$(DisableUpdateDetection)' == 'true'">
30+
<DefineConstants>$(DefineConstants);DISABLE_UPDATE_DETECTION</DefineConstants>
31+
</PropertyGroup>
32+
2933
<ItemGroup>
3034
<AvaloniaResource Include="App.ico" />
3135
<AvaloniaResource Include="Resources/Fonts/*" />

src/Views/Launcher.axaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@
5151
</MenuItem.Icon>
5252
</MenuItem>
5353
<MenuItem Header="-"/>
54-
<MenuItem Header="{DynamicResource Text.SelfUpdate}" Command="{x:Static s:App.CheckForUpdateCommand}">
54+
<MenuItem Header="{DynamicResource Text.SelfUpdate}" Command="{x:Static s:App.CheckForUpdateCommand}" IsVisible="{x:Static s:App.IsCheckForUpdateCommandVisible}">
5555
<MenuItem.Icon>
5656
<Path Width="14" Height="14" Data="{StaticResource Icons.SoftwareUpdate}"/>
5757
</MenuItem.Icon>
5858
</MenuItem>
59-
<MenuItem Header="-"/>
59+
<MenuItem Header="-" IsVisible="{x:Static s:App.IsCheckForUpdateCommandVisible}"/>
6060
<MenuItem Header="{DynamicResource Text.About}" Command="{x:Static s:App.OpenAboutCommand}">
6161
<MenuItem.Icon>
6262
<Path Width="14" Height="14" Data="{StaticResource Icons.Info}"/>

src/Views/Preference.axaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
33
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
44
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5+
xmlns:s="using:SourceGit"
56
xmlns:m="using:SourceGit.Models"
67
xmlns:c="using:SourceGit.Converters"
78
xmlns:vm="using:SourceGit.ViewModels"
@@ -45,7 +46,7 @@
4546
<TabItem.Header>
4647
<TextBlock Classes="tab_header" Text="{DynamicResource Text.Preference.General}"/>
4748
</TabItem.Header>
48-
<Grid Margin="8" RowDefinitions="32,32,32,32,32,32,32" ColumnDefinitions="Auto,*">
49+
<Grid Margin="8" RowDefinitions="32,32,32,32,32,32,Auto" ColumnDefinitions="Auto,*">
4950
<TextBlock Grid.Row="0" Grid.Column="0"
5051
Text="{DynamicResource Text.Preference.General.Locale}"
5152
HorizontalAlignment="Right"
@@ -118,6 +119,7 @@
118119
<CheckBox Grid.Row="6" Grid.Column="1"
119120
Height="32"
120121
Content="{DynamicResource Text.Preference.General.Check4UpdatesOnStartup}"
122+
IsVisible="{x:Static s:App.IsCheckForUpdateCommandVisible}"
121123
IsChecked="{Binding Source={x:Static vm:Preference.Instance}, Path=Check4UpdatesOnStartup, Mode=TwoWay}"/>
122124
</Grid>
123125
</TabItem>

0 commit comments

Comments
 (0)