Handle friend added
This commit is contained in:
parent
b09e43deb0
commit
97b8b332b2
1 changed files with 18 additions and 3 deletions
21
lib/main.rb
21
lib/main.rb
|
@ -48,7 +48,7 @@ private
|
||||||
end
|
end
|
||||||
|
|
||||||
@tox_client.on_friend_request do |public_key|
|
@tox_client.on_friend_request do |public_key|
|
||||||
@tox_client.friend_add_norequest public_key
|
on_friend_add @tox_client.friend_add_norequest public_key
|
||||||
end
|
end
|
||||||
|
|
||||||
@screen = Screen.new
|
@screen = Screen.new
|
||||||
|
@ -181,8 +181,23 @@ private
|
||||||
{
|
{
|
||||||
name: friend.name.freeze,
|
name: friend.name.freeze,
|
||||||
online: friend.status == Tox::UserStatus::NONE,
|
online: friend.status == Tox::UserStatus::NONE,
|
||||||
}
|
}.freeze
|
||||||
end,
|
end.freeze,
|
||||||
|
).freeze,
|
||||||
|
).freeze,
|
||||||
|
).freeze
|
||||||
|
end
|
||||||
|
|
||||||
|
def on_friend_add(friend)
|
||||||
|
@state = state.merge(
|
||||||
|
sidebar: state[:sidebar].merge(
|
||||||
|
menu: state[:sidebar][:menu].merge(
|
||||||
|
items: (state[:sidebar][:menu][:items] + [
|
||||||
|
{
|
||||||
|
name: friend.name.freeze,
|
||||||
|
online: friend.status == Tox::UserStatus::NONE,
|
||||||
|
}.freeze,
|
||||||
|
]).freeze,
|
||||||
).freeze,
|
).freeze,
|
||||||
).freeze,
|
).freeze,
|
||||||
).freeze
|
).freeze
|
||||||
|
|
Reference in a new issue