Load friends for Tox client
This commit is contained in:
parent
29f0a8287c
commit
b09e43deb0
1 changed files with 17 additions and 0 deletions
17
lib/main.rb
17
lib/main.rb
|
@ -40,6 +40,8 @@ private
|
||||||
|
|
||||||
@tox_client = Tox::Client.new tox_options
|
@tox_client = Tox::Client.new tox_options
|
||||||
|
|
||||||
|
on_friends_load @tox_client.friends
|
||||||
|
|
||||||
@tox_client.on_iteration do
|
@tox_client.on_iteration do
|
||||||
after_iteration
|
after_iteration
|
||||||
before_iteration
|
before_iteration
|
||||||
|
@ -171,6 +173,21 @@ private
|
||||||
}.freeze
|
}.freeze
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def on_friends_load(friends)
|
||||||
|
@state = state.merge(
|
||||||
|
sidebar: state[:sidebar].merge(
|
||||||
|
menu: state[:sidebar][:menu].merge(
|
||||||
|
items: friends.map do |friend|
|
||||||
|
{
|
||||||
|
name: friend.name.freeze,
|
||||||
|
online: friend.status == Tox::UserStatus::NONE,
|
||||||
|
}
|
||||||
|
end,
|
||||||
|
).freeze,
|
||||||
|
).freeze,
|
||||||
|
).freeze
|
||||||
|
end
|
||||||
|
|
||||||
def on_window_left
|
def on_window_left
|
||||||
@state = state.merge(
|
@state = state.merge(
|
||||||
focus: :sidebar,
|
focus: :sidebar,
|
||||||
|
|
Reference in a new issue