Skip to content

Commit

Permalink
Bug fix and improvement (#179)
Browse files Browse the repository at this point in the history
* show catagory name on nav bar

* empty space also tapable during bulk select

* better log
  • Loading branch information
Doraemoe authored Jun 17, 2023
1 parent ffe641d commit 90f1a6b
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 32 deletions.
20 changes: 12 additions & 8 deletions DuManga.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
E9BE57B42942F1AB00A3AEA0 /* LockScreenModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = E9BE57B32942F1AB00A3AEA0 /* LockScreenModel.swift */; };
E9C73DC42A1C5F4900EFDD81 /* HistoryList.swift in Sources */ = {isa = PBXBuildFile; fileRef = E9C73DC32A1C5F4900EFDD81 /* HistoryList.swift */; };
E9C73DC72A1C6F2F00EFDD81 /* HistoryListModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = E9C73DC62A1C6F2F00EFDD81 /* HistoryListModel.swift */; };
E9CBC0F02A3DD62F00CCD592 /* LogFormatter.swift in Sources */ = {isa = PBXBuildFile; fileRef = E9CBC0EF2A3DD62F00CCD592 /* LogFormatter.swift */; };
E9D40C9B2A26334E00FC3405 /* TagMiddleware.swift in Sources */ = {isa = PBXBuildFile; fileRef = E9D40C9A2A26334E00FC3405 /* TagMiddleware.swift */; };
E9E3631426F463F800C58D01 /* Alamofire in Frameworks */ = {isa = PBXBuildFile; productRef = 7D354CD024F1390400617F4A /* Alamofire */; };
E9E3631626F463F800C58D01 /* Logging in Frameworks */ = {isa = PBXBuildFile; productRef = 7D354CE124F15F1800617F4A /* Logging */; };
Expand Down Expand Up @@ -255,6 +256,7 @@
E9BE57B32942F1AB00A3AEA0 /* LockScreenModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = LockScreenModel.swift; path = DuMangaTests/Resources/LockScreenModel.swift; sourceTree = SOURCE_ROOT; };
E9C73DC32A1C5F4900EFDD81 /* HistoryList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HistoryList.swift; sourceTree = "<group>"; };
E9C73DC62A1C6F2F00EFDD81 /* HistoryListModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HistoryListModel.swift; sourceTree = "<group>"; };
E9CBC0EF2A3DD62F00CCD592 /* LogFormatter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LogFormatter.swift; sourceTree = "<group>"; };
E9D40C9A2A26334E00FC3405 /* TagMiddleware.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TagMiddleware.swift; sourceTree = "<group>"; };
E9E3631E26F471E400C58D01 /* LogView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LogView.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
Expand Down Expand Up @@ -541,6 +543,7 @@
4BD82694B57396B2CD6BACED /* ContentView.swift */,
4BD8258293EA80CD9CC32653 /* ContentViewModel.swift */,
7D3DFF15251777B200686612 /* DuMangaApp.swift */,
E9CBC0EF2A3DD62F00CCD592 /* LogFormatter.swift */,
);
name = Views;
sourceTree = "<group>";
Expand Down Expand Up @@ -770,6 +773,7 @@
7DF7EA742564E1D2003B5A5A /* AppDatabase.swift in Sources */,
7D3DFF16251777B200686612 /* DuMangaApp.swift in Sources */,
E94C1DDC2A204DDA00552ABD /* ImageService.swift in Sources */,
E9CBC0F02A3DD62F00CCD592 /* LogFormatter.swift in Sources */,
7DF7EA852564E675003B5A5A /* Record.swift in Sources */,
7D354D0524F2387900617F4A /* ViewModels.swift in Sources */,
7D354CDA24F13C4900617F4A /* LANraragiResponse.swift in Sources */,
Expand Down Expand Up @@ -1035,7 +1039,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 67;
CURRENT_PROJECT_VERSION = 68;
DEVELOPMENT_ASSET_PATHS = "\"DuManga/Preview Content\"";
DEVELOPMENT_TEAM = UUEBW58SA6;
ENABLE_PREVIEWS = YES;
Expand All @@ -1046,7 +1050,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.11.0;
MARKETING_VERSION = 1.11.1;
PRODUCT_BUNDLE_IDENTIFIER = com.jif.DuManga;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand All @@ -1062,7 +1066,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 67;
CURRENT_PROJECT_VERSION = 68;
DEVELOPMENT_ASSET_PATHS = "\"DuManga/Preview Content\"";
DEVELOPMENT_TEAM = UUEBW58SA6;
ENABLE_PREVIEWS = YES;
Expand All @@ -1073,7 +1077,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.11.0;
MARKETING_VERSION = 1.11.1;
PRODUCT_BUNDLE_IDENTIFIER = com.jif.DuManga;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -1139,7 +1143,7 @@
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 67;
CURRENT_PROJECT_VERSION = 68;
DEVELOPMENT_TEAM = UUEBW58SA6;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = Action/Info.plist;
Expand All @@ -1151,7 +1155,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 1.11.0;
MARKETING_VERSION = 1.11.1;
PRODUCT_BUNDLE_IDENTIFIER = com.jif.DuManga.Action;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
Expand All @@ -1168,7 +1172,7 @@
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 67;
CURRENT_PROJECT_VERSION = 68;
DEVELOPMENT_TEAM = UUEBW58SA6;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = Action/Info.plist;
Expand All @@ -1180,7 +1184,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 1.11.0;
MARKETING_VERSION = 1.11.1;
PRODUCT_BUNDLE_IDENTIFIER = com.jif.DuManga.Action;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
Expand Down
2 changes: 2 additions & 0 deletions DuManga/Category/CategoryArchiveList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ struct CategoryArchiveList: View {
}
}
}
.navigationBarTitleDisplayMode(.inline)
.navigationTitle(categoryItem.name)
.environment(\.editMode, $enableSelect)
.onChange(of: categoryArchiveListModel.categoryItems[categoryItem.id]) {
// swiftlint:disable closure_parameter_position
Expand Down
2 changes: 2 additions & 0 deletions DuManga/Category/CategoryList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ struct CategoryList: View {
.cornerRadius(20)
}
}
.navigationTitle("category")
.navigationBarTitleDisplayMode(.inline)
.onAppear {
categoryListModel.connectStore()
}
Expand Down
1 change: 1 addition & 0 deletions DuManga/Common/ArchiveSelection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ struct ArchiveSelection: View {
LazyVGrid(columns: columns) {
ForEach(archivesToDisplay) { item in
ArchiveGrid(archiveItem: item)
.contentShape(Rectangle())
.onTapGesture {
if selected.contains(item.id) {
selected.remove(item.id)
Expand Down
7 changes: 6 additions & 1 deletion DuManga/DuMangaApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,12 @@ struct DuMangaApp: App {
}

let console = ConsoleLogger("com.jif.DuManga.console")
let fileLogger = try FileLogger("com.jif.DuManga.file", logLevel: .info, fileURL: logFileURL)
let fileLogger = try FileLogger(
"com.jif.DuManga.file",
logLevel: .info,
logFormat: LogFormatter(),
fileURL: logFileURL
)

var puppy = Puppy()
puppy.add(console)
Expand Down
21 changes: 21 additions & 0 deletions DuManga/LogFormatter.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import Foundation
import Puppy

struct LogFormatter: LogFormattable {
private let dateFormat = DateFormatter()

init() {
dateFormat.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ"
}

// swiftlint:disable all
func formatMessage(_ level: LogLevel, message: String, tag: String, function: String,
file: String, line: UInt, swiftLogInfo: [String: String],
label: String, date: Date, threadID: UInt64) -> String {
let date = dateFormatter(date, withFormatter: dateFormat)
let fileName = fileName(file)
let moduleName = moduleName(file)
return "timestamp=\(date) level=\(level) logger=\(swiftLogInfo["label"] ?? "") location=\(moduleName)/\(fileName)#L.\(line) function=\(function) message=\(message)"
}
// swiftlint:enable all
}
38 changes: 20 additions & 18 deletions DuManga/Setting/LogView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,25 @@ struct LogView: View {
@State var log = ""

var body: some View {
Text(log)
.textSelection(.enabled)
.onAppear(perform: {
do {
let logFileURL = try FileManager.default
.url(
for: .applicationSupportDirectory,
in: .userDomainMask,
appropriateFor: nil,
create: true
)
.appendingPathComponent("app.log")
log = try String(contentsOf: logFileURL, encoding: .utf8)
} catch {
log = "error reading log"
}
})
.toolbar(.hidden, for: .tabBar)
ScrollView {
Text(log)
.textSelection(.enabled)
}
.onAppear(perform: {
do {
let logFileURL = try FileManager.default
.url(
for: .applicationSupportDirectory,
in: .userDomainMask,
appropriateFor: nil,
create: true
)
.appendingPathComponent("app.log")
log = try String(contentsOf: logFileURL, encoding: .utf8)
} catch {
log = "error reading log"
}
})
.toolbar(.hidden, for: .tabBar)
}
}
9 changes: 4 additions & 5 deletions DuManga/UploadViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ class UploadViewModel: ObservableObject {
downloadJobs = .init()
}
for job in downloadJobs {
if job.lastUpdate.addingTimeInterval(3600) < Date() {
_ = try? database.deleteDownloadJobs(job.id)
}
if !job.isSuccess && !job.isError {
do {
let response = try await service.checkJobStatus(id: job.id).value
Expand All @@ -64,11 +67,7 @@ class UploadViewModel: ObservableObject {
UploadViewModel.logger.error("failed to check job status. id=\(job.id) \(error)")
}
} else {
if job.lastUpdate.addingTimeInterval(3600) < Date() {
_ = try? database.deleteDownloadJobs(job.id)
} else {
jobDetails[job.id] = job
}
jobDetails[job.id] = job
}
}
}
Expand Down

0 comments on commit 90f1a6b

Please sign in to comment.