Skip to content

Commit

Permalink
creation and deletion fixes on mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
Kacper-RF committed May 17, 2023
1 parent 4ce8068 commit 418e0e9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { DateTime } from 'luxon'
import { navigationSelectors } from '../../store/navigation/navigation.selectors'
import { ScreenNames } from '../../const/ScreenNames.enum'
import { navigationActions } from '../../store/navigation/navigation.slice'
import { generateChannelAddress } from '@quiet/common'

export const CreateChannelScreen: FC = () => {
const dispatch = useDispatch()
Expand Down Expand Up @@ -79,7 +80,7 @@ export const CreateChannelScreen: FC = () => {
name: name,
description: `Welcome to #${name}`,
owner: user.nickname,
address: name,
address: generateChannelAddress(name),
timestamp: DateTime.utc().valueOf()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import { navigationSelectors } from '../../store/navigation/navigation.selectors

export const DeleteChannelScreen: FC<DeleteChannelScreenProps> = ({ route }) => {
const dispatch = useDispatch()
// KACPER
const { channel } = route.params

const { channel: channelRouteParam } = route.params

const channels = useSelector(publicChannels.selectors.publicChannels)

Expand All @@ -19,18 +19,19 @@ export const DeleteChannelScreen: FC<DeleteChannelScreenProps> = ({ route }) =>
console.log({ channels })

useEffect(() => {
if (screen === ScreenNames.DeleteChannelScreen && !channels.find(c => c.name === channel)) {
if (screen === ScreenNames.DeleteChannelScreen && !channels.find(c => c.name === channelRouteParam)) {
dispatch(navigationActions.replaceScreen({ screen: ScreenNames.ChannelListScreen }))
}
}, [dispatch, screen, channels])

const deleteChannel = useCallback(() => {
const deletedChannel = channels.find((channel) => channel.name === channelRouteParam)
dispatch(
publicChannels.actions.deleteChannel({
channelAddress: channel
channelAddress: deletedChannel.address
})
)
}, [dispatch])
}, [dispatch, channels, channelRouteParam])

const handleBackButton = useCallback(() => {
dispatch(
Expand All @@ -42,7 +43,7 @@ export const DeleteChannelScreen: FC<DeleteChannelScreenProps> = ({ route }) =>

return (
<DeleteChannel
name={channel}
name={channelRouteParam}
deleteChannel={deleteChannel}
handleBackButton={handleBackButton}
/>
Expand Down

0 comments on commit 418e0e9

Please sign in to comment.