Apply dirty tracking to Drafts button prompt
Only show the save/discard prompt when pressing the Drafts button if the composer has unsaved changes (isDirty). If the content is unchanged from a loaded draft or was just saved, go directly to the drafts list. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -832,7 +832,8 @@ export const ComposePost = ({
|
||||
onSelectDraft={handleSelectDraft}
|
||||
onSaveDraft={saveCurrentDraft}
|
||||
onDiscard={handleClearComposer}
|
||||
isEmpty={isComposerEmpty}>
|
||||
isEmpty={isComposerEmpty}
|
||||
isDirty={composerState.isDirty}>
|
||||
{missingAltError && <AltTextReminder error={missingAltError} />}
|
||||
<ErrorBanner
|
||||
error={error}
|
||||
@@ -1124,6 +1125,7 @@ function ComposerTopBar({
|
||||
onSaveDraft,
|
||||
onDiscard,
|
||||
isEmpty,
|
||||
isDirty,
|
||||
topBarAnimatedStyle,
|
||||
children,
|
||||
}: {
|
||||
@@ -1139,6 +1141,7 @@ function ComposerTopBar({
|
||||
onSaveDraft: () => Promise<void>
|
||||
onDiscard: () => void
|
||||
isEmpty: boolean
|
||||
isDirty: boolean
|
||||
topBarAnimatedStyle: StyleProp<ViewStyle>
|
||||
children?: React.ReactNode
|
||||
}) {
|
||||
@@ -1170,6 +1173,7 @@ function ComposerTopBar({
|
||||
onSaveDraft={onSaveDraft}
|
||||
onDiscard={onDiscard}
|
||||
isEmpty={isEmpty}
|
||||
isDirty={isDirty}
|
||||
/>
|
||||
{isPublishing ? (
|
||||
<>
|
||||
|
||||
@@ -13,11 +13,13 @@ export function DraftsButton({
|
||||
onSaveDraft,
|
||||
onDiscard,
|
||||
isEmpty,
|
||||
isDirty,
|
||||
}: {
|
||||
onSelectDraft: (draft: StoredDraft) => void
|
||||
onSaveDraft: () => Promise<void>
|
||||
onDiscard: () => void
|
||||
isEmpty: boolean
|
||||
isDirty: boolean
|
||||
}) {
|
||||
const {_} = useLingui()
|
||||
const draftsDialogControl = Dialog.useDialogControl()
|
||||
@@ -25,11 +27,11 @@ export function DraftsButton({
|
||||
const {isPending: isSaving} = useSaveDraft()
|
||||
|
||||
const handlePress = () => {
|
||||
if (isEmpty) {
|
||||
// Composer is empty, go directly to drafts list
|
||||
if (isEmpty || !isDirty) {
|
||||
// Composer is empty or has no unsaved changes, go directly to drafts list
|
||||
draftsDialogControl.open()
|
||||
} else {
|
||||
// Composer has content, ask what to do
|
||||
// Composer has unsaved changes, ask what to do
|
||||
savePromptControl.open()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user