From 7ace298d6ecca5a048c74781e39be0732f9a55ab Mon Sep 17 00:00:00 2001 From: Dan Ballard Date: Thu, 10 Mar 2022 14:09:52 -0800 Subject: [PATCH] add started() is lcg initialized check api; prevcent reconnect from launching dup peer message forwarding; remove unused MessageCounterResync --- lib.go | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/lib.go b/lib.go index 00e9938..6830ab6 100644 --- a/lib.go +++ b/lib.go @@ -8,14 +8,12 @@ import "C" import ( "crypto/rand" + constants2 "cwtch.im/cwtch/model/constants" "cwtch.im/cwtch/protocol/files" "encoding/json" "fmt" "io/ioutil" path "path/filepath" - "strconv" - - constants2 "cwtch.im/cwtch/model/constants" "git.openprivacy.ca/cwtch.im/libcwtch-go/features" @@ -294,6 +292,19 @@ func buildACN(settings utils.GlobalSettings, torPath string, appDir string) conn return acn } +//export c_Started +func c_Started() C.int { + return C.int(Started()) +} + +// Started returns 1 if application is initialized and 0 if it is null +func Started() int { + if application == nil { + return 0 + } + return 1 +} + //export c_ReconnectCwtchForeground func c_ReconnectCwtchForeground() { ReconnectCwtchForeground() @@ -302,7 +313,7 @@ func c_ReconnectCwtchForeground() { // Like StartCwtch, but StartCwtch has already been called so we don't need to restart Tor etc (probably) // Do need to re-send initial state tho, eg profiles that are already loaded func ReconnectCwtchForeground() { - log.Infof("Reconnecting cwtchforeground") + log.Infof("Reconnecting cwtch foreground") if application == nil { log.Errorf("ReconnectCwtchForeground: Application is nil, presuming stale thread, EXITING Reconnect\n") return @@ -311,7 +322,7 @@ func ReconnectCwtchForeground() { // populate profile list peerList := application.ListProfiles() for _, onion := range peerList { - eventHandler.Push(event.NewEvent(event.NewPeer, map[event.Field]string{event.Identity: onion})) + eventHandler.Push(event.NewEvent(event.NewPeer, map[event.Field]string{event.Identity: onion, "Reload": event.True})) } settings := utils.ReadGlobalSettings() @@ -319,17 +330,6 @@ func ReconnectCwtchForeground() { for _, profileOnion := range peerList { // fix peerpeercontact message counts profile := application.GetPeer(profileOnion) - conversations, _ := profile.FetchConversations() - for _, conversation := range conversations { - if (conversation.IsGroup() && groupHandler != nil) || !conversation.IsServer() { - totalMessages, _ := profile.GetChannelMessageCount(conversation.ID, 0) - eventHandler.Push(event.NewEvent(event.MessageCounterResync, map[event.Field]string{ - event.Identity: profileOnion, - event.ConversationID: strconv.Itoa(conversation.ID), - event.Data: strconv.Itoa(totalMessages), - })) - } - } // Group Experiment Server Refresh if groupHandler != nil {