orderiom-api-package 0.4.77 → 0.4.78
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/modules/restaurant.js +33 -0
package/package.json
CHANGED
|
@@ -101,6 +101,39 @@ const actions = {
|
|
|
101
101
|
commonErrorCallback()
|
|
102
102
|
);
|
|
103
103
|
},
|
|
104
|
+
// Delete older caches of index.html file manually because workbox can't do it properly
|
|
105
|
+
async deleteOlderIndexCaches() {
|
|
106
|
+
// get all the cache storages for this website
|
|
107
|
+
return caches.keys().then(res => {
|
|
108
|
+
if(!res.length) return;
|
|
109
|
+
// get the first cache storages for this website
|
|
110
|
+
return caches.open(res[0]).then(cache => {
|
|
111
|
+
// get all the cached requests
|
|
112
|
+
return cache.keys().then(requests => {
|
|
113
|
+
// get all the cached requests that is related to index.html
|
|
114
|
+
const indexCaches = requests.filter(request => request.url.includes('index.html'))
|
|
115
|
+
|
|
116
|
+
// If there is only one cached request for index.html then no need to do anything
|
|
117
|
+
if(indexCaches.length <= 1) return;
|
|
118
|
+
|
|
119
|
+
return Promise.all(indexCaches.map(async indexCache => {
|
|
120
|
+
// Get the last modified time for all cache requests of index.html
|
|
121
|
+
return cache.match(indexCache).then(response => {
|
|
122
|
+
if(!response) return;
|
|
123
|
+
indexCache.lastModified = new Date(response.headers.get('Last-Modified')).getTime()
|
|
124
|
+
})
|
|
125
|
+
})).then(() => {
|
|
126
|
+
// Delete the older caches of index.html
|
|
127
|
+
indexCaches.sort((a, b) => b.lastModified - a.lastModified)
|
|
128
|
+
const olderIndexCaches = indexCaches.slice(1, indexCaches.length)
|
|
129
|
+
return Promise.all(olderIndexCaches.map(olderIndexCache => {
|
|
130
|
+
return cache.delete(olderIndexCache);
|
|
131
|
+
}))
|
|
132
|
+
})
|
|
133
|
+
})
|
|
134
|
+
})
|
|
135
|
+
})
|
|
136
|
+
},
|
|
104
137
|
contact({ }, data) {
|
|
105
138
|
return $http.post('api/contact', data).then((res) => {
|
|
106
139
|
return {
|