From 4361b6e4e39b761957beef22b8254c22908921c6 Mon Sep 17 00:00:00 2001 From: Braiden Vasco Date: Thu, 27 Jul 2017 22:01:17 +0000 Subject: [PATCH] Show error mark if message not received after 10 secs --- lib/main.rb | 11 ++++++----- lib/widgets/chat/history.rb | 9 ++++++++- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/lib/main.rb b/lib/main.rb index 3d37ae1..931c5ab 100644 --- a/lib/main.rb +++ b/lib/main.rb @@ -280,11 +280,12 @@ private ), history: (state[:friends][friend_number][:history] + [ - error: error, - out: true, - time: Time.now.utc.freeze, - name: @tox_client.name.freeze, - text: text, + error: error, + out: true, + received: false, + time: Time.now.utc.freeze, + name: @tox_client.name.freeze, + text: text, ]).freeze, ).freeze, ).freeze, diff --git a/lib/widgets/chat/history.rb b/lib/widgets/chat/history.rb index ab67df1..30a762d 100644 --- a/lib/widgets/chat/history.rb +++ b/lib/widgets/chat/history.rb @@ -13,7 +13,14 @@ module Widgets offset = 0 props[:messages].reverse_each do |msg| - offset += draw_message offset, msg[:error], msg[:out], msg[:time].strftime('%H:%M:%S'), msg[:name], msg[:text] + offset += draw_message( + offset, + msg[:error] || msg[:out] && !msg[:received] && Time.now.utc - msg[:time] > 10, + msg[:out], + msg[:time].strftime('%H:%M:%S'), + msg[:name], + msg[:text], + ) break if offset >= props[:height] end