Skip to content

Commit

Permalink
Merge pull request #4087 from tloncorp/po/tlon-3099-fix-wrong-layout-…
Browse files Browse the repository at this point in the history
…for-detailview-comments

detail views: fix bad layouts for comments
  • Loading branch information
patosullivan authored Oct 18, 2024
2 parents c2969d1 + 4ec9a7a commit fb5f3df
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
15 changes: 12 additions & 3 deletions packages/shared/src/types/PostCollectionConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@ export type PostCollectionLayoutType =
// If the caller has a non-nullable `channel`, they can then get a
// non-nullable return value - nice, right?
export function layoutTypeFromChannel(
channel: db.Channel
channel: db.Channel,
detailView?: boolean
): PostCollectionLayoutType;
export function layoutTypeFromChannel(
channel: db.Channel | null
channel: db.Channel | null,
detailView?: boolean
): PostCollectionLayoutType | null;
export function layoutTypeFromChannel(
channel: db.Channel | null
channel: db.Channel | null,
detailView?: boolean
): PostCollectionLayoutType | null {
switch (channel?.type) {
case null:
Expand All @@ -35,9 +38,15 @@ export function layoutTypeFromChannel(
return 'compact-list-bottom-to-top';

case 'notebook':
if (detailView) {
return 'compact-list-bottom-to-top';
}
return 'comfy-list-top-to-bottom';

case 'gallery':
if (detailView) {
return 'compact-list-bottom-to-top';
}
return 'grid';
}
}
Expand Down
4 changes: 3 additions & 1 deletion packages/ui/src/components/Channel/Scroller.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ const Scroller = forwardRef(
renderEmptyComponent: renderEmptyComponentFn,
posts,
channel,
detailView,
firstUnreadId,
unreadCount,
onStartReached,
Expand All @@ -118,6 +119,7 @@ const Scroller = forwardRef(
renderEmptyComponent?: () => ReactElement;
posts: db.Post[] | null;
channel: db.Channel;
detailView?: boolean;
firstUnreadId?: string | null;
unreadCount?: number | null;
onStartReached?: () => void;
Expand All @@ -141,7 +143,7 @@ const Scroller = forwardRef(
ref
) => {
const collectionLayoutType = useMemo(
() => layoutTypeFromChannel(channel),
() => layoutTypeFromChannel(channel, detailView),
[channel]
);
const collectionLayout = useMemo(
Expand Down
2 changes: 2 additions & 0 deletions packages/ui/src/components/DetailView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export const DetailView = ({
inverted
renderItem={ChatMessage}
channel={channel}
detailView
editingPost={editingPost}
setEditingPost={setEditingPost}
posts={resolvedPosts ?? null}
Expand Down Expand Up @@ -97,6 +98,7 @@ export const DetailView = ({
setActiveMessage,
setEditingPost,
headerMode,
channel
]);

return isChat ? (
Expand Down

0 comments on commit fb5f3df

Please sign in to comment.