Add timestamps to attachment filenames
This commit is contained in:
parent
d2c1e6df27
commit
41216f1378
2 changed files with 13 additions and 4 deletions
|
@ -61,12 +61,15 @@
|
|||
Whisper.AttachmentView = Backbone.View.extend({
|
||||
tagName: 'span',
|
||||
className: 'attachment',
|
||||
initialize: function() {
|
||||
initialize: function(options) {
|
||||
this.blob = new Blob([this.model.data], {type: this.model.contentType});
|
||||
|
||||
var parts = this.model.contentType.split('/');
|
||||
this.contentType = parts[0];
|
||||
this.fileType = parts[1];
|
||||
if (options.timestamp) {
|
||||
this.timestamp = options.timestamp;
|
||||
}
|
||||
},
|
||||
events: {
|
||||
'click': 'onclick'
|
||||
|
@ -89,9 +92,12 @@
|
|||
},
|
||||
saveFile: function() {
|
||||
var blob = this.blob;
|
||||
var suggestedName;
|
||||
var suggestedName = 'signal';
|
||||
if (this.timestamp) {
|
||||
suggestedName += moment(this.timestamp).format('-YYYY-MM-DD-HHmmss');
|
||||
}
|
||||
if (this.fileType) {
|
||||
suggestedName = 'signal.' + this.fileType;
|
||||
suggestedName += '.' + this.fileType;
|
||||
}
|
||||
var w = extension.windows.getViews()[0];
|
||||
if (w && w.chrome && w.chrome.fileSystem) {
|
||||
|
|
|
@ -259,7 +259,10 @@
|
|||
},
|
||||
loadAttachments: function() {
|
||||
this.model.get('attachments').forEach(function(attachment) {
|
||||
var view = new Whisper.AttachmentView({ model: attachment });
|
||||
var view = new Whisper.AttachmentView({
|
||||
model: attachment,
|
||||
timestamp: this.model.get('sent_at')
|
||||
});
|
||||
this.listenTo(view, 'update', function() {
|
||||
if (!view.el.parentNode) {
|
||||
this.trigger('beforeChangeHeight');
|
||||
|
|
Loading…
Reference in a new issue