Skip to content

Commit 56359c6

Browse files
committed
fix reload single extension; fix add double im entries
1 parent 77d28f4 commit 56359c6

File tree

3 files changed

+23
-5
lines changed

3 files changed

+23
-5
lines changed

ipc/ipc.swift

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,27 @@ public func openURL(_ urlString: String) {
99
}
1010
}
1111

12+
private func listKeyboards() -> [String] {
13+
let pluginsURL = Bundle.main.bundleURL.appendingPathComponent("PlugIns")
14+
var result = [String]()
15+
if let items = try? FileManager.default.contentsOfDirectory(
16+
at: pluginsURL,
17+
includingPropertiesForKeys: nil,
18+
options: [.skipsHiddenFiles])
19+
{
20+
for item in items where item.pathExtension == "appex" {
21+
result.append(item.deletingPathExtension().lastPathComponent)
22+
}
23+
}
24+
return result
25+
}
26+
1227
public func requestReload() {
1328
mkdirP(appGroupTmp.path)
14-
try? "".write(
15-
to: appGroupTmp.appendingPathComponent("reload"), atomically: true, encoding: .utf8)
29+
for keyboard in listKeyboards() {
30+
try? "".write(
31+
to: appGroupTmp.appendingPathComponent("\(keyboard).reload"), atomically: true,
32+
encoding: .utf8)
33+
}
1634
logger.info("Reload requested")
1735
}

keyboard/KeyboardViewController.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ class KeyboardViewController: UIInputViewController, FcitxProtocol {
6464
logger.info("viewWillAppear \(self.id)")
6565
virtualKeyboardView.setReturnKeyType(textDocumentProxy.returnKeyType)
6666
super.viewWillAppear(animated)
67-
if removeFile(appGroupTmp.appendingPathComponent("reload")) {
67+
let keyboard = Bundle.main.bundleURL.deletingPathExtension().lastPathComponent
68+
if removeFile(appGroupTmp.appendingPathComponent("\(keyboard).reload")) {
6869
logger.info("Reload accepted")
6970
reload()
7071
}

src/InputMethodsView.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ struct AddInputMethodsView: View {
5353
enabledInputMethods.append(inputMethod)
5454
setInputMethods(
5555
String(
56-
data: try! JSONEncoder().encode(
57-
enabledInputMethods.map { $0.name } + [inputMethod.name]),
56+
data: try! JSONEncoder().encode(enabledInputMethods.map { $0.name }),
5857
encoding: .utf8)!)
5958
requestReload()
6059
message = String(

0 commit comments

Comments
 (0)