Skip to content

Commit

Permalink
files downloaded notification shows modules
Browse files Browse the repository at this point in the history
  • Loading branch information
beebeeoii committed Jan 21, 2022
1 parent 3ab8222 commit e733248
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion FyneApp.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ Website = "https://github.com/beebeeoii/lominus"
Name = "Lominus"
ID = "com.beebeeoii.lominus"
Version = "1.2.0"
Build = 113
Build = 115
14 changes: 10 additions & 4 deletions internal/cron/cron.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ func createJob(frequency int) (*gocron.Job, error) {
}

nFilesToUpdate := 0
filesUpdated := []string{}
filesUpdated := []api.File{}

for _, file := range updatedFiles {
if _, exists := currentFiles[file.Name]; !exists || currentFiles[file.Name].LastUpdated.Before(file.LastUpdated) {
Expand All @@ -173,18 +173,24 @@ func createJob(frequency int) (*gocron.Job, error) {
logs.Logger.Errorln(downloadErr)
continue
}
filesUpdated = append(filesUpdated, file.Name)
filesUpdated = append(filesUpdated, file)
}
}

if nFilesToUpdate > 0 {
nFilesUpdated := len(filesUpdated)
updatedFilesModulesNames := []string{}

for _, file := range filesUpdated {
updatedFilesModulesNames = append(updatedFilesModulesNames, fmt.Sprintf("[%s] %s ", file.Ancestors[0], file.Name))
}

var updatedFileNamesString string

if nFilesUpdated > 4 {
updatedFileNamesString = strings.Join(append(filesUpdated[:3], "..."), "\n")
updatedFileNamesString = strings.Join(append(updatedFilesModulesNames[:3], "..."), "\n")
} else {
updatedFileNamesString = strings.Join(filesUpdated, "\n")
updatedFileNamesString = strings.Join(updatedFilesModulesNames, "\n")
}

notifications.NotificationChannel <- notifications.Notification{
Expand Down

0 comments on commit e733248

Please sign in to comment.