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

"Release Channel" Function #2017

Draft
wants to merge 4 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 10 additions & 6 deletions Flow.Launcher.Core/Updater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,20 @@ namespace Flow.Launcher.Core
{
public class Updater
{
public string GitHubRepository { get; }
public bool UpdateToPrerelease { get; set; }

public const string ReleaseRepository = "https://github.com/Flow-Launcher/Flow.Launcher";
public const string PrereleaseRepository = "https://github.com/Flow-Launcher/Prereleases";

public string GitHubRepository => UpdateToPrerelease ? PrereleaseRepository : ReleaseRepository;

public Updater(string gitHubRepository)
{
GitHubRepository = gitHubRepository;
}

private SemaphoreSlim UpdateLock { get; } = new SemaphoreSlim(1);

public async Task UpdateAppAsync(IPublicAPI api, bool silentUpdate = true)
{
await UpdateLock.WaitAsync().ConfigureAwait(false);

try
{
if (!silentUpdate)
Expand All @@ -54,6 +56,7 @@ public async Task UpdateAppAsync(IPublicAPI api, bool silentUpdate = true)
{
if (!silentUpdate)
MessageBox.Show(api.GetTranslation("update_flowlauncher_already_on_latest"));

return;
}

Expand Down Expand Up @@ -94,7 +97,7 @@ public async Task UpdateAppAsync(IPublicAPI api, bool silentUpdate = true)
Log.Exception($"|Updater.UpdateApp|Check your connection and proxy settings to github-cloud.s3.amazonaws.com.", e);
else
Log.Exception($"|Updater.UpdateApp|Error Occurred", e);

if (!silentUpdate)
api.ShowMsg(api.GetTranslation("update_flowlauncher_fail"),
api.GetTranslation("update_flowlauncher_check_connection"));
Expand Down Expand Up @@ -134,6 +137,7 @@ private async Task<UpdateManager> GitHubUpdateManagerAsync(string repository)
{
Proxy = Http.WebProxy
};

var downloader = new FileDownloader(client);

var manager = new UpdateManager(latestUrl, urlDownloader: downloader);
Expand Down
8 changes: 5 additions & 3 deletions Flow.Launcher.Infrastructure/UserSettings/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,10 @@ public string Theme
public double SettingWindowHeight { get; set; } = 700;
public double SettingWindowTop { get; set; }
public double SettingWindowLeft { get; set; }
public System.Windows.WindowState SettingWindowState { get; set; } = WindowState.Normal;
public WindowState SettingWindowState { get; set; } = WindowState.Normal;

public bool PrereleaseUpdateSource { get; set; }

public int CustomExplorerIndex { get; set; } = 0;

[JsonIgnore]
Expand Down Expand Up @@ -253,8 +255,8 @@ public bool HideNotifyIcon

[JsonConverter(typeof(JsonStringEnumConverter))]
public LastQueryMode LastQueryMode { get; set; } = LastQueryMode.Selected;


// This needs to be loaded last by staying at the bottom
public PluginsSettings PluginSettings { get; set; } = new PluginsSettings();
}
Expand Down
4 changes: 2 additions & 2 deletions Flow.Launcher/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public partial class App : IDisposable, ISingleInstanceApp
private Settings _settings;
private MainViewModel _mainVM;
private SettingWindowViewModel _settingsVM;
private readonly Updater _updater = new Updater(Flow.Launcher.Properties.Settings.Default.GithubRepo);
private readonly Updater _updater = new();
private readonly Portable _portable = new Portable();
private readonly PinyinAlphabet _alphabet = new PinyinAlphabet();
private StringMatcher _stringMatcher;
Expand Down Expand Up @@ -59,7 +59,7 @@ private async void OnStartupAsync(object sender, StartupEventArgs e)
RegisterDispatcherUnhandledException();

ImageLoader.Initialize();

_settingsVM = new SettingWindowViewModel(_updater, _portable);
_settings = _settingsVM.Settings;

Expand Down
3 changes: 3 additions & 0 deletions Flow.Launcher/Languages/en.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,9 @@
<system:String x:Key="clearlogfolder">Clear Logs</system:String>
<system:String x:Key="clearlogfolderMessage">Are you sure you want to delete all logs?</system:String>
<system:String x:Key="welcomewindow">Wizard</system:String>
<system:String x:Key="updateSource">Release Channel</system:String>
<system:String x:Key="release">Stable</system:String>
<system:String x:Key="prerelease">Pre-release</system:String>

<!-- FileManager Setting Dialog -->
<system:String x:Key="fileManagerWindow">Select File Manager</system:String>
Expand Down
3 changes: 3 additions & 0 deletions Flow.Launcher/Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@
<Setting Name="GithubRepo" Type="System.String" Scope="Application">
<Value Profile="(Default)">https://github.com/Flow-Launcher/Flow.Launcher</Value>
</Setting>
<Setting Name="PrereleaseRepo" Type="System.String" Scope="Application">
<Value Profile="(Default)">https://github.com/Flow-Launcher/Prereleases</Value>
</Setting>
</Settings>
</SettingsFile>
57 changes: 39 additions & 18 deletions Flow.Launcher/SettingWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@
</ItemsControl>
</Border>

<Border
<Border
Margin="0,30,0,0"
Padding="0"
Style="{DynamicResource SettingGroupBox}">
Expand All @@ -720,7 +720,7 @@
<ComboBox
x:Name="SelectScreen"
MinWidth="160"
Margin="0,0,18,0"
Margin="0,0,18,0"
VerticalAlignment="Center"
FontSize="14"
ItemsSource="{Binding ScreenNumbers}"
Expand All @@ -738,14 +738,12 @@
</ComboBox>
</StackPanel>
<TextBlock Style="{StaticResource Glyph}">
&#xe7f4;
&#xe7f4;
</TextBlock>
</ItemsControl>
</Border>

<Separator
Width="Auto"
BorderThickness="1">
<Separator Width="Auto" BorderThickness="1">
<Separator.Style>
<Style BasedOn="{StaticResource SettingSeparatorStyle}" TargetType="Separator">
<Setter Property="Visibility" Value="Visible" />
Expand All @@ -758,9 +756,7 @@
</Separator.Style>
</Separator>

<Border
Margin="0"
BorderThickness="0">
<Border Margin="0" BorderThickness="0">
<Border.Style>
<Style BasedOn="{StaticResource SettingGroupBox}" TargetType="Border">
<Setter Property="Visibility" Value="Visible" />
Expand All @@ -786,8 +782,7 @@
FontSize="14"
ItemsSource="{Binding SearchWindowAligns}"
SelectedValue="{Binding Settings.SearchWindowAlign}"
SelectedValuePath="Value">
</ComboBox>
SelectedValuePath="Value" />
<StackPanel Margin="0,0,18,0" Orientation="Horizontal">
<StackPanel.Style>
<Style TargetType="StackPanel">
Expand Down Expand Up @@ -817,7 +812,7 @@
</StackPanel>
</StackPanel>
<TextBlock Style="{StaticResource Glyph}">
&#xe7f4;
&#xe7f4;
</TextBlock>
</ItemsControl>
</Border>
Expand Down Expand Up @@ -3014,7 +3009,10 @@
TextAlignment="left" />


<Border Margin="0,9,0,0" Style="{DynamicResource SettingGroupBox}">
<Border
Margin="0,9,0,0"
CornerRadius="8 8 0 0"
Style="{DynamicResource SettingGroupBox}">
<ItemsControl Style="{StaticResource SettingGrid}">
<StackPanel Style="{StaticResource TextPanel}">
<TextBlock
Expand All @@ -3026,11 +3024,6 @@
<TextBlock Style="{DynamicResource SettingSubTitleLabel}" Text="{DynamicResource version}" />
</StackPanel>
<StackPanel Grid.Column="2" Orientation="Horizontal">
<Button
Margin="0,0,10,0"
HorizontalAlignment="Right"
Click="OnCheckUpdates"
Content="{DynamicResource checkUpdates}" />
<Button
Margin="0,0,14,0"
Padding="0"
Expand All @@ -3054,6 +3047,34 @@
</ItemsControl>
</Border>


<Border
Margin="0,0,0,8"
CornerRadius="0 0 8 8"
Style="{DynamicResource SettingGroupBox}">
<ItemsControl Style="{StaticResource SettingGrid}">
<StackPanel Style="{StaticResource TextPanel}">
<TextBlock
Grid.Column="1"
VerticalAlignment="Center"
Style="{DynamicResource SettingTitleLabel}"
Text="{DynamicResource updateSource}" />
</StackPanel>
<StackPanel Grid.Column="2" Orientation="Horizontal">
<ComboBox Margin="0,0,8,0" SelectedIndex="0">
<ComboBoxItem Content="{DynamicResource release}" />
<ComboBoxItem Content="{DynamicResource prerelease}" IsSelected="{Binding Settings.PrereleaseUpdateSource}" />
</ComboBox>
<Button
Margin="0,0,14,0"
HorizontalAlignment="Right"
Click="OnCheckUpdates"
Content="{DynamicResource checkUpdates}" />
</StackPanel>
<TextBlock Width="50" Style="{StaticResource Glyph}" />
</ItemsControl>
</Border>

<Border Height="62" Style="{DynamicResource SettingGroupBox}">
<ItemsControl Style="{StaticResource SettingGrid}">
<StackPanel Style="{StaticResource TextPanel}">
Expand Down