Don't sort list of RSS feeds in UI.

This commit is contained in:
akwizgran
2022-12-12 17:31:45 +00:00
parent 33d01aac8c
commit e52250f1e4
3 changed files with 3 additions and 15 deletions

View File

@@ -22,7 +22,6 @@ import org.briarproject.nullsafety.NotNullByDefault;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.Executor;
import java.util.logging.Logger;
@@ -101,7 +100,6 @@ class RssFeedViewModel extends DbViewModel {
private List<Feed> loadFeeds(Transaction txn) throws DbException {
long start = now();
List<Feed> feeds = feedManager.getFeeds(txn);
Collections.sort(feeds);
logDuration(LOG, "Loading feeds", start);
return feeds;
}
@@ -145,7 +143,6 @@ class RssFeedViewModel extends DbViewModel {
Feed feed = feedManager.addFeed(url);
List<Feed> updated = addListItem(getList(feeds), feed);
if (updated != null) {
Collections.sort(updated);
feeds.postValue(new LiveResult<>(updated));
}
importResult.postEvent(IMPORTED);

View File

@@ -9,7 +9,7 @@ import javax.annotation.concurrent.Immutable;
@Immutable
@NotNullByDefault
public class Feed implements Comparable<Feed> {
public class Feed {
private final Blog blog;
private final LocalAuthor localAuthor;
@@ -68,16 +68,6 @@ public class Feed implements Comparable<Feed> {
return false;
}
// FIXME: compareTo() is inconsistent with equals()
@Override
public int compareTo(Feed o) {
if (this == o) return 0;
long aTime = getAdded(), bTime = o.getAdded();
if (aTime > bTime) return -1;
if (aTime < bTime) return 1;
return 0;
}
@Override
public int hashCode() {
return blog.hashCode();

View File

@@ -62,6 +62,7 @@ import okhttp3.ResponseBody;
import static java.util.Collections.sort;
import static java.util.logging.Level.WARNING;
import static java.util.logging.Logger.getLogger;
import static org.briarproject.bramble.util.LogUtils.logException;
import static org.briarproject.bramble.util.StringUtils.isNullOrEmpty;
import static org.briarproject.bramble.util.StringUtils.truncateUtf8;
@@ -79,7 +80,7 @@ class FeedManagerImpl implements FeedManager, EventListener, OpenDatabaseHook,
RemoveBlogHook {
private static final Logger LOG =
Logger.getLogger(FeedManagerImpl.class.getName());
getLogger(FeedManagerImpl.class.getName());
private final TaskScheduler scheduler;
private final Executor ioExecutor;