Files
pictureFrame-webApp/public/build/assets/BaseBottomSheet-vZ7hFF0Y.js
T
football2801 2cd558bac3
CI / test (push) Has been cancelled
fix(home): preview reflects what's on the frame, not what's queued
Both the backend preview endpoint and the frontend cache-buster were
preferring lockedImage over currentImage. Locking is a queued override
that doesn't take effect until the device's next poll, so showing it on
Home before the device has actually pulled it lied about the frame's
state. Always use currentImage now.

Also: add a primary "+ Add Photo" button at the top of the Library page
so users can upload without bouncing back to Home; updates the empty-
state copy to point at the new button.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-06 19:15:14 -04:00

1 line
4.9 KiB
JavaScript

import{C as e,L as t,N as n,O as r,R as i,S as a,V as o,_ as s,d as c,dt as l,f as u,g as d,j as f,p,r as m,s as h,t as g,u as _,ut as v}from"./_plugin-vue_export-helper-CeYnMxKK.js";import{c as y,d as b,f as x}from"./index-BGc6BnG_.js";var S=m(`devices`,()=>{let e=o([]),t=o(!1),n=o(null);async function r(){t.value=!0,n.value=null;try{let t=await fetch(`/api/devices`);if(!t.ok)throw Error(`Failed to load devices`);e.value=await t.json()}catch(e){n.value=e instanceof Error?e.message:`Unknown error`}finally{t.value=!1}}async function i(t,n){let r=await fetch(`/api/devices/${t}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)});if(!r.ok)throw Error(`Failed to update device`);let i=await r.json(),a=e.value.findIndex(e=>e.id===t);return a!==-1&&(e.value[a]=i),i}async function a(t,n){let r=await fetch(`/api/devices/${t}/lock`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({imageId:n})});if(!r.ok)throw Error(`Failed to lock image`);let i=await r.json(),a=e.value.findIndex(e=>e.id===t);return a!==-1&&(e.value[a]=i),i}async function s(t){let n=await fetch(`/api/devices/${t}/lock`,{method:`DELETE`});if(!n.ok)throw Error(`Failed to unlock`);let r=await n.json(),i=e.value.findIndex(e=>e.id===t);return i!==-1&&(e.value[i]=r),r}return{devices:e,loading:t,error:n,fetchDevices:r,updateDevice:i,lockImage:a,unlockImage:s}}),C=m(`upload`,()=>{let e=o(null),t=o(null),n=o(null),r=o(null),i=o(null),a=o(null),s=o([]),c=o(null),l=o([]),u=o(null);function d(n,r){_(),e.value=n,t.value=URL.createObjectURL(n),c.value=r??null,l.value=r?[r]:[]}async function f(n,r){_();let o=await(await fetch(n.originalUrl)).blob();e.value=new File([o],n.originalFilename,{type:o.type}),t.value=URL.createObjectURL(o),u.value=n.id,i.value=n.cropParams??null,a.value=n.cropOrientation??null,s.value=n.stickerState?[...n.stickerState]:[],l.value=n.approvedDeviceIds,c.value=r??null}function p(e,t,o){r.value&&URL.revokeObjectURL(r.value),n.value=e,r.value=URL.createObjectURL(e),i.value=t,a.value=o}function m(e){s.value=[...s.value,e]}function h(e,t){s.value=s.value.map(n=>n.id===e?{...n,...t}:n)}function g(e){s.value=s.value.filter(t=>t.id!==e)}function _(){t.value&&URL.revokeObjectURL(t.value),r.value&&URL.revokeObjectURL(r.value),e.value=null,t.value=null,n.value=null,r.value=null,i.value=null,a.value=null,s.value=[],c.value=null,l.value=[],u.value=null}return{originalFile:e,originalUrl:t,croppedBlob:n,croppedUrl:r,cropParams:i,cropOrientation:a,stickers:s,contextDeviceId:c,selectedDeviceIds:l,editingImageId:u,init:d,initEdit:f,setCrop:p,addSticker:m,updateSticker:h,removeSticker:g,cleanup:_}}),w={key:0,class:`btn__spinner`,"aria-hidden":`true`},T=g(s({__name:`BaseButton`,props:{variant:{default:`primary`},tag:{default:`button`},type:{default:`button`},disabled:{type:Boolean,default:!1},loading:{type:Boolean,default:!1}},setup(e){return(t,o)=>(r(),c(n(e.tag),a({type:e.tag===`button`?e.type:void 0,disabled:e.disabled||e.loading,class:[`btn`,`btn--${e.variant}`,{"btn--loading":e.loading}]},t.$attrs),{default:i(()=>[e.loading?(r(),p(`span`,w)):u(``,!0),f(t.$slots,`default`,{},void 0,!0)]),_:3},16,[`type`,`disabled`,`class`]))}}),[[`__scopeId`,`data-v-7d3f1e61`]]),E=[`aria-label`],D=80,O=g(s({__name:`BaseBottomSheet`,props:{modelValue:{type:Boolean},label:{}},emits:[`update:modelValue`],setup(n,{emit:a}){let s=n,m=a,g=o(null),S=o(0),C=o(!1),w=0,T=null,O=null;function k(){m(`update:modelValue`,!1)}function A(e){w=e.touches[0].clientY,C.value=!0,S.value=0}function j(e){if(!C.value)return;let t=e.touches[0].clientY-w;S.value=t>0?t:0}function M(){C.value&&(C.value=!1,S.value>D&&k(),S.value=0)}function N(e){e.pointerType!==`touch`&&(w=e.clientY,C.value=!0,S.value=0,T=e.pointerId,e.currentTarget.setPointerCapture(e.pointerId),window.addEventListener(`pointermove`,P),window.addEventListener(`pointerup`,F),window.addEventListener(`pointercancel`,F))}function P(e){if(!C.value||e.pointerId!==T)return;let t=e.clientY-w;S.value=t>0?t:0}function F(e){e.pointerId===T&&(T=null,window.removeEventListener(`pointermove`,P),window.removeEventListener(`pointerup`,F),window.removeEventListener(`pointercancel`,F),M())}return t(()=>s.modelValue,async t=>{t?(O=document.activeElement,await e(),g.value?.focus()):(O?.focus(),O=null,S.value=0,C.value=!1)}),(e,t)=>(r(),c(h,{to:`body`},[d(y,{name:`sheet`},{default:i(()=>[n.modelValue?(r(),p(`div`,{key:0,class:`sheet-overlay`,role:`dialog`,"aria-label":n.label,"aria-modal":`true`,onClick:x(k,[`self`]),onKeydown:b(k,[`esc`])},[_(`div`,{ref_key:`sheetRef`,ref:g,class:v([`sheet`,{"sheet--dragging":C.value}]),style:l(S.value>0?{transform:`translateY(${S.value}px)`}:void 0),tabindex:`-1`},[_(`div`,{class:`sheet__handle-target`,onTouchstartPassive:A,onTouchmovePassive:j,onTouchend:M,onTouchcancel:M,onPointerdown:N,"aria-hidden":`true`},[...t[0]||=[_(`div`,{class:`sheet__handle`},null,-1)]],32),f(e.$slots,`default`,{},void 0,!0)],6)],40,E)):u(``,!0)]),_:3})]))}}),[[`__scopeId`,`data-v-967683c3`]]);export{S as i,T as n,C as r,O as t};