-$msg_count = $IMAP->messagecount();
-$pages = ceil($msg_count / $IMAP->page_size);
-$nextpage_count = $old_count - $IMAP->page_size * $IMAP->list_page;
-$remaining = $msg_count - $IMAP->page_size * ($IMAP->list_page - 1);
+if ($_POST['_from'] == 'show')
+{
+ if ($next = get_input_value('_next_uid', RCUBE_INPUT_GPC))
+ $OUTPUT->command('show_message', $next);
+ else
+ $OUTPUT->command('command', 'list');
+}
+else
+{
+ $msg_count = $IMAP->messagecount(NULL, $IMAP->threading ? 'THREADS' : 'ALL');
+ $pages = ceil($msg_count / $IMAP->page_size);
+ $nextpage_count = $old_count - $IMAP->page_size * $IMAP->list_page;
+ $remaining = $msg_count - $IMAP->page_size * ($IMAP->list_page - 1);