[Gekidou] Fix & small refactor to the app entry logic and WS reconnection (#5937)

* Fix & small refactor to the app entry logic and WS reconnection

* Remove not needed log in MainActivity

* Replace async forEach with for await

* extract getClient to its own block

* replace double filter with reduce

* fix select channel on WS reconnect and user no longer belongs to current team

* feedback review on WS users actions

* Add windowFocusChanged for Android only

* on WS reconnection set team & channel if not member of current team

* reduce suggestion

* feedback review
This commit is contained in:
Elias Nahum
2022-02-09 12:49:37 -03:00
committed by GitHub
parent 92e069f00c
commit 3ea065b845
19 changed files with 349 additions and 200 deletions

View File

@@ -2,9 +2,14 @@ package com.mattermost.rnbeta;
import android.os.Bundle;
import androidx.annotation.Nullable;
import android.view.KeyEvent;
import android.content.res.Configuration;
import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.WritableMap;
import com.reactnativenavigation.NavigationActivity;
import com.github.emilioicai.hwkeyboardevent.HWKeyboardEventModule;
@@ -29,6 +34,18 @@ public class MainActivity extends NavigationActivity {
}
}
@Override
// This can be removed once https://github.com/facebook/react-native/issues/32628 is solved
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
MattermostManagedModule instance = MattermostManagedModule.getInstance();
if (instance != null) {
WritableMap data = Arguments.createMap();
data.putString("appState", hasFocus ? "active" : "background");
instance.sendEvent("windowFocusChanged", data);
}
}
/*
https://mattermost.atlassian.net/browse/MM-10601
Required by react-native-hw-keyboard-event