@marktiderman/genesis-cli 1.7.0 → 1.9.0
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/README.md +26 -4
- package/dist/cli.js +933 -319
- package/dist/cli.js.map +1 -1
- package/dist/{config-CrZbM3jD.d.ts → config-QC_Ewwwp.d.ts} +27 -3
- package/dist/doctor.d.ts +68 -4
- package/dist/doctor.js +654 -87
- package/dist/doctor.js.map +1 -1
- package/dist/expo.d.ts +2 -2
- package/dist/expo.js.map +1 -1
- package/dist/genesis-catalog.json +164 -14
- package/dist/index.d.ts +1 -1
- package/dist/index.js +666 -101
- package/dist/index.js.map +1 -1
- package/dist/starter/.env.example +3 -0
- package/dist/starter/README.md +7 -0
- package/dist/starter/__tests__/app-config.test.ts +27 -0
- package/dist/starter/__tests__/chat-outboxes.test.ts +64 -0
- package/dist/starter/__tests__/check-in-photos.test.ts +5 -3
- package/dist/starter/__tests__/components/fake-supabase.ts +8 -0
- package/dist/starter/__tests__/components/messages.test.tsx +33 -0
- package/dist/starter/__tests__/components/settings.test.tsx +34 -0
- package/dist/starter/__tests__/components/setup.ts +13 -0
- package/dist/starter/__tests__/components/tabs-feature-off.test.tsx +1 -1
- package/dist/starter/__tests__/components/tabs.test.tsx +2 -2
- package/dist/starter/__tests__/inline-copy.ts +1 -1
- package/dist/starter/__tests__/starter.test.ts +117 -3
- package/dist/starter/app.config.ts +19 -2
- package/dist/starter/genesis.config.json +2 -2
- package/dist/starter/jest.config.js +2 -1
- package/dist/starter/metro.config.js +1 -1
- package/dist/starter/package.json +9 -0
- package/dist/starter/src/app/(app)/(home)/check-in.tsx +4 -38
- package/dist/starter/src/app/(app)/_layout.tsx +25 -3
- package/dist/starter/src/app/(app)/messages/[id].tsx +63 -0
- package/dist/starter/src/app/(app)/messages/_layout.tsx +11 -0
- package/dist/starter/src/app/(app)/messages/check-in.tsx +9 -0
- package/dist/starter/src/app/(app)/messages/index.tsx +38 -0
- package/dist/starter/src/app/(app)/messages/search.tsx +39 -0
- package/dist/starter/src/app/(app)/notifications/index.tsx +7 -13
- package/dist/starter/src/app/(app)/settings/availability.tsx +16 -0
- package/dist/starter/src/app/(app)/settings/index.tsx +8 -3
- package/dist/starter/src/app/(app)/settings/notifications.tsx +6 -3
- package/dist/starter/src/copy.ts +19 -0
- package/dist/starter/src/lib/chat-outboxes.ts +50 -0
- package/dist/starter/src/lib/chat-video.ts +57 -0
- package/dist/starter/src/lib/chat.tsx +319 -0
- package/dist/starter/src/lib/check-in-screen.tsx +43 -0
- package/dist/starter/src/lib/define-starter.ts +9 -0
- package/dist/starter/src/lib/env.ts +4 -0
- package/dist/starter/src/lib/links.ts +2 -0
- package/dist/starter/src/lib/notifications.ts +30 -12
- package/dist/starter/src/lib/push.ts +21 -5
- package/dist/starter/starter.config.ts +1 -0
- package/dist/starter/supabase/config.toml +5 -0
- package/dist/starter/supabase/migrations/20261025000000_genesis_chat.sql +1836 -0
- package/dist/starter/supabase/migrations/20261025000050_genesis_chat_coaching.sql +934 -0
- package/dist/starter/supabase/migrations/20261025000060_genesis_chat_search_threads.sql +85 -0
- package/dist/starter/supabase/migrations/20261025000100_genesis_notifications.sql +2057 -0
- package/dist/starter/supabase/migrations/20261026000000_chat_people.sql +57 -0
- package/dist/starter/supabase/tests/database/chat_people.test.sql +112 -0
- package/dist/starter/supabase/tests/database/genesis_chat.test.sql +254 -0
- package/dist/starter/supabase/tests/database/genesis_chat_coaching.test.sql +269 -0
- package/dist/starter/supabase/tests/database/genesis_chat_search_threads.test.sql +50 -0
- package/dist/starter/supabase/tests/database/genesis_notifications.test.sql +473 -0
- package/dist/vite.js +651 -86
- package/dist/vite.js.map +1 -1
- package/package.json +3 -3
- package/dist/starter/supabase/tests/database/genesis_push.test.sql +0 -407
|
@@ -1,14 +1,24 @@
|
|
|
1
1
|
import { Redirect } from "expo-router";
|
|
2
2
|
import { NativeTabs } from "expo-router/native-tabs";
|
|
3
3
|
import { useSession } from "@marktiderman/genesis-native";
|
|
4
|
+
import { NotificationsProvider } from "@marktiderman/genesis-notifications/react";
|
|
4
5
|
import starter from "../../../starter.config";
|
|
5
6
|
import { copy } from "@/copy";
|
|
7
|
+
import { ChatRoot, useClearChatOnSignOut } from "@/lib/chat";
|
|
8
|
+
import { notifications } from "@/lib/notifications";
|
|
9
|
+
import { supabase } from "@/lib/supabase";
|
|
6
10
|
|
|
7
|
-
/**
|
|
11
|
+
/**
|
|
12
|
+
* Signed-in screens: the platform's own tab bar. A tab whose feature is off is hidden. The
|
|
13
|
+
* notifier (feed, unread count, preferences) is provided to every tab, and refetches on the
|
|
14
|
+
* person's private realtime channel. Chat (`features.chat`) is provided to every tab too, so
|
|
15
|
+
* Settings → Availability and the Messages tab share one chat (one outbox).
|
|
16
|
+
*/
|
|
8
17
|
export default function AppLayout() {
|
|
9
|
-
const { status } = useSession();
|
|
18
|
+
const { status, userId } = useSession();
|
|
19
|
+
useClearChatOnSignOut();
|
|
10
20
|
if (status === "signedOut") return <Redirect href="/sign-in" />;
|
|
11
|
-
|
|
21
|
+
const tabs = (
|
|
12
22
|
<NativeTabs>
|
|
13
23
|
<NativeTabs.Trigger name="(home)">
|
|
14
24
|
<NativeTabs.Trigger.Label>{copy.tabs.home}</NativeTabs.Trigger.Label>
|
|
@@ -18,10 +28,22 @@ export default function AppLayout() {
|
|
|
18
28
|
<NativeTabs.Trigger.Label>{copy.tabs.notifications}</NativeTabs.Trigger.Label>
|
|
19
29
|
<NativeTabs.Trigger.Icon sf={{ default: "bell", selected: "bell.fill" }} md="notifications" />
|
|
20
30
|
</NativeTabs.Trigger>
|
|
31
|
+
<NativeTabs.Trigger name="messages" hidden={!starter.features.chat}>
|
|
32
|
+
<NativeTabs.Trigger.Label>{copy.tabs.messages}</NativeTabs.Trigger.Label>
|
|
33
|
+
<NativeTabs.Trigger.Icon sf={{ default: "bubble.left.and.bubble.right", selected: "bubble.left.and.bubble.right.fill" }} md="chat" />
|
|
34
|
+
</NativeTabs.Trigger>
|
|
21
35
|
<NativeTabs.Trigger name="settings">
|
|
22
36
|
<NativeTabs.Trigger.Label>{copy.tabs.settings}</NativeTabs.Trigger.Label>
|
|
23
37
|
<NativeTabs.Trigger.Icon sf={{ default: "gearshape", selected: "gearshape.fill" }} md="settings" />
|
|
24
38
|
</NativeTabs.Trigger>
|
|
25
39
|
</NativeTabs>
|
|
26
40
|
);
|
|
41
|
+
const app = starter.features.notifications ? (
|
|
42
|
+
<NotificationsProvider client={supabase} registry={notifications} userId={status === "signedIn" ? userId : null}>
|
|
43
|
+
{tabs}
|
|
44
|
+
</NotificationsProvider>
|
|
45
|
+
) : (
|
|
46
|
+
tabs
|
|
47
|
+
);
|
|
48
|
+
return starter.features.chat ? <ChatRoot>{app}</ChatRoot> : app;
|
|
27
49
|
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
import { Redirect, Stack, router, useIsFocused, useLocalSearchParams, type Href } from "expo-router";
|
|
3
|
+
import { useQuery } from "@tanstack/react-query";
|
|
4
|
+
import { ChatIconButton, ChatThreadScreen, chatThreadMatch, useChatThreadStackOptions } from "@marktiderman/genesis-chat/native";
|
|
5
|
+
import { chatKeys, useChat, usePeople } from "@marktiderman/genesis-chat/react";
|
|
6
|
+
import { useSuppressNotifications } from "@marktiderman/genesis-native/push";
|
|
7
|
+
import starter from "../../../../starter.config";
|
|
8
|
+
import { copy } from "@/copy";
|
|
9
|
+
import { chatClient, kindAllowsTopics } from "@/lib/chat";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* One conversation (`features.chat`; ChatThreadScreen). Its own pushes stay quiet while it is open.
|
|
13
|
+
* `?message=<id>&seq=<n>` (a search result) opens it at that message; the header searches it.
|
|
14
|
+
*/
|
|
15
|
+
export default function MessagesThreadScreen() {
|
|
16
|
+
const { id, message, seq } = useLocalSearchParams<{ id: string; message?: string; seq?: string }>();
|
|
17
|
+
if (!starter.features.chat) return <Redirect href="/" />;
|
|
18
|
+
if (!id) return <Redirect href="/messages" />;
|
|
19
|
+
return <Thread id={id} message={message} seq={seq} />;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function Thread({ id, message, seq }: { id: string; message?: string; seq?: string }) {
|
|
23
|
+
// The same query the thread reads (one fetch), for the header's title.
|
|
24
|
+
const { data: conversation } = useQuery({ queryKey: chatKeys.conversation(id), queryFn: () => chatClient.conversation(id) });
|
|
25
|
+
// An untitled two-person conversation is called by the other person's name (chat_people).
|
|
26
|
+
const { userId } = useChat();
|
|
27
|
+
const { data: members } = useQuery({ queryKey: chatKeys.members(id), queryFn: () => chatClient.members(id) });
|
|
28
|
+
const other = members && members.length === 2 ? (members.find((m) => m.userId !== userId)?.userId ?? null) : null;
|
|
29
|
+
const people = usePeople([other]);
|
|
30
|
+
const otherName = other ? people[other]?.name : undefined;
|
|
31
|
+
useSuppressNotifications(chatThreadMatch(id));
|
|
32
|
+
const options = useChatThreadStackOptions({
|
|
33
|
+
headerTitle: conversation?.title ?? otherName ?? copy.messages.threadTitle,
|
|
34
|
+
headerRight: () => (
|
|
35
|
+
<ChatIconButton
|
|
36
|
+
testID="thread-search"
|
|
37
|
+
icon="search"
|
|
38
|
+
label={copy.messages.searchThread}
|
|
39
|
+
onPress={() => router.push({ pathname: "/messages/search", params: { conversationId: id } } as unknown as Href)}
|
|
40
|
+
/>
|
|
41
|
+
),
|
|
42
|
+
});
|
|
43
|
+
// The kind's rules (the query the thread reads): a group can start its first topic, a direct one has none.
|
|
44
|
+
const { data: rules } = useQuery({
|
|
45
|
+
queryKey: ["genesis-chat", "kind", conversation?.kind ?? ""],
|
|
46
|
+
queryFn: () => chatClient.kind(conversation!.kind),
|
|
47
|
+
enabled: Boolean(conversation?.kind),
|
|
48
|
+
staleTime: 10 * 60_000,
|
|
49
|
+
});
|
|
50
|
+
// Another tab or a screen pushed over it pauses what the thread is playing.
|
|
51
|
+
const focused = useIsFocused();
|
|
52
|
+
// A check-in card opens the check-in in this stack, so Back comes back here.
|
|
53
|
+
const openAttachment = (a: { kind: string }) => (a.kind === "check_in" && starter.features.checkIn ? router.push("/messages/check-in" as Href) : undefined);
|
|
54
|
+
const jumpTo = useMemo(() => (message ? { messageId: message, seq: seq ? Number(seq) : undefined } : null), [message, seq]);
|
|
55
|
+
return (
|
|
56
|
+
<>
|
|
57
|
+
<Stack.Screen options={options} />
|
|
58
|
+
{/* Keyed by the conversation: a push or link that opens another one in this screen starts it fresh
|
|
59
|
+
(its list position, sheets, viewer and composer), instead of carrying the last one's over. */}
|
|
60
|
+
<ChatThreadScreen key={id} conversationId={id} jumpTo={jumpTo} onOpenAttachment={openAttachment} showTopics={kindAllowsTopics(rules)} focused={focused} />
|
|
61
|
+
</>
|
|
62
|
+
);
|
|
63
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Redirect, Stack } from "expo-router";
|
|
2
|
+
import { useSession } from "@marktiderman/genesis-native";
|
|
3
|
+
import starter from "../../../../starter.config";
|
|
4
|
+
|
|
5
|
+
/** The Messages tab (`features.chat`): a stack, under the signed-in person's chat (`ChatRoot`, in the tabs' layout). */
|
|
6
|
+
export default function MessagesStack() {
|
|
7
|
+
const { userId } = useSession();
|
|
8
|
+
if (!starter.features.chat) return <Redirect href="/" />;
|
|
9
|
+
if (!userId) return null;
|
|
10
|
+
return <Stack />;
|
|
11
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CheckInScreen } from "@/lib/check-in-screen";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The check-in opened from a card in a conversation: in the Messages stack, so Back returns to
|
|
5
|
+
* the conversation (its back button reads the conversation's title).
|
|
6
|
+
*/
|
|
7
|
+
export default function MessagesCheckIn() {
|
|
8
|
+
return <CheckInScreen />;
|
|
9
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
import { View } from "react-native";
|
|
3
|
+
import { Redirect, Stack, router, type Href } from "expo-router";
|
|
4
|
+
import { ChatBroadcastSheet, ChatIconButton, ChatInboxScreen, chatPath } from "@marktiderman/genesis-chat/native";
|
|
5
|
+
import { getInboxPageStackOptions } from "@marktiderman/genesis-ui-native";
|
|
6
|
+
import starter from "../../../../starter.config";
|
|
7
|
+
import { copy } from "@/copy";
|
|
8
|
+
|
|
9
|
+
/** Broadcasts go into direct conversations, one per person. */
|
|
10
|
+
const BROADCAST_KIND = "direct";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Your conversations, newest first, with unread counts (`features.chat`; ChatInboxScreen is
|
|
14
|
+
* genesis-ui-native's InboxPage). The header searches every conversation and broadcasts one
|
|
15
|
+
* message into many direct conversations (each reply comes back privately). Every signed-in
|
|
16
|
+
* person may broadcast here; an app with roles shows the button only to the people it lets.
|
|
17
|
+
*/
|
|
18
|
+
export default function MessagesInboxScreen() {
|
|
19
|
+
const [broadcasting, setBroadcasting] = useState(false);
|
|
20
|
+
if (!starter.features.chat) return <Redirect href="/" />;
|
|
21
|
+
return (
|
|
22
|
+
<>
|
|
23
|
+
<Stack.Screen
|
|
24
|
+
options={getInboxPageStackOptions({
|
|
25
|
+
headerTitle: copy.chat.inboxTitle,
|
|
26
|
+
headerRight: () => (
|
|
27
|
+
<View style={{ flexDirection: "row" }}>
|
|
28
|
+
<ChatIconButton testID="messages-search" icon="search" label={copy.messages.search} onPress={() => router.push("/messages/search" as Href)} />
|
|
29
|
+
<ChatIconButton testID="messages-broadcast" icon="share" label={copy.messages.broadcast} onPress={() => setBroadcasting(true)} />
|
|
30
|
+
</View>
|
|
31
|
+
),
|
|
32
|
+
})}
|
|
33
|
+
/>
|
|
34
|
+
<ChatInboxScreen onOpen={(id) => router.push(chatPath(id) as Href)} />
|
|
35
|
+
<ChatBroadcastSheet open={broadcasting} onOpenChange={setBroadcasting} kind={BROADCAST_KIND} />
|
|
36
|
+
</>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Redirect, Stack, router, useLocalSearchParams, type Href } from "expo-router";
|
|
2
|
+
import { ChatSearchScreen } from "@marktiderman/genesis-chat/native";
|
|
3
|
+
import { getSettingsPageStackOptions } from "@marktiderman/genesis-ui-native";
|
|
4
|
+
import { useThemeRoles } from "@marktiderman/genesis-ui-native/hooks";
|
|
5
|
+
import starter from "../../../../starter.config";
|
|
6
|
+
import { copy } from "@/copy";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Search (`features.chat`): every conversation from the inbox, or one (`?conversationId=`) from
|
|
10
|
+
* its thread. A result opens its thread at the message: from a thread, back to that thread.
|
|
11
|
+
*
|
|
12
|
+
* The bar is opaque, in the screen's background, like the thread's (`useChatThreadStackOptions`):
|
|
13
|
+
* the search field sits in a plain view, not a scroll view iOS insets, so under the see-through
|
|
14
|
+
* bar iOS 26 draws it would sit behind the bar and the status bar.
|
|
15
|
+
*/
|
|
16
|
+
export default function MessagesSearchScreen() {
|
|
17
|
+
const { conversationId } = useLocalSearchParams<{ conversationId?: string }>();
|
|
18
|
+
const colors = useThemeRoles();
|
|
19
|
+
if (!starter.features.chat) return <Redirect href="/" />;
|
|
20
|
+
return (
|
|
21
|
+
<>
|
|
22
|
+
<Stack.Screen
|
|
23
|
+
options={getSettingsPageStackOptions({
|
|
24
|
+
headerTitle: copy.messages.searchTitle,
|
|
25
|
+
large: false,
|
|
26
|
+
headerOptions: { headerTransparent: false, headerStyle: { backgroundColor: colors.groupedBackground } },
|
|
27
|
+
})}
|
|
28
|
+
/>
|
|
29
|
+
<ChatSearchScreen
|
|
30
|
+
conversationId={conversationId ?? null}
|
|
31
|
+
onOpen={(hit) => {
|
|
32
|
+
const href = { pathname: "/messages/[id]", params: { id: hit.conversationId, message: hit.messageId, seq: String(hit.seq) } } as unknown as Href;
|
|
33
|
+
if (conversationId) router.dismissTo(href);
|
|
34
|
+
else router.push(href);
|
|
35
|
+
}}
|
|
36
|
+
/>
|
|
37
|
+
</>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { useCallback } from "react";
|
|
2
|
-
import { Redirect, Stack, useFocusEffect } from "expo-router";
|
|
2
|
+
import { Redirect, Stack, router, useFocusEffect, type Href } from "expo-router";
|
|
3
3
|
import { useOptionalPush } from "@marktiderman/genesis-native/push";
|
|
4
|
-
import {
|
|
4
|
+
import { NotificationsFeed, useNotificationsFeedHeader } from "@marktiderman/genesis-notifications/native";
|
|
5
5
|
import starter from "../../../../starter.config";
|
|
6
6
|
import { copy } from "@/copy";
|
|
7
|
-
import { useNotifications } from "@/lib/notifications";
|
|
8
7
|
|
|
9
|
-
/** The Notifications tab (`features.notifications`). */
|
|
8
|
+
/** The Notifications tab (`features.notifications`): the person's feed, from genesis-notifications. */
|
|
10
9
|
export default function NotificationsScreen() {
|
|
11
|
-
const
|
|
10
|
+
const header = useNotificationsFeedHeader({ headerTitle: copy.notifications.title });
|
|
12
11
|
// Coming to this tab is the moment push is worth asking for: the soft prompt (never at launch;
|
|
13
12
|
// the block ignores an offer in its first seconds and after a recent Not now), each time it's shown.
|
|
14
13
|
const push = useOptionalPush();
|
|
@@ -20,14 +19,9 @@ export default function NotificationsScreen() {
|
|
|
20
19
|
if (!starter.features.notifications) return <Redirect href="/" />;
|
|
21
20
|
return (
|
|
22
21
|
<>
|
|
23
|
-
<Stack.Screen options={
|
|
24
|
-
<
|
|
25
|
-
|
|
26
|
-
items={data}
|
|
27
|
-
refreshing={isRefetching}
|
|
28
|
-
onRefresh={async () => {
|
|
29
|
-
await refetch();
|
|
30
|
-
}}
|
|
22
|
+
<Stack.Screen options={header} />
|
|
23
|
+
<NotificationsFeed
|
|
24
|
+
onOpen={(item) => (item.url ? router.push(item.url as Href) : undefined)}
|
|
31
25
|
emptyTitle={copy.notifications.emptyTitle}
|
|
32
26
|
emptyBody={copy.notifications.emptyBody}
|
|
33
27
|
/>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Redirect, Stack, router } from "expo-router";
|
|
2
|
+
import { ChatAvailabilityScreen } from "@marktiderman/genesis-chat/native";
|
|
3
|
+
import { getSettingsPageStackOptions } from "@marktiderman/genesis-ui-native";
|
|
4
|
+
import starter from "../../../../starter.config";
|
|
5
|
+
import { copy } from "@/copy";
|
|
6
|
+
|
|
7
|
+
/** Settings → Availability (`features.chat`): your away message, working hours and time zone, shown in your conversations. */
|
|
8
|
+
export default function AvailabilitySettingsScreen() {
|
|
9
|
+
if (!starter.features.chat) return <Redirect href="/settings" />;
|
|
10
|
+
return (
|
|
11
|
+
<>
|
|
12
|
+
<Stack.Screen options={getSettingsPageStackOptions({ headerTitle: copy.settings.availability, large: false })} />
|
|
13
|
+
<ChatAvailabilityScreen onSaved={() => router.back()} />
|
|
14
|
+
</>
|
|
15
|
+
);
|
|
16
|
+
}
|
|
@@ -4,7 +4,7 @@ import { Alert } from "react-native";
|
|
|
4
4
|
import type { Session } from "@supabase/supabase-js";
|
|
5
5
|
import { useBlockSettings, useSession } from "@marktiderman/genesis-native";
|
|
6
6
|
import { useBlockReload } from "@marktiderman/genesis-native/updates";
|
|
7
|
-
import { SettingsPage, getSettingsPageStackOptions, type SettingsPageDangerousAction } from "@marktiderman/genesis-ui-native";
|
|
7
|
+
import { SettingsPage, getSettingsPageStackOptions, type SettingsPageDangerousAction, type SettingsPageRow } from "@marktiderman/genesis-ui-native";
|
|
8
8
|
import starter from "../../../../starter.config";
|
|
9
9
|
import { copy } from "@/copy";
|
|
10
10
|
import { deleteAccount } from "@/lib/account";
|
|
@@ -23,10 +23,15 @@ export default function SettingsScreen() {
|
|
|
23
23
|
// An update never reloads the app while the deletion request runs.
|
|
24
24
|
useBlockReload(busy);
|
|
25
25
|
const version = useAppVersion();
|
|
26
|
-
const blockSettings = useBlockSettings(
|
|
26
|
+
const blockSettings = useBlockSettings<SettingsPageRow>(
|
|
27
27
|
[
|
|
28
28
|
{ id: "account", title: t.accountSection, rows: [{ id: "email", title: t.signedInAs, subtitle: session?.user.email ?? "" }] },
|
|
29
|
-
{
|
|
29
|
+
{
|
|
30
|
+
id: "general",
|
|
31
|
+
rows: starter.features.chat
|
|
32
|
+
? [{ id: "availability", title: t.availability, subtitle: t.availabilitySubtitle, showChevron: true, onPress: () => router.push("/settings/availability" as Href), testID: "open-availability" }]
|
|
33
|
+
: [],
|
|
34
|
+
},
|
|
30
35
|
// The support block's Send feedback and Help rows (`features.support`).
|
|
31
36
|
{ id: "support", title: copy.support.settings.section, rows: [] },
|
|
32
37
|
{
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import { Redirect, Stack } from "expo-router";
|
|
2
|
-
import {
|
|
2
|
+
import { NotificationPreferences } from "@marktiderman/genesis-notifications/native";
|
|
3
3
|
import { getSettingsPageStackOptions } from "@marktiderman/genesis-ui-native";
|
|
4
4
|
import starter from "../../../../starter.config";
|
|
5
5
|
import { copy } from "@/copy";
|
|
6
6
|
|
|
7
|
-
/**
|
|
7
|
+
/**
|
|
8
|
+
* Settings → Notifications (`features.push`): the push block's permission, quiet hours and previews,
|
|
9
|
+
* with genesis-notifications' switch per category and channel in place of its category switches.
|
|
10
|
+
*/
|
|
8
11
|
export default function NotificationSettingsScreen() {
|
|
9
12
|
if (!starter.features.push) return <Redirect href="/settings" />;
|
|
10
13
|
return (
|
|
11
14
|
<>
|
|
12
15
|
<Stack.Screen options={getSettingsPageStackOptions({ headerTitle: copy.push.settingsTitle, large: false })} />
|
|
13
|
-
<
|
|
16
|
+
<NotificationPreferences testID="notification-settings" />
|
|
14
17
|
</>
|
|
15
18
|
);
|
|
16
19
|
}
|
package/dist/starter/src/copy.ts
CHANGED
|
@@ -12,6 +12,7 @@ const en = {
|
|
|
12
12
|
tabs: {
|
|
13
13
|
home: "Home",
|
|
14
14
|
notifications: "Notifications",
|
|
15
|
+
messages: "Messages",
|
|
15
16
|
settings: "Settings",
|
|
16
17
|
},
|
|
17
18
|
signIn: {
|
|
@@ -77,6 +78,8 @@ const en = {
|
|
|
77
78
|
deletedTitle: "Account deleted",
|
|
78
79
|
deletedBody: "Your account and its data have been deleted.",
|
|
79
80
|
notifications: "Notifications",
|
|
81
|
+
availability: "Availability",
|
|
82
|
+
availabilitySubtitle: "Away message and working hours",
|
|
80
83
|
},
|
|
81
84
|
push: {
|
|
82
85
|
settingsTitle: "Notifications",
|
|
@@ -105,6 +108,22 @@ const en = {
|
|
|
105
108
|
ideas: { title: "Idea board" },
|
|
106
109
|
shipped: { title: "You asked, we shipped" },
|
|
107
110
|
},
|
|
111
|
+
// Chat's own strings (genesis-chat's `chatNativeCopy`); the ones here override its English.
|
|
112
|
+
chat: {
|
|
113
|
+
inboxTitle: "Messages",
|
|
114
|
+
},
|
|
115
|
+
messages: {
|
|
116
|
+
threadTitle: "Conversation",
|
|
117
|
+
searchTitle: "Search",
|
|
118
|
+
search: "Search messages",
|
|
119
|
+
searchThread: "Search this conversation",
|
|
120
|
+
broadcast: "Broadcast a message",
|
|
121
|
+
// A check-in sent in a conversation (an attachment of kind `check_in`), drawn as a card.
|
|
122
|
+
checkInCard: "Check-in",
|
|
123
|
+
checkInAnswer: "Answer",
|
|
124
|
+
// On the sender's own check-in card, in place of Answer.
|
|
125
|
+
checkInSent: "Sent",
|
|
126
|
+
},
|
|
108
127
|
} as const;
|
|
109
128
|
|
|
110
129
|
/** The shape every translation fills: the English catalog's keys, with any string as the value. */
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unsent chat messages on this phone, per person, and forgetting them: the
|
|
3
|
+
* saved copy under `genesis-chat:outbox:<userId>` and, while Messages has been
|
|
4
|
+
* opened, the live outbox (`useChat().clearOutbox()`). No React Native here,
|
|
5
|
+
* so the starter's vitest runs it; `chat.tsx` passes AsyncStorage.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export const OUTBOX_PREFIX = "genesis-chat:outbox:";
|
|
9
|
+
|
|
10
|
+
export const outboxKey = (userId: string) => `${OUTBOX_PREFIX}${userId}`;
|
|
11
|
+
|
|
12
|
+
/** The AsyncStorage calls this needs. */
|
|
13
|
+
export interface OutboxKeyStorage {
|
|
14
|
+
getAllKeys(): Promise<readonly string[]>;
|
|
15
|
+
removeItem(key: string): Promise<void>;
|
|
16
|
+
multiRemove(keys: readonly string[]): Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface ChatOutboxes {
|
|
20
|
+
/** The live outbox's `clearOutbox`, kept past the Messages screens' unmount (sign-out unmounts them first). */
|
|
21
|
+
register(userId: string, clearOutbox: () => Promise<void>): void;
|
|
22
|
+
/** Forgets one person's unsent messages: the live outbox if there is one, and the saved copy. */
|
|
23
|
+
clear(userId: string): Promise<void>;
|
|
24
|
+
/** Forgets everyone else's (on sign-in: a session that ended while the app was closed, or a switch). */
|
|
25
|
+
clearOthers(userId: string): Promise<void>;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function createChatOutboxes(storage: OutboxKeyStorage): ChatOutboxes {
|
|
29
|
+
const clearers = new Map<string, () => Promise<void>>();
|
|
30
|
+
const live = async (userId: string) => {
|
|
31
|
+
const clear = clearers.get(userId);
|
|
32
|
+
clearers.delete(userId);
|
|
33
|
+
// Emptied in memory too, so a send still in flight saves an empty queue, not the old one.
|
|
34
|
+
if (clear) await clear();
|
|
35
|
+
};
|
|
36
|
+
return {
|
|
37
|
+
register(userId, clearOutbox) {
|
|
38
|
+
clearers.set(userId, clearOutbox);
|
|
39
|
+
},
|
|
40
|
+
async clear(userId) {
|
|
41
|
+
await live(userId);
|
|
42
|
+
await storage.removeItem(outboxKey(userId));
|
|
43
|
+
},
|
|
44
|
+
async clearOthers(userId) {
|
|
45
|
+
for (const other of [...clearers.keys()]) if (other !== userId) await live(other);
|
|
46
|
+
const keys = (await storage.getAllKeys()).filter((k) => k.startsWith(OUTBOX_PREFIX) && k !== outboxKey(userId));
|
|
47
|
+
if (keys.length) await storage.multiRemove(keys);
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hosted video messages for chat (`ChatProvider videoUpload`). Set
|
|
3
|
+
* `EXPO_PUBLIC_CHAT_VIDEO_UPLOAD_URL` to your server's `createVideoUploadHandler` (from
|
|
4
|
+
* `@marktiderman/genesis-chat/server`, with your Mux keys): each recording then goes to Mux
|
|
5
|
+
* and streams back as HLS. Unset, videos go to Supabase Storage as files, like a picked video.
|
|
6
|
+
*
|
|
7
|
+
* `EXPO_PUBLIC_CHAT_VIDEO_UPLOAD_URL=fake-storage` (development builds only) tries the hosted
|
|
8
|
+
* path against a local stack without Mux: the "upload URL" is a Storage signed upload URL in the
|
|
9
|
+
* sender's own folder, and the message carries a made-up Mux upload id, so it stays
|
|
10
|
+
* "Processing" (no webhook ever marks it ready). It takes the whole file in one PUT and can't
|
|
11
|
+
* resume. It exists to try the recorder, the upload progress and the send; never ship it.
|
|
12
|
+
*/
|
|
13
|
+
import * as ExpoCrypto from "expo-crypto";
|
|
14
|
+
import type { ChatVideoUpload } from "@marktiderman/genesis-chat/react";
|
|
15
|
+
import { env } from "./env";
|
|
16
|
+
import { supabase } from "./supabase";
|
|
17
|
+
|
|
18
|
+
declare const __DEV__: boolean;
|
|
19
|
+
|
|
20
|
+
/** The app's upload handler: POST `{ conversationId }` with the person's token. */
|
|
21
|
+
function handlerVideoUpload(url: string): ChatVideoUpload {
|
|
22
|
+
return {
|
|
23
|
+
async create(conversationId) {
|
|
24
|
+
const token = (await supabase.auth.getSession()).data.session?.access_token;
|
|
25
|
+
if (!token) throw new Error("Sign in to send a video");
|
|
26
|
+
const res = await fetch(url, { method: "POST", headers: { "content-type": "application/json", authorization: `Bearer ${token}` }, body: JSON.stringify({ conversationId }) });
|
|
27
|
+
if (!res.ok) throw new Error(`The video couldn't start uploading (${res.status})`);
|
|
28
|
+
const body = (await res.json()) as { url?: unknown; providerId?: unknown; provider?: unknown };
|
|
29
|
+
if (typeof body.url !== "string" || typeof body.providerId !== "string" || body.provider !== "mux") throw new Error("The video upload server answered something else");
|
|
30
|
+
return { url: body.url, providerId: body.providerId, provider: "mux" };
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** Development only: a Storage signed upload URL standing in for a Mux direct upload. */
|
|
36
|
+
const fakeStorageVideoUpload: ChatVideoUpload = {
|
|
37
|
+
async create(conversationId) {
|
|
38
|
+
const userId = (await supabase.auth.getSession()).data.session?.user.id;
|
|
39
|
+
if (!userId) throw new Error("Sign in to send a video");
|
|
40
|
+
const path = `${conversationId}/${userId}/${ExpoCrypto.randomUUID()}.mov`;
|
|
41
|
+
const { data, error } = await supabase.storage.from("genesis-chat").createSignedUploadUrl(path);
|
|
42
|
+
if (error || !data) throw new Error(error?.message ?? "No upload URL");
|
|
43
|
+
console.warn("[chat] fake-storage video upload: this video will stay 'Processing'; set a real upload handler for Mux.");
|
|
44
|
+
return { url: data.signedUrl, providerId: `fake-${ExpoCrypto.randomUUID()}`, provider: "mux" };
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export function chatVideoUpload(): ChatVideoUpload | undefined {
|
|
49
|
+
const url = env.chatVideoUploadUrl;
|
|
50
|
+
if (!url) return undefined;
|
|
51
|
+
if (url === "fake-storage") {
|
|
52
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) return fakeStorageVideoUpload;
|
|
53
|
+
console.warn("[chat] EXPO_PUBLIC_CHAT_VIDEO_UPLOAD_URL=fake-storage is for development builds only: videos go to storage as files.");
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
return handlerVideoUpload(url);
|
|
57
|
+
}
|