Class: Twterm::Tab::DirectMessage::ConversationList
Instance Attribute Summary
Attributes included from Scrollable
#scroller
Attributes inherited from Base
#window
Instance Method Summary
collapse
Methods included from Subscriber
included, #subscribe, #unsubscribe
Methods included from Scrollable
#total_item_count
#filter, #filter_query, #reset_filter
Methods included from Publisher
#publish
Methods included from Utils
check_type
Methods inherited from Base
#close, #refresh
Constructor Details
Returns a new instance of ConversationList.
19
20
21
22
23
|
# File 'lib/twterm/tab/direct_message/conversation_list.rb', line 19
def initialize
super
subscribe(Event::DirectMessage::Fetched) { refresh }
end
|
Instance Method Details
#==(other) ⇒ Object
25
26
27
|
# File 'lib/twterm/tab/direct_message/conversation_list.rb', line 25
def ==(other)
other.is_a?(self.class)
end
|
#drawable_item_count ⇒ Object
15
16
17
|
# File 'lib/twterm/tab/direct_message/conversation_list.rb', line 15
def drawable_item_count
window.maxy.-(2).div(3)
end
|
#items ⇒ Object
29
30
31
32
33
34
35
|
# File 'lib/twterm/tab/direct_message/conversation_list.rb', line 29
def items
if filter_query.empty?
Client.current.direct_message_conversations
else
Client.current.direct_message_conversations.select { |c| c.matches?(filter_query) }
end
end
|
#respond_to_key(key) ⇒ Object
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/twterm/tab/direct_message/conversation_list.rb', line 37
def respond_to_key(key)
return true if scroller.respond_to_key(key)
case key
when 10
open_conversation
when ?n, ?r
conversation = current_item
DirectMessageComposer.instance.compose(conversation.collocutor)
when ?/
filter
when ?q
reset_filter
else
return false
end
true
end
|
#title ⇒ Object
84
85
86
|
# File 'lib/twterm/tab/direct_message/conversation_list.rb', line 84
def title
'Direct Messages'
end
|
#update ⇒ Object
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
# File 'lib/twterm/tab/direct_message/conversation_list.rb', line 57
def update
scroller.drawable_items.each.with_index(0) do |conversation, i|
line = 3 * i
window.with_color(:black, :magenta) do
2.times do |j|
window.setpos(line + j, 0)
window.addch(' ')
end
end if scroller.current_item?(i)
window.setpos(line, 2)
window.bold do
window.with_color(conversation.collocutor.color) do
window.addstr(conversation.collocutor.name)
end
end
window.addstr(' (@%s)' % conversation.collocutor.screen_name)
window.addstr(' [%s]' % conversation.updated_at)
window.setpos(line + 1, 2)
window.addstr(conversation.preview.split_by_width(window.maxx - 4).first)
end
end
|