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

Try wordpress-rs #20799

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions WordPress/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ repositories {
includeGroup "org.wordpress.fluxc"
includeGroup "org.wordpress.wellsql"
includeGroup "org.wordpress.gutenberg-mobile"
includeGroup "rs.wordpress.api"
includeGroupByRegex "org.wordpress.react-native-libraries.*"
includeGroup "com.automattic"
includeGroup "com.automattic.tracks"
Expand Down Expand Up @@ -350,6 +351,10 @@ static def addBuildConfigFieldsFromPrefixedProperties(variant, properties, prefi
}

dependencies {
implementation('rs.wordpress.api:android:0.1-rc-9') {
exclude group: "net.java.dev.jna"
}
implementation 'net.java.dev.jna:jna:5.13.0@aar'
implementation 'androidx.webkit:webkit:1.11.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,9 @@ 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.api.kotlin.WpApiClient
import rs.wordpress.api.kotlin.WpRequestSuccess
import uniffi.wp_api.wpAuthenticationFromUsernameAndPassword
import javax.inject.Inject
import javax.inject.Named
import kotlin.coroutines.CoroutineContext
Expand Down Expand Up @@ -305,6 +309,33 @@ class PostListMainViewModel @Inject constructor(
}

isStarted = true

fetchDemoUserFromRust()
}

private fun fetchDemoUserFromRust() {
// This is an empty test site that'll be destroyed in a few days.
val siteUrl = "https://loudly-special.jurassic.ninja/"
val authentication = wpAuthenticationFromUsernameAndPassword(
username = "demo", password = "50uB 6ivM b7OC vc1K GXjh zZsI"
)
val client = WpApiClient(siteUrl, authentication)
launch {
val demoUser = client.request { requestBuilder ->
requestBuilder.users().retrieveMeWithEditContext()
}
when (demoUser) {
is WpRequestSuccess -> {
withContext(mainDispatcher) {
_snackBarMessage.value =
SnackbarMessageHolder(
message = UiString.UiStringText("Demo user's name: ${demoUser.data.name}")
)
}
}
else -> {}
}
}
}

override fun onCleared() {
Expand Down
Loading