Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The search will be more quik without wifi #87

Open
algking opened this issue Apr 4, 2018 · 0 comments
Open

The search will be more quik without wifi #87

algking opened this issue Apr 4, 2018 · 0 comments

Comments

@algking
Copy link

algking commented Apr 4, 2018

here is the code , the url is a visual host
I wonder why , when I shut down the wifi , the alfred will return the result more quickly?
If turn on the wifi,will be more slow, I have logged the url in alfy.fetch function,which shows
they both use the cached data .

alfy.fetch('http://linuxcmd.com/data.json',
           {maxAge: 86400000}).then(result => {
    var commands = [];
    var e = 0;
    for(var a in result){
      ++e;
      result[a]['id'] = e;
      commands.push(result[a]);
  }
  var i=0,
  page_size = commands.length,
  arrResult = [],
  query=alfy.input;
  if(commands&&commands.length&&toString.call(commands).indexOf('Array')>-1){
    var count = 0
    for (; i < page_size; i++) {
      if(isSreachIndexOF(commands[i].n,query)
       || isSreachIndexOF(commands[i].d,query) 
      ){
        if(count < page_size){
          arrResult.push(commands[i]);
          ++count;
        }
      }
    }
  }
  var items = [];
  for(var i = 0;i< arrResult.length;i++){
    items.push({
      title: arrResult[i].n,
      subtitle: arrResult[i].d,
      arg: arrResult[i].n
    })
  }

  if(items.length < 1){
    items.push({
      title: "没有搜素到内容",
      subtitle: "请尝试其它关键字",
    })
  }
  alfy.output(items);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant