Skip to content

Commit

Permalink
fix blank topic (go-gitea#3948)
Browse files Browse the repository at this point in the history
  • Loading branch information
lunny committed May 11, 2018
1 parent bc84007 commit c14870c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions public/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 5 additions & 1 deletion routers/repo/topic.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit c14870c

Please sign in to comment.