mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Merge pull request #2479 from Flow-Launcher/ignorenull-for-pluginstoreitem
ignore null datetimes for pluginstoreitem
This commit is contained in:
commit
381f2fa13b
2 changed files with 17 additions and 6 deletions
|
|
@ -5,6 +5,8 @@ using System.Collections.Generic;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Net.Http.Json;
|
using System.Net.Http.Json;
|
||||||
|
using System.Text.Json;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
|
@ -16,6 +18,11 @@ namespace Flow.Launcher.Core.ExternalPlugins
|
||||||
|
|
||||||
private List<UserPlugin> plugins = new();
|
private List<UserPlugin> plugins = new();
|
||||||
|
|
||||||
|
private static JsonSerializerOptions PluginStoreItemSerializationOption = new JsonSerializerOptions()
|
||||||
|
{
|
||||||
|
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingDefault
|
||||||
|
};
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Fetch and deserialize the contents of a plugins.json file found at <see cref="ManifestFileUrl"/>.
|
/// Fetch and deserialize the contents of a plugins.json file found at <see cref="ManifestFileUrl"/>.
|
||||||
/// We use conditional http requests to keep repeat requests fast.
|
/// We use conditional http requests to keep repeat requests fast.
|
||||||
|
|
@ -32,12 +39,15 @@ namespace Flow.Launcher.Core.ExternalPlugins
|
||||||
|
|
||||||
request.Headers.Add("If-None-Match", latestEtag);
|
request.Headers.Add("If-None-Match", latestEtag);
|
||||||
|
|
||||||
using var response = await Http.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, token).ConfigureAwait(false);
|
using var response = await Http.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, token)
|
||||||
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
if (response.StatusCode == HttpStatusCode.OK)
|
if (response.StatusCode == HttpStatusCode.OK)
|
||||||
{
|
{
|
||||||
this.plugins = await response.Content.ReadFromJsonAsync<List<UserPlugin>>(cancellationToken: token).ConfigureAwait(false);
|
this.plugins = await response.Content
|
||||||
this.latestEtag = response.Headers.ETag.Tag;
|
.ReadFromJsonAsync<List<UserPlugin>>(PluginStoreItemSerializationOption, cancellationToken: token)
|
||||||
|
.ConfigureAwait(false);
|
||||||
|
this.latestEtag = response.Headers.ETag?.Tag;
|
||||||
|
|
||||||
Log.Info(nameof(CommunityPluginSource), $"Loaded {this.plugins.Count} plugins from {ManifestFileUrl}");
|
Log.Info(nameof(CommunityPluginSource), $"Loaded {this.plugins.Count} plugins from {ManifestFileUrl}");
|
||||||
return this.plugins;
|
return this.plugins;
|
||||||
|
|
@ -49,7 +59,8 @@ namespace Flow.Launcher.Core.ExternalPlugins
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log.Warn(nameof(CommunityPluginSource), $"Failed to load resource {ManifestFileUrl} with response {response.StatusCode}");
|
Log.Warn(nameof(CommunityPluginSource),
|
||||||
|
$"Failed to load resource {ManifestFileUrl} with response {response.StatusCode}");
|
||||||
throw new Exception($"Failed to load resource {ManifestFileUrl} with response {response.StatusCode}");
|
throw new Exception($"Failed to load resource {ManifestFileUrl} with response {response.StatusCode}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,8 @@ namespace Flow.Launcher.Core.ExternalPlugins
|
||||||
public string UrlDownload { get; set; }
|
public string UrlDownload { get; set; }
|
||||||
public string UrlSourceCode { get; set; }
|
public string UrlSourceCode { get; set; }
|
||||||
public string IcoPath { get; set; }
|
public string IcoPath { get; set; }
|
||||||
public DateTime LatestReleaseDate { get; set; }
|
public DateTime? LatestReleaseDate { get; set; }
|
||||||
public DateTime DateAdded { get; set; }
|
public DateTime? DateAdded { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue