Skip to content

Commit

Permalink
added dao filter local storage support (#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
Megha-Dev-19 authored Apr 1, 2024
1 parent 2b381c3 commit 455f56e
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion apps/astraplusplus/widget/DAO/Proposals/ProposalsPikespeak.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ const isVotingBodyDao = daoId === VotingBodyDaoId;
const proposalsCount = Near.view(daoId, "number_of_proposals");

if (proposalsCount === null) return;

const STORAGE_FILTERS_KEY = daoId + "_filters";
const storageFiltersData = Storage.privateGet(STORAGE_FILTERS_KEY);
State.init({
daoId,
page: 0,
Expand All @@ -50,6 +51,15 @@ State.init({
tab: "active"
});

if (
storageFiltersData &&
JSON.stringify(state.filters) !== storageFiltersData
) {
State.update({
filters: JSON.parse(storageFiltersData)
});
}

function getPreVoteVotes(supported) {
const votes = {};
for (const item of supported) {
Expand Down Expand Up @@ -335,12 +345,17 @@ return (
props={{
filters: state.filters,
cancel: () => {
Storage.privateSet(STORAGE_FILTERS_KEY, null);
State.update({
...state,
filtersOpen: false
});
},
applyFilters: (filters) => {
Storage.privateSet(
STORAGE_FILTERS_KEY,
JSON.stringify(filters)
);
State.update({
...state,
filters,
Expand Down

0 comments on commit 455f56e

Please sign in to comment.