@@ -12,7 +12,6 @@ local addonName, DF = ...
1212-- diacritic-normalised); the display hook; conflict/overlap analysis;
1313-- source pickers (group/guild/friends/B.net); an optional nickname marker;
1414-- and sharing (broadcast/accept, in Features/NicknamesComm.lua).
15- -- NOTE: the /dfnick slash command is dev-only scaffolding to retire before release.
1615-- ============================================================
1716
1817local pairs , ipairs , type = pairs , ipairs , type
@@ -64,6 +63,9 @@ local DIACRITICS = {
6463function NK :Normalize (str )
6564 if not str or str == " " then return " " end
6665 str = strlower (str )
66+ -- Fast path: plain-ASCII names (the common case) have no accents to strip,
67+ -- so skip the diacritic table entirely. Accented UTF-8 bytes are >= 0x80.
68+ if not strfind (str , " [\128 -\255 ]" ) then return str end
6769 -- Replace each known accented UTF-8 sequence with its base letter.
6870 for accented , base in pairs (DIACRITICS ) do
6971 str = gsub (str , accented , base )
@@ -363,10 +365,23 @@ function NK:RefreshAllFrames()
363365 end )
364366 end
365367 -- Notify any UI listener (e.g. the options panel) so it stays in sync no
366- -- matter where the change came from (GUI, /dfnick, future sharing, ...).
368+ -- matter where the change came from (GUI, sharing, ...).
367369 if NK .onChange then NK .onChange () end
368370end
369371
372+ -- Coalesce a burst of refreshes (e.g. many incoming nicknames when a group
373+ -- forms) into a single frame redraw shortly after the activity settles.
374+ function NK :ScheduleRefresh ()
375+ NK ._refreshToken = (NK ._refreshToken or 0 ) + 1
376+ local token = NK ._refreshToken
377+ C_Timer .After (0.2 , function ()
378+ -- Only the last call in a burst matches the token, so the redraw runs once.
379+ if NK ._refreshToken == token then
380+ NK :RefreshAllFrames ()
381+ end
382+ end )
383+ end
384+
370385-- ============================================================
371386-- ENTRY HELPERS (used by the GUI add/edit flow)
372387-- ============================================================
690705-- RECEIVED NICKNAMES (Phase 4 — shared to us by other users)
691706-- Kept SEPARATE from the curated list (NK.received, session-only) and used
692707-- only as a LOWEST-priority fallback in Resolve, so your own rules always
693- -- win. The comm layer (next slice) fills this from broadcasts; for now a
694- -- dev command (/dfnick recv) can simulate an incoming nickname.
708+ -- win. The comm layer (Features/NicknamesComm.lua) fills this from broadcasts.
695709-- ============================================================
696710
697711NK .received = NK .received or {} -- [normFull | normName] = { nick=, sender= }
@@ -764,7 +778,8 @@ function NK:AddReceived(fullName, nick, sender)
764778 local name = strsplit (" -" , fullName )
765779 NK .received [NK :Normalize (fullName )] = entry
766780 if name and name ~= " " then NK .received [NK :Normalize (name )] = entry end
767- NK :RefreshAllFrames ()
781+ -- Debounced: a group forming can deliver many of these at once.
782+ NK :ScheduleRefresh ()
768783end
769784
770785-- User block / unblock for a sender (persisted in `rejected`). Filter-blocked
0 commit comments