Skip to content

Commit

Permalink
added the path to client script so that start:dev would run propperly…
Browse files Browse the repository at this point in the history
….now im getting: InjectManifest has been called multiple times, perhaps due to running webpack in --watch mode. The precache manifest generated after the first call may be inaccurate! Please see GoogleChrome/workbox#1790 for more information.
  • Loading branch information
AhmedGarcia committed Sep 15, 2024
1 parent b5a24e9 commit 1ab3db1
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 17 deletions.
2 changes: 1 addition & 1 deletion client/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<h1> Just Another Text Editor</h1>

<div class="navbar-brand"
><img src="./assets/icons/icon_96x96.png"
><img src="/client/src/images/logo.png"
/></div>
</nav>

Expand Down
17 changes: 9 additions & 8 deletions client/src/js/database.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ const initdb = async () => //Opens a database named jate, creating it if it does
// TODO: Add logic to a method that accepts some content and adds it to the database
export const putDb = async (content) => { //Updates the content stored in IndexedDB under a specific id.
console.log('PUT to the database');
const jateDb = await openDB('jate', 1);
const tx = jateDb.transaction('jate', 'readwrite');
const store = tx.objectStore('jate');
const request = store.put({ id: 1, value: content });
const result = await request;
console.log('Data save to the database', result);
const jateDb = await openDB('jate', 1); // Connect to the database and the version we want to use
const tx = jateDb.transaction('jate', 'readwrite'); // Create a new transaction and specify the store and data privileges
const store = tx.objectStore('jate'); // Open up the desired object store
const request = store.put({ id: 1, value: content }); // Use the .add() method on the store and pass in the content
const result = await request; // Get confirmation of the request
console.log('Data saved to the database', result);
};

// TODO: Add logic for a method that gets all the content from the database
Expand All @@ -29,8 +29,9 @@ export const getDb = async () => { //Retrieves the content from IndexedDB to
const jateDb = await openDB('jate', 1);
const tx = jateDb.transaction('jate', 'readonly');
const store = tx.objectStore('jate');
const request = store.get(1);
const result = await request;
const request = store.getAll();
const result = await request; // Get confirmation of the request
console.log('result.value', result);
return result?.value;
};

Expand Down
15 changes: 8 additions & 7 deletions client/src/js/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,22 @@ const butInstall = document.getElementById('buttonInstall');
// TODO: Add an event handler to the `beforeinstallprompt` event
window.addEventListener('beforeinstallprompt', (event) => {
event.preventDefault();
window.deferredPrompt = event;
butInstall.classList.toggle('hidden', false);
window.deferredPrompt = event; // Store the event for later use
butInstall.classList.toggle('hidden', false); // Remove the hidden class from the button
});

// TODO: Implement a click event handler on the `butInstall` element
butInstall.addEventListener('click', async () => {
const promptEvent = window.deferredPrompt;
if (!promptEvent) return;
promptEvent.prompt();
window.deferredPrompt = null;
butInstall.classList.toggle('hidden', true);
promptEvent.prompt(); // Show the install prompt
window.deferredPrompt = null; // Reset the deferred prompt variable
butInstall.classList.toggle('hidden', true); // Hide the install button
});

// TODO: Add an handler for the `appinstalled` event
window.addEventListener('appinstalled', (event) => {
console.log('App installed');
window.addEventListener('appinstalled', () => {
console.log('App installed successfully!');
// Clear the deferredPrompt
window.deferredPrompt = null;
});
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"start": "node server/server.js",
"start:dev": "concurrently \"npm run server\" \"npm run client\"",
"server": "nodemon server/server.js",
"client": "webpack serve --open --hot",
"client": "webpack serve --open --hot --config ./client/webpack.config.js",
"build": "webpack --mode production --config ./client/webpack.config.js",
"install": "cd client && npm install"
},
Expand Down

0 comments on commit 1ab3db1

Please sign in to comment.