feat: adds save preferences on collections

This commit is contained in:
Sai K K 2024-11-04 21:08:31 +05:30
parent be4fc2d9ad
commit fc2931855e

View File

@ -1,5 +1,6 @@
import React, { useState } from 'react'; import React, { useState } from 'react';
import { useDispatch, useSelector } from 'react-redux'; import { useDispatch, useSelector } from 'react-redux';
import { savePreferences } from 'providers/ReduxStore/slices/app';
import { import {
IconSearch, IconSearch,
IconFolders, IconFolders,
@ -22,6 +23,8 @@ const CollectionsBadge = () => {
const dispatch = useDispatch(); const dispatch = useDispatch();
const { collections } = useSelector((state) => state.collections); const { collections } = useSelector((state) => state.collections);
const { collectionSortOrder } = useSelector((state) => state.collections); const { collectionSortOrder } = useSelector((state) => state.collections);
const preferences = useSelector((state) => state.app.preferences);
const sortCollectionOrder = () => { const sortCollectionOrder = () => {
let order; let order;
switch (collectionSortOrder) { switch (collectionSortOrder) {
@ -36,6 +39,10 @@ const CollectionsBadge = () => {
break; break;
} }
dispatch(sortCollections({ order })); dispatch(sortCollections({ order }));
dispatch(savePreferences({
...preferences,
collectionSortOrder: order
}));
}; };
return ( return (
<div className="items-center mt-2 relative"> <div className="items-center mt-2 relative">