@novacraft-engineering/mailbox 0.4.22 → 0.4.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app/mail/page.tsx +39 -2
- package/package.json +1 -1
package/app/mail/page.tsx
CHANGED
|
@@ -3718,6 +3718,9 @@ export default function DevMailPage() {
|
|
|
3718
3718
|
.catch(() => {})
|
|
3719
3719
|
.finally(() => {
|
|
3720
3720
|
if (flags.read === true) ids.forEach(id => pendingRead.current.delete(id))
|
|
3721
|
+
// The starred tally counts conversations, not messages, so it cannot be derived
|
|
3722
|
+
// from the ids alone — the server says what it is now.
|
|
3723
|
+
if (flags.starred !== undefined) loadCounts(true)
|
|
3721
3724
|
})
|
|
3722
3725
|
},
|
|
3723
3726
|
[apiHeaders],
|
|
@@ -3754,6 +3757,40 @@ export default function DevMailPage() {
|
|
|
3754
3757
|
},
|
|
3755
3758
|
[apiHeaders, setInboundFlag, threadIds, threadKeys, loadCounts],
|
|
3756
3759
|
)
|
|
3760
|
+
/**
|
|
3761
|
+
* The row carries the newest message's id, but the star belongs to the conversation —
|
|
3762
|
+
* starring the newest message leaves an older starred one lit and the row never clears.
|
|
3763
|
+
*/
|
|
3764
|
+
const toggleRowStar = useCallback(
|
|
3765
|
+
(id: string, threadId: string | null, starred: boolean) => {
|
|
3766
|
+
if (!threadId) {
|
|
3767
|
+
setInboundFlag(threadIds(id), { starred })
|
|
3768
|
+
return
|
|
3769
|
+
}
|
|
3770
|
+
setInboxEmails(list =>
|
|
3771
|
+
list.map(entry => (threadKeys.get(entry.id) === threadKeys.get(id) ? { ...entry, starred } : entry)),
|
|
3772
|
+
)
|
|
3773
|
+
setThreads(list =>
|
|
3774
|
+
list.map(thread =>
|
|
3775
|
+
thread.threadId === threadId
|
|
3776
|
+
? { ...thread, starredCount: starred ? Math.max(1, thread.count) : 0 }
|
|
3777
|
+
: thread,
|
|
3778
|
+
),
|
|
3779
|
+
)
|
|
3780
|
+
setServerCounts(current =>
|
|
3781
|
+
current ? { ...current, starred: Math.max(0, current.starred + (starred ? 1 : -1)) } : current,
|
|
3782
|
+
)
|
|
3783
|
+
fetch('/api/mail/inbox', {
|
|
3784
|
+
method: 'PATCH',
|
|
3785
|
+
headers: apiHeaders(),
|
|
3786
|
+
body: JSON.stringify({ threadId, starred }),
|
|
3787
|
+
})
|
|
3788
|
+
.then(() => loadCounts(true))
|
|
3789
|
+
.catch(() => {})
|
|
3790
|
+
},
|
|
3791
|
+
[apiHeaders, setInboundFlag, threadIds, threadKeys, loadCounts],
|
|
3792
|
+
)
|
|
3793
|
+
|
|
3757
3794
|
useEffect(() => { swipeCommitRef.current = commitRowFlags }, [commitRowFlags])
|
|
3758
3795
|
useEffect(() => { setInboundFlagRef.current = setInboundFlag }, [setInboundFlag])
|
|
3759
3796
|
|
|
@@ -7899,12 +7936,12 @@ export default function DevMailPage() {
|
|
|
7899
7936
|
className={`${styles.itemStar} ${item.starred ? styles.itemStarOn : ''}`}
|
|
7900
7937
|
onClick={event => {
|
|
7901
7938
|
event.stopPropagation()
|
|
7902
|
-
|
|
7939
|
+
toggleRowStar(item.id, item.kind === 'inbound' ? item.threadId : null, !item.starred)
|
|
7903
7940
|
}}
|
|
7904
7941
|
onKeyDown={event => {
|
|
7905
7942
|
if (event.key === 'Enter') {
|
|
7906
7943
|
event.stopPropagation()
|
|
7907
|
-
|
|
7944
|
+
toggleRowStar(item.id, item.kind === 'inbound' ? item.threadId : null, !item.starred)
|
|
7908
7945
|
}
|
|
7909
7946
|
}}
|
|
7910
7947
|
>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@novacraft-engineering/mailbox",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.23",
|
|
4
4
|
"description": "A shared webmail app: one codebase, one deployment per mailbox. Threads, a rich composer with signatures, attachments on S3-compatible storage, sharing links, full-text search, web push and PWA install.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"webmail",
|