Skip to content

Commit

Permalink
Fix code from rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
Dananji committed Sep 1, 2023
1 parent 9dbb61d commit a38f24f
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 163 deletions.
7 changes: 0 additions & 7 deletions src/components/IIIFPlayerWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,6 @@ export default function IIIFPlayerWrapper({
const [manifestError, setManifestError] = React.useState('');
const dispatch = useManifestDispatch();

React.useEffect(() => {
if (manifest) {
const isPlaylist = Object.values(manifest.label)[0][0].includes('[Playlist]')
dispatch({ isPlaylist: isPlaylist, type: 'isPlaylist' })
}
}, [manifest]);

React.useEffect(() => {
if (manifest) {
dispatch({ manifest: manifest, type: 'updateManifest' });
Expand Down
14 changes: 11 additions & 3 deletions src/components/MediaPlayer/MediaPlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,17 @@ const MediaPlayer = ({ enableFileDownload = false, enablePIP = false }) => {
const [isMultiCanvased, setIsMultiCanvased] = React.useState(false);
const [lastCanvasIndex, setLastCanvasIndex] = React.useState(0);
const [isVideo, setIsVideo] = React.useState();
const [isEmptyCanvas, setIsEmptyCanvas] = React.useState(false);

const { canvasIndex, manifest, canvasDuration, srcIndex, targets, autoAdvance, playlist } =
const {
canvasIndex,
manifest,
canvasDuration,
canvasIsEmpty,
srcIndex,
targets,
autoAdvance,
playlist
} =
manifestState;
const { player } = playerState;

Expand All @@ -45,7 +53,7 @@ const MediaPlayer = ({ enableFileDownload = false, enablePIP = false }) => {

// flag to identify multiple canvases in the manifest
// to render previous/next buttons
const canvases = canvasCount(manifest);
const canvases = canvasesInManifest(manifest).length;
setIsMultiCanvased(canvases > 1 ? true : false);
setLastCanvasIndex(canvases - 1);
}
Expand Down
12 changes: 10 additions & 2 deletions src/components/MediaPlayer/MediaPlayer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,11 @@ describe('MediaPlayer component', () => {
window.HTMLMediaElement.prototype.load = () => { };

const PlayerWithManifest = withManifestAndPlayerProvider(MediaPlayer, {
initialManifestState: { manifest: playlistManifest, canvasIndex: 0, isPlaylist: true },
initialManifestState: {
manifest: playlistManifest,
canvasIndex: 0,
playlist: { isPlaylist: true }
},
initialPlayerState: {},
});
render(<PlayerWithManifest />);
Expand All @@ -124,7 +128,11 @@ describe('MediaPlayer component', () => {

test('renders player for a accessible Canvas', () => {
const PlayerWithManifest = withManifestAndPlayerProvider(MediaPlayer, {
initialManifestState: { manifest: playlistManifest, canvasIndex: 1, isPlaylist: true },
initialManifestState: {
manifest: playlistManifest,
canvasIndex: 1,
playlist: { isPlaylist: true }
},
initialPlayerState: {},
});
render(<PlayerWithManifest />);
Expand Down
4 changes: 2 additions & 2 deletions src/components/StructuredNavigation/StructuredNavigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const StructuredNavigation = () => {
const playerDispatch = usePlayerDispatch();

const { clickedUrl, isClicked, isPlaying, player } = usePlayerState();
const { canvasDuration, canvasIndex, hasMultiItems, targets, manifest, isPlaylist, canvasIsEmpty } =
const { canvasDuration, canvasIndex, hasMultiItems, targets, manifest, playlist, canvasIsEmpty } =
useManifestState();

const [canvasSegments, setCanvasSegments] = React.useState([]);
Expand Down Expand Up @@ -51,7 +51,7 @@ const StructuredNavigation = () => {

// Set currentNavItem when current Canvas is an inaccessible item
React.useEffect(() => {
if (canvasIsEmpty && isPlaylist) {
if (canvasIsEmpty && playlist.isPlaylist) {
manifestDispatch({ item: canvasSegments[canvasIndex], type: 'switchItem' });
}
}, [canvasIsEmpty, canvasIndex]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,11 @@ describe('StructuredNavigation component', () => {
describe('with a playlist manifest', () => {
beforeEach(() => {
const NavWithPlayerAndManifest = withManifestAndPlayerProvider(StructuredNavigation, {
initialManifestState: { manifest: playlist, isPlaylist: true, canvasIsEmpty: true },
initialManifestState: {
manifest: playlist,
playlist: { isPlaylist: true },
canvasIsEmpty: true
},
initialPlayerState: { playerRange: { start: null, end: null } },
});
render(<NavWithPlayerAndManifest />);
Expand Down
11 changes: 0 additions & 11 deletions src/services/iiif-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,6 @@ export function canvasesInManifest(manifest) {
return canvases;
}

export function canvasCount(manifest) {
try {
return parseManifest(manifest)
.getSequences()[0]
.getCanvases().length;
} catch (err) {
console.error('Error reading given Manifest, ', err);
return 0;
}
}

/**
* Check if item's behavior is set to a value which should hide it
* @param {Object} item
Expand Down
6 changes: 3 additions & 3 deletions src/services/iiif-parser.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,6 @@ describe('iiif-parser', () => {
});
});

<<<<<<< HEAD
describe('parseAutoAdvance()', () => {
describe('with manifest without auto-advance behavior', () => {
it('should return true', () => {
Expand Down Expand Up @@ -492,7 +491,9 @@ describe('iiif-parser', () => {
id: 'http://example.com/manifests/playlist/canvas/2/marker/3',
canvasId: 'http://example.com/manifests/playlist/canvas/2'
});
=======
});
});

describe('inaccessibleItemMessage()', () => {
it('returns text under placeholderCanvas', () => {
const itemMessage = iiifParser.inaccessibleItemMessage(manifest, 1);
Expand All @@ -507,7 +508,6 @@ describe('iiif-parser', () => {
if ('returns null when no placeholderCanvas is in the Canvas', () => {
const itemMessage = iiifParser.inaccessibleItemMessage(singleSrcManifest, 0);
expect(itemMessage).toBeNull();
>>>>>>> 9aafd36 (Fix broken tests)
});
});
});
13 changes: 0 additions & 13 deletions src/services/utility-helpers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,6 @@ describe('util helper', () => {
});
});

<<<<<<< HEAD
=======
describe('createTimestamp()', () => {
test('with hours', () => {
expect(util.createTimestamp(557.65, true)).toEqual('00:09:17');
});

test('without hours', () => {
expect(util.createTimestamp(557.65, false)).toEqual('09:17');
});
});

>>>>>>> 9aafd36 (Fix broken tests)
describe('getCanvasTarget()', () => {
const targets = [
{ start: 0, end: 2455, altStart: 0, duration: 2455, sIndex: 0 },
Expand Down
121 changes: 0 additions & 121 deletions src/test_data/playlist.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,48 +18,25 @@ export default {
{
id: 'http://example.com/manifests/playlist/canvas/1',
type: 'Canvas',
<<<<<<< HEAD
duration: 572.034,
label: {
en: ["Lunchroom Manners"]
=======
label: {
en: ["Restricted Item"]
>>>>>>> 9aafd36 (Fix broken tests)
},
placeholderCanvas: {
id: 'http://example.com/manifests/playlist/canvas/1/placeholder',
type: "Canvas",
<<<<<<< HEAD
width: 640,
height: 360,
=======
>>>>>>> 9aafd36 (Fix broken tests)
items: [
{
id: 'http://example.com/manifests/playlist/canvas/1/placeholder/1',
type: "AnnotationPage",
items: [
{
<<<<<<< HEAD
id: 'http://example.com/manifests/playlist/canvas/1/placeholder/1-image',
type: "Annotation",
motivation: "painting",
body: {
id: 'http://example.com/lunchroom_manners/lunchroom_manners_poster.jpg',
type: "Image",
format: "image/jpeg",
width: 640,
height: 360
=======
id: 'http://example.com/manifests/playlist/canvas/2/placeholder/1-image',
type: "Annotation",
motivation: "painting",
body: {
type: "Text",
format: "text/plain",
label: { en: ['You do not have permission to playback this item.'] }
>>>>>>> 9aafd36 (Fix broken tests)
},
target: 'http://example.com/manifests/playlist/canvas/1/placeholder'
}
Expand All @@ -71,93 +48,9 @@ export default {
{
id: 'http://example.com/manifests/playlist/canvas/1/page',
type: 'AnnotationPage',
<<<<<<< HEAD
items: [
{
id: 'http://example.com/manifests/playlist/canvas/1/page/annotation',
type: 'Annotation',
motivation: 'painting',
body: [
{
type: 'Choice',
choiceHint: 'user',
items: [
{
id: 'http://example.com/lunchroom_manners/high/lunchroom_manners_1024kb.mp4#t=0,572.0',
type: 'Video',
format: 'video/mp4',
label: {
en: ['High'],
},
height: 360,
width: 480,
duration: 572.0
},
{
id: 'http://example.com/lunchroom_manners/medium/lunchroom_manners_512kb.mp4#t=0,572.0',
type: 'Video',
format: 'video/mp4',
label: {
en: ['Medium'],
},
height: 360,
width: 480,
duration: 572.0
},
{
id: 'http://example.com/lunchroom_manners/low/lunchroom_manners_256kb.mp4#t=0,572.0',
type: 'Video',
format: 'video/mp4',
label: {
en: ['Low'],
},
height: 360,
width: 480,
duration: 572.0
},
],
},
],
target: 'http://example.com/manifests/playlist/canvas/1',
},
],
},
],
annotations: [
{
type: "AnnotationPage",
id: 'http://example.com/manifests/playlist/canvas/1/annotation_page/1',
items: [
{
type: "Annotation",
motivation: "highlighting",
body: {
type: "TextualBody",
format: "text/html",
value: "Marker 1"
},
id: 'http://example.com/manifests/playlist/canvas/1/marker/1',
target: 'http://example.com/manifests/playlist/canvas/1#t=2.836',
},
{
type: "Annotation",
motivation: "highlighting",
body: {
type: "TextualBody",
format: "text/html",
value: "Marker 2"
},
id: 'http://example.com/manifests/playlist/canvas/1/marker/2',
target: 'http://example.com/manifests/playlist/canvas/1#t=369.811'
}
]
}
],
=======
},
],
annotations: [],
>>>>>>> 9aafd36 (Fix broken tests)
},
{
id: 'http://example.com/manifests/playlist/canvas/2',
Expand Down Expand Up @@ -249,8 +142,6 @@ export default {
}
],
},
<<<<<<< HEAD
=======
{
id: 'http://example.com/manifests/playlist/canvas/3',
type: 'Canvas',
Expand Down Expand Up @@ -371,7 +262,6 @@ export default {
}
],
},
>>>>>>> 9aafd36 (Fix broken tests)
],
structures: [
{
Expand All @@ -383,11 +273,7 @@ export default {
{
id: 'http://example.com/manifests/playlist/range/1',
type: 'Range',
<<<<<<< HEAD
label: { en: ['Playlist Item 1'] },
=======
label: { en: ['Restricted Item'] },
>>>>>>> 9aafd36 (Fix broken tests)
items: [
{
type: "Canvas",
Expand All @@ -398,20 +284,14 @@ export default {
{
id: 'http://example.com/manifests/playlist/range/2',
type: 'Range',
<<<<<<< HEAD
label: { en: ['Playlist Item 2'] },
=======
label: { en: ['Playlist Item 1'] },
>>>>>>> 9aafd36 (Fix broken tests)
items: [
{
type: "Canvas",
id: 'http://example.com/manifests/playlist/canvas/2#t=0,'
}
]
},
<<<<<<< HEAD
=======
{
id: 'http://example.com/manifests/playlist/range/3',
type: 'Range',
Expand All @@ -423,7 +303,6 @@ export default {
}
]
},
>>>>>>> 9aafd36 (Fix broken tests)
]
}
]
Expand Down

0 comments on commit a38f24f

Please sign in to comment.