Fixes and remove logs

This commit is contained in:
Mo Tarbin
2026-07-07 00:23:36 -04:00
parent 57ac5cb9bf
commit 12d95dd4b1
9 changed files with 60 additions and 30 deletions

View File

@@ -85,9 +85,9 @@ const extractStorageKey = url => {
// replace them with backend proxy URLs (which generate fresh signed URLs on
// each request). Returns the patched HTML, or the original if nothing changed.
const refreshSignedUrlsInHtml = html => {
console.debug('1. refreshSignedUrlsInHtml', { html })
if (!html) return html
if (
!html.includes('dt-data-path') &&
!html.includes('X-Amz-') &&
!html.includes('X-Goog-') &&
!html.includes('sig') &&
@@ -95,22 +95,26 @@ const refreshSignedUrlsInHtml = html => {
) {
return html
}
console.debug('2. refreshSignedUrlsInHtml: found potential signed URLs, parsing HTML...')
const parser = new DOMParser()
const doc = parser.parseFromString(html, 'text/html')
const imgs = doc.querySelectorAll('img[src]')
let changed = false
imgs.forEach(async img => {
if (!img.getAttribute('dt-data-path')) {
// not custom tag, skipping:
return
}
imgs.forEach(img => {
const stablePath = img.getAttribute('dt-data-path')
const src = img.getAttribute('src')
let nextSrc = src
img.setAttribute('src', resolvePhotoURL(src))
changed = true
if (stablePath) {
nextSrc = resolvePhotoURL(stablePath)
} else if (isCloudSignedUrl(src)) {
nextSrc = resolvePhotoURL(extractStorageKey(src))
}
if (nextSrc && nextSrc !== src) {
img.setAttribute('src', nextSrc)
changed = true
}
})
return changed ? doc.body.innerHTML : html

View File

@@ -975,7 +975,10 @@ const ChoreEdit = () => {
key={att.file_path || idx}
onClick={() => {
const url = resolvePhotoURL(att.sign || att.file_path)
const ext = att.file_name?.split('.').pop().toLowerCase()
const ext = (att.file_name || '')
.split('.')
.pop()
.toLowerCase()
const isImage = [
'jpg',
'jpeg',
@@ -1031,7 +1034,8 @@ const ChoreEdit = () => {
size='sm'
variant='plain'
color='danger'
onClick={() => {
onClick={event => {
event.stopPropagation()
DeleteChoreAttachment(choreId, att.file_path)
.then(() => {
setAttachments(prev =>
@@ -1054,7 +1058,8 @@ const ChoreEdit = () => {
size='sm'
variant='plain'
color='danger'
onClick={() => {
onClick={event => {
event.stopPropagation()
setAttachments(prev =>
prev.filter((_, i) => i !== idx),
)

View File

@@ -631,7 +631,7 @@ const ChoreView = () => {
mb: 0.5,
}}
>
<Typography level='h3'>asde{chore.name}</Typography>
<Typography level='h3'>{chore.name}</Typography>
<PendingBadge commands={pendingCmds} />
</Box>
{chore.isActive === false && (

View File

@@ -34,8 +34,12 @@ function AttachmentBrowserModal({ choreId, isOpen, onClose }) {
if (!isOpen || !choreId) return
setIsLoading(true)
GetChoreAttachments(choreId)
.then(res => res.json())
.then(async res => {
if (!res.ok) throw new Error('Failed to fetch attachments')
return res.json()
})
.then(data => setAttachments(Array.isArray(data) ? data : []))
.catch(() => setAttachments([]))
.finally(() => setIsLoading(false))
}, [isOpen, choreId])
@@ -91,7 +95,16 @@ function AttachmentBrowserModal({ choreId, isOpen, onClose }) {
) : (
<List sx={{ '--ListItem-paddingX': '0px' }}>
{attachments.map((attachment, index) => (
<ListItem key={index} sx={{ p: 0 }}>
<ListItem
key={
attachment.id ||
attachment.file_path ||
attachment.sign ||
attachment.file_name ||
index
}
sx={{ p: 0 }}
>
<ListItemButton
onClick={() => handleAttachmentClick(attachment)}
sx={{ borderRadius: 'sm', gap: 1.5, py: 1 }}

View File

@@ -92,12 +92,14 @@ function AttachmentViewerModal({ config }) {
component='img'
src={url}
alt={fileName}
onClick={() => url && openUrl(url)}
onLoad={() => setImgLoaded(true)}
onError={() => {
setImgLoaded(true)
setImgError(true)
}}
sx={{
cursor: url ? 'zoom-in' : 'default',
maxWidth: '100%',
maxHeight: '65vh',
borderRadius: 'md',

View File

@@ -88,8 +88,7 @@ const ProfileSettings = () => {
formData.append('file', compressedFile, 'profile.jpg')
const response = await apiClient.upload('/users/profile_photo', formData)
if (!response.ok) throw new Error('Upload failed')
const data = await response.json()
// const url = resolvePhotoURL(data.url || data.sign)
await response.json()
refetchUserProfile() // Refresh user profile to get the new photoURL
showSuccess({

View File

@@ -21,7 +21,7 @@ import { useScanToTask } from './useScanToTask'
* Flow: capture → (auto) processing → done [calls onTaskExtracted + onClose]
* → error [retake or cancel]
*/
const ScanPanel = ({ open, onTaskExtracted, onClose }) => {
const ScanPanel = ({ open, onTaskExtracted, onClose, initialImageUrl }) => {
const {
isNativeScanner,
phase,
@@ -46,12 +46,12 @@ const ScanPanel = ({ open, onTaskExtracted, onClose }) => {
// Start/stop based on open state
useEffect(() => {
if (open) {
activate()
activate(initialImageUrl)
} else {
reset()
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [open])
}, [open, initialImageUrl])
// Start camera when entering capture phase on web
useEffect(() => {

View File

@@ -207,13 +207,22 @@ export function useScanToTask() {
setPhase('capture')
}, [])
const activate = useCallback(() => {
setCapturedImage(null)
setTaskResult(null)
setErrorMsg('')
setOcrProgress(0)
setPhase('capture')
}, [])
const activate = useCallback(
(initialImageUrl = null) => {
setCapturedImage(initialImageUrl)
setTaskResult(null)
setErrorMsg('')
setOcrProgress(0)
if (initialImageUrl) {
processImage(initialImageUrl, 'browser')
return
}
setPhase('capture')
},
[processImage],
)
const reset = useCallback(() => {
stopCamera()

View File

@@ -235,8 +235,6 @@ const SmartTaskTitleInput = ({
caretColor: mode === 'dark' ? '#fff' : '#000',
border: 'none',
outline: 'none',
border: 'none',
outline: 'none',
}}
/>
<div