Config: Remove Pal.Client.Net dependency for HasRole check

This commit is contained in:
Liza 2023-02-16 13:27:28 +01:00
parent 5c82382161
commit 7e2ccd3b42
4 changed files with 5 additions and 6 deletions

View File

@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Text.Json.Serialization;
using Pal.Client.Net;
namespace Pal.Client.Configuration
{
@ -47,12 +46,12 @@ namespace Pal.Client.Configuration
Accounts.RemoveAll(a => a.Server == server && a.IsUsable);
}
public bool HasRoleOnCurrentServer(string role)
public bool HasRoleOnCurrentServer(string server, string role)
{
if (Mode != EMode.Online)
return false;
var account = FindAccount(RemoteApi.RemoteUrl);
var account = FindAccount(server);
return account == null || account.CachedRoles.Contains(role);
}
}

View File

@ -30,7 +30,7 @@ namespace Pal.Client.Configuration
IAccountConfiguration? FindAccount(string server);
void RemoveAccount(string server);
bool HasRoleOnCurrentServer(string role);
bool HasRoleOnCurrentServer(string server, string role);
}
public class DeepDungeonConfiguration

View File

@ -33,7 +33,7 @@ namespace Pal.Client.DependencyInjection
private async Task FetchFloorStatistics()
{
if (!_configuration.HasRoleOnCurrentServer("statistics:view"))
if (!_configuration.HasRoleOnCurrentServer(RemoteApi.RemoteUrl, "statistics:view"))
{
_chatGui.PalError(Localization.Command_pal_stats_CurrentFloor);
return;

View File

@ -296,7 +296,7 @@ namespace Pal.Client.Windows
private void DrawExportTab()
{
if (_configuration.HasRoleOnCurrentServer("export:run") &&
if (_configuration.HasRoleOnCurrentServer(RemoteApi.RemoteUrl, "export:run") &&
ImGui.BeginTabItem($"{Localization.ConfigTab_Export}###TabExport"))
{
string todaysFileName = $"export-{DateTime.Today:yyyy-MM-dd}.pal";