Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Aragas committed May 27, 2024
1 parent a6c6a19 commit 9baebba
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,24 +53,18 @@
{
try
{
if (await _userClient.SetRoleAsync(userId: (int) _model.UserId, role: _model.Role) is { Error: not null })
if (await _userClient.SetRoleAsync(userId: (int) _model.UserId, role: _model.Role) is { Error: null })
{
await _notificationService.Success(
$"Assigned '{_model.Role}' to user with id '{_model.UserId}'!",
"Success!");
await _notificationService.Success($"Assigned '{_model.Role}' to user with id '{_model.UserId}'!", "Success!");
}
else
{
await _notificationService.Error(
$"Failed to assign '{_model.Role}' to user with id '{_model.UserId}'!",
"Error!");
await _notificationService.Error($"Failed to assign '{_model.Role}' to user with id '{_model.UserId}'!", "Error!");
}
}
catch
{
await _notificationService.Error(
$"Failed to assign '{_model.Role}' to user with id '{_model.UserId}'!",
"Error!");
await _notificationService.Error($"Failed to assign '{_model.Role}' to user with id '{_model.UserId}'!", "Error!");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@

public async ValueTask DisposeAsync()
{
_cancellationTokenSource.Cancel();
await _cancellationTokenSource.CancelAsync();
try { await _client.CloseAsync(WebSocketCloseStatus.NormalClosure, "Bye", CancellationToken.None); }
catch (Exception) { /* ignored */ }
await Task.WhenAny(_receiveTask, Task.Delay(2000));
Expand Down
8 changes: 2 additions & 6 deletions src/BUTR.Site.NexusMods.Client/Pages/Basic/Settings.razor
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,13 @@
private async Task OnSave()
{
await _localStorage.SetItemAsync("settings", _userSettings);
await _notificationService.Success(
"Saved the settings!",
"Success!");
await _notificationService.Success("Saved the settings!", "Success!");
}

private async Task OnCancel()
{
_userSettings = await _localStorage.GetItemAsync<UserSettings>("settings") ?? new();
await _notificationService.Success(
$"Reloaded the settings!",
"Success!");
await _notificationService.Success($"Reloaded the settings!", "Success!");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,14 @@
await _modalRef.Hide();
if (save && _dataGridRef?.Value is not null && _moduleIdToDelete is not null)
{
if (await _userClient.RemoveModuleManualLinkAsync(userId: _dataGridRef.Value.NexusModsUserId, moduleId: _moduleIdToDelete) is { Error: not null })
if (await _userClient.RemoveModuleManualLinkAsync(userId: _dataGridRef.Value.NexusModsUserId, moduleId: _moduleIdToDelete) is { Error: null })
{
await _notificationService.Success($"Disallowed succesfully!", "Success!");
await _notificationService.Success("Disallowed succesfully!", "Success!");
await _dataGridRef.Reload();
}
else
{
await _notificationService.Error($"Failed to disallow!", "Error!");
await _notificationService.Error("Failed to disallow!", "Error!");
}
}
}
Expand All @@ -129,24 +129,18 @@
{
if (await DoUserAllowMod(_model))
{
await _notificationService.Success(
$"Assigned '{_model.ModuleId}' to user '{_model.UserUrl}'!",
"Success!");
await _notificationService.Success($"Assigned '{_model.ModuleId}' to user '{_model.UserUrl}'!", "Success!");
if (_dataGridRef is not null)
await _dataGridRef.Reload();
}
else
{
await _notificationService.Error(
$"Failed to assign '{_model.ModuleId}' to user '{_model.UserUrl}'!",
"Error!");
await _notificationService.Error($"Failed to assign '{_model.ModuleId}' to user '{_model.UserUrl}'!", "Error!");
}
}
catch
{
await _notificationService.Error(
$"Failed to assign '{_model.ModuleId}' to user '{_model.UserUrl}'!",
"Error!");
await _notificationService.Error($"Failed to assign '{_model.ModuleId}' to user '{_model.UserUrl}'!", "Error!");
}
}

Expand Down Expand Up @@ -174,7 +168,7 @@
return false;
}

return await _userClient.AddModuleManualLinkAsync(moduleId: model.ModuleId, userId: hasUserId ? (int) userId : null, username: hasUsername ? username : null) is { Error: not null };
return await _userClient.AddModuleManualLinkAsync(moduleId: model.ModuleId, userId: hasUserId ? (int) userId : null, username: hasUsername ? username : null) is { Error: null };
}
private async Task<bool> DoUserDisallowMod(UserManuallyLinkedModuleModel model)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,14 @@
await _modalRef.Hide();
if (save && _dataGridRef?.Value is not null && _modIdToDelete is not null)
{
if (await _modClient.RemoveModuleManualLinkAsync(moduleId: _dataGridRef.Value.ModuleId, modId: _modIdToDelete.Value) is { Error: not null })
if (await _modClient.RemoveModuleManualLinkAsync(moduleId: _dataGridRef.Value.ModuleId, modId: _modIdToDelete.Value) is { Error: null })
{
await _notificationService.Success($"Disallowed succesfully!", "Success!");
await _notificationService.Success("Disallowed succesfully!", "Success!");
await _dataGridRef.Reload();
}
else
{
await _notificationService.Error($"Failed to disallow!", "Error!");
await _notificationService.Error("Failed to disallow!", "Error!");
}
}
}
Expand All @@ -136,24 +136,18 @@
{
if (await DoManualLink(_model))
{
await _notificationService.Success(
$"Linked '{_model.ModuleId}' to mod '{_model.NexusModsUrl}'!",
"Success!");
await _notificationService.Success($"Linked '{_model.ModuleId}' to mod '{_model.NexusModsUrl}'!", "Success!");
if (_dataGridRef is not null)
await _dataGridRef.Reload();
}
else
{
await _notificationService.Error(
$"Failed to link '{_model.ModuleId}' to mod '{_model.NexusModsUrl}'!",
"Error!");
await _notificationService.Error($"Failed to link '{_model.ModuleId}' to mod '{_model.NexusModsUrl}'!", "Error!");
}
}
catch
{
await _notificationService.Error(
$"Failed to link '{_model.ModuleId}' to mod '{_model.NexusModsUrl}'!",
"Error!");
await _notificationService.Error($"Failed to link '{_model.ModuleId}' to mod '{_model.NexusModsUrl}'!", "Error!");
}

