prop to hide displayAs selector

This commit is contained in:
Martti Malmi 2023-11-28 22:16:00 +02:00
parent 1330db056a
commit ad163625c3
4 changed files with 8 additions and 3 deletions

View File

@ -5,9 +5,11 @@ export type DisplayAs = "grid" | "feed";
type DisplaySelectorProps = {
activeSelection: DisplayAs;
onSelect: (display: DisplayAs) => void;
show?: boolean;
};
export const DisplayAsSelector = ({ activeSelection, onSelect }: DisplaySelectorProps) => {
export const DisplayAsSelector = ({ activeSelection, onSelect, show }: DisplaySelectorProps) => {
if (show === false) return null;
return (
<div className="flex mb-4">
<div

View File

@ -21,6 +21,7 @@ export interface TimelineProps {
loadMore?: boolean;
noSort?: boolean;
displayAs?: DisplayAs;
showDisplayAsSelector?: boolean;
}
/**
@ -73,7 +74,7 @@ const Timeline = (props: TimelineProps) => {
return (
<>
<LiveStreams evs={liveStreams} />
<DisplayAsSelector activeSelection={displayAs} onSelect={(displayAs: DisplayAs) => setDisplayAs(displayAs)} />
<DisplayAsSelector show={props.showDisplayAsSelector} activeSelection={displayAs} onSelect={(displayAs: DisplayAs) => setDisplayAs(displayAs)} />
<TimelineRenderer
frags={[
{

View File

@ -22,6 +22,7 @@ export interface TimelineFollowsProps {
noteRenderer?: (ev: NostrEvent) => ReactNode;
noteOnClick?: (ev: NostrEvent) => void;
displayAs?: DisplayAs;
showDisplayAsSelector?: boolean;
}
/**
@ -108,7 +109,7 @@ const TimelineFollows = (props: TimelineFollowsProps) => {
return (
<>
{(props.liveStreams ?? true) && <LiveStreams evs={liveStreams} />}
<DisplayAsSelector activeSelection={displayAs} onSelect={(displayAs: DisplayAs) => setDisplayAs(displayAs)} />
<DisplayAsSelector show={props.showDisplayAsSelector} activeSelection={displayAs} onSelect={(displayAs: DisplayAs) => setDisplayAs(displayAs)} />
<TimelineRenderer
frags={[{ events: orderDescending(mainFeed.concat(mixinFiltered)), refTime: latest }]}
related={reactions.data ?? []}

View File

@ -173,6 +173,7 @@ function MediaCol({ setThread }: { setThread: (e: NostrLink) => void }) {
return images.length > 0;
}}
displayAs="grid"
showDisplayAsSelector={false}
noteOnClick={e => setThread(NostrLink.fromEvent(e))}
/>
</div>