6 new, 4 modified for 1.3.5
[webos-internals:djcin7s-modifications.git] / email / email-delete-from-notification.patch
1 diff --git a/usr/palm/applications/com.palm.app.email/app/controllers/email-dashboard-assistant.js b/usr/palm/applications/com.palm.app.email/app/controllers/email-dashboard-assistant.js
2 index 4431398..a1e3ca6 100644
3 --- a/usr/palm/applications/com.palm.app.email/app/controllers/email-dashboard-assistant.js
4 +++ b/usr/palm/applications/com.palm.app.email/app/controllers/email-dashboard-assistant.js
5 @@ -50,6 +50,13 @@ var EmailDashboardAssistant = Class.create({
6                         target = target.up('div.email-dashboard-tap-target');
7                 }
8  
9 +               var tDelete = false;
10 +                       
11 +               //check to see if the trash icon was tapped
12 +               if ( target.hasClassName('email-dashboard-tap-target-delete')) {
13 +                       tDelete = true;
14 +               }
15 +
16                 if (target) {
17                         // disable the tap event to prevent keep handling user's multiple taps
18                         if (!this.allInboxesOn) 
19 @@ -60,7 +67,15 @@ var EmailDashboardAssistant = Class.create({
20                         if (accountId == "single") {
21                                 var folderId = target.readAttribute('folderid');
22                                 var messageId = target.readAttribute('messageid');
23 +       
24 +                               if(tDelete)
25 +                               {
26 +                                       this.deleteSingleMessage(accountId, folderId, messageId);
27 +                               }
28 +                               else
29 +                               {
30                                 this.showSingleMessage(accountId, folderId, messageId);
31 +                               }
32                         } else if (accountId == "all") {
33                                 this.showAccount(); // just display the account scene
34                         } else {
35 @@ -170,6 +185,52 @@ var EmailDashboardAssistant = Class.create({
36                         });
37         },
38  
39 +       deleteSuccess: function(account, folder, message) {
40 +               //try to sync so that we get notified of the delete and the notification gets updated
41 +               Folder.syncFolder(folder, true);
42 +       },
43 +
44 +       deleteFailure: function(account, folder, message) {
45 +               //if we failed it is likely due to not getting the delete msg back from the server so we didnt remove the already deleted email notification
46 +       
47 +               //set the ignoreClear flag so that the new email timestamp doesnt get set
48 +               //this will allow for us to close the stage but when the next update comes through we will still have all the unread emails to work with
49 +               this.ignoreClear = true;
50 +               if (this.notificationAssistant.allInboxesOn) {
51 +                       this.notificationAssistant.closeEmailDashboard();
52 +               }
53 +               else
54 +               {
55 +                       this.notificationAssistant.closeEmailDashboard(this.notifications[0]);
56 +               }
57 +       
58 +               //try to sync the folder to get any updates
59 +               Folder.syncFolder(folder, true);        
60 +       },
61 +       
62 +       deleteSingleMessage: function(account, folder, message) {
63 +
64 +               var deleteReq = new Mojo.Service.Request('palm://com.palm.mail', {
65 +                       method: 'setDeleted',
66 +                       parameters: {'message':message, 'value': true },
67 +                       onSuccess: this.deleteSuccess.bind(this, account, folder, message),
68 +                       onFailure: this.deleteFailure.bind(this, account, folder, message)
69 +                       });
70 +
71 +               //So should not need to do this but many have reported the emails not deleting due to issues with synchronization after 1.3.1 update
72 +               //So lets try to send the delete twice.         
73 +//             var delet\87eReq = new Mojo.Service.Request('palm://com.palm.mail', {
74 +//                     method: 'setDeleted',
75 +//                     parameters: {'message':message, 'value': true },
76 +//                     onSuccess: this.deleteSuccess.bind(this, account, folder, message),
77 +//                     onFailure: this.deleteFailure.bind(this, account, folder, message)
78 +//                     });
79 +               
80 +               //Since we are not consistently getting the message back from the server that something was deleted so that the notification bar
81 +               //gets updated go ahead and close it if we get the message the notification bar will come back up. Truly sucks that it doesnt always give us the update
82 +               this.deleteFailure(account, folder, message);
83 +       },
84 +       
85         showFolder: function(accountId, folderId, resp) {
86                 this.notificationAssistant.setFolderViewedTimestamp(folderId, new Date().getTime());
87                 this.notificationAssistant.clearAccount(accountId, folderId);
88 diff --git a/usr/palm/applications/com.palm.app.email/app/controllers/notification-assistant.js b/usr/palm/applications/com.palm.app.email/app/controllers/notification-assistant.js
89 index 7f52bdd..8f1cd02 100644
90 --- a/usr/palm/applications/com.palm.app.email/app/controllers/notification-assistant.js
91 +++ b/usr/palm/applications/com.palm.app.email/app/controllers/notification-assistant.js
92 @@ -20,7 +20,7 @@ var NotificationAssistant = Class.create({
93                 // sending broadcast and dashboard updates when the user would see it because of the
94                 // scene he's in.
95                 this.filter = {};
96 -               this.newMailDeferralTimeout = 7;
97 +               this.newMailDeferralTimeout = 0;//7;
98         },
99  
100         windowBlurFocusHandler: function(event) {
101 @@ -234,8 +234,10 @@ var NotificationAssistant = Class.create({
102  
103                         var folderObj;
104                         var listIndex;
105 +                       
106                         for (listIndex = 0; listIndex < resp.list.length; ++listIndex) {
107                                 folderObj = resp.list[listIndex];
108 +                               
109                                 if (this.shouldDoNotification(folderObj)) {
110                                         // Add to the UI model only if notify is set and the count shows there's items to add
111                                         if (folderObj.notify === true && folderObj.count > 0) {
112 @@ -245,6 +247,7 @@ var NotificationAssistant = Class.create({
113                                         // Logic for sound: AccountpreferencesAssistant.kNotifyTypeAudio is highest
114                                         // priority and trumps all other sound types.
115                                         if (folderObj.hasNew === true && 
116 +
117                                             folderObj.playSound !== AccountpreferencesAssistant.kNotifyTypeNone &&
118                                             playSound !== AccountpreferencesAssistant.kNotifyTypeAudio) {
119  
120 @@ -640,10 +643,10 @@ var NotificationAssistant = Class.create({
121                         // displayActive and displayDimmed
122                         if (data.event == 'displayOff') {
123                                 this.displayOff = true;
124 -                               this.newMailDeferralTimeout = 0.5;
125 +                               this.newMailDeferralTimeout = 0;//0.5;
126                         } else if (data.event == 'displayOn') {
127                                 this.displayOff = false;
128 -                               this.newMailDeferralTimeout = 7;
129 +                               this.newMailDeferralTimeout = 0;//7;
130                         }
131  
132                         Mojo.Log.info("displayUpdate displayOff", this.displayOff, "event", data.event);
133 diff --git a/usr/palm/applications/com.palm.app.email/app/views/email-dashboard/multiple-accounts-template.html b/usr/palm/applications/com.palm.app.email/app/views/email-dashboard/multiple-accounts-template.html
134 index 38c8b71..21889dd 100644
135 --- a/usr/palm/applications/com.palm.app.email/app/views/email-dashboard/multiple-accounts-template.html
136 +++ b/usr/palm/applications/com.palm.app.email/app/views/email-dashboard/multiple-accounts-template.html
137 @@ -6,6 +6,10 @@
138       <div class="palm-dashboard-icon email">
139       </div>
140    </div>   
141 +  <div class="palm-dashboard-icon-container email-dashboard-tap-target email-dashboard-tap-target-delete" style="float: right; margin-left: 4px;" accountid="single" folderid="#{folder}" messageid="#{message}">
142 +       <div class="palm-dashboard-icon delete">
143 +       </div>
144 +  </div>
145    <div class="palm-dashboard-text-container email-dashboard-tap-target" accountid="single" folderid="#{folder}" messageid="#{message}">
146       <div class="dashboard-title">
147        #{from}
148 diff --git a/usr/palm/applications/com.palm.app.email/app/views/email-dashboard/single-account-template.html b/usr/palm/applications/com.palm.app.email/app/views/email-dashboard/single-account-template.html
149 index 31a4683..24e0858 100644
150 --- a/usr/palm/applications/com.palm.app.email/app/views/email-dashboard/single-account-template.html
151 +++ b/usr/palm/applications/com.palm.app.email/app/views/email-dashboard/single-account-template.html
152 @@ -6,6 +6,10 @@
153       <div class="palm-dashboard-icon #{accountDomain}">
154       </div>
155    </div>   
156 +  <div class="palm-dashboard-icon-container email-dashboard-tap-target email-dashboard-tap-target-delete" style="float: right; margin-left: 4px;" accountid="single" folderid="#{folder}" messageid="#{message}">
157 +       <div class="palm-dashboard-icon delete">
158 +        </div>
159 +  </div>   
160    <div class="palm-dashboard-text-container email-dashboard-tap-target" accountid="single" folderid="#{folder}" messageid="#{message}">
161       <div class="dashboard-title">
162        #{from}
163 diff --git a/usr/palm/applications/com.palm.app.email/app/views/email-dashboard/single-email-template.html b/usr/palm/applications/com.palm.app.email/app/views/email-dashboard/single-email-template.html
164 index 0eca342..a474aee 100644
165 --- a/usr/palm/applications/com.palm.app.email/app/views/email-dashboard/single-email-template.html
166 +++ b/usr/palm/applications/com.palm.app.email/app/views/email-dashboard/single-email-template.html
167 @@ -1,8 +1,13 @@
168 -<div class="dashboard-notification-module single">
169 +<div class="dashboard-notification-module">
170    <div class="palm-dashboard-icon-container email-dashboard-tap-target" accountid="#{account}">
171       <div class="palm-dashboard-icon #{accountDomain}">
172       </div>
173    </div>   
174 +  <div class="palm-dashboard-icon-container email-dashboard-tap-target email-dashboard-tap-target-delete" style="float: right; margin-left: 4px;" 
175 +               accountid="single" folderid="#{folder}" messageid="#{message}">
176 +        <div class="palm-dashboard-icon delete">
177 +       </div>
178 +  </div>
179    <div class="palm-dashboard-text-container email-dashboard-tap-target" accountid="single" folderid="#{folder}" messageid="#{message}">
180       <div class="dashboard-title">
181        #{from}
182 diff --git a/usr/palm/applications/com.palm.app.email/stylesheets/notifications.css b/usr/palm/applications/com.palm.app.email/stylesheets/notifications.css
183 index 5ba21eb..ecc6aef 100644
184 --- a/usr/palm/applications/com.palm.app.email/stylesheets/notifications.css
185 +++ b/usr/palm/applications/com.palm.app.email/stylesheets/notifications.css
186 @@ -78,3 +78,9 @@ Copyright 2009 Palm, Inc.  All rights reserved.
187  .palm-dashboard-icon.gmail                     { background: url(../images/notification-large-gmail.png) center left no-repeat; }
188  .palm-dashboard-icon.yahoo                     { background: url(../images/notification-large-yahoo.png) center left no-repeat; }
189  .palm-dashboard-icon.aol                       { background: url(../images/notification-large-aol.png) center left no-repeat; }
190 +
191 +/*To support delete of email from notification*/
192 +.palm-dashboard-icon.delete                        { background: url(../images/icon_trash.png) center center no-repeat; }
193 +
194 +.email-dashboard-tap-target-delete {
195 +}