migrate to strong api calls (#29)

* migrate to strong api calls

* set last added user to null on changing notes popup setting
This commit is contained in:
rootdarkarchon
2022-10-08 14:35:30 +02:00
committed by GitHub
parent 9533dd0cfb
commit f9cf26ed69
11 changed files with 338 additions and 201 deletions

View File

@@ -158,6 +158,7 @@ public class SettingsUi : Window, IDisposable
ImGui.Separator();
if (ImGui.Checkbox("Open Notes Popup on user addition", ref _openPopupOnAddition))
{
_apiController.LastAddedUser = null;
_configuration.OpenPopupOnAdd = _openPopupOnAddition;
_configuration.Save();
}
@@ -196,14 +197,14 @@ public class SettingsUi : Window, IDisposable
if (ImGui.Button(
FontAwesomeIcon.Upload.ToIconString() + "##updateFile" + forbiddenFile.Hash))
{
_ = _apiController.AddOrUpdateForbiddenFileEntry(forbiddenFile);
_ = _apiController.AdminUpdateOrAddForbiddenFile(forbiddenFile);
}
ImGui.SameLine();
if (ImGui.Button(FontAwesomeIcon.Trash.ToIconString() + "##deleteFile" +
forbiddenFile.Hash))
{
_ = _apiController.DeleteForbiddenFileEntry(forbiddenFile);
_ = _apiController.AdminDeleteForbiddenFile(forbiddenFile);
}
ImGui.PopFont();
@@ -221,7 +222,7 @@ public class SettingsUi : Window, IDisposable
ImGui.PushFont(UiBuilder.IconFont);
if (ImGui.Button(FontAwesomeIcon.Plus.ToIconString() + "##addForbiddenFile"))
{
_ = _apiController.AddOrUpdateForbiddenFileEntry(new ForbiddenFileDto()
_ = _apiController.AdminUpdateOrAddForbiddenFile(new ForbiddenFileDto()
{
ForbiddenBy = _forbiddenFileHashForbiddenBy,
Hash = _forbiddenFileHashEntry
@@ -271,7 +272,7 @@ public class SettingsUi : Window, IDisposable
if (ImGui.Button(FontAwesomeIcon.Upload.ToIconString() + "##updateUser" +
bannedUser.CharacterHash))
{
_ = _apiController.AddOrUpdateBannedUserEntry(bannedUser);
_ = _apiController.AdminUpdateOrAddBannedUser(bannedUser);
}
ImGui.SameLine();
@@ -280,7 +281,7 @@ public class SettingsUi : Window, IDisposable
if (ImGui.Button(FontAwesomeIcon.Trash.ToIconString() + "##deleteUser" +
bannedUser.CharacterHash))
{
_ = _apiController.DeleteBannedUserEntry(bannedUser);
_ = _apiController.AdminDeleteBannedUser(bannedUser);
}
ImGui.PopFont();
@@ -305,7 +306,7 @@ public class SettingsUi : Window, IDisposable
ImGui.PushFont(UiBuilder.IconFont);
if (ImGui.Button(FontAwesomeIcon.Plus.ToIconString() + "##addForbiddenFile"))
{
_ = _apiController.AddOrUpdateBannedUserEntry(new BannedUserDto()
_ = _apiController.AdminUpdateOrAddBannedUser(new BannedUserDto()
{
CharacterHash = _forbiddenFileHashForbiddenBy,
Reason = _forbiddenFileHashEntry
@@ -378,7 +379,7 @@ public class SettingsUi : Window, IDisposable
if (ImGui.Button(FontAwesomeIcon.SkullCrossbones.ToIconString() + "##onlineUserBan" +
onlineUser.CharacterNameHash))
{
_ = _apiController.AddOrUpdateBannedUserEntry(new BannedUserDto
_ = _apiController.AdminUpdateOrAddBannedUser(new BannedUserDto
{
CharacterHash = onlineUser.CharacterNameHash,
Reason = "Banned by " + _uiShared.PlayerName
@@ -393,7 +394,7 @@ public class SettingsUi : Window, IDisposable
"##onlineUserModerator" +
onlineUser.CharacterNameHash))
{
_apiController.PromoteToModerator(onlineUser.UID);
_apiController.AdminChangeModeratorStatus(onlineUser.UID, true);
}
}
else
@@ -402,7 +403,7 @@ public class SettingsUi : Window, IDisposable
"##onlineUserNonModerator" +
onlineUser.CharacterNameHash))
{
_apiController.DemoteFromModerator(onlineUser.UID);
_apiController.AdminChangeModeratorStatus(onlineUser.UID, false);
}
}
}
@@ -444,7 +445,7 @@ public class SettingsUi : Window, IDisposable
if (ImGui.Button("Delete everything", new Vector2(buttonSize, 0)))
{
Task.Run(() => _apiController.DeleteAllMyFiles());
Task.Run(() => _apiController.FilesDeleteAll());
_deleteFilesPopupModalShown = false;
}
@@ -481,7 +482,7 @@ public class SettingsUi : Window, IDisposable
if (ImGui.Button("Delete account", new Vector2(buttonSize, 0)))
{
Task.Run(() => _apiController.DeleteAccount());
Task.Run(() => _apiController.UserDelete());
_deleteAccountPopupModalShown = false;
SwitchToIntroUi?.Invoke();
}