Skip to content

Commit cd8c762

Browse files
committed
Extract out a selector for the selected channel
1 parent b4b8caf commit cd8c762

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

ui/frontend/selectors/index.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,11 @@ export const miriVersionDetailsText = createSelector(getMiri, versionDetails);
123123

124124
const editionSelector = (state: State) => state.configuration.edition;
125125

126-
export const isNightlyChannel = (state: State) => (
127-
state.configuration.channel === Channel.Nightly
126+
const channelSelector = (state: State) => state.configuration.channel;
127+
128+
export const isNightlyChannel = createSelector(
129+
channelSelector,
130+
(channel) => channel === Channel.Nightly,
128131
);
129132
export const isHirAvailable = isNightlyChannel;
130133

@@ -142,10 +145,7 @@ export const getModeLabel = (state: State) => {
142145
return `${mode}`;
143146
};
144147

145-
export const getChannelLabel = (state: State) => {
146-
const { configuration: { channel } } = state;
147-
return `${channel}`;
148-
};
148+
export const getChannelLabel = createSelector(channelSelector, (channel) => `${channel}`);
149149

150150
export const isEditionDefault = createSelector(
151151
editionSelector,
@@ -387,11 +387,12 @@ export const websocketStatusSelector = createSelector(
387387

388388
export const executeRequestPayloadSelector = createSelector(
389389
codeSelector,
390+
channelSelector,
390391
(state: State) => state.configuration,
391392
getBacktraceSet,
392393
(_state: State, { crateType, tests }: { crateType: string, tests: boolean }) => ({ crateType, tests }),
393-
(code, configuration, backtrace, { crateType, tests }) => ({
394-
channel: configuration.channel,
394+
(code, channel, configuration, backtrace, { crateType, tests }) => ({
395+
channel,
395396
mode: configuration.mode,
396397
edition: configuration.edition,
397398
crateType,
@@ -403,13 +404,14 @@ export const executeRequestPayloadSelector = createSelector(
403404

404405
export const compileRequestPayloadSelector = createSelector(
405406
codeSelector,
407+
channelSelector,
406408
(state: State) => state.configuration,
407409
getCrateType,
408410
runAsTest,
409411
getBacktraceSet,
410412
(_state: State, { target }: { target: string }) => ({ target }),
411-
(code, configuration, crateType, tests, backtrace, { target }) => ({
412-
channel: configuration.channel,
413+
(code, channel, configuration, crateType, tests, backtrace, { target }) => ({
414+
channel,
413415
mode: configuration.mode,
414416
edition: configuration.edition,
415417
crateType,

0 commit comments

Comments
 (0)