From e79b95af3f93c4c47aded1ebd93d74aca3ff7923 Mon Sep 17 00:00:00 2001 From: quenenni Date: Sat, 6 Apr 2013 22:40:40 +0200 Subject: [PATCH] bug fixed in case several emails subscribed for same pad & authorId --- static/js/ep_email.js | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/static/js/ep_email.js b/static/js/ep_email.js index 487a973..686e592 100644 --- a/static/js/ep_email.js +++ b/static/js/ep_email.js @@ -101,17 +101,21 @@ exports.handleClientMessage_emailUnsubscriptionSuccess = function(hook, context) exports.handleClientMessage_emailNotificationGetUserInfo = function (hook, context) { // return the existing options for this userId var result = context.payload; - if(result.success == true){ // If data found, set the options with them - $('[name=ep_email]').val(result.email); - $('[name=ep_email_onStart]').prop('checked', result.onStart); - $('[name=ep_email_onEnd]').prop('checked', result.onEnd); - } else { // No data found, set the options to default values - $('[name=ep_email_onStart]').prop('checked', true); - $('[name=ep_email_onEnd]').prop('checked', false); - } - if (result.formName == 'ep_email_form_mysettings') { - $('.ep_email_settings').slideToggle(); + // Only use first data from the server. (case when 2 emails subscribed for the same pad & authorId) + if ($('.ep_email_settings').is(':visible') == false) { + if(result.success == true){ // If data found, set the options with them + $('[name=ep_email]').val(result.email); + $('[name=ep_email_onStart]').prop('checked', result.onStart); + $('[name=ep_email_onEnd]').prop('checked', result.onEnd); + } else { // No data found, set the options to default values + $('[name=ep_email_onStart]').prop('checked', true); + $('[name=ep_email_onEnd]').prop('checked', false); + } + + if (result.formName == 'ep_email_form_mysettings') { + $('.ep_email_settings').slideToggle(); + } } }