frontend client for gemstone. decentralised workplace app
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: add channel

serenity 3511b004 539b66ba

+40 -41
+39 -39
src/components/Settings/AddChannelModalContent.tsx
··· 3 3 import { useFacet } from "@/lib/facet"; 4 4 import { lighten } from "@/lib/facet/src/lib/colors"; 5 5 import type { ComAtprotoRepoStrongRef } from "@/lib/types/atproto"; 6 + import { addChannel } from "@/lib/utils/gmstn"; 6 7 import { 7 8 useOAuthAgentGuaranteed, 8 9 useOAuthSessionGuaranteed, ··· 40 41 const { data: lattices, isLoading: latticesLoading } = 41 42 useLatticesQueryActual(); 42 43 const { data: shards, isLoading: shardsLoading } = useShardsQueryActual(); 43 - 44 - const { mutate: newChannelMutation, isPending: mutationPending } = 45 - useMutation({ 46 - mutationFn: async () => { 47 - // const registerResult = await registerNewChannel({ 48 - // channelDomain: inputText, 49 - // agent, 50 - // }); 51 - // if (!registerResult.ok) { 52 - // console.error( 53 - // "Something went wrong when registering the channel.", 54 - // registerResult.error, 55 - // ); 56 - // throw new Error( 57 - // `Something went wrong when registering the channel. ${registerResult.error}`, 58 - // ); 59 - // } 60 - // setShowAddModal(false); 61 - }, 62 - onSuccess: async () => { 63 - await queryClient.invalidateQueries({ 64 - queryKey: channelsQueryKey, 65 - }); 66 - setShowAddModal(false); 67 - }, 68 - onError: (err) => { 69 - console.error( 70 - "Something went wrong when registering the channel.", 71 - err, 72 - ); 73 - setMutationError(err.message); 74 - }, 75 - }); 76 - 77 44 const selectableShards = shards 78 45 ? shards.map((shard) => ({ 79 46 domain: shard.uri.rKey, ··· 100 67 Omit<ComAtprotoRepoStrongRef, "$type"> 101 68 >(selectableLattices[0].ref); 102 69 70 + const { mutate: newChannelMutation, isPending: mutationPending } = 71 + useMutation({ 72 + mutationFn: async () => { 73 + const registerResult = await addChannel({ 74 + channelInfo: { 75 + name, 76 + topic, 77 + storeAt: selectedShard, 78 + routeThrough: selectedLattice, 79 + }, 80 + agent, 81 + }); 82 + if (!registerResult.ok) { 83 + console.error( 84 + "Something went wrong when registering the channel.", 85 + registerResult.error, 86 + ); 87 + throw new Error( 88 + `Something went wrong when registering the channel. ${registerResult.error}`, 89 + ); 90 + } 91 + setShowAddModal(false); 92 + }, 93 + onSuccess: async () => { 94 + await queryClient.invalidateQueries({ 95 + queryKey: channelsQueryKey, 96 + }); 97 + setShowAddModal(false); 98 + }, 99 + onError: (err) => { 100 + console.error( 101 + "Something went wrong when registering the channel.", 102 + err, 103 + ); 104 + setMutationError(err.message); 105 + }, 106 + }); 107 + 103 108 const isLoading = latticesLoading && shardsLoading; 104 - console.log({ 105 - selectedShard: JSON.stringify(selectedShard), 106 - selectedLattice: JSON.stringify(selectedLattice), 107 - name: name.trim(), 108 - }); 109 109 110 110 // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- must explicitly check because we are deriving from an array. 111 111 const readyToSubmit = !!(selectedShard && selectedLattice && name.trim());
+1 -1
src/components/Settings/ChannelSettings.tsx
··· 98 98 { color: semantic.textInverse }, 99 99 ]} 100 100 > 101 - Add 101 + Add 102 102 </Text> 103 103 </View> 104 104 )}
-1
src/components/Settings/InviteUserModalContent.tsx
··· 61 61 $type: "com.atproto.repo.strongRef", 62 62 }, 63 63 }); 64 - console.log(inviteRes) 65 64 if (!inviteRes.ok) throw new Error(inviteRes.error); 66 65 }, 67 66 onSuccess: async () => {