lib/pra/app.rb in pra-1.7.2 vs lib/pra/app.rb in pra-2.0.0

- old
+ new

@@ -1,10 +1,10 @@ require 'thread' require 'pra/window_system_factory' require 'pra/pull_request_service' -require 'pra/error_log' +require 'pra/log' Thread.abort_on_exception=true module Pra class App @@ -20,26 +20,33 @@ def spawn_pull_request_fetcher Thread.new { pull_request_fetcher_thread } end def fetch_and_refresh_pull_requests + if @window_system.force_refresh || Time.now - @window_system.last_updated > Pra.config.refresh_interval + refresh_pull_requests + end + + Kernel.sleep(0.1) + end + + def refresh_pull_requests + @window_system.force_refresh = false @window_system.fetching_pull_requests new_pull_requests = [] Pra::PullRequestService.fetch_pull_requests do |fetch| fetch.on_success do |pull_requests| new_pull_requests += pull_requests end fetch.on_error do |error| - Pra::ErrorLog.log(error) + Pra::Log.error(error) @window_system.fetch_failed end end @window_system.refresh_pull_requests(new_pull_requests) - - Kernel.sleep(5 * 60) end def pull_request_fetcher_thread while( true ) do fetch_and_refresh_pull_requests