fix: fist comment of disqus error

This commit is contained in:
henry.chen
2023-01-05 13:25:18 +08:00
parent 04289c633e
commit 17792e5a7e
4 changed files with 66 additions and 8 deletions

View File

@@ -301,7 +301,7 @@ func handleAPIPostCreate(c *gin.Context) {
}
// 旧文章
article.ID = cid
artc, _ := cache.Ei.FindArticleByID(article.ID)
artc, _ := cache.Ei.FindArticleByID(article.ID) // cache
if artc != nil {
article.IsDraft = false
article.Count = artc.Count

View File

@@ -3,6 +3,7 @@ package page
import (
"bytes"
"context"
"fmt"
htemplate "html/template"
"io/ioutil"
@@ -198,7 +199,8 @@ func handleDisqusList(c *gin.Context) {
slug := c.Param("slug")
cursor := c.Query("cursor")
if artc := cache.Ei.ArticlesMap[slug]; artc != nil {
artc := cache.Ei.ArticlesMap[slug]
if artc != nil {
dcs.Data.Thread = artc.Thread
}
postsList, err := internal.PostsList(slug, cursor)
@@ -229,6 +231,18 @@ func handleDisqusList(c *gin.Context) {
IsDeleted: v.IsDeleted,
}
}
// query thread & update
if artc != nil && artc.Thread == "" {
if dcs.Data.Thread != "" {
artc.Thread = dcs.Data.Thread
} else if internal.ThreadDetails(artc) == nil {
dcs.Data.Thread = artc.Thread
}
cache.Ei.UpdateArticle(context.Background(), artc.ID,
map[string]interface{}{
"thread": artc.Thread,
})
}
}
// handleDisqusPage 评论页