ласт воркинг билд с некоторыми патчами ибо могу
This commit is contained in:
parent
e2a4c5d8c0
commit
4c090d4295
@ -3,7 +3,17 @@ import Foundation
|
|||||||
class APIClient: ObservableObject {
|
class APIClient: ObservableObject {
|
||||||
private let baseURL = "https://mkch.pooziqo.xyz"
|
private let baseURL = "https://mkch.pooziqo.xyz"
|
||||||
private let apiURL = "https://mkch.pooziqo.xyz/api"
|
private let apiURL = "https://mkch.pooziqo.xyz/api"
|
||||||
private let session = URLSession.shared
|
private lazy var session: URLSession = {
|
||||||
|
let config = URLSessionConfiguration.default
|
||||||
|
config.timeoutIntervalForRequest = 20
|
||||||
|
config.timeoutIntervalForResource = 40
|
||||||
|
config.httpAdditionalHeaders = [
|
||||||
|
"Accept": "application/json",
|
||||||
|
"Accept-Language": Locale.preferredLanguages.first ?? "ru-RU",
|
||||||
|
"User-Agent": self.userAgent
|
||||||
|
]
|
||||||
|
return URLSession(configuration: config)
|
||||||
|
}()
|
||||||
private var authKey: String = ""
|
private var authKey: String = ""
|
||||||
private var passcode: String = ""
|
private var passcode: String = ""
|
||||||
private let userAgent = "MobileMkch/2.1.0-ios-alpha"
|
private let userAgent = "MobileMkch/2.1.0-ios-alpha"
|
||||||
|
|||||||
@ -6,9 +6,12 @@ class BackgroundTaskManager {
|
|||||||
static let shared = BackgroundTaskManager()
|
static let shared = BackgroundTaskManager()
|
||||||
|
|
||||||
private var backgroundTaskIdentifier: String {
|
private var backgroundTaskIdentifier: String {
|
||||||
if let savedIdentifier = UserDefaults.standard.string(forKey: "BackgroundTaskIdentifier") {
|
// Используем идентификатор из Info.plist (BGTaskSchedulerPermittedIdentifiers)
|
||||||
return savedIdentifier
|
if let identifiers = Bundle.main.object(forInfoDictionaryKey: "BGTaskSchedulerPermittedIdentifiers") as? [String],
|
||||||
|
let first = identifiers.first {
|
||||||
|
return first
|
||||||
}
|
}
|
||||||
|
// Фоллбек на значение по умолчанию
|
||||||
return "com.mkch.MobileMkch.backgroundrefresh"
|
return "com.mkch.MobileMkch.backgroundrefresh"
|
||||||
}
|
}
|
||||||
private let notificationManager = NotificationManager.shared
|
private let notificationManager = NotificationManager.shared
|
||||||
|
|||||||
@ -44,6 +44,9 @@ struct BoardsView: View {
|
|||||||
}
|
}
|
||||||
.navigationTitle("Доски mkch")
|
.navigationTitle("Доски mkch")
|
||||||
.navigationBarTitleDisplayMode(.large)
|
.navigationBarTitleDisplayMode(.large)
|
||||||
|
.refreshable {
|
||||||
|
loadBoards()
|
||||||
|
}
|
||||||
.onAppear {
|
.onAppear {
|
||||||
if boards.isEmpty {
|
if boards.isEmpty {
|
||||||
loadBoards()
|
loadBoards()
|
||||||
|
|||||||
@ -1,5 +1,9 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
|
private enum DateFormatterCache {
|
||||||
|
static let iso8601 = ISO8601DateFormatter()
|
||||||
|
}
|
||||||
|
|
||||||
struct Board: Codable, Identifiable {
|
struct Board: Codable, Identifiable {
|
||||||
let code: String
|
let code: String
|
||||||
let description: String
|
let description: String
|
||||||
@ -18,8 +22,7 @@ struct Thread: Codable, Identifiable {
|
|||||||
let files: [String]
|
let files: [String]
|
||||||
|
|
||||||
var creationDate: Date {
|
var creationDate: Date {
|
||||||
let formatter = ISO8601DateFormatter()
|
return DateFormatterCache.iso8601.date(from: creation) ?? Date()
|
||||||
return formatter.date(from: creation) ?? Date()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var ratingValue: Int {
|
var ratingValue: Int {
|
||||||
@ -40,8 +43,7 @@ struct ThreadDetail: Codable, Identifiable {
|
|||||||
let files: [String]
|
let files: [String]
|
||||||
|
|
||||||
var creationDate: Date {
|
var creationDate: Date {
|
||||||
let formatter = ISO8601DateFormatter()
|
return DateFormatterCache.iso8601.date(from: creation) ?? Date()
|
||||||
return formatter.date(from: creation) ?? Date()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,8 +54,7 @@ struct Comment: Codable, Identifiable {
|
|||||||
let files: [String]
|
let files: [String]
|
||||||
|
|
||||||
var creationDate: Date {
|
var creationDate: Date {
|
||||||
let formatter = ISO8601DateFormatter()
|
return DateFormatterCache.iso8601.date(from: creation) ?? Date()
|
||||||
return formatter.date(from: creation) ?? Date()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var formattedText: String {
|
var formattedText: String {
|
||||||
|
|||||||
@ -71,6 +71,9 @@ struct ThreadDetailView: View {
|
|||||||
}
|
}
|
||||||
.padding()
|
.padding()
|
||||||
}
|
}
|
||||||
|
.refreshable {
|
||||||
|
loadThreadDetail()
|
||||||
|
}
|
||||||
.navigationTitle("#\(thread.id)")
|
.navigationTitle("#\(thread.id)")
|
||||||
.navigationBarTitleDisplayMode(.inline)
|
.navigationBarTitleDisplayMode(.inline)
|
||||||
.toolbar {
|
.toolbar {
|
||||||
|
|||||||
@ -53,6 +53,9 @@ struct ThreadsView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.refreshable {
|
||||||
|
loadThreads()
|
||||||
|
}
|
||||||
|
|
||||||
if settings.enablePagination && totalPages > 1 {
|
if settings.enablePagination && totalPages > 1 {
|
||||||
HStack {
|
HStack {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user