Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions apps/mail/actions/mail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,28 @@ export const bulkArchive = async ({ ids }: { ids: string[] }) => {
}
};

export const bulkStar = async ({ ids }: { ids: string[] }) => {
try {
const driver = await getActiveDriver();
await driver.modifyLabels(ids, { addLabels: ['STARRED'], removeLabels: [] });
return { success: true };
} catch (error) {
console.error('Error marking message as starred:', error);
throw error;
}
};

export const bulkUnstar = async ({ ids }: { ids: string[] }) => {
try {
const driver = await getActiveDriver();
await driver.modifyLabels(ids, { addLabels: [], removeLabels: ['STARRED'] });
return { success: true };
} catch (error) {
console.error('Error marking message as unstarred:', error);
throw error;
}
};

export const muteThread = async ({ ids }: { ids: string[] }) => {
try {
const driver = await getActiveDriver();
Expand Down
27 changes: 19 additions & 8 deletions apps/mail/components/mail/mail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ import {
DialogTitle,
DialogTrigger,
} from '@/components/ui/dialog';
import {
bulkArchive,
bulkDeleteThread,
bulkStar,
getMail,
markAsImportant,
markAsRead,
} from '@/actions/mail';
import {
Archive2,
Bell,
Expand All @@ -21,13 +29,6 @@ import {
User,
X,
} from '../icons/icons';
import {
bulkArchive,
bulkDeleteThread,
getMail,
markAsImportant,
markAsRead,
} from '@/actions/mail';
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip';
import { Drawer, DrawerContent, DrawerHeader, DrawerTitle } from '@/components/ui/drawer';
import { ResizablePanel, ResizablePanelGroup } from '@/components/ui/resizable';
Expand Down Expand Up @@ -523,7 +524,17 @@ function BulkSelectActions() {

<Tooltip>
<TooltipTrigger asChild>
<button className="flex aspect-square h-8 items-center justify-center gap-1 overflow-hidden rounded-md border bg-white px-2 text-sm transition-all duration-300 ease-out hover:bg-gray-100 dark:border-none dark:bg-[#313131] dark:hover:bg-[#313131]/80">
<button
className="flex aspect-square h-8 items-center justify-center gap-1 overflow-hidden rounded-md border bg-white px-2 text-sm transition-all duration-300 ease-out hover:bg-gray-100 dark:border-none dark:bg-[#313131] dark:hover:bg-[#313131]/80"
onClick={() => {
if (mail.bulkSelected.length === 0) return;
toast.promise(bulkStar({ ids: mail.bulkSelected }).then(onMoveSuccess), {
loading: 'Marking as starred...',
success: 'All done! marked as starred',
error: 'Something went wrong!',
});
}}
>
<div className="relative overflow-visible">
<Star2 className="fill-[#9D9D9D] stroke-[#9D9D9D] dark:stroke-[#9D9D9D]" />
</div>
Expand Down