fix: preserve list scroll position when tagging an email
This commit is contained in:
@@ -139,6 +139,7 @@ export default function Home() {
|
||||
deleteEmail,
|
||||
markAsRead,
|
||||
toggleStar,
|
||||
setEmailKeywordsLocal,
|
||||
moveToMailbox,
|
||||
moveThreadToMailbox,
|
||||
searchEmails,
|
||||
@@ -1085,11 +1086,9 @@ export default function Home() {
|
||||
// Update email keywords via JMAP
|
||||
await client.updateEmailKeywords(emailId, keywords);
|
||||
|
||||
// Update local state
|
||||
selectEmail(email.id === selectedEmail?.id ? { ...email, keywords } : selectedEmail);
|
||||
|
||||
// Refresh emails list to show color in list
|
||||
await fetchEmails(client, selectedMailbox);
|
||||
// Patch the email in place so the list keeps its scroll/pagination state
|
||||
// instead of being reset to the first page by a full refetch.
|
||||
setEmailKeywordsLocal(emailId, keywords);
|
||||
|
||||
// Refresh tag counts
|
||||
fetchTagCounts(client);
|
||||
|
||||
@@ -85,6 +85,7 @@ interface EmailStore {
|
||||
clearSearchFilters: () => void;
|
||||
toggleAdvancedSearch: () => void;
|
||||
toggleStar: (client: IJMAPClient, emailId: string) => Promise<void>;
|
||||
setEmailKeywordsLocal: (emailId: string, keywords: Record<string, boolean>) => void;
|
||||
|
||||
// Batch operations
|
||||
batchMarkAsRead: (client: IJMAPClient, read: boolean) => Promise<void>;
|
||||
@@ -1057,6 +1058,17 @@ export const useEmailStore = create<EmailStore>((set, get) => ({
|
||||
}
|
||||
},
|
||||
|
||||
setEmailKeywordsLocal: (emailId, keywords) => {
|
||||
set((state) => ({
|
||||
emails: state.emails.map(e =>
|
||||
e.id === emailId ? { ...e, keywords: { ...keywords } } : e
|
||||
),
|
||||
selectedEmail: state.selectedEmail?.id === emailId
|
||||
? { ...state.selectedEmail, keywords: { ...keywords } }
|
||||
: state.selectedEmail,
|
||||
}));
|
||||
},
|
||||
|
||||
// Batch operations
|
||||
batchMarkAsRead: async (client, read) => {
|
||||
const { selectedEmailIds, emails, mailboxes } = get();
|
||||
|
||||
Reference in New Issue
Block a user