Browse Source

Auto download new products

Krzysztof Krysiński 1 month ago
parent
commit
776b1dccdb

+ 2 - 2
src/PixiEditor/Properties/AssemblyInfo.cs

@@ -43,5 +43,5 @@ using System.Runtime.InteropServices;
 // You can specify all the values or you can default the Build and Revision Numbers
 // You can specify all the values or you can default the Build and Revision Numbers
 // by using the '*' as shown below:
 // by using the '*' as shown below:
 // [assembly: AssemblyVersion("1.0.*")]
 // [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("2.0.0.99")]
-[assembly: AssemblyFileVersion("2.0.0.99")]
+[assembly: AssemblyVersion("2.0.1.0")]
+[assembly: AssemblyFileVersion("2.0.1.0")]

+ 13 - 1
src/PixiEditor/ViewModels/SubViewModels/UserViewModel.cs

@@ -1,6 +1,7 @@
 using System.Collections.ObjectModel;
 using System.Collections.ObjectModel;
 using Avalonia.Threading;
 using Avalonia.Threading;
 using CommunityToolkit.Mvvm.Input;
 using CommunityToolkit.Mvvm.Input;
+using PixiEditor.Extensions.CommonApi.UserPreferences;
 using PixiEditor.Helpers;
 using PixiEditor.Helpers;
 using PixiEditor.IdentityProvider;
 using PixiEditor.IdentityProvider;
 using PixiEditor.IdentityProvider.PixiAuth;
 using PixiEditor.IdentityProvider.PixiAuth;
@@ -134,7 +135,8 @@ internal class UserViewModel : SubViewModel<ViewModelMain>
         {
         {
             return;
             return;
         }
         }
-
+        
+        
         foreach (ProductData product in products)
         foreach (ProductData product in products)
         {
         {
             bool isInstalled = IsInstalled(product.Id);
             bool isInstalled = IsInstalled(product.Id);
@@ -145,6 +147,16 @@ internal class UserViewModel : SubViewModel<ViewModelMain>
                 installedVersion = Owner.ExtensionsSubViewModel.ExtensionLoader.LoadedExtensions
                 installedVersion = Owner.ExtensionsSubViewModel.ExtensionLoader.LoadedExtensions
                     .FirstOrDefault(x => x.Metadata.UniqueName == product.Id)?.Metadata.Version;
                     .FirstOrDefault(x => x.Metadata.UniqueName == product.Id)?.Metadata.Version;
             }
             }
+            else
+            {
+                bool productDownloadedAtLeastOnce = IPreferences.Current.GetPreference<bool>(
+                    $"product_{product.Id}_downloaded_at_least_once", false);
+                if (!productDownloadedAtLeastOnce)
+                {
+                    Dispatcher.UIThread.InvokeAsync(async () => await InstallContent(product.Id));
+                    IPreferences.Current.UpdateLocalPreference($"product_{product.Id}_downloaded_at_least_once", true);
+                }
+            }
 
 
             OwnedProducts.Add(new OwnedProductViewModel(product, isInstalled, installedVersion, InstallContentCommand,
             OwnedProducts.Add(new OwnedProductViewModel(product, isInstalled, installedVersion, InstallContentCommand,
                 IsInstalled));
                 IsInstalled));