Skip to content

Commit c14870c

Browse files
authored
fix blank topic (#3948)
1 parent bc84007 commit c14870c

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

public/js/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2197,7 +2197,11 @@ function initTopicbar() {
21972197
alert(res.message);
21982198
} else {
21992199
viewDiv.children(".topic").remove();
2200+
if (topics.length == 0) {
2201+
return
2202+
}
22002203
var topicArray = topics.split(",");
2204+
22012205
var last = viewDiv.children("a").last();
22022206
for (var i=0;i < topicArray.length; i++) {
22032207
$('<div class="ui green basic label topic" style="cursor:pointer;">'+topicArray[i]+'</div>').insertBefore(last)

routers/repo/topic.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ func TopicPost(ctx *context.Context) {
2121
return
2222
}
2323

24-
topics := strings.Split(ctx.Query("topics"), ",")
24+
var topics = make([]string, 0)
25+
var topicsStr = strings.TrimSpace(ctx.Query("topics"))
26+
if len(topicsStr) > 0 {
27+
topics = strings.Split(topicsStr, ",")
28+
}
2529

2630
err := models.SaveTopics(ctx.Repo.Repository.ID, topics...)
2731
if err != nil {

0 commit comments

Comments
 (0)