Version 0.9.1-2: Critical fixes for pause button and Electron update

Major Fixes:
1. FIXED: Pause button visibility logic completely rewritten
   - Pause button now properly hidden on duration=0 sites
   - Shows ONLY on user interaction (mousedown/touchstart/keydown)
   - Main process sends pause-button-visibility on tab switch
   - Preload receives visibility state and enforces it
   - Button hidden immediately when switching to manual sites

2. FIXED: Pause dialog window conflict resolved
   - Created separate pauseWindow variable (was reusing promptWindow)
   - Pause dialog no longer disappears immediately
   - Prevents conflicts with inactivity prompt window
   - Each dialog has its own window lifecycle

3. FIXED: Mixed header characters now uniform
   - All =--- and =-- patterns replaced with ---
   - Consistent use of dashes throughout script
   - Better terminal display compatibility

4. FIXED: Manual Electron update detection improved
   - Three-method detection strategy:
     * Method 1: Check /home/kiosk/kiosk-app
     * Method 2: Search all /home/*/kiosk-app with main.js verification
     * Method 3: Check current directory for kiosk-app
   - Added debug output showing search paths and current context
   - More robust detection across different installation scenarios

Implementation Details:
- pauseButtonShouldShow tracks if button is allowed on current site
- pauseButtonShown tracks if button is currently displayed
- User interaction only shows button if pauseButtonShouldShow is true
- attachView() sends visibility message on every tab switch
- Throttled user interaction handling (100ms) prevents spam
This commit is contained in:
Claude
2025-11-18 17:22:28 +00:00
parent f65e99c8fb
commit 1521b7e54f
+63 -59
View File
@@ -473,7 +473,7 @@ show_system_status() {
} }
show_addon_status() { show_addon_status() {
echo " =-- INSTALLED ADDONS --=" echo " --- INSTALLED ADDONS ---"
echo echo
local any_addon=false local any_addon=false
@@ -3321,7 +3321,7 @@ const CONFIG_FILE=path.join(__dirname,'config.json');
const VERSION='0.9.1-2'; const VERSION='0.9.1-2';
let mainWindow,views=[],hiddenViews=[],tabs=[],currentIndex=0,showingHidden=false; let mainWindow,views=[],hiddenViews=[],tabs=[],currentIndex=0,showingHidden=false;
let pinWindow=null,promptWindow=null,htmlKeyboardWindow=null; let pinWindow=null,promptWindow=null,pauseWindow=null,htmlKeyboardWindow=null;
let tabIndexToViewIndex=[]; let tabIndexToViewIndex=[];
let currentHiddenIndex=0; let currentHiddenIndex=0;
@@ -3544,10 +3544,10 @@ function startMasterTimer(){
clearInterval(masterTimer); clearInterval(masterTimer);
} }
console.log('[TIMER] =--- MASTER TIMER STARTED ---=='); console.log('[TIMER] --- MASTER TIMER STARTED ---');
console.log('[TIMER] Home tab index:',homeTabIndex); console.log('[TIMER] Home tab index:',homeTabIndex);
console.log('[TIMER] Inactivity timeout:',inactivityTimeout/1000,'seconds'); console.log('[TIMER] Inactivity timeout:',inactivityTimeout/1000,'seconds');
console.log('[TIMER] =-----------------------------------='); console.log('[TIMER] -----------------------------------');
siteStartTime=Date.now(); siteStartTime=Date.now();
lastUserInteraction=Date.now(); lastUserInteraction=Date.now();
@@ -3849,9 +3849,9 @@ function showInactivityPrompt(){
} }
function showPauseDialog(){ function showPauseDialog(){
if(promptWindow&&!promptWindow.isDestroyed())return; if(pauseWindow&&!pauseWindow.isDestroyed())return;
promptWindow=new BrowserWindow({ pauseWindow=new BrowserWindow({
width:800, width:800,
height:600, height:600,
frame:false, frame:false,
@@ -3861,17 +3861,17 @@ function showPauseDialog(){
webPreferences:{nodeIntegration:true,contextIsolation:false} webPreferences:{nodeIntegration:true,contextIsolation:false}
}); });
promptWindow.loadFile(path.join(__dirname,'pause-dialog.html')); pauseWindow.loadFile(path.join(__dirname,'pause-dialog.html'));
promptWindow.on('closed',()=>{ pauseWindow.on('closed',()=>{
promptWindow=null; pauseWindow=null;
}); });
ipcMain.once('pause-time-selected',(event,minutes)=>{ ipcMain.once('pause-time-selected',(event,minutes)=>{
if(promptWindow&&!promptWindow.isDestroyed()){ if(pauseWindow&&!pauseWindow.isDestroyed()){
promptWindow.close(); pauseWindow.close();
} }
promptWindow=null; pauseWindow=null;
if(minutes===0){ if(minutes===0){
// Cancel - do nothing // Cancel - do nothing
@@ -4233,27 +4233,6 @@ function createWindow(){
ipcMain.on('keyboard-activity',()=>{markKeyboardActivity();}); ipcMain.on('keyboard-activity',()=>{markKeyboardActivity();});
ipcMain.on('show-pause-dialog',()=>{showPauseDialog();}); ipcMain.on('show-pause-dialog',()=>{showPauseDialog();});
// Handle pause button visibility request
ipcMain.on('request-pause-button-visibility',()=>{
const currentTabIdx=viewIndexToTabIndex(currentIndex);
let shouldShow=true;
if(currentTabIdx>=0&&tabs[currentTabIdx]){
const siteDuration=parseInt(tabs[currentTabIdx].duration)||0;
// Hide pause button on manual sites (duration=0)
if(siteDuration===0){
shouldShow=false;
}
}
// Send visibility state to all views
views.forEach(v=>{
if(v&&v.webContents){
v.webContents.send('pause-button-visibility',shouldShow);
}
});
});
ipcMain.on('keyboard-type',(event,key)=>{ ipcMain.on('keyboard-type',(event,key)=>{
markKeyboardActivity(); markKeyboardActivity();
@@ -5159,7 +5138,8 @@ window.addEventListener('DOMContentLoaded',()=>{
// Pause button functionality // Pause button functionality
let pauseButton=null; let pauseButton=null;
let pauseButtonVisible=false; let pauseButtonShouldShow=false;
let pauseButtonShown=false;
function createPauseButton(){ function createPauseButton(){
if(pauseButton)return; if(pauseButton)return;
@@ -5188,43 +5168,46 @@ window.addEventListener('DOMContentLoaded',()=>{
function showPauseButton(){ function showPauseButton(){
if(!pauseButton)createPauseButton(); if(!pauseButton)createPauseButton();
pauseButton.style.display='flex'; pauseButton.style.display='flex';
pauseButtonVisible=true; pauseButtonShown=true;
} }
function hidePauseButton(){ function hidePauseButton(){
if(pauseButton){ if(pauseButton){
pauseButton.style.display='none'; pauseButton.style.display='none';
pauseButtonVisible=false; pauseButtonShown=false;
} }
} }
// Listen for pause button visibility control from main process // Listen for pause button visibility control from main process
ipcRenderer.on('pause-button-visibility',(event,visible)=>{ // Main process controls whether button should be available on this site
if(visible){ ipcRenderer.on('pause-button-visibility',(event,shouldShow)=>{
showPauseButton(); pauseButtonShouldShow=shouldShow;
}else{ if(!shouldShow){
// If button should not show on this site, hide it immediately
hidePauseButton(); hidePauseButton();
} }
// If shouldShow is true, button will appear on user interaction
}); });
// Show pause button on user interaction (but not on manual sites) // Show pause button on user interaction (only if allowed on this site)
let lastPauseButtonCheck=0; let lastUserInteraction=0;
const PAUSE_BUTTON_THROTTLE=5000; const USER_INTERACTION_THROTTLE=100;
function checkAndShowPauseButton(){ function handleUserInteraction(){
const now=Date.now(); const now=Date.now();
if(now-lastPauseButtonCheck>PAUSE_BUTTON_THROTTLE){ if(now-lastUserInteraction<USER_INTERACTION_THROTTLE)return;
lastPauseButtonCheck=now; lastUserInteraction=now;
ipcRenderer.send('request-pause-button-visibility');
// Only show if this site allows pause button and it's not already shown
if(pauseButtonShouldShow&&!pauseButtonShown){
showPauseButton();
} }
} }
// Show pause button on any user interaction // Show pause button on any user interaction
const pauseButtonTriggers=['mousedown','touchstart','keydown']; const pauseButtonTriggers=['mousedown','touchstart','keydown'];
pauseButtonTriggers.forEach(eventType=>{ pauseButtonTriggers.forEach(eventType=>{
document.addEventListener(eventType,()=>{ document.addEventListener(eventType,handleUserInteraction,{passive:true,capture:true});
checkAndShowPauseButton();
},{passive:true,capture:true});
}); });
function isTextInput(el){ function isTextInput(el){
@@ -8266,14 +8249,21 @@ manual_electron_update() {
local DETECTED_KIOSK_USER="" local DETECTED_KIOSK_USER=""
local DETECTED_KIOSK_DIR="" local DETECTED_KIOSK_DIR=""
# Check if kiosk user exists echo "Searching for kiosk installation..."
if id "$KIOSK_USER" &>/dev/null 2>&1; then
DETECTED_KIOSK_USER="$KIOSK_USER" # Method 1: Check if default kiosk user exists and has kiosk-app
DETECTED_KIOSK_DIR="$(eval echo ~$KIOSK_USER)/kiosk-app" if id "$KIOSK_USER" &>/dev/null; then
else local kiosk_home=$(eval echo ~$KIOSK_USER)
# Try to find any user with kiosk-app directory if [ -d "$kiosk_home/kiosk-app" ]; then
DETECTED_KIOSK_USER="$KIOSK_USER"
DETECTED_KIOSK_DIR="$kiosk_home/kiosk-app"
fi
fi
# Method 2: Search all /home directories for kiosk-app
if [ -z "$DETECTED_KIOSK_DIR" ]; then
for user_home in /home/*; do for user_home in /home/*; do
if [ -d "$user_home/kiosk-app" ]; then if [ -d "$user_home/kiosk-app" ] && [ -f "$user_home/kiosk-app/main.js" ]; then
DETECTED_KIOSK_USER=$(basename "$user_home") DETECTED_KIOSK_USER=$(basename "$user_home")
DETECTED_KIOSK_DIR="$user_home/kiosk-app" DETECTED_KIOSK_DIR="$user_home/kiosk-app"
break break
@@ -8281,6 +8271,14 @@ manual_electron_update() {
done done
fi fi
# Method 3: Check current directory
if [ -z "$DETECTED_KIOSK_DIR" ]; then
if [ -f "$PWD/kiosk-app/main.js" ]; then
DETECTED_KIOSK_USER=$(whoami)
DETECTED_KIOSK_DIR="$PWD/kiosk-app"
fi
fi
# Check if we found a kiosk installation # Check if we found a kiosk installation
if [ -z "$DETECTED_KIOSK_DIR" ] || [ ! -d "$DETECTED_KIOSK_DIR" ]; then if [ -z "$DETECTED_KIOSK_DIR" ] || [ ! -d "$DETECTED_KIOSK_DIR" ]; then
echo "✗ Kiosk installation not found!" echo "✗ Kiosk installation not found!"
@@ -8288,6 +8286,12 @@ manual_electron_update() {
echo "Searched locations:" echo "Searched locations:"
echo " - /home/$KIOSK_USER/kiosk-app" echo " - /home/$KIOSK_USER/kiosk-app"
echo " - /home/*/kiosk-app" echo " - /home/*/kiosk-app"
echo " - $PWD/kiosk-app"
echo ""
echo "Debug info:"
echo " Current user: $(whoami)"
echo " Current directory: $PWD"
echo " Kiosk user exists: $(id "$KIOSK_USER" &>/dev/null && echo 'yes' || echo 'no')"
echo "" echo ""
echo "Please install the kiosk first (Main Menu > Install Kiosk)" echo "Please install the kiosk first (Main Menu > Install Kiosk)"
pause pause
@@ -8616,7 +8620,7 @@ core_menu() {
clear clear
echo "------------------------------------------------------------" echo "------------------------------------------------------------"
echo " CORE SETTINGS " echo " CORE SETTINGS "
echo "=------------------------------------------------------------=" echo "------------------------------------------------------------"
echo echo
show_current_config show_current_config
echo echo
@@ -8829,7 +8833,7 @@ audio_diagnostics() {
fix_squeezelite_audio() { fix_squeezelite_audio() {
clear clear
echo "=-- FIX SQUEEZELITE AUDIO --=" echo "--- FIX SQUEEZELITE AUDIO ---"
echo echo
echo "This will attempt to fix Squeezelite audio issues by:" echo "This will attempt to fix Squeezelite audio issues by:"