@burdenoff/microfe-calendar 2026.1123.3 → 2026.1124.2
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/components/AgendaView.js.map +1 -1
- package/dist/generated/wspace-operations.d.ts +785 -0
- package/dist/generated/wspace-operations.js +250 -84
- package/dist/generated/wspace-operations.js.map +1 -1
- package/dist/generated/wspace-types.d.ts +1243 -10
- package/dist/hooks/useSafePermissions.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/providers/CalendarProvider.d.ts +3 -1
- package/dist/providers/CalendarProvider.js +12 -10
- package/dist/providers/CalendarProvider.js.map +1 -1
- package/dist/translations/en.d.ts +351 -0
- package/dist/types/index.d.ts +9 -0
- package/dist/v2/CalendarPageV2.js +92 -14
- package/dist/v2/CalendarPageV2.js.map +1 -1
- package/dist/v2/colors.d.ts +23 -0
- package/dist/v2/colors.js +92 -0
- package/dist/v2/colors.js.map +1 -0
- package/dist/v2/data/enums.d.ts +6 -0
- package/dist/v2/data/enums.js +10 -0
- package/dist/v2/data/enums.js.map +1 -0
- package/dist/v2/data/errors.d.ts +4 -0
- package/dist/v2/data/errors.js +17 -0
- package/dist/v2/data/errors.js.map +1 -0
- package/dist/v2/data/invalidation.js +19 -0
- package/dist/v2/data/invalidation.js.map +1 -0
- package/dist/v2/data/normalize.js +181 -16
- package/dist/v2/data/normalize.js.map +1 -1
- package/dist/v2/data/serialWrites.d.ts +17 -0
- package/dist/v2/data/serialWrites.js +21 -0
- package/dist/v2/data/serialWrites.js.map +1 -0
- package/dist/v2/data/useCalendarsV2.d.ts +10 -1
- package/dist/v2/data/useCalendarsV2.js +68 -16
- package/dist/v2/data/useCalendarsV2.js.map +1 -1
- package/dist/v2/data/useEventActions.d.ts +49 -0
- package/dist/v2/data/useEventActions.js +399 -0
- package/dist/v2/data/useEventActions.js.map +1 -0
- package/dist/v2/data/useEventForPeek.d.ts +17 -0
- package/dist/v2/data/useEventForPeek.js +29 -0
- package/dist/v2/data/useEventForPeek.js.map +1 -0
- package/dist/v2/data/useEventSearchV2.d.ts +15 -0
- package/dist/v2/data/useEventSearchV2.js +80 -0
- package/dist/v2/data/useEventSearchV2.js.map +1 -0
- package/dist/v2/data/useEventsInRangeV2.js +78 -0
- package/dist/v2/data/useEventsInRangeV2.js.map +1 -0
- package/dist/v2/data/useFreeBusy.d.ts +5 -0
- package/dist/v2/data/useFreeBusy.js +83 -0
- package/dist/v2/data/useFreeBusy.js.map +1 -0
- package/dist/v2/data/useKeyedLoad.js +47 -0
- package/dist/v2/data/useKeyedLoad.js.map +1 -0
- package/dist/v2/data/useRoomsV2.d.ts +28 -0
- package/dist/v2/data/useRoomsV2.js +45 -0
- package/dist/v2/data/useRoomsV2.js.map +1 -0
- package/dist/v2/day/DayPanel.d.ts +6 -0
- package/dist/v2/day/DayPanel.js +215 -0
- package/dist/v2/day/DayPanel.js.map +1 -0
- package/dist/v2/day/daySummary.d.ts +37 -0
- package/dist/v2/day/daySummary.js +37 -0
- package/dist/v2/day/daySummary.js.map +1 -0
- package/dist/v2/dialogs/CalendarDialogsV2.d.ts +1 -0
- package/dist/v2/dialogs/CalendarDialogsV2.js +17 -0
- package/dist/v2/dialogs/CalendarDialogsV2.js.map +1 -0
- package/dist/v2/dialogs/ShortcutsDialog.d.ts +4 -0
- package/dist/v2/dialogs/ShortcutsDialog.js +42 -0
- package/dist/v2/dialogs/ShortcutsDialog.js.map +1 -0
- package/dist/v2/events/eventLook.d.ts +46 -0
- package/dist/v2/events/eventLook.js +35 -0
- package/dist/v2/events/eventLook.js.map +1 -0
- package/dist/v2/events/eventModel.d.ts +92 -0
- package/dist/v2/events/eventModel.js +116 -0
- package/dist/v2/events/eventModel.js.map +1 -0
- package/dist/v2/events/localChanges.d.ts +4 -0
- package/dist/v2/events/localChanges.js +23 -0
- package/dist/v2/events/localChanges.js.map +1 -0
- package/dist/v2/format.d.ts +67 -0
- package/dist/v2/format.js +112 -0
- package/dist/v2/format.js.map +1 -0
- package/dist/v2/grid/AllDayRow.d.ts +20 -0
- package/dist/v2/grid/AllDayRow.js +94 -0
- package/dist/v2/grid/AllDayRow.js.map +1 -0
- package/dist/v2/grid/EventBlock.d.ts +21 -0
- package/dist/v2/grid/EventBlock.js +112 -0
- package/dist/v2/grid/EventBlock.js.map +1 -0
- package/dist/v2/grid/GridParts.d.ts +40 -0
- package/dist/v2/grid/GridParts.js +210 -0
- package/dist/v2/grid/GridParts.js.map +1 -0
- package/dist/v2/grid/QuickCreate.d.ts +1 -0
- package/dist/v2/grid/QuickCreate.js +175 -0
- package/dist/v2/grid/QuickCreate.js.map +1 -0
- package/dist/v2/grid/TimeGrid.d.ts +1 -0
- package/dist/v2/grid/TimeGrid.js +188 -0
- package/dist/v2/grid/TimeGrid.js.map +1 -0
- package/dist/v2/grid/geometry.d.ts +72 -0
- package/dist/v2/grid/geometry.js +85 -0
- package/dist/v2/grid/geometry.js.map +1 -0
- package/dist/v2/grid/layout.d.ts +24 -0
- package/dist/v2/grid/layout.js +77 -0
- package/dist/v2/grid/layout.js.map +1 -0
- package/dist/v2/grid/useGridDrag.d.ts +42 -0
- package/dist/v2/grid/useGridDrag.js +181 -0
- package/dist/v2/grid/useGridDrag.js.map +1 -0
- package/dist/v2/grid/useSlotCursor.d.ts +32 -0
- package/dist/v2/grid/useSlotCursor.js +57 -0
- package/dist/v2/grid/useSlotCursor.js.map +1 -0
- package/dist/v2/grid/workingHours.d.ts +21 -0
- package/dist/v2/grid/workingHours.js +101 -0
- package/dist/v2/grid/workingHours.js.map +1 -0
- package/dist/v2/hooks/useAvailableHeight.d.ts +2 -0
- package/dist/v2/hooks/useAvailableHeight.js +25 -0
- package/dist/v2/hooks/useAvailableHeight.js.map +1 -0
- package/dist/v2/hooks/useCalendarShortcuts.d.ts +9 -0
- package/dist/v2/hooks/useCalendarShortcuts.js +60 -0
- package/dist/v2/hooks/useCalendarShortcuts.js.map +1 -0
- package/dist/v2/hooks/useDebouncedValue.d.ts +1 -0
- package/dist/v2/hooks/useDebouncedValue.js +12 -0
- package/dist/v2/hooks/useDebouncedValue.js.map +1 -0
- package/dist/v2/hooks/useMediaQuery.d.ts +5 -0
- package/dist/v2/hooks/useMediaQuery.js +17 -0
- package/dist/v2/hooks/useMediaQuery.js.map +1 -0
- package/dist/v2/hooks/useNow.d.ts +2 -0
- package/dist/v2/hooks/useNow.js +31 -0
- package/dist/v2/hooks/useNow.js.map +1 -0
- package/dist/v2/limits.d.ts +6 -0
- package/dist/v2/limits.js +5 -0
- package/dist/v2/limits.js.map +1 -0
- package/dist/v2/list/EventListRow.d.ts +10 -0
- package/dist/v2/list/EventListRow.js +109 -0
- package/dist/v2/list/EventListRow.js.map +1 -0
- package/dist/v2/list/ListViewV2.d.ts +16 -0
- package/dist/v2/list/ListViewV2.js +96 -0
- package/dist/v2/list/ListViewV2.js.map +1 -0
- package/dist/v2/month/MonthView.d.ts +1 -0
- package/dist/v2/month/MonthView.js +328 -0
- package/dist/v2/month/MonthView.js.map +1 -0
- package/dist/v2/month/monthLayout.d.ts +39 -0
- package/dist/v2/month/monthLayout.js +29 -0
- package/dist/v2/month/monthLayout.js.map +1 -0
- package/dist/v2/page/CalendarChrome.d.ts +2 -0
- package/dist/v2/page/CalendarChrome.js +295 -0
- package/dist/v2/page/CalendarChrome.js.map +1 -0
- package/dist/v2/page/CalendarPageContext.d.ts +92 -0
- package/dist/v2/page/CalendarPageContext.js +11 -0
- package/dist/v2/page/CalendarPageContext.js.map +1 -0
- package/dist/v2/page/pageHelpers.d.ts +19 -0
- package/dist/v2/page/pageHelpers.js +39 -0
- package/dist/v2/page/pageHelpers.js.map +1 -0
- package/dist/v2/page/useCalendarPageModel.d.ts +2 -0
- package/dist/v2/page/useCalendarPageModel.js +198 -0
- package/dist/v2/page/useCalendarPageModel.js.map +1 -0
- package/dist/v2/page/viewState.d.ts +70 -0
- package/dist/v2/page/viewState.js +47 -0
- package/dist/v2/page/viewState.js.map +1 -0
- package/dist/v2/peek/EventPeek.d.ts +2 -0
- package/dist/v2/peek/EventPeek.js +92 -0
- package/dist/v2/peek/EventPeek.js.map +1 -0
- package/dist/v2/peek/PeekEvent.d.ts +4 -0
- package/dist/v2/peek/PeekEvent.js +443 -0
- package/dist/v2/peek/PeekEvent.js.map +1 -0
- package/dist/v2/peek/PeekParts.d.ts +14 -0
- package/dist/v2/peek/PeekParts.js +75 -0
- package/dist/v2/peek/PeekParts.js.map +1 -0
- package/dist/v2/prefs/calendarPrefs.d.ts +2 -2
- package/dist/v2/prefs/calendarPrefs.js +35 -34
- package/dist/v2/prefs/calendarPrefs.js.map +1 -1
- package/dist/v2/rail/CalendarRail.d.ts +3 -0
- package/dist/v2/rail/CalendarRail.js +258 -0
- package/dist/v2/rail/CalendarRail.js.map +1 -0
- package/dist/v2/rail/railStatus.d.ts +54 -0
- package/dist/v2/rail/railStatus.js +84 -0
- package/dist/v2/rail/railStatus.js.map +1 -0
- package/dist/v2/rail/syncWords.d.ts +10 -0
- package/dist/v2/rail/syncWords.js +75 -0
- package/dist/v2/rail/syncWords.js.map +1 -0
- package/dist/v2/rail/useMonthEventDates.d.ts +4 -0
- package/dist/v2/rail/useMonthEventDates.js +30 -0
- package/dist/v2/rail/useMonthEventDates.js.map +1 -0
- package/dist/v2/routes.js +4 -1
- package/dist/v2/routes.js.map +1 -1
- package/dist/v2/runs/RunPeek.d.ts +2 -0
- package/dist/v2/runs/RunPeek.js +382 -0
- package/dist/v2/runs/RunPeek.js.map +1 -0
- package/dist/v2/runs/RunPills.d.ts +28 -0
- package/dist/v2/runs/RunPills.js +179 -0
- package/dist/v2/runs/RunPills.js.map +1 -0
- package/dist/v2/runs/RunRows.d.ts +21 -0
- package/dist/v2/runs/RunRows.js +140 -0
- package/dist/v2/runs/RunRows.js.map +1 -0
- package/dist/v2/runs/RunsNotices.d.ts +1 -0
- package/dist/v2/runs/RunsNotices.js +37 -0
- package/dist/v2/runs/RunsNotices.js.map +1 -0
- package/dist/v2/runs/RunsSwitch.d.ts +1 -0
- package/dist/v2/runs/RunsSwitch.js +54 -0
- package/dist/v2/runs/RunsSwitch.js.map +1 -0
- package/dist/v2/runs/WorkflowRunsLayer.d.ts +4 -0
- package/dist/v2/runs/WorkflowRunsLayer.js +82 -0
- package/dist/v2/runs/WorkflowRunsLayer.js.map +1 -0
- package/dist/v2/runs/runAccess.d.ts +37 -0
- package/dist/v2/runs/runAccess.js +14 -0
- package/dist/v2/runs/runAccess.js.map +1 -0
- package/dist/v2/runs/runLayout.d.ts +76 -0
- package/dist/v2/runs/runLayout.js +129 -0
- package/dist/v2/runs/runLayout.js.map +1 -0
- package/dist/v2/runs/runLinks.d.ts +32 -0
- package/dist/v2/runs/runLinks.js +50 -0
- package/dist/v2/runs/runLinks.js.map +1 -0
- package/dist/v2/runs/runModel.d.ts +97 -0
- package/dist/v2/runs/runModel.js +132 -0
- package/dist/v2/runs/runModel.js.map +1 -0
- package/dist/v2/runs/runPeekState.d.ts +53 -0
- package/dist/v2/runs/runPeekState.js +62 -0
- package/dist/v2/runs/runPeekState.js.map +1 -0
- package/dist/v2/runs/runTypes.d.ts +60 -0
- package/dist/v2/runs/runWords.d.ts +23 -0
- package/dist/v2/runs/runWords.js +83 -0
- package/dist/v2/runs/runWords.js.map +1 -0
- package/dist/v2/runs/runsLayerContext.d.ts +26 -0
- package/dist/v2/runs/runsLayerContext.js +33 -0
- package/dist/v2/runs/runsLayerContext.js.map +1 -0
- package/dist/v2/runs/useRunHrefs.d.ts +10 -0
- package/dist/v2/runs/useRunHrefs.js +60 -0
- package/dist/v2/runs/useRunHrefs.js.map +1 -0
- package/dist/v2/runs/useRunLabels.d.ts +6 -0
- package/dist/v2/runs/useRunLabels.js +27 -0
- package/dist/v2/runs/useRunLabels.js.map +1 -0
- package/dist/v2/runs/useRunsAccess.d.ts +2 -0
- package/dist/v2/runs/useRunsAccess.js +14 -0
- package/dist/v2/runs/useRunsAccess.js.map +1 -0
- package/dist/v2/runs/useWorkflowRuns.d.ts +61 -0
- package/dist/v2/runs/useWorkflowRuns.js +119 -0
- package/dist/v2/runs/useWorkflowRuns.js.map +1 -0
- package/dist/v2/search/SearchResults.d.ts +1 -0
- package/dist/v2/search/SearchResults.js +88 -0
- package/dist/v2/search/SearchResults.js.map +1 -0
- package/dist/v2/search/searchModel.d.ts +20 -0
- package/dist/v2/search/searchModel.js +22 -0
- package/dist/v2/search/searchModel.js.map +1 -0
- package/dist/v2/state/calendarV2Store.d.ts +4 -1
- package/dist/v2/state/calendarV2Store.js +3 -1
- package/dist/v2/state/calendarV2Store.js.map +1 -1
- package/dist/v2/state/useCalendarV2Navigation.d.ts +1 -0
- package/dist/v2/state/useCalendarV2Navigation.js +4 -1
- package/dist/v2/state/useCalendarV2Navigation.js.map +1 -1
- package/dist/v2/states/CalendarStates.d.ts +18 -0
- package/dist/v2/states/CalendarStates.js +122 -0
- package/dist/v2/states/CalendarStates.js.map +1 -0
- package/dist/v2/styles.d.ts +32 -0
- package/dist/v2/styles.js +10 -0
- package/dist/v2/styles.js.map +1 -0
- package/dist/v2/time/calendarTime.js +121 -35
- package/dist/v2/time/calendarTime.js.map +1 -1
- package/dist/v2/types.d.ts +22 -2
- package/package.json +1 -1
|
@@ -1,25 +1,77 @@
|
|
|
1
1
|
import { CalendarV2CalendarsDocument as e } from "../../generated/wspace-operations.js";
|
|
2
2
|
import { useCalendar as t } from "../../providers/CalendarProvider.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
import { MAX_LISTED_CALENDARS as n } from "../limits.js";
|
|
4
|
+
import { sortCalendarsV2 as r, toCalendarV2 as i } from "./normalize.js";
|
|
5
|
+
import { useKeyedLoad as a } from "./useKeyedLoad.js";
|
|
6
|
+
import { useCallback as o, useMemo as s } from "react";
|
|
7
|
+
import { useApolloClient as c, useQuery as l } from "@apollo/client/react";
|
|
8
|
+
var u = Math.ceil(n / 200);
|
|
9
|
+
async function d(t, n) {
|
|
10
|
+
let r = [], i = n;
|
|
11
|
+
for (let n = 1; n < u; n += 1) {
|
|
12
|
+
let n = (await t.query({
|
|
13
|
+
query: e,
|
|
14
|
+
variables: { pagination: {
|
|
15
|
+
limit: 200,
|
|
16
|
+
offset: i
|
|
17
|
+
} },
|
|
18
|
+
fetchPolicy: "network-only"
|
|
19
|
+
})).data?.calendars;
|
|
20
|
+
if (!n) throw Error("The calendars could not be loaded");
|
|
21
|
+
if (r.push(...n.calendars), !n.hasMore || n.calendars.length === 0) break;
|
|
22
|
+
i += n.calendars.length;
|
|
23
|
+
}
|
|
24
|
+
return r;
|
|
25
|
+
}
|
|
26
|
+
function f(e, t) {
|
|
27
|
+
if (e !== null) return t.dataKey === e ? t.data : t.error ? void 0 : t.data;
|
|
28
|
+
}
|
|
29
|
+
function p(e, t) {
|
|
30
|
+
let n = c(), r = e?.calendars, i = !t && e?.hasMore && r && r.length > 0 ? [e.total, ...r.map((e) => e.id)].join("|") : null, o = a(i, async () => ({
|
|
31
|
+
first: r ?? [],
|
|
32
|
+
later: await d(n, r?.length ?? 0)
|
|
33
|
+
})), s = f(i, o);
|
|
34
|
+
return {
|
|
35
|
+
whole: s,
|
|
36
|
+
pending: i !== null && s === void 0,
|
|
37
|
+
error: o.error,
|
|
38
|
+
reload: o.reload
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function m(e) {
|
|
42
|
+
return e.skip ? "idle" : e.hasFirst ? e.laterPending ? e.laterError ? "error" : "loading" : "ready" : e.firstError ? "error" : e.firstLoading ? "loading" : "ready";
|
|
43
|
+
}
|
|
44
|
+
function h(n = {}) {
|
|
45
|
+
let a = n.skip ?? !1, { currentUser: c } = t(), u = c?.id ?? null, { data: d, error: f, loading: h, refetch: g } = l(e, {
|
|
8
46
|
variables: { pagination: { limit: 200 } },
|
|
9
47
|
fetchPolicy: "cache-and-network",
|
|
10
|
-
skip:
|
|
11
|
-
}),
|
|
12
|
-
|
|
13
|
-
|
|
48
|
+
skip: a
|
|
49
|
+
}), _ = d?.calendars, v = p(_, a), y = v.whole, b = s(() => {
|
|
50
|
+
let e = y ? [...y.first, ...y.later] : _?.calendars ?? [], t = [...new Map(e.map((e) => [e.id, e])).values()];
|
|
51
|
+
return r(t.map((e) => i(e, u)));
|
|
52
|
+
}, [
|
|
53
|
+
_,
|
|
54
|
+
u,
|
|
55
|
+
y
|
|
56
|
+
]), x = v.reload, S = o(() => {
|
|
57
|
+
g().catch(() => void 0), x();
|
|
58
|
+
}, [g, x]);
|
|
14
59
|
return {
|
|
15
|
-
calendars:
|
|
16
|
-
status:
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
60
|
+
calendars: b,
|
|
61
|
+
status: m({
|
|
62
|
+
skip: a,
|
|
63
|
+
hasFirst: _ !== void 0,
|
|
64
|
+
firstError: f !== void 0,
|
|
65
|
+
firstLoading: h,
|
|
66
|
+
laterPending: v.pending,
|
|
67
|
+
laterError: v.error !== null
|
|
68
|
+
}),
|
|
69
|
+
error: f ?? (v.pending ? v.error : null),
|
|
70
|
+
hasMore: v.pending,
|
|
71
|
+
total: _?.total ?? b.length,
|
|
72
|
+
refetch: S
|
|
21
73
|
};
|
|
22
74
|
}
|
|
23
|
-
export {
|
|
75
|
+
export { f as servingWholeList, h as useCalendarsV2 };
|
|
24
76
|
|
|
25
77
|
//# sourceMappingURL=useCalendarsV2.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCalendarsV2.js","names":["
|
|
1
|
+
{"version":3,"file":"useCalendarsV2.js","names":["MAX_CALENDAR_PAGES","MAX_LISTED_CALENDARS","loadLaterPages","found","offset","firstCount","page","next","client","CalendarV2CalendarsDocument","servingWholeList","key","load","useWholeList","useApolloClient","firstRows","first","skip","calendar","useKeyedLoad","whole","listStatus","input","useCalendarsV2","options","useCalendar","myUserId","currentUser","useQuery","connection","data","later","calendars","useMemo","rows","unique","raw","sortCalendarsV2","toCalendarV2","reloadLater","reload","useCallback","refetch","error","loading"],"sources":["../../../src/v2/data/useCalendarsV2.ts"],"sourcesContent":["/**\n * The calendars the redesigned calendar lists (BOFF-15698 A0): the workspace's calendars the\n * person can see, in the rail's order, each with its section (\"My calendars\" or \"Other\n * calendars\") and what its sync says. A watched query: a write that refetches\n * `CalendarV2Calendars` updates every list on the page.\n *\n * The service answers 200 calendars at a time. Someone who can see more gets the other pages\n * too, and the list is `ready` only once it is whole (a calendar left out would vanish from\n * the rail, the views and search); a later page that fails makes the list an `error`.\n */\nimport { useCallback, useMemo } from 'react';\nimport { useApolloClient, useQuery } from '@apollo/client/react';\nimport {\n CalendarV2CalendarsDocument,\n type CalendarV2CalendarsQuery,\n type CalendarV2CalendarsQueryVariables,\n} from '../../generated/wspace-operations';\nimport { useCalendar } from '../../providers/CalendarProvider';\nimport { MAX_LISTED_CALENDARS } from '../limits';\nimport type { CalendarV2 } from '../types';\nimport { sortCalendarsV2, toCalendarV2 } from './normalize';\nimport { useKeyedLoad } from './useKeyedLoad';\n\n/** The most calendars one list asks for (the service's page limit). */\nexport const CALENDARS_PAGE_SIZE = 200;\n\n/** The most pages asked for, so a list that never ends can't loop. */\nconst MAX_CALENDAR_PAGES = Math.ceil(MAX_LISTED_CALENDARS / CALENDARS_PAGE_SIZE);\n\ntype RawCalendarV2 = CalendarV2CalendarsQuery['calendars']['calendars'][number];\n\nexport interface CalendarsV2 {\n calendars: CalendarV2[];\n /** `idle` when skipped; `error` only when there is nothing to show. */\n status: 'idle' | 'loading' | 'ready' | 'error';\n error: Error | null;\n /** More calendars exist than the ones in hand (their pages are still loading, or failed). */\n hasMore: boolean;\n total: number;\n refetch: () => void;\n}\n\ntype CalendarsClient = ReturnType<typeof useApolloClient>;\n\n/** The pages after the first, asked one after another until the service says there are no more. */\nasync function loadLaterPages(\n client: CalendarsClient,\n firstCount: number\n): Promise<RawCalendarV2[]> {\n const found: RawCalendarV2[] = [];\n let offset = firstCount;\n for (let page = 1; page < MAX_CALENDAR_PAGES; page += 1) {\n const result = await client.query<CalendarV2CalendarsQuery, CalendarV2CalendarsQueryVariables>({\n query: CalendarV2CalendarsDocument,\n variables: { pagination: { limit: CALENDARS_PAGE_SIZE, offset } },\n fetchPolicy: 'network-only',\n });\n const next = result.data?.calendars;\n if (!next) throw new Error('The calendars could not be loaded');\n found.push(...next.calendars);\n if (!next.hasMore || next.calendars.length === 0) break;\n offset += next.calendars.length;\n }\n return found;\n}\n\ntype FirstPage = CalendarV2CalendarsQuery['calendars'] | undefined;\n\n/**\n * Which loaded answer serves for `key`: its own; while it loads, the last one; none once its\n * load failed (or when there is no key).\n */\nexport function servingWholeList<T>(\n key: string | null,\n load: { data: T | undefined; dataKey: string | null; error: Error | null }\n): T | undefined {\n if (key === null) return undefined;\n if (load.dataKey === key) return load.data;\n return load.error ? undefined : load.data;\n}\n\n/** A whole list: a first page with the pages after it, as they were loaded together. */\ninterface WholeList {\n first: readonly RawCalendarV2[];\n later: readonly RawCalendarV2[];\n}\n\n/**\n * The whole list, when the person can see more calendars than the first page holds. After a\n * refresh changes the first page, the last whole list (its own first page with its own later\n * pages, never mixed with the new ones) serves until the new later pages land, so the page\n * doesn't drop back to loading; if they fail, the list is an error, never the old one as if\n * it were current.\n */\nfunction useWholeList(first: FirstPage, skip: boolean) {\n const client = useApolloClient();\n const firstRows = first?.calendars;\n const key =\n !skip && first?.hasMore && firstRows && firstRows.length > 0\n ? [first.total, ...firstRows.map((calendar) => calendar.id)].join('|')\n : null;\n const load = useKeyedLoad<WholeList>(key, async () => ({\n first: firstRows ?? [],\n later: await loadLaterPages(client, firstRows?.length ?? 0),\n }));\n const whole = servingWholeList(key, load);\n return {\n whole,\n /** Not in hand: still to come (loading), or failed (`error`). */\n pending: key !== null && whole === undefined,\n error: load.error,\n reload: load.reload,\n };\n}\n\n/** Whole, still loading, or failed: never `ready` while a page is missing. */\nfunction listStatus(input: {\n skip: boolean;\n hasFirst: boolean;\n firstError: boolean;\n firstLoading: boolean;\n laterPending: boolean;\n laterError: boolean;\n}): CalendarsV2['status'] {\n if (input.skip) return 'idle';\n if (input.hasFirst) {\n if (!input.laterPending) return 'ready';\n return input.laterError ? 'error' : 'loading';\n }\n if (input.firstError) return 'error';\n return input.firstLoading ? 'loading' : 'ready';\n}\n\nexport function useCalendarsV2(options: { skip?: boolean } = {}): CalendarsV2 {\n const skip = options.skip ?? false;\n const { currentUser } = useCalendar();\n const myUserId = currentUser?.id ?? null;\n const { data, error, loading, refetch } = useQuery<\n CalendarV2CalendarsQuery,\n CalendarV2CalendarsQueryVariables\n >(CalendarV2CalendarsDocument, {\n variables: { pagination: { limit: CALENDARS_PAGE_SIZE } },\n fetchPolicy: 'cache-and-network',\n skip,\n });\n const connection = data?.calendars;\n const later = useWholeList(connection, skip);\n const whole = later.whole;\n\n const calendars = useMemo(() => {\n const rows = whole ? [...whole.first, ...whole.later] : (connection?.calendars ?? []);\n const unique = [...new Map(rows.map((raw) => [raw.id, raw])).values()];\n return sortCalendarsV2(unique.map((raw) => toCalendarV2(raw, myUserId)));\n }, [connection, myUserId, whole]);\n const reloadLater = later.reload;\n const reload = useCallback(() => {\n // A failed refetch shows through `error`.\n refetch().catch(() => undefined);\n reloadLater();\n }, [refetch, reloadLater]);\n\n return {\n calendars,\n status: listStatus({\n skip,\n hasFirst: connection !== undefined,\n firstError: error !== undefined,\n firstLoading: loading,\n laterPending: later.pending,\n laterError: later.error !== null,\n }),\n error: error ?? (later.pending ? later.error : null),\n hasMore: later.pending,\n total: connection?.total ?? calendars.length,\n refetch: reload,\n };\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { CalendarFormat, DurationWords } from '../format';
|
|
2
|
+
import { EventTimes } from '../grid/geometry';
|
|
3
|
+
import { CalendarEventV2, CalendarV2, EventResponseV2 } from '../types';
|
|
4
|
+
/** The Undo window of a delete, in seconds: the service holds it this long (B6). */
|
|
5
|
+
export declare const DELETE_HOLD_SECONDS = 8;
|
|
6
|
+
export type Tr = (key: string, fallback: string, params?: Record<string, string | number>) => string;
|
|
7
|
+
/** What the page knows that the messages need. */
|
|
8
|
+
export interface EventActionsContext {
|
|
9
|
+
tr: Tr;
|
|
10
|
+
format: CalendarFormat;
|
|
11
|
+
durationWords: DurationWords;
|
|
12
|
+
timeZone: string;
|
|
13
|
+
me: string | null;
|
|
14
|
+
showDeclined: boolean;
|
|
15
|
+
defaultReminder: number | null;
|
|
16
|
+
/** Loads the whole calendar list again (every page), e.g. after a sync was checked. */
|
|
17
|
+
reloadCalendars: () => void;
|
|
18
|
+
}
|
|
19
|
+
export type Answer = 'ACCEPTED' | 'TENTATIVE' | 'DECLINED';
|
|
20
|
+
export interface QuickCreateInput {
|
|
21
|
+
calendarId: string;
|
|
22
|
+
title: string;
|
|
23
|
+
start: Date;
|
|
24
|
+
end: Date;
|
|
25
|
+
allDay: boolean;
|
|
26
|
+
}
|
|
27
|
+
export interface EventActions {
|
|
28
|
+
/** Event times shown before the service confirms a move (by event id). */
|
|
29
|
+
overrides: ReadonlyMap<string, EventTimes>;
|
|
30
|
+
/** Events deleted here, hidden until the views reload without them. */
|
|
31
|
+
removedIds: ReadonlySet<string>;
|
|
32
|
+
/** Answers given here, shown before the views reload. */
|
|
33
|
+
answers: ReadonlyMap<string, EventResponseV2>;
|
|
34
|
+
changeTimes: (event: CalendarEventV2, next: EventTimes, kind: 'move' | 'resize') => Promise<void>;
|
|
35
|
+
remove: (event: CalendarEventV2) => Promise<void>;
|
|
36
|
+
respond: (event: CalendarEventV2, answer: Answer) => Promise<void>;
|
|
37
|
+
duplicate: (event: CalendarEventV2) => Promise<void>;
|
|
38
|
+
quickCreate: (input: QuickCreateInput) => Promise<boolean>;
|
|
39
|
+
downloadIcs: (event: CalendarEventV2) => Promise<void>;
|
|
40
|
+
copyText: (text: string, done: string) => Promise<void>;
|
|
41
|
+
checkSyncNow: (calendar: CalendarV2) => Promise<void>;
|
|
42
|
+
/** Drops changes the reloaded events now show (the service confirmed them). */
|
|
43
|
+
settle: (events: readonly CalendarEventV2[]) => void;
|
|
44
|
+
}
|
|
45
|
+
/** A file name from an event's title: letters, digits and dashes. */
|
|
46
|
+
export declare function icsFileName(title: string): string;
|
|
47
|
+
export declare function useEventActions(context: EventActionsContext): EventActions;
|
|
48
|
+
/** The person's answer to show for an event: one given here wins until the views reload. */
|
|
49
|
+
export declare function answerFor(event: CalendarEventV2, answers: ReadonlyMap<string, EventResponseV2>, me: string | null): EventResponseV2 | null;
|
|
@@ -0,0 +1,399 @@
|
|
|
1
|
+
import { CalendarV2CreateEventDocument as e, CalendarV2CreateReminderDocument as t, CalendarV2DeleteEventDocument as n, CalendarV2DuplicateEventDocument as r, CalendarV2EventIcsDocument as i, CalendarV2RespondToEventDocument as a, CalendarV2RestoreEventDocument as o, CalendarV2TriggerSyncDocument as s, CalendarV2UpdateEventTimesDocument as c } from "../../generated/wspace-operations.js";
|
|
2
|
+
import { myPart as l } from "../events/eventModel.js";
|
|
3
|
+
import { formatDay as u, formatDuration as d, formatInstantRange as f, formatInstantTime as ee } from "../format.js";
|
|
4
|
+
import { instantToZoned as p } from "../time/calendarTime.js";
|
|
5
|
+
import { REMINDER_IN_APP as m, RSVP_STATUS as h, SCOPE_ALL_EVENTS as te } from "./enums.js";
|
|
6
|
+
import { graphQLErrorCode as ne } from "./errors.js";
|
|
7
|
+
import { invalidateCalendarEvents as g } from "./invalidation.js";
|
|
8
|
+
import { SerialWrites as _ } from "./serialWrites.js";
|
|
9
|
+
import { useCallback as v, useEffect as re, useMemo as y, useRef as b, useState as x } from "react";
|
|
10
|
+
import { useConfirm as S, useNotify as C } from "@burdenoff/fe-libs/ui";
|
|
11
|
+
import { useApolloClient as w } from "@apollo/client/react";
|
|
12
|
+
function ie(e, t) {
|
|
13
|
+
return e.guests.filter((e) => !e.organizer && e.userId !== t).length;
|
|
14
|
+
}
|
|
15
|
+
function T(e, t) {
|
|
16
|
+
let n = p(e, t.timeZone).date;
|
|
17
|
+
return u(n, t.format, "mid");
|
|
18
|
+
}
|
|
19
|
+
function E(e, t) {
|
|
20
|
+
if (typeof document > "u" || typeof URL.createObjectURL != "function") return !1;
|
|
21
|
+
let n = URL.createObjectURL(new Blob([e], { type: "text/calendar;charset=utf-8" })), r = document.createElement("a");
|
|
22
|
+
return r.href = n, r.download = t, r.rel = "noopener", document.body.appendChild(r), r.click(), r.remove(), setTimeout(() => URL.revokeObjectURL(n), 1e3), !0;
|
|
23
|
+
}
|
|
24
|
+
function D(e) {
|
|
25
|
+
return `${e.normalize("NFKD").replace(/[^\p{L}\p{N}]+/gu, "-").replace(/^-+|-+$/g, "").slice(0, 60).toLowerCase() || "event"}.ics`;
|
|
26
|
+
}
|
|
27
|
+
function O(l) {
|
|
28
|
+
let O = w(), k = C(), A = S(), [j, M] = x(/* @__PURE__ */ new Map()), [N, ae] = x(/* @__PURE__ */ new Set()), [P, F] = x(/* @__PURE__ */ new Map()), [I] = x(() => new _()), L = b({
|
|
29
|
+
times: /* @__PURE__ */ new Set(),
|
|
30
|
+
answers: /* @__PURE__ */ new Set()
|
|
31
|
+
}), R = b(l);
|
|
32
|
+
re(() => {
|
|
33
|
+
R.current = l;
|
|
34
|
+
});
|
|
35
|
+
let z = v((e, t) => {
|
|
36
|
+
M((n) => {
|
|
37
|
+
let r = new Map(n);
|
|
38
|
+
return t ? r.set(e, t) : r.delete(e), r;
|
|
39
|
+
});
|
|
40
|
+
}, []), B = v((e, t) => {
|
|
41
|
+
ae((n) => {
|
|
42
|
+
let r = new Set(n);
|
|
43
|
+
return t ? r.add(e) : r.delete(e), r;
|
|
44
|
+
});
|
|
45
|
+
}, []), V = v((e, t) => {
|
|
46
|
+
F((n) => {
|
|
47
|
+
let r = new Map(n);
|
|
48
|
+
return t ? r.set(e, t) : r.delete(e), r;
|
|
49
|
+
});
|
|
50
|
+
}, []), H = v(async (e, t) => {
|
|
51
|
+
await O.mutate({
|
|
52
|
+
mutation: c,
|
|
53
|
+
variables: {
|
|
54
|
+
id: e,
|
|
55
|
+
input: {
|
|
56
|
+
startTime: t.start.toISOString(),
|
|
57
|
+
endTime: t.end.toISOString()
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}, [O]), U = v(async (e, t, r) => {
|
|
62
|
+
await O.mutate({
|
|
63
|
+
mutation: n,
|
|
64
|
+
variables: {
|
|
65
|
+
id: e,
|
|
66
|
+
holdSeconds: t,
|
|
67
|
+
scope: r ?? null
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}, [O]), W = v((e, t) => {
|
|
71
|
+
let { tr: n } = R.current, r = ne(t), i = r === "FORBIDDEN" || r === "UNAUTHORIZED" ? n("calendar.v2.actionForbidden", "You don’t have permission to change this event.") : r === "NOT_FOUND" ? n("calendar.v2.actionGone", "It may have been deleted or moved by someone else.") : n("calendar.v2.actionRetry", "Nothing was changed. Try again in a moment.");
|
|
72
|
+
k({
|
|
73
|
+
title: e,
|
|
74
|
+
description: i,
|
|
75
|
+
tone: "error"
|
|
76
|
+
});
|
|
77
|
+
}, [k]), G = v(async (e, t, n) => {
|
|
78
|
+
let r = R.current, i = {
|
|
79
|
+
start: e.start,
|
|
80
|
+
end: e.end
|
|
81
|
+
}, a = `times:${e.id}`, o = I.claim(a), s = L.current.times;
|
|
82
|
+
s.delete(e.id), z(e.id, t);
|
|
83
|
+
try {
|
|
84
|
+
await I.run(a, () => H(e.id, t));
|
|
85
|
+
} catch (t) {
|
|
86
|
+
if (!I.isNewest(a, o)) return;
|
|
87
|
+
z(e.id, null), W(n === "move" ? r.tr("calendar.v2.moveFailed", "Couldn’t move “{{title}}”", { title: e.title }) : r.tr("calendar.v2.resizeFailed", "Couldn’t change “{{title}}”", { title: e.title }), t);
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
if (I.isNewest(a, o) && s.add(e.id), g(), !I.isNewest(a, o)) return;
|
|
91
|
+
let c = Math.round((t.end.getTime() - t.start.getTime()) / 6e4), l = n === "move" ? r.tr("calendar.v2.moved", "Moved “{{title}}” to {{day}}, {{time}}.", {
|
|
92
|
+
title: e.title,
|
|
93
|
+
day: T(t.start, r),
|
|
94
|
+
time: f(t.start, t.end, r.timeZone, r.format)
|
|
95
|
+
}) : r.tr("calendar.v2.resized", "“{{title}}” now ends at {{time}} ({{length}}).", {
|
|
96
|
+
title: e.title,
|
|
97
|
+
time: ee(t.end, r.timeZone, r.format),
|
|
98
|
+
length: d(c, r.durationWords)
|
|
99
|
+
});
|
|
100
|
+
k({
|
|
101
|
+
title: l,
|
|
102
|
+
tone: "success",
|
|
103
|
+
undoneTitle: r.tr("calendar.v2.movedBack", "Put back."),
|
|
104
|
+
undoFailedTitle: r.tr("calendar.v2.moveBackFailed", "Couldn’t put it back."),
|
|
105
|
+
undo: async () => {
|
|
106
|
+
let t = I.claim(a);
|
|
107
|
+
s.delete(e.id), z(e.id, i);
|
|
108
|
+
try {
|
|
109
|
+
await I.run(a, () => H(e.id, i));
|
|
110
|
+
} catch (n) {
|
|
111
|
+
throw I.isNewest(a, t) && z(e.id, null), n;
|
|
112
|
+
}
|
|
113
|
+
I.isNewest(a, t) && s.add(e.id), g();
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
}, [
|
|
117
|
+
W,
|
|
118
|
+
k,
|
|
119
|
+
z,
|
|
120
|
+
H,
|
|
121
|
+
I
|
|
122
|
+
]), K = v(async (e) => {
|
|
123
|
+
let t = R.current;
|
|
124
|
+
if (e.isRecurring) {
|
|
125
|
+
if (!await A({
|
|
126
|
+
title: t.tr("calendar.v2.deleteSeriesTitle", "Delete every event in “{{title}}”?", { title: e.title }),
|
|
127
|
+
description: t.tr("calendar.v2.deleteSeriesBody", "This is a repeating event. Every event in the series is deleted, and its guests are told. This can’t be undone."),
|
|
128
|
+
tone: "danger",
|
|
129
|
+
confirmLabel: t.tr("calendar.v2.deleteSeries", "Delete the series"),
|
|
130
|
+
cancelLabel: t.tr("calendar.v2.keep", "Keep it")
|
|
131
|
+
})) return;
|
|
132
|
+
B(e.id, !0);
|
|
133
|
+
try {
|
|
134
|
+
await U(e.id, 0, te);
|
|
135
|
+
} catch (n) {
|
|
136
|
+
B(e.id, !1), W(t.tr("calendar.v2.deleteFailed", "Couldn’t delete “{{title}}”", { title: e.title }), n);
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
g(), k({
|
|
140
|
+
title: t.tr("calendar.v2.deletedSeries", "Deleted every event in “{{title}}”.", { title: e.title }),
|
|
141
|
+
tone: "success"
|
|
142
|
+
});
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
B(e.id, !0);
|
|
146
|
+
try {
|
|
147
|
+
await U(e.id, 8);
|
|
148
|
+
} catch (n) {
|
|
149
|
+
B(e.id, !1), W(t.tr("calendar.v2.deleteFailed", "Couldn’t delete “{{title}}”", { title: e.title }), n);
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
g();
|
|
153
|
+
let n = ie(e, t.me);
|
|
154
|
+
k({
|
|
155
|
+
title: t.tr("calendar.v2.deleted", "Deleted “{{title}}”.", { title: e.title }),
|
|
156
|
+
description: n === 0 ? void 0 : n === 1 ? t.tr("calendar.v2.deletedTellOne", "Its guest hears it’s cancelled when this closes.") : t.tr("calendar.v2.deletedTellMany", "{{count}} guests hear it’s cancelled when this closes.", { count: n }),
|
|
157
|
+
tone: "success",
|
|
158
|
+
duration: 8e3,
|
|
159
|
+
undoneTitle: t.tr("calendar.v2.restored", "Restored. Nobody was told."),
|
|
160
|
+
undoFailedTitle: t.tr("calendar.v2.restoreFailed", "Too late to undo: it’s deleted."),
|
|
161
|
+
undo: async () => {
|
|
162
|
+
await O.mutate({
|
|
163
|
+
mutation: o,
|
|
164
|
+
variables: { id: e.id }
|
|
165
|
+
}), B(e.id, !1), g();
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
}, [
|
|
169
|
+
O,
|
|
170
|
+
A,
|
|
171
|
+
U,
|
|
172
|
+
W,
|
|
173
|
+
k,
|
|
174
|
+
B
|
|
175
|
+
]), q = v(async (e, t) => {
|
|
176
|
+
let n = R.current, r = P.get(e.id) ?? e.myResponse ?? "NO_RESPONSE";
|
|
177
|
+
if (r === t) return;
|
|
178
|
+
let i = `answer:${e.id}`, o = (t) => I.run(i, async () => {
|
|
179
|
+
await O.mutate({
|
|
180
|
+
mutation: a,
|
|
181
|
+
variables: {
|
|
182
|
+
eventId: e.id,
|
|
183
|
+
status: h[t]
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
}), s = I.claim(i), c = L.current.answers;
|
|
187
|
+
c.delete(e.id), V(e.id, t);
|
|
188
|
+
try {
|
|
189
|
+
await o(t);
|
|
190
|
+
} catch (t) {
|
|
191
|
+
if (!I.isNewest(i, s)) return;
|
|
192
|
+
V(e.id, null), W(n.tr("calendar.v2.answerFailed", "Couldn’t send your answer to “{{title}}”", { title: e.title }), t);
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
if (I.isNewest(i, s) && c.add(e.id), g(), !I.isNewest(i, s)) return;
|
|
196
|
+
let l = t === "ACCEPTED" ? n.tr("calendar.v2.answeredYes", "You’re going to “{{title}}”. The organiser is told.", { title: e.title }) : t === "TENTATIVE" ? n.tr("calendar.v2.answeredMaybe", "You’re a maybe for “{{title}}”.", { title: e.title }) : n.tr("calendar.v2.answeredNo", "You declined “{{title}}”.", { title: e.title });
|
|
197
|
+
k({
|
|
198
|
+
title: l,
|
|
199
|
+
description: t === "DECLINED" && !n.showDeclined ? n.tr("calendar.v2.declinedHidden", "It’s hidden now. “Show events I declined” is in Calendar settings.") : void 0,
|
|
200
|
+
tone: "success",
|
|
201
|
+
undoneTitle: n.tr("calendar.v2.answerUndone", "Your answer is back as it was."),
|
|
202
|
+
undo: async () => {
|
|
203
|
+
let t = I.claim(i);
|
|
204
|
+
c.delete(e.id), V(e.id, r);
|
|
205
|
+
try {
|
|
206
|
+
await o(r);
|
|
207
|
+
} catch (n) {
|
|
208
|
+
throw I.isNewest(i, t) && V(e.id, null), n;
|
|
209
|
+
}
|
|
210
|
+
I.isNewest(i, t) && c.add(e.id), g();
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
}, [
|
|
214
|
+
P,
|
|
215
|
+
O,
|
|
216
|
+
W,
|
|
217
|
+
k,
|
|
218
|
+
V,
|
|
219
|
+
I
|
|
220
|
+
]), J = v(async (e) => {
|
|
221
|
+
let t = R.current, n = null;
|
|
222
|
+
try {
|
|
223
|
+
n = (await O.mutate({
|
|
224
|
+
mutation: r,
|
|
225
|
+
variables: {
|
|
226
|
+
eventId: e.id,
|
|
227
|
+
newStartTime: e.start.toISOString()
|
|
228
|
+
}
|
|
229
|
+
})).data?.duplicateEvent.id ?? null;
|
|
230
|
+
} catch (n) {
|
|
231
|
+
W(t.tr("calendar.v2.duplicateFailed", "Couldn’t copy “{{title}}”", { title: e.title }), n);
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
g(), k({
|
|
235
|
+
title: t.tr("calendar.v2.duplicated", "Made a copy of “{{title}}” at the same time.", { title: e.title }),
|
|
236
|
+
description: t.tr("calendar.v2.duplicatedHint", "Drag it where you want it, or open it to change it."),
|
|
237
|
+
tone: "success",
|
|
238
|
+
undoneTitle: t.tr("calendar.v2.copyRemoved", "The copy is gone."),
|
|
239
|
+
undo: n ? async () => {
|
|
240
|
+
n && (await U(n, 0), g());
|
|
241
|
+
} : void 0
|
|
242
|
+
});
|
|
243
|
+
}, [
|
|
244
|
+
O,
|
|
245
|
+
U,
|
|
246
|
+
W,
|
|
247
|
+
k
|
|
248
|
+
]), Y = v(async (n) => {
|
|
249
|
+
let r = R.current, i = null;
|
|
250
|
+
try {
|
|
251
|
+
i = (await O.mutate({
|
|
252
|
+
mutation: e,
|
|
253
|
+
variables: { input: {
|
|
254
|
+
calendarId: n.calendarId,
|
|
255
|
+
title: n.title,
|
|
256
|
+
startTime: n.start.toISOString(),
|
|
257
|
+
endTime: n.end.toISOString(),
|
|
258
|
+
allDay: n.allDay,
|
|
259
|
+
eventType: "MEETING",
|
|
260
|
+
timezone: r.timeZone
|
|
261
|
+
} }
|
|
262
|
+
})).data?.createEvent.id ?? null;
|
|
263
|
+
} catch (e) {
|
|
264
|
+
return W(r.tr("calendar.v2.createFailed", "Couldn’t add “{{title}}”", { title: n.title }), e), !1;
|
|
265
|
+
}
|
|
266
|
+
let a = !1;
|
|
267
|
+
if (i && r.defaultReminder !== null) try {
|
|
268
|
+
await O.mutate({
|
|
269
|
+
mutation: t,
|
|
270
|
+
variables: { input: {
|
|
271
|
+
eventId: i,
|
|
272
|
+
minutesBefore: r.defaultReminder,
|
|
273
|
+
channel: m
|
|
274
|
+
} }
|
|
275
|
+
});
|
|
276
|
+
} catch {
|
|
277
|
+
a = !0;
|
|
278
|
+
}
|
|
279
|
+
g();
|
|
280
|
+
let o = p(n.start, r.timeZone).date;
|
|
281
|
+
return k({
|
|
282
|
+
title: r.tr("calendar.v2.created", "Added “{{title}}”, {{day}} {{time}}.", {
|
|
283
|
+
title: n.title,
|
|
284
|
+
day: u(o, r.format, "short"),
|
|
285
|
+
time: n.allDay ? r.tr("calendar.v2.allDayLower", "all day") : f(n.start, n.end, r.timeZone, r.format)
|
|
286
|
+
}),
|
|
287
|
+
description: a ? r.tr("calendar.v2.reminderMissed", "Its reminder wasn’t added. Open the event to add one.") : void 0,
|
|
288
|
+
tone: a ? "warning" : "success",
|
|
289
|
+
undoneTitle: r.tr("calendar.v2.createUndone", "Removed."),
|
|
290
|
+
undo: i ? async () => {
|
|
291
|
+
i && (await U(i, 0), g());
|
|
292
|
+
} : void 0
|
|
293
|
+
}), !0;
|
|
294
|
+
}, [
|
|
295
|
+
O,
|
|
296
|
+
U,
|
|
297
|
+
W,
|
|
298
|
+
k
|
|
299
|
+
]), X = v(async (e) => {
|
|
300
|
+
let t = R.current;
|
|
301
|
+
try {
|
|
302
|
+
let t = (await O.query({
|
|
303
|
+
query: i,
|
|
304
|
+
variables: { eventId: e.id },
|
|
305
|
+
fetchPolicy: "network-only"
|
|
306
|
+
})).data?.exportEventToIcs;
|
|
307
|
+
if (!t || !E(t, D(e.title))) throw Error("No file");
|
|
308
|
+
} catch {
|
|
309
|
+
k({
|
|
310
|
+
title: t.tr("calendar.v2.icsFailed", "Couldn’t download “{{title}}”", { title: e.title }),
|
|
311
|
+
description: t.tr("calendar.v2.actionRetry", "Nothing was changed. Try again in a moment."),
|
|
312
|
+
tone: "error"
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
}, [O, k]), Z = v(async (e, t) => {
|
|
316
|
+
let n = R.current;
|
|
317
|
+
try {
|
|
318
|
+
await navigator.clipboard.writeText(e), k({
|
|
319
|
+
title: t,
|
|
320
|
+
tone: "success"
|
|
321
|
+
});
|
|
322
|
+
} catch {
|
|
323
|
+
k({
|
|
324
|
+
title: n.tr("calendar.v2.copyFailed", "Couldn’t copy. Select the text and copy it instead."),
|
|
325
|
+
tone: "error"
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
}, [k]), Q = v(async (e) => {
|
|
329
|
+
let t = R.current;
|
|
330
|
+
if (e.sync) {
|
|
331
|
+
try {
|
|
332
|
+
await O.mutate({
|
|
333
|
+
mutation: s,
|
|
334
|
+
variables: { syncId: e.sync.id }
|
|
335
|
+
});
|
|
336
|
+
} catch (n) {
|
|
337
|
+
W(t.tr("calendar.v2.checkFailed", "Couldn’t check “{{name}}” now", { name: e.name }), n);
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
t.reloadCalendars(), g(), k({
|
|
341
|
+
title: t.tr("calendar.v2.checked", "Checked “{{name}}” for changes.", { name: e.name }),
|
|
342
|
+
tone: "success"
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
}, [
|
|
346
|
+
O,
|
|
347
|
+
W,
|
|
348
|
+
k
|
|
349
|
+
]), $ = v((e) => {
|
|
350
|
+
let t = new Map(e.map((e) => [e.id, e])), n = new Set(L.current.times), r = new Set(L.current.answers);
|
|
351
|
+
L.current.times.clear(), L.current.answers.clear(), M((e) => {
|
|
352
|
+
if (e.size === 0) return e;
|
|
353
|
+
let r = !1, i = new Map(e);
|
|
354
|
+
for (let [a, o] of e) {
|
|
355
|
+
let e = t.get(a);
|
|
356
|
+
(n.has(a) || e && e.start.getTime() === o.start.getTime() && e.end.getTime() === o.end.getTime()) && (i.delete(a), r = !0);
|
|
357
|
+
}
|
|
358
|
+
return r ? i : e;
|
|
359
|
+
}), F((e) => {
|
|
360
|
+
if (e.size === 0) return e;
|
|
361
|
+
let n = !1, i = new Map(e);
|
|
362
|
+
for (let [a, o] of e) (r.has(a) || t.get(a)?.myResponse === o) && (i.delete(a), n = !0);
|
|
363
|
+
return n ? i : e;
|
|
364
|
+
});
|
|
365
|
+
}, []);
|
|
366
|
+
return y(() => ({
|
|
367
|
+
overrides: j,
|
|
368
|
+
removedIds: N,
|
|
369
|
+
answers: P,
|
|
370
|
+
changeTimes: G,
|
|
371
|
+
remove: K,
|
|
372
|
+
respond: q,
|
|
373
|
+
duplicate: J,
|
|
374
|
+
quickCreate: Y,
|
|
375
|
+
downloadIcs: X,
|
|
376
|
+
copyText: Z,
|
|
377
|
+
checkSyncNow: Q,
|
|
378
|
+
settle: $
|
|
379
|
+
}), [
|
|
380
|
+
P,
|
|
381
|
+
G,
|
|
382
|
+
Q,
|
|
383
|
+
Z,
|
|
384
|
+
X,
|
|
385
|
+
J,
|
|
386
|
+
j,
|
|
387
|
+
Y,
|
|
388
|
+
K,
|
|
389
|
+
N,
|
|
390
|
+
q,
|
|
391
|
+
$
|
|
392
|
+
]);
|
|
393
|
+
}
|
|
394
|
+
function k(e, t, n) {
|
|
395
|
+
return l(e, n) === "organizer" ? null : t.get(e.id) ?? e.myResponse;
|
|
396
|
+
}
|
|
397
|
+
export { k as answerFor, D as icsFileName, O as useEventActions };
|
|
398
|
+
|
|
399
|
+
//# sourceMappingURL=useEventActions.js.map
|