Skip to content

Commit 5b9cf0d

Browse files
committed
Fix spurious notification bubbles
1 parent 8996340 commit 5b9cf0d

File tree

3 files changed

+43
-22
lines changed

3 files changed

+43
-22
lines changed

tptmp/client/init.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,9 @@ local function run()
217217
begin_chat_func = begin_chat,
218218
window_status_func = get_window_status,
219219
sync_func = function()
220+
win:set_silent(true)
220221
cmd:parse("/sync")
222+
win:set_silent(false)
221223
end,
222224
})
223225

tptmp/client/profile/vanilla.lua

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -924,26 +924,28 @@ function profile_i:handle_mousedown(px, py, button)
924924
if key == "unknown" then
925925
local identifier = self.display_toolwarn_identifier_
926926
local ids = self.xidr_unsupported_[identifier]
927-
local display_as = identifier
928-
if elem[identifier] then
929-
display_as = elem.property(elem[identifier], "Name")
930-
end
931-
self.log_event_func_(("The following users in the room cannot use %s, please avoid using it while connected"):format(display_as))
932-
local str = ""
933-
local function commit()
934-
self.log_event_func_(" - " .. str)
935-
str = ""
936-
end
937-
for i = 1, #ids do
938-
str = str .. self.client_.id_to_member[ids[i]].formatted_nick
939-
if i < #ids then
940-
str = str .. "\bw, "
927+
if ids then -- TODO: remove; this should always be a table but there's some sequencing problem that I can't figure out
928+
local display_as = identifier
929+
if elem[identifier] then
930+
display_as = elem.property(elem[identifier], "Name")
931+
end
932+
self.log_event_func_(("The following users in the room cannot use %s, please avoid using it while connected"):format(display_as))
933+
local str = ""
934+
local function commit()
935+
self.log_event_func_(" - " .. str)
936+
str = ""
941937
end
942-
if gfx.textSize(str) > gfx.WIDTH / 2 then
943-
commit()
938+
for i = 1, #ids do
939+
str = str .. self.client_.id_to_member[ids[i]].formatted_nick
940+
if i < #ids then
941+
str = str .. "\bw, "
942+
end
943+
if gfx.textSize(str) > gfx.WIDTH / 2 then
944+
commit()
945+
end
944946
end
947+
commit()
945948
end
946-
commit()
947949
else
948950
self.log_event_func_(toolwarn_messages[key])
949951
end

tptmp/client/window.lua

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,9 @@ function window_i:backlog_update_()
295295
end
296296

297297
function window_i:backlog_push_(collect, important)
298+
if self.silent_ then
299+
important = false
300+
end
298301
self.backlog_unique_ = self.backlog_unique_ + 1
299302
local msg = {
300303
unique = self.backlog_unique_,
@@ -323,6 +326,10 @@ function window_i:backlog_push_str(str, important)
323326
end
324327
end
325328

329+
function window_i:backlog_mark_seen()
330+
self.backlog_last_seen_ = self.backlog_last_wrapped_
331+
end
332+
326333
function window_i:backlog_bump_marker()
327334
self.backlog_enable_marker_ = false
328335
if self.backlog_last_seen_ < self.backlog_unique_ then
@@ -395,7 +402,7 @@ function window_i:handle_tick()
395402
local now = socket.gettime()
396403

397404
if self.backlog_auto_scroll_ and not floating then
398-
self.backlog_last_seen_ = self.backlog_last_wrapped_
405+
self:backlog_mark_seen()
399406
else
400407
if self.backlog_last_seen_ < self.backlog_unique_ and not self.backlog_enable_marker_ then
401408
self:backlog_bump_marker()
@@ -580,10 +587,15 @@ function window_i:handle_mousedown(px, py, button)
580587
end
581588
end
582589

590+
function window_i:hide_window()
591+
self:backlog_mark_seen()
592+
self.hide_window_func_()
593+
end
594+
583595
function window_i:handle_mouseup(px, py, button)
584596
if button == ui.SDL_BUTTON_LEFT then
585597
if self.close_active_ then
586-
self.hide_window_func_()
598+
self:hide_window()
587599
end
588600
self.resizer_active_ = false
589601
self.dragger_active_ = false
@@ -652,7 +664,7 @@ function window_i:handle_keypress(key, scan, rep, shift, ctrl, alt)
652664
self:input_reset_()
653665
end
654666
if shift or force_hide then
655-
self.hide_window_func_()
667+
self:hide_window()
656668
end
657669
else
658670
self.in_focus = true
@@ -783,7 +795,7 @@ function window_i:handle_keypress(key, scan, rep, shift, ctrl, alt)
783795
if self.hide_when_chat_done then
784796
self.hide_when_chat_done = false
785797
self.in_focus = false
786-
self.hide_window_func_()
798+
self:hide_window()
787799
end
788800
end
789801
else
@@ -870,7 +882,7 @@ function window_i:handle_keypress(key, scan, rep, shift, ctrl, alt)
870882
return not modkey_scan[scan]
871883
else
872884
if not ctrl and not alt and scan == ui.SDL_SCANCODE_ESCAPE then
873-
self.hide_window_func_()
885+
self:hide_window()
874886
return true
875887
end
876888
end
@@ -925,6 +937,10 @@ local function set_size_clamp(new_width, new_height, new_pos_x, new_pos_y)
925937
return width, height, pos_x, pos_y
926938
end
927939

940+
function window_i:set_silent(silent)
941+
self.silent_ = silent
942+
end
943+
928944
function window_i:set_size(new_width, new_height)
929945
self.width_, self.height_, self.pos_x_, self.pos_y_ = set_size_clamp(new_width, new_height, self.pos_x_, self.pos_y_)
930946
self:input_update_()
@@ -1127,6 +1143,7 @@ local function new(params)
11271143
local title_width = gfx.textSize(title)
11281144
local win = setmetatable({
11291145
in_focus = false,
1146+
silent_ = false,
11301147
pos_x_ = pos_x,
11311148
pos_y_ = pos_y,
11321149
width_ = width,

0 commit comments

Comments
 (0)