refactor old isLoading to isLoadingMessages, and add "plenty" of new initalPageLoad payload retrievals
@@ -22,8 +22,9 @@ import {
} from "./reduce-messages.js";
import {
addConnectionFull,
+ addActiveConnectionsToNeedInLoading,
markConnectionAsRated,
- setConnectionLoading,
+ setConnectionLoadingMessages,
markConnectionAsRead,
selectNeedByConnectionUri,
changeConnectionState,
@@ -52,12 +53,19 @@ export default function(allNeedsInState = initialState, action = {}) {
case actionTypes.initialPageLoad:
case actionTypes.needs.fetchUnloadedNeeds:
case actionTypes.login: {
- let activeNeedUris = action.payload.get("activeNeedUris");
- let inactiveNeedUris = action.payload.get("inactiveNeedUris");
- let inactiveNeedUrisLoading = action.payload.get(
+ const activeNeedUris = action.payload.get("activeNeedUris");
+ const inactiveNeedUris = action.payload.get("inactiveNeedUris");
+ const inactiveNeedUrisLoading = action.payload.get(
"inactiveNeedUrisLoading"
);
- let theirNeedUrisInLoading = action.payload.get("theirNeedUrisInLoading");
+ const theirNeedUrisInLoading = action.payload.get(
+ "theirNeedUrisInLoading"
+ );
+
+ const needUriForConnections = action.payload.get("needUriForConnections");
+ const activeConnectionUrisLoading = action.payload.get(
+ "activeConnectionUrisLoading"
+ );
let ownNeeds = action.payload.get("ownNeeds");
ownNeeds = ownNeeds ? ownNeeds : Immutable.Set();
@@ -94,8 +102,14 @@ export default function(allNeedsInState = initialState, action = {}) {
stateWithOwnNeedsAndTheirNeedsInLoading
);
- return storeConnectionsData(
+ const stateWithConnectionsToLoad = addActiveConnectionsToNeedInLoading(
stateWithOwnAndTheirNeeds,
+ needUriForConnections,
+ activeConnectionUrisLoading
+ );
+
+ return storeConnectionsData(
+ stateWithConnectionsToLoad,
action.payload.get("connections")
);
}
@@ -428,11 +442,11 @@ export default function(allNeedsInState = initialState, action = {}) {
allNeedsInState,
action.payload.connectionUri
);
- case actionTypes.connections.setLoading:
- return setConnectionLoading(
+ case actionTypes.connections.setLoadingMessages:
+ return setConnectionLoadingMessages(
allNeedsInState,
action.payload.connectionUri,
- action.payload.isLoading
+ action.payload.isLoadingMessages
);
case actionTypes.connections.updateAgreementData:
@@ -544,11 +558,11 @@ export default function(allNeedsInState = initialState, action = {}) {
case actionTypes.connections.showLatestMessages:
case actionTypes.connections.showMoreMessages: {
- const isLoading = action.payload.get("isLoading");
+ const isLoadingMessages = action.payload.get("isLoadingMessages");
const connectionUri = action.payload.get("connectionUri");
- if (isLoading && connectionUri) {
- allNeedsInState = setConnectionLoading(
+ if (isLoadingMessages && connectionUri) {
+ allNeedsInState = setConnectionLoadingMessages(
allNeedsInState,
connectionUri,
true
@@ -558,7 +572,7 @@ export default function(allNeedsInState = initialState, action = {}) {
const loadedMessages = action.payload.get("events");
if (loadedMessages) {
allNeedsInState = addExistingMessages(allNeedsInState, loadedMessages);
- allNeedsInState = setConnectionLoading(
+ allNeedsInState = setConnectionLoadingMessages(
allNeedsInState,
connectionUri,
false
@@ -567,7 +581,7 @@ export default function(allNeedsInState = initialState, action = {}) {
const error = action.payload.get("error");
if (error && connectionUri) {
- allNeedsInState = setConnectionLoading(
+ allNeedsInState = setConnectionLoadingMessages(
allNeedsInState,
connectionUri,
false
