A one-of-a-kind resume builder that keeps your privacy in mind. Completely secure, customizable, portable, open-source and free forever. Try it out today!
TypeScript agent-skillsaidsh-pluginhacktoberfestjavascriptmcp-serverreactresume-builderself-hostedtypescript
fix: preserve newer native photo choices during uploads
Amruth Pillai61eb7d529518
diff --git a/apps/mobile/scripts/experience.test.mjs b/apps/mobile/scripts/experience.test.mjsindex 20614187c..f1826e138 100644--- a/apps/mobile/scripts/experience.test.mjs+++ b/apps/mobile/scripts/experience.test.mjs@@ -2275,6 +2275,7 @@ const photoHooks = load("features/write/hooks.ts", {"./model": {},});let pictureOptions;+let photoUploadRequest;const { PictureScreen } = load("features/write/picture-screen.tsx", {"@tanstack/react-query": {useMutation: (options) => {@@ -2282,17 +2283,35 @@ const { PictureScreen } = load("features/write/picture-screen.tsx", {return {};},},- "expo-file-system": {},+ "expo-file-system": {+ File: class extends Blob {+ constructor(uri) {+ super(["fictional image bytes"]);+ this.uri = uri;+ }+ },+ },"expo-image": { Image: "Image" },- "expo-image-picker": {},+ "expo-image-picker": {+ launchImageLibraryAsync: async () => ({ canceled: false, assets: [{ uri: "fixture://photo" }] }),+ },"./entry-screen": { EditorScreen: "EditorScreen" },"./hooks": { ...photoHooks, useWriteData: (select) => select(photoStore.getState().data) },"./pickers": {},- "./upload": {},- "@/api/client": { client: { storage: { deleteFile: async () => photoBytes.delete(photoUrl) } } },+ "./upload": load("features/write/upload.ts", {}),+ "@/api/client": {+ rest: async (path, init) => {+ assert.equal(path, "/files");+ assert.equal(init.method, "POST");+ assert.ok(init.body instanceof FormData);+ photoUploadRequest.started();+ return photoUploadRequest.response;+ },+ client: { storage: { deleteFile: async () => photoBytes.delete(photoUrl) } },+ },"@/auth/session": { useSession: () => ({ server: "https://resume.example.test" }) },"@/draft": { useResumeStore: photoStore, useIsResumeLocked: () => photoStore.getState().locked },- "@/draft/native": { nativeEnvironment: {} },+ "@/draft/native": { nativeEnvironment: { scope: async () => "photo-owner" } },});const photoView = () => render(PictureScreen);assert.equal(@@ -2306,6 +2325,46 @@ assert.equal("existing photo offers appearance controls",);+for (const action of ["unchanged", "edited", "removed"]) {+ let completeUpload;+ let enterUpload;+ const started = new Promise((resolve) => {+ enterUpload = resolve;+ });+ const response = new Promise((resolve) => {+ completeUpload = resolve;+ });+ photoUploadRequest = { started: enterUpload, response };+ photoStore.getState().update((draft) => {+ draft.picture.url = photoUrl;+ draft.picture.size = 80;+ });+ photoView();+ const pending = pictureOptions.mutationFn();+ await started;+ assert.equal(photoStore.getState().data.picture.url, photoUrl);+ const newerUrl = "https://photos.example.test/newer.jpeg";+ control(photoView(), "Size").onChange(99);+ if (action === "edited") control(photoView(), "URL").onChangeText(newerUrl);+ if (action === "removed") control(photoView(), "Remove photo").onPress();+ const expected =+ action === "unchanged" ? "https://photos.example.test/uploaded.jpeg" : action === "edited" ? newerUrl : "";+ completeUpload({ ok: true, json: async () => ({ url: "https://photos.example.test/uploaded.jpeg" }) });+ await pending;+ assert.equal(photoStore.getState().data.picture.url, expected, `late upload respects ${action} URL`);+ assert.equal(photoStore.getState().data.picture.size, 99, "upload preserves newer appearance edits");+ photoStore.getState().undo();+ assert.equal(photoStore.getState().data.picture.url, photoUrl, "upload or newer choice is one undo step");+ assert.equal(photoStore.getState().data.picture.size, 99, "photo Undo preserves newer appearance edits");+ photoStore.getState().redo();+ assert.equal(photoStore.getState().data.picture.url, expected, "ignored upload does not replace newer history");+}+photoStore.getState().update((draft) => {+ draft.picture.url = photoUrl;+ draft.picture.size = 80;+});+console.log("PASS native photo upload preserves newer URL or removal and unrelated appearance edits");+// Undo removal must retain the edit immediately before it.photoStore.getState().update((draft) => {draft.picture.size = 123;diff --git a/apps/mobile/src/features/write/picture-screen.tsx b/apps/mobile/src/features/write/picture-screen.tsxindex a9d828854..b99cf1cb3 100644--- a/apps/mobile/src/features/write/picture-screen.tsx+++ b/apps/mobile/src/features/write/picture-screen.tsx@@ -91,7 +91,15 @@ export function PictureScreen() {if (!resolvePictureUrl(uploaded.url, server)) throw new Error("Upload failed");// Leaving for another resume, or switching account, while it uploaded: the result is dropped.const url = uploaded.url;- await commitUpload(owner, uploadContext, () => set("url", url, true));+ await commitUpload(owner, uploadContext, () =>+ update(+ (draft) => {+ // A URL edited or removed during upload is newer than this result.+ if (draft.picture.url === picture.url) draft.picture.url = url;+ },+ { newStep: true },+ ),+ );},// The previous photo stays until an upload succeeds.onError: (error) =>diff --git a/docs/guides/filling-in-your-details.mdx b/docs/guides/filling-in-your-details.mdxindex dbeeac652..5f7977f67 100644--- a/docs/guides/filling-in-your-details.mdx+++ b/docs/guides/filling-in-your-details.mdx@@ -79,6 +79,8 @@ For social profiles you want listed in their own section, such as LinkedIn withUnreadable photo files are rejected before cropping. Photos larger than **10 MB** can still be cropped and re-encoded to shrink them; **Skip and upload** is unavailable above the limit. Upload failures give photo-specific guidance without changing the current photo. Native mobile uses its system image picker/crop editor and applies the same upload cap.+If you change the photo URL or remove the photo while an upload is running, your newer choice is kept when that upload finishes. Other photo settings you edit during the upload are kept too.+Whether to include a photo depends on where you're applying. Many applicant tracking systems ignore photos, while some countries expect one. The photo row at the top of the Basics card reminds you of this.<Steps>