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

Refs/heads/feat/profile/powersync #310

Draft
wants to merge 41 commits into
base: main
Choose a base branch
from
Draft

Conversation

francelu
Copy link
Contributor

@francelu francelu commented Dec 13, 2024

PowerSync for profiles (written by Alonso)

Description

This will be an unfinished PR. This PR solves #278 and would have integrated an offline mode in PowerSync to sync locally the profiles. Essentially the app would have a local database SQLite containing their profiles. Unfortunately their does not seem to be an official way to unit test PowerSync in kotlin, there are alternatives in typescript but I could not figure out how to make it work for kotlin. Currently this branch, can read correctly any profile remotely (from Supabase) but can not correctly upsert the data back to supabase.

Changes

Added a new model that would implement the UserRepository interface but with PowerSync so this limited the number of files that needed to be changed. Most of the modified files are mostly due to modifications to adjust to the generalization. The most important file here would be the Schema, that would describe the local database created for the users.

Files

Added

  • app/src/main/java/com/android/periodpals/model/user/UserModelPowerSync.kt
  • app/src/main/java/com/android/periodpals/resources/Schema.kt

Modified

  • app/build.gradle.kts
  • app/src/main/java/com/android/periodpals/MainActivity.kt
  • app/src/main/java/com/android/periodpals/model/user/User.kt
  • app/src/main/java/com/android/periodpals/model/user/UserDto.kt
  • app/src/main/java/com/android/periodpals/model/user/UserViewModel.kt

Dependencies Added

  • com.powersync:core:1.0.0-BETA9 for the core of the PowerSync functionality and the local-first database model it offered.
  • com.powersync:connector-supabase:1.0.0-BETA9 for the link with Supabase to connect with PowerSync services.
  • com.powersync:compose:1.0.0-BETA11 for applications of PowerSync's methods to be called within composables

Testing

Unable to find testing methods for the new model class, the view model is already tested. There was a lack of time and resources, had to resort to the emulator and other people's phones.

Comments

I (Alonso) spent 2-3 weeks working on this and hitting every conceivable wall I could. Unfortunatly it couldn't be merged in time. PowerSync has been the death of me but to be honest I learned about PostgreSQL and SQLite, what buckets and transactions are, so perhaps worth for me.

@francelu francelu linked an issue Dec 13, 2024 that may be closed by this pull request
3 tasks
@francelu francelu marked this pull request as draft December 13, 2024 12:25
@francelu francelu self-assigned this Dec 13, 2024
@coaguila coaguila assigned coaguila and unassigned francelu Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Integrate PowerSync to the project
2 participants