Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
LocalForage.getItem('g').then(async gFromLocalForage => {
// console.log("result of LocalForage is ", gFromLocalForage, JSON.stringify(gFromLocalForage), g, JSON.stringify(g))
if (window.fullCache && gFromLocalForage){
g = gFromLocalForage
}
else {
LocalForage.setItem('g', g)
console.log("LOAD DATA AND INIT ABOUT TO BE CALLED")
loadDataAndInit()
}
})
})
case 'NONE':
console.error('No Web3 instance detected - please check your wallet provider.')
break
default:
console.log('Detected connection to an UNKNOWN network -- localhost?')
defaultTokens = {
hash: 'local',
tokens: await tokensMap('1.0'),
}
console.log('LocalHost Token List: ', defaultTokens.tokens.elements)
break
}
// set tokens to localForage
await localForage.setItem('defaultTokens', defaultTokens)
}
// Set user's custom IPFS hash for tokens exists in localForage
if (customListHash) dispatch(setIPFSFileHashAndPath({ fileHash: customListHash }))
if (customTokens) {
const customTokensWithDecimals = await getAllTokenDecimals(customTokens)
// reset localForage customTokens w/decimals filled in
localForage.setItem('customTokens', customTokensWithDecimals)
dispatch(setCustomTokenList({ customTokenList: customTokensWithDecimals }))
dispatch(setTokenListType({ type: 'CUSTOM' }))
} else if (customListHash) {
const fileContent = await ipfsFetchFromHash(customListHash)
const json = fileContent
Object.keys(newState.contextIndex).map(key => {
const contexts = newState.contextIndex[key]
contexts.forEach(context => {
context.value = context.value || context.key
delete context.key // eslint-disable-line fp/no-delete
})
return localForage.setItem('contextIndex-' + key, contexts)
}),
async function onDelete(): Promise {
if (!pub) return;
// Remove pub from list
let pubs: Illuminsight.Pub[] = await localForage.getItem('pub-list');
pubs = pubs.filter((p) => p.id != pub.id);
await localForage.setItem('pub-list', pubs);
// Delete pub files
await localForage.removeItem(`pub-${pub.id}`);
await localForage.removeItem(`pub-cover-${pub.id}`);
// Update tags
await saveTags(pubs);
// Take us home and notify user
history.replace('/');
enqueueSnackbar(`${pub.name} was deleted`);
}
function savePersistently() {
console.log('Saving settings persistently...');
return localforage.setItem(
playgroundSettingsStoreKey,
JSON.stringify(settings.toJS())
)
.then(function() {
console.log('Settings saved!', settings.toJS());
})
.catch(function(e) {
console.log('Error saving:', e);
throw e;
});
}
.then( ( adapter ) => {
localforage
.setItem( KEYCLOAK_INPROGESS_KEY, true )
.then( () => {
adapter.init( { onLoad: 'login-required', checkLoginIframe: false } )
.success( () => {
this._user = this._buildUser( adapter );
localforage.setItem( KEYCLOAK_TOKEN_EXPIRES_KEY, adapter.tokenParsed.exp );
this._trigger( 'login', this._user );
this._logout = adapter.logout;
this._loggedIn = true;
localforage
.removeItem( KEYCLOAK_INPROGESS_KEY )
.then( () => {
let event = new HashChangeEvent( 'hashchange' );
event.oldURL = '_oauth';
event.newURL = location.hash;
window.dispatchEvent( event );
export const reset = store => next => action => {
if (action.type !== 'ACTIVATE') return next(action);
if (typeof action.count !== 'undefined') {
localforage.setItem('state', action.count)
.then(localforage.setItem('id', action.id));
return store.dispatch({type: 'RESET', state: action.count, id: action.id});
}
let state;
localforage.getItem('state')
.then(savedState => {
state = savedState;
return localforage.getItem('id');
})
.then(id => store.dispatch({type: 'RESET', state, id}))
.catch(err => console.error(err) && next(action));
};
ngOnInit() {
const key = 'key';
const value = 'hello world';
localForage.setItem(key, value).then(() => {
this.storageMap.get(key, { type: 'string' }).subscribe((result) => {
this.title = result || 'not ok';
});
});
}
.end((error, response) => {
let data = [];
for (let product of response.body.data.posts) {
data.push({
id: product.id,
name: product.name,
tagline: product.tagline,
url: product.redirect_url,
votesCount: product.votes_count,
commentsCount: product.comments_count,
discussionUrl: product.discussion_url,
});
}
localforage.setItem('producthunt', {
expires: moment().add(expiresDuration, expiresUnit).valueOf(),
data
});
callback(data);
});
});