lib/ayadn/scroll.rb in ayadn-1.6.0 vs lib/ayadn/scroll.rb in ayadn-1.7.0

- old
+ new

@@ -3,11 +3,13 @@ class Scroll def initialize(api, view) @api = api @view = view + @view.hide_cursor @chars = %w{ | / - \\ } + at_exit { @view.show_cursor } end def method_missing(meth, options) case meth.to_s when 'trending', 'photos', 'checkins', 'replies', 'global', 'unified' @@ -24,14 +26,14 @@ loop do begin stream = get(target, options) stream['data'].empty? ? niceranks = {} : niceranks = @nr.get_ranks(stream) Debug.stream stream, options, target - target = "explore:#{target}" if explore?(target) + target = "explore:#{target}" if explore?(target) # explore but not global show_if_new(stream, options, target, niceranks) target = orig_target if target =~ /explore/ - options = save_then_return(stream, options) + options = save_then_return(stream, options, target) countdown rescue Interrupt canceled end end @@ -43,11 +45,11 @@ loop do begin stream = @api.get_mentions(username, options) Debug.stream stream, options, username show_if_new(stream, options, "mentions:#{id}") - options = save_then_return(stream, options) + options = save_then_return(stream, options, "mentions:#{id}") countdown rescue Interrupt canceled end end @@ -59,11 +61,11 @@ loop do begin stream = @api.get_posts(username, options) Debug.stream stream, options, username show_if_new(stream, options, "posts:#{id}") - options = save_then_return(stream, options) + options = save_then_return(stream, options, "posts:#{id}") countdown rescue Interrupt canceled end end @@ -74,11 +76,11 @@ loop do begin stream = @api.get_convo(post_id, options) Debug.stream stream, options, post_id show_if_new(stream, options, "replies:#{post_id}") - options = save_then_return(stream, options) + options = save_then_return(stream, options, "replies:#{post_id}") countdown rescue Interrupt canceled end end @@ -89,11 +91,11 @@ loop do begin stream = @api.get_messages(channel_id, options) Debug.stream stream, options, channel_id show_if_new(stream, options, "channel:#{channel_id}") - options = save_then_return(stream, options) + options = save_then_return(stream, options, "channel:#{channel_id}") countdown rescue Interrupt canceled end end @@ -154,12 +156,12 @@ def show_if_new(stream, options, target, niceranks = {}) show(stream, options, niceranks) if Databases.has_new?(stream, target) end - def save_then_return(stream, options) + def save_then_return(stream, options, name = 'unknown') unless stream['meta']['max_id'].nil? - Databases.save_max_id(stream) + Databases.save_max_id(stream, name) return options_hash(stream, options) end options end