sort combined private mail conversations by latest updated conversation instead of created parent

This commit is contained in:
Mario Vavti 2017-11-13 22:01:37 +01:00
parent 5dad444026
commit c8dbcf8a2a
2 changed files with 8 additions and 9 deletions

View File

@ -28,6 +28,8 @@ class Conversations {
require_once('include/message.php'); require_once('include/message.php');
$o = '';
// private_messages_list() can do other more complicated stuff, for now keep it simple // private_messages_list() can do other more complicated stuff, for now keep it simple
$r = private_messages_list(local_channel(), $mailbox, \App::$pager['start'], \App::$pager['itemspage']); $r = private_messages_list(local_channel(), $mailbox, \App::$pager['start'], \App::$pager['itemspage']);
@ -36,13 +38,13 @@ class Conversations {
return $o; return $o;
} }
$messages = array(); $messages = [];
foreach($r as $rr) { foreach($r as $rr) {
$selected = ((argc() == 3) ? intval(argv(2)) == intval($rr['id']) : $r[0]['id'] == $rr['id']); $selected = ((argc() == 3) ? intval(argv(2)) == intval($rr['id']) : $r[0]['id'] == $rr['id']);
$messages[] = array( $messages[] = [
'mailbox' => $mailbox, 'mailbox' => $mailbox,
'id' => $rr['id'], 'id' => $rr['id'],
'from_name' => $rr['from']['xchan_name'], 'from_name' => $rr['from']['xchan_name'],
@ -57,14 +59,14 @@ class Conversations {
'date' => datetime_convert('UTC',date_default_timezone_get(),$rr['created'], 'c'), 'date' => datetime_convert('UTC',date_default_timezone_get(),$rr['created'], 'c'),
'seen' => $rr['seen'], 'seen' => $rr['seen'],
'selected' => ((argv(1) != 'new') ? $selected : '') 'selected' => ((argv(1) != 'new') ? $selected : '')
); ];
} }
$tpl = get_markup_template('mail_head.tpl'); $tpl = get_markup_template('mail_head.tpl');
$o .= replace_macros($tpl, array( $o .= replace_macros($tpl, [
'$header' => $header, '$header' => $header,
'$messages' => $messages '$messages' => $messages
)); ]);
} }
return $o; return $o;

View File

@ -335,12 +335,9 @@ function private_messages_list($uid, $mailbox = '', $start = 0, $numitems = 0) {
case 'combined': case 'combined':
default: default:
$parents = q("SELECT mail.parent_mid FROM mail LEFT JOIN conv ON mail.conv_guid = conv.guid WHERE mail.mid = mail.parent_mid AND mail.channel_id = %d ORDER BY conv.updated DESC $limit",
$parents = q("SELECT parent_mid FROM mail WHERE mid = parent_mid AND channel_id = %d ORDER BY created DESC",
dbesc($local_channel) dbesc($local_channel)
); );
//FIXME: We need the latest mail of a thread here. This query throws errors in postgres. We now look for the latest in php until somebody can fix this...
//$sql = "SELECT * FROM ( SELECT * FROM mail WHERE channel_id = $local_channel ORDER BY created DESC $limit ) AS temp_table GROUP BY parent_mid ORDER BY created DESC";
break; break;
} }