Skip to content
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

Issue: Last modified sort in media library #200

Closed
zivbk1 opened this issue Dec 2, 2021 · 6 comments
Closed

Issue: Last modified sort in media library #200

zivbk1 opened this issue Dec 2, 2021 · 6 comments
Labels
bug Something isn't working
Milestone

Comments

@zivbk1
Copy link

zivbk1 commented Dec 2, 2021

Change the last modified sort option and get a different list of files each time.

See the video example here: https://youtu.be/Xp7wyLXxUXk

Expected behavior

Files should sort correctly by modified date.

Desktop (please complete the following information):

  • OS: Win 11
  • Browser: Chrome
  • Version: Version 96.0.4664.45 (Official Build) (64-bit)
@estruyf
Copy link
Owner

estruyf commented Dec 3, 2021

Interesting, this is based on the modified timestamp on each document. I'll check if I can reproduce it. Also saw a styling issue during your video, so will add that as a bug to the list.

@estruyf estruyf added the bug Something isn't working label Dec 3, 2021
estruyf added a commit that referenced this issue Dec 5, 2021
@estruyf
Copy link
Owner

estruyf commented Dec 5, 2021

A fix got implemented which sorts the files with the same modified date on file name as a secondary sorting option. I tested it in my projects, @zivbk1 can you check if the experience is better on your end as well?

@estruyf estruyf added this to the 5.7.0 milestone Dec 7, 2021
@estruyf estruyf closed this as completed Dec 7, 2021
@zivbk1
Copy link
Author

zivbk1 commented Dec 7, 2021

A fix got implemented which sorts the files with the same modified date on file name as a secondary sorting option. I tested it in my projects, @zivbk1 can you check if the experience is better on your end as well?

Sorry for not getting a chance to test it until now. I know the issue here is already closed, but I have some questions.
On my site, the filename and last modified sorts are the same now. Is there data for the files that can be used to determine the date the file was last modified or added to the repo?

@estruyf
Copy link
Owner

estruyf commented Dec 7, 2021

@zivbk1 in that case, I think it might be because of how GitPod works. Probably it checks out the project each time you load it, meaning, the modified date will be the same for all files. This would explain the behavior.

@zivbk1
Copy link
Author

zivbk1 commented Dec 7, 2021

@estruyf you are correct, all the dates in the files are at the day/time the file was cloned from the repo. To fix that I added the following commands to my GitPod.io startup tasks (for a Hugo site).

tasks:
  - name: Install Hugo and Dependencies
    before: brew install hugo && npm install && sudo apt install git-restore-mtime
    init: git restore-mtime --force && gpUrl=$(gp url 1313);jq --arg gpurl "$gpUrl" '.["frontMatter.preview.host"] = $gpurl' frontmatter.json > tmp.$$.json && mv tmp.$$.json frontmatter.json
    command: hugo server -D -F --baseUrl $(gp url 1313) --liveReloadPort=443 --appendPort=false --bind=0.0.0.0
ports:
  - port: 1313
    onOpen: open-browser

sudo apt install git-restore-mtime in the 'before' step, adds a utility to modify folder/file dates based on their last commit to the repo.

git restore-mtime --force in the 'init' step modifies all the files and folders based on commit history.

Now when the repo is cloned fresh into a new GitPod workspace, the modified date sorting works as expected.

@estruyf
Copy link
Owner

estruyf commented Dec 8, 2021

Oh, nice you found a way to overcome this @zivbk1 ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants