Skip to content

Commit

Permalink
Show pinned status
Browse files Browse the repository at this point in the history
  • Loading branch information
livid committed Jul 21, 2023
1 parent a112683 commit bbf7711
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 4 deletions.
12 changes: 12 additions & 0 deletions Planet/Entities/MyPlanetModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1778,6 +1778,18 @@ extension MyPlanetModel {
navigation.sort(by: { $0.weight < $1.weight })
return navigation
}

var isPinned: Bool {
// TODO: Is this the best way to check if a planet is pinned?
if let localCID = lastPublishedCID, localCID.count > 0,
let remoteCID = pinnablePinCID, remoteCID.count > 0
{
if localCID == remoteCID {
return true
}
}
return false
}
}

struct PublicPlanetModel: Codable {
Expand Down
12 changes: 11 additions & 1 deletion Planet/Views/My/MyPlanetEditView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,13 @@ struct MyPlanetEditView: View {

if let status = pinnablePinStatus {
Button {

if let url = planet.browserURL {
debugPrint("Pinnable: Open preview URL \(url)")
NSWorkspace.shared.open(url)
}
else {
debugPrint("Pinnable: Preview URL is not available")
}
} label: {
if let cid = pinnablePinCID {
if cid == planet.lastPublishedCID {
Expand All @@ -251,6 +257,10 @@ struct MyPlanetEditView: View {
pinnablePinStatus = status
if let cid = status.last_known_cid {
pinnablePinCID = cid
if cid != planet.pinnablePinCID {
planet.pinnablePinCID = cid
try? await planet.save()
}
}
}
}
Expand Down
13 changes: 11 additions & 2 deletions Planet/Views/Sidebar/MyPlanetSidebarItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,17 @@ struct MyPlanetSidebarItem: View {
.font(.body)
.foregroundColor(.primary)
Spacer()
LoadingIndicatorView()
.opacity(planet.isPublishing ? 1.0 : 0.0)
if planet.isPublishing {
LoadingIndicatorView()
} else {
if planet.isPinned {
Image(systemName: "externaldrive.fill.badge.checkmark")
.foregroundColor(.secondary)
.opacity(0.5)
.help("Pinned with Pinnable")
}
}

}
.contextMenu {
Group {
Expand Down
2 changes: 1 addition & 1 deletion Planet/versioning.xcconfig
Original file line number Diff line number Diff line change
@@ -1 +1 @@
CURRENT_PROJECT_VERSION = 1531
CURRENT_PROJECT_VERSION = 1532

0 comments on commit bbf7711

Please sign in to comment.