Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add setting for notifying or not when toggling hints #295

Merged
merged 1 commit into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/common/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const defaultSettings = {
hintsToggleTabs: new Map<number, boolean>(),
alwaysComputeHintables: false,
enableNotifications: true,
notifyWhenTogglingHints: false,
toastPosition: "top-center",
toastTransition: "bounce",
toastDuration: 5000,
Expand Down
2 changes: 1 addition & 1 deletion src/content/actions/runRangoActionWithoutTarget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export async function runRangoActionWithoutTarget(
break;

case "displayTogglesStatus":
await notifyTogglesStatus();
await notifyTogglesStatus(true);
break;

case "focusFirstInput":
Expand Down
9 changes: 7 additions & 2 deletions src/content/notify/notify.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,13 @@ export async function notify(text: string, options?: ToastOptions) {
}
}

export async function notifyTogglesStatus() {
if (!(await shouldNotify())) return;
export async function notifyTogglesStatus(force = false) {
if (
!(await shouldNotify()) ||
(!force && !getCachedSetting("notifyWhenTogglingHints"))
) {
return;
}

renderToast();

Expand Down
13 changes: 13 additions & 0 deletions src/settings/SettingsComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,19 @@ export function SettingsComponent() {
}}
/>
</SettingRow>
<SettingRow>
<Toggle
label="Show notification when toggling hints"
isPressed={settings.notifyWhenTogglingHints}
isDisabled={!settings.enableNotifications}
onClick={() => {
handleChange(
"notifyWhenTogglingHints",
!settings.notifyWhenTogglingHints
);
}}
/>
</SettingRow>
<SettingRow>
<Select
label="Position"
Expand Down
1 change: 1 addition & 0 deletions src/typings/StorageSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export const zStorageSchema = z.object({

// Notifications
enableNotifications: z.boolean(),
notifyWhenTogglingHints: z.boolean(),
toastPosition: z.enum([
"top-right",
"top-center",
Expand Down
Loading