Open ConnectionPopup on first start

This commit is contained in:
Christian Muehlhaeuser 2019-05-09 16:20:25 +02:00
parent 78c0212cf3
commit 7367656c68
No known key found for this signature in database
GPG key ID: 3CF9FA45CA1EBB7E
2 changed files with 14 additions and 9 deletions

View file

@ -3,6 +3,7 @@ package mastodon
import (
"context"
"errors"
"fmt"
"log"
"regexp"
@ -70,17 +71,17 @@ func (mod *Account) Authenticate(code string) (string, string, string, string, e
}
// Run executes the account's event loop.
func (mod *Account) Run(eventChan chan interface{}) {
func (mod *Account) Run(eventChan chan interface{}) error {
mod.evchan = eventChan
if mod.config.AccessToken == "" {
return
return errors.New("no accesstoken found")
}
var err error
mod.self, err = mod.client.GetAccountCurrentUser(context.Background())
if err != nil {
panic(err)
return err
}
ev := accounts.LoginEvent{
@ -104,7 +105,7 @@ func (mod *Account) Run(eventChan chan interface{}) {
Limit: initialNotificationsCount,
})
if err != nil {
panic(err)
return err
}
for i := len(nn) - 1; i >= 0; i-- {
mod.handleNotification(nn[i])
@ -114,13 +115,14 @@ func (mod *Account) Run(eventChan chan interface{}) {
Limit: initialFeedCount,
})
if err != nil {
panic(err)
return err
}
for i := len(tt) - 1; i >= 0; i-- {
mod.evchan <- mod.handleStatus(tt[i])
}
mod.handleStream()
go mod.handleStream()
return nil
}
func (mod *Account) Logo() string {

View file

@ -186,9 +186,12 @@ func setupMastodon(config Account) {
evchan := make(chan interface{})
go handleEvents(evchan, postModel, notificationModel)
go func() {
tc.Run(evchan)
}()
err := tc.Run(evchan)
if err != nil {
// panic(err)
fmt.Println("Error connecting:", err)
}
configBridge.SetFirstRun(err != nil)
}
func main() {