X Tutup
Skip to content

fix: file list visual fixes on expirations date and decuplicate elements on shared files#41056

Merged
DeepDiver1975 merged 5 commits intomasterfrom
filelist-visual-fixes
Nov 22, 2023
Merged

fix: file list visual fixes on expirations date and decuplicate elements on shared files#41056
DeepDiver1975 merged 5 commits intomasterfrom
filelist-visual-fixes

Conversation

@steelcuts
Copy link
Contributor

Description

This PR fixes 2 issues:

  1. Duplicate file elements in shared file list caused by an event not beeing cleared
  2. Weird expiration date

Related Issue

#41055

Motivation and Context

Visual issues that could be missleading

How Has This Been Tested?

Not extensively tested, only with Brave and Chrome on oC 10.13.2.

Screenshots (if appropriate):

Issue:
Bildschirmaufnahme-2023-10-20-um-18 13 44

Fixed:
Bildschirmaufnahme-2023-10-20-um-18 33 34

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Database schema changes (next release will require increase of minor version instead of patch)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Technical debt
  • Tests only (no source changes)

Checklist:

  • Code changes
  • Unit tests added
  • Acceptance tests added
  • Documentation ticket raised:
  • Changelog item, see TEMPLATE

@update-docs
Copy link

update-docs bot commented Oct 20, 2023

Thanks for opening this pull request! The maintainers of this repository would appreciate it if you would create a changelog item based on your changes.

@jvillafanez
Copy link
Member

Any side effect? I mean, removing ALL "click" events from the filelist might cause issues

@steelcuts
Copy link
Contributor Author

Any side effect? I mean, removing ALL "click" events from the filelist might cause issues

There shouldn't be any side effects. From what I gather, the code is designed to attach the relevant events each time the file list gets initialized.

@steelcuts
Copy link
Contributor Author

CI now approves of my changes, but I noticed that there may still be an issue deeper within the code.

Here's the specific line in the code:

if(fileData.shares && fileData.shares[0].expiration !== null && fileData.shares[0].expiration !== 0) {

The first time _createRow() is called, fileData.shares[0].expiration is null as expected from /ocs/v1.php/apps/files_sharing/api/v1/shares. However, after clicking the element (and subsequently calling the _createRow() again), fileData.shares[0].expiration is an integer 0. I can look into this when i have more time, but maybe this is not even an issue at all?

@jvillafanez
Copy link
Member

I think we should look into it, at least to know why that change happens (maybe it makes sense, or maybe we can't do anything about it)
I'm ok if we want to merge in order to release this fix "soon" because I don't expect any additional bug, but I'd rather fix the real issue (if there is an issue) than putting a band-aid because there could be other related bugs.

@steelcuts
Copy link
Contributor Author

steelcuts commented Oct 25, 2023

I've identified the reason behind it returning a value of 0 instead of null after clicking. When you click the element, it fetches the attributes from the model, which, in turn, retrieves the data from the jQuery object: https://github.com/owncloud/core/blob/b451ac539617129632f262cabc61e84a0ec8e579/apps/files/js/filelist.js#L448C3-L457

The reason you get the integer 0 is because of these specific lines in the code:

var expirationTimestamp = 0;
if(fileData.shares && fileData.shares[0].expiration !== null && fileData.shares[0].expiration !== 0) {
expirationTimestamp = moment(fileData.shares[0].expiration).endOf('day').valueOf();
}
$tr.attr('data-expiration', expirationTimestamp);
Here, "data-expiration" is intentionally set to 0 if there wasn't an expiration previously defined. As a result, it is retrieved as 0, which is in line with the intended functionality and should not lead to any issues.

@jvillafanez
Copy link
Member

I'd need to check the documentation... If the API is documented to return null if no expiration is set (which makes sense), and then the web UI converts the value to 0 for its own purposes, I think it's ok, but there should be a comment explaining why this is needed. The obvious alternative would be to handle the null value differently, which I think it's the natural thought.

I'd write a comment with a brief explanation, at least to know that we need to handle those 2 values.

DeepDiver1975
DeepDiver1975 previously approved these changes Oct 27, 2023
@DeepDiver1975 DeepDiver1975 dismissed their stale review October 27, 2023 07:22

Changelog is missing

@DeepDiver1975
Copy link
Member

file changelog/unreleased/41056: title is too long (max 80 characters) 🤷 @steelcuts

This ensures that older events won't be triggered, preventing the file list from having duplicate entries.
The null check failed, which resulted in unexpected timestamps.
I applied the wrong logic in my first commit.
@DeepDiver1975 DeepDiver1975 changed the title Filelist visual fixes fix: file list visual fixes on expirations date and decuplicate elements on shared files Nov 16, 2023
@DeepDiver1975
Copy link
Member

@steelcuts I took the freedom to finalize this pr

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@DeepDiver1975 DeepDiver1975 merged commit 1d57f47 into master Nov 22, 2023
@delete-merged-branch delete-merged-branch bot deleted the filelist-visual-fixes branch November 22, 2023 09:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

X Tutup