mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-29 16:14:59 +00:00
refactor: delay starting background tasks
* start background task only it is needed * solve the problem that we can not use `ViewModels.Preference.Instance` until resource ready * remove avatar sever settings
This commit is contained in:
parent
e7921db339
commit
7fe1df20cc
13 changed files with 178 additions and 190 deletions
|
@ -39,7 +39,7 @@ namespace SourceGit.Views
|
|||
refetch.Click += (_, _) =>
|
||||
{
|
||||
if (User != null)
|
||||
Models.AvatarManager.Request(User.Email, true);
|
||||
Models.AvatarManager.Instance.Request(User.Email, true);
|
||||
};
|
||||
|
||||
ContextMenu = new ContextMenu();
|
||||
|
@ -54,7 +54,7 @@ namespace SourceGit.Views
|
|||
return;
|
||||
|
||||
var corner = (float)Math.Max(2, Bounds.Width / 16);
|
||||
var img = Models.AvatarManager.Request(User.Email, false);
|
||||
var img = Models.AvatarManager.Instance.Request(User.Email, false);
|
||||
if (img != null)
|
||||
{
|
||||
var rect = new Rect(0, 0, Bounds.Width, Bounds.Height);
|
||||
|
@ -72,21 +72,19 @@ namespace SourceGit.Views
|
|||
public void OnAvatarResourceChanged(string email)
|
||||
{
|
||||
if (User.Email.Equals(email, StringComparison.Ordinal))
|
||||
{
|
||||
InvalidateVisual();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnLoaded(RoutedEventArgs e)
|
||||
{
|
||||
base.OnLoaded(e);
|
||||
Models.AvatarManager.Subscribe(this);
|
||||
Models.AvatarManager.Instance.Subscribe(this);
|
||||
}
|
||||
|
||||
protected override void OnUnloaded(RoutedEventArgs e)
|
||||
{
|
||||
base.OnUnloaded(e);
|
||||
Models.AvatarManager.Unsubscribe(this);
|
||||
Models.AvatarManager.Instance.Unsubscribe(this);
|
||||
}
|
||||
|
||||
private static void OnUserPropertyChanged(Avatar avatar, AvaloniaPropertyChangedEventArgs e)
|
||||
|
|
|
@ -57,7 +57,7 @@
|
|||
<TabItem.Header>
|
||||
<TextBlock Classes="tab_header" Text="{DynamicResource Text.Preference.General}"/>
|
||||
</TabItem.Header>
|
||||
<Grid Margin="8" RowDefinitions="32,32,32,32,32,32,32,32" ColumnDefinitions="Auto,*">
|
||||
<Grid Margin="8" RowDefinitions="32,32,32,32,32,32,32" ColumnDefinitions="Auto,*">
|
||||
<TextBlock Grid.Row="0" Grid.Column="0"
|
||||
Text="{DynamicResource Text.Preference.General.Locale}"
|
||||
HorizontalAlignment="Right"
|
||||
|
@ -71,25 +71,10 @@
|
|||
SelectedItem="{Binding Locale, Mode=TwoWay, Converter={x:Static c:StringConverters.ToLocale}}"/>
|
||||
|
||||
<TextBlock Grid.Row="1" Grid.Column="0"
|
||||
Text="{DynamicResource Text.Preference.General.AvatarServer}"
|
||||
HorizontalAlignment="Right"
|
||||
Margin="0,0,16,0"/>
|
||||
<ComboBox Grid.Row="1" Grid.Column="1"
|
||||
MinHeight="28"
|
||||
Padding="8,0"
|
||||
HorizontalAlignment="Stretch"
|
||||
SelectedItem="{Binding AvatarServer, Mode=TwoWay}">
|
||||
<ComboBox.Items>
|
||||
<sys:String>https://www.gravatar.com/avatar/</sys:String>
|
||||
<sys:String>https://cravatar.cn/avatar/</sys:String>
|
||||
</ComboBox.Items>
|
||||
</ComboBox>
|
||||
|
||||
<TextBlock Grid.Row="2" Grid.Column="0"
|
||||
Text="{DynamicResource Text.Preference.General.VisibleDiffContextLines}"
|
||||
HorizontalAlignment="Right"
|
||||
Margin="0,0,16,0"/>
|
||||
<NumericUpDown Grid.Row="2" Grid.Column="1"
|
||||
<NumericUpDown Grid.Row="1" Grid.Column="1"
|
||||
Minimum="4" Maximum="10000" Increment="1"
|
||||
Height="28"
|
||||
Padding="4"
|
||||
|
@ -98,11 +83,11 @@
|
|||
CornerRadius="3"
|
||||
Value="{Binding DiffViewVisualLineNumbers, Mode=TwoWay}"/>
|
||||
|
||||
<TextBlock Grid.Row="3" Grid.Column="0"
|
||||
<TextBlock Grid.Row="2" Grid.Column="0"
|
||||
Text="{DynamicResource Text.Preference.General.SubjectGuideLength}"
|
||||
HorizontalAlignment="Right"
|
||||
Margin="0,0,16,0"/>
|
||||
<NumericUpDown Grid.Row="3" Grid.Column="1"
|
||||
<NumericUpDown Grid.Row="2" Grid.Column="1"
|
||||
Minimum="50" Maximum="1000" Increment="1"
|
||||
Height="28"
|
||||
Padding="4"
|
||||
|
@ -111,11 +96,11 @@
|
|||
CornerRadius="3"
|
||||
Value="{Binding SubjectGuideLength, Mode=TwoWay}"/>
|
||||
|
||||
<TextBlock Grid.Row="4" Grid.Column="0"
|
||||
<TextBlock Grid.Row="3" Grid.Column="0"
|
||||
Text="{DynamicResource Text.Preference.General.MaxHistoryCommits}"
|
||||
HorizontalAlignment="Right"
|
||||
Margin="0,0,16,0"/>
|
||||
<Grid Grid.Row="4" Grid.Column="1" ColumnDefinitions="*,64">
|
||||
<Grid Grid.Row="3" Grid.Column="1" ColumnDefinitions="*,64">
|
||||
<Slider Grid.Column="0"
|
||||
Minimum="20000" Maximum="100000"
|
||||
TickPlacement="BottomRight" TickFrequency="5000"
|
||||
|
@ -130,16 +115,16 @@
|
|||
Text="{Binding MaxHistoryCommits}"/>
|
||||
</Grid>
|
||||
|
||||
<CheckBox Grid.Row="5" Grid.Column="1"
|
||||
<CheckBox Grid.Row="4" Grid.Column="1"
|
||||
Content="{DynamicResource Text.Preference.General.RestoreTabs}"
|
||||
IsChecked="{Binding RestoreTabs, Mode=TwoWay}"/>
|
||||
|
||||
<CheckBox Grid.Row="6" Grid.Column="1"
|
||||
<CheckBox Grid.Row="5" Grid.Column="1"
|
||||
Height="32"
|
||||
Content="{DynamicResource Text.Preference.General.UseFixedTabWidth}"
|
||||
IsChecked="{Binding Source={x:Static vm:Preference.Instance}, Path=UseFixedTabWidth, Mode=TwoWay}"/>
|
||||
|
||||
<CheckBox Grid.Row="7" Grid.Column="1"
|
||||
<CheckBox Grid.Row="6" Grid.Column="1"
|
||||
Height="32"
|
||||
Content="{DynamicResource Text.Preference.General.Check4UpdatesOnStartup}"
|
||||
IsChecked="{Binding Source={x:Static vm:Preference.Instance}, Path=Check4UpdatesOnStartup, Mode=TwoWay}"/>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue