Skip to content

"Release Channel" Function #2017

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

Draft
wants to merge 13 commits into
base: dev
Choose a base branch
from
16 changes: 12 additions & 4 deletions Flow.Launcher.Core/Updater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,22 @@ namespace Flow.Launcher.Core
{
public class Updater
{
public string GitHubRepository { get; init; }
public string GitHubReleaseRepository { get; }
public string GitHubPrereleaseRepository { get; }

public bool UpdateToPrerelease => _settings.PrereleaseUpdateSource;

public string GitHubRepository => UpdateToPrerelease ? GitHubPrereleaseRepository : GitHubReleaseRepository;

private readonly Settings _settings;
private readonly IPublicAPI _api;

public Updater(IPublicAPI publicAPI, string gitHubRepository)
public Updater(Settings settings, IPublicAPI publicAPI, string gitHubReleaseRepository, string gitHubPrereleaseRepository)
{
_settings = settings;
_api = publicAPI;
GitHubRepository = gitHubRepository;
GitHubReleaseRepository = gitHubReleaseRepository;
GitHubPrereleaseRepository = gitHubPrereleaseRepository;
}

private SemaphoreSlim UpdateLock { get; } = new SemaphoreSlim(1);
Expand Down Expand Up @@ -99,7 +107,7 @@ public async Task UpdateAppAsync(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
2 changes: 2 additions & 0 deletions Flow.Launcher.Infrastructure/UserSettings/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ public string Theme
public double? SettingWindowLeft { get; set; } = null;
public WindowState SettingWindowState { get; set; } = WindowState.Normal;

public bool PrereleaseUpdateSource { get; set; }

bool _showPlaceholder { get; set; } = false;
public bool ShowPlaceholder
{
Expand Down
6 changes: 5 additions & 1 deletion Flow.Launcher/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,11 @@ public App()
.UseContentRoot(AppContext.BaseDirectory)
.ConfigureServices(services => services
.AddSingleton(_ => _settings)
.AddSingleton(sp => new Updater(sp.GetRequiredService<IPublicAPI>(), Launcher.Properties.Settings.Default.GithubRepo))
.AddSingleton(sp => new Updater(
_settings,
sp.GetRequiredService<IPublicAPI>(),
Launcher.Properties.Settings.Default.GithubRepo,
Launcher.Properties.Settings.Default.PrereleaseRepo))
.AddSingleton<Portable>()
.AddSingleton<SettingWindowViewModel>()
.AddSingleton<IAlphabet, PinyinAlphabet>()
Expand Down
12 changes: 12 additions & 0 deletions Flow.Launcher/Flow.Launcher.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,18 @@
</Content>
</ItemGroup>

<ItemGroup>
<Compile Update="Properties\Settings.Designer.cs">
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
<None Update="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>

<ItemGroup>
<None Update="Resources\dev.ico">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
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 @@ -329,6 +329,9 @@
<system:String x:Key="clearcachefolderMessage">Are you sure you want to delete all caches?</system:String>
<system:String x:Key="clearfolderfailMessage">Failed to clear part of folders and files. Please see log file for more information</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>
<system:String x:Key="userdatapath">User Data Location</system:String>
<system:String x:Key="userdatapathToolTip">User settings and installed plugins are saved in the user data folder. This location may vary depending on whether it's in portable mode or not.</system:String>
<system:String x:Key="userdatapathButton">Open Folder</system:String>
Expand Down
13 changes: 11 additions & 2 deletions Flow.Launcher/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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>
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,17 @@ public string CacheFolderSize
App.API.GetTranslation("about_activate_times"),
_settings.ActivateTimes
);


public int PrereleaseSelectedIndex
{
get => _settings.PrereleaseUpdateSource ? 1 : 0;
set
{
_settings.PrereleaseUpdateSource = value == 1;
OnPropertyChanged();
}
}

public class LogLevelData : DropdownDataGeneric<LOGLEVEL> { }

public List<LogLevelData> LogLevels { get; } =
Expand Down
14 changes: 10 additions & 4 deletions Flow.Launcher/SettingPages/Views/SettingsPaneAbout.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@
Icon="&#xe946;"
Sub="{DynamicResource version}">
<StackPanel Orientation="Horizontal">
<Button
Margin="0 0 10 0"
Command="{Binding UpdateAppCommand}"
Content="{DynamicResource checkUpdates}" />
<Button Padding="0" Style="{StaticResource AccentButtonStyle}">
<Hyperlink
NavigateUri="{Binding SponsorPage}"
Expand All @@ -49,6 +45,16 @@
</StackPanel>
</cc:Card>

<cc:Card Title="{DynamicResource updateSource}" Icon="&#xE777;">
<StackPanel Orientation="Horizontal">
<ComboBox Margin="0 0 10 0" SelectedIndex="{Binding PrereleaseSelectedIndex}">
<ComboBoxItem Content="{DynamicResource release}" />
<ComboBoxItem Content="{DynamicResource prerelease}" />
</ComboBox>
<Button Command="{Binding UpdateAppCommand}" Content="{DynamicResource checkUpdates}" />
</StackPanel>
</cc:Card>

<cc:Card Title="{DynamicResource releaseNotes}" Icon="&#xe8fd;">
<cc:HyperLink Text="{DynamicResource releaseNotes}" Uri="{Binding ReleaseNotes}" />
</cc:Card>
Expand Down
2 changes: 1 addition & 1 deletion Flow.Launcher/SettingWindow.xaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Window
<Window
x:Class="Flow.Launcher.SettingWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Expand Down
2 changes: 1 addition & 1 deletion Flow.Launcher/ViewModel/SettingWindowViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Flow.Launcher.Infrastructure.UserSettings;
using Flow.Launcher.Infrastructure.UserSettings;
using Flow.Launcher.Plugin;

namespace Flow.Launcher.ViewModel;
Expand Down
Loading