Merge branch 'develop' into electron

This commit is contained in:
jliddev
2020-09-30 15:09:04 -05:00
10 changed files with 69 additions and 14 deletions

View File

@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
@@ -7,12 +7,7 @@
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="protobuf-net" Version="3.0.29" />
</ItemGroup>
<ItemGroup>
<Reference Include="System.ComponentModel.Annotations">
<HintPath>C:\Program Files (x86)\Microsoft SDKs\UWPNuGetPackages\microsoft.netcore.universalwindowsplatform\6.2.10\ref\uap10.0.15138\System.ComponentModel.Annotations.dll</HintPath>
</Reference>
<PackageReference Include="System.ComponentModel.Annotations" Version="4.7.0" />
</ItemGroup>
</Project>

View File

@@ -1,5 +1,13 @@
{
"ChangeLogs": [
{
"Version": "1.18.0",
"Description": "Add an 'Open Folder' option to the addon context menu (By Xathz).\nFeatured addons are now sorted by download count."
},
{
"Version": "1.17.1",
"Description": "Fix a visual bug where auto updated addons were not shown up to date on the My Addons page."
},
{
"Version": "1.17.0",
"Description": "Auto updates should function more like you would expect.\nSystem Notifications should appear when addons are auto updated.\nRe-Scan is now less desctructive, should preserve channels and auto update state.\nAdd the ability to update multiple clients at once by right clicking update-all.\nBug fixes.\nUI Updates."

View File

@@ -3,6 +3,7 @@ using System.IO;
using System.Linq;
using WowUp.Common.Enums;
using WowUp.WPF.Entities;
using WowUp.WPF.Services.Contracts;
using WowUp.WPF.Utilities;
namespace WowUp.WPF.Extensions

View File

@@ -0,0 +1,12 @@
using WowUp.Common.Enums;
using WowUp.WPF.Entities;
namespace WowUp.WPF.Models.Events
{
public class AddonStateEventArgs
{
public Addon Addon { get; set; }
public AddonInstallState AddonInstallState { get; set; }
public decimal Progress { get; set; }
}
}

View File

@@ -45,9 +45,12 @@ namespace WowUp.WPF.Services
public event AddonEventHandler AddonUninstalled;
public event AddonEventHandler AddonInstalled;
public event AddonEventHandler AddonUpdated;
public event AddonStateEventHandler AddonStateChanged;
public string BackupPath => Path.Combine(FileUtilities.AppDataPath, BackupFolder);
public string GetFullInstallPath(Addon addon) => Path.GetFullPath(Path.Combine(_warcraftService.GetAddonFolderPath(addon.ClientType), addon.FolderName));
public AddonService(
IServiceProvider serviceProvider,
IAddonRepository addonRepository,
@@ -160,7 +163,7 @@ namespace WowUp.WPF.Services
var addonResults = await Task.WhenAll(addonTasks);
var addonResultsConcat = addonResults.SelectMany(res => res);
return addonResultsConcat.ToList();
return addonResultsConcat.OrderByDescending(result => result.DownloadCount).ToList();
}
public async Task<List<Addon>> GetAddons(WowClientType clientType, bool rescan = false)
@@ -383,6 +386,19 @@ namespace WowUp.WPF.Services
await InstallAddon(addon.Id, onUpdate);
}
private void SendAddonStateChange(
Addon addon,
AddonInstallState addonInstallState,
decimal progress)
{
AddonStateChanged?.Invoke(this, new AddonStateEventArgs
{
Addon = addon,
AddonInstallState = addonInstallState,
Progress = progress
});
}
public async Task InstallAddon(int addonId, Action<AddonInstallState, decimal> updateAction = null)
{
var addon = GetAddon(addonId);
@@ -392,6 +408,7 @@ namespace WowUp.WPF.Services
}
updateAction?.Invoke(AddonInstallState.Downloading, 25m);
SendAddonStateChange(addon, AddonInstallState.Downloading, 25m);
string downloadedFilePath = string.Empty;
string unzippedDirectory = string.Empty;
@@ -405,11 +422,13 @@ namespace WowUp.WPF.Services
if (!string.IsNullOrEmpty(addon.InstalledVersion))
{
updateAction?.Invoke(AddonInstallState.BackingUp, 0.50m);
SendAddonStateChange(addon, AddonInstallState.BackingUp, 75m);
var backupZipFilePath = Path.Combine(BackupPath, $"{addon.Name}-{addon.InstalledVersion}.zip");
//await _downloadService.ZipFile(downloadedFilePath, backupZipFilePath);
}
updateAction?.Invoke(AddonInstallState.Installing, 75m);
SendAddonStateChange(addon, AddonInstallState.Installing, 75m);
unzippedDirectory = await _downloadService.UnzipFile(downloadedFilePath);
@@ -449,6 +468,7 @@ namespace WowUp.WPF.Services
}
updateAction?.Invoke(AddonInstallState.Complete, 100m);
SendAddonStateChange(addon, AddonInstallState.Complete, 100m);
}
private async Task CacheThumbnail(Addon addon)

