-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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
feat: add width, height, crop and mode to BeforePreviewFetchedEvent #38679
Conversation
private int $width, | ||
private int $height) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The two new required constructor arguments form a breaking change for apps creating an instance, e.g. to dispatch their own event.
Can we assume that apps don't do that? Then the change could be ok.
Otherwise I would prefer to make the two new properties optional and nullable, document that in three versions (nextcloud 31) the arguments are required and only then make them non-null.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we assume that apps don't do that? Then the change could be ok.
I assume that ;)
Would you mind adding more details while we're at it? What I added in #37193 for admin_audit ( |
a91d343
to
137a4e8
Compare
@tcitworld added crop and mode. |
6a0311b
to
aaf6a3e
Compare
aaf6a3e
to
bf2346a
Compare
Added defaults for width, height, crop and mode to keep the public api stable. |
bf2346a
to
4f0e351
Compare
public function __construct( | ||
private Node $node, | ||
/** @deprecated 28.0.0 default value is deprecated **/ | ||
private int $width = 0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if it's better to have wrong data (0x0px image) or null values when the emitter doesn't pass values
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True True
4f0e351
to
adaf879
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Psalm sugar
/** | ||
* @since 28.0.0 | ||
*/ | ||
public function getMode(): ?string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/** | |
* @since 28.0.0 | |
*/ | |
public function getMode(): ?string { | |
/** | |
* @since 28.0.0 | |
* @return null|IPreview::MODE_* | |
*/ | |
public function getMode(): ?string { |
@@ -32,14 +32,21 @@ | |||
* @since 25.0.1 | |||
*/ | |||
class BeforePreviewFetchedEvent extends \OCP\EventDispatcher\Event { | |||
private Node $node; | |||
|
|||
/** | |||
* @since 25.0.1 | |||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
*/ | |
* @param string|IPreview::MODE_* | |
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea
user_usage_report keeps a counter for files read. The app uses - OC_Filesystem::read hook - Event listener (the legacy one) for IPreview::EVENT Request for previews do not trigger the hook, hence the additional event listener. The thumbnails for a list or grid view should not count, so we need the width and height. Signed-off-by: Daniel Kesselberg <[email protected]>
adaf879
to
440f882
Compare
Documentation: nextcloud/documentation#10674 |
Summary
user_usage_report keeps a counter for files read.1
The app uses
Request for previews do not trigger the hook, hence the additional event listener.
The thumbnails for a list or grid view should not count, so we need the width and height.
TODO
Checklist
Footnotes
https://github.com/nextcloud/user_usage_report/blob/c12e97d84033818af27ae5cf659c88f743137be7/lib/AppInfo/Application.php#L51 ↩