Skip to content

Commit

Permalink
Fixed Composer autosave buggo I made
Browse files Browse the repository at this point in the history
  • Loading branch information
bnvk committed Oct 17, 2014
1 parent f121267 commit 9b09959
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
5 changes: 4 additions & 1 deletion static/default/html/jsapi/compose/autosave.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
Mailpile.compose_autosave = function(mid, form_data) {

// Text is different, run autosave
// Should test against model
if ($('#compose-text-' + mid).val() !== Mailpile.messages_composing['compose-text-' + mid]) {

// UI Feedback
var autosave_msg = $('#compose-message-autosaving-' + mid).data('autosave_msg');
$('#compose-message-autosaving-' + mid).html(autosave_msg).fadeIn();

//
// Autosave It
$.ajax({
url : Mailpile.api.compose_save,
type : 'POST',
Expand All @@ -31,6 +32,8 @@ Mailpile.compose_autosave = function(mid, form_data) {
}
});
}
// Not Autosaving
else { }
};


Expand Down
9 changes: 1 addition & 8 deletions static/default/html/jsapi/compose/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,7 @@ Mailpile.compose_init = function(mid) {


// Save Text Composing Objects (move to data model)
Mailpile.messages_composing['compose-text-' + mid] = $('compose-text-' + mid).val();


// Run Autosave
// FIXME: this should be moved to the global event loop
Mailpile.compose_autosave_timer.play();
Mailpile.compose_autosave_timer.set({ time : 20000, autostart : true });
Mailpile.messages_composing['compose-text-' + mid] = $('#compose-text-' + mid).val();


// Initialize Attachments
Expand All @@ -33,7 +27,6 @@ Mailpile.compose_init = function(mid) {
mid: mid
});


// Show Crypto Tooltips
Mailpile.tooltip_compose_crypto_signature();
Mailpile.tooltip_compose_crypto_encryption();
Expand Down
9 changes: 8 additions & 1 deletion static/default/html/jsapi/index-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,18 @@ $(document).ready(function() {
//EventLog.init();
setTimeout(function() {

// make event log start async (e.g. for proper page load event handling)
EventLog.timer = $.timer();
EventLog.timer.set({ time : 22500, autostart : false });
// make event log start async (e.g. for proper page load event handling)
EventLog.poll();

// Run Composer Autosave
if (Mailpile.instance.state.context_url === '/message/' ||
Mailpile.instance.state.context_url === '/message/draft/') {
Mailpile.compose_autosave_timer.play();
Mailpile.compose_autosave_timer.set({ time : 20000, autostart : true });
}

}, 1000);

});
Expand Down

0 comments on commit 9b09959

Please sign in to comment.