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