remove remote interactions

This commit is contained in:
2022-11-13 11:52:03 +01:00
parent 96d048fba6
commit f44aa14f0d
3 changed files with 3 additions and 127 deletions

View File

@@ -85,7 +85,7 @@ func initialModel(ctx *context.Context, t table.Model, initialQuery string, numE
if initialQuery != "" {
queryInput.SetValue(initialQuery)
}
return model{ctx: ctx, spinner: s, isLoading: true, table: t, runQuery: &initialQuery, queryInput: queryInput, numEntries: numEntries}
return model{ctx: ctx, spinner: s, isLoading: false, table: t, runQuery: &initialQuery, queryInput: queryInput, numEntries: numEntries}
}
func (m model) Init() tea.Cmd {
@@ -199,10 +199,6 @@ func (m model) View() string {
if m.quitting {
return ""
}
loadingMessage := ""
if m.isLoading {
loadingMessage = fmt.Sprintf("%s Loading hishtory entries from other devices...", m.spinner.View())
}
warning := ""
if m.isOffline {
warning += "Warning: failed to contact the hishtory backend (are you offline?), so some results may be stale\n\n"
@@ -210,7 +206,7 @@ func (m model) View() string {
if m.searchErr != nil {
warning += fmt.Sprintf("Warning: failed to search: %v\n\n", m.searchErr)
}
return fmt.Sprintf("\n%s\n%s%s\nSearch Query: %s\n\n%s\n", loadingMessage, warning, m.banner, m.queryInput.View(), baseStyle.Render(m.table.View()))
return fmt.Sprintf("\n%s%s\nSearch Query: %s\n\n%s\n", warning, m.banner, m.queryInput.View(), baseStyle.Render(m.table.View()))
}
func getRows(ctx *context.Context, columnNames []string, query string, numEntries int) ([]table.Row, int, error) {
@@ -411,32 +407,6 @@ func TuiQuery(ctx *context.Context, gitCommit, initialQuery string) error {
return err
}
p := tea.NewProgram(initialModel(ctx, t, initialQuery, numEntries), tea.WithOutput(os.Stderr))
go func() {
err := RetrieveAdditionalEntriesFromRemote(ctx)
if err != nil {
p.Send(err)
}
p.Send(doneDownloadingMsg{})
}()
// Async: Process deletion requests
go func() {
err := ProcessDeletionRequests(ctx)
if err != nil {
p.Send(err)
}
}()
// Async: Check for any banner from the server
go func() {
banner, err := GetBanner(ctx, gitCommit)
if err != nil {
if IsOfflineError(err) {
p.Send(offlineMsg{})
} else {
p.Send(err)
}
}
p.Send(bannerMsg{banner: string(banner)})
}()
// Blocking: Start the TUI
err = p.Start()
if err != nil {