Skip to content

Commit

Permalink
Small refactorings
Browse files Browse the repository at this point in the history
  • Loading branch information
MariusDoe committed Aug 22, 2024
1 parent 3f2411a commit ce1125c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,15 @@ const PictureView = ({
pictureSequenceIds
);

const [hasPrevious, hasNext, hasPreviousInSequence, hasNextInSequence] = useMemo(() => {
return [
const [hasPrevious, hasNext, hasPreviousInSequence, hasNextInSequence] = useMemo(
() => [
Boolean(getPreviousPictureId(pictureInSiblingsId, siblingIds)),
Boolean(getNextPictureId(pictureInSiblingsId, siblingIds)),
Boolean(getPreviousPictureId(pictureInSequenceId, pictureSequenceIds)),
Boolean(getNextPictureId(pictureInSequenceId, pictureSequenceIds)),
];
}, [pictureInSequenceId, pictureInSiblingsId, pictureSequenceIds, siblingIds]);
],
[pictureInSequenceId, pictureInSiblingsId, pictureSequenceIds, siblingIds]
);

const onNavigateMessage = useCallback(
({ pictureInSiblingsId, pictureInSequenceId }: PictureIds) => {
Expand Down
12 changes: 6 additions & 6 deletions projects/bp-gallery/src/hooks/prefetch.hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,24 @@ const usePrefetchPictureHook = (
siblings?: string[],
pictureSequenceIds?: string[]
) => {
const [previousQuery] = useGetPictureInfoLazyQuery();
const [nextQuery] = useGetPictureInfoLazyQuery();
const [previousInSiblingsQuery] = useGetPictureInfoLazyQuery();
const [nextInSiblingsQuery] = useGetPictureInfoLazyQuery();
const [previousInSequenceQuery] = useGetPictureInfoLazyQuery();
const [nextInSequenceQuery] = useGetPictureInfoLazyQuery();

useEffect(() => {
if (siblings?.includes(pictureInSiblingsId)) {
const previousId = getPreviousPictureId(pictureInSiblingsId, siblings);
if (previousId) {
previousQuery({
previousInSiblingsQuery({
variables: {
pictureId: previousId,
},
});
}
const nextId = getNextPictureId(pictureInSiblingsId, siblings);
if (nextId) {
nextQuery({
nextInSiblingsQuery({
variables: {
pictureId: nextId,
},
Expand Down Expand Up @@ -56,8 +56,8 @@ const usePrefetchPictureHook = (
}, [
pictureInSiblingsId,
siblings,
previousQuery,
nextQuery,
previousInSiblingsQuery,
nextInSiblingsQuery,
pictureSequenceIds,
pictureInSequenceId,
previousInSequenceQuery,
Expand Down
4 changes: 1 addition & 3 deletions projects/bp-gallery/src/hooks/presentation-channel.hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ const usePresentationChannel = (id: string, onNavigate: (ids: PictureIds) => voi
useEffect(() => {
const consumer = channelFactory(id);
producer.current = channelFactory(id);
consumer.onmessage = (
event: MessageEvent<{ pictureInSiblingsId: string; pictureInSequenceId: string }>
) => {
consumer.onmessage = (event: MessageEvent<PictureIds>) => {
onNavigate(event.data);
};

Expand Down

0 comments on commit ce1125c

Please sign in to comment.