Skip to content
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

Merged
merged 4 commits into from
Jul 28, 2020
Merged

Conversation

zwarm
Copy link
Contributor

@zwarm zwarm commented Jul 22, 2020

Addresses part of #12039

This PR introduces EventBus events into ReaderPostTable.java and ReaderDatabase.java to notify the Reader repositories that the underlying tbl_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.

@zwarm zwarm added [Status] Not Ready for Merge Part of a WIP Feature This label is used to disable milestone checks for PRs that are not against `develop` or `release`. labels Jul 22, 2020
@zwarm zwarm requested review from ashiagr and malinajirka July 22, 2020 20:45
@peril-wordpress-mobile
Copy link

peril-wordpress-mobile bot commented Jul 22, 2020

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(
Copy link
Contributor Author

@zwarm zwarm Jul 22, 2020

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(
Copy link
Contributor Author

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);
Copy link
Contributor Author

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()
Copy link
Contributor Author

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.

@peril-wordpress-mobile
Copy link

peril-wordpress-mobile bot commented Jul 22, 2020

You can test the changes on this Pull Request by downloading the APK here.

@zwarm zwarm added New Reader Android Reader and removed Part of a WIP Feature This label is used to disable milestone checks for PRs that are not against `develop` or `release`. [Status] Not Ready for Merge labels Jul 24, 2020
@zwarm zwarm added this to the 15.4 milestone Jul 24, 2020
@zwarm zwarm marked this pull request as ready for review July 24, 2020 11:18
@zwarm zwarm modified the milestones: 15.4, 15.5 Jul 24, 2020
@malinajirka malinajirka self-assigned this Jul 28, 2020
Copy link
Contributor

@malinajirka malinajirka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@malinajirka malinajirka merged commit 6c410a2 into develop Jul 28, 2020
@malinajirka malinajirka deleted the issue/12039-reader-table-events branch July 28, 2020 06:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants