mail UX: restore-to-folder, draft/attachment fixes, printing, sidebar collapse
Backend: - Restore returns each message to its original folder (e.g. Sent/Archive) instead of always the Inbox: new messages.restore_mailbox_id (migration 0010) + restore_thread_job. - Drafts: expunge reconciliation for the Drafts poll (provider.list_uids / _reconcile_drafts) clears phantom "remote" drafts; send + discard drop the mirrored DB row; adopting a remote draft carries its real attachments into the compose flow. - Thread detail/list are folder-aware: individually trashed/spam messages are hidden outside their folder, Trash/Spam show only their own messages, and the mail-list message count matches the view. Frontend: - Thread reading panel: fix newest-first card overlap/spacing (expand-all and single expand), hide Reply/Forward on trashed messages, close the Actions menu on message-body (iframe) clicks, scroll to the inline composer, and prompt Save draft / Discard on the X close. - Composer: remount when switching drafts, dirty-tracking to stop duplicate IMAP mirrors, and close the From/More dropdowns on outside click. - Sidebar: collapse/expand toggle (icons-only ~60px rail) and a log-out icon on Sign out. - Mail-standard printing in a new window with reliable page margins (lib/print.ts). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01U72FZiF1W1pb8XxyWBTREA
This commit is contained in:
@@ -15,7 +15,7 @@ from sqlalchemy.ext.asyncio import AsyncSession
|
||||
from app.config import get_settings
|
||||
from app.events import get_event_bus
|
||||
from app.indexer.indexer import PersistResult, persist_message
|
||||
from app.models import Account, Mailbox, Message
|
||||
from app.models import Account, Draft, Mailbox, Message
|
||||
from app.providers.base import MailboxDelta, ProviderNotSupported
|
||||
from app.providers.imap_smtp import ImapSmtpProvider
|
||||
from app.search.factory import get_search_backend
|
||||
@@ -248,6 +248,49 @@ async def apply_delta(
|
||||
},
|
||||
)
|
||||
|
||||
# Expunge reconciliation for Drafts. The mirror mechanism (and other clients)
|
||||
# expunge server copies, but a CONDSTORE poll doesn't report vanished UIDs, so
|
||||
# expunged drafts would linger in the DB and resurface as phantom "remote"
|
||||
# drafts. Drafts folders are small, so a full UID reconcile per poll is cheap.
|
||||
if mailbox.special_use == "drafts":
|
||||
await _reconcile_drafts(provider, account, mailbox)
|
||||
|
||||
|
||||
async def _reconcile_drafts(
|
||||
provider: ImapSmtpProvider, account: Account, mailbox: Mailbox
|
||||
) -> None:
|
||||
"""Drop DB rows for drafts that no longer exist on the server (were expunged)."""
|
||||
from app.db import session_scope
|
||||
|
||||
try:
|
||||
server_uids = await provider.list_uids(mailbox.path)
|
||||
except Exception:
|
||||
logger.exception("drafts reconcile: list_uids failed for %s", mailbox.path)
|
||||
return
|
||||
|
||||
async with session_scope() as session:
|
||||
db_uids = set(
|
||||
await session.scalars(select(Message.uid).where(Message.mailbox_id == mailbox.id))
|
||||
)
|
||||
gone = db_uids - server_uids
|
||||
if not gone:
|
||||
return
|
||||
await session.execute(
|
||||
delete(Message).where(Message.mailbox_id == mailbox.id, Message.uid.in_(gone))
|
||||
)
|
||||
# A local draft whose mirrored copy vanished becomes local-only again.
|
||||
await session.execute(
|
||||
update(Draft)
|
||||
.where(Draft.account_id == account.id, Draft.imap_uid.in_(gone))
|
||||
.values(imap_uid=None)
|
||||
)
|
||||
|
||||
logger.info("drafts reconcile: removed %d expunged row(s) in %s", len(gone), mailbox.path)
|
||||
await get_event_bus().publish(
|
||||
"message.deleted",
|
||||
{"user_id": str(account.user_id), "account_id": str(account.id), "mailbox": mailbox.path},
|
||||
)
|
||||
|
||||
|
||||
async def live_loop(
|
||||
account_id: uuid.UUID, mailbox_path: str = "INBOX", stop: asyncio.Event | None = None
|
||||
|
||||
Reference in New Issue
Block a user