Skip to content

Commit 658c8a8

Browse files
committed
fix: check
1 parent 70da5fc commit 658c8a8

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

MusicBar/StatusBar.swift

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class StatusBar: NSObject {
4040
}
4141
}
4242

43-
func getCheck(_ t: String,_ a: String) -> String {
43+
func getCheck(_ t: String,_ a: String) -> String? {
4444
let t = t.trimmingCharacters(in: .whitespaces)
4545
let a = a.trimmingCharacters(in: .whitespaces)
4646

@@ -55,7 +55,7 @@ class StatusBar: NSObject {
5555
} else if(a != "") {
5656
return "Song by \(a)"
5757
} else {
58-
return ""
58+
return nil
5959
}
6060
}
6161

@@ -82,16 +82,19 @@ class StatusBar: NSObject {
8282
let songTitleCheck = self.getSongTitle(songTitle)
8383
let songArtistCheck = self.getArtist(songArtist)
8484

85+
let check = getCheck(songTitleCheck, songArtistCheck)
8586

86-
let titleCombined = " " + getCheck(songTitleCheck, songArtistCheck)
87-
88-
if #available(macOS 11.0, *) {
89-
button.title = titleCombined
90-
}
91-
else {
92-
let attributes = [NSAttributedString.Key.foregroundColor: NSColor.white]
93-
let attributedText = NSAttributedString(string: titleCombined, attributes: attributes)
94-
button.attributedTitle = attributedText
87+
if (check != nil) {
88+
let titleCombined = " " + (check ?? "")
89+
90+
if #available(macOS 11.0, *) {
91+
button.title = titleCombined
92+
}
93+
else {
94+
let attributes = [NSAttributedString.Key.foregroundColor: NSColor.white]
95+
let attributedText = NSAttributedString(string: titleCombined, attributes: attributes)
96+
button.attributedTitle = attributedText
97+
}
9598
}
9699

97100
button.image = resized

0 commit comments

Comments
 (0)