Sharpnado.TaskLoaderView icon indicating copy to clipboard operation
Sharpnado.TaskLoaderView copied to clipboard

Activity Indicator only showing up when Task.Delay(10) is there

Open NPadrutt opened this issue 1 year ago • 1 comments

Platform (please complete the following information):

  • OS: iOS (havent tested Android)
  • Device: Simulator
  • Sdk vervion: [iOS 11/Android SDK 21]
  • MAUI: 7.0.92

Describe the bug I have a List that displays a couple of categories / tags. I call the load function in the OnNavigatedTo method and it works as far as it displays the items after a second or so. But the busy indicator does only show up, when I add a await Task.Delay(10) before my data are loaded from SQLite (fun fact Delay(5) seems to be not sufficient as well ^^). Any idea why that is and what I'm doing wrong?


    public void Initialize()
    {
        Loader.Load(_ => LoadCategories());
    }

    private async Task<List<CategoryGroup>> LoadCategories(string searchTerm = "")
    {
        // Why has this to be here?
        await Task.Delay(10);
        var categories = await mediator.Send(new GetCategoryBySearchTermQuery(searchTerm));
        var categoryVms = categories.Select(c => new CategoryListItemViewModel { Id = c.Id, Name = c.Name, RequireNote = c.RequireNote }).ToList();
        var groupedCategories = categoryVms.GroupBy(c => c.Name[0].ToString(CultureInfo.InvariantCulture).ToUpper(CultureInfo.InvariantCulture))
            .Select(g => new CategoryGroup(title: g.Key, categoryItems: g.ToList()));

        return new(groupedCategories);
    }

NPadrutt avatar Jul 14 '23 07:07 NPadrutt