lib/ayadn/stream.rb in ayadn-1.7.7 vs lib/ayadn/stream.rb in ayadn-1.8.0

- old
+ new

@@ -19,14 +19,14 @@ Settings.options[:force] == true ? niceranks = {} : niceranks = NiceRank.new.get_ranks(stream) Check.no_new_posts(stream, options, 'global') Databases.save_max_id(stream, 'global') unless stream['meta']['max_id'].nil? @view.render(stream, options, niceranks) end - if Settings.options[:timeline][:compact] == true && options[:scroll] == true + if options[:scroll] @view.clear_screen() + Scroll.new(@api, @view).global(options) end - Scroll.new(@api, @view).global(options) if options[:scroll] puts "\n" if Settings.options[:timeline][:compact] && options[:raw].nil? end def method_missing(meth, options) @@ -49,14 +49,14 @@ stream = @api.send("get_#{meth}".to_sym, options) Check.no_new_posts(stream, options, target) Databases.save_max_id(stream) @view.render(stream, options) end - if Settings.options[:timeline][:compact] == true && options[:scroll] == true + if options[:scroll] @view.clear_screen() + Scroll.new(@api, @view).send(meth, options) end - Scroll.new(@api, @view).send(meth, options) if options[:scroll] puts "\n" if Settings.options[:timeline][:compact] && options[:raw].nil? end def mentions username, options @@ -71,14 +71,14 @@ Check.no_data(stream, 'mentions') options = options.dup options[:in_mentions] = true @view.render(stream, options) end - if Settings.options[:timeline][:compact] == true && options[:scroll] == true + if options[:scroll] @view.clear_screen() + Scroll.new(@api, @view).mentions(username, options) end - Scroll.new(@api, @view).mentions(username, options) if options[:scroll] puts "\n" if Settings.options[:timeline][:compact] && options[:raw].nil? end def posts username, options Settings.options[:force] = true if options[:force] @@ -199,16 +199,29 @@ Scroll.new(@api, @view).convo(id, options) if options[:scroll] puts "\n" if Settings.options[:timeline][:compact] && options[:raw].nil? end def messages(channel_id, options) + if options[:silent] + Settings.options[:marker][:update_messages] = false + end channel_id = @workers.get_channel_id_from_alias(channel_id) @view.downloading(options) resp = @api.get_messages(channel_id, options) - Check.no_new_posts(resp, options, "channel:#{channel_id}") + name = "channel:#{channel_id}" + Check.no_new_posts(resp, options, name) + if Settings.options[:marker][:update_messages] == true + unless resp['meta']['max_id'].nil? + marked = @api.update_marker(name, resp['meta']['max_id']) + updated = JSON.parse(marked) + if updated['meta']['code'] != 200 + raise "couldn't update channel #{channel_id} as read" + end + end + end Databases.save_max_id(resp) @view.if_raw(resp, options) - Check.no_data(resp, 'messages') + Check.no_data(resp, 'messages') unless options[:scroll] @view.render(resp, options) Scroll.new(@api, @view).messages(channel_id, options) if options[:scroll] puts "\n" if Settings.options[:timeline][:compact] && options[:raw].nil? end