Skip to content

Commit 82a174f

Browse files
committed
Add Prerelease update source
1 parent 1bf9520 commit 82a174f

File tree

7 files changed

+108
-20
lines changed

7 files changed

+108
-20
lines changed

Flow.Launcher.Core/Updater.cs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,20 @@ namespace Flow.Launcher.Core
2222
{
2323
public class Updater
2424
{
25-
public string GitHubRepository { get; }
25+
public bool UpdateToPrerelease { get; set; }
26+
27+
public const string ReleaseRepository = "https://github.com/Flow-Launcher/Flow.Launcher";
28+
public const string PrereleaseRepository = "https://github.com/Flow-Launcher/Prereleases";
29+
30+
public string GitHubRepository => UpdateToPrerelease ? PrereleaseRepository : ReleaseRepository;
2631

27-
public Updater(string gitHubRepository)
28-
{
29-
GitHubRepository = gitHubRepository;
30-
}
3132

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

3435
public async Task UpdateAppAsync(IPublicAPI api, bool silentUpdate = true)
3536
{
3637
await UpdateLock.WaitAsync().ConfigureAwait(false);
38+
3739
try
3840
{
3941
if (!silentUpdate)
@@ -54,6 +56,7 @@ public async Task UpdateAppAsync(IPublicAPI api, bool silentUpdate = true)
5456
{
5557
if (!silentUpdate)
5658
MessageBox.Show(api.GetTranslation("update_flowlauncher_already_on_latest"));
59+
5760
return;
5861
}
5962

@@ -94,7 +97,7 @@ public async Task UpdateAppAsync(IPublicAPI api, bool silentUpdate = true)
9497
Log.Exception($"|Updater.UpdateApp|Check your connection and proxy settings to github-cloud.s3.amazonaws.com.", e);
9598
else
9699
Log.Exception($"|Updater.UpdateApp|Error Occurred", e);
97-
100+
98101
if (!silentUpdate)
99102
api.ShowMsg(api.GetTranslation("update_flowlauncher_fail"),
100103
api.GetTranslation("update_flowlauncher_check_connection"));
@@ -134,6 +137,7 @@ private async Task<UpdateManager> GitHubUpdateManagerAsync(string repository)
134137
{
135138
Proxy = Http.WebProxy
136139
};
140+
137141
var downloader = new FileDownloader(client);
138142

139143
var manager = new UpdateManager(latestUrl, urlDownloader: downloader);

Flow.Launcher.Infrastructure/UserSettings/Settings.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,10 @@ public string Theme
6464
public double SettingWindowHeight { get; set; } = 700;
6565
public double SettingWindowTop { get; set; }
6666
public double SettingWindowLeft { get; set; }
67-
public System.Windows.WindowState SettingWindowState { get; set; } = WindowState.Normal;
67+
public WindowState SettingWindowState { get; set; } = WindowState.Normal;
6868

69+
public bool PrereleaseUpdateSource { get; set; }
70+
6971
public int CustomExplorerIndex { get; set; } = 0;
7072

7173
[JsonIgnore]
@@ -253,8 +255,8 @@ public bool HideNotifyIcon
253255

254256
[JsonConverter(typeof(JsonStringEnumConverter))]
255257
public LastQueryMode LastQueryMode { get; set; } = LastQueryMode.Selected;
256-
257-
258+
259+
258260
// This needs to be loaded last by staying at the bottom
259261
public PluginsSettings PluginSettings { get; set; } = new PluginsSettings();
260262
}

Flow.Launcher/App.xaml.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public partial class App : IDisposable, ISingleInstanceApp
2929
private Settings _settings;
3030
private MainViewModel _mainVM;
3131
private SettingWindowViewModel _settingsVM;
32-
private readonly Updater _updater = new Updater(Flow.Launcher.Properties.Settings.Default.GithubRepo);
32+
private readonly Updater _updater = new();
3333
private readonly Portable _portable = new Portable();
3434
private readonly PinyinAlphabet _alphabet = new PinyinAlphabet();
3535
private StringMatcher _stringMatcher;
@@ -59,7 +59,7 @@ await Stopwatch.NormalAsync("|App.OnStartup|Startup cost", async () =>
5959
RegisterDispatcherUnhandledException();
6060

6161
ImageLoader.Initialize();
62-
62+
6363
_settingsVM = new SettingWindowViewModel(_updater, _portable);
6464
_settings = _settingsVM.Settings;
6565

Flow.Launcher/Languages/en.xaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,9 @@
234234
<system:String x:Key="clearlogfolder">Clear Logs</system:String>
235235
<system:String x:Key="clearlogfolderMessage">Are you sure you want to delete all logs?</system:String>
236236
<system:String x:Key="welcomewindow">Wizard</system:String>
237+
<system:String x:Key="updateSource">Update Source</system:String>
238+
<system:String x:Key="release">Release</system:String>
239+
<system:String x:Key="prerelease">Prerelease</system:String>
237240

238241
<!-- FileManager Setting Dialog -->
239242
<system:String x:Key="fileManagerWindow">Select File Manager</system:String>

Flow.Launcher/Properties/Settings.settings

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,8 @@
55
<Setting Name="GithubRepo" Type="System.String" Scope="Application">
66
<Value Profile="(Default)">https://github.com/Flow-Launcher/Flow.Launcher</Value>
77
</Setting>
8+
<Setting Name="PrereleaseRepo" Type="System.String" Scope="Application">
9+
<Value Profile="(Default)">https://github.com/Flow-Launcher/Prereleases</Value>
10+
</Setting>
811
</Settings>
912
</SettingsFile>

Flow.Launcher/SettingWindow.xaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3058,12 +3058,13 @@
30583058
Grid.Column="1"
30593059
VerticalAlignment="Center"
30603060
Style="{DynamicResource SettingTitleLabel}"
3061-
Text="Update Source" />
3061+
Text="{DynamicResource updateSource}" />
30623062
</StackPanel>
30633063
<StackPanel Grid.Column="2" Orientation="Horizontal">
30643064
<ComboBox Margin="0,0,8,0" SelectedIndex="0">
3065-
<ComboBoxItem>Release</ComboBoxItem>
3066-
<ComboBoxItem>Preview</ComboBoxItem>
3065+
<ComboBoxItem Content="{DynamicResource release}"/>
3066+
<ComboBoxItem IsSelected="{Binding Settings.PrereleaseUpdateSource}"
3067+
Content="{DynamicResource prerelease}"/>
30673068
</ComboBox>
30683069
<Button
30693070
Margin="0,0,14,0"

0 commit comments

Comments
 (0)