Skip to content

Commit

Permalink
bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Louiswu2011 committed Feb 2, 2023
1 parent 8630f01 commit 5c6b8fb
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 39 deletions.
4 changes: 2 additions & 2 deletions chafenqi.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 63;
CURRENT_PROJECT_VERSION = 65;
DEVELOPMENT_ASSET_PATHS = "\"chafenqi/Preview Content\"";
DEVELOPMENT_TEAM = CYVRCL87U4;
ENABLE_PREVIEWS = YES;
Expand Down Expand Up @@ -693,7 +693,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 63;
CURRENT_PROJECT_VERSION = 65;
DEVELOPMENT_ASSET_PATHS = "\"chafenqi/Preview Content\"";
DEVELOPMENT_TEAM = CYVRCL87U4;
ENABLE_PREVIEWS = YES;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@
filePath = "chafenqi/View/SongView/SongDetailView.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "246"
endingLineNumber = "246"
startingLineNumber = "249"
endingLineNumber = "249"
landmarkName = "body"
landmarkType = "24">
</BreakpointContent>
Expand Down
53 changes: 28 additions & 25 deletions chafenqi/View/SongView/SongDetailView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ struct SongDetailView: View {
@AppStorage("settingsCoverSource") var coverSource = 0
@AppStorage("userInfoData") var userInfoData = Data()
@AppStorage("chartIDMap") var mapData = Data()
@AppStorage("didLogin") var didLogin = false

@Environment(\.colorScheme) var colorScheme

Expand Down Expand Up @@ -217,7 +218,7 @@ struct SongDetailView: View {
}
.padding(.bottom)

if (!loadingScore) {
if (!loadingScore && didLogin) {
VStack(spacing: 5) {
ForEach(0..<4) { index in
ScoreCardView(index: index, scoreEntries: scoreEntries, song: song)
Expand All @@ -232,33 +233,35 @@ struct SongDetailView: View {
}
}
.task {
userInfo = try! JSONDecoder().decode(UserData.self, from: userInfoData)
var scores = userInfo.records.best.filter {
$0.musicID == song.id
}
scores.sort {
$0.levelIndex < $1.levelIndex
}
scoreEntries = Dictionary(uniqueKeysWithValues: scores.map { ($0.levelIndex, $0) })
loadingScore.toggle()
}
.toolbar {
ToolbarItem(placement: .navigationBarTrailing) {
Menu {
Button {
showingCalc.toggle()
} label: {
Image(systemName: "plus.forwardslash.minus")
Text("分数计算")
}
.sheet(isPresented: $showingCalc) {
BorderCalcView(song: song)
}
} label: {
Image(systemName: "ellipsis.circle")
if(didLogin) {
userInfo = try! JSONDecoder().decode(UserData.self, from: userInfoData)
var scores = userInfo.records.best.filter {
$0.musicID == song.id
}
scores.sort {
$0.levelIndex < $1.levelIndex
}
scoreEntries = Dictionary(uniqueKeysWithValues: scores.map { ($0.levelIndex, $0) })
}
loadingScore.toggle()
}
// .toolbar {
// ToolbarItem(placement: .navigationBarTrailing) {
// Menu {
// Button {
// showingCalc.toggle()
// } label: {
// Image(systemName: "plus.forwardslash.minus")
// Text("分数计算")
// }
// .sheet(isPresented: $showingCalc) {
// BorderCalcView(song: song)
// }
// } label: {
// Image(systemName: "ellipsis.circle")
// }
// }
// }
}
}

Expand Down
16 changes: 6 additions & 10 deletions chafenqi/View/TopView/HomeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,8 @@ struct HomeView: View {

}
.task {
getChartIDMap()

if (!didLogin) {
status = .empty
} else {
Expand Down Expand Up @@ -330,8 +332,6 @@ struct HomeView: View {
await loadSongList()
totalChartCount = getTotalChartCount()

try getChartIDMap()

// For now
removeWEChart()

Expand Down Expand Up @@ -375,15 +375,11 @@ struct HomeView: View {
return total
}

func getChartIDMap() throws {
func getChartIDMap() {
guard mapData.isEmpty else { return }

let path = Bundle.main.url(forResource: "IdMap", withExtension: "json")
let content: Data
do {
mapData = try Data(contentsOf: path!)
print("Successfully loaded ID map file.")
} catch {
throw CFQError.IOError(file: path!.absoluteString)
}
mapData = try! Data(contentsOf: path!)
}
}

Expand Down

0 comments on commit 5c6b8fb

Please sign in to comment.