mirror of
https://github.com/viq/NewsBlur.git
synced 2025-09-18 21:43:31 +00:00
better atomic flagging for story session resets by sync service
This commit is contained in:
parent
895e784dc2
commit
f370ac5cd8
2 changed files with 12 additions and 6 deletions
|
@ -69,6 +69,8 @@ public abstract class ItemListFragment extends NbFragment implements OnScrollLis
|
|||
super.onCreate(savedInstanceState);
|
||||
defaultFeedView = (DefaultFeedView)getArguments().getSerializable("defaultFeedView");
|
||||
activity = (ItemsList) getActivity();
|
||||
// tell the sync service to discard the reading session at the start of the next sync, just in case
|
||||
NBSyncService.resetReadingSession();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -633,17 +633,21 @@ public class NBSyncService extends Service {
|
|||
StoryOrder order = PrefsUtils.getStoryOrder(this, fs);
|
||||
ReadFilter filter = PrefsUtils.getReadFilter(this, fs);
|
||||
|
||||
boolean doReset = false;
|
||||
synchronized (PENDING_FEED_MUTEX) {
|
||||
if (ResetSession) {
|
||||
// the next fetch will be the start of a new reading session; clear it so it
|
||||
// will be re-primed
|
||||
dbHelper.clearStorySession();
|
||||
// don't just rely on the auto-prepare code when fetching stories, it might be called
|
||||
// after we insert our first page and not trigger
|
||||
dbHelper.prepareReadingSession(fs);
|
||||
doReset = true;
|
||||
ResetSession = false;
|
||||
}
|
||||
}
|
||||
if (doReset) {
|
||||
// the next fetch will be the start of a new reading session; clear it so it
|
||||
// will be re-primed
|
||||
dbHelper.clearStorySession();
|
||||
// don't just rely on the auto-prepare code when fetching stories, it might be called
|
||||
// after we insert our first page and not trigger
|
||||
dbHelper.prepareReadingSession(fs);
|
||||
}
|
||||
|
||||
while (totalStoriesSeen < PendingFeedTarget) {
|
||||
if (stopSync()) return;
|
||||
|
|
Loading…
Add table
Reference in a new issue