refactor(history): start moving history-related code into avante/history
The utils module has grown too big and contains unrelated functionality. Start moving code related to managing history messages comprising chat history into lua/avante/history module to keep the code more manageable.
This commit is contained in:
@@ -53,10 +53,11 @@ function History.list(bufnr)
|
||||
--- sort by timestamp
|
||||
--- sort by latest_filename
|
||||
table.sort(res, function(a, b)
|
||||
local H = require("avante.history")
|
||||
if a.filename == latest_filename then return true end
|
||||
if b.filename == latest_filename then return false end
|
||||
local a_messages = Utils.get_history_messages(a)
|
||||
local b_messages = Utils.get_history_messages(b)
|
||||
local a_messages = H.get_history_messages(a)
|
||||
local b_messages = H.get_history_messages(b)
|
||||
local timestamp_a = #a_messages > 0 and a_messages[#a_messages].timestamp or a.timestamp
|
||||
local timestamp_b = #b_messages > 0 and b_messages[#b_messages].timestamp or b.timestamp
|
||||
return timestamp_a > timestamp_b
|
||||
|
||||
Reference in New Issue
Block a user