Skip to content

Commit

Permalink
fix(frontend/backend): feeds content display (cypht-org#1398)
Browse files Browse the repository at this point in the history
* Fix feeds display

* Fix feed message view page

* Fix the prev & next links for the feed message content

* Combined inbox includes not only imap data but feeds content as well
  • Loading branch information
mercihabam authored Dec 4, 2024
1 parent 412b5ad commit 116b8a5
Show file tree
Hide file tree
Showing 12 changed files with 191 additions and 150 deletions.
17 changes: 13 additions & 4 deletions modules/core/js_modules/Hm_MessagesStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,18 @@ class Hm_MessagesStore {

#getRequestConfig() {
let hook;
let serverId;
let imapServerId;
let feedServerId;
let folder;
const config = [];
if (this.path.startsWith('imap')) {
hook = "ajax_imap_folder_display";
const detail = Hm_Utils.parse_folder_path(this.path, 'imap');
serverId = detail.server_id;
imapServerId = detail.server_id;
folder = detail.folder;
} else if (this.path.startsWith('feeds')) {
hook = "ajax_feed_combined";
feedServerId = this.path.split('_')[1];
} else {
switch (this.path) {
case 'unread':
Expand All @@ -170,6 +174,8 @@ class Hm_MessagesStore {
hook = "ajax_imap_flagged";
break;
case 'combined_inbox':
hook = "ajax_combined_message_list";
break;
case 'email':
hook = "ajax_imap_combined_inbox";
break;
Expand All @@ -186,12 +192,15 @@ class Hm_MessagesStore {
if (hook) {
config.push({ name: "hm_ajax_hook", value: hook });
}
if (serverId) {
config.push({ name: "imap_server_id", value: serverId });
if (imapServerId) {
config.push({ name: "imap_server_id", value: imapServerId });
}
if (folder) {
config.push({ name: "folder", value: folder });
}
if (feedServerId) {
config.push({ name: "feed_server_ids", value: feedServerId });
}
return config;
}

Expand Down
18 changes: 17 additions & 1 deletion modules/core/js_modules/route_handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,20 @@ function applyInfoPageHandlers() {
return () => {
clearTimeout(timer);
}
}
}

function applyMessagePageHandlers(routeParams) {
const path = routeParams.list_path.substr(0, 4);

switch (path) {
case 'imap':
applyImapMessageContentPageHandlers(routeParams);
break;
case 'feed':
applyFeedMessageContentPageHandlers(routeParams);
break;

default:
break;
}
}
2 changes: 1 addition & 1 deletion modules/core/navigation/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const modulesRoutes = [
},
{
page: 'message',
handler: 'applyImapMessageContentPageHandlers'
handler: 'applyMessagePageHandlers'
},
{
page: 'compose',
Expand Down
15 changes: 15 additions & 0 deletions modules/core/output_modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -2432,3 +2432,18 @@ protected function output()
return $res;
}
}

class Hm_output_combined_message_list extends Hm_Output_Module {
protected function output() {
$messageList = [];
$style = $this->get('news_list_style') ? 'news' : 'email';
if ($this->get('imap_combined_inbox_data')) {
$messageList = array_merge($messageList, format_imap_message_list($this->get('imap_combined_inbox_data'), $this, false, $style));
}
if ($this->get('feed_list_data')) {
$messageList = array_merge($messageList, $this->get('feed_list_data'), Hm_Output_filter_feed_list_data::formatMessageList($this));
}
$this->out('formatted_message_list', $messageList);
$this->out('page_links', 'There is no pagination in this view, please visit the individual mail boxes.');
}
}
7 changes: 6 additions & 1 deletion modules/core/setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,10 @@
setup_base_ajax_page('ajax_privacy_settings', 'core');
add_handler('ajax_privacy_settings', 'privacy_settings', true, 'core');

setup_base_ajax_page('ajax_combined_message_list', 'core');
add_handler('ajax_combined_message_list', 'load_user_data', true, 'core');
add_output('ajax_combined_message_list', 'combined_message_list', true, 'core');

/* allowed input */
return array(
'allowed_pages' => array(
Expand All @@ -207,7 +211,8 @@
'notfound',
'search',
'ajax_quick_servers_setup',
'ajax_privacy_settings'
'ajax_privacy_settings',
'ajax_combined_message_list'
),
'allowed_output' => array(
'date' => array(FILTER_DEFAULT, false),
Expand Down
6 changes: 3 additions & 3 deletions modules/core/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -840,11 +840,11 @@ function Message_List() {
}
};

this.prev_next_links = function(msgUid) {
this.prev_next_links = function(msgUid, lisPath = getListPathParam()) {
let phref;
let nhref;
const target = $('.msg_headers tr').last();
const messages = new Hm_MessagesStore(getListPathParam(), Hm_Utils.get_url_page_number());
const messages = new Hm_MessagesStore(lisPath, Hm_Utils.get_url_page_number());
messages.load(false, true);
const next = messages.getNextRowForMessage(msgUid);
const prev = messages.getPreviousRowForMessage(msgUid);
Expand Down Expand Up @@ -2339,7 +2339,7 @@ const handleExternalResources = (inline) => {
const messageContainer = document.querySelector('.msg_text_inner');
messageContainer.insertAdjacentHTML('afterbegin', '<div class="external_notices"></div>');

const senderEmail = document.querySelector('#contact_info').textContent.match(EMAIL_REGEX)[0];
const senderEmail = document.querySelector('#contact_info')?.textContent.match(EMAIL_REGEX)[0];
const sender = senderEmail + '_external_resources_allowed';
const elements = messageContainer.querySelectorAll('[data-src]');
const blockedResources = [];
Expand Down
3 changes: 3 additions & 0 deletions modules/feeds/js_modules/route_handlers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function applyFeedMessageContentPageHandlers(routeParams) {
feed_item_view(routeParams.uid, routeParams.list_path);
}
Loading

0 comments on commit 116b8a5

Please sign in to comment.