View File

@@ -9,15 +9,19 @@ using WowUp.WPF.Models.Events;
namespace WowUp.WPF.Services.Contracts
{
public delegate void AddonEventHandler(object sender, AddonEventArgs e);
public delegate void AddonStateEventHandler(object sender, AddonStateEventArgs e);
public interface IAddonService
{
event AddonEventHandler AddonUninstalled;
event AddonEventHandler AddonInstalled;
event AddonEventHandler AddonUpdated;
event AddonStateEventHandler AddonStateChanged;
string BackupPath { get; }
string GetFullInstallPath(Addon addon);
Addon GetAddon(int addonId);
Addon UpdateAddon(Addon addon);

View File

@@ -1,5 +1,6 @@
using Serilog;
using System;
using System.Diagnostics;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media;
@@ -31,6 +32,7 @@ namespace WowUp.WPF.ViewModels
}
public Command ActionCommand { get; set; }
public Command OpenFolderCommand { get; set; }
public Command InstallCommand { get; set; }
public Command UpdateCommand { get; set; }
public Command OpenLinkCommand { get; set; }
@@ -263,6 +265,7 @@ namespace WowUp.WPF.ViewModels
_addonService = addonService;
_analyticsService = analyticsService;
OpenFolderCommand = new Command(() => addonService.GetFullInstallPath(Addon).OpenUrlInBrowser());
InstallCommand = new Command(async () => await InstallAddon());
UpdateCommand = new Command(async () => await UpdateAddon());
OpenLinkCommand = new Command(() => ExternalUrl.OpenUrlInBrowser());
@@ -327,12 +330,9 @@ namespace WowUp.WPF.ViewModels
public async Task UpdateAddon()
{
ShowStatusText = false;
ShowUpdateButton = false;
try
{
await _addonService.InstallAddon(_addon.Id, OnInstallUpdate);
await _addonService.InstallAddon(_addon.Id);
}
catch (Exception ex)
{
@@ -423,8 +423,11 @@ namespace WowUp.WPF.ViewModels
_analyticsService.TrackUserAction("Addons", "Channel", channelType.ToString());
}
private void OnInstallUpdate(AddonInstallState installState, decimal percent)
public void OnInstallUpdate(AddonInstallState installState, decimal percent)
{
ShowStatusText = false;
ShowUpdateButton = false;
try
{
ProgressText = GetInstallStateText(installState);

View File

@@ -212,6 +212,15 @@ namespace WowUp.WPF.ViewModels
AddonUpdated(args.Addon);
};
_addonService.AddonStateChanged += (sender, args) =>
{
var addon = DisplayAddons.FirstOrDefault(listItem => listItem.Addon.Id == args.Addon.Id);
if(addon != null)
{
addon.OnInstallUpdate(args.AddonInstallState, args.Progress);
}
};
_warcraftService.ProductChanged += (sender, args) =>
{
SetClientNames();

View File

@@ -280,6 +280,9 @@
Command="{Binding AlphaCheckedCommand}"></MenuItem>
</MenuItem>
<Separator Visibility="{Binding ShowUpdateButton, Converter={StaticResource BoolToVisibilty}}" />
<MenuItem Header="Open Folder"
Command="{Binding OpenFolderCommand}" />
<Separator Visibility="{Binding ShowUpdateButton, Converter={StaticResource BoolToVisibilty}}" />
<MenuItem Header="Update"
Visibility="{Binding ShowUpdateButton, Converter={StaticResource BoolToVisibilty}}"
Command="{Binding InstallCommand}"/>

View File

@@ -10,7 +10,7 @@
<PackageId>WowUp</PackageId>
<Authors>Jliddev</Authors>
<Product>WowUp</Product>
<Version>1.18.0-beta.1</Version>
<Version>1.18.0-beta.3</Version>
<ApplicationIcon>wowup_logo_512np_RRT_icon.ico</ApplicationIcon>
<Copyright>jliddev</Copyright>
<PackageProjectUrl>https://wowup.io</PackageProjectUrl>