Skip to content

Commit

Permalink
Unify automatic marking as \Seen in preview pane, full-page and extwi…
Browse files Browse the repository at this point in the history
…n views (#5071)

We now have one 'mail_read_time' option that works for all cases.
Option 'preview_pane_mark_read' has been removed and marked as an alias.
  • Loading branch information
alecpl committed Nov 1, 2016
1 parent 04f2d13 commit 556c172
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 42 deletions.
6 changes: 3 additions & 3 deletions config/defaults.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -1073,9 +1073,9 @@
// 'list' - two columns, no preview
$config['layout'] = 'widescreen';

// Mark as read when viewed in preview pane (delay in seconds)
// Set to -1 if messages in preview pane should not be marked as read
$config['preview_pane_mark_read'] = 0;
// Mark as read when viewing a message (delay in seconds)
// Set to -1 if messages should not be marked as read
$config['mail_read_time'] = 0;

// Clear Trash on logout
$config['logout_purge'] = false;
Expand Down
27 changes: 11 additions & 16 deletions program/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,11 @@ function rcube_webmail()
this.display_message('', 'loading'));
}

if (this.env.mail_read_time > 0)
setTimeout(function() {
ref.http_post('mark', {_uid: ref.env.uid, _flag: 'read', _mbox: ref.env.mailbox, _quiet: 1});
}, this.env.mail_read_time * 1000);

