Fix bugs with handling large image attachments
* Avoid infinite loop scaling too-big images * Don't crash if no file is selected * Fix file size toast Fixes #242 // FREEBIE
This commit is contained in:
parent
585c82aee8
commit
53a9ab4834
2 changed files with 8 additions and 4 deletions
|
@ -42,6 +42,9 @@
|
||||||
// hack
|
// hack
|
||||||
if (this.window && this.window.chrome && this.window.chrome.fileSystem) {
|
if (this.window && this.window.chrome && this.window.chrome.fileSystem) {
|
||||||
this.window.chrome.fileSystem.chooseEntry({type: 'openFile'}, function(entry) {
|
this.window.chrome.fileSystem.chooseEntry({type: 'openFile'}, function(entry) {
|
||||||
|
if (!entry) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
entry.file(function(file) {
|
entry.file(function(file) {
|
||||||
this.file = file;
|
this.file = file;
|
||||||
this.previewImages();
|
this.previewImages();
|
||||||
|
@ -97,7 +100,6 @@
|
||||||
quality = quality * maxSize / blob.size;
|
quality = quality * maxSize / blob.size;
|
||||||
if (quality < 50) {
|
if (quality < 50) {
|
||||||
quality = 50;
|
quality = 50;
|
||||||
i = 1;
|
|
||||||
}
|
}
|
||||||
} while (i > 0 && blob.size > maxSize);
|
} while (i > 0 && blob.size > maxSize);
|
||||||
|
|
||||||
|
@ -130,9 +132,11 @@
|
||||||
case 'video': limitKb = 8000; break;
|
case 'video': limitKb = 8000; break;
|
||||||
}
|
}
|
||||||
if ((blob.size/1024).toFixed(4) >= limitKb) {
|
if ((blob.size/1024).toFixed(4) >= limitKb) {
|
||||||
new Whisper.FileSizeToast({
|
var toast = new Whisper.FileSizeToast({
|
||||||
model: {limit: limitKb}
|
model: {limit: limitKb}
|
||||||
}).render();
|
});
|
||||||
|
toast.$el.insertAfter(this.$el);
|
||||||
|
toast.render();
|
||||||
this.deleteFiles();
|
this.deleteFiles();
|
||||||
}
|
}
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
this.$el.html(Mustache.render(this.template, this.model));
|
this.$el.html(Mustache.render(this.template, this.model));
|
||||||
this.$el.appendTo($('body')).show();
|
this.$el.show();
|
||||||
setTimeout(this.close.bind(this), 2000);
|
setTimeout(this.close.bind(this), 2000);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue