mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-12-28 09:02:35 +01:00
fix: Do not setup UP if init from an UP action
This commit is contained in:
parent
81164316b5
commit
fd19dafbbb
@ -68,6 +68,8 @@ class BackgroundPush {
|
||||
|
||||
DateTime lastReceivedPush;
|
||||
|
||||
bool upAction = false;
|
||||
|
||||
BackgroundPush._(this.client, {this.onFcmError}) {
|
||||
onLogin ??=
|
||||
client.onLoginStateChanged.stream.listen(handleLoginStateChanged);
|
||||
@ -214,12 +216,18 @@ class BackgroundPush {
|
||||
bool _wentToRoomOnStartup = false;
|
||||
|
||||
Future<void> setupPush() async {
|
||||
Logs().d("SetupPush");
|
||||
await setupLocalNotificationsPlugin();
|
||||
if (client.loginState != LoginState.loggedIn ||
|
||||
!PlatformInfos.isMobile ||
|
||||
context == null) {
|
||||
return;
|
||||
}
|
||||
// Do not setup unifiedpush if this has been initialized by
|
||||
// an unifiedpush action
|
||||
if (upAction) {
|
||||
return;
|
||||
}
|
||||
if (!PlatformInfos.isIOS &&
|
||||
(await UnifiedPush.getDistributors()).isNotEmpty) {
|
||||
await setupUp();
|
||||
@ -334,6 +342,7 @@ class BackgroundPush {
|
||||
}
|
||||
|
||||
Future<void> _newUpEndpoint(String newEndpoint) async {
|
||||
upAction = true;
|
||||
if (newEndpoint?.isEmpty ?? true) {
|
||||
await _upUnregistered();
|
||||
return;
|
||||
@ -377,6 +386,7 @@ class BackgroundPush {
|
||||
}
|
||||
|
||||
Future<void> _upUnregistered() async {
|
||||
upAction = true;
|
||||
Logs().i('[Push] Removing UnifiedPush endpoint...');
|
||||
final oldEndpoint = await store.getItem(SettingKeys.unifiedPushEndpoint);
|
||||
await store.setItemBool(SettingKeys.unifiedPushRegistered, false);
|
||||
@ -390,6 +400,7 @@ class BackgroundPush {
|
||||
}
|
||||
|
||||
Future<void> _onUpMessage(String message) async {
|
||||
upAction = true;
|
||||
Map<String, dynamic> data;
|
||||
try {
|
||||
data = Map<String, dynamic>.from(json.decode(message)['notification']);
|
||||
|
Loading…
Reference in New Issue
Block a user