(enabled, dispatch)
| 138 | } |
| 139 | |
| 140 | export const setReduxDevToolsMethods = (enabled, dispatch) => { |
| 141 | if (process.platform !== 'darwin') return |
| 142 | initNamedImages() |
| 143 | |
| 144 | // Already setup |
| 145 | if (enabled && isSliderEnabled) return |
| 146 | |
| 147 | const handleSliderChange = (nextIndex, dontUpdateTouchBarSlider = false) => dispatch({ |
| 148 | type: 'JUMP_TO_STATE', |
| 149 | actionId: storeLiftedState.stagedActionIds[nextIndex], |
| 150 | index: nextIndex, |
| 151 | dontUpdateTouchBarSlider, |
| 152 | }) |
| 153 | |
| 154 | rightBar = { |
| 155 | slider: new TouchBarSlider({ |
| 156 | value: 0, |
| 157 | minValue: 0, |
| 158 | maxValue: 0, |
| 159 | change(nextIndex) { |
| 160 | if (nextIndex !== storeLiftedState.currentStateIndex) { |
| 161 | // Set `dontUpdateTouchBarSlider` true for keep slide experience |
| 162 | handleSliderChange(nextIndex, true) |
| 163 | } |
| 164 | }, |
| 165 | }), |
| 166 | prev: new TouchBarButton({ |
| 167 | icon: namedImages.prev, |
| 168 | click() { |
| 169 | const nextIndex = storeLiftedState.currentStateIndex - 1 |
| 170 | if (nextIndex >= 0) { |
| 171 | handleSliderChange(nextIndex) |
| 172 | } |
| 173 | }, |
| 174 | }), |
| 175 | next: new TouchBarButton({ |
| 176 | icon: namedImages.next, |
| 177 | click() { |
| 178 | const nextIndex = storeLiftedState.currentStateIndex + 1 |
| 179 | if (nextIndex < storeLiftedState.computedStates.length) { |
| 180 | handleSliderChange(nextIndex) |
| 181 | } |
| 182 | }, |
| 183 | }), |
| 184 | } |
| 185 | isSliderEnabled = enabled |
| 186 | setTouchBar() |
| 187 | } |
| 188 | |
| 189 | export const updateSliderContent = (liftedState, dontUpdateTouchBarSlider) => { |
| 190 | if (process.platform !== 'darwin') return |
no test coverage detected