Skip to content

Commit

Permalink
ask for persistent storage + handle errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Ratatinator97 committed Jun 5, 2024
1 parent e0e3b47 commit 327b71d
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 4 deletions.
16 changes: 14 additions & 2 deletions pages/pictalk/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,20 @@ export default {
}
},
async fetchCollection(collectionId) {
const collection = await this.$store.dispatch("fetchCollection", collectionId);
return collection;
try {
const collection = await this.$store.dispatch("fetchCollection", collectionId);
return collection;
} catch (error) {
const notif = this.$buefy.notification.open({
duration: 4500,
message: this.$t("LostConnectivity"),
position: "is-top-right",
type: "is-danger",
hasIcon: true,
iconSize: "is-small",
icon: "airplane",
});
}
},
async refreshPictos() {
try {
Expand Down
16 changes: 14 additions & 2 deletions pages/public/pictalk/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,20 @@ export default {
return sortedItems;
},
async fetchCollection(collectionId) {
const collection = await this.$store.dispatch("fetchCollection", collectionId);
return collection;
try {
const collection = await this.$store.dispatch("fetchCollection", collectionId);
return collection;
} catch (error) {
const notif = this.$buefy.notification.open({
duration: 4500,
message: this.$t("LostConnectivity"),
position: "is-top-right",
type: "is-danger",
hasIcon: true,
iconSize: "is-small",
icon: "airplane",
});
}
},
loadedPictos() {
return this.loadPictos(
Expand Down
16 changes: 16 additions & 0 deletions plugins/dexieDB.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ if (process.client) {
pictogram: 'id, fatherCollectionId, public, userId',
collection: 'id, collection, fatherCollectionId, partial, public, userId',
});
if (navigator.storage && navigator.storage.persist) {
navigator.storage.persist().then(granted => {
if (granted)
console.log('Storage will not be cleared except for hard drive space shortage, or explicit user action.');
else
console.log('Storage may be cleared by the UA under storage pressure.');
});
}
db.open().catch(function (e) {
console.error("Open failed: " + e.stack);
});
Expand All @@ -23,5 +31,13 @@ export function createDatabaseForUser(username) {
pictogram: 'id, fatherCollectionId, public, userId',
collection: 'id, collection, fatherCollectionId, partial, public, userId',
});
if (navigator.storage && navigator.storage.persist) {
navigator.storage.persist().then(granted => {
if (granted)
console.log('Storage will not be cleared except for hard drive space shortage, or explicit user action.');
else
console.log('Storage may be cleared by the UA under storage pressure.');
});
}
return db.open();
}

0 comments on commit 327b71d

Please sign in to comment.