if (this.env.blockedobjects) {
if (this.gui_objects.remoteobjectsmsg)
this.gui_objects.remoteobjectsmsg.style.display = 'block';
Expand Down Expand Up @@ -1612,8 +1617,6 @@ function rcube_webmail()

if (this.preview_timer)
clearTimeout(this.preview_timer);
if (this.preview_read_timer)
clearTimeout(this.preview_read_timer);

// prepare treelist widget for dragging interactions
if (this.treelist)
Expand Down Expand Up @@ -1807,8 +1810,6 @@ function rcube_webmail()
{
if (this.preview_timer)
clearTimeout(this.preview_timer);
if (this.preview_read_timer)
clearTimeout(this.preview_read_timer);

var selected = list.get_single_selection();

Expand Down Expand Up @@ -1852,8 +1853,6 @@ function rcube_webmail()
if (win && win.location.href.indexOf(this.env.blankpage) >= 0) {
if (this.preview_timer)
clearTimeout(this.preview_timer);
if (this.preview_read_timer)
clearTimeout(this.preview_read_timer);

this.preview_timer = setTimeout(function() { ref.msglist_get_preview(); }, this.dblclick_time);
}
Expand All @@ -1863,8 +1862,6 @@ function rcube_webmail()
{
if (this.preview_timer)
clearTimeout(this.preview_timer);
if (this.preview_read_timer)
clearTimeout(this.preview_read_timer);

var uid = list.get_single_selection();

Expand Down Expand Up @@ -2397,14 +2394,6 @@ function rcube_webmail()
this.open_window(url, true);
else
this.location_href(url, target, true);

// mark as read and change mbox unread counter
if (preview && this.message_list && this.message_list.rows[id] && this.message_list.rows[id].unread && this.env.preview_pane_mark_read > 0) {
this.preview_read_timer = setTimeout(function() {
ref.set_unread_message(id, ref.env.mailbox);
ref.http_post('mark', {_uid: id, _flag: 'read', _mbox: ref.env.mailbox, _quiet: 1});
}, this.env.preview_pane_mark_read * 1000);
}
}
};

Expand Down Expand Up @@ -8225,6 +8214,12 @@ function rcube_webmail()

// process the response data according to the sent action
switch (response.action) {
case 'mark':
// Mark the message as Seen also in the opener/parent
if ((this.env.action == 'show' || this.env.action == 'preview') && this.env.last_flag == 'SEEN')
this.set_unread_message(this.env.uid, this.env.mailbox);
break;

case 'delete':
if (this.task == 'addressbook') {
var sid, uid = this.contact_list.get_selection(), writable = false;
Expand Down
1 change: 1 addition & 0 deletions program/lib/Roundcube/rcube_config.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class rcube_config
'refresh_interval' => 'keep_alive',
'min_refresh_interval' => 'min_keep_alive',
'messages_cache_ttl' => 'message_cache_lifetime',
'mail_read_time' => 'preview_pane_mark_read',
'redundant_attachments_cache_ttl' => 'redundant_attachments_memcache_ttl',
);

Expand Down
1 change: 0 additions & 1 deletion program/steps/mail/func.inc
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ if (empty($RCMAIL->action) || $RCMAIL->action == 'list') {
$OUTPUT->set_env('threading', $threading);
$OUTPUT->set_env('threads', $threading || $RCMAIL->storage->get_capability('THREAD'));
$OUTPUT->set_env('reply_all_mode', (int) $RCMAIL->config->get('reply_all_mode'));
$OUTPUT->set_env('preview_pane_mark_read', (int) $RCMAIL->config->get('preview_pane_mark_read'));
$OUTPUT->set_env('layout', $RCMAIL->config->get('layout') ?: 'widescreen');

if ($RCMAIL->storage->get_capability('QUOTA')) {
Expand Down
2 changes: 2 additions & 0 deletions program/steps/mail/mark.inc
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ if (($_uids = rcube_utils::get_input_value('_uid', rcube_utils::INPUT_POST))
foreach (rcmail::get_uids() as $mbox => $uids) {
rcmail_send_unread_count($mbox);
}

$OUTPUT->set_env('last_flag', $flag);
}
else if ($flag == 'DELETED' && $skip_deleted) {
if ($_POST['_from'] == 'show') {
Expand Down
27 changes: 15 additions & 12 deletions program/steps/mail/show.inc
Original file line number Diff line number Diff line change
Expand Up @@ -129,18 +129,21 @@ if ($uid) {
}
}

if (empty($MESSAGE->headers->flags['SEEN'])
&& $MESSAGE->context === null
&& ($RCMAIL->action == 'show' || ($RCMAIL->action == 'preview' && intval($RCMAIL->config->get('preview_pane_mark_read')) == 0))
) {
$RCMAIL->output->command('set_unread_message', $MESSAGE->uid, $mbox_name);
$RCMAIL->plugins->exec_hook('message_read', array(
'uid' => $MESSAGE->uid,
'mailbox' => $mbox_name,
'message' => $MESSAGE,
));

$set_seen_flag = true;
if (empty($MESSAGE->headers->flags['SEEN']) && $MESSAGE->context === null) {
$v = intval($RCMAIL->config->get('mail_read_time'));
if ($v > 0) {
$OUTPUT->set_env('mail_read_time', $v);
}
else if ($v == 0) {
$RCMAIL->output->command('set_unread_message', $MESSAGE->uid, $mbox_name);
$RCMAIL->plugins->exec_hook('message_read', array(
'uid' => $MESSAGE->uid,
'mailbox' => $mbox_name,
'message' => $MESSAGE,
));

$set_seen_flag = true;
}
}
}

Expand Down
17 changes: 8 additions & 9 deletions program/steps/settings/func.inc
Original file line number Diff line number Diff line change
Expand Up @@ -408,30 +408,29 @@ function rcmail_user_prefs($current = null)
'advanced' => array('name' => rcube::Q($RCMAIL->gettext('advancedoptions'))),
);

// show config parameter for preview pane auto mark as read delay
if (!isset($no_override['preview_pane_mark_read'])) {
// show config parameter for auto marking the previewed message as read
if (!isset($no_override['mail_read_time'])) {
if (!$current) {
continue 2;
}

// apply default if config option is not set at all
$config['preview_pane_mark_read'] = $RCMAIL->config->get('preview_pane_mark_read', 0);
$config['mail_read_time'] = intval($RCMAIL->config->get('mail_read_time'));

$field_id = 'rcmfd_preview_pane_mark_read';
$select = new html_select(array('name' => '_preview_pane_mark_read', 'id' => $field_id,
'disabled' => $config['layout'] == 'list' ? 1 : 0));
$field_id = 'rcmfd_mail_read_time';
$select = new html_select(array('name' => '_mail_read_time', 'id' => $field_id));

$select->add($RCMAIL->gettext('never'), '-1');
$select->add($RCMAIL->gettext('never'), -1);
$select->add($RCMAIL->gettext('immediately'), 0);

foreach (array(5, 10, 20, 30) as $sec) {
$label = $RCMAIL->gettext(array('name' => 'afternseconds', 'vars' => array('n' => $sec)));
$select->add($label, $sec);
}

$blocks['main']['options']['preview_pane_mark_read'] = array(
$blocks['main']['options']['mail_read_time'] = array(
'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('previewpanemarkread'))),
'content' => $select->show(intval($config['preview_pane_mark_read'])),
'content' => $select->show($config['mail_read_time']),
);
}

Expand Down
2 changes: 1 addition & 1 deletion program/steps/settings/save_prefs.inc
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ case 'general':

case 'mailbox':
$a_user_prefs = array(
'preview_pane_mark_read' => isset($_POST['_preview_pane_mark_read']) ? intval($_POST['_preview_pane_mark_read']) : $CONFIG['preview_pane_mark_read'],
'mail_read_time' => isset($_POST['_mail_read_time']) ? intval($_POST['_mail_read_time']) : $CONFIG['mail_read_time'],
'autoexpand_threads' => isset($_POST['_autoexpand_threads']) ? intval($_POST['_autoexpand_threads']) : 0,
'mdn_requests' => isset($_POST['_mdn_requests']) ? intval($_POST['_mdn_requests']) : 0,
'check_all_folders' => isset($_POST['_check_all_folders']),
Expand Down

0 comments on commit 556c172

Please sign in to comment.