mirror of
https://github.com/viq/NewsBlur.git
synced 2025-11-01 09:09:16 +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);
|
super.onCreate(savedInstanceState);
|
||||||
defaultFeedView = (DefaultFeedView)getArguments().getSerializable("defaultFeedView");
|
defaultFeedView = (DefaultFeedView)getArguments().getSerializable("defaultFeedView");
|
||||||
activity = (ItemsList) getActivity();
|
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
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -633,17 +633,21 @@ public class NBSyncService extends Service {
|
||||||
StoryOrder order = PrefsUtils.getStoryOrder(this, fs);
|
StoryOrder order = PrefsUtils.getStoryOrder(this, fs);
|
||||||
ReadFilter filter = PrefsUtils.getReadFilter(this, fs);
|
ReadFilter filter = PrefsUtils.getReadFilter(this, fs);
|
||||||
|
|
||||||
|
boolean doReset = false;
|
||||||
synchronized (PENDING_FEED_MUTEX) {
|
synchronized (PENDING_FEED_MUTEX) {
|
||||||
if (ResetSession) {
|
if (ResetSession) {
|
||||||
// the next fetch will be the start of a new reading session; clear it so it
|
doReset = true;
|
||||||
// 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);
|
|
||||||
ResetSession = false;
|
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) {
|
while (totalStoriesSeen < PendingFeedTarget) {
|
||||||
if (stopSync()) return;
|
if (stopSync()) return;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue