Skip to content

Commit

Permalink
Store tasks sort order in local storage (#5121)
Browse files Browse the repository at this point in the history
  • Loading branch information
HelNershingThapa authored May 10, 2022
1 parent 04d5ca3 commit f355e6c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions frontend/src/components/taskSelection/taskList.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import messages from './messages';
import { RelativeTimeWithUnit } from '../../utils/formattedRelativeTime';
import { TaskActivity } from './taskActivity';
import { compareTaskId, compareLastUpdate } from '../../utils/sorting';
import { getItem, setItem } from '../../utils/safe_storage';
import { TASK_COLOURS } from '../../config';
import { LockIcon, ListIcon, ZoomPlusIcon, CloseIcon, InternalLinkIcon } from '../svgIcons';
import { PaginatorLine, howManyPages } from '../paginator';
Expand Down Expand Up @@ -207,6 +208,12 @@ export function TaskList({
[readyTasks],
);

useEffect(() => {
const tasksSortOrder = getItem('tasksSortOrder');
tasksSortOrder && setSortingOption(tasksSortOrder);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

useEffect(() => {
if (tasks && tasks.features) {
let newTasks = tasks.features;
Expand Down Expand Up @@ -250,6 +257,7 @@ export function TaskList({
function updateSortingOption(data: Object) {
if (data) {
setSortingOption(data[0].value);
setItem('tasksSortOrder', data[0].value);
}
}

Expand Down
1 change: 1 addition & 0 deletions frontend/src/store/actions/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export const logout = () => (dispatch) => {
safeStorage.removeItem('action');
safeStorage.removeItem('osm_oauth_token');
safeStorage.removeItem('osm_oauth_token_secret');
safeStorage.removeItem('tasksSortOrder');
dispatch(clearUserDetails());
};

Expand Down

0 comments on commit f355e6c

Please sign in to comment.