mirror of
https://github.com/iib0011/omni-tools.git
synced 2025-09-20 14:39:34 +02:00
Fix bookmarked tools retrieval
This commit is contained in:
@@ -148,12 +148,21 @@ export default function Hero() {
|
|||||||
{...props}
|
{...props}
|
||||||
onClick={() => navigate('/' + option.path)}
|
onClick={() => navigate('/' + option.path)}
|
||||||
>
|
>
|
||||||
<Stack direction={'row'} spacing={2} alignItems={'center'}>
|
<Stack
|
||||||
<Icon fontSize={20} icon={option.icon} />
|
direction={'row'}
|
||||||
<Box>
|
alignItems={'center'}
|
||||||
<Typography fontWeight={'bold'}>{option.name}</Typography>
|
justifyContent={'stretch'}
|
||||||
<Typography fontSize={12}>{option.shortDescription}</Typography>
|
width={'100%'}
|
||||||
</Box>
|
>
|
||||||
|
<Stack direction={'row'} spacing={2} alignItems={'center'}>
|
||||||
|
<Icon fontSize={20} icon={option.icon} />
|
||||||
|
<Box>
|
||||||
|
<Typography fontWeight={'bold'}>{option.name}</Typography>
|
||||||
|
<Typography fontSize={12}>
|
||||||
|
{option.shortDescription}
|
||||||
|
</Typography>
|
||||||
|
</Box>
|
||||||
|
</Stack>
|
||||||
<Icon
|
<Icon
|
||||||
fontSize={20}
|
fontSize={20}
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
|
@@ -3,7 +3,12 @@ import { DefinedTool } from '@tools/defineTool';
|
|||||||
const bookmarkedToolsKey = 'bookmarkedTools';
|
const bookmarkedToolsKey = 'bookmarkedTools';
|
||||||
|
|
||||||
export function getBookmarkedToolPaths(): string[] {
|
export function getBookmarkedToolPaths(): string[] {
|
||||||
return localStorage.getItem(bookmarkedToolsKey)?.split(',') ?? [];
|
return (
|
||||||
|
localStorage
|
||||||
|
.getItem(bookmarkedToolsKey)
|
||||||
|
?.split(',')
|
||||||
|
?.filter((path) => path) ?? []
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isBookmarked(tool: DefinedTool): boolean {
|
export function isBookmarked(tool: DefinedTool): boolean {
|
||||||
@@ -21,12 +26,15 @@ export function toggleBookmarked(tool: DefinedTool) {
|
|||||||
function bookmark(tool: DefinedTool) {
|
function bookmark(tool: DefinedTool) {
|
||||||
localStorage.setItem(
|
localStorage.setItem(
|
||||||
bookmarkedToolsKey,
|
bookmarkedToolsKey,
|
||||||
tool.path + ',' + (localStorage.getItem(bookmarkedToolsKey) ?? '')
|
[tool.path, ...getBookmarkedToolPaths()].join(',')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function unbookmark(tool: DefinedTool) {
|
function unbookmark(tool: DefinedTool) {
|
||||||
const bookmarked = localStorage.getItem(bookmarkedToolsKey)?.split(',') ?? [];
|
localStorage.setItem(
|
||||||
const unbookmarked = bookmarked.filter((path) => path != tool.path);
|
bookmarkedToolsKey,
|
||||||
localStorage.setItem(bookmarkedToolsKey, unbookmarked.join(','));
|
getBookmarkedToolPaths()
|
||||||
|
.filter((path) => path !== tool.path)
|
||||||
|
.join(',')
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user