···
import { useFacet } from "@/lib/facet";
import { lighten } from "@/lib/facet/src/lib/colors";
import type { ComAtprotoRepoStrongRef } from "@/lib/types/atproto";
6
+
import { addChannel } from "@/lib/utils/gmstn";
useOAuthSessionGuaranteed,
···
const { data: lattices, isLoading: latticesLoading } =
useLatticesQueryActual();
const { data: shards, isLoading: shardsLoading } = useShardsQueryActual();
44
-
const { mutate: newChannelMutation, isPending: mutationPending } =
46
-
mutationFn: async () => {
47
-
// const registerResult = await registerNewChannel({
48
-
// channelDomain: inputText,
51
-
// if (!registerResult.ok) {
53
-
// "Something went wrong when registering the channel.",
54
-
// registerResult.error,
57
-
// `Something went wrong when registering the channel. ${registerResult.error}`,
60
-
// setShowAddModal(false);
62
-
onSuccess: async () => {
63
-
await queryClient.invalidateQueries({
64
-
queryKey: channelsQueryKey,
66
-
setShowAddModal(false);
70
-
"Something went wrong when registering the channel.",
73
-
setMutationError(err.message);
const selectableShards = shards
? shards.map((shard) => ({
···
Omit<ComAtprotoRepoStrongRef, "$type">
>(selectableLattices[0].ref);
70
+
const { mutate: newChannelMutation, isPending: mutationPending } =
72
+
mutationFn: async () => {
73
+
const registerResult = await addChannel({
77
+
storeAt: selectedShard,
78
+
routeThrough: selectedLattice,
82
+
if (!registerResult.ok) {
84
+
"Something went wrong when registering the channel.",
85
+
registerResult.error,
88
+
`Something went wrong when registering the channel. ${registerResult.error}`,
91
+
setShowAddModal(false);
93
+
onSuccess: async () => {
94
+
await queryClient.invalidateQueries({
95
+
queryKey: channelsQueryKey,
97
+
setShowAddModal(false);
101
+
"Something went wrong when registering the channel.",
104
+
setMutationError(err.message);
const isLoading = latticesLoading && shardsLoading;
105
-
selectedShard: JSON.stringify(selectedShard),
106
-
selectedLattice: JSON.stringify(selectedLattice),
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- must explicitly check because we are deriving from an array.
const readyToSubmit = !!(selectedShard && selectedLattice && name.trim());