Skip to content

Commit 571e4cb

Browse files
authored
internal/tray, internal/tsutil: reorder menu items and don't poll for 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
1 parent d0eda8a commit 571e4cb

File tree

4 files changed

+18
-8
lines changed

4 files changed

+18
-8
lines changed

dev.deedles.Trayscale.metainfo.xml

+6
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@
5454
<content_rating type="oars-1.1" />
5555

5656
<releases>
57+
<release version="v0.13.3" date="2024-08-16">
58+
<description>
59+
<ul>Reorder tray menu items.</ul>
60+
<ul>Skip polling for waiting files if Taildrop isn't turned on.</ul>
61+
</description>
62+
</release>
5763
<release version="v0.13.2" date="2024-08-14">
5864
<description>
5965
<ul>Update to Go 1.23.</ul>

internal/tray/tray.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ func New(online bool) *Tray {
3434
systray.SetIcon(statusIcon(online))
3535
systray.SetTitle("Trayscale")
3636

37+
showWindow := systray.AddMenuItem("Show", "")
38+
systray.AddSeparator()
3739
connToggleItem := systray.AddMenuItem(connToggleText(online), "")
3840
selfNodeItem := systray.AddMenuItem("", "")
3941
systray.AddSeparator()
40-
showWindow := systray.AddMenuItem("Show", "")
41-
systray.AddSeparator()
4242
quit := systray.AddMenuItem("Quit", "")
4343

4444
return &Tray{

internal/tsutil/poller.go

+9-5
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"tailscale.com/client/tailscale/apitype"
1414
"tailscale.com/ipn"
1515
"tailscale.com/ipn/ipnstate"
16+
"tailscale.com/tailcfg"
1617
)
1718

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

84-
files, err := WaitingFiles(ctx)
85-
if err != nil {
86-
if ctx.Err() != nil {
87-
return
85+
var files []apitype.WaitingFile
86+
if status.Self.HasCap(tailcfg.CapabilityFileSharing) {
87+
files, err = WaitingFiles(ctx)
88+
if err != nil {
89+
if ctx.Err() != nil {
90+
return
91+
}
92+
slog.Error("get waiting files", "err", err)
8893
}
89-
slog.Error("get waiting files", "err", err)
9094
}
9195

9296
s := Status{Status: status, Prefs: prefs, Files: files}

internal/tsutil/tsutil.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func IsMullvad(peer *ipnstate.PeerStatus) bool {
3939
// CanMullvad returns true if peer is allowed to access Mullvad exit
4040
// nodes.
4141
func CanMullvad(peer *ipnstate.PeerStatus) bool {
42-
return peer.CapMap.Contains("mullvad")
42+
return peer.HasCap("mullvad")
4343
}
4444

4545
// CompareLocations alphabestically compares the countries and then,

0 commit comments

Comments
 (0)