-
Notifications
You must be signed in to change notification settings - Fork 269
fix(messenger): defer mailserver history sync when app is in background #7508
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
d793ad5
9aac52a
ee0cd6c
72956f2
26b2e81
5ab25f5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ import ( | |
| "sync" | ||
|
|
||
| "github.com/status-im/status-go/common" | ||
| "github.com/status-im/status-go/protocol" | ||
| "github.com/status-im/status-go/server" | ||
| ) | ||
|
|
||
|
|
@@ -38,6 +39,35 @@ func (p *PausableMediaServer) Resume() error { | |
| return nil | ||
| } | ||
|
|
||
| // PausableMessenger wraps a protocol.Messenger to implement common.Pausable. | ||
| // Pause() → ToBackground() and Resume() → ToForeground() so that the Java | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Java? 👀 |
||
| // PauseServices/ResumeServices flow gates filter health-check pings and | ||
| // mailserver history syncs without a separate SetAppBackground API call. | ||
| type PausableMessenger struct { | ||
|
jrainville marked this conversation as resolved.
|
||
| common.PauseBroadcaster | ||
| m *protocol.Messenger | ||
| } | ||
|
|
||
| func newPausableMessenger(m *protocol.Messenger) *PausableMessenger { | ||
| p := &PausableMessenger{m: m} | ||
| p.MarkStarted() | ||
| return p | ||
| } | ||
|
|
||
| func (p *PausableMessenger) PausableName() string { return "messenger" } | ||
|
|
||
| func (p *PausableMessenger) Pause() error { | ||
| p.m.ToBackground() | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Was the Messenger's
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. seems so
Comment on lines
+59
to
+60
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not ideal that I understand that Status app calls Not sure how to simply workaround it with current APIs though. |
||
| p.MarkPaused() | ||
| return nil | ||
| } | ||
|
|
||
| func (p *PausableMessenger) Resume() error { | ||
| p.m.ToForeground() | ||
| p.MarkResumed() | ||
| return nil | ||
| } | ||
|
|
||
| // PausableServiceInfo is a lightweight snapshot of a pausable service's state. | ||
| type PausableServiceInfo struct { | ||
| Name string `json:"name"` | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -159,7 +159,11 @@ func (m *Messenger) checkForStorenodeCycleSignals() { | |
| if ok { | ||
| signal.SendStoreNodeAvailable(&ms) | ||
| } | ||
| m.asyncRequestAllHistoricMessages() | ||
| // Skip history sync when backgrounded; ToForeground() | ||
| // will trigger it when the app returns to foreground. | ||
| if !m.backgroundMode.Load() { | ||
|
Comment on lines
+162
to
+164
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of skipping store node requests, why don't we just completely disconnect from storenodes and stop the |
||
| m.asyncRequestAllHistoricMessages() | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@xAlisher here and in other places we should refer to
github.com/waku-org/go-wakunot to the personal fork.