Skip to content

Commit 19aabea

Browse files
committed
feat: remove built in database and read from new downloaded one
1 parent 5cb3825 commit 19aabea

12 files changed

Lines changed: 36 additions & 193 deletions
-11.2 MB
Binary file not shown.
-2.27 MB
Binary file not shown.
-4.73 MB
Binary file not shown.
-2.54 MB
Binary file not shown.
-4.08 MB
Binary file not shown.
-472 KB
Binary file not shown.
-8.32 MB
Binary file not shown.
-5.02 MB
Binary file not shown.

Keyboards/DataManager/LanguageDBManager.swift

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class LanguageDBManager {
1616
if translate {
1717
database = openDBQueue("TranslationData")
1818
} else {
19-
database = openDBQueue("\(getControllerLanguageAbbr().uppercased())LanguageData")
19+
database = openDownloadedDBQueue("\(getControllerLanguageAbbr().uppercased())LanguageData")
2020
}
2121
}
2222

@@ -42,6 +42,20 @@ class LanguageDBManager {
4242
}
4343
}
4444

45+
private func openDownloadedDBQueue(_ dbName: String) -> DatabaseQueue? {
46+
let fileManager = FileManager.default
47+
guard let containerURL = fileManager.containerURL(forSecurityApplicationGroupIdentifier: "group.be.scri.userDefaultsContainer") else {
48+
print("App group container not found")
49+
return nil
50+
}
51+
let dbPath = containerURL.appendingPathComponent("\(dbName).sqlite").path
52+
guard fileManager.fileExists(atPath: dbPath) else {
53+
print("\(dbName).sqlite not found in app group container")
54+
return nil
55+
}
56+
return try? DatabaseQueue(path: dbPath)
57+
}
58+
4559
/// Loads a JSON file that contains grammatical information into a dictionary.
4660
///
4761
/// - Parameters

Keyboards/KeyboardsBase/KeyboardViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ class KeyboardViewController: UIInputViewController {
457457
// Get options for completion that start with the current prefix and are not just one letter.
458458
let completionOptions = LanguageDBManager.shared.queryAutocompletions(word: currentPrefix)
459459

460-
if !completionOptions[0].isEmpty {
460+
if !completionOptions.isEmpty && !completionOptions[0].isEmpty {
461461
if completionOptions.count <= 3 {
462462
for i in 0 ..< completionOptions.count {
463463
if shiftButtonState == .shift {

0 commit comments

Comments
 (0)