Compare commits

...
Author SHA1 Message Date
Paul Kaplan 88004b7ba0 Merge pull request #4564 from paulkaplan/hotfix/toolbox-update-after-tab
[master] Request a toolbox refresh after switching between tabs to fix #4561
2019-02-15 09:33:50 -05:00
Paul Kaplan 0492570f5d Request a toolbox refresh after switching between tabs to fix #4561 2019-02-15 09:31:55 -05:00
Paul Kaplan 90cb84500e Merge pull request #4555 from paulkaplan/hotfix/gif-frames
Fix loading single frame gifs by removing onDone in favor of indices
2019-02-14 13:49:53 -05:00
Paul Kaplan 697f697fc5 Fix loading single frame gifs by removing onDone in favor of indices
Because the `onFrame` callback could do async work, it was possible for onDone to try to submit the costumes before the onFrame had produced any. This was subject to browsers different timing treatments of setTimeout vs. promise resolution. This makes the gif-decoder use the same style of progress API as the file uploader
2019-02-14 13:07:56 -05:00
Paul Kaplan 791ad4e0a9 Merge pull request #4554 from LLK/release/02-14-2019
Update master to 0.1.0-prerelease.20190213213304
2019-02-14 13:05:23 -05:00
Paul Kaplan 1d2bf1d31c Merge pull request #4482 from paulkaplan/hotfix/fix-tests
Remove beforeunload callback that was breaking tests
2019-02-04 11:52:28 -05:00
4 changed files with 24 additions and 14 deletions

No files matched your search

+1
View File
@@ -162,6 +162,7 @@ class Blocks extends React.Component {
this.setLocale();
} else {
this.props.vm.refreshWorkspace();
this.requestToolboxUpdate();
}
window.dispatchEvent(new Event('resize'));
+5 -6
View File
@@ -118,15 +118,14 @@ const costumeUpload = function (fileData, fileType, storage, handleCostume, hand
}
case 'image/gif': {
let costumes = [];
const onFrame = (frameNumber, dataUrl) => {
gifDecoder(fileData, (frameNumber, dataUrl, numFrames) => {
costumeUpload(dataUrl, 'image/png', storage, costumes_ => {
costumes = costumes.concat(costumes_);
if (frameNumber === numFrames - 1) {
handleCostume(costumes);
}
}, handleError);
};
const onDone = () => {
handleCostume(costumes);
};
gifDecoder(fileData, {onFrame, onDone});
});
return; // Abandon this load, do not try to load gif itself
}
default:
+4 -8
View File
@@ -1,9 +1,10 @@
import {GifReader} from 'omggif';
export default (arrayBuffer, {onFrame, onDone}) => {
export default (arrayBuffer, onFrame) => {
const canvas = document.createElement('canvas');
const ctx = canvas.getContext('2d');
const gifReader = new GifReader(new Uint8Array(arrayBuffer));
const numFrames = gifReader.numFrames();
canvas.width = gifReader.width;
canvas.height = gifReader.height;
@@ -14,7 +15,6 @@ export default (arrayBuffer, {onFrame, onDone}) => {
const framePixels = [];
gifReader.decodeAndBlitFrameRGBA(i, framePixels);
const {x, y, width, height, disposal} = gifReader.frameInfo(i);
for (let row = 0; row < height; row++) {
for (let column = 0; column < width; column++) {
const indexOffset = 4 * (x + (y * canvas.width));
@@ -47,16 +47,12 @@ export default (arrayBuffer, {onFrame, onDone}) => {
break;
}
onFrame(i, dataUrl);
onFrame(i, dataUrl, numFrames);
if (i < gifReader.numFrames() - 1) {
if (i < numFrames - 1) {
setTimeout(() => {
loadFrame(i + 1);
});
} else {
setTimeout(() => {
onDone();
});
}
};
+14
View File
@@ -252,4 +252,18 @@ describe('Working with the blocks', () => {
await driver.sleep(500); // Wait for scroll to finish
await clickText('my\u00A0variable');
});
// Regression test for switching editor tabs causing toolbox to stop updating
test('Creating variables after adding extensions updates the toolbox', async () => {
await loadUri(uri);
await clickText('Costumes');
await clickText('Code');
await clickText('Variables', scope.blocksTab);
await driver.sleep(500); // Wait for scroll
await clickText('Make a List');
const el = await findByXpath("//input[@name='New list name:']");
await el.sendKeys('list1');
await clickButton('OK');
await clickText('list1', scope.blocksTab);
});
});