proper clear draft message
This commit is contained in:
parent
ed553f51f7
commit
42d6a3f075
|
|
@ -305,6 +305,9 @@ func main() {
|
||||||
go func() {
|
go func() {
|
||||||
<-signals
|
<-signals
|
||||||
slog.Info("received SIGINT or SIGTERM signal, shutting down")
|
slog.Info("received SIGINT or SIGTERM signal, shutting down")
|
||||||
|
if err := st.ClearAllDrafts(); err != nil {
|
||||||
|
slog.Warn("failed to clear drafts on shutdown", "error", err)
|
||||||
|
}
|
||||||
quit()
|
quit()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -182,6 +182,11 @@ func osRun(_ func(), hasCompletedFirstRun, startHidden bool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func quit() {
|
func quit() {
|
||||||
|
if wv.Store != nil {
|
||||||
|
if err := wv.Store.ClearAllDrafts(); err != nil {
|
||||||
|
slog.Warn("failed to clear drafts on quit", "error", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
C.quit()
|
C.quit()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -111,6 +111,11 @@ func (*appCallbacks) UIRunning() bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (app *appCallbacks) Quit() {
|
func (app *appCallbacks) Quit() {
|
||||||
|
if wv.Store != nil {
|
||||||
|
if err := wv.Store.ClearAllDrafts(); err != nil {
|
||||||
|
slog.Warn("failed to clear drafts on quit", "error", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
app.t.Quit()
|
app.t.Quit()
|
||||||
wv.Terminate()
|
wv.Terminate()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -707,6 +707,14 @@ func (db *database) updateChatDraft(chatID string, draft string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (db *database) clearAllDrafts() error {
|
||||||
|
_, err := db.conn.Exec(`UPDATE chats SET draft = ''`)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("clear all drafts: %w", err)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// updateChatBrowserState updates only the browser_state for a chat
|
// updateChatBrowserState updates only the browser_state for a chat
|
||||||
func (db *database) updateChatBrowserState(chatID string, state json.RawMessage) error {
|
func (db *database) updateChatBrowserState(chatID string, state json.RawMessage) error {
|
||||||
_, err := db.conn.Exec(`UPDATE chats SET browser_state = ? WHERE id = ?`, string(state), chatID)
|
_, err := db.conn.Exec(`UPDATE chats SET browser_state = ? WHERE id = ?`, string(state), chatID)
|
||||||
|
|
|
||||||
|
|
@ -460,6 +460,14 @@ func (s *Store) UpdateChatDraft(chatID string, draft string) error {
|
||||||
return s.db.updateChatDraft(chatID, draft)
|
return s.db.updateChatDraft(chatID, draft)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Store) ClearAllDrafts() error {
|
||||||
|
if err := s.ensureDB(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.db.clearAllDrafts()
|
||||||
|
}
|
||||||
|
|
||||||
func (s *Store) UpdateChatBrowserState(chatID string, state json.RawMessage) error {
|
func (s *Store) UpdateChatBrowserState(chatID string, state json.RawMessage) error {
|
||||||
if err := s.ensureDB(); err != nil {
|
if err := s.ensureDB(); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
||||||
|
|
@ -268,8 +268,6 @@ function ChatForm({
|
||||||
if (textareaRef.current) {
|
if (textareaRef.current) {
|
||||||
textareaRef.current.style.height = "auto";
|
textareaRef.current.style.height = "auto";
|
||||||
}
|
}
|
||||||
|
|
||||||
clearDraft();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Clear loginPromptFeature when user becomes authenticated or no features are enabled
|
// Clear loginPromptFeature when user becomes authenticated or no features are enabled
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue