mirror of
https://github.com/Kenshin/simpread.git
synced 2026-02-01 15:41:29 +00:00
Optimize local/remote websites_list.json to chrome storage logic.
q quit exit
This commit is contained in:
parent
521bdc74c9
commit
c001fb5fc3
@ -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" );
|
||||
});
|
||||
|
||||
/**
|
||||
|
||||
@ -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 {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user