-
-
Notifications
You must be signed in to change notification settings - Fork 829
feat(mobile): Add user setting for default bookmark view mode #1723
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
Conversation
@@ -2,7 +2,7 @@ | |||
|
|||
- The database schema lives in `packages/db/schema.ts`. | |||
- Changing the schema, requires a migration. | |||
- You can generate the migration by running `pnpm run db:generate` in the root dir. | |||
- You can generate the migration by running `pnpm run db:generate --name description_of_schema_change` in the root dir. |
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.
Give the LLMs everything they need to know to oneshot a solution ^^
packages/db/schema.ts
Outdated
@@ -561,6 +561,11 @@ export const userSettings = sqliteTable("userSettings", { | |||
}) | |||
.notNull() | |||
.default("open_original_link"), | |||
mobileBookmarkClickDefaultViewMode: text("mobileBookmarkClickDefaultViewMode", { |
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.
not sure if mobileBookmarkClickDefaultViewMode
is the best name ^^
anyone with a better idea please suggest
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.
Overall, looks good to me! I have one question about whether this needs to be stored in the db or not. If not, I think it might simplify things a bit (specially the backward compatibility checks, etc).
GEMINI.md
Outdated
## Development Notes | ||
|
||
- When making schema changes, refer to the instructions in docs/docs/07-Development/03-database.md |
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.
I think we can save it a couple of calls if we just quickly tell it how to do the db migration 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.
My tiny concern is that it will kinda duplicate the information, but otherwise I don't mind either.
@@ -0,0 +1 @@ | |||
ALTER TABLE `userSettings` ADD `mobileBookmarkClickDefaultViewMode` text DEFAULT 'reader' NOT NULL; |
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.
Instead of storing this in the database, have you considered storing it with the other mobile local settings in /apps/mobile/lib/settings.ts
, I feel like it's not one of the those settings that require synchronization as people don't really switch mobile apps that frequently, what do you think?
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.
We might not want it now, but I was thinking "might as well".
I'll change the implementation to use local settings to move the PR forward, but feel free to let me know if you change your mind lol.
const { mutate: updateUserSettings } = api.users.updateSettings.useMutation({ | ||
onSuccess: () => { | ||
// Invalidate and refetch user settings cache | ||
utils.users.settings.invalidate(); | ||
toast({ | ||
message: "Bookmark View Mode updated!", | ||
showProgress: false, | ||
}); | ||
router.back(); | ||
}, | ||
onError: () => { | ||
toast({ | ||
message: "Something went wrong", | ||
variant: "destructive", | ||
showProgress: false, | ||
}); | ||
}, | ||
}); |
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.
You can use useUpdateUserSettings
which takes care of invalidation for you.
/** | ||
* Don't retry if the endpoint doesn't exist | ||
* maybe we can remove this after x months after release lol | ||
*/ | ||
retry: false, |
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.
The settings endpoint was added in 0.25 and it's been more than a month, I think it's fair to assume that everyone should have it running by now.
> | ||
<Pressable className="flex flex-row justify-between"> | ||
<Text className="text-lg text-accent-foreground"> | ||
Bookmark View Mode |
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.
How about Default Bookmark View
?
@MohamedBassem change requests have been applied, please take a look again 🙇 |
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.
Looks great, thank you!
Summary
Changes Made
mobileBookmarkClickDefaultViewMode
setting to mobile app's local settingsUser Experience
Screenshots/Demo
Tested on ios simulator
I've also tested on the android app on device, connected to a karakeep server on v0.25.0 to make sure that the latest version of the app works even on older server instances.
Resolves #1603
🤖 Generated with Claude Code
Co-Authored-By: Claude noreply@anthropic.com