Skip to content

Commit

Permalink
add All Snoozed button and Icon to left menu
Browse files Browse the repository at this point in the history
  • Loading branch information
DKing2222 committed Nov 21, 2024
1 parent b5b97f5 commit 2795955
Show file tree
Hide file tree
Showing 12 changed files with 134 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ DEFAULT_SETTING_SENT_PER_SOURCE=20
DEFAULT_SETTING_SENT_SINCE='-1 week'
DEFAULT_SETTING_JUNK_PER_SOURCE=20
DEFAULT_SETTING_JUNK_SINCE='-1 week'
DEFAULT_SETTING_SNOOZED_PER_SOURCE=20
DEFAULT_SETTING_SNOOZED_SINCE='-1 week'
DEFAULT_SETTING_TAGS_PER_SOURCE=20
DEFAULT_SETTING_TAGS_SINCE='-1 week'
DEFAULT_SETTING_TRASH_PER_SOURCE=20
Expand Down
14 changes: 14 additions & 0 deletions config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -1053,6 +1053,20 @@
*/
'default_setting_junk_per_source' => env('DEFAULT_SETTING_JUNK_PER_SOURCE', 20),

/*
|
| Per source time limit for snoozed page
| Defaults to 1 week
*/
'default_setting_snoozed_since' => env('DEFAULT_SETTING_SNOOZED_SINCE', '-1 week'),

/*
|
| Per source number limit for snoozed page
| Defaults 20
*/
'default_setting_snoozed_per_source' => env('DEFAULT_SETTING_SNOOZED_PER_SOURCE', 20),

/*
|
| Per source time limit for tags page
Expand Down
2 changes: 2 additions & 0 deletions lib/environment.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ public function define_default_constants($config) {
define('DEFAULT_IMAP_PER_PAGE', $config->get('default_setting_imap_per_page', 20));
define('DEFAULT_JUNK_SINCE', $config->get('default_setting_junk_since', '-1 week'));
define('DEFAULT_JUNK_PER_SOURCE', $config->get('default_setting_junk_per_source', 20));
define('DEFAULT_SNOOZED_SINCE', $config->get('default_setting_snoozed_since', '-1 week'));
define('DEFAULT_SNOOZED_PER_SOURCE', $config->get('default_setting_snoozed_per_source', 20));
define('DEFAULT_TAGS_SINCE', $config->get('default_setting_tags_since', '-1 week'));
define('DEFAULT_TAGS_PER_SOURCE', $config->get('default_setting_tags_per_source', 20));
define('DEFAULT_TRASH_SINCE', $config->get('default_setting_trash_since', '-1 week'));
Expand Down
26 changes: 26 additions & 0 deletions modules/core/handler_modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,32 @@ public function process() {
}
}

/**
* Process input from the max per source setting for the Snoozed page in the settings page
* @subpackage core/handler
*/
class Hm_Handler_process_snoozed_source_max_setting extends Hm_Handler_Module {
/**
* Allowed values are greater than zero and less than MAX_PER_SOURCE
*/
public function process() {
process_site_setting('snoozed_per_source', $this, 'max_source_setting_callback', DEFAULT_SNOOZED_PER_SOURCE);
}
}

/**
* Process "since" setting for the Snoozed page in the settings page
* @subpackage core/handler
*/
class Hm_Handler_process_snoozed_since_setting extends Hm_Handler_Module {
/**
* valid values are defined in the process_since_argument function
*/
public function process() {
process_site_setting('snoozed_since', $this, 'since_setting_callback', DEFAULT_SNOOZED_SINCE);
}
}

