Patch Email DeleteAll

From WebOS Internals
Revision as of 04:57, 14 August 2009 by Mamouton (talk | contribs)
Jump to navigation Jump to search

This will add a button at the bottom of the screen with a trashcan icon between the Compose and Refresh buttons. Selecting the button will delete all email items in the list after prompting the user for confirmation.

I am deliberately not using line numbers to minimize the need for updates as new WebOS releases come out.



Find the setup function and modify the cmdMenuModel items, replace the



{label:$L('Delete All'), icon:'delete', command:'deleteall'},

Find the handleCommand function and add the following case statement:

case 'deleteall':

Now add the following three functions:

  handleDeleteAllResponse: function (event) {
        //check to see if there are more items to delete.

  deleteAll: function(){
  	var count = this.emailListElement.mojo.getLength();

	var id;

	if(count > 0) 
		var item = this.emailListElement.mojo.getNodeByIndex(0);	
		if(item !== undefined)
		   id =;
			this.controller.serviceRequest(Email.identifier, {
			        	method: 'setDeleted',
			                parameters: {'message':id, 'value': true },
			                onSuccess: this.handleDeleteAllResponse.bind(this),
			                onFailure: this.handleDeleteAllResponse.bind(this)
		}//if item !== undefined
			//item was undefined probably because it is currently marked for delete
	}//count > 0

  handleDeleteAll: function (event) {
	var totalCount = 0;
	totalCount = this.emailListElement.mojo.getLength();
                             onChoose: function(value) {
  	                              		if(value == 'yes') {
							//Delete all items in this folder
	                                	title: '<b>' + $L('Delete All') + '</b>',
                      				message: $L('Are you sure you want to delte all ') + "<b>" + totalCount + "</b>" + $L(' items in this folder?'),
                       				choices: [
                               				{label:$L('Yes'), value:'yes', type:'affirmative'},
                                    			{label:$L('No'), value:'no', type:'alert'}

Is there a way to select a certain number of messages and then delete those versus all those on the page?