mirror of
https://github.com/oxen-io/session-desktop.git
synced 2023-12-14 02:12:57 +01:00
Update attachment size limits to match mobile clients
Per WhisperSystems/TextSecure@8a1428e, bump GIF limit to 5MB, and audio/video limit to 100MB. Update toast to notify in correct human-readable units. The only kB size limit is for images, and will trigger only if after scaling up to 4 times, the rescaled image did not come in under the size limit without unacceptable quality loss. Closes #354
This commit is contained in:
parent
b9b01330fe
commit
861bc416e6
2 changed files with 19 additions and 6 deletions
|
@ -135,7 +135,7 @@
|
|||
</script>
|
||||
<script type='text/x-tmpl-mustache' id='file-size-modal'>
|
||||
Sorry, the selected file exceeds message size
|
||||
restrictions. ({{ limit }}kB)
|
||||
restrictions. ({{ limit }}{{ units }})
|
||||
</script>
|
||||
<script type='text/x-tmpl-mustache' id='message-detail'>
|
||||
<div class='conversation-header'>
|
||||
|
|
|
@ -113,14 +113,27 @@
|
|||
|
||||
this.autoScale(file).then(function(blob) {
|
||||
var limitKb = 1000000;
|
||||
switch (type) {
|
||||
case 'image': limitKb = 420; break;
|
||||
case 'audio': limitKb = 32000; break;
|
||||
case 'video': limitKb = 8000; break;
|
||||
var blobType = file.type === 'image/gif' ? 'gif' : type;
|
||||
switch (blobType) {
|
||||
case 'image':
|
||||
limitKb = 420; break;
|
||||
case 'gif':
|
||||
limitKb = 5000; break;
|
||||
case 'audio':
|
||||
limitKb = 100000; break;
|
||||
case 'video':
|
||||
limitKb = 100000; break;
|
||||
}
|
||||
if ((blob.size/1024).toFixed(4) >= limitKb) {
|
||||
var units = ['kB','MB','GB'];
|
||||
var u = -1;
|
||||
var limit = limitKb * 1000;
|
||||
do {
|
||||
limit /= 1000;
|
||||
++u;
|
||||
} while (limit >= 1000 && u < units.length - 1);
|
||||
var toast = new Whisper.FileSizeToast({
|
||||
model: {limit: limitKb}
|
||||
model: {limit: limit, units: units[u]}
|
||||
});
|
||||
toast.$el.insertAfter(this.$el);
|
||||
toast.render();
|
||||
|
|
Loading…
Reference in a new issue