cleanup, actually show success/failure

This commit is contained in:
Stanley Dimant
2025-02-08 00:34:56 +01:00
parent 1d9bb90976
commit d369e08397
3 changed files with 39 additions and 21 deletions

View File

@@ -106,7 +106,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(CharaDataDownloadDto dataDownloadDto, string charaName)
@@ -631,6 +631,7 @@ public sealed partial class CharaDataManager : DisposableMediatorSubscriberBase
{
_ownCharaData.Remove(dto.Id);
_metaInfoCache.Remove(dto.FullId, out _);
UiBlockingComputation = null;
return ("No such DTO found", false);
}
@@ -639,11 +640,12 @@ public sealed partial class CharaDataManager : DisposableMediatorSubscriberBase
if (!extendedDto!.HasMissingFiles)
{
UiBlockingComputation = null;
return ("Restored successfully", true);
}
var missingFileList = extendedDto!.MissingFiles.ToList();
return await UploadFiles(missingFileList, async () =>
var result = await UploadFiles(missingFileList, async () =>
{
var newFilePaths = dto.FileGamePaths;
foreach (var missing in missingFileList)
@@ -657,6 +659,9 @@ 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)
@@ -987,8 +992,7 @@ public sealed partial class CharaDataManager : DisposableMediatorSubscriberBase
}
finally
{
UploadTask = null;
UploadProgress = null;
UiBlockingComputation = null;
}
}

View File

