mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-14 19:59:05 +01:00
Introduce RssFeedViewModel
Furnishing the RssFeed function as a single activity with fragments for Manage and Import.
This commit is contained in:
@@ -166,7 +166,7 @@ class FeedManagerImpl implements FeedManager, EventListener, OpenDatabaseHook,
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addFeed(String url) throws DbException, IOException {
|
||||
public Feed addFeed(String url) throws DbException, IOException {
|
||||
// fetch syndication feed to get its metadata
|
||||
SyndFeed f = fetchSyndFeed(url);
|
||||
|
||||
@@ -198,6 +198,8 @@ class FeedManagerImpl implements FeedManager, EventListener, OpenDatabaseHook,
|
||||
} finally {
|
||||
db.endTransaction(txn);
|
||||
}
|
||||
|
||||
return updatedFeed;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -232,18 +234,11 @@ class FeedManagerImpl implements FeedManager, EventListener, OpenDatabaseHook,
|
||||
|
||||
@Override
|
||||
public List<Feed> getFeeds() throws DbException {
|
||||
List<Feed> feeds;
|
||||
Transaction txn = db.startTransaction(true);
|
||||
try {
|
||||
feeds = getFeeds(txn);
|
||||
db.commitTransaction(txn);
|
||||
} finally {
|
||||
db.endTransaction(txn);
|
||||
}
|
||||
return feeds;
|
||||
return db.transactionWithResult(true, this::getFeeds);
|
||||
}
|
||||
|
||||
private List<Feed> getFeeds(Transaction txn) throws DbException {
|
||||
@Override
|
||||
public List<Feed> getFeeds(Transaction txn) throws DbException {
|
||||
List<Feed> feeds = new ArrayList<>();
|
||||
Group g = getLocalGroup();
|
||||
try {
|
||||
|
||||
@@ -17,6 +17,7 @@ import org.briarproject.bramble.api.sync.Message;
|
||||
import org.briarproject.bramble.api.system.Clock;
|
||||
import org.briarproject.bramble.api.system.TaskScheduler;
|
||||
import org.briarproject.bramble.test.BrambleMockTestCase;
|
||||
import org.briarproject.bramble.test.DbExpectations;
|
||||
import org.briarproject.bramble.test.ImmediateExecutor;
|
||||
import org.briarproject.briar.api.blog.Blog;
|
||||
import org.briarproject.briar.api.blog.BlogManager;
|
||||
@@ -145,17 +146,14 @@ public class FeedManagerImplTest extends BrambleMockTestCase {
|
||||
BdfDictionary feedsDict =
|
||||
BdfDictionary.of(new BdfEntry(KEY_FEEDS, feedList));
|
||||
expectGetLocalGroup();
|
||||
context.checking(new Expectations() {{
|
||||
oneOf(db).startTransaction(true);
|
||||
will(returnValue(txn));
|
||||
context.checking(new DbExpectations() {{
|
||||
oneOf(db).transactionWithResult(with(true), withDbCallable(txn));
|
||||
oneOf(clientHelper).getGroupMetadataAsDictionary(txn, localGroupId);
|
||||
will(returnValue(feedsDict));
|
||||
if (feedList.size() == 1) {
|
||||
oneOf(feedFactory).createFeed(feedDict);
|
||||
will(returnValue(feed));
|
||||
}
|
||||
oneOf(db).commitTransaction(txn);
|
||||
oneOf(db).endTransaction(txn);
|
||||
}});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user