-
Notifications
You must be signed in to change notification settings - Fork 39
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
perf: remove immer from static report #501
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,16 @@ | ||
import actionNames from '../action-names'; | ||
import {applyStateUpdate} from '../utils/state'; | ||
|
||
export default (state, action) => { | ||
switch (action.type) { | ||
case actionNames.INIT_GUI_REPORT: | ||
case actionNames.INIT_STATIC_REPORT: { | ||
const {apiValues} = action.payload; | ||
|
||
return applyChanges(state, apiValues); | ||
return applyStateUpdate(state, {apiValues}); | ||
} | ||
|
||
default: | ||
return state; | ||
} | ||
}; | ||
|
||
function applyChanges(state, apiValues) { | ||
return { | ||
...state, | ||
apiValues: { | ||
...state.apiValues, | ||
...apiValues | ||
} | ||
}; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,14 @@ | ||
import actionNames from '../action-names'; | ||
import {produce} from 'immer'; | ||
import {set} from 'lodash'; | ||
import {applyStateUpdate} from '../utils/state'; | ||
|
||
export default produce((draft, action) => { | ||
export default ((state, action) => { | ||
switch (action.type) { | ||
case actionNames.UPDATE_BOTTOM_PROGRESS_BAR: { | ||
const {currentRootSuiteId} = action.payload; | ||
|
||
return set(draft, 'progressBar.currentRootSuiteId', currentRootSuiteId); | ||
return applyStateUpdate(state, {progressBar: {currentRootSuiteId}}); | ||
} | ||
|
||
default: | ||
return draft; | ||
return state; | ||
} | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
import {handleActiveResults, addGroupItem, sortGroupValues} from '../helpers'; | ||
import {ensureDiffProperty} from '../../../utils/state'; | ||
|
||
export function groupMeta({group, groupKey, ...restArgs}) { | ||
export function groupMeta({group, groupKey, diff = group, ...restArgs}) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Здесь и далее There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Довольно непонятное API. Если ничего не передал в При этом этот Не пробовал смотреть на There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Да, так и задумывалось. Это опциональный аргумент "куда записывать изменения". По умолчанию, если не передать его, запишет в
Да в принципе так же, как и обычное состояние. Просто изменения пишешь туда, и при передаче удостовериваешься, что передаваемый ключ существует с помощью
Пробовал, еще более неудобный |
||
const metaKeys = new Set(); | ||
if (groupKey) { | ||
group.byKey[groupKey] = {}; | ||
ensureDiffProperty(diff, ['byKey', groupKey]); | ||
} | ||
|
||
const resultCb = (result) => { | ||
|
@@ -18,14 +19,19 @@ export function groupMeta({group, groupKey, ...restArgs}) { | |
continue; | ||
} | ||
|
||
addGroupItem({group: group.byKey[groupKey], result, value}); | ||
addGroupItem({ | ||
group: group.byKey[groupKey], | ||
result, | ||
value, | ||
diff: diff.byKey[groupKey] | ||
Comment on lines
+23
to
+26
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Так что дальше в функции они прокидываются так же, как и сами их |
||
}); | ||
} | ||
}; | ||
|
||
handleActiveResults({...restArgs, resultCb}); | ||
|
||
group.allKeys = [...metaKeys].sort(); | ||
diff.allKeys = [...metaKeys].sort(); | ||
if (groupKey) { | ||
group.byKey[groupKey] = sortGroupValues(group.byKey[groupKey]); | ||
diff.byKey[groupKey] = sortGroupValues(diff.byKey[groupKey]); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
А почему просто не назвать
updateState
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
потому что
state
не обновляется. Он иммутабелен, иupdateState
по сути ничего обновлять не будет. Тут именно создается новый стейт из старого и диффа