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

API mockup + save state #29

Open
wants to merge 6 commits into
base: workflow
Choose a base branch
from
Open

API mockup + save state #29

wants to merge 6 commits into from

Conversation

petternikolai
Copy link
Contributor

@petternikolai petternikolai commented May 30, 2024

This implements functions that potentially can be used with little tweaks to implement calls to an API.
In addition it adds save state functionality to main.js

The code changes include the addition of login and register API calls in the `login.js` and `register.js` files respectively. These API calls are implemented using the `authFetch` function and the appropriate endpoints from the `constants.js` file. The login API call handles the authentication process and saves the access token and profile data to the local storage. The register API call handles the registration process. These changes are made in preparation for future development that may require API integration.

Note: The recent user commits and repository commits are not directly related to these code changes and are provided for context only.
Copy link

netlify bot commented May 30, 2024

Deploy Preview for yeetsheet ready!

Name Link
🔨 Latest commit 75d6097
🔍 Latest deploy log https://app.netlify.com/sites/yeetsheet/deploys/6658f82d9dc706000895a53f
😎 Deploy Preview https://deploy-preview-29--yeetsheet.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

This commit adds functionality to initialize the spreadsheet with data from IndexedDB or default data. It introduces a new function, `loadInitialData`, which retrieves cell values from IndexedDB and populates the spreadsheet with them. If a cell value is not found in IndexedDB, it defaults to an empty string. The initial data is then passed to the `spreadsheet` function to create and append the spreadsheet to the container. Additionally, the commit includes an auto-save feature that saves the spreadsheet state every 10 seconds. This ensures that any changes made to the spreadsheet are persisted in IndexedDB. The commit also removes unused code.
@petternikolai petternikolai changed the title API mockup API mockup + save state May 30, 2024
src/js/api/auth/login.js Outdated Show resolved Hide resolved

addCellTargetingEvents('#spreadsheetContainer table', (col, row, value) => {
// Here you can put the save function with params for cell contents.
console.log('save', col, row, value);
const cellId = `cell-${row}-${col}`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the save cell was already done in another way from someone else, did you change it by purpose?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is merely a suggestion. We can revert to the old code if you want :)

});

// Auto-save every 10 seconds
setInterval(() => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as discussed, I'm not sure they meant to save the whole spreadsheet every 10 seconds, or just the cell that is currently editing

Copy link
Contributor Author

@petternikolai petternikolai May 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@WeronikaMartinsen what is your take on this? I don't see any reason not to save the state of the whole spreadsheet every 10 seconds. In the future the code could be extended to save more things on the page if needed as well. I just interpreted "Save state" as saving the state of the whole spreadsheet and not a single cell

src/js/main.js Show resolved Hide resolved
src/js/storage/load.js Outdated Show resolved Hide resolved
Copy link
Contributor

@jonhenrikaavitsland jonhenrikaavitsland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DanielEkerhovd
Can you please resolve the conlflicts in this PR

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

Successfully merging this pull request may close these issues.

3 participants