Updates to fix a bug when there is only one new email. Also updated to always clear...
[webos-internals:modifications.git] / email / email-delete-from-notification.patch
1 This patch adds the capability to delete email from the new email notification bar.
2
3 11-23-09:
4 Handle deletes better - now clear stage after every delete
5 Fix single-email-template for line that was to long aparently.
6
7 11-05-09:
8 Updated for 1.3.1
9 Moved trash can icon to right side
10 Index: /usr/palm/applications/com.palm.app.email/app/controllers/email-dashboard-assistant.js
11 ===================================================================
12 --- .orig/usr/palm/applications/com.palm.app.email/app/controllers/email-dashboard-assistant.js
13 +++ /usr/palm/applications/com.palm.app.email/app/controllers/email-dashboard-assistant.js
14 @@ -46,9 +46,17 @@ var EmailDashboardAssistant = Class.crea
15         tapHandler: function(event) {
16                 // Ignore additional taps in case the user is impatient
17                 var target = event.target;
18 +
19                 if (!target.hasClassName('email-dashboard-tap-target')) {
20                         target = target.up('div.email-dashboard-tap-target');
21                 }
22 +       
23 +               var tDelete = false;
24 +                       
25 +               //check to see if the trash icon was tapped
26 +               if ( target.hasClassName('email-dashboard-tap-target-delete')) {
27 +                       tDelete = true;
28 +               }
29  
30                 if (target) {
31                         var accountId = target.readAttribute('accountid');
32 @@ -56,9 +64,17 @@ var EmailDashboardAssistant = Class.crea
33                         if (accountId == "single") {
34                                 var folderId = target.readAttribute('folderid');
35                                 var messageId = target.readAttribute('messageid');
36 -                               this.showSingleMessage(accountId, folderId, messageId);
37 +       
38 +                               if(tDelete)
39 +                               {
40 +                                       this.deleteSingleMessage(accountId, folderId, messageId);
41 +                               }
42 +                               else
43 +                               {
44 +                                       this.showSingleMessage(accountId, folderId, messageId);
45 +                               }
46                         } else if (accountId == "all") {
47 -                               this.showAccount(); // just display the account scene
48 +                                       this.showAccount(); // just display the account scene
49                         } else {
50                                 this.showAccount(accountId);
51                         }
52 @@ -162,6 +178,47 @@ var EmailDashboardAssistant = Class.crea
53                         });
54         },
55  
56 +        
57 +       deleteSuccess: function(account, folder, message) {
58 +               //try to sync so that we get notified of the delete and the notification gets updated
59 +               Folder.syncFolder(folder, true);
60 +       },
61 +
62 +       deleteFailure: function(account, folder, message) {
63 +               //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
64 +       
65 +               //set the ignoreClear flag so that the new email timestamp doesnt get set
66 +               //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
67 +               this.ignoreClear = true;
68 +               this.notificationAssistant.closeEmailDashboard(this.notifications[0]);
69 +       
70 +               //try to sync the folder to get any updates
71 +               Folder.syncFolder(folder, true);        
72 +       },
73 +       
74 +       deleteSingleMessage: function(account, folder, message) {
75 +
76 +               var deleteReq = new Mojo.Service.Request('palm://com.palm.mail', {
77 +                       method: 'setDeleted',
78 +                       parameters: {'message':message, 'value': true },
79 +                       onSuccess: this.deleteSuccess.bind(this, account, folder, message),
80 +                       onFailure: this.deleteFailure.bind(this, account, folder, message)
81 +                       });
82 +
83 +               //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
84 +               //So lets try to send the delete twice.         
85 +//             var delet\87eReq = new Mojo.Service.Request('palm://com.palm.mail', {
86 +//                     method: 'setDeleted',
87 +//                     parameters: {'message':message, 'value': true },
88 +//                     onSuccess: this.deleteSuccess.bind(this, account, folder, message),
89 +//                     onFailure: this.deleteFailure.bind(this, account, folder, message)
90 +//                     });
91 +               
92 +               //Since we are not consistently getting the message back from the server that something was deleted so that the notification bar
93 +               //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
94 +               this.deleteFailure(account, folder, message);
95 +       },
96 +       
97         showFolder: function(accountId, folderId, resp) {
98                 var folderInfo = { folderId: folderId,
99                                    accountId: accountId,
100 Index: /usr/palm/applications/com.palm.app.email/app/views/email-dashboard/multiple-accounts-template.html
101 ===================================================================
102 --- .orig/usr/palm/applications/com.palm.app.email/app/views/email-dashboard/multiple-accounts-template.html
103 +++ /usr/palm/applications/com.palm.app.email/app/views/email-dashboard/multiple-accounts-template.html
104 @@ -5,7 +5,11 @@
105      </div>
106       <div class="palm-dashboard-icon email">
107       </div>
108 -  </div>   
109 +  </div> 
110 +  <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}">
111 +       <div class="palm-dashboard-icon delete">
112 +       </div>
113 +  </div>
114    <div class="palm-dashboard-text-container email-dashboard-tap-target" accountid="single" folderid="#{folder}" messageid="#{message}">
115       <div class="dashboard-title">
116        #{from}
117 Index: /usr/palm/applications/com.palm.app.email/app/views/email-dashboard/single-account-template.html
118 ===================================================================
119 --- .orig/usr/palm/applications/com.palm.app.email/app/views/email-dashboard/single-account-template.html
120 +++ /usr/palm/applications/com.palm.app.email/app/views/email-dashboard/single-account-template.html
121 @@ -5,6 +5,10 @@
122      </div>
123       <div class="palm-dashboard-icon #{accountDomain}">
124       </div>
125 +  </div> 
126 +  <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}">
127 +       <div class="palm-dashboard-icon delete">
128 +        </div>
129    </div>   
130    <div class="palm-dashboard-text-container email-dashboard-tap-target" accountid="single" folderid="#{folder}" messageid="#{message}">
131       <div class="dashboard-title">
132 Index: /usr/palm/applications/com.palm.app.email/app/views/email-dashboard/single-email-template.html
133 ===================================================================
134 --- .orig/usr/palm/applications/com.palm.app.email/app/views/email-dashboard/single-email-template.html
135 +++ /usr/palm/applications/com.palm.app.email/app/views/email-dashboard/single-email-template.html
136 @@ -1,8 +1,13 @@
137 -<div class="dashboard-notification-module single">
138 +<div class="dashboard-notification-module">
139    <div class="palm-dashboard-icon-container email-dashboard-tap-target" accountid="#{account}">
140       <div class="palm-dashboard-icon #{accountDomain}">
141       </div>
142    </div>   
143 +  <div class="palm-dashboard-icon-container email-dashboard-tap-target email-dashboard-tap-target-delete" style="float: right; margin-left: 4px;" 
144 +               accountid="single" folderid="#{folder}" messageid="#{message}">
145 +        <div class="palm-dashboard-icon delete">
146 +       </div>
147 +  </div>
148    <div class="palm-dashboard-text-container email-dashboard-tap-target" accountid="single" folderid="#{folder}" messageid="#{message}">
149       <div class="dashboard-title">
150        #{from}
151 Index: /usr/palm/applications/com.palm.app.email/stylesheets/notifications.css
152 ===================================================================
153 --- .orig/usr/palm/applications/com.palm.app.email/stylesheets/notifications.css
154 +++ /usr/palm/applications/com.palm.app.email/stylesheets/notifications.css
155 @@ -78,3 +78,9 @@ Copyright 2009 Palm, Inc.  All rights re
156  .palm-dashboard-icon.gmail                     { background: url(../images/notification-large-gmail.png) center left no-repeat; }
157  .palm-dashboard-icon.yahoo                     { background: url(../images/notification-large-yahoo.png) center left no-repeat; }
158  .palm-dashboard-icon.aol                       { background: url(../images/notification-large-aol.png) center left no-repeat; }
159 +
160 +/*To support delete of email from notification*/
161 +.palm-dashboard-icon.delete                        { background: url(../images/icon_trash.png) center center no-repeat; }
162 +
163 +.email-dashboard-tap-target-delete {
164 +}
165 Index: /usr/palm/applications/com.palm.app.email/app/controllers/notification-assistant.js
166 ===================================================================
167 --- .orig/usr/palm/applications/com.palm.app.email/app/controllers/notification-assistant.js
168 +++ /usr/palm/applications/com.palm.app.email/app/controllers/notification-assistant.js
169 @@ -20,7 +20,7 @@ var NotificationAssistant = Class.create
170                 // sending broadcast and dashboard updates when the user would see it because of the
171                 // scene he's in.
172                 this.filter = {};
173 -               this.newMailDeferralTimeout = 7;
174 +               this.newMailDeferralTimeout = 0;//7;
175         },
176  
177         windowBlurFocusHandler: function(event) {
178 @@ -157,8 +157,10 @@ var NotificationAssistant = Class.create
179  
180                         var folderObj;
181                         var listIndex;
182 +                       
183                         for (listIndex = 0; listIndex < resp.list.length; ++listIndex) {
184                                 folderObj = resp.list[listIndex];
185 +                               
186                                 if (this.shouldDoNotification(folderObj)) {
187                                         // Add to the UI model only if notify is set and the count shows there's items to add
188                                         if (folderObj.notify === true && folderObj.count > 0) {
189 @@ -168,6 +170,7 @@ var NotificationAssistant = Class.create
190                                         // Logic for sound: AccountpreferencesAssistant.kNotifyTypeAudio is highest
191                                         // priority and trumps all other sound types.
192                                         if (folderObj.hasNew === true && 
193 +
194                                             folderObj.playSound !== AccountpreferencesAssistant.kNotifyTypeNone &&
195                                             playSound !== AccountpreferencesAssistant.kNotifyTypeAudio) {
196  
197 @@ -636,10 +639,10 @@ var NotificationAssistant = Class.create
198                         // displayActive and displayDimmed
199                         if (data.event == 'displayOff') {
200                                 this.displayOff = true;
201 -                               this.newMailDeferralTimeout = 0.5;
202 +                               this.newMailDeferralTimeout = 0;//0.5;
203                         } else if (data.event == 'displayOn') {
204                                 this.displayOff = false;
205 -                               this.newMailDeferralTimeout = 7;
206 +                               this.newMailDeferralTimeout = 0;//7;
207                         }
208  
209                         Mojo.Log.info("displayUpdate displayOff", this.displayOff, "event", data.event);