Function
updateChannel
({
accountId,
channelId,
channelName,
viewType,
}: {
accountId: string;
channelId: string;
channelName: string;
viewType: ChannelViewType;
})
Source from the content-addressed store, hash-verified
| 41 | ); |
| 42 | |
| 43 | function updateChannel({ |
| 44 | accountId, |
| 45 | channelId, |
| 46 | channelName, |
| 47 | viewType, |
| 48 | }: { |
| 49 | accountId: string; |
| 50 | channelId: string; |
| 51 | channelName: string; |
| 52 | viewType: ChannelViewType; |
| 53 | }) { |
| 54 | setLoading(true); |
| 55 | return api |
| 56 | .updateChannel({ |
| 57 | accountId, |
| 58 | channelId, |
| 59 | channelName, |
| 60 | channelPrivate, |
| 61 | viewType, |
| 62 | }) |
| 63 | .then(() => { |
| 64 | // changing channel name changes the path |
| 65 | // we'd need to dynamically update it |
| 66 | // we should most likely send this through websockets |
| 67 | // to other users to update the channel name dynamically |
| 68 | // otherwise they'll get a 404 on the previous channel name |
| 69 | setLoading(false); |
| 70 | window.location.href = window.location.href.replace( |
| 71 | `/${channel.channelName}`, |
| 72 | `/${channelName}` |
| 73 | ); |
| 74 | close(); |
| 75 | }) |
| 76 | .catch(() => { |
| 77 | setLoading(false); |
| 78 | close(); |
| 79 | }); |
| 80 | } |
| 81 | |
| 82 | function onSubmit(event: React.FormEvent<HTMLFormElement>) { |
| 83 | event.preventDefault(); |
Tested by
no test coverage detected