Config: Remove Pal.Client.Net dependency for HasRole check
This commit is contained in:
parent
5c82382161
commit
7e2ccd3b42
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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";
|
||||
|
Loading…
Reference in New Issue
Block a user