using Newtonsoft.Json.Linq; using XFEWarframe.Desktop.Editing; namespace XFEWarframe.Player.ViewModels; public partial class InventoryPageViewModel { private SuggestionProvider? suggestions; public SuggestionProvider Suggestions => suggestions ??= new(async query => { if (!Account.IsLoggedIn) return []; return (await App.Accounts.InventoryAsync(query, Category?.Key ?? "", 0)).Items .Select(x => (object)new SearchSuggestion(x.Name, x.Type)).ToArray(); }); } public partial class ItemCatalogPageViewModel { private SuggestionProvider? suggestions; public SuggestionProvider Suggestions => suggestions ??= new(async query => { if (!Account.IsLoggedIn || !Account.ItemGrantEnabled) return []; return (await App.Accounts.CatalogAsync(query, Category?.Key ?? "", 0)).Items .Select(x => (object)new SearchSuggestion(x.Name, x.Type)).ToArray(); }); } public partial class EditorPageViewModel { private SuggestionProvider? suggestions; public SuggestionProvider Suggestions => suggestions ??= new(async query => { if (!Account.IsLoggedIn) return []; if (!Account.EditingEnabled) return (await AccountService.InventoryAsync(query, Category?.Key ?? "", 0)).Items .Select(x => (object)new SearchSuggestion(x.Name, x.Type)).ToArray(); var data = await AccountService.ReadEditorAsync(Category?.Key ?? "Suits", query, null, 0); return (data["items"] as JArray ?? []).Select(x => (object)new SearchSuggestion(x.Value("name")!, x.Value("key")!)).ToArray(); }); } public partial class RivenPageViewModel { private SuggestionProvider? ownedSuggestions; public SuggestionProvider OwnedSuggestions => ownedSuggestions ??= SuggestionProvider.OwnedRivens((query, skip) => AccountService.ReadEditorAsync("Upgrades", query, null, skip)); }