Skip to content

Commit

Permalink
Merge pull request #126 from Gamhub-io/fixes/feed_reload
Browse files Browse the repository at this point in the history
Fixes/feed reload
  • Loading branch information
bricefriha authored Jun 4, 2024
2 parents 5e5014a + 6255c86 commit a67cd87
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 46 deletions.
59 changes: 27 additions & 32 deletions AresNews/AresNews/ViewModels/NewsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,6 @@ public async Task FetchArticles(bool isFullRefresh = false)

}
}
//articles = new ObservableCollection<Article> (GetBackupFromDb().OrderBy(a => a.Time).ToList()) ;

var page = (NewsPage)((IShellSectionController)Shell.Current?.CurrentItem?.CurrentItem).PresentedPage;
page.DisplayOfflineMessage(ex.Message);
Expand All @@ -550,36 +549,32 @@ public async Task FetchArticles(bool isFullRefresh = false)
IsRefreshing = false;
return;
}

//MainThread.BeginInvokeOnMainThread(() =>
//{

if (OnTopScroll)
{
// Update list of articles
UpdateArticles(articles);
try
{
// Manage backup
_ = RefreshDB();

}
catch
{
}
finally
{
_isLaunching = false;
}

IsRefreshing = false;
}

else
{
UnnoticedArticles = new ObservableCollection<Article>(articles);
}
//});
if (OnTopScroll)
{
// Update list of articles
UpdateArticles(articles);
try
{
// Manage backup
_ = RefreshDB();

}
catch
{
}
finally
{
_isLaunching = false;
}

IsRefreshing = false;
}

else
{
UnnoticedArticles = new ObservableCollection<Article>(articles);
}


}
Expand All @@ -599,11 +594,11 @@ private void UpdateArticles(IEnumerable<Article> articles)
foreach (var current in listArticle)
{
// Check if the current article already exists in the _articles collection
Article existingArticle = _articles.FirstOrDefault(a => a.Id == current.Id);
Article existingArticle = _articles.FirstOrDefault(a => a.MongooseId == current.MongooseId);

if (existingArticle == null)
// Article doesn't exist in _articles, add it to the articlesToAdd list
Articles.Add(current);
Articles.Insert(0,current);
else if (!existingArticle.IsEqualTo(current))
// Article exists in _articles, add it to the articlesToUpdate list
articlesToUpdate.Add(current);
Expand Down
16 changes: 2 additions & 14 deletions AresNews/AresNews/Views/ArticlePage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,8 @@ protected override void OnDisappearing()
// Stop all text to speech
_vm.StopTtS();


//const int timeToWait = 4;
//_vm.SelectedArticle.Content = null;

//// For sefty it's better to wait 4 seconds before navigating back from this page
//double totalSeconds = _vm.timeSpent.Elapsed.TotalSeconds;

//if (totalSeconds < timeToWait)
//{
// Thread.Sleep(Convert.ToInt32((timeToWait - totalSeconds)* 1000));
//}
base.OnDisappearing();


}
/// <summary>
Expand Down Expand Up @@ -93,7 +82,7 @@ public void OpenDropdownMenu()
{
double height = 70;
double width = 180;
//_vm.ModalClose = false;

// Animation
void callbackH(double inputH) => dropdownMenu.HeightRequest = inputH;
void callbackW(double inputW) => dropdownMenu.WidthRequest = inputW;
Expand All @@ -110,7 +99,6 @@ public void OpenDropdownMenu()
/// </summary>
public void CloseDropdownMenu()
{
//_vm.ModalClose = true;

// Animation
void callbackH(double inputH) => dropdownMenu.HeightRequest = inputH;
Expand Down

0 comments on commit a67cd87

Please sign in to comment.