Optimize local/remote websites_list.json to chrome storage logic.

q
quit
exit
This commit is contained in:
Kenshin 2017-01-09 11:34:21 +08:00
parent 521bdc74c9
commit c001fb5fc3
2 changed files with 5 additions and 9 deletions

View File

@ -6,11 +6,8 @@ import { storage } from 'storage';
* Save local/remote website_list.json to chrome storage
*/
storage.Get( function() {
if ( local.Firstload() ) {
storage.GetNewsites( "local" );
} else if( !local.Count() ) {
storage.GetNewsites( "remote" );
}
if ( local.Firstload() ) storage.GetNewsites( "local" );
else if( !local.Count() ) storage.GetNewsites( "remote" );
});
/**

View File

@ -139,10 +139,9 @@ class Storage {
* @param {string} url, e.g. chrome-extension://xxxx/website_list.json or http://xxxx.xx/website_list.json
*/
async GetNewsites( type ) {
const url = type === "remote" ? remote : local;
const response = await fetch( url );
const sites = await response.json();
const len = simpread.sites.length;
const response = await fetch( type === "remote" ? remote : local ),
sites = await response.json(),
len = simpread.sites.length;
if ( len == 0 ) {
simpread.sites = formatSites( sites );
} else {