0
0
Fork 0
mirror of https://github.com/go-gitea/gitea synced 2024-11-21 18:55:35 +01:00

fix blank topic (#3948)

This commit is contained in:
Lunny Xiao 2018-05-11 16:15:18 +08:00 committed by GitHub
parent bc8400747a
commit c14870c5ac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View file

@ -2197,7 +2197,11 @@ function initTopicbar() {
alert(res.message);
} else {
viewDiv.children(".topic").remove();
if (topics.length == 0) {
return
}
var topicArray = topics.split(",");
var last = viewDiv.children("a").last();
for (var i=0;i < topicArray.length; i++) {
$('<div class="ui green basic label topic" style="cursor:pointer;">'+topicArray[i]+'</div>').insertBefore(last)

View file

@ -21,7 +21,11 @@ func TopicPost(ctx *context.Context) {
return
}
topics := strings.Split(ctx.Query("topics"), ",")
var topics = make([]string, 0)
var topicsStr = strings.TrimSpace(ctx.Query("topics"))
if len(topicsStr) > 0 {
topics = strings.Split(topicsStr, ",")
}
err := models.SaveTopics(ctx.Repo.Repository.ID, topics...)
if err != nil {