-
-
Notifications
You must be signed in to change notification settings - Fork 269
Add debounce to capturing screenshots #2368
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 24 commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
77cce7c
Add debounce to `ScreenshotWidget`
denrase f540ecb
add changelog entry
denrase e5f628a
provide clock in tests
denrase 235de7b
remove unused import
denrase 09c7f91
update clock at correct line
denrase 7345987
Merge branch 'main' into feat/screenshot-debounce
denrase ba0b8e7
update cl
denrase 3d489d9
use now from clock
denrase c088da8
Merge branch 'main' into feat/screenshot-debounce
denrase 3a9d843
refactor debouncer to be similar to sentry-java impl
denrase e710098
use debouncer in screenshot_event_processor
denrase 161f182
Change beforeScreenshot to beforeCapture callback
denrase d6b74f2
update changelog entry
denrase 570b1aa
format
denrase fbea7d7
fix analyze issue
denrase ad5a9ce
feedback
denrase 57087b1
recert timer impl for widgets observer
denrase 1f5f85c
keep before screenshot callback
denrase f2950b9
Merge branch 'main' into feat/screenshot-debounce
denrase cfafff0
update cl
denrase eea29fc
update error msg
denrase 006839e
refactor
denrase 2e43ad3
add warning
denrase e96bb8d
add ignores for analyzer
denrase 5a9bcac
Merge branch 'main' into feat/screenshot-debounce
denrase f4c724d
rename callback
denrase 9fce5c0
Merge branch 'main' into feat/screenshot-debounce
denrase b157a35
rename to beforeScreenshotCapture
denrase 28b0857
Merge branch 'main' into feat/screenshot-debounce
denrase 7ce37e4
cleanup
denrase cd64cc1
fix cl
denrase d245569
move to features in cl
denrase 4d5f535
add sample to changelog
denrase File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
denrase marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,24 @@ | ||
import 'dart:async'; | ||
import 'package:flutter/foundation.dart'; | ||
import 'package:meta/meta.dart'; | ||
import 'package:sentry/sentry.dart'; | ||
|
||
@internal | ||
class Debouncer { | ||
final int milliseconds; | ||
Timer? _timer; | ||
final ClockProvider clockProvider; | ||
final int waitTimeMs; | ||
DateTime? _lastExecutionTime; | ||
|
||
Debouncer({required this.milliseconds}); | ||
Debouncer(this.clockProvider, {this.waitTimeMs = 2000}); | ||
|
||
void run(VoidCallback action) { | ||
_timer?.cancel(); | ||
_timer = Timer(Duration(milliseconds: milliseconds), action); | ||
} | ||
bool shouldDebounce() { | ||
final currentTime = clockProvider(); | ||
final lastExecutionTime = _lastExecutionTime; | ||
_lastExecutionTime = currentTime; | ||
|
||
if (lastExecutionTime != null && | ||
currentTime.difference(lastExecutionTime).inMilliseconds < waitTimeMs) { | ||
return true; | ||
} | ||
|
||
void dispose() { | ||
_timer?.cancel(); | ||
return false; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import 'dart:async'; | ||
import 'package:flutter/foundation.dart'; | ||
import 'package:meta/meta.dart'; | ||
|
||
@internal | ||
class TimerDebouncer { | ||
final int milliseconds; | ||
Timer? _timer; | ||
|
||
TimerDebouncer({required this.milliseconds}); | ||
|
||
void run(VoidCallback action) { | ||
_timer?.cancel(); | ||
_timer = Timer(Duration(milliseconds: milliseconds), action); | ||
} | ||
|
||
void dispose() { | ||
_timer?.cancel(); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.