Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/lib/mw-project-metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@ const installProjectMetadata = vm => {
// deserializeProject is the one place the VM hands us the parsed project
// json, so it is the only cheap way to see the meta a file arrived with.
const originalDeserialize = vm.deserializeProject.bind(vm);
vm.deserializeProject = (projectJSON, zip) => {
vm.deserializeProject = (projectJSON, zip, ...rest) => {
loadedMeta = (projectJSON && projectJSON.meta) || null;
// Opening a project adopts its birthday; opening one without a
// recorded birthday means the next save mints one.
created = (loadedMeta && (loadedMeta.created || loadedMeta.createdAt)) || null;
return originalDeserialize(projectJSON, zip);
return originalDeserialize(projectJSON, zip, ...rest);
};
};

Expand Down
11 changes: 11 additions & 0 deletions test/unit/util/mw-project-metadata.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@ import {
} from '../../../src/lib/mw-project-metadata';

describe('project metadata', () => {
test('passes every deserialize argument through, including the load cancellation check', async () => {
const original = jest.fn(() => Promise.resolve());
const vm = {toJSON: () => '{}', deserializeProject: original};
const active = () => false;

installProjectMetadata(vm);
await vm.deserializeProject({meta: {}}, 'zip', active);

expect(original).toHaveBeenCalledWith({meta: {}}, 'zip', active);
});

test('keeps Scratch metadata and carries MistWarp metadata across saves', async () => {
let source = {
meta: {
Expand Down