Skip to content

Commit

Permalink
Upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
suchmememanyskill committed Apr 17, 2024
1 parent 096a1f5 commit 971f79a
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 13 deletions.
19 changes: 18 additions & 1 deletion StlSpy/Service/LocalStorage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,24 @@ public async Task AddPost(CollectionId id, Post post, IProgress<float>? progress

if (!AreFilesCached(post.UniversalId))
{
await SavePostLocally(post, progress);
try
{
await SavePostLocally(post, progress);
}
catch (Exception e)
{
var path = GetPath(post.UniversalId);
try
{
Directory.Delete(path, true);
}
catch
{
}

throw;
}

}

if (!collection.UIDs.Contains(post.UniversalId))
Expand Down
10 changes: 5 additions & 5 deletions StlSpy/StlSpy.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
<TrimmableAssembly Include="Avalonia.Themes.Default" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Avalonia" Version="11.0.0" />
<PackageReference Include="Avalonia.Desktop" Version="11.0.0" />
<PackageReference Include="Avalonia" Version="11.1.0-beta1" />
<PackageReference Include="Avalonia.Desktop" Version="11.1.0-beta1" />
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.0" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.0" />
<PackageReference Include="MessageBox.Avalonia" Version="3.0.0" />
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.1.0-beta1" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.1.0-beta1" />
<PackageReference Include="MessageBox.Avalonia" Version="3.1.5.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.2-beta2" />
<PackageReference Include="TextCopy" Version="6.2.1" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion StlSpy/Utils/Request.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static async Task<byte[]> GetAsync(Uri uri, Dictionary<string, string> he
{
using (HttpClient client = new())
{
client.Timeout = TimeSpan.FromMinutes(5);
client.Timeout = TimeSpan.FromMinutes(1);

foreach (var kv in headers)
client.DefaultRequestHeaders.Add(kv.Key, kv.Value);
Expand Down
3 changes: 2 additions & 1 deletion StlSpy/Views/LocalCollectionView.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ private async void AddTopButtons()

private async void Get()
{
_view.SetPosts(GetPosts());
await _view.SetPosts(GetPosts());
}

private async Task<List<PreviewPostView>> GetPosts()
Expand All @@ -87,6 +87,7 @@ private async Task<List<PreviewPostView>> GetPosts()
await load.WaitUntilReady();
load.Complete();
}

return (await storage.GetPosts(_id))!.Posts.OrderByDescending(x => x.Added).Select(x =>
{
var post = new PreviewPostView(x, ApiDescription.GetLocalApiDescription());
Expand Down
15 changes: 10 additions & 5 deletions StlSpy/Views/PreviewPostView.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,8 @@ public partial class PreviewPostView : UserControlExt<PreviewPostView>

public event Action? OnNeedListReload;

public async void DownloadImage()
public async void GetCoverImage()
{
if (_downloadedImage)
return;

_downloadedImage = true;
try
{
byte[]? data = await Post.Thumbnail.Get();
Expand All @@ -58,6 +54,15 @@ public async void DownloadImage()
}
}

public void DownloadImage()
{
if (_downloadedImage)
return;

_downloadedImage = true;
Dispatcher.UIThread.Post(GetCoverImage, DispatcherPriority.Background);
}

public PreviewPostView(PreviewPost previewPost, ApiDescription api)
{
Post = previewPost;
Expand Down

0 comments on commit 971f79a

Please sign in to comment.