Skip to content

Commit de29375

Browse files
committed
fix adding im clears available im list
1 parent 122e0ba commit de29375

File tree

2 files changed

+16
-18
lines changed

2 files changed

+16
-18
lines changed

patches/fcitx5.patch

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
diff --git a/CMakeLists.txt b/CMakeLists.txt
2-
index aa90bad4..fa6e165f 100644
2+
index 3c7bc877..12612326 100644
33
--- a/CMakeLists.txt
44
+++ b/CMakeLists.txt
5-
@@ -191,9 +191,7 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DI
5+
@@ -224,9 +224,7 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DI
66
include_directories(${CMAKE_CURRENT_BINARY_DIR})
77

88
add_subdirectory(src)
@@ -30,10 +30,10 @@ index 85c9865b..edf51a44 100644
3030
)
3131
target_include_directories(Fcitx5Config PUBLIC
3232
diff --git a/src/lib/fcitx-utils/CMakeLists.txt b/src/lib/fcitx-utils/CMakeLists.txt
33-
index e1498a14..119d193d 100644
33+
index 4fe67c8d..29514786 100644
3434
--- a/src/lib/fcitx-utils/CMakeLists.txt
3535
+++ b/src/lib/fcitx-utils/CMakeLists.txt
36-
@@ -121,10 +121,9 @@ ecm_setup_version(PROJECT
36+
@@ -119,10 +119,9 @@ ecm_setup_version(PROJECT
3737
PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/Fcitx5UtilsConfigVersion.cmake"
3838
SOVERSION 2)
3939

src/InputMethodsView.swift

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,17 @@ struct InputMethodsSectionHeaderView: View {
1919
}
2020
}
2121

22-
private class ViewModel: ObservableObject {
23-
@Published var inputMethods = [InputMethod]()
22+
func availableInputMethods() -> [InputMethod] {
23+
let allInputMethods = try! JSONDecoder().decode(
24+
[InputMethod].self, from: String(getAllInputMethods()).data(using: .utf8)!)
25+
let enabledInputMethods = try! JSONDecoder().decode(
26+
[InputMethod].self, from: String(getInputMethods()).data(using: .utf8)!
27+
).map { $0.name }
28+
return allInputMethods.filter { !enabledInputMethods.contains($0.name) }
29+
}
2430

25-
func refresh() {
26-
let allInputMethods = try! JSONDecoder().decode(
27-
[InputMethod].self, from: String(getAllInputMethods()).data(using: .utf8)!)
28-
let enabledInputMethods = try! JSONDecoder().decode(
29-
[InputMethod].self, from: String(getInputMethods()).data(using: .utf8)!
30-
).map { $0.name }
31-
inputMethods = allInputMethods.filter { !enabledInputMethods.contains($0.name) }
32-
}
31+
private class ViewModel: ObservableObject {
32+
@Published var inputMethods = availableInputMethods()
3333
}
3434

3535
struct AddInputMethodsView: View {
@@ -54,7 +54,8 @@ struct AddInputMethodsView: View {
5454
enabledInputMethods.append(inputMethod)
5555
setInputMethods(
5656
String(
57-
data: try! JSONEncoder().encode(enabledInputMethods.map { $0.name }),
57+
data: try! JSONEncoder().encode(
58+
enabledInputMethods.map { $0.name } + [inputMethod.name]),
5859
encoding: .utf8)!)
5960
requestReload()
6061
message = "Added \(inputMethod.displayName)"
@@ -78,8 +79,5 @@ struct AddInputMethodsView: View {
7879
}
7980
.navigationTitle("Add input methods")
8081
.navigationBarTitleDisplayMode(.inline)
81-
.onAppear {
82-
viewModel.refresh()
83-
}
8482
}
8583
}

0 commit comments

Comments
 (0)