Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
597ce8c9cf | |||
c2202bdfef |
@@ -390,6 +390,7 @@ END;
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ftsQuery = ftsQuery.replaceAll('-', ' ');
|
||||||
debugPrint('FTS query: "$ftsQuery"');
|
debugPrint('FTS query: "$ftsQuery"');
|
||||||
|
|
||||||
// Execute the FTS query
|
// Execute the FTS query
|
||||||
@@ -401,7 +402,6 @@ END;
|
|||||||
JOIN notes n ON notes_fts.rowid = n.id
|
JOIN notes n ON notes_fts.rowid = n.id
|
||||||
WHERE notes_fts MATCH ?
|
WHERE notes_fts MATCH ?
|
||||||
ORDER BY rank
|
ORDER BY rank
|
||||||
LIMIT 100
|
|
||||||
''',
|
''',
|
||||||
[ftsQuery],
|
[ftsQuery],
|
||||||
);
|
);
|
||||||
|
@@ -575,41 +575,6 @@ class MainPageState extends State<MainPage> with WindowListener {
|
|||||||
debugPrint("Volume saved: $_volume");
|
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<void> _saveData() async {
|
Future<void> _saveData() async {
|
||||||
String previousEntry = _previousEntryController.text;
|
String previousEntry = _previousEntryController.text;
|
||||||
String currentEntry = _currentEntryController.text;
|
String currentEntry = _currentEntryController.text;
|
||||||
@@ -619,14 +584,8 @@ class MainPageState extends State<MainPage> with WindowListener {
|
|||||||
|
|
||||||
// Handle current entry
|
// Handle current entry
|
||||||
if (currentEntry.isNotEmpty) {
|
if (currentEntry.isNotEmpty) {
|
||||||
// Skip saving if it looks like keyboard smashing
|
|
||||||
if (!_isLikelyKeyboardSmashing(currentEntry)) {
|
|
||||||
await createNote(currentEntry);
|
await createNote(currentEntry);
|
||||||
_currentEntryController.clear(); // Clear the input field after saving
|
_currentEntryController.clear(); // Clear the input field after saving
|
||||||
} else {
|
|
||||||
debugPrint("Skipping save of likely keyboard smashing: $currentEntry");
|
|
||||||
_currentEntryController.clear(); // Still clear the input
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle scratch pad
|
// Handle scratch pad
|
||||||
|
Reference in New Issue
Block a user