lib/ayadn/scroll.rb in ayadn-1.8.2 vs lib/ayadn/scroll.rb in ayadn-2.0
- old
+ new
@@ -4,11 +4,11 @@
def initialize(api, view)
@api = api
@view = view
@view.hide_cursor
- @chars = %w{ | / - \\ }
+ @chars = %w{ - \\ | / }
at_exit { @view.show_cursor }
end
def method_missing(meth, options)
case meth.to_s
@@ -18,109 +18,124 @@
super
end
end
def scroll_it(target, options)
+ Settings.global[:scrolling] = true
options = check_raw(options)
orig_target = target
@nr = NiceRank.new
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) # explore but not global
+ clear() if Settings.options[:scroll][:spinner] == true
show_if_new(stream, options, target, niceranks)
target = orig_target if target =~ /explore/
options = save_then_return(stream, options, target)
countdown
+ print "..." if Settings.options[:scroll][:spinner] == true
rescue Interrupt
canceled
end
end
end
def mentions(username, options)
+ Settings.global[:scrolling] = true
options = check_raw(options)
id = @api.get_user(username)['data']['id']
loop do
begin
stream = @api.get_mentions(username, options)
Debug.stream stream, options, username
+ clear() if Settings.options[:scroll][:spinner] == true
show_if_new(stream, options, "mentions:#{id}")
options = save_then_return(stream, options, "mentions:#{id}")
countdown
+ print "..." if Settings.options[:scroll][:spinner] == true
rescue Interrupt
canceled
end
end
end
def posts(username, options)
+ Settings.global[:scrolling] = true
options = check_raw(options)
id = @api.get_user(username)['data']['id']
loop do
begin
stream = @api.get_posts(username, options)
Debug.stream stream, options, username
+ clear() if Settings.options[:scroll][:spinner] == true
show_if_new(stream, options, "posts:#{id}")
options = save_then_return(stream, options, "posts:#{id}")
countdown
+ print "..." if Settings.options[:scroll][:spinner] == true
rescue Interrupt
canceled
end
end
end
def convo(post_id, options)
+ Settings.global[:scrolling] = true
options = check_raw(options)
loop do
begin
stream = @api.get_convo(post_id, options)
Debug.stream stream, options, post_id
+ clear() if Settings.options[:scroll][:spinner] == true
show_if_new(stream, options, "replies:#{post_id}")
options = save_then_return(stream, options, "replies:#{post_id}")
countdown
+ print "..." if Settings.options[:scroll][:spinner] == true
rescue Interrupt
canceled
end
end
end
def messages(channel_id, options)
+ Settings.global[:scrolling] = true
options = check_raw(options)
loop do
begin
stream = @api.get_messages(channel_id, options)
Debug.stream stream, options, channel_id
+ clear() if Settings.options[:scroll][:spinner] == true
show_if_new(stream, options, "channel:#{channel_id}")
- if Settings.options[:marker][:update_messages] == true
+ if Settings.options[:marker][:messages] == true
unless resp['meta']['max_id'].nil?
marked = @api.update_marker("channel:#{channel_id}", stream['meta']['max_id'])
updated = JSON.parse(marked)
if updated['meta']['code'] != 200
Errors.warn "couldn't update channel #{channel_id} as read"
end
end
end
options = save_then_return(stream, options, "channel:#{channel_id}")
countdown
+ print "..." if Settings.options[:scroll][:spinner] == true
rescue Interrupt
canceled
end
end
end
private
def countdown
- Settings.options[:timeline][:show_spinner] == true ? waiting : pause
+ Settings.options[:scroll][:spinner] == true ? waiting : pause
end
def clear
print("\r")
- print(" ".ljust(5))
+ print(" ".ljust(40))
print("\r")
end
def spin
print(@chars[0]) # Print the next character...
@@ -206,10 +221,10 @@
@view.show_posts(stream['data'], options, niceranks)
end
end
def canceled
- puts Status.canceled
+ Status.new.canceled
exit
end
end
end