Skip to content

Commit

Permalink
Add config, disable redux
Browse files Browse the repository at this point in the history
  • Loading branch information
uigywnkiub committed Apr 11, 2024
1 parent f31e847 commit 315464d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/node_modules
/build
.DS_Store
src/**/*.DS_Store
32 changes: 25 additions & 7 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ import CodeModal from "./components/Modal/CodeModal";
// hooks
import { useLocalStorage } from "./hooks/useLocalStorage";

// cfg
import { IS_DISABLE_REDUX } from "./config/config";

// styles
import "./App.css";
import NotifPopup from "./components/NotifPopup/NotifPopup";
Expand Down Expand Up @@ -59,11 +62,10 @@ function App() {
};
const { id: idMatch } = newTodo;

if ("vibrate" in navigator) {
navigator.vibrate(100);
if (!IS_DISABLE_REDUX) {
dispatch(addTodo(newTodo));
}

dispatch(addTodo(newTodo));
setTodos([...todos, newTodo]);
setLocalStorTodos([...todos, newTodo]);
setLocalStorTodosText([...localStorTodosText, { text, idMatch }]);
Expand Down Expand Up @@ -111,7 +113,14 @@ function App() {
return;
}

dispatch(deleteTodo(id));
if ("vibrate" in navigator) {
navigator.vibrate(300);
}

if (!IS_DISABLE_REDUX) {
dispatch(deleteTodo(id));
}

setTodos(filterTodosHandlerById(todos, id));
setLocalStorTodos(filterTodosHandlerById(localStorTodos, id));
};
Expand All @@ -123,7 +132,10 @@ function App() {
);
};

dispatch(toggleTodo(id));
if (!IS_DISABLE_REDUX) {
dispatch(toggleTodo(id));
}

setTodos(toggleTodos(todos));
setLocalStorTodos(toggleTodos(localStorTodos));
};
Expand All @@ -133,13 +145,19 @@ function App() {
return todosArray.filter((todo) => !todo.isCompleted || todo.isSecure);
};

dispatch(deleteCompletedTodos());
if (!IS_DISABLE_REDUX) {
dispatch(deleteCompletedTodos());
}

setTodos(filterUnsecureCompletedTodos(todos));
setLocalStorTodos(filterUnsecureCompletedTodos(todos));
};

const resetTodosHandler = () => {
dispatch(clearAllTodos());
if (!IS_DISABLE_REDUX) {
dispatch(clearAllTodos());
}

setTodos([]);
setLocalStorTodos([]);
setLocalStorTodosText([]);
Expand Down
1 change: 1 addition & 0 deletions src/config/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const IS_DISABLE_REDUX = true;

0 comments on commit 315464d

Please sign in to comment.