From d445530fa08cdbe2088150a3e7d23596eab9b142 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 19 Feb 2021 17:15:22 +0300 Subject: format note on the client --- plugins/note/init.php | 9 +++------ plugins/note/note.js | 14 ++++++-------- 2 files changed, 9 insertions(+), 14 deletions(-) (limited to 'plugins/note') diff --git a/plugins/note/init.php b/plugins/note/init.php index 278cfe6c3..f4bdf45bc 100644 --- a/plugins/note/init.php +++ b/plugins/note/init.php @@ -55,17 +55,14 @@ class Note extends Plugin { } function setNote() { - $id = $_REQUEST["id"]; - $note = trim(strip_tags($_REQUEST["note"])); + $id = (int)clean($_REQUEST["id"]); + $note = clean($_REQUEST["note"]); $sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET note = ? WHERE ref_id = ? AND owner_uid = ?"); $sth->execute([$note, $id, $_SESSION['uid']]); - $formatted_note = Article::_format_note_html($id, $note); - - print json_encode(array("note" => $formatted_note, - "raw_length" => mb_strlen($note))); + print json_encode(["id" => $id, "note" => $note]); } function api_version() { diff --git a/plugins/note/note.js b/plugins/note/note.js index d42fca2c1..a46acb355 100644 --- a/plugins/note/note.js +++ b/plugins/note/note.js @@ -13,16 +13,14 @@ Plugins.Note = { dialog.hide(); if (reply) { - const elem = App.byId("POSTNOTE-" + id); + App.findAll(`div[data-note-for="${reply.id}"]`).forEach((elem) => { + elem.querySelector(".body").innerHTML = reply.note; - if (elem) { - elem.innerHTML = reply.note; - - if (reply.raw_length != 0) - Element.show(elem); + if (reply.note) + elem.show(); else - Element.hide(elem); - } + elem.hide(); + }); } }); } -- cgit v1.2.3