MCPcopy
hub / github.com/gitify-app/gitify / SystemSettings

Function SystemSettings

src/renderer/components/settings/SystemSettings.tsx:42–378  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

40import { VolumeUpIcon } from '../icons/VolumeUpIcon';
41
42export const SystemSettings: FC = () => {
43 const {
44 settings,
45 updateSetting,
46 shortcutRegistrationError,
47 clearShortcutRegistrationError,
48 } = useAppContext();
49
50 const [recordingShortcut, setRecordingShortcut] = useState(false);
51 const [liveModifierAccelerator, setLiveModifierAccelerator] = useState('');
52 const shortcutRowRef = useRef<HTMLDivElement>(null);
53 const isMac = window.gitify.platform.isMacOS();
54
55 useEffect(() => {
56 if (!recordingShortcut) {
57 return;
58 }
59
60 const onPointerDown = (event: PointerEvent) => {
61 if (shortcutRowRef.current?.contains(event.target as Node)) {
62 return;
63 }
64 setRecordingShortcut(false);
65 };
66
67 document.addEventListener('pointerdown', onPointerDown, true);
68 return () => {
69 document.removeEventListener('pointerdown', onPointerDown, true);
70 };
71 }, [recordingShortcut]);
72
73 useEffect(() => {
74 if (!recordingShortcut) {
75 setLiveModifierAccelerator('');
76 return;
77 }
78
79 const activeModifierAccelerator = (event: KeyboardEvent) =>
80 MODIFIER_SEGMENTS.filter((m) => m.test(event))
81 .map((m) => m.accelerator)
82 .join('+');
83
84 const onKeyDown = (event: KeyboardEvent) => {
85 event.preventDefault();
86 event.stopPropagation();
87
88 setLiveModifierAccelerator(activeModifierAccelerator(event));
89
90 const accelerator = keyboardEventToAccelerator(event);
91 if (accelerator) {
92 clearShortcutRegistrationError();
93 updateSetting('openGitifyShortcut', accelerator);
94 setLiveModifierAccelerator('');
95 setRecordingShortcut(false);
96 }
97 };
98
99 const onKeyUp = (event: KeyboardEvent) => {

Callers

nothing calls this directly

Calls 6

useAppContextFunction · 0.90
canDecreaseVolumeFunction · 0.90
decreaseVolumeFunction · 0.90
canIncreaseVolumeFunction · 0.90
increaseVolumeFunction · 0.90

Tested by

no test coverage detected