Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 3x 3x 3x 3x 1x 1x 1x 1x 1x 1x 1x 1x 5x 5x 5x 5x 5x 5x 5x 1x 5x 1x 1x 5x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 2x 2x 2x 2x 2x 2x 1x 1x 2x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 4x 4x 1x 1x 1x 4x 1x 1x 1x 4x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 5x 5x 5x 5x 5x 5x 1x 1x 1x 5x 1x 1x 1x 5x 1x 1x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x | import * as vscode from "vscode"; import { getAuthContext } from "../services/auth-service"; import { signInMenu, handleSignUp, handleSignOut, } from "../services/auth-service"; const showErrors = true; /** * Displays an error notification to the user in VS Code. * * Logs the error to the console and, if enabled, shows a non-modal error message in the editor. * * @param message - The error message to display. */ export async function errorNotification(message: string) { console.error(message); if (!showErrors) { return; } vscode.window.showErrorMessage(message, { modal: false }); } /** * Prompts unauthenticated users to either sign in or sign up. * * Displays an informational notification with "Sign In" and "Sign Up" options, * and triggers the appropriate authentication workflow based on the user's choice. */ export async function authNotification() { const choice = await vscode.window.showInformationMessage( "You are not authenticated. Please sign in to track your progress!", "Sign In", "Sign Up" ); if (choice === "Sign In") { await signInMenu(); } else if (choice === "Sign Up") { await handleSignUp(); } } /** * Notifies the user with a sign-out prompt. * * If the user confirms, triggers the sign-out process. * * @param messsage - The message to display with the sign-out option. */ export async function authSignOutNotification(messsage: string) { const signOutChoice = await vscode.window.showInformationMessage( `${messsage}`, "Sign Out" ); if (signOutChoice === "Sign Out") { await handleSignOut(); } } /** * Shows a temporary warning notification in the VS Code status bar. * * Displays the message for 2 seconds before automatically dismissing it. * * @param message - The message to display in the status bar. */ export async function showAuthNotification(message: string) { // vscode.window.showInformationMessage(message, { modal: false }); const notification = vscode.window.createStatusBarItem( vscode.StatusBarAlignment.Right, 90 ); notification.text = `$(info) ${message}`; notification.color = new vscode.ThemeColor("statusBarItem.warningForeground"); notification.backgroundColor = new vscode.ThemeColor( "statusBarItem.warningBackground" ); notification.show(); // Auto-dismiss after 2 seconds setTimeout(() => { notification.hide(); notification.dispose(); }, 2000); } /** * Displays a help-related notification if the user is authenticated * and has notifications enabled in their settings. * * If the user is unauthenticated, prompts them to sign in. * * @param message - The help message to display. */ export async function helpNotification(message: string) { const { context, error } = await getAuthContext(); if (error) { errorNotification(error); return; } if (!context) { authNotification(); return; } if (!context.settings.show_notifications) { return; } vscode.window.showInformationMessage(message, { modal: false }); } /** * Notifies the user with a customizable informational message. * Optionally offers a "Review" action that redirects the user to a URL. * * Checks for authentication and user notification settings before displaying the message. * * @param message - The message to display to the user. * @param url - (Optional) The URL to open if the user chooses "Review". * @param isModal - (Optional) Whether the notification should appear as a modal. Defaults to `false`. */ export async function notifyUser( message: string, url?: string, isModal: boolean = false ) { const { context, error } = await getAuthContext(); if (error) { errorNotification(error); return; } if (!context) { authNotification(); return; } if (!context.settings.show_notifications) { return; } vscode.window .showInformationMessage(message, { modal: isModal }, "Review", "Ignore") .then((selection) => { if (selection === "Review") { vscode.env.openExternal( vscode.Uri.parse(url || "https://clover.nickrucinski.com/") ); } }); } |