Drafts toast
This commit is contained in:
committed by
Samuel Newman
parent
7da77a3107
commit
d1e62af654
@@ -479,6 +479,14 @@ export const ComposePost = ({
|
|||||||
setViewMode('drafts')
|
setViewMode('drafts')
|
||||||
}, [clearDraft])
|
}, [clearDraft])
|
||||||
|
|
||||||
|
// Handler for saving draft and closing with toast
|
||||||
|
const onSaveDraftAndClose = useCallback(() => {
|
||||||
|
saveImmediate(composerState)
|
||||||
|
closeComposer()
|
||||||
|
clearThumbnailCache(queryClient)
|
||||||
|
Toast.show(_(msg`Saved to drafts`))
|
||||||
|
}, [_, saveImmediate, composerState, closeComposer, queryClient])
|
||||||
|
|
||||||
// Handler for when a draft is deleted from the drafts list
|
// Handler for when a draft is deleted from the drafts list
|
||||||
const onDraftDeleted = useCallback(
|
const onDraftDeleted = useCallback(
|
||||||
(deletedDraftId: string) => {
|
(deletedDraftId: string) => {
|
||||||
@@ -1086,17 +1094,12 @@ export const ComposePost = ({
|
|||||||
<Trans>Update draft?</Trans>
|
<Trans>Update draft?</Trans>
|
||||||
</Prompt.TitleText>
|
</Prompt.TitleText>
|
||||||
<Prompt.DescriptionText>
|
<Prompt.DescriptionText>
|
||||||
<Trans>Update draft and save it to post at a later time.</Trans>
|
<Trans>Update draft and save it to post later.</Trans>
|
||||||
</Prompt.DescriptionText>
|
</Prompt.DescriptionText>
|
||||||
<Prompt.Actions>
|
<Prompt.Actions>
|
||||||
<Prompt.Action
|
<Prompt.Action
|
||||||
cta={_(msg`Update draft`)}
|
cta={_(msg`Update draft`)}
|
||||||
onPress={() => {
|
onPress={onSaveDraftAndClose}
|
||||||
// Explicitly save the changes before closing
|
|
||||||
saveImmediate(composerState)
|
|
||||||
closeComposer()
|
|
||||||
clearThumbnailCache(queryClient)
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
<Prompt.Action
|
<Prompt.Action
|
||||||
cta={_(msg`Don't update`)}
|
cta={_(msg`Don't update`)}
|
||||||
@@ -1116,10 +1119,13 @@ export const ComposePost = ({
|
|||||||
<Trans>Save to drafts?</Trans>
|
<Trans>Save to drafts?</Trans>
|
||||||
</Prompt.TitleText>
|
</Prompt.TitleText>
|
||||||
<Prompt.DescriptionText>
|
<Prompt.DescriptionText>
|
||||||
<Trans>Save to drafts to edit and post at a later time.</Trans>
|
<Trans>Save to drafts to edit and post later.</Trans>
|
||||||
</Prompt.DescriptionText>
|
</Prompt.DescriptionText>
|
||||||
<Prompt.Actions>
|
<Prompt.Actions>
|
||||||
<Prompt.Action cta={_(msg`Save draft`)} onPress={onClose} />
|
<Prompt.Action
|
||||||
|
cta={_(msg`Save draft`)}
|
||||||
|
onPress={onSaveDraftAndClose}
|
||||||
|
/>
|
||||||
<Prompt.Action
|
<Prompt.Action
|
||||||
cta={_(msg`Don't save`)}
|
cta={_(msg`Don't save`)}
|
||||||
color="negative_subtle"
|
color="negative_subtle"
|
||||||
@@ -1139,7 +1145,7 @@ export const ComposePost = ({
|
|||||||
<Trans>Save to drafts?</Trans>
|
<Trans>Save to drafts?</Trans>
|
||||||
</Prompt.TitleText>
|
</Prompt.TitleText>
|
||||||
<Prompt.DescriptionText>
|
<Prompt.DescriptionText>
|
||||||
<Trans>Save to drafts to edit and post at a later time.</Trans>
|
<Trans>Save to drafts to edit and post later.</Trans>
|
||||||
</Prompt.DescriptionText>
|
</Prompt.DescriptionText>
|
||||||
<Prompt.Actions>
|
<Prompt.Actions>
|
||||||
<Prompt.Action
|
<Prompt.Action
|
||||||
@@ -1160,7 +1166,7 @@ export const ComposePost = ({
|
|||||||
<Trans>Update draft?</Trans>
|
<Trans>Update draft?</Trans>
|
||||||
</Prompt.TitleText>
|
</Prompt.TitleText>
|
||||||
<Prompt.DescriptionText>
|
<Prompt.DescriptionText>
|
||||||
<Trans>Update draft and save it to post at a later time.</Trans>
|
<Trans>Update draft and save it to post later.</Trans>
|
||||||
</Prompt.DescriptionText>
|
</Prompt.DescriptionText>
|
||||||
<Prompt.Actions>
|
<Prompt.Actions>
|
||||||
<Prompt.Action
|
<Prompt.Action
|
||||||
|
|||||||
@@ -66,10 +66,20 @@ export function DraftsView({
|
|||||||
<View style={[a.flex_1]} />
|
<View style={[a.flex_1]} />
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
<ScrollView style={[a.flex_1]} contentContainerStyle={[a.gap_md]}>
|
<ScrollView
|
||||||
|
style={[a.flex_1]}
|
||||||
|
contentContainerStyle={[
|
||||||
|
a.gap_md,
|
||||||
|
drafts.length === 0 && {flexGrow: 1},
|
||||||
|
]}>
|
||||||
{drafts.length === 0 ? (
|
{drafts.length === 0 ? (
|
||||||
<View style={[a.py_xl, a.align_center, a.gap_md]}>
|
<View
|
||||||
<PencilLineIcon width={64} style={[t.atoms.text_contrast_low]} />
|
style={[
|
||||||
|
a.align_center,
|
||||||
|
a.gap_lg,
|
||||||
|
isNative ? [a.flex_1, a.justify_center] : [a.pt_xl, a.pb_4xl],
|
||||||
|
]}>
|
||||||
|
<PencilLineIcon width={48} style={[t.atoms.text_contrast_low]} />
|
||||||
<Text style={[t.atoms.text_contrast_medium]}>
|
<Text style={[t.atoms.text_contrast_medium]}>
|
||||||
<Trans>No drafts yet</Trans>
|
<Trans>No drafts yet</Trans>
|
||||||
</Text>
|
</Text>
|
||||||
|
|||||||
Reference in New Issue
Block a user