ласт воркинг билд с некоторыми патчами ибо могу

This commit is contained in:
Lain Iwakura 2025-08-07 22:43:06 +03:00
parent e2a4c5d8c0
commit 4c090d4295
No known key found for this signature in database
GPG Key ID: C7C18257F2ADC6F8
6 changed files with 32 additions and 9 deletions

View File

@ -3,7 +3,17 @@ import Foundation
class APIClient: ObservableObject {
private let baseURL = "https://mkch.pooziqo.xyz"
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 passcode: String = ""
private let userAgent = "MobileMkch/2.1.0-ios-alpha"

View File

@ -6,9 +6,12 @@ class BackgroundTaskManager {
static let shared = BackgroundTaskManager()
private var backgroundTaskIdentifier: String {
if let savedIdentifier = UserDefaults.standard.string(forKey: "BackgroundTaskIdentifier") {
return savedIdentifier
// Используем идентификатор из Info.plist (BGTaskSchedulerPermittedIdentifiers)
if let identifiers = Bundle.main.object(forInfoDictionaryKey: "BGTaskSchedulerPermittedIdentifiers") as? [String],
let first = identifiers.first {
return first
}
// Фоллбек на значение по умолчанию
return "com.mkch.MobileMkch.backgroundrefresh"
}
private let notificationManager = NotificationManager.shared

View File

@ -44,6 +44,9 @@ struct BoardsView: View {
}
.navigationTitle("Доски mkch")
.navigationBarTitleDisplayMode(.large)
.refreshable {
loadBoards()
}
.onAppear {
if boards.isEmpty {
loadBoards()

View File

@ -1,5 +1,9 @@
import Foundation
private enum DateFormatterCache {
static let iso8601 = ISO8601DateFormatter()
}
struct Board: Codable, Identifiable {
let code: String
let description: String
@ -18,8 +22,7 @@ struct Thread: Codable, Identifiable {
let files: [String]
var creationDate: Date {
let formatter = ISO8601DateFormatter()
return formatter.date(from: creation) ?? Date()
return DateFormatterCache.iso8601.date(from: creation) ?? Date()
}
var ratingValue: Int {
@ -40,8 +43,7 @@ struct ThreadDetail: Codable, Identifiable {
let files: [String]
var creationDate: Date {
let formatter = ISO8601DateFormatter()
return formatter.date(from: creation) ?? Date()
return DateFormatterCache.iso8601.date(from: creation) ?? Date()
}
}
@ -52,8 +54,7 @@ struct Comment: Codable, Identifiable {
let files: [String]
var creationDate: Date {
let formatter = ISO8601DateFormatter()
return formatter.date(from: creation) ?? Date()
return DateFormatterCache.iso8601.date(from: creation) ?? Date()
}
var formattedText: String {

View File

@ -71,6 +71,9 @@ struct ThreadDetailView: View {
}
.padding()
}
.refreshable {
loadThreadDetail()
}
.navigationTitle("#\(thread.id)")
.navigationBarTitleDisplayMode(.inline)
.toolbar {

View File

@ -53,6 +53,9 @@ struct ThreadsView: View {
}
}
}
.refreshable {
loadThreads()
}
if settings.enablePagination && totalPages > 1 {
HStack {