mirror of
https://github.com/status-im/status-go.git
synced 2025-01-24 21:49:54 +00:00
PR to fix media server sleep issue (#3189)
* fix media-server sleep wake up issue we now use waku v2 and hence messenger was nil. Since it was nil, the logic in place responsible for triggering app state events was not firing and hence media server would become un-responsive after a sleep event. this commit fixes that. Co-Authored-By: Andrea Maria Piana <andrea.maria.piana@gmail.com> --------- Co-authored-by: Andrea Maria Piana <andrea.maria.piana@gmail.com>
This commit is contained in:
parent
b69042e7d7
commit
cf84c40320
@ -1289,31 +1289,38 @@ func (b *GethStatusBackend) ConnectionChange(typ string, expensive bool) {
|
||||
// AppStateChange handles app state changes (background/foreground).
|
||||
// state values: see https://facebook.github.io/react-native/docs/appstate.html
|
||||
func (b *GethStatusBackend) AppStateChange(state string) {
|
||||
var messenger *protocol.Messenger
|
||||
s, err := parseAppState(state)
|
||||
if err != nil {
|
||||
log.Error("AppStateChange failed, ignoring", "error", err)
|
||||
return // and do nothing
|
||||
return
|
||||
}
|
||||
|
||||
b.log.Info("App State changed", "new-state", s)
|
||||
b.appState = s
|
||||
|
||||
if b.statusNode != nil {
|
||||
wakuext := b.statusNode.WakuExtService()
|
||||
if b.statusNode == nil {
|
||||
log.Warn("statusNode nil, not reporting app state change")
|
||||
return
|
||||
}
|
||||
|
||||
if wakuext != nil {
|
||||
messenger := wakuext.Messenger()
|
||||
if b.statusNode.WakuExtService() != nil {
|
||||
messenger = b.statusNode.WakuExtService().Messenger()
|
||||
}
|
||||
|
||||
if b.statusNode.WakuV2ExtService() != nil {
|
||||
messenger = b.statusNode.WakuV2ExtService().Messenger()
|
||||
}
|
||||
|
||||
if messenger == nil {
|
||||
log.Warn("messenger nil, not reporting app state change")
|
||||
return
|
||||
}
|
||||
|
||||
if messenger != nil {
|
||||
if s == appStateForeground {
|
||||
messenger.ToForeground()
|
||||
} else {
|
||||
messenger.ToBackground()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// TODO: put node in low-power mode if the app is in background (or inactive)
|
||||
// and normal mode if the app is in foreground.
|
||||
|
@ -4444,6 +4444,7 @@ func (m *Messenger) prepareMessage(msg *common.Message, s *server.MediaServer) {
|
||||
if msg.ContentType == protobuf.ChatMessage_IMAGE {
|
||||
msg.ImageLocalURL = s.MakeImageURL(msg.ID)
|
||||
}
|
||||
|
||||
if msg.ContentType == protobuf.ChatMessage_DISCORD_MESSAGE {
|
||||
|
||||
dm := msg.GetDiscordMessage()
|
||||
|
@ -80,6 +80,7 @@ func (s *ServerURLSuite) TestServer_MakeImageURL() {
|
||||
s.Require().Equal(
|
||||
"https://127.0.0.1:1337/messages/images?messageId=0x10aded70ffee",
|
||||
s.server.MakeImageURL("0x10aded70ffee"))
|
||||
|
||||
s.testNoPort(
|
||||
"https://127.0.0.1:80/messages/images?messageId=0x10aded70ffee",
|
||||
s.serverNoPort.MakeImageURL("0x10aded70ffee"))
|
||||
|
Loading…
x
Reference in New Issue
Block a user