1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-12 13:28:33 +00:00

Workshop - Added indicator for official workshop entries

This commit is contained in:
Robert 2024-07-22 11:01:50 +02:00
parent b00f5ca73a
commit a45d98c171
8 changed files with 45 additions and 16 deletions

View File

@ -14,6 +14,7 @@ public class EntryEntity
public int EntryType { get; set; }
public string Author { get; set; } = string.Empty;
public bool IsOfficial { get; set; }
public string Name { get; set; } = string.Empty;
public string Summary { get; set; } = string.Empty;
public long Downloads { get; set; }

View File

@ -11,8 +11,8 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace Artemis.Storage.Migrations
{
[DbContext(typeof(ArtemisDbContext))]
[Migration("20240706131336_ExpandInstalledEntry")]
partial class ExpandInstalledEntry
[Migration("20240722084220_AutoUpdating")]
partial class AutoUpdating
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
@ -264,6 +264,9 @@ namespace Artemis.Storage.Migrations
b.Property<DateTimeOffset>("InstalledAt")
.HasColumnType("TEXT");
b.Property<bool>("IsOfficial")
.HasColumnType("INTEGER");
b.Property<long?>("LatestReleaseId")
.HasColumnType("INTEGER");

View File

@ -6,7 +6,7 @@ using Microsoft.EntityFrameworkCore.Migrations;
namespace Artemis.Storage.Migrations
{
/// <inheritdoc />
public partial class ExpandInstalledEntry : Migration
public partial class AutoUpdating : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
@ -38,6 +38,13 @@ namespace Artemis.Storage.Migrations
nullable: false,
defaultValue: 0L);
migrationBuilder.AddColumn<bool>(
name: "IsOfficial",
table: "Entries",
type: "INTEGER",
nullable: false,
defaultValue: false);
migrationBuilder.AddColumn<long>(
name: "LatestReleaseId",
table: "Entries",
@ -50,7 +57,7 @@ namespace Artemis.Storage.Migrations
type: "TEXT",
nullable: false,
defaultValue: "");
// Enable auto-update on all entries that are not profiles
migrationBuilder.Sql("UPDATE Entries SET AutoUpdate = 1 WHERE EntryType != 2");
@ -87,6 +94,10 @@ namespace Artemis.Storage.Migrations
name: "Downloads",
table: "Entries");
migrationBuilder.DropColumn(
name: "IsOfficial",
table: "Entries");
migrationBuilder.DropColumn(
name: "LatestReleaseId",
table: "Entries");

View File

@ -261,6 +261,9 @@ namespace Artemis.Storage.Migrations
b.Property<DateTimeOffset>("InstalledAt")
.HasColumnType("TEXT");
b.Property<bool>("IsOfficial")
.HasColumnType("INTEGER");
b.Property<long?>("LatestReleaseId")
.HasColumnType("INTEGER");

View File

@ -39,7 +39,7 @@
<TextBlock Grid.Row="0" Margin="0 0 0 5" TextTrimming="CharacterEllipsis">
<Run Classes="h5" Text="{CompiledBinding Entry.Name, FallbackValue=Title}" />
<Run Classes="subtitle">by you</Run>
<Run Classes="subtitle" Text="{CompiledBinding Emoji}" />
<Run Text="{CompiledBinding Emoji}" />
</TextBlock>
<TextBlock Grid.Row="1"
Classes="subtitle"

View File

@ -11,7 +11,7 @@ namespace Artemis.UI.Screens.Workshop.Library.Tabs;
public class SubmissionsTabItemViewModel : ViewModelBase
{
private static readonly string[] Emojis = ["❤️", "🧡", "💛", "💚", "💙", "💜", "🤍", "💔", "❣️", "💕", "💞", "💓", "💗", "💖", "💘", "💝", "😍", "🥰"];
private static readonly string[] Emojis = ["❤️", "🧡", "💛", "💚", "💙", "💜", "💔", "❣️", "💕", "💞", "💓", "💗", "💖", "💘", "💝", "😍", "🥰"];
private readonly IRouter _router;
public SubmissionsTabItemViewModel(IGetSubmittedEntries_SubmittedEntries entry, IRouter router)

View File

@ -4,7 +4,6 @@ using System.Threading.Tasks;
using Artemis.Core;
using Artemis.Core.Services;
using Artemis.UI.Services.Interfaces;
using Artemis.UI.Shared.Services;
using Artemis.UI.Shared.Utilities;
using Artemis.WebClient.Workshop;
using Artemis.WebClient.Workshop.Handlers.InstallationHandlers;
@ -19,13 +18,11 @@ public class WorkshopUpdateService : IWorkshopUpdateService
{
private readonly ILogger _logger;
private readonly IWorkshopClient _client;
private readonly INotificationService _notificationService;
private readonly IWorkshopService _workshopService;
private readonly Lazy<IUpdateNotificationProvider> _updateNotificationProvider;
private readonly PluginSetting<bool> _showNotifications;
public WorkshopUpdateService(ILogger logger, IWorkshopClient client, IWorkshopService workshopService, ISettingsService settingsService,
Lazy<IUpdateNotificationProvider> updateNotificationProvider)
public WorkshopUpdateService(ILogger logger, IWorkshopClient client, IWorkshopService workshopService, ISettingsService settingsService, Lazy<IUpdateNotificationProvider> updateNotificationProvider)
{
_logger = logger;
_client = client;
@ -69,15 +66,27 @@ public class WorkshopUpdateService : IWorkshopUpdateService
_logger.Information("Auto-updating entry {Entry} to version {Version}", entry, latestRelease.Version);
EntryInstallResult updateResult = await _workshopService.InstallEntry(entry, latestRelease, new Progress<StreamProgress>(), CancellationToken.None);
try
{
EntryInstallResult updateResult = await _workshopService.InstallEntry(entry, latestRelease, new Progress<StreamProgress>(), CancellationToken.None);
// This happens during installation too but not on our reference of the entry
if (updateResult.IsSuccess)
entry.ApplyRelease(latestRelease);
// This happens during installation too but not on our reference of the entry
if (updateResult.IsSuccess)
entry.ApplyRelease(latestRelease);
_logger.Information("Auto-update result: {Result}", updateResult);
if (updateResult.IsSuccess)
_logger.Information("Auto-update successful for entry {Entry}", entry);
else
_logger.Warning("Auto-update failed for entry {Entry}: {Message}", entry, updateResult.Message);
return updateResult.IsSuccess;
return updateResult.IsSuccess;
}
catch (Exception e)
{
_logger.Warning(e, "Auto-update failed for entry {Entry}", entry);
}
return false;
}
/// <inheritdoc />

View File

@ -65,6 +65,7 @@ public class InstalledEntry : CorePropertyChanged, IEntrySummary
{
Id = Entity.EntryId;
Author = Entity.Author;
IsOfficial = Entity.IsOfficial;
Name = Entity.Name;
Summary = Entity.Summary;
EntryType = (EntryType) Entity.EntryType;
@ -87,6 +88,7 @@ public class InstalledEntry : CorePropertyChanged, IEntrySummary
Entity.EntryType = (int) EntryType;
Entity.Author = Author;
Entity.IsOfficial = IsOfficial;
Entity.Name = Name;
Entity.Summary = Summary;
Entity.Downloads = Downloads;