Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | 4x 4x 4x 1x 3x 4x 2x 2x 4x 4x 3x 2x 2x 1x 1x 1x 1x 34x 2x 4x 1x 2x 2x 23x | import { AVAILABLE } from "../constants";
import {
INIT_CHANNEL_MAP,
SELECT_REVISION,
CLEAR_SELECTED_REVISIONS,
RELEASE_REVISION_SUCCESS,
CLOSE_CHANNEL_SUCCESS,
} from "../actions/channelMap";
function selectRevision(state, revision, toggle) {
const arch = revision.architectures[0];
state = {
...state,
[AVAILABLE]: { ...state[AVAILABLE] },
};
if (
toggle &&
state[AVAILABLE][arch] &&
state[AVAILABLE][arch].revision === revision.revision
) {
delete state[AVAILABLE][arch];
} else {
state[AVAILABLE][arch] = { ...revision };
}
return state;
}
function releaseRevision(state, revision, channel) {
state = {
...state,
[channel]: { ...state[channel] },
};
revision.architectures.forEach((arch) => {
const currentlyReleased = state[channel][arch];
// only update revision in channel map if it changed since last time
if (
!currentlyReleased ||
currentlyReleased.revision !== revision.revision
) {
state[channel][arch] = { ...revision };
}
});
return state;
}
function closeChannel(state, channel) {
// if channel is already closed do nothing
if (!state[channel]) {
return state;
}
state = { ...state };
delete state[channel];
return state;
}
// contains channel map for each channel in current track
// also includes 'unassigned' fake channel to show selected unassigned revision
export default function channelMap(state = {}, action) {
switch (action.type) {
case INIT_CHANNEL_MAP:
return {
...action.payload.channelMap,
};
case SELECT_REVISION:
return selectRevision(
state,
action.payload.revision,
action.payload.toggle,
);
case CLEAR_SELECTED_REVISIONS:
return {
...state,
[AVAILABLE]: {},
};
case RELEASE_REVISION_SUCCESS:
return releaseRevision(
state,
action.payload.revision,
action.payload.channel,
);
case CLOSE_CHANNEL_SUCCESS:
return closeChannel(state, action.payload.channel);
default:
return state;
}
}
|