mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-30 00:12:50 -05:00
clipboard: touch copied history entry
- makes it appear at the top of the history
This commit is contained in:
@@ -146,6 +146,11 @@ func handleCopyEntry(conn net.Conn, req models.Request, m *Manager) {
|
||||
return
|
||||
}
|
||||
|
||||
if err := m.TouchEntry(uint64(id)); err != nil {
|
||||
models.RespondError(conn, req.ID, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
models.Respond(conn, req.ID, models.SuccessResult{Success: true, Message: "copied to clipboard"})
|
||||
}
|
||||
|
||||
|
||||
@@ -820,6 +820,28 @@ func (m *Manager) DeleteEntry(id uint64) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func (m *Manager) TouchEntry(id uint64) error {
|
||||
if m.db == nil {
|
||||
return fmt.Errorf("database not available")
|
||||
}
|
||||
|
||||
entry, err := m.GetEntry(id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
entry.Timestamp = time.Now()
|
||||
|
||||
if err := m.storeEntry(*entry); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
m.updateState()
|
||||
m.notifySubscribers()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Manager) ClearHistory() {
|
||||
if m.db == nil {
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user