mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-02 21:51:49 +01:00
Improve recent documents handling (#16727)
* merge * Update RecentDoc struct to make timestamp fields optional * GetDoc is solely responsible for retrieving document content and does not handle business logic * Remove RemoveRecentDoc function and its calls from multiple files to streamline document handling * Ensure the API correctly returns an empty array, add deduplication logic, and remove redundant sorting steps when updating fields * 🎨 Supports configuring the maximum number of `Recent documents` to be listed https://github.com/siyuan-note/siyuan/issues/16720 * merge * 🎨 Supports configuring the maximum number of `Recent documents` to be listed https://github.com/siyuan-note/siyuan/issues/16720 * 🐛 Fix browsing time not sorted * 🎨 Supports configuring the maximum number of `Recent documents` to be listed https://github.com/siyuan-note/siyuan/issues/16720 * merge * remove async * try catch
This commit is contained in:
parent
fc5a79ff16
commit
b0f71123a3
9 changed files with 398 additions and 220 deletions
|
|
@ -81,6 +81,7 @@ func ServeAPI(ginServer *gin.Engine) {
|
|||
ginServer.Handle("POST", "/api/storage/getRecentDocs", model.CheckAuth, getRecentDocs)
|
||||
ginServer.Handle("POST", "/api/storage/updateRecentDocViewTime", model.CheckAuth, updateRecentDocViewTime)
|
||||
ginServer.Handle("POST", "/api/storage/updateRecentDocCloseTime", model.CheckAuth, updateRecentDocCloseTime)
|
||||
ginServer.Handle("POST", "/api/storage/batchUpdateRecentDocCloseTime", model.CheckAuth, batchUpdateRecentDocCloseTime)
|
||||
ginServer.Handle("POST", "/api/storage/updateRecentDocOpenTime", model.CheckAuth, updateRecentDocOpenTime)
|
||||
|
||||
ginServer.Handle("POST", "/api/storage/getOutlineStorage", model.CheckAuth, getOutlineStorage)
|
||||
|
|
|
|||
|
|
@ -295,11 +295,11 @@ func updateRecentDocCloseTime(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
if nil == arg["rootID"] {
|
||||
rootID, ok := arg["rootID"].(string)
|
||||
if !ok || rootID == "" {
|
||||
return
|
||||
}
|
||||
|
||||
rootID := arg["rootID"].(string)
|
||||
err := model.UpdateRecentDocCloseTime(rootID)
|
||||
if err != nil {
|
||||
ret.Code = -1
|
||||
|
|
@ -307,3 +307,26 @@ func updateRecentDocCloseTime(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
}
|
||||
|
||||
func batchUpdateRecentDocCloseTime(c *gin.Context) {
|
||||
ret := gulu.Ret.NewResult()
|
||||
defer c.JSON(http.StatusOK, ret)
|
||||
|
||||
arg, ok := util.JsonArg(c, ret)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
rootIDsArg := arg["rootIDs"].([]interface{})
|
||||
var rootIDs []string
|
||||
for _, id := range rootIDsArg {
|
||||
rootIDs = append(rootIDs, id.(string))
|
||||
}
|
||||
|
||||
err := model.BatchUpdateRecentDocCloseTime(rootIDs)
|
||||
if err != nil {
|
||||
ret.Code = -1
|
||||
ret.Msg = err.Error()
|
||||
return
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue