diff --git a/src/common/BaseAnnotator.ts b/src/common/BaseAnnotator.ts index a57fd0384..a7b72e7c0 100644 --- a/src/common/BaseAnnotator.ts +++ b/src/common/BaseAnnotator.ts @@ -14,6 +14,7 @@ export type FileOptions = { annotations?: { activeId?: string; }; + currentFileVersionId?: string; fileVersionId?: string; }; }; @@ -53,8 +54,9 @@ export default class BaseAnnotator extends EventEmitter { super(); const fileOptionsValue = fileOptions?.[file.id]; + const currentFileVersionId = fileOptionsValue?.currentFileVersionId; const fileOptionsVersionId = fileOptionsValue?.fileVersionId; - const fileVersionId = file.file_version.id; + const fileVersionId = file.file_version.id; // This is always the currently-previewed version id, not current version id const initialState = { annotations: { @@ -63,7 +65,7 @@ export default class BaseAnnotator extends EventEmitter { options: { fileId: file.id, fileVersionId: fileOptionsVersionId ?? fileVersionId, - isCurrentFileVersion: !fileOptionsVersionId || fileOptionsVersionId === fileVersionId, + isCurrentFileVersion: !fileOptionsVersionId || fileOptionsVersionId === currentFileVersionId, permissions: file.permissions, }, }; diff --git a/src/common/__tests__/BaseAnnotator-test.ts b/src/common/__tests__/BaseAnnotator-test.ts index 24ced7a9c..4b16b1159 100644 --- a/src/common/__tests__/BaseAnnotator-test.ts +++ b/src/common/__tests__/BaseAnnotator-test.ts @@ -109,19 +109,20 @@ describe('BaseAnnotator', () => { }); test.each` - fileOptionsVersionId | fileVersionId | isCurrentFileVersion - ${'0'} | ${'0'} | ${true} - ${undefined} | ${'0'} | ${true} - ${'1'} | ${'0'} | ${false} + fileOptionsVersionId | currentFileVersionId | isCurrentFileVersion + ${'0'} | ${'0'} | ${true} + ${undefined} | ${'0'} | ${true} + ${'1'} | ${'0'} | ${false} `( 'should set isCurrentFileVersion to $isCurrentFileVersion', - ({ fileOptionsVersionId, fileVersionId, isCurrentFileVersion }) => { + ({ currentFileVersionId, fileOptionsVersionId, isCurrentFileVersion }) => { const file = { ...defaults.file, - file_version: { id: fileVersionId }, + file_version: { id: fileOptionsVersionId }, }; const fileOptions = { '12345': { + currentFileVersionId, fileVersionId: fileOptionsVersionId, }, };