/**
* Process "since" setting for the Everything page in the settings page
* @subpackage core/handler
Expand Down
6 changes: 6 additions & 0 deletions modules/core/message_list_functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ function get_message_list_settings($path, $handler) {
$per_source_limit = $handler->user_config->get('junk_per_source_setting', DEFAULT_JUNK_PER_SOURCE);
$mailbox_list_title = array('Junk');
}
elseif ($path == 'snoozed') {
$list_path = 'snoozed';
$message_list_since = $handler->user_config->get('snoozed_since_setting', DEFAULT_SNOOZED_SINCE);
$per_source_limit = $handler->user_config->get('snoozed_per_source_setting', DEFAULT_SNOOZED_PER_SOURCE);
$mailbox_list_title = array('Snoozed');
}
elseif ($path == 'trash') {
$list_path = 'trash';
$message_list_since = $handler->user_config->get('trash_since_setting', DEFAULT_TRASH_SINCE);
Expand Down
62 changes: 61 additions & 1 deletion modules/core/output_modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -1384,6 +1384,11 @@ protected function output() {
$res .= '<i class="bi bi-pencil-square menu-icon"></i>';
}
$res .= '<span class="nav-label">'.$this->trans('Drafts').'</span></a></li>';
$res .= '<li class="menu_snoozed"><a class="unread_link" href="?page=message_list&amp;list_path=snoozed">';
if (!$this->get('hide_folder_icons')) {
$res .= '<i class="bi bi-clock-fill menu-icon"></i>';
}
$res .= '<span class="nav-label">'.$this->trans('Snoozed').'</span></a></li>';

if ($this->format == 'HTML5') {
return $res;
Expand Down Expand Up @@ -2146,7 +2151,62 @@ protected function output() {
'<td>'.message_since_dropdown($since, 'trash_since', $this, DEFAULT_TRASH_SINCE).'</td></tr>';
}
}

/**
* Starts the Snoozed section on the settings page
* @subpackage core/output
*/
class Hm_Output_start_snoozed_settings extends Hm_Output_Module {
/**
* Settings in this section control the snoozed messages view
*/
protected function output() {
return '<tr><td data-target=".snoozed_setting" colspan="2" class="settings_subtitle cursor-pointer border-bottom p-2">'.
'<i class="bi bi-clock-fill fs-5 me-2"></i>'.
$this->trans('Snoozed').'</td></tr>';
}
}
/**
* Option for the maximum number of messages per source for the Snoozed page
* @subpackage core/output
*/
class Hm_Output_snoozed_source_max_setting extends Hm_Output_Module {
/**
* Processed by Hm_Handler_process_snoozed_source_max_setting
*/
protected function output() {
$sources = DEFAULT_SNOOZED_PER_SOURCE;
$settings = $this->get('user_settings', array());
$reset = '';
if (array_key_exists('snoozed_per_source', $settings)) {
$sources = $settings['snoozed_per_source'];
}
if ($sources != DEFAULT_SNOOZED_PER_SOURCE) {
$reset = '<span class="tooltip_restore" restore_aria_label="Restore default value"><i class="bi bi-arrow-repeat refresh_list reset_default_value_input"></i></span>';
}
return '<tr class="snoozed_setting"><td><label for="snoozed_per_source">'.
$this->trans('Max messages per source for Snoozed').'</label></td>' .
'<td class="d-flex"><input class="form-control form-control-sm w-auto" type="text" size="2" id="snoozed_per_source" name="snoozed_per_source" value="'.$this->html_safe($sources).'" data-default-value="'.DEFAULT_SNOOZED_PER_SOURCE.'" />'.$reset.'</td></tr>';
}
}
/**
* Option for the snoozed messages date range
* @subpackage core/output
*/
class Hm_Output_snoozed_since_setting extends Hm_Output_Module {
/**
* Processed by Hm_Handler_process_snoozed_since_setting
*/
protected function output() {
$since = DEFAULT_SNOOZED_SINCE;
$settings = $this->get('user_settings', array());
if (array_key_exists('snoozed_since', $settings) && $settings['snoozed_since']) {
$since = $settings['snoozed_since'];
}
return '<tr class="snoozed_setting"><td><label for="snoozed_since">'.
$this->trans('Show snoozed messages since').'</label></td>'.
'<td>'.message_since_dropdown($since, 'snoozed_since', $this, DEFAULT_SNOOZED_SINCE).'</td></tr>';
}
}
/**
* Starts the Draft section on the settings page
* @subpackage core/output
Expand Down
9 changes: 8 additions & 1 deletion modules/core/setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
add_handler('settings', 'process_all_email_source_max_setting', true, 'core', 'date', 'after');
add_handler('settings', 'process_junk_since_setting', true, 'core', 'date', 'after');
add_handler('settings', 'process_junk_source_max_setting', true, 'core', 'date', 'after');
add_handler('settings', 'process_snoozed_since_setting', true, 'core', 'date', 'after');
add_handler('settings', 'process_snoozed_source_max_setting', true, 'core', 'date', 'after');
add_handler('settings', 'process_trash_since_setting', true, 'core', 'date', 'after');
add_handler('settings', 'process_trash_source_max_setting', true, 'core', 'date', 'after');
add_handler('settings', 'process_drafts_since_setting', true, 'core', 'date', 'after');
Expand Down Expand Up @@ -89,7 +91,10 @@
add_output('settings', 'start_junk_settings', true, 'core', 'flagged_source_max_setting', 'after');
add_output('settings', 'junk_since_setting', true, 'core', 'start_junk_settings', 'after');
add_output('settings', 'junk_source_max_setting', true, 'core', 'junk_since_setting', 'after');
add_output('settings', 'start_trash_settings', true, 'core', 'junk_source_max_setting', 'after');
add_output('settings', 'start_snoozed_settings', true, 'core', 'junk_source_max_setting', 'after');
add_output('settings', 'snoozed_since_setting', true, 'core', 'start_snoozed_settings', 'after');
add_output('settings', 'snoozed_source_max_setting', true, 'core', 'snoozed_since_setting', 'after');
add_output('settings', 'start_trash_settings', true, 'core', 'snoozed_source_max_setting', 'after');
add_output('settings', 'trash_since_setting', true, 'core', 'start_trash_settings', 'after');
add_output('settings', 'trash_source_max_setting', true, 'core', 'trash_since_setting', 'after');
add_output('settings', 'start_drafts_settings', true, 'core', 'trash_source_max_setting', 'after');
Expand Down Expand Up @@ -315,6 +320,8 @@
'stay_logged_in' => FILTER_VALIDATE_BOOLEAN,
'junk_per_source' => FILTER_VALIDATE_INT,
'junk_since' => FILTER_DEFAULT,
'snoozed_per_source' => FILTER_VALIDATE_INT,
'snoozed_since' => FILTER_DEFAULT,
'trash_per_source' => FILTER_VALIDATE_INT,
'trash_since' => FILTER_DEFAULT,
'drafts_per_source' => FILTER_DEFAULT,
Expand Down
1 change: 1 addition & 0 deletions modules/core/site.css
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,7 @@ button {
.flagged_setting,
.general_setting,
.junk_setting,
.snoozed_setting,
.trash_setting,
.drafts_setting,
.privacy_setting {
Expand Down
7 changes: 6 additions & 1 deletion modules/core/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,7 @@ function Message_List() {
'unread': 'formatted_unread_data',
'flagged': 'formatted_flagged_data',
'junk': 'formatted_junk_data',
'snoozed': 'formatted_snoozed_data',
'trash': 'formatted_trash_data',
'sent': 'formatted_sent_data',
'drafts': 'formatted_drafts_data',
Expand Down Expand Up @@ -617,6 +618,9 @@ function Message_List() {
if (action_type == 'unflag' && getListPathParam() == 'flagged') {
remove = true;
}
if (action_type == 'unsnooze' && getListPathParam() == 'snoozed') {
remove = true;
}
else if (action_type == 'delete' || action_type == 'archive') {
remove = true;
}
Expand Down Expand Up @@ -1052,6 +1056,7 @@ function Message_List() {
this.set_unread_state = function() { self.set_message_list_state('formatted_unread_data'); };
this.set_search_state = function() { self.set_message_list_state('formatted_search_data'); };
this.set_junk_state = function() { self.set_message_list_state('formatted_junk_data'); };
this.set_snoozed_state = function() { self.set_message_list_state('formatted_snoozed_data'); };
this.set_trash_state = function() { self.set_message_list_state('formatted_trash_data'); };
this.set_draft_state = function() { self.set_message_list_state('formatted_drafts_data'); };
this.set_tag_state = function() { self.set_message_list_state('formatted_tag_data'); };
Expand Down Expand Up @@ -1447,7 +1452,7 @@ var Hm_Utils = {
var results = {}
var i;
var hash = window.location.hash;
var sections = ['.wp_notifications_setting', '.github_all_setting', '.tfa_setting', '.sent_setting', '.general_setting', '.unread_setting', '.flagged_setting', '.all_setting', '.email_setting', '.junk_setting', '.trash_setting', '.drafts_setting','.tag_setting'];
var sections = ['.wp_notifications_setting', '.github_all_setting', '.tfa_setting', '.sent_setting', '.general_setting', '.unread_setting', '.flagged_setting', '.all_setting', '.email_setting', '.junk_setting', '.snoozed_setting', '.trash_setting', '.drafts_setting','.tag_setting'];
for (i=0;i<sections.length;i++) {
dsp = Hm_Utils.get_from_local_storage(sections[i]);
if (hash) {
Expand Down
3 changes: 3 additions & 0 deletions modules/imap/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ function imap_sources($callback, $mod, $folder = 'sent') {
elseif ($inbox) {
$sources[] = array('callback' => $callback, 'folder' => bin2hex('INBOX'), 'type' => 'imap', 'name' => $vals['name'], 'id' => $index);
}
elseif ($folder=="snoozed"){
$sources[] = array('callback' => $callback, 'folder' => bin2hex('Snoozed'), 'type' => 'imap', 'name' => $vals['name'], 'id' => $index);
}
else {
$sources[] = array('callback' => $callback, 'folder' => bin2hex('SPECIAL_USE_CHECK'), 'nodisplay' => true, 'type' => 'imap', 'name' => $vals['name'], 'id' => $index);
}
Expand Down
5 changes: 4 additions & 1 deletion modules/imap/handler_modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -1611,6 +1611,9 @@ public function process() {
case 'junk':
$callback = 'imap_folder_content';
break;
case 'snoozed':
$callback = 'imap_folder_content';
break;
case 'trash':
$callback = 'imap_folder_content';
break;
Expand All @@ -1628,7 +1631,7 @@ public function process() {
if ($callback != 'imap_background_unread_content') {
$this->out('move_copy_controls', true);
}
if (in_array($path, ['sent', 'junk', 'trash', 'drafts'])) {
if (in_array($path, ['sent', 'junk', 'snoozed','trash', 'drafts'])) {
foreach (imap_sources($callback, $this, $path) as $vals) {
$this->append('data_sources', $vals);
}
Expand Down
2 changes: 1 addition & 1 deletion modules/imap/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ var add_auto_folder = function(folder) {
};

var cache_folder_data = function() {
if (['sent', 'drafts', 'junk', 'trash','tag'].includes(getListPathParam())) {
if (['sent', 'drafts', 'junk','snoozed', 'trash','tag'].includes(getListPathParam())) {
Hm_Message_List.set_message_list_state('formatted_'+getListPathParam()+'_data');
}
};
Expand Down

0 comments on commit 2795955

Please sign in to comment.