82a42011d8
CI / test (push) Has been cancelled
A dynamically-created <input type="file"> that's never attached to the DOM drops its first `change` event on a cold-launched iOS PWA — the native photo picker resolves out of the original user-gesture context and the closure that captured the input is gone. Symptom Matt hit 2026-05-14: first image-pick after hard-close + reopen of the PWA silently failed to advance to the crop tool; the second attempt worked. HomeView and LibraryView now keep a hidden <input ref="fileInputEl" type="file"> live in their templates. onAddPhoto clicks that input inside the user-gesture context; @change fires reliably even on cold launches. The picker resets input.value between selections so picking the same file twice still fires. Tests updated to query the template input via wrapper.find() instead of stubbing document.createElement; 347/347 frontend tests pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 line
7.0 KiB
JavaScript
1 line
7.0 KiB
JavaScript
import{C as e,F as t,J as n,K as r,N as i,U as a,V as o,Y as s,f as c,g as l,h as u,p as ee,q as d,t as f,u as p,v as m,x as h,y as g}from"./_plugin-vue_export-helper-BNDVmFr7.js";import{n as te,r as _,t as ne}from"./index-DHJU4XGZ.js";var v=a(null),y=a(!1);function b(){return typeof window>`u`?!1:window.matchMedia?.(`(display-mode: standalone)`).matches?!0:window.navigator.standalone===!0}function x(){if(typeof navigator>`u`)return!1;let e=navigator.userAgent,t=e.includes(`Mac`)&&navigator.maxTouchPoints>1;return/iPhone|iPod/.test(e)||t}var S=!1;function C(){S||typeof window>`u`||(S=!0,y.value=b(),window.addEventListener(`beforeinstallprompt`,e=>{e.preventDefault(),v.value=e}),window.addEventListener(`appinstalled`,()=>{v.value=null,y.value=!0}),window.matchMedia?.(`(display-mode: standalone)`).addEventListener(`change`,e=>{y.value=e.matches}))}C();function re(){let e=x(),t=u(()=>v.value!==null);async function n(){let e=v.value;if(!e)return!1;await e.prompt();let t=await e.userChoice;return v.value=null,t.outcome===`accepted`}return{isStandalone:y,isIOS:e,canPromptInstall:t,install:n}}var ie={class:`settings`},ae={key:0,class:`settings__section`},oe={class:`settings__section`},se={class:`theme-grid`,role:`radiogroup`,"aria-label":`Choose theme`},ce=[`aria-checked`,`aria-label`,`onClick`],w={class:`theme-swatch__label`},T={key:0,class:`theme-swatch__check`,"aria-hidden":`true`},E={class:`settings__section`},D={class:`settings__row`},O={class:`settings__row-value`},k={class:`install-modal__card`},A={class:`pw-form__field`},j={class:`pw-form__field`},M={class:`pw-form__field`},N=[`aria-invalid`],P={key:0,class:`pw-form__error`},F={key:0,class:`pw-form__error`,role:`alert`},I={key:1,class:`pw-form__success`,role:`status`},L=[`disabled`],R={class:`install-modal__card`},z={id:`install-modal-title`,class:`install-modal__title`},le={class:`install-modal__steps`},B={key:0},V={key:1},H={key:0},U=f(e({__name:`SettingsView`,setup(e){let f=_(),{saveTheme:v}=te(),{isStandalone:y,isIOS:b,canPromptInstall:x,install:S}=re(),C=u(()=>f.user?.theme??`warm-craft`),U=a(!1);function W(e){v(e)}async function ue(){!await S()&&!x.value&&(U.value=!0)}let G=a(!1),K=a(``),q=a(``),J=a(``),Y=a(!1),X=a(null),Z=a(!1),Q=u(()=>J.value.length>0&&J.value!==q.value);function de(){K.value=``,q.value=``,J.value=``,X.value=null,Z.value=!1,Y.value=!1}function $(){G.value=!1,de()}async function fe(){if(!Q.value){X.value=null,Z.value=!1,Y.value=!0;try{let e=await fetch(`/api/user/password`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({currentPassword:K.value,newPassword:q.value})});if(e.status===204){Z.value=!0,K.value=``,q.value=``,J.value=``,setTimeout($,1500);return}X.value=(await e.json().catch(()=>({})))?.error??`Could not update password.`}catch{X.value=`Network error. Try again.`}finally{Y.value=!1}}}return(e,a)=>(i(),g(`main`,ie,[a[27]||=l(`h1`,{class:`settings__title`},`Settings`,-1),r(y)?m(``,!0):(i(),g(`section`,ae,[a[7]||=l(`h2`,{class:`settings__section-title`},`Install app`,-1),a[8]||=l(`p`,{class:`settings__hint`},` Pin pictureFrame to your home screen so it opens like a native app. `,-1),r(x)?(i(),g(`button`,{key:0,type:`button`,class:`settings__install`,onClick:ue},` Install pictureFrame `)):(i(),g(`button`,{key:1,type:`button`,class:`settings__install`,onClick:a[0]||=e=>U.value=!0},` Add to Home Screen `))])),l(`section`,oe,[a[10]||=l(`h2`,{class:`settings__section-title`},`Theme`,-1),l(`div`,se,[(i(!0),g(ee,null,t(r(ne),e=>(i(),g(`button`,{key:e.id,type:`button`,role:`radio`,"aria-checked":C.value===e.id,"aria-label":e.label,class:d([`theme-swatch`,{"theme-swatch--active":C.value===e.id}]),style:n({"--swatch-bg":e.bg,"--swatch-primary":e.primary,"--swatch-text":e.text}),onClick:t=>W(e.id)},[a[9]||=l(`span`,{class:`theme-swatch__preview`,"aria-hidden":`true`},[l(`span`,{class:`theme-swatch__bar`}),l(`span`,{class:`theme-swatch__dot`})],-1),l(`span`,w,s(e.label),1),C.value===e.id?(i(),g(`span`,T,`✓`)):m(``,!0)],14,ce))),128))])]),l(`section`,E,[a[12]||=l(`h2`,{class:`settings__section-title`},`Account`,-1),l(`div`,D,[a[11]||=l(`span`,{class:`settings__row-label`},`Signed in as`,-1),l(`span`,O,s(r(f).user?.email),1)]),l(`button`,{type:`button`,class:`settings__action-link`,onClick:a[1]||=e=>G.value=!0},` Change password `),a[13]||=l(`a`,{href:`/logout`,class:`settings__logout`},`Sign out`,-1)]),G.value?(i(),g(`div`,{key:1,class:`install-modal`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`pw-modal-title`,onClick:c($,[`self`])},[l(`div`,k,[l(`button`,{type:`button`,class:`install-modal__close`,"aria-label":`Close`,onClick:$},`×`),a[18]||=l(`h2`,{id:`pw-modal-title`,class:`install-modal__title`},`Change password`,-1),l(`form`,{class:`pw-form`,onSubmit:c(fe,[`prevent`])},[l(`label`,A,[a[14]||=l(`span`,{class:`pw-form__label`},`Current password`,-1),o(l(`input`,{"onUpdate:modelValue":a[2]||=e=>K.value=e,type:`password`,autocomplete:`current-password`,required:``,class:`pw-form__input`},null,512),[[p,K.value]])]),l(`label`,j,[a[15]||=l(`span`,{class:`pw-form__label`},`New password`,-1),o(l(`input`,{"onUpdate:modelValue":a[3]||=e=>q.value=e,type:`password`,autocomplete:`new-password`,minlength:`8`,required:``,class:`pw-form__input`},null,512),[[p,q.value]]),a[16]||=l(`span`,{class:`pw-form__hint`},`At least 8 characters.`,-1)]),l(`label`,M,[a[17]||=l(`span`,{class:`pw-form__label`},`Confirm new password`,-1),o(l(`input`,{"onUpdate:modelValue":a[4]||=e=>J.value=e,type:`password`,autocomplete:`new-password`,required:``,class:`pw-form__input`,"aria-invalid":Q.value?`true`:`false`},null,8,N),[[p,J.value]]),Q.value?(i(),g(`span`,P,`Passwords don't match.`)):m(``,!0)]),X.value?(i(),g(`p`,F,s(X.value),1)):m(``,!0),Z.value?(i(),g(`p`,I,`Password updated.`)):m(``,!0),l(`button`,{type:`submit`,class:`settings__install`,disabled:Y.value||Q.value||!K.value||!q.value},s(Y.value?`Saving…`:`Update password`),9,L)],32)])])):m(``,!0),U.value?(i(),g(`div`,{key:2,class:`install-modal`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`install-modal-title`,onClick:a[6]||=c(e=>U.value=!1,[`self`])},[l(`div`,R,[l(`button`,{type:`button`,class:`install-modal__close`,"aria-label":`Close`,onClick:a[5]||=e=>U.value=!1},`×`),l(`h2`,z,s(r(b)?`Add to your iPhone home screen`:`Add to your home screen`),1),l(`ol`,le,[r(b)?(i(),g(`li`,B,[...a[19]||=[h(` Tap the `,-1),l(`strong`,null,`Share`,-1),h(` icon at the bottom of Safari (the square with an up-arrow). `,-1)]])):(i(),g(`li`,V,[...a[20]||=[h(` Open your browser's menu (usually the three dots `,-1),l(`strong`,null,`⋮`,-1),h(` in the top right). `,-1)]])),l(`li`,null,[a[22]||=h(` Scroll down and tap `,-1),a[23]||=l(`strong`,null,`Add to Home Screen`,-1),r(b)?m(``,!0):(i(),g(`span`,H,[...a[21]||=[h(`or `,-1),l(`strong`,null,`Install app`,-1)]])),a[24]||=h(`. `,-1)]),a[25]||=l(`li`,null,[h(` Tap `),l(`strong`,null,`Add`),h(` in the top right to confirm. `)],-1)]),a[26]||=l(`p`,{class:`install-modal__footer`},` The app will appear on your home screen. Open it from there and it runs like a regular app — no address bar, no tabs. `,-1)])])):m(``,!0)]))}}),[[`__scopeId`,`data-v-c012959a`]]);export{U as default}; |