Skip to content

Commit

Permalink
separate initial state & add initial tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
nimone committed Nov 12, 2021
1 parent b81e8da commit a676b55
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 23 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
A simple and accessible Google Tasks client with a beautiful interface inspired from todoist. It can also act as a stand alone todolist (without Google Tasks sync).

**Todos:**
![Todos screenshot](https://i.ibb.co/cTtGML0/Screenshot-from-2021-11-11-13-48-26.png)
![Todos screenshot](https://i.ibb.co/FHBT0J6/Screenshot-from-2021-11-12-19-39-14.png)

**Settings:**
![Settings screenshot](https://i.ibb.co/6b9V0X4/Screenshot-from-2021-11-12-19-40-14.png)

**Projects:**
![Projects screenshot](https://i.ibb.co/j35gyVz/Screenshot-from-2021-11-11-13-51-14.png)
![Projects screenshot](https://i.ibb.co/vzkDNLs/Screenshot-from-2021-11-12-19-41-52.png)

---
## Features 🌟
Expand Down
43 changes: 43 additions & 0 deletions src/redux/initialState.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
const initialTasks = [
"✔️ Mark me completed.",
"✏️ Edit to corrrect me.",
"🗑️ Delete me.",
"⚙️ Click the gear (top-right) to access settings.",
"🟠 Change the current theme.",
"🔄 Sync with your Google Tasks account.",
"✅ View completed todos.",
"🆘 In-case of emergency \"Reset & Clear cache\" is your friend.",
"🔽 Sort the todos to \"Oldest First\".",
"📗 Click \"TodoList ↕️\" (top-left) to access other projects / tasklists.",
]

const initialState = {
todos: {
0: {
...initialTasks.map((task, i) => ({
task,
id: i,
timestamp: initialTasks.length-i,
completed: false,
}))
},
},
projects: {
0: {
id: 0,
synced: false,
timestamp: Date.now(),
title: "TodoList",
}
},
settings: {
currentTheme: "randomImage",
sortType: "newest",
currentProject: 0,
removeCompleted: false,
showCompleted: false,
isSignedIn: false,
},
}

export default initialState
21 changes: 1 addition & 20 deletions src/redux/persistedState.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,5 @@
import { getTodos, getSettings, getProjects } from "../db"

export const initialState = {
todos: {},
projects: {
0: {
id: 0,
synced: false,
timestamp: Date.now(),
title: "TodoList",
}
},
settings: {
currentTheme: "randomImage",
sortType: "newest",
currentProject: 0,
removeCompleted: false,
showCompleted: false,
isSignedIn: false,
},
}
import initialState from "./initialState"

const persistedState = {
todos: await getTodos() || initialState.todos,
Expand Down
2 changes: 1 addition & 1 deletion src/redux/rootReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { combineReducers } from 'redux'
import todoReducer from './todos/todoReducer'
import projectReducer from './projects/projectReducer'
import settingReducer from './settings/settingReducer'
import { initialState } from './persistedState'
import initialState from './initialState'

const appReducer = combineReducers({
todos: todoReducer,
Expand Down

0 comments on commit a676b55

Please sign in to comment.