Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Action items' storage #17

Closed
zhixiangteoh opened this issue Mar 11, 2021 · 0 comments
Closed

Action items' storage #17

zhixiangteoh opened this issue Mar 11, 2021 · 0 comments

Comments

@zhixiangteoh
Copy link
Owner

zhixiangteoh commented Mar 11, 2021

Schema:

// e.g. actions object in browser storage
actions = {
    greenItems: null,
    yellowItems: [ 
      { id: "1", body: "need to fix" }, 
      { id: "2", body: "could've improved"},
      ...
    ],
    redItems: [ 
      { id: "3", body: "failed to fix" }, 
      { id: "4", body: "failure in life"}, 
      ...
    ]
}

Reducer to support these actions:

  • ADD_YELLOW_ITEM (add one to yellowItems)
  • ADD_RED_ITEM (add one to redItems)
  • REMOVE_YELLOW_ITEM (remove one from yellowItems by id)
  • REMOVE_RED_ITEM (remove one from redItems by id)
  • SET_YELLOW_ITEMS (replace yellowItems array)
  • SET_RED_ITEMS (replace redItems array)
  • INIT (set whole actions object)

How it will generally work:

  1. Initialized with all Yellow and Red items in PreviousList
    1. Has access to currentMonday
    2. Similar to PreviousList, gets all Yellow / Red items from previous week to firstMonday and dispatches INIT
  2. User clicks Move to Green/Yellow/Red
    1. REMOVE_YELLOW_ITEM / REMOVE_RED_ITEM from Actions context
    2. ADD_YELLOW_ITEM / ADD_RED_ITEM to Current's List context
  3. User clicks Delete
    1. REMOVE_YELLOW_ITEM / REMOVE_RED_ITEM from Actions context

Update: Decided to reuse ListContext to create a pseudo Actions context, but with a null greenItems field and without accessing / modifying this field.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant