Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feeds iOS crash #136

Merged
merged 1 commit into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 15 additions & 16 deletions AresNews/AresNews/ViewModels/FeedsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ public bool IsRefreshing
OnPropertyChanged(nameof(IsRefreshing));
}
}
private ObservableCollection<Article> _articles;
private ObservableRangeCollection<Article> _articles;

public ObservableCollection<Article> Articles
public ObservableRangeCollection<Article> Articles
{
get { return _articles; }
set
Expand Down Expand Up @@ -233,9 +233,9 @@ public FeedsViewModel(FeedsPage page)
CurrentPage = page;

// Instantiate definitions
FeedTabs = new ObservableCollection<TabButton>();
FeedTabs = new ObservableRangeCollection<TabButton>();
Feeds = new ObservableCollection<Feed>(App.SqLiteConn.GetAllWithChildren<Feed>());
_articles = new ObservableCollection<Article>();
_articles = new ObservableRangeCollection<Article>();

// Organise feeds into tabs
CopyFeedsToTabs();
Expand Down Expand Up @@ -460,14 +460,16 @@ private async Task AggregateFeed(Feed feed, bool firstLoad = true)
{


articles = await App.WService.Get<List<Article>>(controller:"feeds", action: needUpdate ? "update" : null, parameters: needUpdate ? new string[] { timeUpdate } : null, jsonBody: $"{{\"search\": \"{feed.Keywords}\"}}", unSuccessCallback: async (err) =>
articles = await App.WService.Get<List<Article>>(controller:"feeds",
action: needUpdate ? "update" : null,
parameters: needUpdate ?
new string[] { timeUpdate } : null,
jsonBody: $"{{\"search\": \"{feed.Keywords}\"}}", unSuccessCallback: async (err) =>
{
#if DEBUG
throw new Exception(await err.Content.ReadAsStringAsync());
#endif
});
//if (!needUpdate)
// Articles?.Clear();

}
// Offline search
Expand All @@ -491,11 +493,8 @@ private async Task AggregateFeed(Feed feed, bool firstLoad = true)
UnnoticedArticles = new ObservableCollection<Article>( articles);
}
else
{
// Update list of articles
InsertArticles(articles);

}
SelectedFeed.IsLoaded = true;

IsRefreshing = false;
Expand All @@ -507,12 +506,12 @@ private async Task AggregateFeed(Feed feed, bool firstLoad = true)
/// <param name="articles">articles to add</param>
private void InsertArticles(IEnumerable<Article> articles)
{
Articles?.Clear();
for (int i = 0; i < articles.Count(); i++)
{
if (i != -1)
Articles.Add(articles.ElementAt(i));
}
ObservableRangeCollection<Article> articlesOld = new (_articles);
Articles = new ObservableRangeCollection<Article>();

Articles.AddRange(articles);
if (articlesOld.Any())
Articles.AddRange(articlesOld);
}

// See detail of the article
Expand Down
6 changes: 0 additions & 6 deletions AresNews/AresNews/Views/Portals/DiscordAuthPortal.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,7 @@
using AresNews.Models.Http.Responses;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

using Xamarin.Forms;
using Xamarin.Forms.Xaml;

Expand Down