Giter Site home page Giter Site logo

w3b3 / todoish Goto Github PK

View Code? Open in Web Editor NEW
1.0 0.0 0.0 4.38 MB

App initially conceived as a 30-min effort to demo a TODO app with persistency on AstraDB (Apache Cassandra-based cloud database, from @Datastax)

Home Page: https://todo-dev.brasileiro.ca

HTML 25.35% CSS 4.70% JavaScript 69.95%
astradb datastax cassandra cassandra-database react reactjs typescript javascript rest todo

todoish's People

Contributors

w3b3 avatar

Stargazers

 avatar

todoish's Issues

Bug: bad API response should not break UI

Currently having a typeerror being shown here

useEffect(() => {
    getAllEntries().then((newList) => {
      setTaskList(newList.tasks);
      // setApiPagination(newList.pagination);
      setTotalNumberOfTasks(newList.tasks.length); //TEMPORARY SOLUTION - FLAKY SINCE ITS WITHOUT PAGINATION
    });
  }, []);

Add error handling in case API doesn't return

This screenshot illustrates the issue:
image

Reproduction steps / History

  • This is the very first deploy to Vercel.
  • No Env were configured (yet)
  • API calls are running like https://undefined-undefined.astra.etc...
  • fetch is returning a TypeError (it is caught by a try-catch block and returning the exception from catch).
  • e: TypeError: NetworkError when attempting to fetch resource.
  • So... the API response (a bad one) is being fed to the UI
  • One of the things the UI does is doing some array operations on the response (sort, then map) and this is where it is errors out (unhandled error).
  • TypeError: C.sort is not a function

Ideas:

  • Update the return from API catch block.
  • Validate response in UI, not passing down if data is not a valid Array.
  • Also: can we add the famous Error Boundary here? (I know we can, but the real question is: should we?)

Bug: `handleAddTask` for newly setup db is crashing the UI

  80 |   setTaskList(newList.tasks);
  81 |   // setApiPagination(newList.pagination);
  82 |   // setTotalNumberOfTasks(newList.rowCount); //DOES NOT WORK
> 83 |   setTotalNumberOfTasks(newList.tasks.length); //TEMPORARY SOLUTION - FLAKY SINCE ITS WITHOUT PAGINATION
     | ^  84 | };

Add skeleton for loading state on page load

On initial page load, currently show the "YOU DON'T HAVE ANY ELEMENT IN YOUR LIST" for a couple seconds until the call to the API/DB resolves and the list is populated and React renders it.

Instead I want to see a skeleton (that assumes some content is going to be returned from the API) and that will be replaced with the actual response content:

  • a full list of items
  • an empty array (rendering an empty list)

Advanced: optimistic UI updates (and UNDO action)

It is a pain to wait for 2 API calls to fully resolve to ONLY THEN be able to continue operating with the App.

It feels weird. It should be instantaneous. API responses should come whenever AND (ONLY THEN) we will worry with a error state.

Examples:

  • I will send a delete entry call
    • The app should assume the call was successfully submitted and responded at the same instance. Meaning the task should be removed from the screen upon clicking.
    • When the API returns a 200, the list is updated (maybe a new pagination, maybe a new ordering) but the user is already interacting with something else.
    • When the API returns a 400/500 response, a pop-up is displayed to the user and the response comes back with a revert operation in whatever was changed (maybe the old state of the article list has to be promoted again, since the fast one is not the most accurate given the bad response).

This implies that some actions will have to cache/keep an old state and a new state in memory. The new state always replaces instantaneously and the old state is only used when the response is bad. If response is good, old state is discarded.

Optimize the background image

Not only make it smaller, but responsible and using source sets appropriately
Background images are hard, but a trick should be available in Stack Overflow

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.