wip: peering profiles

This commit is contained in:
2023-07-23 16:27:50 +02:00
parent 04ecfd3be3
commit 337f5ae6b9
2 changed files with 13 additions and 2 deletions

View File

@ -227,14 +227,17 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
))
profiles := m.app.ListProfiles()
m.profiles = append(m.profiles, profile{
newProfile := profile{
name: msg.name,
onion: profiles[len(profiles)-1],
statusViewport: viewport.New(
m.width,
m.height-3,
),
})
}
m.profiles = append(m.profiles, newProfile)
cmds = append(cmds, startProfileCmd(m, newProfile.onion))
m.menuBar = append(m.menuBar, msg.name)
@ -256,6 +259,7 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
for _, profile := range profiles {
m.menuBar = append(m.menuBar, profile.name)
cmds = append(cmds, startProfileCmd(m, profile.onion))
}
m.profiles = profiles
@ -314,6 +318,7 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
m.app = msg.app
m.acn = msg.acn
m.connState = connected
m.app.ActivateEngines(true, true, false)
case errMsg:
cmds = append(cmds, m.sendStatusCmd(msg.Error()))

View File

@ -4,6 +4,7 @@ import (
"cwtch.im/cwtch/model/attr"
"cwtch.im/cwtch/model/constants"
"github.com/charmbracelet/bubbles/viewport"
tea "github.com/charmbracelet/bubbletea"
)
type profile struct {
@ -42,3 +43,8 @@ func unlockProfiles(m model, password string) profiles {
return unlocked
}
func startProfileCmd(m model, onion string) tea.Msg {
// https://git.openprivacy.ca/sarah/cwtchbot/src/branch/main/bot.go
return nil
}