Skip to content
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

offline data not push in to outbox queue during aeroplane mode of mobile. #484

Open
aadarsh13pathak opened this issue Jan 10, 2022 · 7 comments

Comments

@aadarsh13pathak
Copy link

aadarsh13pathak commented Jan 10, 2022

I create a app which have offline and online modes,when i switch to aeroplane mode and open my application and add some data in offline mode after adding data ,i close the app then turn on my mobile internet and then open my application and there is no data which i have added in offline mode and after that my normal data not added in online mode also ...
this redux offline working goood when i normally close my mobile internet and add something in my app it will go in the outbox successfully and showing on the UI in the online mode ,but when i switch my mobile phone in Aeroplane mode and then open my application and add something item it will go in to the offline outbox and when i turn on my mobile internet for checking my offline data is come or not but it not come on the UI and my outbox queue is increasing continously .
**in Aeroplane mode my offline data not push in to offline outbox **

@aadarsh13pathak aadarsh13pathak changed the title outbox offline data is stuck during aeroplane mode of mobile. offline data not push in to outbox queue during aeroplane mode of mobile. Jan 10, 2022
@sorodrigo
Copy link
Member

Could you provide some snapshots of your store to see what's going on?

@aadarsh13pathak
Copy link
Author

aadarsh13pathak commented Jan 10, 2022

import { createStore, applyMiddleware, compose } from "redux";
import { persistStore, persistReducer } from "redux-persist";
import AsyncStorage from "@react-native-async-storage/async-storage";
import ReduxThunk from "redux-thunk";
import ReduxLogger from "redux-logger";
import hardSet from "redux-persist/lib/stateReconciler/hardSet";
import rootReducer from "@store/store";

//offline
import { createOffline } from "@redux-offline/redux-offline";
import offlineConfig from "@redux-offline/redux-offline/lib/defaults";

const {
  middleware: offlineMiddleware,
  enhanceReducer: offlineEnhanceReducer,
  enhanceStore: offlineEnhanceStore
} = createOffline({
  ...offlineConfig,
  persist: false
});

const persistConfig = {
  key: "root",
  storage: AsyncStorage,
  stateReconciler: hardSet,
  whitelist: ["user", "inbox", "app", "offline", "journal", "learning", "todayCount"]
};

// const store: Store<IAppState> = createStore(
//   offlineEnhancer.enhanceReducer(rootReducer),
//   initialState,
//   composeEnhancers(
//       offlineEnhancer.enhanceStore,
//       applyMiddleware(offlineEnhancer.middleware as any, epicMiddleware),
//   )
// );

const persistedReducer = persistReducer(persistConfig, offlineEnhanceReducer(rootReducer));

const isDevMode = Boolean(__DEV__);

const middleWares = isDevMode ? [offlineMiddleware, ReduxThunk, ReduxLogger] : [offlineMiddleware, ReduxThunk];
const store = createStore(persistedReducer, {}, compose(offlineEnhanceStore, applyMiddleware(...middleWares)));

const persistor = persistStore(store);

export default { store, persistor };

@aadarsh13pathak
Copy link
Author

aadarsh13pathak commented Jan 12, 2022

hey @sorodrigo when i am online but my app treat me as offline

  "offline": {
    "busy": false,
    "lastTransaction": 30,
    "netInfo": {
      "isConnectionExpensive": false,
      "reach": "wifi"
    },
    "online": true,
    "outbox": [
      
    ],
    "retryCount": 0,
    "retryScheduled": false
}

and thats why my data nor push into outbox and neitther pop ,i have to switch on and off my internet then it will work as offline
and it log this

"offline": {
    "busy": false,
    "lastTransaction": 34,
    "netInfo": {
      "isConnectionExpensive": undefined,
      "reach": "none"
    },
    "online": false,
    "outbox": [
      [
        Object
      ]
    ],
    "retryCount": 0,
    "retryScheduled": false
}

@sorodrigo
Copy link
Member

Hmm I'm sorry but it's very hard to tell with the info I have. Are you testing in a simulator? Could you verify this happens in a real device? Also could you send me the state of the outbox:

  • before and after you enable airplane mode
  • before and after you disabled airplane mode

@redux-offline redux-offline deleted a comment from aadarsh13pathak Jan 13, 2022
@sorodrigo
Copy link
Member

@aadarsh13pathak please redact tokens and personal data before sharing stuff 😳

@aadarsh13pathak
Copy link
Author

aadarsh13pathak commented Jan 13, 2022

@sorodrigo yes this happens in my real device

Before enable aeroplane mode

"offline": {
"busy": false,
"lastTransaction": 0,
"netInfo": {
"isConnectionExpensive": false,
"reach": "wifi"
},
"online": true,
"outbox": [

],
"retryCount": 0,
"retryScheduled": false

},

after enable aeroplane mode

"offline": {
"busy": false,
"lastTransaction": 0,
"netInfo": {
"isConnectionExpensive": false,
"reach": "wifi"
},
"online": true,
"outbox": [

],
"retryCount": 0,
"retryScheduled": false

},

after disable aeroplane mode

"offline": {
"busy": false,
"lastTransaction": 1,
"netInfo": {
"isConnectionExpensive": false,
"reach": "wifi"
},
"online": true,
"outbox": [

],
"retryCount": 0,
"retryScheduled": false

after enable and disable my phone internet and that time my app work fine

"offline": {
"busy": false,
"lastTransaction": 1,
"netInfo": {
"isConnectionExpensive": undefined,
"reach": "none"
},
"online": false,
"outbox": [

],
"retryCount": 0,

@aadarsh13pathak
Copy link
Author

@sorodrigo could you tell me ,
is something wrong in my code or its just a library issue ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants