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
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useCallback, useEffect, useMemo } from "react";
import { Button } from "@hypr/ui/components/ui/button";
import { cn } from "@hypr/utils";

import { useSync } from "./context";
import { useSync } from "../context";
import { SyncIndicator } from "./status";

import {
Expand Down
2 changes: 1 addition & 1 deletion apps/desktop/src/calendar/components/apple/status.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
} from "@hypr/ui/components/ui/tooltip";
import { cn } from "@hypr/utils";

import { useSync } from "./context";
import { useSync } from "../context";

export function SyncIndicator() {
const { status } = useSync();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
useTaskRunRunning,
} from "tinytick/ui-react";

import { CALENDAR_SYNC_TASK_ID } from "~/services/apple-calendar";
import { CALENDAR_SYNC_TASK_ID } from "~/services/calendar";

export const TOGGLE_SYNC_DEBOUNCE_MS = 5000;

Expand Down
13 changes: 10 additions & 3 deletions apps/desktop/src/calendar/components/oauth/calendar-selection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { useCallback, useEffect, useMemo } from "react";
import { googleListCalendars } from "@hypr/api-client";
import { createClient } from "@hypr/api-client/client";

import { useSync } from "../context";

import { useAuth } from "~/auth";
import {
type CalendarGroup,
Expand Down Expand Up @@ -38,6 +40,8 @@ export function useOAuthCalendarSelection(config: CalendarProvider) {
const store = main.UI.useStore(main.STORE_ID);
const calendars = main.UI.useTable("calendars", main.STORE_ID);
const { user_id } = main.UI.useValues(main.STORE_ID);
const { status, scheduleSync, scheduleDebouncedSync, cancelDebouncedSync } =
useSync();

const {
data: incomingCalendars,
Expand Down Expand Up @@ -110,18 +114,21 @@ export function useOAuthCalendarSelection(config: CalendarProvider) {
const handleToggle = useCallback(
(calendar: CalendarItem, enabled: boolean) => {
store?.setPartialRow("calendars", calendar.id, { enabled });
scheduleDebouncedSync();
},
[store],
[store, scheduleDebouncedSync],
);

const handleRefresh = useCallback(async () => {
cancelDebouncedSync();
await refetch();
}, [refetch]);
scheduleSync();
}, [refetch, scheduleSync, cancelDebouncedSync]);

return {
groups,
handleToggle,
handleRefresh,
isLoading: isFetching,
isLoading: isFetching || status === "syncing",
};
}
118 changes: 60 additions & 58 deletions apps/desktop/src/calendar/components/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import {
} from "@hypr/ui/components/ui/accordion";

import { AppleCalendarSelection } from "./apple/calendar-selection";
import { SyncProvider } from "./apple/context";
import { AccessPermissionRow, TroubleShootingLink } from "./apple/permission";
import { SyncProvider } from "./context";
import { OAuthProviderContent } from "./oauth/provider-content";
import { PROVIDERS } from "./shared";

Expand All @@ -24,54 +24,56 @@ export function CalendarSidebarContent() {
);

return (
<Accordion type="single" collapsible defaultValue="apple">
{visibleProviders.map((provider) =>
provider.disabled ? (
<div
key={provider.id}
className="flex items-center gap-2 py-2 opacity-50"
>
{provider.icon}
<span className="text-sm font-medium">{provider.displayName}</span>
{provider.badge && (
<span className="rounded-full border border-neutral-300 px-2 text-xs font-light text-neutral-500">
{provider.badge}
<SyncProvider>
<Accordion type="single" collapsible defaultValue="apple">
{visibleProviders.map((provider) =>
provider.disabled ? (
<div
key={provider.id}
className="flex items-center gap-2 py-2 opacity-50"
>
{provider.icon}
<span className="text-sm font-medium">
{provider.displayName}
</span>
)}
</div>
) : (
<AccordionItem
key={provider.id}
value={provider.id}
className="border-none"
>
<AccordionTrigger className="py-2 hover:no-underline">
<div className="flex items-center gap-2">
{provider.icon}
<span className="text-sm font-medium">
{provider.displayName}
{provider.badge && (
<span className="rounded-full border border-neutral-300 px-2 text-xs font-light text-neutral-500">
{provider.badge}
</span>
{provider.badge && (
<span className="rounded-full border border-neutral-300 px-2 text-xs font-light text-neutral-500">
{provider.badge}
)}
</div>
) : (
<AccordionItem
key={provider.id}
value={provider.id}
className="border-none"
>
<AccordionTrigger className="py-2 hover:no-underline">
<div className="flex items-center gap-2">
{provider.icon}
<span className="text-sm font-medium">
{provider.displayName}
</span>
)}
</div>
</AccordionTrigger>
<AccordionContent className="pb-2">
{provider.id === "apple" && (
<div className="flex flex-col gap-3">
{calendar.status !== "authorized" ? (
<AccessPermissionRow
title="Calendar"
status={calendar.status}
isPending={calendar.isPending}
onOpen={calendar.open}
onRequest={calendar.request}
onReset={calendar.reset}
/>
) : (
<SyncProvider>
{provider.badge && (
<span className="rounded-full border border-neutral-300 px-2 text-xs font-light text-neutral-500">
{provider.badge}
</span>
)}
</div>
</AccordionTrigger>
<AccordionContent className="pb-2">
{provider.id === "apple" && (
<div className="flex flex-col gap-3">
{calendar.status !== "authorized" ? (
<AccessPermissionRow
title="Calendar"
status={calendar.status}
isPending={calendar.isPending}
onOpen={calendar.open}
onRequest={calendar.request}
onReset={calendar.reset}
/>
) : (
<AppleCalendarSelection
leftAction={
<TroubleShootingLink
Expand All @@ -82,17 +84,17 @@ export function CalendarSidebarContent() {
/>
}
/>
</SyncProvider>
)}
</div>
)}
{provider.nangoIntegrationId && (
<OAuthProviderContent config={provider} />
)}
</AccordionContent>
</AccordionItem>
),
)}
</Accordion>
)}
</div>
)}
{provider.nangoIntegrationId && (
<OAuthProviderContent config={provider} />
)}
</AccordionContent>
</AccordionItem>
),
)}
</Accordion>
</SyncProvider>
);
}
2 changes: 1 addition & 1 deletion apps/desktop/src/onboarding/calendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import { Button } from "@hypr/ui/components/ui/button";
import { OnboardingButton } from "./shared";

import { useAppleCalendarSelection } from "~/calendar/components/apple/calendar-selection";
import { SyncProvider } from "~/calendar/components/apple/context";
import { ApplePermissions } from "~/calendar/components/apple/permission";
import { CalendarSelection } from "~/calendar/components/calendar-selection";
import { SyncProvider } from "~/calendar/components/context";
import { usePermission } from "~/shared/hooks/usePermissions";

function AppleCalendarList() {
Expand Down
109 changes: 0 additions & 109 deletions apps/desktop/src/services/apple-calendar/ctx.ts

This file was deleted.

Loading
Loading