Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ protocol ProjectFactory {
}

// MARK: - Plist.Value Extension

extension Plist.Value {
static var displayName: Plist.Value = "42Box"
static var displayShareExtensionName: Plist.Value = "42Box.Share"
static var appVersion: Plist.Value = "1.0.1"

static var appVersion: Plist.Value = "1.0.2"
}

// MARK: - iBox Factory
Expand Down
12 changes: 7 additions & 5 deletions iBox/Sources/Initializer/DefaultData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ class DefaultData {
fetchDefaultData { defaultFolders in
DispatchQueue.main.async {
CoreDataManager.shared.deleteAllFolders()
CoreDataManager.shared.addInitialFolders(defaultFolders)
if let defaultFolders = defaultFolders {
CoreDataManager.shared.addInitialFolders(defaultFolders)
}
UserDefaultsManager.isDefaultDataInserted = true
completion?()
}
Expand All @@ -26,7 +28,7 @@ class DefaultData {
}
}

static func fetchDefaultData(completion: @escaping ([Folder]) -> Void) {
static func fetchDefaultData(completion: @escaping ([Folder]?) -> Void) {
let localDic: [String : String] = ["Seoul" : "default-kr", "default" : "default"]
let cityName = "Seoul"
let local = localDic[cityName] ?? "default"
Expand All @@ -35,20 +37,20 @@ class DefaultData {
URLSession.shared.dataTask(with: url) { data, response, error in
guard let data = data, error == nil else {
print("Error fetching default data: \(String(describing: error))")
completion(DefaultDataLoader.defaultData)
completion(nil)
return
}

do {
let folderData = try JSONDecoder().decode(FolderData.self, from: data)
let folders = [Folder(id: UUID(), name: "42 \(cityName)", bookmarks: folderData.list.map { Bookmark(id: UUID(), name: $0.name, url: URL(string: $0.url)!) })]
if let defaultURLData = URL(string: folderData.favorite) {
DefaultDataLoader.defaultURL = defaultURLData
}
let folders = [Folder(id: UUID(), name: "42 \(cityName)", bookmarks: folderData.list.map { Bookmark(id: UUID(), name: $0.name, url: URL(string: $0.url)!) })]
completion(folders)
} catch {
print("Error decoding JSON: \(error)")
completion(DefaultDataLoader.defaultData)
completion(nil)
}
}.resume()
}
Expand Down
6 changes: 3 additions & 3 deletions iBox/Sources/Initializer/DefaultDataModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ struct BookmarkData: Codable {
}

struct DefaultDataLoader {
static var defaultURL = URL(string: "https://github.com/42Box/iOS/blob/main/HowToUse.md#-how-to-use")!
static let defaultData = [
static var defaultURL = URL(string: "https://42box.github.io/iOSHowToUse/")!
static var defaultData: [Folder]? = [
Folder(id: UUID(), name: "42Box", bookmarks: [
Bookmark(id: UUID(), name: "How to use 42Box", url: URL(string: "https://github.com/42Box/iOS/blob/main/HowToUse.md#-how-to-use")!),
Bookmark(id: UUID(), name: "How to use 42Box", url: URL(string: "https://42box.github.io/iOSHowToUse/")!),
// Bookmark(id: UUID(), name: "42 Intra", url: URL(string: "https://profile.intra.42.fr/")!),
// Bookmark(id: UUID(), name: "42Where", url: URL(string: "https://www.where42.kr/")! ),
// Bookmark(id: UUID(), name: "42Stat", url: URL(string: "https://stat.42seoul.kr/")!),
Expand Down
6 changes: 3 additions & 3 deletions iBox/Sources/Settings/Reset/ResetViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ class ResetViewController: BaseViewController<ResetView>, BaseViewControllerProt
extension ResetViewController: ResetViewDelegate {

func showAlert() {
let alertController = UIAlertController(title: "κ²½κ³ ", message: "이 μž‘μ—…μ€ 되돌릴 수 μ—†μŠ΅λ‹ˆλ‹€. κ³„μ†ν•˜λ €λ©΄ \"iBox\"라고 μž…λ ₯ν•΄ μ£Όμ„Έμš”.", preferredStyle: .alert)
let alertController = UIAlertController(title: "κ²½κ³ ", message: "이 μž‘μ—…μ€ 되돌릴 수 μ—†μŠ΅λ‹ˆλ‹€. κ³„μ†ν•˜λ €λ©΄ \"42Box\"라고 μž…λ ₯ν•΄ μ£Όμ„Έμš”.", preferredStyle: .alert)

let cancelAction = UIAlertAction(title: "μ·¨μ†Œ", style: .cancel, handler: nil)
alertController.addAction(cancelAction)

let confirmAction = UIAlertAction(title: "확인", style: .default) { [weak self] _ in
guard let self = self else { return }
if let textField = alertController.textFields?.first, let text = textField.text, text == "iBox" {
if let textField = alertController.textFields?.first, let text = textField.text, text == "42Box" {
self.resetData()
} else {
self.showAlert()
Expand All @@ -58,7 +58,7 @@ extension ResetViewController: ResetViewDelegate {
alertController.addTextField() { textField in
NotificationCenter.default.addObserver(forName: UITextField.textDidChangeNotification, object: textField, queue: OperationQueue.main, using:
{_ in
let isTextMatch = textField.text?.trimmingCharacters(in: .whitespacesAndNewlines) == "iBox"
let isTextMatch = textField.text?.trimmingCharacters(in: .whitespacesAndNewlines) == "42Box"

confirmAction.isEnabled = isTextMatch
})
Expand Down