-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Issue/12039 reader table events #12502
Conversation
You can trigger optional UI/connected tests for these changes by visiting CircleCI here. |
@@ -526,10 +532,15 @@ public static int deletePostsWithTag(final ReaderTag tag) { | |||
} | |||
|
|||
String[] args = {tag.getTagSlug(), Integer.toString(tag.tagType.toInt())}; | |||
return ReaderDatabase.getWritableDb().delete( | |||
int rowsDeleted = ReaderDatabase.getWritableDb().delete( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method was directly returning the int value. I changed to keep the value local and will only post the new event if rows have actually been deleted.
@@ -538,20 +549,30 @@ public static int removeTagsFromPost(long blogId, long postId, final ReaderTagTy | |||
} | |||
|
|||
String[] args = {Integer.toString(tagType.toInt()), Long.toString(blogId), Long.toString(postId)}; | |||
return ReaderDatabase.getWritableDb().delete( | |||
int rowsDeleted = ReaderDatabase.getWritableDb().delete( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another instance of the method directly returning the int value. I changed to keep the value local and will only post the new event is rows have actually been deleted.
} | ||
|
||
public static int deletePostsInBlog(long blogId) { | ||
String[] args = {Long.toString(blogId)}; | ||
return ReaderDatabase.getWritableDb().delete("tbl_posts", "blog_id = ?", args); | ||
int rowsDeleted = ReaderDatabase.getWritableDb().delete("tbl_posts", "blog_id = ?", args); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another instance of the method directly returning the int value. I changed to keep the value local and will only post the new event is rows have actually been deleted.
) : CoroutineScope { | ||
override val coroutineContext: CoroutineContext | ||
get() = bgDispatcher | ||
|
||
private var isStarted = false | ||
private val isDirty = AtomicBoolean() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AtomicBoolean may be overkill, but considering there may be multiple event posts felt it was safer. Open to thoughts.
You can test the changes on this Pull Request by downloading the APK here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
Addresses part of #12039
This PR introduces EventBus events into
ReaderPostTable.java
andReaderDatabase.java
to notify the Reader repositories that the underlyingtbl_posts
has been modified (inserts, updates, deletes). If the posts stream has active observers, the repository will refresh itself, otherwise it sets a flag and will await active observers before refreshing.This should not affect any existing workflows.
This PR is branched off of and builds upon #12454. Once #12454 is merged, then I will update this PR with the latest.