Skip to content

Commit

Permalink
internal/tray, internal/tsutil: reorder menu items and don't poll for…
Browse files Browse the repository at this point in the history
… files if Taildrop isn't turned on (#149)

* internal/tray: reorder tray menu items

* internal/tsutil: don't bother polling for waiting files if Taildrop isn't turned on anyways

* meta: add v0.13.3 to metainfo
  • Loading branch information
DeedleFake authored Aug 16, 2024
1 parent d0eda8a commit 571e4cb
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
6 changes: 6 additions & 0 deletions dev.deedles.Trayscale.metainfo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@
<content_rating type="oars-1.1" />

<releases>
<release version="v0.13.3" date="2024-08-16">
<description>
<ul>Reorder tray menu items.</ul>
<ul>Skip polling for waiting files if Taildrop isn't turned on.</ul>
</description>
</release>
<release version="v0.13.2" date="2024-08-14">
<description>
<ul>Update to Go 1.23.</ul>
Expand Down
4 changes: 2 additions & 2 deletions internal/tray/tray.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ func New(online bool) *Tray {
systray.SetIcon(statusIcon(online))
systray.SetTitle("Trayscale")

showWindow := systray.AddMenuItem("Show", "")
systray.AddSeparator()
connToggleItem := systray.AddMenuItem(connToggleText(online), "")
selfNodeItem := systray.AddMenuItem("", "")
systray.AddSeparator()
showWindow := systray.AddMenuItem("Show", "")
systray.AddSeparator()
quit := systray.AddMenuItem("Quit", "")

return &Tray{
Expand Down
14 changes: 9 additions & 5 deletions internal/tsutil/poller.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"tailscale.com/client/tailscale/apitype"
"tailscale.com/ipn"
"tailscale.com/ipn/ipnstate"
"tailscale.com/tailcfg"
)

// A Poller gets the latest Tailscale status at regular intervals or
Expand Down Expand Up @@ -81,12 +82,15 @@ func (p *Poller) Run(ctx context.Context) {
continue
}

files, err := WaitingFiles(ctx)
if err != nil {
if ctx.Err() != nil {
return
var files []apitype.WaitingFile
if status.Self.HasCap(tailcfg.CapabilityFileSharing) {
files, err = WaitingFiles(ctx)
if err != nil {
if ctx.Err() != nil {
return
}
slog.Error("get waiting files", "err", err)
}
slog.Error("get waiting files", "err", err)
}

s := Status{Status: status, Prefs: prefs, Files: files}
Expand Down
2 changes: 1 addition & 1 deletion internal/tsutil/tsutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func IsMullvad(peer *ipnstate.PeerStatus) bool {
// CanMullvad returns true if peer is allowed to access Mullvad exit
// nodes.
func CanMullvad(peer *ipnstate.PeerStatus) bool {
return peer.CapMap.Contains("mullvad")
return peer.HasCap("mullvad")
}

// CompareLocations alphabestically compares the countries and then,
Expand Down

0 comments on commit 571e4cb

Please sign in to comment.