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({
|
Whisper.AttachmentView = Backbone.View.extend({
|
||||||
tagName: 'span',
|
tagName: 'span',
|
||||||
className: 'attachment',
|
className: 'attachment',
|
||||||
initialize: function() {
|
initialize: function(options) {
|
||||||
this.blob = new Blob([this.model.data], {type: this.model.contentType});
|
this.blob = new Blob([this.model.data], {type: this.model.contentType});
|
||||||
|
|
||||||
var parts = this.model.contentType.split('/');
|
var parts = this.model.contentType.split('/');
|
||||||
this.contentType = parts[0];
|
this.contentType = parts[0];
|
||||||
this.fileType = parts[1];
|
this.fileType = parts[1];
|
||||||
|
if (options.timestamp) {
|
||||||
|
this.timestamp = options.timestamp;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
events: {
|
events: {
|
||||||
'click': 'onclick'
|
'click': 'onclick'
|
||||||
|
@ -89,9 +92,12 @@
|
||||||
},
|
},
|
||||||
saveFile: function() {
|
saveFile: function() {
|
||||||
var blob = this.blob;
|
var blob = this.blob;
|
||||||
var suggestedName;
|
var suggestedName = 'signal';
|
||||||
|
if (this.timestamp) {
|
||||||
|
suggestedName += moment(this.timestamp).format('-YYYY-MM-DD-HHmmss');
|
||||||
|
}
|
||||||
if (this.fileType) {
|
if (this.fileType) {
|
||||||
suggestedName = 'signal.' + this.fileType;
|
suggestedName += '.' + this.fileType;
|
||||||
}
|
}
|
||||||
var w = extension.windows.getViews()[0];
|
var w = extension.windows.getViews()[0];
|
||||||
if (w && w.chrome && w.chrome.fileSystem) {
|
if (w && w.chrome && w.chrome.fileSystem) {
|
||||||
|
|
|
@ -259,7 +259,10 @@
|
||||||
},
|
},
|
||||||
loadAttachments: function() {
|
loadAttachments: function() {
|
||||||
this.model.get('attachments').forEach(function(attachment) {
|
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() {
|
this.listenTo(view, 'update', function() {
|
||||||
if (!view.el.parentNode) {
|
if (!view.el.parentNode) {
|
||||||
this.trigger('beforeChangeHeight');
|
this.trigger('beforeChangeHeight');
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue