forked from MirrorHub/mautrix-whatsapp
Remove sync.OnceFunc usage. Fixes #679
This commit is contained in:
parent
cb6afe2e82
commit
4efb226045
1 changed files with 7 additions and 4 deletions
|
@ -21,7 +21,6 @@ import (
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/rs/zerolog"
|
"github.com/rs/zerolog"
|
||||||
|
@ -458,8 +457,12 @@ func (user *User) storeHistorySync(evt *waProto.HistorySync) {
|
||||||
Int("msg_count", len(conv.GetMessages())).
|
Int("msg_count", len(conv.GetMessages())).
|
||||||
Logger()
|
Logger()
|
||||||
|
|
||||||
initPortal := sync.OnceFunc(func() {
|
var portal *Portal
|
||||||
portal := user.GetPortalByJID(jid)
|
initPortal := func() {
|
||||||
|
if portal != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
portal = user.GetPortalByJID(jid)
|
||||||
historySyncConversation := user.bridge.DB.HistorySync.NewConversationWithValues(
|
historySyncConversation := user.bridge.DB.HistorySync.NewConversationWithValues(
|
||||||
user.MXID,
|
user.MXID,
|
||||||
conv.GetId(),
|
conv.GetId(),
|
||||||
|
@ -474,7 +477,7 @@ func (user *User) storeHistorySync(evt *waProto.HistorySync) {
|
||||||
conv.GetMarkedAsUnread(),
|
conv.GetMarkedAsUnread(),
|
||||||
conv.GetUnreadCount())
|
conv.GetUnreadCount())
|
||||||
historySyncConversation.Upsert()
|
historySyncConversation.Upsert()
|
||||||
})
|
}
|
||||||
|
|
||||||
var minTime, maxTime time.Time
|
var minTime, maxTime time.Time
|
||||||
var minTimeIndex, maxTimeIndex int
|
var minTimeIndex, maxTimeIndex int
|
||||||
|
|
Loading…
Reference in a new issue