Roundcube Community Forum

 

Need undelete functionality

Started by Melen, December 07, 2007, 12:04:47 PM

Previous topic - Next topic

Melen

Hi all,

We've recently installed 0.1-RC2. We are not using the trash folder (trash_mbox is blank). We use flag_for_deletion.

Other than the known problem of the delete button not working in message view, there doesn't seem to be a way to undelete messages. Selecting a message marked for deletion and hitting the delete key on the keyboard does nothing (except, apparently, mark it as deleted again). Selecting the message and clicking the delete icon also doesn't seem to work.

It's odd because I see mention of code to handle undeleting and I'm not seeing any complaints. Help?

-Melen

Melen

Just so everyone knows, I've done this so far:

1) First, I've figured out that clicking on the tiny icons next to the subject suffices to remove the delete flag, at least as far as I can tell
2) I've modified app.js slightly to make the delete button a toggle. In the delete_messages function I've changed:

 
   else if (!this.env.trash_mailbox && this.env.flag_for_deletion)
   {
    this.mark_message('delete');

   if(this.env.action=="show")
    this.command('nextmessage','',this);
   else if (selection.length == 1)
    this.message_list.select_next();
   }

to

 
   else if (!this.env.trash_mailbox && this.env.flag_for_deletion)
   {
    if (this.message_list.rows[uid].deleted) {
        this.mark_message('undelete');
    } else {
        this.mark_message('delete');
    }
   if(this.env.action=="show")
    this.command('nextmessage','',this);
   else if (selection.length == 1)
    this.message_list.select_next();
   }

Not sure if that's the best way to accomplish this, but this was a major issue for us.

Next problem... What can be done to make the delete button on message view work?

Melen

I was sort of hoping for some "official" word on this stuff, but oh well. Here's what I have, which additionally makes the delete button in message view work as well:

   var uid = this.get_single_uid();
    if (selection.length==1) {
        if (this.message_list.rows[uid].deleted) {
            this.mark_message('undelete');
        } else {
            this.mark_message('delete');
        }
    } else if (selection.length==0) {
        this.display_message('Message marked for deletion','error');
        this.http_post('mark', '_uid='+uid+'&_flag=delete');
    } else {
        var a_uids = new Array();
        var selection2 = this.message_list.get_selection();
        var id;
        for (var n=0; n<selection2.length; n++) {
            id = selection2[n];
            a_uids[a_uids.length] = id;
        }
        this.toggle_delete_status(a_uids);
    }

Probably could be cleaner. But it seems to work. I also had to comment out a couple of lines that move to the next message:

  //if(this.env.action=="show")
   // this.command('nextmessage','',this);
   //else if (selection.length == 1)
    if (selection.length == 1)
    this.message_list.select_next();

This was because it was redirecting to the next message too quickly and the mark for deletion wasn't even getting a chance to complete.

No idea, in the message view context, how to check message flags unfortunately, so I don't know yet how to make the delete button a toggle.

-Melen