mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-05 16:23:36 +00:00
Add debug logging and lower threshold for testing push reminders
- Reduced MESSAGE_THRESHOLD from 5 to 2 for easier testing - Added console.log statements to track: - Message counter increments - shouldShowReminder checks and conditions - Git status (uncommitted changes, commits ahead, remotes) - Added useEffect to watch shouldShowReminder changes - Fixed async state update issue by watching effect dependency This will help debug why the reminder dialog may not be appearing.
This commit is contained in:
1 parent
5de01c6130
commit
66a37ec92c
2 files changed
+37
-11
No files matched your search
@@ -21,7 +21,7 @@ const DEFAULT_STATE: PushReminderState = {
|
||||
};
|
||||
|
||||
/** Number of messages before showing push reminder */
|
||||
const MESSAGE_THRESHOLD = 5;
|
||||
const MESSAGE_THRESHOLD = 2; // Lowered to 2 for easier testing
|
||||
|
||||
/** Minimum time in ms between showing reminders (5 minutes) */
|
||||
const MIN_REMINDER_INTERVAL = 5 * 60 * 1000;
|
||||
@@ -49,33 +49,57 @@ export function usePushReminder(projectId: string | null) {
|
||||
// Check if should show reminder
|
||||
const shouldShowReminder = useCallback(() => {
|
||||
if (!state.enabled || !projectId || !gitStatus?.isGitRepo) {
|
||||
console.log('[PushReminder] Should NOT show - enabled:', state.enabled, 'projectId:', projectId, 'isGitRepo:', gitStatus?.isGitRepo);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Don't show if user recently interacted with push reminder
|
||||
const timeSinceLastInteraction = Date.now() - state.lastInteraction;
|
||||
if (timeSinceLastInteraction < MIN_REMINDER_INTERVAL) {
|
||||
console.log('[PushReminder] Should NOT show - too soon since last interaction:', Math.round(timeSinceLastInteraction / 1000), 'seconds');
|
||||
return false;
|
||||
}
|
||||
|
||||
// Show if:
|
||||
// 1. There are uncommitted changes OR commits ahead of remote
|
||||
// 1. There are uncommitted changes OR commits ahead of remote OR no remote configured
|
||||
// 2. Enough messages have been sent since last interaction
|
||||
const hasUnpushedWork = gitStatus.hasUncommittedChanges || gitStatus.ahead > 0;
|
||||
const hasUnpushedWork =
|
||||
gitStatus.hasUncommittedChanges ||
|
||||
gitStatus.ahead > 0 ||
|
||||
gitStatus.remotes.length === 0;
|
||||
const enoughMessages = state.messagesSinceLastPush >= MESSAGE_THRESHOLD;
|
||||
|
||||
return hasUnpushedWork && enoughMessages;
|
||||
console.log('[PushReminder] Check:', {
|
||||
hasUnpushedWork,
|
||||
enoughMessages,
|
||||
messageCount: state.messagesSinceLastPush,
|
||||
threshold: MESSAGE_THRESHOLD,
|
||||
hasUncommittedChanges: gitStatus.hasUncommittedChanges,
|
||||
ahead: gitStatus.ahead,
|
||||
remotesCount: gitStatus.remotes.length,
|
||||
});
|
||||
|
||||
const shouldShow = hasUnpushedWork && enoughMessages;
|
||||
console.log('[PushReminder] Should show reminder:', shouldShow);
|
||||
|
||||
return shouldShow;
|
||||
}, [state, projectId, gitStatus]);
|
||||
|
||||
// Increment message counter
|
||||
const incrementMessages = useCallback(() => {
|
||||
if (!state.enabled || !projectId) return;
|
||||
if (!state.enabled || !projectId) {
|
||||
console.log('[PushReminder] Not incrementing - enabled:', state.enabled, 'projectId:', projectId);
|
||||
return;
|
||||
}
|
||||
|
||||
const newCount = state.messagesSinceLastPush + 1;
|
||||
console.log('[PushReminder] Incrementing message counter to:', newCount);
|
||||
|
||||
setState((prev) => ({
|
||||
...prev,
|
||||
messagesSinceLastPush: prev.messagesSinceLastPush + 1,
|
||||
}));
|
||||
}, [state.enabled, projectId, setState]);
|
||||
}, [state.enabled, projectId, setState, state.messagesSinceLastPush]);
|
||||
|
||||
// Reset counter (called after push or dismiss)
|
||||
const resetReminder = useCallback(() => {
|
||||
@@ -98,8 +122,8 @@ export function usePushReminder(projectId: string | null) {
|
||||
|
||||
// Check if there's unpushed work that should trigger warning icon
|
||||
const hasUnpushedWork = gitStatus?.isGitRepo && (
|
||||
gitStatus.hasUncommittedChanges ||
|
||||
gitStatus.ahead > 0 ||
|
||||
gitStatus.hasUncommittedChanges ||
|
||||
gitStatus.ahead > 0 ||
|
||||
gitStatus.remotes.length === 0
|
||||
);
|
||||
|
||||
|
||||
@@ -113,12 +113,14 @@ export function ProjectView() {
|
||||
// Handle message sent - increment push reminder counter
|
||||
const handleMessageSent = useCallback(() => {
|
||||
pushReminder.incrementMessages();
|
||||
}, [pushReminder]);
|
||||
|
||||
// Check if we should show the reminder
|
||||
if (pushReminder.shouldShowReminder) {
|
||||
// Watch for when we should show the reminder (after state updates)
|
||||
useEffect(() => {
|
||||
if (pushReminder.shouldShowReminder && !isPushReminderOpen) {
|
||||
setIsPushReminderOpen(true);
|
||||
}
|
||||
}, [pushReminder]);
|
||||
}, [pushReminder.shouldShowReminder, isPushReminderOpen]);
|
||||
|
||||
// Handle first user interaction to enable audio context
|
||||
const handleFirstInteraction = () => {
|
||||
|
||||
Reference in new issue
Block a user