MCPcopy
hub / github.com/refined-github/refined-github / onChoiceButtonClick

Function onChoiceButtonClick

source/helpers/bisect.tsx:56–97  ·  view source on GitHub ↗
({currentTarget: button}: React.MouseEvent<HTMLButtonElement>)

Source from the content-addressed store, hash-verified

54}
55
56async function onChoiceButtonClick({currentTarget: button}: React.MouseEvent<HTMLButtonElement>): Promise<void> {
57 const answer = button.value;
58 const bisectedFeatures = (await state.get())!;
59
60 if (bisectedFeatures.length > 1) {
61 await state.set(
62 answer === 'yes'
63 ? bisectedFeatures.slice(0, getMiddleStep(bisectedFeatures))
64 : bisectedFeatures.slice(getMiddleStep(bisectedFeatures)),
65 );
66
67 button.parentElement!.replaceWith(<div className="btn" aria-disabled="true">Reloading…</div>);
68 location.reload();
69 return;
70 }
71
72 // Last step, no JS feature was enabled
73 if (answer === 'yes') {
74 createMessageBox(
75 <>
76 <p>
77 Unable to identify feature. It might be a CSS-only feature, a{' '}
78 <a href="https://github.com/refined-github/refined-github/wiki/Meta-features" target="_blank" rel="noreferrer">
79 meta-feature
80 </a>, or unrelated to Refined GitHub.
81 </p>
82 <p>Try disabling Refined GitHub to see if the change or issue is caused by the extension.</p>
83 </>,
84 );
85 } else {
86 const feature = (
87 <a href={getFeatureUrl(bisectedFeatures[0])}>
88 <code>{bisectedFeatures[0]}</code>
89 </a>
90 );
91
92 createMessageBox(<>The change or issue is caused by {feature}.</>);
93 }
94
95 await state.delete();
96 globalThis.removeEventListener('visibilitychange', hideMessage);
97}
98
99export default async function bisectFeatures(): Promise<Record<string, boolean> | void> {
100 // `bisect` stores the list of features to be split in half

Callers

nothing calls this directly

Calls 5

getMiddleStepFunction · 0.85
createMessageBoxFunction · 0.85
getFeatureUrlFunction · 0.85
getMethod · 0.80
setMethod · 0.80

Tested by

no test coverage detected