MCDO fixes 2

implement RestoreThenUpload for charadata

cleanup, actually show success/failure

actually sort chara data list lmao

add shared character data sets display to main ui (partial)

increase size of mcdo table slightly

fix selecting last new entry
This commit is contained in:
Stanley Dimant
2025-02-08 00:14:16 +01:00
committed by Loporrit
parent 8f9528879d
commit 27bbe96618
6 changed files with 113 additions and 32 deletions

View File

@@ -103,7 +103,7 @@ public sealed partial class CharaDataManager : DisposableMediatorSubscriberBase
public IDictionary<UserData, List<CharaDataMetaInfoExtendedDto>> SharedWithYouData => _sharedWithYouData;
public Task? UiBlockingComputation { get; private set; }
public ValueProgress<string>? UploadProgress { get; private set; }
public Task<(string Output, bool Success)>? UploadTask { get; private set; }
public Task<(string Output, bool Success)>? UploadTask { get; set; }
public bool BrioAvailable => _ipcManager.Brio.APIAvailable;
public Task ApplyCharaData(CharaDataMetaInfoDto dataMetaInfoDto, string charaName)
@@ -581,8 +581,31 @@ public sealed partial class CharaDataManager : DisposableMediatorSubscriberBase
var hasDto = _ownCharaData.TryGetValue(id, out var dto);
if (!hasDto || dto == null) return;
var missingFileList = dto.MissingFiles.ToList();
UiBlockingComputation = UploadTask = UploadFiles(missingFileList, async () =>
UiBlockingComputation = UploadTask = RestoreThenUpload(dto);
}
private async Task<(string Output, bool Success)> RestoreThenUpload(CharaDataFullExtendedDto dto)
{
var newDto = await _apiController.CharaDataAttemptRestore(dto.Id).ConfigureAwait(false);
if (newDto == null)
{
_ownCharaData.Remove(dto.Id);
_metaInfoCache.Remove(dto.FullId, out _);
UiBlockingComputation = null;
return ("No such DTO found", false);
}
await AddOrUpdateDto(newDto).ConfigureAwait(false);
_ = _ownCharaData.TryGetValue(dto.Id, out var extendedDto);
if (!extendedDto!.HasMissingFiles)
{
UiBlockingComputation = null;
return ("Restored successfully", true);
}
var missingFileList = extendedDto!.MissingFiles.ToList();
var result = await UploadFiles(missingFileList, async () =>
{
var newFilePaths = dto.FileGamePaths;
foreach (var missing in missingFileList)
@@ -595,7 +618,10 @@ public sealed partial class CharaDataManager : DisposableMediatorSubscriberBase
};
var res = await _apiController.CharaDataUpdate(updateDto).ConfigureAwait(false);
await AddOrUpdateDto(res).ConfigureAwait(false);
});
}).ConfigureAwait(false);
UiBlockingComputation = null;
return result;
}
internal void ApplyDataToSelf(CharaDataFullExtendedDto dataDto)
@@ -926,8 +952,7 @@ public sealed partial class CharaDataManager : DisposableMediatorSubscriberBase
}
finally
{
UploadTask = null;
UploadProgress = null;
UiBlockingComputation = null;
}
}

View File

@@ -100,6 +100,7 @@ public record PairDataAnalyzedMessage(string UID) : KeyedMessage(UID);
public record GameObjectHandlerCreatedMessage(GameObjectHandler GameObjectHandler, bool OwnedObject) : MessageBase;
public record GameObjectHandlerDestroyedMessage(GameObjectHandler GameObjectHandler, bool OwnedObject) : MessageBase;
public record HaltCharaDataCreation(bool Resume = false) : SameThreadMessage;
public record OpenCharaDataHubWithFilterMessage(UserData UserData) : MessageBase;
public record PluginChangeMessage(string InternalName, Version Version, bool IsLoaded) : KeyedMessage(InternalName);
#pragma warning restore S2094