From deaecca678cdcee9c6e1df90f9b083937ed614a9 Mon Sep 17 00:00:00 2001 From: LEO Yoon-Tsaw Date: Wed, 22 May 2024 21:57:47 -0400 Subject: [PATCH] do not showStatusMessage if no label has valid String --- sources/SquirrelApplicationDelegate.swift | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sources/SquirrelApplicationDelegate.swift b/sources/SquirrelApplicationDelegate.swift index d955ab701..cc677e93f 100644 --- a/sources/SquirrelApplicationDelegate.swift +++ b/sources/SquirrelApplicationDelegate.swift @@ -261,13 +261,11 @@ private func notificationHandler(contextObject: UnsafeMutableRawPointer?, sessio if !delegate.enableNotifications { return } - // schema change + if messageType == "schema", let messageValue = messageValue, let schemaName = try? /^[^\/]*\/(.*)$/.firstMatch(in: messageValue)?.output.1 { delegate.showStatusMessage(msgTextLong: String(schemaName), msgTextShort: String(schemaName)) return - } - // option change - if messageType == "option" { + } else if messageType == "option" { let state = messageValue?.first != "!" let optionName = if state { messageValue @@ -280,7 +278,9 @@ private func notificationHandler(contextObject: UnsafeMutableRawPointer?, sessio let stateLabelShort = delegate.rimeAPI.get_state_label_abbreviated(sessionId, name, state, true) let longLabel = stateLabelLong.str.map { String(cString: $0) } let shortLabel = stateLabelShort.str.map { String(cString: $0) } - delegate.showStatusMessage(msgTextLong: longLabel, msgTextShort: shortLabel) + if longLabel != nil || shortLabel != nil { + delegate.showStatusMessage(msgTextLong: longLabel, msgTextShort: shortLabel) + } } } }