@@ -38,8 +38,9 @@ internal sealed partial class CharaDataHubUi
}
var indent = ImRaii.PushIndent(10f);
if (canUpdate || (!_charaDataManager.UploadTask?.IsCompleted ?? false))
if (canUpdate || _charaDataManager.UploadTask != null)
{
ImGuiHelpers.ScaledDummy(5);
UiSharedService.DrawGrouped(() =>
{
if (canUpdate)
@@ -364,7 +365,7 @@ internal sealed partial class CharaDataHubUi
if (_uiSharedService.IconTextButton(FontAwesomeIcon.Trash, "Delete Character Data"))
{
_ = _charaDataManager.DeleteCharaData(dataDto);
_selectedDtoId = string.Empty;
SelectedDtoId = string.Empty;
}
}
if (!UiSharedService.CtrlPressed())
@@ -575,7 +576,7 @@ internal sealed partial class CharaDataHubUi
{
var uDto = _charaDataManager.GetUpdateDto(entry.Id);
ImGui.TableNextColumn();
if (string.Equals(entry.Id, _selectedDtoId, StringComparison.Ordinal))
if (string.Equals(entry.Id, SelectedDtoId, StringComparison.Ordinal))
_uiSharedService.IconText(FontAwesomeIcon.CaretRight);
ImGui.TableNextColumn();
@@ -592,48 +593,48 @@ internal sealed partial class CharaDataHubUi
{
ImGui.TextUnformatted(idText);
}
if (ImGui.IsItemClicked()) _selectedDtoId = entry.Id;
if (ImGui.IsItemClicked()) SelectedDtoId = entry.Id;
ImGui.TableNextColumn();
ImGui.TextUnformatted(entry.Description);
if (ImGui.IsItemClicked()) _selectedDtoId = entry.Id;
if (ImGui.IsItemClicked()) SelectedDtoId = entry.Id;
UiSharedService.AttachToolTip(entry.Description);
ImGui.TableNextColumn();
ImGui.TextUnformatted(entry.CreatedDate.ToLocalTime().ToString());
if (ImGui.IsItemClicked()) _selectedDtoId = entry.Id;
if (ImGui.IsItemClicked()) SelectedDtoId = entry.Id;
ImGui.TableNextColumn();
ImGui.TextUnformatted(entry.UpdatedDate.ToLocalTime().ToString());
if (ImGui.IsItemClicked()) _selectedDtoId = entry.Id;
if (ImGui.IsItemClicked()) SelectedDtoId = entry.Id;
ImGui.TableNextColumn();
ImGui.TextUnformatted(entry.DownloadCount.ToString());
if (ImGui.IsItemClicked()) _selectedDtoId = entry.Id;
if (ImGui.IsItemClicked()) SelectedDtoId = entry.Id;
ImGui.TableNextColumn();
bool isDownloadable = !entry.HasMissingFiles
&& !string.IsNullOrEmpty(entry.GlamourerData);
_uiSharedService.BooleanToColoredIcon(isDownloadable, false);
if (ImGui.IsItemClicked()) _selectedDtoId = entry.Id;
if (ImGui.IsItemClicked()) SelectedDtoId = entry.Id;
UiSharedService.AttachToolTip(isDownloadable ? "Can be downloaded by others" : "Cannot be downloaded: Has missing files or data, please review this entry manually");
ImGui.TableNextColumn();
var count = entry.FileGamePaths.Concat(entry.FileSwaps).Count();
ImGui.TextUnformatted(count.ToString());
if (ImGui.IsItemClicked()) _selectedDtoId = entry.Id;
if (ImGui.IsItemClicked()) SelectedDtoId = entry.Id;
UiSharedService.AttachToolTip(count == 0 ? "No File data attached" : "Has File data attached");
ImGui.TableNextColumn();
bool hasGlamourerData = !string.IsNullOrEmpty(entry.GlamourerData);
_uiSharedService.BooleanToColoredIcon(hasGlamourerData, false);
if (ImGui.IsItemClicked()) _selectedDtoId = entry.Id;
if (ImGui.IsItemClicked()) SelectedDtoId = entry.Id;
UiSharedService.AttachToolTip(string.IsNullOrEmpty(entry.GlamourerData) ? "No Glamourer data attached" : "Has Glamourer data attached");
ImGui.TableNextColumn();
bool hasCustomizeData = !string.IsNullOrEmpty(entry.CustomizeData);
_uiSharedService.BooleanToColoredIcon(hasCustomizeData, false);
if (ImGui.IsItemClicked()) _selectedDtoId = entry.Id;
if (ImGui.IsItemClicked()) SelectedDtoId = entry.Id;
UiSharedService.AttachToolTip(string.IsNullOrEmpty(entry.CustomizeData) ? "No Customize+ data attached" : "Has Customize+ data attached");
ImGui.TableNextColumn();
@@ -641,7 +642,7 @@ internal sealed partial class CharaDataHubUi
if (!Equals(DateTime.MaxValue, entry.ExpiryDate))
eIcon = FontAwesomeIcon.Clock;
_uiSharedService.IconText(eIcon, ImGuiColors.DalamudYellow);
if (ImGui.IsItemClicked()) _selectedDtoId = entry.Id;
if (ImGui.IsItemClicked()) SelectedDtoId = entry.Id;
if (eIcon != FontAwesomeIcon.None)
{
UiSharedService.AttachToolTip($"This entry will expire on {entry.ExpiryDate.ToLocalTime()}");
@@ -695,12 +696,12 @@ internal sealed partial class CharaDataHubUi
var charaDataEntries = _charaDataManager.OwnCharaData.Count;
if (charaDataEntries != _dataEntries && _selectNewEntry && _charaDataManager.OwnCharaData.Any())
{
_selectedDtoId = _charaDataManager.OwnCharaData.Last().Value.Id;
SelectedDtoId = _charaDataManager.OwnCharaData.Last().Value.Id;
_selectNewEntry = false;
}
_dataEntries = _charaDataManager.OwnCharaData.Count;
_ = _charaDataManager.OwnCharaData.TryGetValue(_selectedDtoId, out var dto);
_ = _charaDataManager.OwnCharaData.TryGetValue(SelectedDtoId, out var dto);
DrawEditCharaData(dto);
}

View File

@@ -49,6 +49,19 @@ internal sealed partial class CharaDataHubUi : WindowMediatorSubscriberBase
private bool _openMcdOnlineOnNextRun = false;
private bool _readExport;
private string _selectedDtoId = string.Empty;
private string SelectedDtoId
{
get => _selectedDtoId;
set
{
if (!string.Equals(_selectedDtoId, value, StringComparison.Ordinal))
{
_charaDataManager.UploadTask = null;
_selectedDtoId = value;
}
}
}
private string _selectedSpecificUserIndividual = string.Empty;
private string _selectedSpecificGroupIndividual = string.Empty;
private string _sharedWithYouDescriptionFilter = string.Empty;
@@ -102,7 +115,7 @@ internal sealed partial class CharaDataHubUi : WindowMediatorSubscriberBase
}
_closalCts.Cancel();
_selectedDtoId = string.Empty;
SelectedDtoId = string.Empty;
_filteredDict = null;
_sharedWithYouOwnerFilter = string.Empty;
_importCode = string.Empty;
@@ -926,7 +939,7 @@ internal sealed partial class CharaDataHubUi : WindowMediatorSubscriberBase
{
if (_uiSharedService.IconTextButton(FontAwesomeIcon.Edit, "Open in MCD Online Editor"))
{
_selectedDtoId = data.Id;
SelectedDtoId = data.Id;
_openMcdOnlineOnNextRun = true;
}
}