mirror of
https://github.com/supabase/supabase.git
synced 2026-09-22 13:37:53 +08:00
c37e756983
## Context Currently in the SQL Editor, toggling "favourite" for a snippet doesn't persist unless you manually save the snippet (which expects a change in the snippet's content before allowing so) - which is a bit of an odd UX This used to work before we introduced manual saving which is currently the default behaviour for the SQL Editor - `addFavorite` and `removeFavorite` would add to the `needsSaving` queue which the editor's save scheduler will subscribe and trigger the save. However the save scheduler doesn't subscribe to the queue for manual saving mode ([ref](https://github.com/supabase/supabase/blob/master/apps/studio/state/sql-editor/sql-editor-save-scheduler.ts#L90)) - hence toggling favourite on a snippet never triggers a PATCH request. Am opting to immediately trigger a PATCH request when toggling favourites which is a bit more of an expected UX imo One thing to note is that favoriting a snippet essentially does a save on the snippet - which means the contents will be persisted as well, although i think this is alright ## To test - [ ] Verify that toggling favourite for a SQL snippet persists immediately - Can verify by checking the context menu CTA to see if it's changed from "Add to favourites" to "Remove from favourites" or vice versa <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Improvements** - Favoriting or unfavoriting SQL snippets now saves immediately. - Favorite changes are handled consistently across the SQL Editor, including the utility panel and snippet navigation. - Pending content saves are coordinated to prevent favorite changes from being overwritten. - If saving a favorite fails, the previous favorite state is restored and an error notification is shown. <!-- end of auto-generated comment: release notes by coderabbit.ai -->