using XFEWarframe.Desktop.Editing; namespace XFEWarframe.Player.ViewModels; public partial class EditorPageViewModel { private bool permissionRefreshPending; private string? permissionSelectedItem; private int permissionSelectedIndex; public string PermissionNotice => !Account.IsLoggedIn || IsCatalogMode ? "" : !Account.EditingEnabled ? UiText.Translate("当前为只读库存。请管理员在“玩家编辑权限”中开启“允许用户编辑物品”并保存;添加物品权限与编辑权限分别设置。") : !permissionRefreshPending && SelectedItem?.CanEdit == false ? UiText.Translate("当前物品没有已授权的编辑操作。管理员保存权限后,此页面会自动更新。") : ""; public bool HasPermissionNotice => PermissionNotice.Length > 0; private void NotifyPermissionNotice() { OnPropertyChanged(nameof(PermissionNotice)); OnPropertyChanged(nameof(HasPermissionNotice)); } private void InvalidatePermissions() { // Keep the selected identity across consecutive notifications from one account response. if (!permissionRefreshPending) { permissionSelectedItem = SelectedItem?.Key; permissionSelectedIndex = offset + Math.Max(0, SelectedItem is null ? 0 : Items.IndexOf(SelectedItem)); } Reset(); permissionRefreshPending = Account.IsLoggedIn; if (!Account.IsLoggedIn) permissionSelectedItem = null; NotifyDetailNavigation(); NotifyPermissionNotice(); } private Task RefreshPermissionsAsync() => RunAsync(async () => { if (!permissionRefreshPending || !Account.IsLoggedIn) return; permissionRefreshPending = false; var item = permissionSelectedItem; permissionSelectedItem = null; SelectedAccount = new(Account.AccountId, Account.DisplayName); offset = permissionSelectedIndex / PageSize * PageSize; try { await ReadAsync(item); } catch { if (!permissionRefreshPending && Account.IsLoggedIn) { permissionRefreshPending = true; permissionSelectedItem = item; } throw; } finally { NotifyDetailNavigation(); NotifyPermissionNotice(); } }); }