Use handlers instead of sleeping for startup chat/contact sync

This commit is contained in:
Tulir Asokan
2019-08-25 00:25:29 +03:00
parent f28322d1f7
commit 1490830be2
6 changed files with 56 additions and 24 deletions

View File

@ -103,7 +103,7 @@ func (handler *CommandHandler) Handle(roomID types.MatrixRoomID, user *User, mes
case "dev-test":
handler.CommandDevTest(ce)
case "login-matrix", "logout", "sync", "list", "open", "pm":
if ce.User.Conn == nil {
if !ce.User.HasSession() {
ce.Reply("You are not logged in. Use the `login` command to log into WhatsApp.")
return
} else if !ce.User.IsConnected() {
@ -333,9 +333,9 @@ func (handler *CommandHandler) CommandSync(ce *CommandEvent) {
}
ce.Reply("Syncing contacts...")
user.syncPuppets()
user.syncPuppets(nil)
ce.Reply("Syncing chats...")
user.syncPortals(create)
user.syncPortals(nil, create)
ce.Reply("Sync complete.")
}