Update index.html
Browse files- index.html +11 -0
index.html
CHANGED
|
@@ -71,7 +71,18 @@
|
|
| 71 |
};
|
| 72 |
const app = initializeApp(firebaseConfig);
|
| 73 |
const db = getFirestore(app);
|
|
|
|
|
|
|
| 74 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
const itemsList = document.getElementById('items-list');
|
| 76 |
const itemInput = document.getElementById('item-input');
|
| 77 |
const addItemBtn = document.getElementById('add-item');
|
|
|
|
| 71 |
};
|
| 72 |
const app = initializeApp(firebaseConfig);
|
| 73 |
const db = getFirestore(app);
|
| 74 |
+
// Enable offline persistence
|
| 75 |
+
import { enableIndexedDbPersistence } from "https://www.gstatic.com/firebasejs/10.12.2/firebase-firestore.js";
|
| 76 |
|
| 77 |
+
enableIndexedDbPersistence(db)
|
| 78 |
+
.then(() => console.log("Firebase offline persistence enabled"))
|
| 79 |
+
.catch(err => {
|
| 80 |
+
if (err.code === 'failed-precondition') {
|
| 81 |
+
console.warn("Multiple tabs open, persistence can only be enabled in one tab at a time.");
|
| 82 |
+
} else if (err.code === 'unimplemented') {
|
| 83 |
+
console.warn("Persistence is not available in this browser.");
|
| 84 |
+
}
|
| 85 |
+
});
|
| 86 |
const itemsList = document.getElementById('items-list');
|
| 87 |
const itemInput = document.getElementById('item-input');
|
| 88 |
const addItemBtn = document.getElementById('add-item');
|