_isLoading = false;
Expand All @@ -179,7 +173,7 @@
if (!NexusModsUtils.TryParseModUrl(model.NexusModsUrl, out _, out var nexusModsId) && !uint.TryParse(model.NexusModsUrl, out nexusModsId))
return false;

return await _modClient.AddModuleManualLinkAsync(moduleId: model.ModuleId, modId: (int) nexusModsId) is { Error: not null };
return await _modClient.AddModuleManualLinkAsync(moduleId: model.ModuleId, modId: (int) nexusModsId) is { Error: null };
}
private async Task<bool> DoManualUnlink(LinkedByStaffModuleNexusModsModsModel model)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<NodeContent>
@context.Path.Replace(".diff", ".dll")

@if (context.Type == NodeType.File && context.Visible)
@if (context is { Type: NodeType.File, Visible: true })
{
if (context.Content.Count == 0)
{
Expand Down
20 changes: 7 additions & 13 deletions src/BUTR.Site.NexusMods.Client/Pages/User/AllowUserMod.razor
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,14 @@
await _modalRef.Hide();
if (save && _dataGridRef?.Value is not null && _userIdToDelete is not null)
{
if (await _userClient.RemoveNexusModsModManualLinkAsync(userId: (int) _userIdToDelete, modId: _dataGridRef.Value.NexusModsModId, cancellationToken: CancellationToken.None) is { Error: not null })
if (await _userClient.RemoveNexusModsModManualLinkAsync(userId: (int) _userIdToDelete, modId: _dataGridRef.Value.NexusModsModId, cancellationToken: CancellationToken.None) is { Error: null })
{
await _notificationService.Success($"Disallowed succesfully!", "Success!");
await _notificationService.Success("Disallowed succesfully!", "Success!");
await _dataGridRef.Reload();
}
else
{
await _notificationService.Error($"Failed to disallow!", "Error!");
await _notificationService.Error("Failed to disallow!", "Error!");
}
}
}
Expand All @@ -127,24 +127,18 @@
{
if (await DoUserAllowMod(_model))
{
await _notificationService.Success(
$"Assigned '{_model.ModUrl}' to user '{_model.UserUrl}'!",
"Success!");
await _notificationService.Success($"Assigned '{_model.ModUrl}' to user '{_model.UserUrl}'!", "Success!");
if (_dataGridRef is not null)
await _dataGridRef.Reload();
}
else
{
await _notificationService.Error(
$"Failed to assign '{_model.ModUrl}' to user '{_model.UserUrl}'!",
"Error!");
await _notificationService.Error($"Failed to assign '{_model.ModUrl}' to user '{_model.UserUrl}'!", "Error!");
}
}
catch
{
await _notificationService.Error(
$"Failed to assign '{_model.ModUrl}' to user '{_model.UserUrl}'!",
"Error!");
await _notificationService.Error($"Failed to assign '{_model.ModUrl}' to user '{_model.UserUrl}'!", "Error!");
}
}

Expand Down Expand Up @@ -178,7 +172,7 @@
return false;
}

return await _userClient.AddNexusModsModManualLinkAsync(modId: (int) modId, userId: hasUserId ? (int) userId : null, username: hasUsername ? username : null) is { Error: not null };
return await _userClient.AddNexusModsModManualLinkAsync(modId: (int) modId, userId: hasUserId ? (int) userId : null, username: hasUsername ? username : null) is { Error: null };
}
private async Task<bool> DoUserDisallowMod(UserManuallyLinkedModModel model)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
if (save && _datagridPagingRef?.Value is not null)
{
var updatedCrashReport = _datagridPagingRef.Value with { };
if (await _crashReportsClient.UpdateAsync(updatedCrashReport.Id, updatedCrashReport.Status, updatedCrashReport.Comment) is { Error: not null })
if (await _crashReportsClient.UpdateAsync(updatedCrashReport.Id, updatedCrashReport.Status, updatedCrashReport.Comment) is { Error: null })
{
await _notificationService.Success("Saved Crash Report!", "Success!");
}
Expand Down
4 changes: 2 additions & 2 deletions src/BUTR.Site.NexusMods.Client/Pages/User/Mods.razor
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,12 @@
if (!NexusModsUtils.TryParseModUrl(model.ModUrl, out _, out var modId) && !uint.TryParse(model.ModUrl, out modId))
return false;

return await _userClient.AddNexusModsModLinkAsync((int) modId) is { Error: not null };
return await _userClient.AddNexusModsModLinkAsync((int) modId) is { Error: null };
}

private async Task<bool> DoUnlinkMod(UserLinkedModModel model)
{
return await _userClient.RemoveNexusModsModLinkAsync(modId: model.NexusModsModId) is { Error: not null };
return await _userClient.RemoveNexusModsModLinkAsync(modId: model.NexusModsModId) is { Error: null };
}

private async Task<DataGridPaging<UserLinkedModModel>.ItemsResponse?> GetMods(int page, int pageSize, ICollection<Filtering> filters, ICollection<Sorting> sortings, CancellationToken ct = default)
Expand Down

0 comments on commit 9baebba

Please sign in to comment.