Skip to content

Workaround patch for no_tag filtering #286

Description

@vit1-irk

Hi! Several people reported issues with annoying scrolling when trying to tag a lot of untagged bookmarks.
#41 #12

I've done a quick patch for no_tag filter to make bookmarks app a little more usable. (apply to current master)
Usage: write "_notag" in the tags filter search bar.

diff --git a/controller/lib/bookmarks.php b/controller/lib/bookmarks.php
index e0fe466..8baf6c4 100644
--- a/controller/lib/bookmarks.php
+++ b/controller/lib/bookmarks.php
@@ -187,6 +187,20 @@ class Bookmarks {
        return $bookmarks;
    }

+   public static function findUntaggedBookmarks($userId, IDb $db, $offset, $limit = 10) {
+       $sql = "SELECT * FROM `*PREFIX*bookmarks` where `id` not in (select `bookmark_id` from `*PREFIX*bookmarks_tags`) AND `user_id` = ?";
+
+       if ($limit == -1 || $limit === false) {
+           $limit = null;
+           $offset = null;
+       }
+
+       $query = $db->prepareQuery($sql, $limit, $offset);
+       $results = $query->execute(array($userId))->fetchAll();
+
+       return $results;
+   }
+
    private static function findBookmarksBuildFilter(&$sql, &$params, $filters, $filterTagOnly, $tagFilterConjunction, $CONFIG_DBTYPE) {
        $tagOrSearch = false;
        $connectWord = 'AND';
diff --git a/controller/rest/bookmarkcontroller.php b/controller/rest/bookmarkcontroller.php
index cd6597b..a9d53a5 100644
--- a/controller/rest/bookmarkcontroller.php
+++ b/controller/rest/bookmarkcontroller.php
@@ -66,16 +66,21 @@ class BookmarkController extends ApiController {
            $qtags = Bookmarks::findTags($this->userId, $this->db, $tags);
            return new JSONResponse(array('data' => $qtags, 'status' => 'success'));
        } else { // type == bookmark
-           $filterTag = Bookmarks::analyzeTagRequest($tag);
-
            $offset = $page * 10;

-           if ($sort == 'bookmarks_sorting_clicks') {
-               $sqlSortColumn = 'clickcount';
-           } else {
-               $sqlSortColumn = 'lastmodified';
+           if ($tag == "_notag") {
+               $bookmarks = Bookmarks::findUntaggedBookmarks($this->userId, $this->db, $offset);
+           }
+           else {
+               $filterTag = Bookmarks::analyzeTagRequest($tag);
+
+               if ($sort == 'bookmarks_sorting_clicks') {
+                   $sqlSortColumn = 'clickcount';
+               } else {
+                   $sqlSortColumn = 'lastmodified';
+               }
+               $bookmarks = Bookmarks::findBookmarks($this->userId, $this->db, $offset, $sqlSortColumn, $filterTag, true);
            }
-           $bookmarks = Bookmarks::findBookmarks($this->userId, $this->db, $offset, $sqlSortColumn, $filterTag, true);
            return new JSONResponse(array('data' => $bookmarks, 'status' => 'success'));
        }
    }

Hope somebody found this patch useful.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions