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

Fix regression bug with active sessions #2809

Merged
merged 2 commits into from
Jun 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion e
Submodule e updated from ee15e4 to 947545
Original file line number Diff line number Diff line change
Expand Up @@ -13644,7 +13644,6 @@ var ActiveSessionRec = Object(immutable["Record"])({
id: undefined,
namespace: undefined,
login: undefined,
active: undefined,
created: undefined,
last_active: undefined,
server_id: undefined,
Expand Down Expand Up @@ -13677,9 +13676,7 @@ function activeSessionStore_receive(state, _ref) {

var jsonArray = json || [];
var newState = activeSessionStore_defaultState().withMutations(function (newState) {
return jsonArray.filter(function (item) {
return item.active === true;
}).forEach(function (item) {
return jsonArray.forEach(function (item) {
var rec = createSessionRec(siteId, item);
newState.set(rec.id, rec);
});
Expand Down
2 changes: 1 addition & 1 deletion web/dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
<link rel="shortcut icon" href="/web/app/favicon.ico"><link href="/web/app/styles.f0d4056308cafd8d7d57.css" rel="stylesheet"></head>
<body class="grv">
<div id="app"></div>
<script type="text/javascript" src="/web/app/vendor.ba4b74d1b45a75b1ce0e.js"></script><script type="text/javascript" src="/web/app/app.a566da8b734f87b82b29.js"></script></body>
<script type="text/javascript" src="/web/app/vendor.ba4b74d1b45a75b1ce0e.js"></script><script type="text/javascript" src="/web/app/app.d57cf48376d31bb5f8a8.js"></script></body>
</html>
24 changes: 11 additions & 13 deletions web/src/app/flux/sessions/activeSessionStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,15 @@ import { Record, List } from 'immutable';

import { RECEIVE_ACTIVE_SESSIONS } from './actionTypes';

const ActiveSessionRec = Record({
const ActiveSessionRec = Record({
id: undefined,
namespace: undefined,
namespace: undefined,
login: undefined,
active: undefined,
created: undefined,
last_active: undefined,
server_id: undefined,
siteId: undefined,
parties: List()
parties: List()
})

const PartyRecord = Record({
Expand All @@ -37,14 +36,14 @@ const PartyRecord = Record({
serverId: undefined
})

const defaultState = () => toImmutable({});
const defaultState = () => toImmutable({});

export default Store({
getInitialState() {
return defaultState();
},

initialize() {
initialize() {
this.on(RECEIVE_ACTIVE_SESSIONS, receive);
}
})
Expand All @@ -54,14 +53,13 @@ function receive(state, { siteId, json }) {
const jsonArray = json || [];
const newState = defaultState().withMutations(newState =>
jsonArray
.filter(item => item.active === true)
.forEach(item => {
const rec = createSessionRec(siteId, item);
newState.set(rec.id, rec);
})
);
return newState.equals(state) ? state : newState;

return newState.equals(state) ? state : newState;
}

function createSessionRec(siteId, json) {
Expand All @@ -77,9 +75,9 @@ function createSessionRec(siteId, json) {

function createParties(jsonArray) {
jsonArray = jsonArray || [];
const list = new List();
const list = new List();
return list.withMutations(list => {
jsonArray.forEach(item => {
jsonArray.forEach(item => {
const party = new PartyRecord({
user: item.user,
serverIp: item.remote_addr,
Expand All @@ -88,5 +86,5 @@ function createParties(jsonArray) {

list.push(party)
})
})
}
})
}