Skip to content

Commit

Permalink
Update safari extension
Browse files Browse the repository at this point in the history
  • Loading branch information
ridemountainpig committed Dec 6, 2024
1 parent ccd98fe commit a35d5e0
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
4 changes: 4 additions & 0 deletions extensions/safari/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Safari Changelog

## [Improve] - {PR_MERGE_DATE}

- Add a preference for `Search Reading List` to hide items that have already been read.

## [Update] - 2024-12-03

- Added `pinyin` support for searching tab
Expand Down
11 changes: 10 additions & 1 deletion extensions/safari/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"iwex",
"xilopaint",
"marcjulian",
"ChangeHow"
"ChangeHow",
"ridemountainpig"
],
"license": "MIT",
"commands": [
Expand Down Expand Up @@ -71,6 +72,14 @@
"label": "Group by status",
"default": true,
"description": "Group items by Read/Unread status"
},
{
"name": "hideReadItems",
"type": "checkbox",
"required": false,
"label": "Hide read items",
"default": false,
"description": "Hide read items"
}
]
},
Expand Down
13 changes: 10 additions & 3 deletions extensions/safari/src/reading-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ import { search } from "./utils";

type Preferences = {
groupByStatus: boolean;
hideReadItems: boolean;
};

const { groupByStatus }: Preferences = getPreferenceValues();
const { groupByStatus, hideReadItems }: Preferences = getPreferenceValues();

export default function Command() {
const [searchText, setSearchText] = useState<string>("");
Expand All @@ -20,9 +21,15 @@ export default function Command() {
return <PermissionError />;
}

const filteredBookmarks = hideReadItems
? _.filter(bookmarks as ReadingListBookmark[], ({ dateLastViewed }) => !dateLastViewed)
: bookmarks;

const groupedBookmarks = groupByStatus
? _.groupBy(bookmarks as ReadingListBookmark[], ({ dateLastViewed }) => (dateLastViewed ? "read" : "unread"))
: { All: bookmarks || [] };
? _.groupBy(filteredBookmarks as ReadingListBookmark[], ({ dateLastViewed }) =>
dateLastViewed ? "read" : "unread",
)
: { All: filteredBookmarks || [] };

return (
<List isLoading={!bookmarks} onSearchTextChange={setSearchText}>
Expand Down

0 comments on commit a35d5e0

Please sign in to comment.