Skip to content

Commit

Permalink
🧧 Channel asset upload (#5218)
Browse files Browse the repository at this point in the history
* Avoid switching to default channel on refetch if channel is populated and belongs to member

* Reset form with correct contentId for assets to display state correctly
  • Loading branch information
WRadoslaw authored Nov 6, 2023
1 parent f6f226e commit e457a91
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 12 additions & 1 deletion packages/atlas/src/hooks/useChannelForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,18 @@ export const useChannelForm = (props: FormType) => {
fee: newChannel ? createChannelFee : updateChannelFee,
},
onTxSync: (result) => {
reset(getValues())
const values = getValues()
reset({
...values,
avatar: {
...values.avatar,
contentId: result.assetsIds.avatarPhoto ?? values.avatar.contentId,
},
cover: {
...values.cover,
contentId: result.assetsIds.coverPhoto ?? values.cover.contentId,
},
})
channelId = result.channelId
refetchUserMemberships()
},
Expand Down
2 changes: 1 addition & 1 deletion packages/atlas/src/providers/user/user.provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const UserProvider: FC<PropsWithChildren> = ({ children }) => {
(currentUser?.membershipId &&
data.memberships?.find((membership) => membership.id === currentUser?.membershipId)) ||
null
if (activeMembership) {
if (activeMembership && !activeMembership.channels.some((channel) => channel.id === channelId)) {
setChannelId(activeMembership.channels[0].id)
}
},
Expand Down

0 comments on commit e457a91

Please sign in to comment.