@remit/web-client 0.0.329 → 0.0.330
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/dist/src/components/calendar/CalendarEventEditor.js +57 -7
- package/dist/src/components/calendar/CalendarEventPopup.js +74 -9
- package/dist/src/components/calendar/CalendarQuickCreate.js +78 -5
- package/dist/src/components/calendar/CalendarScreen.js +49 -10
- package/dist/src/components/calendar/CalendarSession.d.ts +3 -0
- package/dist/src/components/calendar/CalendarTaskPopup.d.ts +4 -0
- package/dist/src/components/calendar/CalendarTaskPopup.js +95 -0
- package/dist/src/components/calendar/CalendarWaiting.d.ts +3 -3
- package/dist/src/components/calendar/CalendarWaiting.js +5 -10
- package/dist/src/components/compose/ComposeForm.js +1 -1
- package/dist/src/components/mail/BulkRunProvider.js +1 -1
- package/dist/src/components/mail/MessageActionMenu.js +1 -1
- package/dist/src/components/mail/MessageList.js +1 -1
- package/dist/src/components/mail/OutboxPane.js +1 -1
- package/dist/src/components/mail/ThreadListInteraction.js +1 -1
- package/dist/src/components/settings/CalendarDefaultSenderCard.d.ts +2 -0
- package/dist/src/components/settings/CalendarDefaultSenderCard.js +16 -0
- package/dist/src/components/ui/ErrorBannerProvider.d.ts +0 -23
- package/dist/src/components/ui/ErrorBannerProvider.js +3 -39
- package/dist/src/components/ui/error-banner-context.d.ts +23 -0
- package/dist/src/components/ui/error-banner-context.js +38 -0
- package/dist/src/hooks/calendar/draft-session.d.ts +2 -1
- package/dist/src/hooks/calendar/draft-session.js +1 -0
- package/dist/src/hooks/calendar/draft.d.ts +8 -2
- package/dist/src/hooks/calendar/draft.js +17 -4
- package/dist/src/hooks/calendar/index.d.ts +4 -2
- package/dist/src/hooks/calendar/index.js +4 -2
- package/dist/src/hooks/calendar/instance.d.ts +2 -1
- package/dist/src/hooks/calendar/instance.js +14 -1
- package/dist/src/hooks/calendar/useCalendarScheduling.d.ts +33 -0
- package/dist/src/hooks/calendar/useCalendarScheduling.js +118 -0
- package/dist/src/hooks/calendar/useCalendarTasks.d.ts +53 -0
- package/dist/src/hooks/calendar/useCalendarTasks.js +105 -0
- package/dist/src/hooks/calendar/useCalendarWrites.d.ts +7 -1
- package/dist/src/hooks/calendar/useCalendarWrites.js +12 -4
- package/dist/src/hooks/calendar/useCalendars.d.ts +2 -0
- package/dist/src/hooks/calendar/useCalendars.js +8 -3
- package/dist/src/hooks/calendar/useDraftSession.js +1 -1
- package/dist/src/hooks/calendar/useMoveEvent.js +1 -0
- package/dist/src/hooks/useApplyLabel.js +1 -1
- package/dist/src/hooks/useCalendarData.d.ts +7 -2
- package/dist/src/hooks/useCalendarData.js +17 -5
- package/dist/src/hooks/useComposeLanguages.js +1 -1
- package/dist/src/hooks/useDeleteMessages.js +1 -1
- package/dist/src/hooks/useEmptyTrash.js +1 -1
- package/dist/src/hooks/useEscalatedActions.js +1 -1
- package/dist/src/hooks/useFilters.d.ts +1 -1
- package/dist/src/hooks/useLabels.d.ts +1 -1
- package/dist/src/hooks/useMarkAsRead.js +1 -1
- package/dist/src/hooks/useMoveMessages.js +1 -1
- package/dist/src/hooks/useReportSpam.js +1 -1
- package/dist/src/hooks/useSignature.js +1 -1
- package/dist/src/hooks/useStarredThreads.d.ts +1 -1
- package/dist/src/hooks/useToggleStar.js +1 -1
- package/dist/src/hooks/useToggleTrusted.js +1 -1
- package/dist/src/hooks/useTriggerSync.d.ts +1 -1
- package/dist/src/hooks/useUpdateAddressFlags.js +1 -1
- package/dist/src/routeTree.gen.d.ts +20 -3
- package/dist/src/routeTree.gen.js +7 -0
- package/dist/src/routes/calendar/$view.$date/task.$calendarTaskId.d.ts +5 -0
- package/dist/src/routes/calendar/$view.$date/task.$calendarTaskId.js +16 -0
- package/dist/src/routes/settings/calendars.js +2 -1
- package/dist/src/routing/calendar.d.ts +4 -0
- package/dist/src/routing/calendar.js +15 -1
- package/dist/src/routing/index.d.ts +1 -1
- package/dist/src/routing/index.js +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Who an event's invitations go out from, who can be invited, and whether the
|
|
3
|
+
* messages a save queued reached their guests.
|
|
4
|
+
*
|
|
5
|
+
* A save answers with the scheduling messages it put in the outbox. They are
|
|
6
|
+
* sent after the save returns, so whether each one went is followed here, by
|
|
7
|
+
* reading the outbox row until the send worker settles it.
|
|
8
|
+
*/
|
|
9
|
+
import { addressOperationsSearchAddressesOptions, configOperationsGetConfigOptions, outboxDetailOperationsGetOutboxMessageOptions, outboxDetailOperationsSendOutboxMessageMutation, userSettingsOperationsGetUserSettingsOptions, userSettingsOperationsUpdateUserSettingsMutation, } from "@remit/api-http-client/@tanstack/react-query.gen.ts";
|
|
10
|
+
import { useMutation, useQueries, useQuery, useQueryClient, } from "@tanstack/react-query";
|
|
11
|
+
import { useCallback, useMemo } from "react";
|
|
12
|
+
import { getErrorStatus } from "../../lib/error-classifier";
|
|
13
|
+
import { useDebouncedValue } from "../useDebouncedValue";
|
|
14
|
+
/** The reader's accounts that can send mail, and the default one. */
|
|
15
|
+
export function useCalendarSenders() {
|
|
16
|
+
const queryClient = useQueryClient();
|
|
17
|
+
const { data } = useQuery({
|
|
18
|
+
...configOperationsGetConfigOptions(),
|
|
19
|
+
staleTime: 60_000,
|
|
20
|
+
});
|
|
21
|
+
const { data: settings } = useQuery(userSettingsOperationsGetUserSettingsOptions());
|
|
22
|
+
const update = useMutation(userSettingsOperationsUpdateUserSettingsMutation());
|
|
23
|
+
const senders = useMemo(() => (data?.accounts ?? [])
|
|
24
|
+
.filter((account) => account.syncedServices.includes("Mail"))
|
|
25
|
+
.map((account) => ({
|
|
26
|
+
accountId: account.accountId,
|
|
27
|
+
email: account.email,
|
|
28
|
+
})), [data?.accounts]);
|
|
29
|
+
const defaultSenderId = settings?.defaultInvitationSenderAccountId;
|
|
30
|
+
const setDefaultSender = useCallback(async (accountId) => {
|
|
31
|
+
await update.mutateAsync({
|
|
32
|
+
body: { defaultInvitationSenderAccountId: accountId },
|
|
33
|
+
});
|
|
34
|
+
await queryClient.invalidateQueries({
|
|
35
|
+
queryKey: userSettingsOperationsGetUserSettingsOptions().queryKey,
|
|
36
|
+
});
|
|
37
|
+
}, [update, queryClient]);
|
|
38
|
+
return { senders, defaultSenderId, setDefaultSender };
|
|
39
|
+
}
|
|
40
|
+
const MIN_QUERY = 2;
|
|
41
|
+
/** Contacts matching what is typed in a Guests field, as the composer finds them. */
|
|
42
|
+
export function useGuestSuggestions(query) {
|
|
43
|
+
const debounced = useDebouncedValue(query.trim(), 200);
|
|
44
|
+
const { data } = useQuery({
|
|
45
|
+
...addressOperationsSearchAddressesOptions({
|
|
46
|
+
query: { q: debounced, limit: 8 },
|
|
47
|
+
}),
|
|
48
|
+
enabled: debounced.length >= MIN_QUERY,
|
|
49
|
+
});
|
|
50
|
+
return useMemo(() => (data?.items ?? []).map((address) => ({
|
|
51
|
+
email: address.normalizedEmail,
|
|
52
|
+
name: address.displayName ?? "",
|
|
53
|
+
})), [data?.items]);
|
|
54
|
+
}
|
|
55
|
+
const SETTLED = [
|
|
56
|
+
"sent",
|
|
57
|
+
"unfiled",
|
|
58
|
+
"failed",
|
|
59
|
+
"blocked",
|
|
60
|
+
];
|
|
61
|
+
const MISSED = ["failed", "blocked"];
|
|
62
|
+
/**
|
|
63
|
+
* Follows each queued scheduling message until it settles. A row that left the
|
|
64
|
+
* outbox was sent and filed, which reads as a 404 here and as reached; any
|
|
65
|
+
* other failed read is said, never taken as reached.
|
|
66
|
+
*/
|
|
67
|
+
export function useSendsFollowUp(sends) {
|
|
68
|
+
const queryClient = useQueryClient();
|
|
69
|
+
const resend = useMutation(outboxDetailOperationsSendOutboxMessageMutation());
|
|
70
|
+
const results = useQueries({
|
|
71
|
+
queries: sends.map((send) => ({
|
|
72
|
+
...outboxDetailOperationsGetOutboxMessageOptions({
|
|
73
|
+
path: { outboxMessageId: send.outboxMessageId },
|
|
74
|
+
}),
|
|
75
|
+
meta: { softErrorStatuses: [404] },
|
|
76
|
+
retry: false,
|
|
77
|
+
refetchInterval: (query) => {
|
|
78
|
+
if (query.state.error)
|
|
79
|
+
return false;
|
|
80
|
+
const status = query.state.data?.status;
|
|
81
|
+
return status && SETTLED.includes(status) ? false : 1500;
|
|
82
|
+
},
|
|
83
|
+
})),
|
|
84
|
+
});
|
|
85
|
+
const unreadable = sends.flatMap((send, index) => {
|
|
86
|
+
const result = results[index];
|
|
87
|
+
if (!result?.error || getErrorStatus(result.error) === 404)
|
|
88
|
+
return [];
|
|
89
|
+
return [{ send, error: result.error, refetch: result.refetch }];
|
|
90
|
+
});
|
|
91
|
+
const recheck = () => {
|
|
92
|
+
for (const entry of unreadable)
|
|
93
|
+
void entry.refetch();
|
|
94
|
+
};
|
|
95
|
+
const missed = sends.filter((_, index) => {
|
|
96
|
+
const status = results[index]?.data?.status;
|
|
97
|
+
return status !== undefined && MISSED.includes(status);
|
|
98
|
+
});
|
|
99
|
+
const retry = useCallback(async () => {
|
|
100
|
+
for (const send of missed) {
|
|
101
|
+
await resend.mutateAsync({
|
|
102
|
+
path: { outboxMessageId: send.outboxMessageId },
|
|
103
|
+
});
|
|
104
|
+
await queryClient.invalidateQueries({
|
|
105
|
+
queryKey: outboxDetailOperationsGetOutboxMessageOptions({
|
|
106
|
+
path: { outboxMessageId: send.outboxMessageId },
|
|
107
|
+
}).queryKey,
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
}, [missed, resend, queryClient]);
|
|
111
|
+
return {
|
|
112
|
+
missed: missed.map((send) => send.email),
|
|
113
|
+
retry,
|
|
114
|
+
checkError: unreadable[0]?.error ?? null,
|
|
115
|
+
unchecked: unreadable.map((entry) => entry.send.email),
|
|
116
|
+
recheck,
|
|
117
|
+
};
|
|
118
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { RemitImapCalendarTaskResponse, RemitImapCreateCalendarTaskInput, RemitImapUpdateCalendarTaskInput } from "@remit/api-http-client/types.gen.ts";
|
|
2
|
+
import type { CalendarTaskData } from "@remit/ui";
|
|
3
|
+
import type { CalendarWindow } from "./window";
|
|
4
|
+
/** A task as the grid draws it, on its due day. */
|
|
5
|
+
export declare const toTaskData: (task: RemitImapCalendarTaskResponse) => CalendarTaskData;
|
|
6
|
+
export declare function useCalendarTasks(window: CalendarWindow, enabled?: boolean): {
|
|
7
|
+
tasks: RemitImapCalendarTaskResponse[];
|
|
8
|
+
error: import("@remit/api-http-client").CalendarTaskOperationsListCalendarTasksError | null;
|
|
9
|
+
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<NoInfer<import("@remit/api-http-client").RemitImapCalendarTaskListResponse>, import("@remit/api-http-client").CalendarTaskOperationsListCalendarTasksError>>;
|
|
10
|
+
};
|
|
11
|
+
export type CalendarTaskRead = {
|
|
12
|
+
kind: "loading";
|
|
13
|
+
} | {
|
|
14
|
+
kind: "found";
|
|
15
|
+
task: RemitImapCalendarTaskResponse;
|
|
16
|
+
} | {
|
|
17
|
+
kind: "gone";
|
|
18
|
+
} | {
|
|
19
|
+
kind: "failed";
|
|
20
|
+
error: unknown;
|
|
21
|
+
retry: () => void;
|
|
22
|
+
};
|
|
23
|
+
/** One task by its id, the way the popup opens it from the address. */
|
|
24
|
+
export declare function useCalendarTask(calendarTaskId: string): CalendarTaskRead;
|
|
25
|
+
export type TaskWriteOutcome = {
|
|
26
|
+
kind: "written";
|
|
27
|
+
} | {
|
|
28
|
+
kind: "refused";
|
|
29
|
+
message: string;
|
|
30
|
+
};
|
|
31
|
+
type TaskRef = Pick<RemitImapCalendarTaskResponse, "calendarTaskId" | "calendarId" | "etag">;
|
|
32
|
+
export declare function useCalendarTaskWrites(): {
|
|
33
|
+
createTask: (input: RemitImapCreateCalendarTaskInput) => Promise<{
|
|
34
|
+
kind: "written";
|
|
35
|
+
} | {
|
|
36
|
+
kind: "refused";
|
|
37
|
+
message: string;
|
|
38
|
+
}>;
|
|
39
|
+
updateTask: (task: TaskRef, patch: RemitImapUpdateCalendarTaskInput) => Promise<{
|
|
40
|
+
kind: "written";
|
|
41
|
+
} | {
|
|
42
|
+
kind: "refused";
|
|
43
|
+
message: string;
|
|
44
|
+
}>;
|
|
45
|
+
deleteTask: (task: TaskRef) => Promise<{
|
|
46
|
+
kind: "written";
|
|
47
|
+
} | {
|
|
48
|
+
kind: "refused";
|
|
49
|
+
message: string;
|
|
50
|
+
}>;
|
|
51
|
+
isWriting: boolean;
|
|
52
|
+
};
|
|
53
|
+
export {};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tasks: read for the window on screen, drawn on their due day, and written
|
|
3
|
+
* one at a time. A task lives in a task list (a `VtodoOnly` collection), never
|
|
4
|
+
* in an event calendar, and is drawn on every view whatever calendars are ticked.
|
|
5
|
+
*/
|
|
6
|
+
import { calendarTaskDetailOperationsDeleteCalendarTaskMutation, calendarTaskDetailOperationsGetCalendarTaskOptions, calendarTaskDetailOperationsUpdateCalendarTaskMutation, calendarTaskOperationsCreateCalendarTaskMutation, calendarTaskOperationsListCalendarTasksOptions, } from "@remit/api-http-client/@tanstack/react-query.gen.ts";
|
|
7
|
+
import { formatErrorMessage } from "@remit/ui";
|
|
8
|
+
import { useMutation, useQuery } from "@tanstack/react-query";
|
|
9
|
+
import { useCallback, useMemo } from "react";
|
|
10
|
+
import { getErrorStatus, softErrorStatuses } from "../../lib/error-classifier";
|
|
11
|
+
import { CALENDAR_WRITE_META, useInvalidateCalendarReads, } from "./useCalendarWrites";
|
|
12
|
+
/** A task as the grid draws it, on its due day. */
|
|
13
|
+
export const toTaskData = (task) => ({
|
|
14
|
+
calendarTaskId: task.calendarTaskId,
|
|
15
|
+
calendarId: task.calendarId,
|
|
16
|
+
title: task.summary,
|
|
17
|
+
due: task.allDay ? task.due.slice(0, 10) : task.dueAt,
|
|
18
|
+
allDay: task.allDay,
|
|
19
|
+
completed: task.completed,
|
|
20
|
+
});
|
|
21
|
+
export function useCalendarTasks(window, enabled = true) {
|
|
22
|
+
const { data, error, refetch } = useQuery({
|
|
23
|
+
...calendarTaskOperationsListCalendarTasksOptions({
|
|
24
|
+
query: { from: window.from, to: window.to },
|
|
25
|
+
}),
|
|
26
|
+
meta: softErrorStatuses(400, 404),
|
|
27
|
+
enabled,
|
|
28
|
+
});
|
|
29
|
+
const tasks = useMemo(() => data?.items ?? [], [data?.items]);
|
|
30
|
+
return { tasks, error, refetch };
|
|
31
|
+
}
|
|
32
|
+
/** One task by its id, the way the popup opens it from the address. */
|
|
33
|
+
export function useCalendarTask(calendarTaskId) {
|
|
34
|
+
const { data, error, refetch } = useQuery({
|
|
35
|
+
...calendarTaskDetailOperationsGetCalendarTaskOptions({
|
|
36
|
+
path: { calendarTaskId },
|
|
37
|
+
}),
|
|
38
|
+
meta: softErrorStatuses(404),
|
|
39
|
+
retry: false,
|
|
40
|
+
});
|
|
41
|
+
if (data)
|
|
42
|
+
return { kind: "found", task: data };
|
|
43
|
+
if (error === null)
|
|
44
|
+
return { kind: "loading" };
|
|
45
|
+
if (getErrorStatus(error) === 404)
|
|
46
|
+
return { kind: "gone" };
|
|
47
|
+
return {
|
|
48
|
+
kind: "failed",
|
|
49
|
+
error,
|
|
50
|
+
retry: () => {
|
|
51
|
+
void refetch();
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
const refused = (error) => ({
|
|
56
|
+
kind: "refused",
|
|
57
|
+
message: getErrorStatus(error) === 412
|
|
58
|
+
? "This task changed while you were looking at it. Close it and open it again."
|
|
59
|
+
: formatErrorMessage(error),
|
|
60
|
+
});
|
|
61
|
+
export function useCalendarTaskWrites() {
|
|
62
|
+
const invalidate = useInvalidateCalendarReads();
|
|
63
|
+
const create = useMutation({
|
|
64
|
+
...calendarTaskOperationsCreateCalendarTaskMutation(),
|
|
65
|
+
meta: CALENDAR_WRITE_META,
|
|
66
|
+
onSuccess: invalidate,
|
|
67
|
+
});
|
|
68
|
+
const update = useMutation({
|
|
69
|
+
...calendarTaskDetailOperationsUpdateCalendarTaskMutation(),
|
|
70
|
+
meta: CALENDAR_WRITE_META,
|
|
71
|
+
onSuccess: invalidate,
|
|
72
|
+
});
|
|
73
|
+
const remove = useMutation({
|
|
74
|
+
...calendarTaskDetailOperationsDeleteCalendarTaskMutation(),
|
|
75
|
+
meta: CALENDAR_WRITE_META,
|
|
76
|
+
onSuccess: invalidate,
|
|
77
|
+
});
|
|
78
|
+
const createTask = useCallback((input) => create
|
|
79
|
+
.mutateAsync({ body: input })
|
|
80
|
+
.then(() => ({ kind: "written" }))
|
|
81
|
+
.catch(refused), [create]);
|
|
82
|
+
const updateTask = useCallback((task, patch) => update
|
|
83
|
+
.mutateAsync({
|
|
84
|
+
path: { calendarTaskId: task.calendarTaskId },
|
|
85
|
+
query: { calendarId: task.calendarId },
|
|
86
|
+
headers: { "If-Match": task.etag },
|
|
87
|
+
body: patch,
|
|
88
|
+
})
|
|
89
|
+
.then(() => ({ kind: "written" }))
|
|
90
|
+
.catch(refused), [update]);
|
|
91
|
+
const deleteTask = useCallback((task) => remove
|
|
92
|
+
.mutateAsync({
|
|
93
|
+
path: { calendarTaskId: task.calendarTaskId },
|
|
94
|
+
query: { calendarId: task.calendarId },
|
|
95
|
+
headers: { "If-Match": task.etag },
|
|
96
|
+
})
|
|
97
|
+
.then(() => ({ kind: "written" }))
|
|
98
|
+
.catch(refused), [remove]);
|
|
99
|
+
return {
|
|
100
|
+
createTask,
|
|
101
|
+
updateTask,
|
|
102
|
+
deleteTask,
|
|
103
|
+
isWriting: create.isPending || update.isPending || remove.isPending,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
@@ -13,10 +13,15 @@
|
|
|
13
13
|
* statuses this surface owns, so a lapsed session takes the screen the way it
|
|
14
14
|
* does everywhere else.
|
|
15
15
|
*/
|
|
16
|
-
import type { RemitImapCreateCalendarEventInput, RemitImapUpdateCalendarEventInput } from "@remit/api-http-client/types.gen.ts";
|
|
16
|
+
import type { RemitImapCalendarSchedulingSend, RemitImapCreateCalendarEventInput, RemitImapUpdateCalendarEventInput } from "@remit/api-http-client/types.gen.ts";
|
|
17
17
|
import type { RecurrenceScope } from "@remit/ui";
|
|
18
|
+
/** The refusals a calendar surface renders itself. A 401 is not among them. */
|
|
19
|
+
export declare const CALENDAR_WRITE_META: {
|
|
20
|
+
softErrorStatuses: number[];
|
|
21
|
+
};
|
|
18
22
|
export type CalendarWriteOutcome = {
|
|
19
23
|
kind: "written";
|
|
24
|
+
sends: RemitImapCalendarSchedulingSend[];
|
|
20
25
|
} | {
|
|
21
26
|
kind: "conflict";
|
|
22
27
|
} | {
|
|
@@ -27,6 +32,7 @@ export type CalendarWriteOutcome = {
|
|
|
27
32
|
export type CalendarCreateOutcome = {
|
|
28
33
|
kind: "created";
|
|
29
34
|
calendarObjectId: string;
|
|
35
|
+
sends: RemitImapCalendarSchedulingSend[];
|
|
30
36
|
} | {
|
|
31
37
|
kind: "conflict";
|
|
32
38
|
} | {
|
|
@@ -19,14 +19,15 @@ import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
|
19
19
|
import { useCallback, useMemo } from "react";
|
|
20
20
|
import { getErrorStatus, softErrorStatuses } from "../../lib/error-classifier";
|
|
21
21
|
/** The refusals a calendar surface renders itself. A 401 is not among them. */
|
|
22
|
-
const CALENDAR_WRITE_META = softErrorStatuses(400, 404, 412);
|
|
22
|
+
export const CALENDAR_WRITE_META = softErrorStatuses(400, 404, 412);
|
|
23
23
|
/** Every read whose answer a write can change. */
|
|
24
24
|
const CALENDAR_QUERY_IDS = new Set([
|
|
25
25
|
"calendarEventOperationsListCalendarEvents",
|
|
26
26
|
"calendarEventDetailOperationsGetCalendarEvent",
|
|
27
27
|
"calendarFreeBusyOperationsListCalendarFreeBusy",
|
|
28
|
+
"calendarTaskOperationsListCalendarTasks",
|
|
29
|
+
"calendarTaskDetailOperationsGetCalendarTask",
|
|
28
30
|
]);
|
|
29
|
-
const WRITTEN = { kind: "written" };
|
|
30
31
|
const outcomeFor = (error) => getErrorStatus(error) === 412
|
|
31
32
|
? { kind: "conflict" }
|
|
32
33
|
: { kind: "refused", message: formatErrorMessage(error) };
|
|
@@ -77,6 +78,7 @@ export function useCalendarWrites() {
|
|
|
77
78
|
.then((created) => ({
|
|
78
79
|
kind: "created",
|
|
79
80
|
calendarObjectId: created.calendarObjectId,
|
|
81
|
+
sends: created.sends,
|
|
80
82
|
}))
|
|
81
83
|
.catch((error) => getErrorStatus(error) === 412
|
|
82
84
|
? { kind: "conflict" }
|
|
@@ -88,7 +90,10 @@ export function useCalendarWrites() {
|
|
|
88
90
|
headers: { "If-Match": write.etag },
|
|
89
91
|
body: patch,
|
|
90
92
|
})
|
|
91
|
-
.then(() =>
|
|
93
|
+
.then((updated) => ({
|
|
94
|
+
kind: "written",
|
|
95
|
+
sends: updated.sends,
|
|
96
|
+
}))
|
|
92
97
|
.catch(outcomeFor), [update]);
|
|
93
98
|
const deleteEvent = useCallback((write) => remove
|
|
94
99
|
.mutateAsync({
|
|
@@ -96,7 +101,10 @@ export function useCalendarWrites() {
|
|
|
96
101
|
query: { calendarId: write.calendarId, ...scopeQuery(write) },
|
|
97
102
|
headers: { "If-Match": write.etag },
|
|
98
103
|
})
|
|
99
|
-
.then(() =>
|
|
104
|
+
.then((removed) => ({
|
|
105
|
+
kind: "written",
|
|
106
|
+
sends: removed.sends,
|
|
107
|
+
}))
|
|
100
108
|
.catch(outcomeFor), [remove]);
|
|
101
109
|
return useMemo(() => ({
|
|
102
110
|
createEvent,
|
|
@@ -2,6 +2,8 @@ import type { RemitImapCalendarResponse } from "@remit/api-http-client/types.gen
|
|
|
2
2
|
import type { CalendarColorId, CalendarDescriptor } from "@remit/ui";
|
|
3
3
|
export interface CalendarsResult {
|
|
4
4
|
calendars: CalendarDescriptor[];
|
|
5
|
+
/** The task lists: collections that hold tasks and no events, left out of `calendars`. */
|
|
6
|
+
taskLists: CalendarDescriptor[];
|
|
5
7
|
/** The collections as the API returned them, for a surface that manages them. */
|
|
6
8
|
collections: RemitImapCalendarResponse[];
|
|
7
9
|
colorByCalendarId: Record<string, CalendarColorId>;
|
|
@@ -14,13 +14,18 @@ import { toCalendarDescriptor } from "./instance";
|
|
|
14
14
|
export function useCalendars() {
|
|
15
15
|
const { data, isLoading, error, refetch } = useQuery(calendarOperationsListCalendarsOptions());
|
|
16
16
|
return useMemo(() => {
|
|
17
|
-
const
|
|
17
|
+
const all = data?.items ?? [];
|
|
18
|
+
const items = all.filter((item) => item.componentSet !== "VtodoOnly");
|
|
18
19
|
const calendars = items.map(toCalendarDescriptor);
|
|
20
|
+
const taskLists = all
|
|
21
|
+
.filter((item) => item.componentSet === "VtodoOnly")
|
|
22
|
+
.map(toCalendarDescriptor);
|
|
19
23
|
return {
|
|
20
24
|
calendars,
|
|
21
|
-
|
|
25
|
+
taskLists,
|
|
26
|
+
collections: all,
|
|
22
27
|
colorByCalendarId: Object.fromEntries(calendars.map((calendar) => [calendar.id, calendar.color])),
|
|
23
|
-
timeZoneByCalendarId: Object.fromEntries(
|
|
28
|
+
timeZoneByCalendarId: Object.fromEntries(all.map((item) => [item.calendarId, item.timezone])),
|
|
24
29
|
defaultCalendarId: (items.find((item) => item.source === "Default") ?? items[0])
|
|
25
30
|
?.calendarId ?? "",
|
|
26
31
|
isLoading,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useCallback, useEffect, useReducer, useRef, useState, } from "react";
|
|
2
2
|
import { draftSessionReducer, escapeTarget, IDLE, } from "./draft-session";
|
|
3
3
|
/** Presses the grid answers itself, and the popups they open. */
|
|
4
|
-
const GRID_OWNED = "[data-calendar-popover], [data-event-id], [data-time-columns], [data-all-day-row], [role='dialog']";
|
|
4
|
+
const GRID_OWNED = "[data-calendar-popover], [data-event-id], [data-task-id], [data-time-columns], [data-all-day-row], [role='dialog']";
|
|
5
5
|
export function useDraftSession({ layers, isPhone, closeToView, closeNav, drawnEvents, }) {
|
|
6
6
|
const [session, dispatch] = useReducer(draftSessionReducer, IDLE);
|
|
7
7
|
const bound = useRef({ session, layers, isPhone, closeToView, closeNav });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { messageBulkOperationsUpdateMessageLabelsMutation } from "@remit/api-http-client/@tanstack/react-query.gen.ts";
|
|
2
2
|
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
3
3
|
import { useCallback } from "react";
|
|
4
|
-
import { useErrorBanners } from "../components/ui/
|
|
4
|
+
import { useErrorBanners } from "../components/ui/error-banner-context";
|
|
5
5
|
import { formatErrorDetail } from "../components/ui/error-banners";
|
|
6
6
|
import { runChunkedMutation } from "../lib/bulk-actions";
|
|
7
7
|
import { invalidateThreadListQueries, threadListCacheKeys, } from "../lib/thread-list-cache";
|
|
@@ -5,8 +5,9 @@
|
|
|
5
5
|
* and expands no recurrence of its own — the server returns instances and this
|
|
6
6
|
* turns them into what the kit draws. Every caller keeps the call it makes.
|
|
7
7
|
*/
|
|
8
|
-
import type { CalendarColorId, CalendarDescriptor, CalendarEventData, CalendarViewId } from "@remit/ui";
|
|
8
|
+
import type { CalendarColorId, CalendarDescriptor, CalendarEventData, CalendarTaskData, CalendarViewId } from "@remit/ui";
|
|
9
9
|
import { type CalendarInstanceRef } from "./calendar";
|
|
10
|
+
import { useCalendarTasks } from "./calendar/useCalendarTasks";
|
|
10
11
|
export interface CalendarDataRequest {
|
|
11
12
|
view: CalendarViewId;
|
|
12
13
|
/** The day the view is centred on, `YYYY-MM-DD`. */
|
|
@@ -28,9 +29,13 @@ export interface CalendarData {
|
|
|
28
29
|
/** The zone each collection's times are read on — never the device's. */
|
|
29
30
|
timeZoneByCalendarId: Record<string, string>;
|
|
30
31
|
isLoading: boolean;
|
|
31
|
-
/** A refusal the calendar renders itself. Null when
|
|
32
|
+
/** A refusal the calendar renders itself. Null when every read succeeded. */
|
|
32
33
|
error: unknown;
|
|
33
34
|
retry: () => void;
|
|
35
|
+
/** The tasks due in the window, as the API returned them. */
|
|
36
|
+
storedTasks: ReturnType<typeof useCalendarTasks>["tasks"];
|
|
37
|
+
/** The same tasks, as the grid draws them. */
|
|
38
|
+
tasks: CalendarTaskData[];
|
|
34
39
|
/** The resource and occurrence behind an event the grid selected. */
|
|
35
40
|
instanceOf: (eventId: string) => CalendarInstanceRef;
|
|
36
41
|
/** The events that leave their time free rather than busy. */
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { useMemo } from "react";
|
|
1
|
+
import { useCallback, useMemo } from "react";
|
|
2
2
|
import { calendarInstanceId, calendarWindow, readCalendarInstanceId, useCalendarEventWindow, useCalendarSelection, useDrawnEvents, usePrefetchAdjacentWindows, } from "./calendar";
|
|
3
|
+
import { toTaskData, useCalendarTasks } from "./calendar/useCalendarTasks";
|
|
3
4
|
export function useCalendarData({ view, date, calendarIds, enabled = true, }) {
|
|
4
5
|
const { calendars, colorByCalendarId, timeZoneByCalendarId, shown, narrowed, resolved, isLoading, } = useCalendarSelection(calendarIds);
|
|
5
6
|
const window = calendarWindow(view, date);
|
|
@@ -10,18 +11,29 @@ export function useCalendarData({ view, date, calendarIds, enabled = true, }) {
|
|
|
10
11
|
enabled: active,
|
|
11
12
|
});
|
|
12
13
|
usePrefetchAdjacentWindows(view, date, narrowed, active);
|
|
13
|
-
const
|
|
14
|
+
const drawnEvents = useDrawnEvents(events.instances, timeZoneByCalendarId, shown);
|
|
15
|
+
const taskRead = useCalendarTasks(window, active);
|
|
16
|
+
const storedTasks = taskRead.tasks;
|
|
17
|
+
const tasks = useMemo(() => storedTasks.map(toTaskData), [storedTasks]);
|
|
18
|
+
const refetchEvents = events.refetch;
|
|
19
|
+
const refetchTasks = taskRead.refetch;
|
|
20
|
+
const retry = useCallback(() => {
|
|
21
|
+
refetchEvents();
|
|
22
|
+
void refetchTasks();
|
|
23
|
+
}, [refetchEvents, refetchTasks]);
|
|
14
24
|
const freeIds = useMemo(() => new Set(events.instances
|
|
15
25
|
.filter((instance) => instance.transparency === "Transparent")
|
|
16
26
|
.map((instance) => calendarInstanceId(instance.calendarObjectId, instance.recurrenceId))), [events.instances]);
|
|
17
27
|
return {
|
|
18
28
|
calendars,
|
|
19
|
-
events:
|
|
29
|
+
events: drawnEvents,
|
|
20
30
|
colorByCalendarId,
|
|
21
31
|
timeZoneByCalendarId,
|
|
22
32
|
isLoading: isLoading || events.isLoading,
|
|
23
|
-
error: events.error,
|
|
24
|
-
retry
|
|
33
|
+
error: events.error ?? taskRead.error,
|
|
34
|
+
retry,
|
|
35
|
+
storedTasks,
|
|
36
|
+
tasks,
|
|
25
37
|
instanceOf: readCalendarInstanceId,
|
|
26
38
|
freeIds,
|
|
27
39
|
};
|
|
@@ -2,7 +2,7 @@ import { accountDetailOperationsUpdateAccountMutation, configOperationsGetConfig
|
|
|
2
2
|
import { defaultComposeLanguages } from "@remit/ui";
|
|
3
3
|
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
4
4
|
import { useCallback, useMemo } from "react";
|
|
5
|
-
import { useErrorBanners } from "../components/ui/
|
|
5
|
+
import { useErrorBanners } from "../components/ui/error-banner-context";
|
|
6
6
|
import { buildMutationErrorBanner } from "../components/ui/error-banners";
|
|
7
7
|
/**
|
|
8
8
|
* The account's writing languages: the menu the composer's language chip
|
|
@@ -2,7 +2,7 @@ import { mailboxOperationsListMailboxesQueryKey, messageBulkOperationsDeleteMess
|
|
|
2
2
|
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
3
3
|
import { useCallback, useEffect, useRef } from "react";
|
|
4
4
|
import { useRoleAppointmentPrompt } from "../components/mail/RoleAppointmentPromptProvider";
|
|
5
|
-
import { useErrorBanners } from "../components/ui/
|
|
5
|
+
import { useErrorBanners } from "../components/ui/error-banner-context";
|
|
6
6
|
import { formatErrorDetail } from "../components/ui/error-banners";
|
|
7
7
|
import { isFolderRoleRefusal } from "../components/ui/folder-role-refusal";
|
|
8
8
|
import { isPlacementRefusal, placementRefusalBanner, } from "../components/ui/placement-refusal";
|
|
@@ -11,7 +11,7 @@ import { configOperationsGetConfigQueryKey, mailboxOperationsListMailboxesQueryK
|
|
|
11
11
|
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
12
12
|
import { useCallback, useRef, useState } from "react";
|
|
13
13
|
import { useRoleAppointmentPrompt } from "../components/mail/RoleAppointmentPromptProvider";
|
|
14
|
-
import { useErrorBanners } from "../components/ui/
|
|
14
|
+
import { useErrorBanners } from "../components/ui/error-banner-context";
|
|
15
15
|
import { formatErrorDetail } from "../components/ui/error-banners";
|
|
16
16
|
import { isFolderRoleRefusal, } from "../components/ui/folder-role-refusal";
|
|
17
17
|
import { softErrorStatuses } from "../lib/error-classifier";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { messageBulkOperationsDeleteMessages, messageBulkOperationsMoveMessages, messageBulkOperationsUpdateFlags, threadOperationsSearchThreads, } from "@remit/api-http-client/sdk.gen.ts";
|
|
2
2
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
3
3
|
import { useBulkRun, } from "../components/mail/BulkRunProvider";
|
|
4
|
-
import { useErrorBanners } from "../components/ui/
|
|
4
|
+
import { useErrorBanners } from "../components/ui/error-banner-context";
|
|
5
5
|
import { buildMutationErrorBanner } from "../components/ui/error-banners";
|
|
6
6
|
/** Page size for the execution loop. Set to the write side's own 100-id cap so
|
|
7
7
|
* an execution page IS a write chunk — no in-memory accumulation step between
|
|
@@ -7,7 +7,7 @@ import { type OrganizeDraft, type OrganizeScope } from "../lib/organize/organize
|
|
|
7
7
|
* filter is created or deleted (the same contract `buildMailboxListKey` pins
|
|
8
8
|
* for trigger-sync).
|
|
9
9
|
*/
|
|
10
|
-
export declare const buildFilterListKey: (accountId: string) => [Pick<import("@remit/api-http-client").Options<import("@remit/api-http-client").FilterOperationsListFiltersData>, "
|
|
10
|
+
export declare const buildFilterListKey: (accountId: string) => [Pick<import("@remit/api-http-client").Options<import("@remit/api-http-client").FilterOperationsListFiltersData>, "body" | "headers" | "path" | "query" | "baseUrl"> & {
|
|
11
11
|
_id: string;
|
|
12
12
|
_infinite?: boolean;
|
|
13
13
|
tags?: ReadonlyArray<string>;
|
|
@@ -5,7 +5,7 @@ import type { RemitImapLabelColor, RemitImapUpdateLabelInput } from "@remit/api-
|
|
|
5
5
|
* settings list and the rule editor's label picker never go stale after a
|
|
6
6
|
* label is created, renamed, recolored, or deleted (issue #26).
|
|
7
7
|
*/
|
|
8
|
-
export declare const buildLabelListKey: (accountId: string) => [Pick<import("@remit/api-http-client").Options<import("@remit/api-http-client").LabelOperationsListLabelsData>, "
|
|
8
|
+
export declare const buildLabelListKey: (accountId: string) => [Pick<import("@remit/api-http-client").Options<import("@remit/api-http-client").LabelOperationsListLabelsData>, "body" | "headers" | "path" | "query" | "baseUrl"> & {
|
|
9
9
|
_id: string;
|
|
10
10
|
_infinite?: boolean;
|
|
11
11
|
tags?: ReadonlyArray<string>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { mailboxOperationsListMailboxesQueryKey, messageBulkOperationsUpdateFlagsMutation, threadDetailOperationsListThreadMessagesQueryKey, } from "@remit/api-http-client/@tanstack/react-query.gen.ts";
|
|
2
2
|
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
3
3
|
import { useCallback, useEffect, useMemo, useRef } from "react";
|
|
4
|
-
import { useErrorBanners } from "../components/ui/
|
|
4
|
+
import { useErrorBanners } from "../components/ui/error-banner-context";
|
|
5
5
|
import { formatErrorDetail } from "../components/ui/error-banners";
|
|
6
6
|
import { runChunkedMutation } from "../lib/bulk-actions";
|
|
7
7
|
import { softErrorMeta } from "../lib/error-classifier";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { mailboxOperationsListMailboxesQueryKey, messageBulkOperationsMoveMessagesMutation, threadDetailOperationsListThreadMessagesQueryKey, } from "@remit/api-http-client/@tanstack/react-query.gen.ts";
|
|
2
2
|
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
3
3
|
import { useCallback } from "react";
|
|
4
|
-
import { useErrorBanners } from "../components/ui/
|
|
4
|
+
import { useErrorBanners } from "../components/ui/error-banner-context";
|
|
5
5
|
import { formatErrorDetail } from "../components/ui/error-banners";
|
|
6
6
|
import { isPlacementRefusal, placementRefusalBanner, } from "../components/ui/placement-refusal";
|
|
7
7
|
import { runChunkedMutation } from "../lib/bulk-actions";
|
|
@@ -2,7 +2,7 @@ import { mailboxOperationsListMailboxesQueryKey, threadDetailOperationsListThrea
|
|
|
2
2
|
import { messageBulkOperationsNotSpam, messageBulkOperationsReportSpam, } from "@remit/api-http-client/sdk.gen.ts";
|
|
3
3
|
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
4
4
|
import { useCallback } from "react";
|
|
5
|
-
import { useErrorBanners } from "../components/ui/
|
|
5
|
+
import { useErrorBanners } from "../components/ui/error-banner-context";
|
|
6
6
|
import { formatErrorDetail } from "../components/ui/error-banners";
|
|
7
7
|
import { ApiError } from "../lib/api";
|
|
8
8
|
import { runChunkedMutation } from "../lib/bulk-actions";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { accountDetailOperationsUpdateAccountMutation, configOperationsGetConfigOptions, configOperationsGetConfigQueryKey, } from "@remit/api-http-client/@tanstack/react-query.gen.ts";
|
|
2
2
|
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
3
3
|
import { useCallback, useMemo } from "react";
|
|
4
|
-
import { useErrorBanners } from "../components/ui/
|
|
4
|
+
import { useErrorBanners } from "../components/ui/error-banner-context";
|
|
5
5
|
import { buildMutationErrorBanner } from "../components/ui/error-banners";
|
|
6
6
|
const EMPTY_SIGNATURE = { html: "", plainText: "" };
|
|
7
7
|
export const useSignature = (accountId) => {
|
|
@@ -8,7 +8,7 @@ export interface StarredCriteria extends ThreadSearchTokenParams {
|
|
|
8
8
|
*/
|
|
9
9
|
query?: string;
|
|
10
10
|
}
|
|
11
|
-
export declare const starredThreadsQueryKey: (criteria?: StarredCriteria) => [Pick<import("@remit/api-http-client").Options<import("@remit/api-http-client").UnifiedThreadOperationsListAllThreadsData>, "
|
|
11
|
+
export declare const starredThreadsQueryKey: (criteria?: StarredCriteria) => [Pick<import("@remit/api-http-client").Options<import("@remit/api-http-client").UnifiedThreadOperationsListAllThreadsData>, "body" | "headers" | "path" | "query" | "baseUrl"> & {
|
|
12
12
|
_id: string;
|
|
13
13
|
_infinite?: boolean;
|
|
14
14
|
tags?: ReadonlyArray<string>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { messageOperationsUpdateMessageFlagsMutation, threadDetailOperationsListThreadMessagesQueryKey, } from "@remit/api-http-client/@tanstack/react-query.gen.ts";
|
|
2
2
|
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
3
|
-
import { useErrorBanners } from "../components/ui/
|
|
3
|
+
import { useErrorBanners } from "../components/ui/error-banner-context";
|
|
4
4
|
import { formatErrorDetail } from "../components/ui/error-banners";
|
|
5
5
|
import { patchThreadListCache } from "../lib/thread-cache";
|
|
6
6
|
import { cancelThreadListQueries, invalidateThreadListQueries, patchThreadListQueries, restoreThreadListQueries, snapshotThreadListQueries, threadListCacheKeys, } from "../lib/thread-list-cache";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { addressDetailOperationsUpdateAddressMutation, messageOperationsDescribeMessageQueryKey, } from "@remit/api-http-client/@tanstack/react-query.gen.ts";
|
|
2
2
|
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
3
|
-
import { useErrorBanners } from "../components/ui/
|
|
3
|
+
import { useErrorBanners } from "../components/ui/error-banner-context";
|
|
4
4
|
import { buildMutationErrorBanner } from "../components/ui/error-banners";
|
|
5
5
|
export const buildTrustedFlag = (nextTrusted, now = Date.now()) => ({
|
|
6
6
|
value: nextTrusted,
|
|
@@ -10,7 +10,7 @@ interface UseTriggerSyncResult {
|
|
|
10
10
|
* given account. Extracted from the hook so the staleness/invalidation
|
|
11
11
|
* contract can be unit-tested without rendering React.
|
|
12
12
|
*/
|
|
13
|
-
export declare const buildMailboxListKey: (accountId: string) => [Pick<import("@remit/api-http-client").Options<import("@remit/api-http-client").MailboxOperationsListMailboxesData>, "
|
|
13
|
+
export declare const buildMailboxListKey: (accountId: string) => [Pick<import("@remit/api-http-client").Options<import("@remit/api-http-client").MailboxOperationsListMailboxesData>, "body" | "headers" | "path" | "query" | "baseUrl"> & {
|
|
14
14
|
_id: string;
|
|
15
15
|
_infinite?: boolean;
|
|
16
16
|
tags?: ReadonlyArray<string>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { addressDetailOperationsUpdateAddressMutation, addressOperationsSearchAddressesQueryKey, } from "@remit/api-http-client/@tanstack/react-query.gen.ts";
|
|
2
2
|
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
3
3
|
import { useCallback } from "react";
|
|
4
|
-
import { useErrorBanners } from "../components/ui/
|
|
4
|
+
import { useErrorBanners } from "../components/ui/error-banner-context";
|
|
5
5
|
import { formatErrorDetail } from "../components/ui/error-banners";
|
|
6
6
|
import { reportFatalError } from "../lib/fatal-error";
|
|
7
7
|
import { senderAddressSearchQuery } from "../lib/sender-address";
|