1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-08-11 17:51:01 +00:00

refactor(js): rename functions to include action suffix

This commit is contained in:
Frédéric Guillot 2025-08-02 18:04:40 -07:00
parent 391792a424
commit e9d9256ae2

View file

@ -453,7 +453,7 @@ function initializeFormHandlers() {
/** /**
* Show the keyboard shortcuts modal. * Show the keyboard shortcuts modal.
*/ */
function showKeyboardShortcuts() { function showKeyboardShortcutsAction() {
const template = document.getElementById("keyboard-shortcuts"); const template = document.getElementById("keyboard-shortcuts");
ModalHandler.open(template.content, "dialog-title"); ModalHandler.open(template.content, "dialog-title");
} }
@ -461,7 +461,7 @@ function showKeyboardShortcuts() {
/** /**
* Mark all visible entries on the current page as read. * Mark all visible entries on the current page as read.
*/ */
function markPageAsRead() { function markPageAsReadAction() {
const items = getVisibleEntries(); const items = getVisibleEntries();
if (items.length === 0) return; if (items.length === 0) return;
@ -652,7 +652,7 @@ function handleBookmarkAction(element) {
* *
* @returns {void} * @returns {void}
*/ */
function handleFetchOriginalContent() { function handleFetchOriginalContentAction() {
if (isListView()) return; if (isListView()) return;
const buttonElement = document.querySelector(":is(a, button)[data-fetch-content-entry]"); const buttonElement = document.querySelector(":is(a, button)[data-fetch-content-entry]");
@ -684,7 +684,7 @@ function handleFetchOriginalContent() {
* @param {boolean} openLinkInCurrentTab - Whether to open the link in the current tab. * @param {boolean} openLinkInCurrentTab - Whether to open the link in the current tab.
* @returns {void} * @returns {void}
*/ */
function openOriginalLink(openLinkInCurrentTab) { function openOriginalLinkAction(openLinkInCurrentTab) {
if (isEntryView()) { if (isEntryView()) {
openOriginalLinkFromEntryView(openLinkInCurrentTab); openOriginalLinkFromEntryView(openLinkInCurrentTab);
} else if (isListView()) { } else if (isListView()) {
@ -747,7 +747,7 @@ function openOriginalLinkFromListView() {
* @param {boolean} openLinkInCurrentTab - Whether to open the link in the current tab. * @param {boolean} openLinkInCurrentTab - Whether to open the link in the current tab.
* @returns {void} * @returns {void}
*/ */
function openCommentLink(openLinkInCurrentTab) { function openCommentLinkAction(openLinkInCurrentTab) {
const entryLink = document.querySelector(isListView() ? ".current-item :is(a, button)[data-comments-link]" : ":is(a, button)[data-comments-link]"); const entryLink = document.querySelector(isListView() ? ".current-item :is(a, button)[data-comments-link]" : ":is(a, button)[data-comments-link]");
if (entryLink) { if (entryLink) {
@ -765,7 +765,7 @@ function openCommentLink(openLinkInCurrentTab) {
* If the current view is a list view, it will navigate to the link of the currently selected item. * If the current view is a list view, it will navigate to the link of the currently selected item.
* If the current view is an entry view, it will navigate to the link of the entry. * If the current view is an entry view, it will navigate to the link of the entry.
*/ */
function openSelectedItem() { function openSelectedItemAction() {
const currentItemLink = document.querySelector(".current-item .item-title a"); const currentItemLink = document.querySelector(".current-item .item-title a");
if (currentItemLink) { if (currentItemLink) {
window.location.href = currentItemLink.getAttribute("href"); window.location.href = currentItemLink.getAttribute("href");
@ -775,7 +775,7 @@ function openSelectedItem() {
/** /**
* Unsubscribe from the feed of the currently selected item. * Unsubscribe from the feed of the currently selected item.
*/ */
function unsubscribeFromFeed() { function handleRemoveFeedAction() {
const unsubscribeLink = document.querySelector("[data-action=remove-feed]"); const unsubscribeLink = document.querySelector("[data-action=remove-feed]");
if (unsubscribeLink) { if (unsubscribeLink) {
sendPOSTRequest(unsubscribeLink.dataset.url).then(() => { sendPOSTRequest(unsubscribeLink.dataset.url).then(() => {
@ -787,7 +787,7 @@ function unsubscribeFromFeed() {
/** /**
* Scroll the page to the currently selected item. * Scroll the page to the currently selected item.
*/ */
function scrollToCurrentItem() { function scrollToCurrentItemAction() {
const currentItem = document.querySelector(".current-item"); const currentItem = document.querySelector(".current-item");
if (currentItem) { if (currentItem) {
scrollPageTo(currentItem, true); scrollPageTo(currentItem, true);
@ -1118,32 +1118,32 @@ function initializeKeyboardShortcuts() {
keyboardHandler.on("n", goToNextPage); keyboardHandler.on("n", goToNextPage);
keyboardHandler.on("h", () => goToPage("previous")); keyboardHandler.on("h", () => goToPage("previous"));
keyboardHandler.on("l", () => goToPage("next")); keyboardHandler.on("l", () => goToPage("next"));
keyboardHandler.on("z t", scrollToCurrentItem); keyboardHandler.on("z t", scrollToCurrentItemAction);
// Item actions // Item actions
keyboardHandler.on("o", openSelectedItem); keyboardHandler.on("o", openSelectedItemAction);
keyboardHandler.on("Enter", () => openSelectedItem()); keyboardHandler.on("Enter", () => openSelectedItemAction());
keyboardHandler.on("v", () => openOriginalLink(false)); keyboardHandler.on("v", () => openOriginalLinkAction(false));
keyboardHandler.on("V", () => openOriginalLink(true)); keyboardHandler.on("V", () => openOriginalLinkAction(true));
keyboardHandler.on("c", () => openCommentLink(false)); keyboardHandler.on("c", () => openCommentLinkAction(false));
keyboardHandler.on("C", () => openCommentLink(true)); keyboardHandler.on("C", () => openCommentLinkAction(true));
// Entry management // Entry management
keyboardHandler.on("m", () => handleEntryStatus("next")); keyboardHandler.on("m", () => handleEntryStatus("next"));
keyboardHandler.on("M", () => handleEntryStatus("previous")); keyboardHandler.on("M", () => handleEntryStatus("previous"));
keyboardHandler.on("A", markPageAsRead); keyboardHandler.on("A", markPageAsReadAction);
keyboardHandler.on("s", () => handleSaveEntryAction()); keyboardHandler.on("s", () => handleSaveEntryAction());
keyboardHandler.on("d", handleFetchOriginalContent); keyboardHandler.on("d", handleFetchOriginalContentAction);
keyboardHandler.on("f", () => handleBookmarkAction()); keyboardHandler.on("f", () => handleBookmarkAction());
// Feed actions // Feed actions
keyboardHandler.on("F", goToFeedPage); keyboardHandler.on("F", goToFeedPage);
keyboardHandler.on("R", handleRefreshAllFeedsAction); keyboardHandler.on("R", handleRefreshAllFeedsAction);
keyboardHandler.on("+", goToAddSubscriptionPage); keyboardHandler.on("+", goToAddSubscriptionPage);
keyboardHandler.on("#", unsubscribeFromFeed); keyboardHandler.on("#", handleRemoveFeedAction);
// UI actions // UI actions
keyboardHandler.on("?", showKeyboardShortcuts); keyboardHandler.on("?", showKeyboardShortcutsAction);
keyboardHandler.on("Escape", () => ModalHandler.close()); keyboardHandler.on("Escape", () => ModalHandler.close());
keyboardHandler.on("a", () => { keyboardHandler.on("a", () => {
const enclosureElement = document.querySelector('.entry-enclosures'); const enclosureElement = document.querySelector('.entry-enclosures');
@ -1171,12 +1171,11 @@ function initializeClickHandlers() {
onClick(":is(a, button)[data-save-entry]", (event) => handleSaveEntryAction(event.target)); onClick(":is(a, button)[data-save-entry]", (event) => handleSaveEntryAction(event.target));
onClick(":is(a, button)[data-toggle-bookmark]", (event) => handleBookmarkAction(event.target)); onClick(":is(a, button)[data-toggle-bookmark]", (event) => handleBookmarkAction(event.target));
onClick(":is(a, button)[data-toggle-status]", (event) => handleEntryStatus("next", event.target)); onClick(":is(a, button)[data-toggle-status]", (event) => handleEntryStatus("next", event.target));
onClick(":is(a, button)[data-fetch-content-entry]", handleFetchOriginalContent); onClick(":is(a, button)[data-fetch-content-entry]", handleFetchOriginalContentAction);
onClick(":is(a, button)[data-share-status]", handleEntryShareAction); onClick(":is(a, button)[data-share-status]", handleEntryShareAction);
// Page actions with confirmation // Page actions with confirmation
onClick(":is(a, button)[data-action=markPageAsRead]", (event) => onClick(":is(a, button)[data-action=markPageAsRead]", (event) => handleConfirmationMessage(event.target, markPageAsReadAction));
handleConfirmationMessage(event.target, markPageAsRead));
// Generic confirmation handler // Generic confirmation handler
onClick(":is(a, button)[data-confirm]", (event) => { onClick(":is(a, button)[data-confirm]", (event) => {