From c2202bdfef9e1bd2117bdd6f9b9793603f7c8dad Mon Sep 17 00:00:00 2001 From: PhatPhuckDave Date: Wed, 21 May 2025 11:24:07 +0200 Subject: [PATCH] Remove keyboard smashing detection logic from note saving process which I thought I already did, damn you AI --- lib/main.dart | 45 ++------------------------------------------- 1 file changed, 2 insertions(+), 43 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 29e6066..94aa687 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -575,41 +575,6 @@ class MainPageState extends State with WindowListener { debugPrint("Volume saved: $_volume"); } - // Check if content appears to be keyboard smashing or repeated characters - bool _isLikelyKeyboardSmashing(String content) { - // Skip empty content - if (content.trim().isEmpty) return false; - - // Check for repeated characters (like "wwwwwwww") - final repeatedCharPattern = RegExp( - r'(.)\1{4,}', - ); // 5 or more repeated chars - if (repeatedCharPattern.hasMatch(content)) { - // But allow if it's a legitimate pattern like base64 - if (RegExp(r'^[A-Za-z0-9+/=]+$').hasMatch(content)) return false; - return true; - } - - // Check for alternating characters (like "asdfasdf") - final alternatingPattern = RegExp(r'(.)(.)\1\2{2,}'); - if (alternatingPattern.hasMatch(content)) return true; - - // Check for common keyboard smashing patterns - final commonPatterns = [ - r'[qwerty]{5,}', // Common keyboard rows - r'[asdf]{5,}', - r'[zxcv]{5,}', - r'[1234]{5,}', - r'[wasd]{5,}', // Common gaming keys - ]; - - for (final pattern in commonPatterns) { - if (RegExp(pattern, caseSensitive: false).hasMatch(content)) return true; - } - - return false; - } - Future _saveData() async { String previousEntry = _previousEntryController.text; String currentEntry = _currentEntryController.text; @@ -619,14 +584,8 @@ class MainPageState extends State with WindowListener { // Handle current entry if (currentEntry.isNotEmpty) { - // Skip saving if it looks like keyboard smashing - if (!_isLikelyKeyboardSmashing(currentEntry)) { - await createNote(currentEntry); - _currentEntryController.clear(); // Clear the input field after saving - } else { - debugPrint("Skipping save of likely keyboard smashing: $currentEntry"); - _currentEntryController.clear(); // Still clear the input - } + await createNote(currentEntry); + _currentEntryController.clear(); // Clear the input field after saving } // Handle scratch pad