Esempio n. 1
0
        /// <summary>
        /// Search function.
        /// </summary>
        /// <returns>An asynchronous task.</returns>
        protected async Task SearchAsync()
        {
            if (Loading)
            {
                searchQueued = true;
                return;
            }

            searchQueued = false;

            Alias = Alias.Trim();
            Tag   = Tag.Trim();
            Text  = Text.Trim();

            if (CanSearch)
            {
                Loading = true;

                do
                {
                    searchQueued = false;
                    await LoadingService.WrapExecutionAsync(
                        async() =>
                        DocsList = await DocumentService.QueryDocumentsAsync(
                            Text,
                            Alias,
                            Tag));
                }while (searchQueued);

                Loading = false;
            }
            else
            {
                DocsList = null;
            }

            StateHasChanged();

            var queryString =
                NavigationHelper.CreateQueryString(
                    (nameof(Text), WebUtility.UrlEncode(Text)),
                    (nameof(Alias), WebUtility.UrlEncode(Alias)),
                    (nameof(Tag), WebUtility.UrlEncode(Tag)));

            navigatingToThisPage = false;
            NavigationService.NavigateTo($"/?{queryString}");

            await InputElement.FocusAsync();
        }