mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 08:49:13 +00:00
feat(web): preserve sort order on Filters list (#772)
* preserve filter sortOrder in localStorage * refactor to use SettingsContext
This commit is contained in:
parent
86725d804e
commit
30cf9c55f0
2 changed files with 42 additions and 17 deletions
|
@ -19,8 +19,11 @@ export const InitializeGlobalContext = () => {
|
|||
)
|
||||
}));
|
||||
}
|
||||
const filterList_ctx = localStorage.getItem("filterList");
|
||||
if (filterList_ctx) {
|
||||
FilterListContext.set(JSON.parse(filterList_ctx));
|
||||
}
|
||||
};
|
||||
|
||||
interface AuthInfo {
|
||||
username: string;
|
||||
isLoggedIn: boolean;
|
||||
|
@ -78,3 +81,27 @@ export const SettingsContext = newRidgeState<SettingsType>(
|
|||
}
|
||||
}
|
||||
);
|
||||
|
||||
export type FilterListState = {
|
||||
indexerFilter: string[],
|
||||
sortOrder: string;
|
||||
status: string;
|
||||
};
|
||||
|
||||
export const FilterListContext = newRidgeState<FilterListState>(
|
||||
{
|
||||
indexerFilter: [],
|
||||
sortOrder: "",
|
||||
status: ""
|
||||
},
|
||||
{
|
||||
onSet: (new_state) => {
|
||||
try {
|
||||
localStorage.setItem("filterList", JSON.stringify(new_state));
|
||||
} catch (e) {
|
||||
console.log("An error occurred while trying to modify the local filter list context state.");
|
||||
console.log("Error:", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
Loading…
Add table
Add a link
Reference in a new issue