Skip to content

Commit

Permalink
added sync from systray
Browse files Browse the repository at this point in the history
  • Loading branch information
beebeeoii committed Jan 12, 2022
1 parent 5dbb51d commit c833ddf
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions internal/ui/systray.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/beebeeoii/lominus/internal/cron"
logs "github.com/beebeeoii/lominus/internal/log"
"github.com/beebeeoii/lominus/internal/lominus"
"github.com/beebeeoii/lominus/internal/notifications"
)

var lastRanItem *systray.MenuItem
Expand All @@ -20,13 +21,25 @@ func onReady() {
systray.SetTooltip(lominus.APP_NAME)
lastRanItem = systray.AddMenuItem("Last sync: Nil", "Shows when Lominus last checked for updates")
lastRanItem.Disable()
syncButton := systray.AddMenuItem("Sync now", "Sync now")
openButton := systray.AddMenuItem("Open", "Open Lominus")
systray.AddSeparator()
quitButton := systray.AddMenuItem("Quit", "Quit Lominus")

go func() {
for {
select {
case <-syncButton.ClickedCh:
preferences := getPreferences()
if preferences.Directory == "" {
notifications.NotificationChannel <- notifications.Notification{Title: "Lominus", Content: "Unable to sync: please set the directory to store your Luminus files"}
return
}
if preferences.Frequency == -1 {
notifications.NotificationChannel <- notifications.Notification{Title: "Lominus", Content: "Unable to sync: please choose a sync frequency to sync now."}
return
}
cron.Rerun(getPreferences().Frequency)
case <-openButton.ClickedCh:
w.Show()
case <-quitButton.ClickedCh:
Expand Down

0 comments on commit c833ddf

Please sign in to comment.