Skip to content

Commit

Permalink
fix: do not apply add-on logic when bookmark is created for a page di…
Browse files Browse the repository at this point in the history
…fferent than the current one
  • Loading branch information
teddy-gustiaux committed Feb 4, 2024
1 parent 2dd8dc4 commit 270025d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/background/bookmarking/BuiltinBookmarking.js
Expand Up @@ -81,6 +81,8 @@ class BuiltinBookmarking {
if (Utils.bookmarkIsSeparator(bookmarkInfo)) return;
if (Utils.bookmarkIsBlankWebPage(bookmarkInfo)) return;
if (Utils.bookmarkIsRegularFolder(bookmarkInfo)) return;
const bookmarkIsCurrentPage = await Utils.bookmarkIsCurrentPage(bookmarkInfo);
if (!bookmarkIsCurrentPage) return;
await this._moveBookmarkToDefinedLocation(bookmarkInfo);
}
}
Expand Down
10 changes: 10 additions & 0 deletions src/background/utils/Utils.js
Expand Up @@ -149,6 +149,16 @@ class Utils {
return isRegularFolder;
}

// Indicate if a bookmark object is for the current page
static async bookmarkIsCurrentPage(bookmarkInfo) {
let isCurrentPage = false;
if (Utils.bookmarkIsWebPage(bookmarkInfo)) {
const newlyActiveTab = await Utils.getActiveTab();
isCurrentPage = bookmarkInfo.url === newlyActiveTab.url;
}
return isCurrentPage;
}

// Indicate if the provided bookmarks are all in the specified folder
static allBookmarksAreInFolder(folderId, bookmarks) {
let result = true;
Expand Down

0 comments on commit 270025d

Please sign in to comment.