Skip to content

Commit

Permalink
Update the message and the logic for block message
Browse files Browse the repository at this point in the history
1. option update now goes with showCustomInputMethodInfo, no need to
   block with keyboard event.
2. select schema shouldn't be the trigger of block message.
3. block message after success/error to prevent certain flood case if
   schema is invalid.
  • Loading branch information
wengxt authored and mokapsing committed Jun 13, 2024
1 parent 73c3638 commit 92b4073
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 7 additions & 0 deletions src/rimeengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,7 @@ void RimeEngine::notify(RimeSessionId session, const std::string &messageType,
const char *icon = "";
const char *tipId = "";
int timeout = 3000;
bool blockMessage = false;
if (messageType == "deploy") {
tipId = "fcitx-rime-deploy";
icon = "fcitx_rime_deploy";
Expand All @@ -585,10 +586,12 @@ void RimeEngine::notify(RimeSessionId session, const std::string &messageType,
}
updateSchemaMenu();
refreshStatusArea(0);
blockMessage = true;
} else if (messageValue == "failure") {
needRefreshAppOption_ = false;
message = _("Rime has encountered an error. "
"See log for details.");
blockMessage = true;
}
} else if (messageType == "option") {
updateStatusArea(session);
Expand All @@ -603,6 +606,10 @@ void RimeEngine::notify(RimeSessionId session, const std::string &messageType,
notifications->call<INotifications::showTip>(
tipId, _("Rime"), icon, _("Rime"), message, timeout);
}
// Block message after error / success.
if (blockMessage) {
blockNotificationFor(30000);
}
}

RimeState *RimeEngine::state(InputContext *ic) {
Expand Down
2 changes: 0 additions & 2 deletions src/rimestate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ void RimeState::selectSchema(const std::string &schema) {
if (api->is_maintenance_mode()) {
return;
}
engine_->blockNotificationFor(30000);
api->set_option(session(), RIME_ASCII_MODE, false);
api->select_schema(session(), schema.data());
}
Expand Down Expand Up @@ -460,7 +459,6 @@ void RimeState::updateUI(InputContext *ic, bool keyRelease) {
inputPanel.setAuxDown(Text());
}
if (newEmptyExceptAux && lastMode_ != subMode()) {
engine_->blockNotificationFor(30000);
engine_->instance()->showInputMethodInformation(ic);
ic->updateUserInterface(UserInterfaceComponent::StatusArea);
}
Expand Down

0 comments on commit 92b4073

Please sign in to comment.