aboutsummaryrefslogtreecommitdiffstats
path: root/js/assets.js
diff options
context:
space:
mode:
authorAlessio Vanni <vannilla@firemail.cc>2019-07-24 13:06:10 +0200
committerAlessio Vanni <vannilla@firemail.cc>2019-07-24 13:06:10 +0200
commitb9ae3e72577a857938fe5727bb87ee2249c76473 (patch)
tree0d6e1ccee7e7ceb65e259fe0f07625860e733367 /js/assets.js
parent8aa6c9df1f84fb9fedaa996a7f92510a53437662 (diff)
downloadematrix-b9ae3e72577a857938fe5727bb87ee2249c76473.tar.lz
ematrix-b9ae3e72577a857938fe5727bb87ee2249c76473.tar.xz
ematrix-b9ae3e72577a857938fe5727bb87ee2249c76473.zip
Add missing function
Diffstat (limited to 'js/assets.js')
-rw-r--r--js/assets.js41
1 files changed, 41 insertions, 0 deletions
diff --git a/js/assets.js b/js/assets.js
index e62bb5d..6e9c1f6 100644
--- a/js/assets.js
+++ b/js/assets.js
@@ -224,6 +224,47 @@
getCacheRegistry(onReady);
};
+ let cacheRemove = function (pattern, callback) {
+ let onReady = function (cache) {
+ let entries = [];
+
+ for (let key in cache) {
+ if (pattern instanceof RegExp && !pattern.test(key)) {
+ continue;
+ }
+
+ if (typeof pattern === 'string' && key !== pattern) {
+ continue;
+ }
+
+ entries.push(key);
+
+ delete cache[key];
+ }
+
+ if (entries.length !== 0) {
+ vAPI.cacheStorage.remove(content);
+
+ let bin = {
+ assetCacheRegistry: cache,
+ };
+ vAPI.cacheStorage.set(bin);
+ }
+
+ if (typeof callback === 'function') {
+ callback();
+ }
+
+ for (let i=0; i<entries.length; ++i) {
+ notifyObservers('after-asset-updated', {
+ assetKey: entries[i],
+ });
+ }
+ };
+
+ getCacheRegistry(onReady);
+ };
+
let markDirtyCache = function (pattern, exclude, callback) {
let onReady = function (registry) {
let entry;