Skip to content

Commit

Permalink
fix channels sidebar
Browse files Browse the repository at this point in the history
  • Loading branch information
hellno committed Aug 24, 2023
1 parent 2e05df4 commit 725cf9e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
10 changes: 8 additions & 2 deletions src/common/components/RightSidebar/ChannelsOverview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { SidebarHeader } from "./SidebarHeader";

const ChannelsOverview = () => {
const [showAll, setShowAll] = useState(false);
const MAX_SIDEBAR_CHANNELS = 9;
const {
channels,
selectedChannelIdx,
Expand All @@ -16,6 +17,11 @@ const ChannelsOverview = () => {
setShowAll(!showAll);
}

let sidebarChannels = showAll ? channels : channels.slice(0, MAX_SIDEBAR_CHANNELS);
if (!showAll && selectedChannelIdx && selectedChannelIdx >= MAX_SIDEBAR_CHANNELS) {
sidebarChannels.push(channels[selectedChannelIdx]);
}

return (<>
<SidebarHeader title="Channels" actionTitle={showAll ? 'Show less' : 'Show all'} onClick={onToggleShowAll} />
<ul role="list" className="mx-4 m-4">
Expand All @@ -35,12 +41,12 @@ const ChannelsOverview = () => {
</kbd>
</span>
</li>
{(showAll ? channels : channels.slice(0, 9)).map((channel: ChannelType, idx: number) => (
{(sidebarChannels).map((channel: ChannelType, idx: number) => (
<li key={channel.name} className="px-2 sm:px-3 lg:px-4">
<div
onClick={() => setCurrentChannelIdx(idx)}
className={classNames(
selectedChannelIdx == idx
(showAll && selectedChannelIdx === idx) || (!showAll && idx === MAX_SIDEBAR_CHANNELS)
? 'text-white font-semibold'
: 'text-gray-400 hover:text-white',
'flex align-center justify-between flex gap-x-3 rounded-md p-1 text-sm leading-6 cursor-pointer'
Expand Down
1 change: 0 additions & 1 deletion src/pages/Home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ export default function Home() {
const navItem = navigation.find((item) => item.router === pathname) || { name: 'herocast', getTitle: null }
const title = navItem.getTitle ? navItem.getTitle() : navItem.name;
const pageNavigation = pathname !== '/login' ? { rightSidebar: RIGHT_SIDEBAR_ENUM.ACCOUNTS } : {};
console.log('pageNavigation', pageNavigation, 'pathname', pathname);

useEffect(() => {
trackPageView(pathname.slice(1));
Expand Down
4 changes: 4 additions & 0 deletions src/pages/Settings/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ export default function Settings() {
const renderInfoSection = () => {
let commands: SimpleCommand[] = [
{ name: 'Command Palette', shortcut: 'cmd+k' },
{ name: 'Feed: go to previous cast in list', shortcut: 'k' },
{ name: 'Feed: go to next cast in list', shortcut: 'j' },
{ name: 'Feed: Open thread view for cast (currently showing Warpcast)', shortcut: 'o' },
{ name: 'Feed: Open embedded link in new tab', shortcut: 'shift+o' },
// ...navigationCommands,
...newPostCommands,
...accountCommands,
Expand Down

0 comments on commit 725cf9e

Please sign in to comment.