mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-22 15:37:45 +00:00
[web] fix bugs
This commit is contained in:
parent
e11d6600be
commit
c40ff0277b
File diff suppressed because one or more lines are too long
@ -17,8 +17,8 @@ const defaultState = {
|
||||
logId: 0,
|
||||
visible: false,
|
||||
filters: { debug: false, info: true, web: true },
|
||||
list: null,
|
||||
view: null,
|
||||
list: undefined,
|
||||
view: undefined,
|
||||
}
|
||||
|
||||
export default function reduce(state = defaultState, action) {
|
||||
|
@ -15,8 +15,8 @@ export const UNKNOWN_CMD = 'FLOWS_UNKNOWN_CMD'
|
||||
export const FETCH_ERROR = 'FLOWS_FETCH_ERROR'
|
||||
|
||||
const defaultState = {
|
||||
list: null,
|
||||
views: null,
|
||||
list: undefined,
|
||||
views: undefined,
|
||||
}
|
||||
|
||||
export default function reduce(state = defaultState, action) {
|
||||
|
@ -11,22 +11,27 @@ const defaultState = {
|
||||
}
|
||||
|
||||
export default function reduce(state = defaultState, action) {
|
||||
if (state.pendingActions && action.type !== RECEIVE) {
|
||||
return {
|
||||
...state,
|
||||
pendingActions: [...state.pendingActions, action]
|
||||
}
|
||||
}
|
||||
|
||||
switch (action.type) {
|
||||
|
||||
case SET:
|
||||
if (state.pendingActions) {
|
||||
return {
|
||||
...state,
|
||||
pendingActions: [...state.pendingActions, action]
|
||||
}
|
||||
}
|
||||
return {
|
||||
...state,
|
||||
data: { ...state.data, [action.id]: null, [action.item.id]: action.item }
|
||||
}
|
||||
|
||||
case CLEAR:
|
||||
if (state.pendingActions) {
|
||||
return {
|
||||
...state,
|
||||
pendingActions: [...state.pendingActions, action]
|
||||
}
|
||||
}
|
||||
return {
|
||||
...state,
|
||||
data: { ...state.data, [action.id]: null }
|
||||
|
@ -15,21 +15,23 @@ const defaultState = {
|
||||
export default function reduce(state = defaultState, action) {
|
||||
switch (action.type) {
|
||||
|
||||
case UPDATE_FILTER:
|
||||
case UPDATE_FILTER: {
|
||||
const data = _.values(action.list.data).filter(action.filter).sort(action.sorter)
|
||||
return {
|
||||
...state,
|
||||
data,
|
||||
indexOf: _.fromPairs(data.map((item, index) => [item.id, index])),
|
||||
}
|
||||
}
|
||||
|
||||
case UPDATE_SORTER:
|
||||
const data = state.data.slice().sort(action.sorter)
|
||||
case UPDATE_SORTER: {
|
||||
const data = [...state.data].sort(action.sorter)
|
||||
return {
|
||||
...state,
|
||||
data,
|
||||
indexOf: _.fromPairs(data.map((item, index) => [item.id, index]))
|
||||
}
|
||||
}
|
||||
|
||||
case ADD:
|
||||
if (state.indexOf[action.item.id] != null || !action.filter(action.item)) {
|
||||
@ -49,7 +51,7 @@ export default function reduce(state = defaultState, action) {
|
||||
...sortedRemove(state, action.id),
|
||||
}
|
||||
|
||||
case UPDATE:
|
||||
case UPDATE: {
|
||||
if (state.indexOf[action.item.id] == null) {
|
||||
return
|
||||
}
|
||||
@ -64,14 +66,16 @@ export default function reduce(state = defaultState, action) {
|
||||
...nextState,
|
||||
...sortedInsert(nextState, action.item, action.sorter)
|
||||
}
|
||||
}
|
||||
|
||||
case RECEIVE:
|
||||
case RECEIVE: {
|
||||
const data = _.values(action.list.data).filter(action.filter).sort(action.sorter)
|
||||
return {
|
||||
...state,
|
||||
data,
|
||||
indexOf: _.fromPairs(data.map((item, index) => [item.id, index])),
|
||||
}
|
||||
}
|
||||
|
||||
default:
|
||||
return state
|
||||
|
@ -2,6 +2,11 @@ import { combineReducers } from 'redux'
|
||||
import * as viewActions from './utils/view'
|
||||
import main from './views/main.js'
|
||||
|
||||
export const ADD = 'FLOW_VIEWS_ADD'
|
||||
export const UPDATE = 'FLOW_VIEWS_UPDATE'
|
||||
export const REMOVE = 'FLOW_VIEWS_REMOVE'
|
||||
export const RECEIVE = 'FLOW_VIEWS_RECEIVE'
|
||||
|
||||
export default combineReducers({
|
||||
main,
|
||||
})
|
||||
|
@ -1,10 +1,10 @@
|
||||
import reduceView, * as viewActions from '../utils/list'
|
||||
import * as viewsActions from '../views'
|
||||
|
||||
export const UPDATE_FILTER = 'MAIN_VIEW_UPDATE_FILTER'
|
||||
export const UPDATE_SORTER = 'MAIN_VIEW_UPDATE_SORTER'
|
||||
export const UPDATE_HIGHLIGHT = 'MAIN_VIEW_UPDATE_HIGHLIGHT'
|
||||
export const SELECT = 'MAIN_VIEW_SELECT'
|
||||
export const UPDATE_FILTER = 'FLOW_VIEWS_MAIN_UPDATE_FILTER'
|
||||
export const UPDATE_SORTER = 'FLOW_VIEWS_MAIN_UPDATE_SORTER'
|
||||
export const UPDATE_HIGHLIGHT = 'FLOW_VIEWS_MAIN_UPDATE_HIGHLIGHT'
|
||||
export const SELECT = 'FLOW_VIEWS_MAIN_SELECT'
|
||||
|
||||
const sortKeyFuns = {
|
||||
|
||||
@ -32,7 +32,7 @@ const defaultState = {
|
||||
selected: [],
|
||||
filter: null,
|
||||
sorter: { column: null, desc: false },
|
||||
view: null,
|
||||
view: undefined,
|
||||
}
|
||||
|
||||
export default function reduce(state = defaultState, action) {
|
||||
|
Loading…
Reference in New Issue
Block a user