fixed CustomName whitespace

This commit is contained in:
Elmar Kresse
2023-09-22 16:31:12 +02:00
parent 023cca3105
commit 334dd406a7
3 changed files with 7 additions and 7 deletions

View File

@@ -22,7 +22,7 @@ func GetModulesForCourseDistinct(app *pocketbase.PocketBase, c echo.Context, cou
func replaceEmptyEntryInStringArray(modules []string, replacement string) {
//replace empty functions with "Sonderveranstaltungen"
for i, module := range modules {
if functions.CheckIfOnlyWhitespace(module) {
if functions.OnlyWhitespace(module) {
modules[i] = replacement
}
}
@@ -34,7 +34,7 @@ func replaceEmptyEntry(modules []struct {
}, replacement string) {
//replace empty functions with "Sonderveranstaltungen"
for i, module := range modules {
if functions.CheckIfOnlyWhitespace(module.Name) {
if functions.OnlyWhitespace(module.Name) {
modules[i].Name = replacement
}
}

View File

@@ -3,7 +3,7 @@ package functions
import "unicode"
// check if course is empty or contains only whitespaces
func CheckIfOnlyWhitespace(word string) bool {
func OnlyWhitespace(word string) bool {
for _, letter := range word {
if !unicode.IsSpace(letter) || !(letter == int32(160)) {
return false

View File

@@ -43,7 +43,7 @@ func (icalModel IcalModel) EmitICal() goics.Componenter {
func replaceNameIfUserDefined(name string, mapping []model.FeedCollection) string {
for _, mapEntry := range mapping {
if mapEntry.Name == name {
if mapEntry.Name == name && !functions.OnlyWhitespace(mapEntry.UserDefinedName) {
return mapEntry.UserDefinedName
}
}
@@ -53,13 +53,13 @@ func replaceNameIfUserDefined(name string, mapping []model.FeedCollection) strin
func generateDescription(event *model.Event) string {
var description string
if !functions.CheckIfOnlyWhitespace(event.Notes) {
if !functions.OnlyWhitespace(event.Notes) {
description += "Notizen: " + event.Notes + "\n"
}
if !functions.CheckIfOnlyWhitespace(event.Prof) {
if !functions.OnlyWhitespace(event.Prof) {
description += "Prof: " + event.Prof + "\n"
}
if !functions.CheckIfOnlyWhitespace(event.Course) {
if !functions.OnlyWhitespace(event.Course) {
description += "Gruppe: " + event.Course + "\n"
}