mirror of
https://github.com/miniflux/v2.git
synced 2025-09-15 18:57:04 +00:00
Ask for confirmation before clicking on mark all as read
This commit is contained in:
parent
ac3693562b
commit
a634839678
19 changed files with 39 additions and 66 deletions
File diff suppressed because one or more lines are too long
|
@ -37,10 +37,6 @@ a:hover {
|
|||
text-decoration: none;
|
||||
}
|
||||
|
||||
.link-flipped-state {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
/* Header and main menu */
|
||||
.header {
|
||||
margin-top: 10px;
|
||||
|
|
|
@ -96,16 +96,15 @@ function incrementUnreadCounter(n){updateUnreadCounterValue((current)=>{return c
|
|||
function updateUnreadCounterValue(callback){let counterElements=document.querySelectorAll("span.unread-counter");counterElements.forEach((element)=>{let oldValue=parseInt(element.textContent,10);element.innerHTML=callback(oldValue);});if(window.location.href.endsWith('/unread')){let oldValue=parseInt(document.title.split('(')[1],10);let newValue=callback(oldValue);document.title=document.title.replace(/(.*?)\(\d+\)(.*?)/,function(match,prefix,suffix,offset,string){return prefix+'('+newValue+')'+suffix;});}}
|
||||
function isEntry(){return document.querySelector("section.entry")!==null;}
|
||||
function isListView(){return document.querySelector(".items")!==null;}
|
||||
function flipElementState(element){let labelElement=document.createElement("span");labelElement.className="link-flipped-state";labelElement.appendChild(document.createTextNode(element.dataset.labelNewState));element.parentNode.appendChild(labelElement);element.parentNode.removeChild(element);}
|
||||
function handleConfirmationMessage(linkElement,callback){linkElement.style.display="none";let containerElement=linkElement.parentNode;let questionElement=document.createElement("span");let yesElement=document.createElement("a");yesElement.href="#";yesElement.appendChild(document.createTextNode(linkElement.dataset.labelYes));yesElement.onclick=(event)=>{event.preventDefault();let loadingElement=document.createElement("span");loadingElement.className="loading";loadingElement.appendChild(document.createTextNode(linkElement.dataset.labelLoading));questionElement.remove();containerElement.appendChild(loadingElement);callback(linkElement.dataset.url,linkElement.dataset.redirectUrl);};let noElement=document.createElement("a");noElement.href="#";noElement.appendChild(document.createTextNode(linkElement.dataset.labelNo));noElement.onclick=(event)=>{event.preventDefault();linkElement.style.display="inline";questionElement.remove();};questionElement.className="confirm";questionElement.appendChild(document.createTextNode(linkElement.dataset.labelQuestion+" "));questionElement.appendChild(yesElement);questionElement.appendChild(document.createTextNode(", "));questionElement.appendChild(noElement);containerElement.appendChild(questionElement);}
|
||||
document.addEventListener("DOMContentLoaded",function(){handleSubmitButtons();if(!document.querySelector("body[data-disable-keyboard-shortcuts=true]")){let keyboardHandler=new KeyboardHandler();keyboardHandler.on("g u",()=>goToPage("unread"));keyboardHandler.on("g b",()=>goToPage("starred"));keyboardHandler.on("g h",()=>goToPage("history"));keyboardHandler.on("g f",()=>goToFeedOrFeeds());keyboardHandler.on("g c",()=>goToPage("categories"));keyboardHandler.on("g s",()=>goToPage("settings"));keyboardHandler.on("ArrowLeft",()=>goToPrevious());keyboardHandler.on("ArrowRight",()=>goToNext());keyboardHandler.on("k",()=>goToPrevious());keyboardHandler.on("p",()=>goToPrevious());keyboardHandler.on("j",()=>goToNext());keyboardHandler.on("n",()=>goToNext());keyboardHandler.on("h",()=>goToPage("previous"));keyboardHandler.on("l",()=>goToPage("next"));keyboardHandler.on("o",()=>openSelectedItem());keyboardHandler.on("v",()=>openOriginalLink());keyboardHandler.on("m",()=>handleEntryStatus());keyboardHandler.on("A",()=>markPageAsRead());keyboardHandler.on("s",()=>handleSaveEntry());keyboardHandler.on("d",()=>handleFetchOriginalContent());keyboardHandler.on("f",()=>handleBookmark());keyboardHandler.on("?",()=>showKeyboardShortcuts());keyboardHandler.on("#",()=>unsubscribeFromFeed());keyboardHandler.on("/",(e)=>setFocusToSearchInput(e));keyboardHandler.on("Escape",()=>ModalHandler.close());keyboardHandler.listen();}
|
||||
let touchHandler=new TouchHandler();touchHandler.listen();onClick("a[data-save-entry]",()=>handleSaveEntry());onClick("a[data-toggle-bookmark]",()=>handleBookmark());onClick("a[data-fetch-content-entry]",()=>handleFetchOriginalContent());onClick("a[data-action=search]",(event)=>setFocusToSearchInput(event));onClick("a[data-action=markPageAsRead]",()=>handleConfirmationMessage(event.target,()=>markPageAsRead()));onClick("a[data-toggle-status]",(event)=>{let currentItem=DomHelper.findParent(event.target,"entry");if(!currentItem){currentItem=DomHelper.findParent(event.target,"item");}
|
||||
if(currentItem){toggleEntryStatus(currentItem);}});onClick("a[data-confirm]",(event)=>handleConfirmationMessage(event.target,(url,redirectURL)=>{let request=new RequestBuilder(url);request.withCallback(()=>{if(redirectURL){window.location.href=redirectURL;}else{window.location.reload();}});request.execute();}));onClick("a[data-link-state=flip]",(event)=>{flipElementState(event.target);},true);if(document.documentElement.clientWidth<600){onClick(".logo",()=>toggleMainMenu());onClick(".header nav li",(event)=>onClickMainMenuListItem(event));}
|
||||
if(currentItem){toggleEntryStatus(currentItem);}});onClick("a[data-confirm]",(event)=>handleConfirmationMessage(event.target,(url,redirectURL)=>{let request=new RequestBuilder(url);request.withCallback(()=>{if(redirectURL){window.location.href=redirectURL;}else{window.location.reload();}});request.execute();}));if(document.documentElement.clientWidth<600){onClick(".logo",()=>toggleMainMenu());onClick(".header nav li",(event)=>onClickMainMenuListItem(event));}
|
||||
if("serviceWorker"in navigator){let scriptElement=document.getElementById("service-worker-script");if(scriptElement){navigator.serviceWorker.register(scriptElement.src);}}});})();`,
|
||||
"sw": `'use strict';self.addEventListener("fetch",(event)=>{if(event.request.url.includes("/feed/icon/")){event.respondWith(caches.open("feed_icons").then((cache)=>{return cache.match(event.request).then((response)=>{return response||fetch(event.request).then((response)=>{cache.put(event.request,response.clone());return response;});});}));}});`,
|
||||
}
|
||||
|
||||
var JavascriptsChecksums = map[string]string{
|
||||
"app": "bf306e93b04662c7ecc975c54e2ce4b1a4ed76d23ea2e708da70fb8371f368b8",
|
||||
"app": "7220905bf67e3283f975da171548d2622160d52ba07ed17933a7c38f41d83caa",
|
||||
"sw": "55fffa223919cc18572788fb9c62fccf92166c0eb5d3a1d6f91c31f24d020be9",
|
||||
}
|
||||
|
|
|
@ -454,15 +454,6 @@ function isListView() {
|
|||
return document.querySelector(".items") !== null;
|
||||
}
|
||||
|
||||
function flipElementState(element) {
|
||||
let labelElement = document.createElement("span");
|
||||
labelElement.className = "link-flipped-state";
|
||||
labelElement.appendChild(document.createTextNode(element.dataset.labelNewState));
|
||||
|
||||
element.parentNode.appendChild(labelElement);
|
||||
element.parentNode.removeChild(element);
|
||||
}
|
||||
|
||||
function handleConfirmationMessage(linkElement, callback) {
|
||||
linkElement.style.display = "none";
|
||||
|
||||
|
|
4
ui/static/js/bootstrap.js
vendored
4
ui/static/js/bootstrap.js
vendored
|
@ -65,10 +65,6 @@ document.addEventListener("DOMContentLoaded", function () {
|
|||
request.execute();
|
||||
}));
|
||||
|
||||
onClick("a[data-link-state=flip]", (event) => {
|
||||
flipElementState(event.target);
|
||||
}, true);
|
||||
|
||||
if (document.documentElement.clientWidth < 600) {
|
||||
onClick(".logo", () => toggleMainMenu());
|
||||
onClick(".header nav li", (event) => onClickMainMenuListItem(event));
|
||||
|
|
2
ui/ui.go
2
ui/ui.go
|
@ -38,7 +38,7 @@ func Serve(router *mux.Router, store *storage.Storage, pool *worker.Pool, feedHa
|
|||
uiRouter.HandleFunc("/bookmarklet", handler.bookmarklet).Name("bookmarklet").Methods("GET")
|
||||
|
||||
// Unread page.
|
||||
uiRouter.HandleFunc("/mark-all-as-read", handler.markAllAsRead).Name("markAllAsRead").Methods("GET")
|
||||
uiRouter.HandleFunc("/mark-all-as-read", handler.markAllAsRead).Name("markAllAsRead").Methods("POST")
|
||||
uiRouter.HandleFunc("/unread", handler.showUnreadPage).Name("unread").Methods("GET")
|
||||
uiRouter.HandleFunc("/unread/entry/{entryID}", handler.showUnreadEntryPage).Name("unreadEntry").Methods("GET")
|
||||
|
||||
|
|
|
@ -8,15 +8,14 @@ import (
|
|||
"net/http"
|
||||
|
||||
"miniflux.app/http/request"
|
||||
"miniflux.app/http/response/html"
|
||||
"miniflux.app/http/route"
|
||||
"miniflux.app/logger"
|
||||
"miniflux.app/http/response/json"
|
||||
)
|
||||
|
||||
func (h *handler) markAllAsRead(w http.ResponseWriter, r *http.Request) {
|
||||
if err := h.store.MarkAllAsRead(request.UserID(r)); err != nil {
|
||||
logger.Error("[MarkAllAsRead] %v", err)
|
||||
json.ServerError(w, r, err)
|
||||
return
|
||||
}
|
||||
|
||||
html.Redirect(w, r, route.Path(h.router, "unread"))
|
||||
json.OK(w, r, "OK")
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue