about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lib/media/alt-text.ts6
-rw-r--r--src/state/models/media/image.ts4
-rw-r--r--src/state/models/ui/shell.ts1
-rw-r--r--src/view/com/modals/AltImage.tsx5
4 files changed, 11 insertions, 5 deletions
diff --git a/src/lib/media/alt-text.ts b/src/lib/media/alt-text.ts
index 9f9f907bf..77b0be446 100644
--- a/src/lib/media/alt-text.ts
+++ b/src/lib/media/alt-text.ts
@@ -1,9 +1,13 @@
 import {RootStoreModel} from 'state/index'
 
-export async function openAltTextModal(store: RootStoreModel): Promise<string> {
+export async function openAltTextModal(
+  store: RootStoreModel,
+  prevAltText: string,
+): Promise<string> {
   return new Promise((resolve, reject) => {
     store.shell.openModal({
       name: 'alt-text-image',
+      prevAltText,
       onAltTextSet: (altText?: string) => {
         if (altText) {
           resolve(altText)
diff --git a/src/state/models/media/image.ts b/src/state/models/media/image.ts
index 3585bb083..d989380d1 100644
--- a/src/state/models/media/image.ts
+++ b/src/state/models/media/image.ts
@@ -15,7 +15,7 @@ export class ImageModel implements RNImage {
   width: number
   height: number
   size: number
-  altText?: string = undefined
+  altText = ''
   cropped?: RNImage = undefined
   compressed?: RNImage = undefined
   scaledWidth: number = POST_IMG_MAX.width
@@ -45,7 +45,7 @@ export class ImageModel implements RNImage {
 
   async setAltText() {
     try {
-      const altText = await openAltTextModal(this.rootStore)
+      const altText = await openAltTextModal(this.rootStore, this.altText)
 
       runInAction(() => {
         this.altText = altText
diff --git a/src/state/models/ui/shell.ts b/src/state/models/ui/shell.ts
index a2891d9bb..797d53f81 100644
--- a/src/state/models/ui/shell.ts
+++ b/src/state/models/ui/shell.ts
@@ -43,6 +43,7 @@ export interface CropImageModal {
 
 export interface AltTextImageModal {
   name: 'alt-text-image'
+  prevAltText: string
   onAltTextSet: (altText?: string) => void
 }
 
diff --git a/src/view/com/modals/AltImage.tsx b/src/view/com/modals/AltImage.tsx
index e6e2ed831..639303c98 100644
--- a/src/view/com/modals/AltImage.tsx
+++ b/src/view/com/modals/AltImage.tsx
@@ -15,14 +15,15 @@ import {isDesktopWeb} from 'platform/detection'
 export const snapPoints = ['80%']
 
 interface Props {
+  prevAltText: string
   onAltTextSet: (altText?: string | undefined) => void
 }
 
-export function Component({onAltTextSet}: Props) {
+export function Component({prevAltText, onAltTextSet}: Props) {
   const pal = usePalette('default')
   const store = useStores()
   const theme = useTheme()
-  const [altText, setAltText] = useState('')
+  const [altText, setAltText] = useState(prevAltText)
 
   const onPressSave = useCallback(() => {
     onAltTextSet(altText)