Skip to content

Commit

Permalink
testing
Browse files Browse the repository at this point in the history
  • Loading branch information
markdavella committed Mar 22, 2024
1 parent a7f2c97 commit baada23
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 4 deletions.
16 changes: 14 additions & 2 deletions web/src/components/InlineModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { PlexMedia } from '@tunarr/types/plex';
import { usePrevious } from '@uidotdev/usehooks';
import React, { memo, useCallback, useEffect, useRef, useState } from 'react';
import {
extractLastIndexes,
firstItemInNextRow,
getEstimatedModalHeight,
} from '../helpers/inlineModalUtil';
Expand All @@ -26,7 +27,6 @@ const plexTypeString = forPlexMedia({
track: 'Track',
album: 'Album',
artist: 'Artist',
default: 'All',
});

function InlineModal(props: InlineModalProps) {
Expand Down Expand Up @@ -121,6 +121,8 @@ function InlineModal(props: InlineModalProps) {
{modalChildren?.map(
(child: PlexMedia, idx: number, arr: PlexMedia[]) => (
<React.Fragment key={child.guid}>
{console.log(child)}
{console.log('log ', idx, ' ', plexTypeString(child))}
<InlineModal
modalIndex={childModalIndex} //to do
modalChildren={childModalChildren} //to do
Expand All @@ -134,7 +136,6 @@ function InlineModal(props: InlineModalProps) {
}
rowSize={rowSize}
type={plexTypeString(child)}
// firstItemInNextRow={firstItemInNextRow}
/>
<PlexGridItem
key={child.guid}
Expand All @@ -159,6 +160,17 @@ function InlineModal(props: InlineModalProps) {
</React.Fragment>
),
)}
{/* This Modal is for last row items because they can't be inserted using the above inline modal */}
<InlineModal
modalIndex={childModalIndex}
modalChildren={childModalChildren}
rowSize={rowSize}
open={extractLastIndexes(
modalChildren,
modalChildren.length % rowSize,
).includes(childModalIndex)}
type={'All'}
/>
</List>
</Collapse>
);
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/channel_config/PlexGridItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const PlexGridItem = forwardRef(

const handleClick = () => {
setOpen(!open);
console.log('TEST');
console.log();

if (moveModal) {
moveModal();
Expand Down
13 changes: 13 additions & 0 deletions web/src/components/channel_config/PlexProgrammingSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { chain, first, isEmpty, isNil, isUndefined, map } from 'lodash-es';
import React, { useCallback, useEffect, useRef, useState } from 'react';
import { useIntersectionObserver } from 'usehooks-ts';
import {
extractLastIndexes,
firstItemInNextRow,
getImagesPerRow,
} from '../../helpers/inlineModalUtil';
Expand Down Expand Up @@ -294,6 +295,7 @@ export default function PlexProgrammingSelector() {
<PlexListItem key={item.guid} item={item} />
) : (
<React.Fragment key={item.guid}>
{console.log('log ', index, ' ', plexTypeString(item))}
<InlineModal
modalIndex={modalIndex}
modalChildren={modalChildren}
Expand Down Expand Up @@ -324,6 +326,17 @@ export default function PlexProgrammingSelector() {
</React.Fragment>
),
)}
{/* This Modal is for last row items because they can't be inserted using the above inline modal */}
<InlineModal
modalIndex={modalIndex}
modalChildren={modalChildren}
rowSize={rowSize}
open={extractLastIndexes(
collectionsData?.Metadata,
collectionsData?.Metadata.length % rowSize,
).includes(modalIndex)}
type={'All'}
/>
</CustomTabPanel>,
);
}
Expand Down
6 changes: 5 additions & 1 deletion web/src/helpers/inlineModalUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ export function getEstimatedModalHeight(
): number {
// Episode modals have smaller height, short circuit for now

if (type === 'All') {
console.log('type: ', type);
if (type === 'Episode') {
console.log('MATCH!');

return 143;
}
// Exit with defaults if container & image width are not provided
Expand Down Expand Up @@ -66,6 +69,7 @@ export function firstItemInNextRow(
modalIndex >= numberOfItems - numberOfItemsLastRow &&
numberOfItemsLastRow < itemsPerRow
) {
return -1;
return numberOfItems - numberOfItemsLastRow;
}

Expand Down
1 change: 1 addition & 0 deletions web/src/helpers/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ export const forTvGuideProgram = <T>(

export const forPlexMedia = <T>(choices: PerTypeCallback<PlexMedia, T>) => {
return (m: PlexMedia) => {
// console.log('m.type ===', m.type);
switch (m.type) {
case 'movie':
if (choices.movie) return applyOrValue(choices.movie, m);
Expand Down

0 comments on commit baada23

Please sign in to comment.