Skip to content

Commit

Permalink
fix: only call renderImage once (#2514)
Browse files Browse the repository at this point in the history
  • Loading branch information
rwd authored Dec 12, 2024
1 parent 7d7fb24 commit a26ee04
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
7 changes: 0 additions & 7 deletions packages/portal/src/components/media/MediaImageViewer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@
}
if (process.client) {
// FIXME: this is called twice, also in mounted
this.renderImage();
}
} catch (error) {
Expand Down Expand Up @@ -186,12 +185,6 @@
url: '$fetch'
},
mounted() {
if (!this.$fetchState.pending) {
this.renderImage();
}
},
methods: {
initOlAnnotationLayer() {
const layerCount = this.olMap.getLayers().getLength();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ describe('components/media/MediaImageViewer', () => {
};
stubItemMediaPresentationComposable({ activeAnnotation: annotation, hasAnnotations: true });
const wrapper = factory({ propsData: { url, width, height } });
await wrapper.vm.fetch();

await new Promise(process.nextTick);
wrapper.vm.highlightAnnotations();
Expand All @@ -163,6 +164,7 @@ describe('components/media/MediaImageViewer', () => {
it('adds a feature for the annotation at the full image size', async() => {
stubItemMediaPresentationComposable({ activeAnnotation: annotation, hasAnnotations: true });
const wrapper = factory({ propsData: { url, width, height } });
await wrapper.vm.fetch();

await new Promise(process.nextTick);
wrapper.vm.highlightAnnotations();
Expand All @@ -185,6 +187,7 @@ describe('components/media/MediaImageViewer', () => {
it('adds a feature for the annotation at its xywh co-ordinates', async() => {
stubItemMediaPresentationComposable({ activeAnnotation: annotation, hasAnnotations: true });
const wrapper = factory({ propsData: { url, width, height } });
await wrapper.vm.fetch();

await new Promise(process.nextTick);
wrapper.vm.highlightAnnotations();
Expand Down Expand Up @@ -240,8 +243,11 @@ describe('components/media/MediaImageViewer', () => {
hash: '#annotations'
};
const wrapper = factory({ propsData: { url, width, height }, mocks: { $route: { query: {}, hash: '#search' } } });
await wrapper.vm.fetch();

await new Promise(process.nextTick);
wrapper.vm.handleMapClick([200, 600]);

expect(routerReplaceSpy.calledWith(sinon.match(expectedRouteArgs))).toBe(true);
});
});
Expand All @@ -254,6 +260,7 @@ describe('components/media/MediaImageViewer', () => {
min: minZoom
} = useZoom();
const wrapper = factory({ propsData: { url, width, height } });
await wrapper.vm.fetch();

await new Promise(process.nextTick);
wrapper.vm.configureZoomLevels();
Expand All @@ -271,6 +278,7 @@ describe('components/media/MediaImageViewer', () => {
setCurrent: setCurrentZoom
} = useZoom();
const wrapper = factory({ propsData: { url, width, height } });
await wrapper.vm.fetch();

await new Promise(process.nextTick);
wrapper.vm.olMap.getView = sinon.stub().returns({
Expand Down

0 comments on commit a26ee04

Please sign in to comment.