Skip to content
This repository has been archived by the owner on Feb 1, 2024. It is now read-only.

Added an exit button for the Settings view #145

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/containers/ChannelHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ function ChannelHeader () {
uiStore.openControlPanel()
}

function goBack(e){
e.stopPropagation()
window.location.hash = (window.lastChannel == undefined) ? '#' : '#/channel/'+window.lastChannel
}

const overrideName = t(`viewNames.${location.pathname.slice(1)}`)

return useObserver(() => (
Expand All @@ -35,6 +40,18 @@ function ChannelHeader () {
) : null}
</div>
<div className='currentChannel'>{channel ? `#${channel}` : overrideName}</div>
{
(window.location.hash == '#/settings') ?
(
<div
className='exit-button icon'
onClick={goBack}
style={{ ...uiStore.theme }}
> &times; </div>
) : (
<div></div>
)
}
</div>
))
}
Expand Down
4 changes: 4 additions & 0 deletions src/styles/ChannelHeader.scss
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ $channel-name-min-height: 1.6em;
font-size: 0.7em;
cursor: pointer;
font-weight: 100;

&.exit-button{
font-size: 1em;
}
}

.currentChannel {
Expand Down
1 change: 1 addition & 0 deletions src/views/ChannelView.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const MessageUserProfilePanel = lazy(() =>
function ChannelView () {
const { networkStore } = useContext(RootContext)
const { channel } = useParams()
window.lastChannel = (channel == undefined) ? window.lastChannel : channel
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of using window I'd recommend using useHistory from react-router-dom OR using a store from context, just to keep the application state in order.


return useObserver(() =>
networkStore.isOnline ? (
Expand Down