1
0
mirror of https://github.com/bitwarden/mobile synced 2025-12-22 11:13:49 +00:00

Fixed flickering on iOS while loading collections for the collection crash hotfix (#1852)

This commit is contained in:
Federico Maccaroni
2022-03-18 15:41:15 -03:00
committed by GitHub
parent 1d9671bc5c
commit 383eee6ec7
4 changed files with 97 additions and 36 deletions

View File

@@ -178,7 +178,9 @@ namespace Bit.App.Pages
}
// TODO: refactor this
if (Device.RuntimePlatform == Device.Android)
if (Device.RuntimePlatform == Device.Android
||
GroupedSends.Any())
{
var items = new List<ISendGroupingsPageListItem>();
foreach (var itemGroup in groupedSends)
@@ -191,16 +193,30 @@ namespace Bit.App.Pages
}
else
{
// HACK: This waitings are to avoid crash on iOS
GroupedSends.Clear();
await Task.Delay(60);
// HACK: we need this on iOS, so that it doesn't crash when adding coming from an empty list
var first = true;
var items = new List<ISendGroupingsPageListItem>();
foreach (var itemGroup in groupedSends)
{
GroupedSends.Add(new SendGroupingsPageHeaderListItem(itemGroup.Name, itemGroup.ItemCount));
await Task.Delay(60);
if (!first)
{
items.Add(new SendGroupingsPageHeaderListItem(itemGroup.Name, itemGroup.ItemCount));
}
else
{
first = false;
}
items.AddRange(itemGroup);
}
GroupedSends.AddRange(itemGroup);
if (groupedSends.Any())
{
GroupedSends.ReplaceRange(new List<ISendGroupingsPageListItem> { new SendGroupingsPageHeaderListItem(groupedSends[0].Name, groupedSends[0].ItemCount) });
GroupedSends.AddRange(items);
}
else
{
GroupedSends.Clear();
}
}
}