diff --git a/packages/core/src/api/index.ts b/packages/core/src/api/index.ts
index 5f15398..a24a9b4 100644
--- a/packages/core/src/api/index.ts
+++ b/packages/core/src/api/index.ts
@@ -194,34 +194,49 @@ function loadNewIcons(provider: string, prefix: string, icons: string[]): void {
cachedReundancy.redundancy.query(
item,
api.send as QueryModuleCallback,
- (data) => {
- // Add icons to storage
+ (data, error) => {
const storage = getStorage(provider, prefix);
- try {
- const added = addIconSet(
- storage,
- data as IconifyJSON,
- 'all'
- );
- if (typeof added === 'boolean') {
+
+ // Check for error
+ if (typeof data !== 'object') {
+ if (error !== 404) {
+ // Do not handle error unless it is 404
return;
}
- // Remove added icons from pending list
- const pending = providerPendingIcons[prefix];
- added.forEach((name) => {
- delete pending[name];
+ // Not found: mark as missing
+ const t = Date.now();
+ item.icons.forEach((name) => {
+ storage.missing[name] = t;
});
-
- // Cache API response
- if (coreModules.cache) {
- coreModules.cache(
- provider,
- data as IconifyJSON
+ } else {
+ // Add icons to storage
+ try {
+ const added = addIconSet(
+ storage,
+ data as IconifyJSON,
+ 'all'
);
+ if (typeof added === 'boolean') {
+ return;
+ }
+
+ // Remove added icons from pending list
+ const pending = providerPendingIcons[prefix];
+ added.forEach((name) => {
+ delete pending[name];
+ });
+
+ // Cache API response
+ if (coreModules.cache) {
+ coreModules.cache(
+ provider,
+ data as IconifyJSON
+ );
+ }
+ } catch (err) {
+ console.error(err);
}
- } catch (err) {
- console.error(err);
}
// Trigger update on next tick
diff --git a/packages/core/tests/10-basic/storage-test.ts b/packages/core/tests/10-basic/storage-test.ts
index e01a4ac..5e3cdc7 100644
--- a/packages/core/tests/10-basic/storage-test.ts
+++ b/packages/core/tests/10-basic/storage-test.ts
@@ -22,6 +22,11 @@ describe('Testing storage', () => {
width: 20,
height: 16,
});
+ addIcon(storage, 'not-really-missing', {
+ body: '',
+ width: 24,
+ height: 24,
+ });
// Add another icon with reserved keyword as name
addIcon(storage, 'constructor', {
@@ -31,17 +36,25 @@ describe('Testing storage', () => {
rotate: 1,
});
+ // Mark 'not-really-missing' as missing
+ storage.missing['not-really-missing'] = Date.now();
+
// Add invalid icon
addIcon(storage, 'invalid', ({} as unknown) as IconifyIcon);
// Should not include 'invalid'
- expect(Object.keys(storage.icons)).to.be.eql(['test', 'constructor']);
+ expect(Object.keys(storage.icons)).to.be.eql([
+ 'test',
+ 'not-really-missing',
+ 'constructor',
+ ]);
// Test iconExists
expect(iconExists(storage, 'test')).to.be.equal(true);
expect(iconExists(storage, 'constructor')).to.be.equal(true);
expect(iconExists(storage, 'invalid')).to.be.equal(false);
expect(iconExists(storage, 'missing')).to.be.equal(false);
+ expect(iconExists(storage, 'not-really-missing')).to.be.equal(true);
// Test getIcon
let expected: FullIconifyIcon = {
@@ -56,16 +69,6 @@ describe('Testing storage', () => {
};
const icon = getIcon(storage, 'test');
expect(icon).to.be.eql(expected);
- expected = {
- body: '',
- width: 24,
- height: 24,
- top: 0,
- left: 0,
- hFlip: false,
- vFlip: false,
- rotate: 1,
- };
// Test icon mutation
let thrown = false;
@@ -77,7 +80,18 @@ describe('Testing storage', () => {
}
expect(thrown).to.be.equal(true);
+ expected = {
+ body: '',
+ width: 24,
+ height: 24,
+ top: 0,
+ left: 0,
+ hFlip: false,
+ vFlip: false,
+ rotate: 1,
+ };
expect(getIcon(storage, 'constructor')).to.be.eql(expected);
+
expect(getIcon(storage, 'invalid')).to.be.equal(null);
expect(getIcon(storage, 'missing')).to.be.equal(null);
});