Skip to content

Commit

Permalink
Try wordpress-rs
Browse files Browse the repository at this point in the history
  • Loading branch information
oguzkocer committed Feb 13, 2024
1 parent 2271079 commit ed9358a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
3 changes: 3 additions & 0 deletions WordPress/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ repositories {
includeGroup "org.wordpress.fluxc"
includeGroup "org.wordpress.wellsql"
includeGroup "org.wordpress.gutenberg-mobile"
includeGroup "rs.wordpress"
includeGroupByRegex "org.wordpress.react-native-libraries.*"
includeGroup "com.automattic"
includeGroup "com.automattic.stories"
Expand Down Expand Up @@ -342,6 +343,8 @@ kapt {
}

dependencies {
implementation 'rs.wordpress:wp_api:trunk-e0af8e4b7ad36852136b097ab28e6c2061f9f61f'

implementation 'androidx.webkit:webkit:1.10.0'
implementation "androidx.navigation:navigation-compose:$androidxComposeNavigationVersion"
compileOnly project(path: ':libs:annotations')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import org.wordpress.android.ui.posts.PostListType.TRASHED
import org.wordpress.android.ui.prefs.AppPrefsWrapper
import org.wordpress.android.ui.uploads.UploadActionUseCase
import org.wordpress.android.ui.uploads.UploadStarter
import org.wordpress.android.ui.utils.UiString
import org.wordpress.android.ui.utils.UiString.UiStringRes
import org.wordpress.android.util.AppLog
import org.wordpress.android.util.NetworkUtilsWrapper
Expand All @@ -54,6 +55,8 @@ import org.wordpress.android.viewmodel.helpers.ToastMessageHolder
import org.wordpress.android.viewmodel.posts.PostFetcher
import org.wordpress.android.viewmodel.posts.PostListItemIdentifier.LocalPostId
import org.wordpress.android.viewmodel.posts.PostListViewModelConnector
import rs.wordpress.wp_api.Library
import uniffi.wp_api.WpAuthentication
import javax.inject.Inject
import javax.inject.Named
import kotlin.coroutines.CoroutineContext
Expand Down Expand Up @@ -290,6 +293,21 @@ class PostListMainViewModel @Inject constructor(
savePostToDbUseCase.savePostToDb(editPostRepository, site)
})
}

fetchPostListFromRust()
}

private fun fetchPostListFromRust() {
// This is an empty test site that'll be destroyed in a few days. This authentication
// token is only temporarily shared to collaborate and will be discarded within a day.
val rustLibrary = Library("https://stupendous-poetry-koala.jurassic.ninja", WpAuthentication("ZGVtbzo2cjFTIHhySlogN2k0RSBXM0J0IEs1dUMgUGN5Yg=="))
launch {
val firstPostTitle = rustLibrary.makePostListRequest().postList!!.first().title!!.raw
withContext(mainDispatcher) {
_snackBarMessage.value =
SnackbarMessageHolder(message = UiString.UiStringText("Fetched first post title from Rust: $firstPostTitle"))
}
}
}

override fun onCleared() {
Expand Down Expand Up @@ -382,6 +400,7 @@ class PostListMainViewModel @Inject constructor(
)
}


fun showTargetPost(targetPostId: Int) {
val postModel = postStore.getPostByLocalPostId(targetPostId)
if (postModel == null) {
Expand Down

0 comments on commit ed9358a

Please sign in to comment.