From 702a75a8c0355737e3e62735b59fe30bee7e42f4 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Thu, 22 Mar 2018 19:51:20 +0200 Subject: Save history to disk. Fixes #1 --- ui/widget/room-view.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'ui/widget/room-view.go') diff --git a/ui/widget/room-view.go b/ui/widget/room-view.go index 433d5dd..141e993 100644 --- a/ui/widget/room-view.go +++ b/ui/widget/room-view.go @@ -18,6 +18,7 @@ package widget import ( "fmt" + "path/filepath" "strings" "time" @@ -67,6 +68,18 @@ func NewRoomView(room *rooms.Room) *RoomView { return view } +func (view *RoomView) logPath(dir string) string { + return filepath.Join(dir, fmt.Sprintf("%s.gmxlog", view.Room.ID)) +} + +func (view *RoomView) SaveHistory(dir string) error { + return view.MessageView().SaveHistory(view.logPath(dir)) +} + +func (view *RoomView) LoadHistory(dir string) (int, error) { + return view.MessageView().LoadHistory(view.logPath(dir)) +} + func (view *RoomView) SetTabCompleteFunc(fn func(room *RoomView, text string, cursorOffset int) string) *RoomView { view.input.SetTabCompleteFunc(func(text string, cursorOffset int) string { return fn(view, text, cursorOffset) -- cgit v1.2.3