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

Update relative timestamps for a better "live" feeling #1215

Merged
merged 4 commits into from
Sep 1, 2016

Conversation

nickvergessen
Copy link
Member

Fix #1083

Steps to reproduce

  1. Create a new folder
  2. See in the Modified column seconds ago
  3. Go away for sometime and leave the browser open

Expected behaviour

See in the Modified column X minutes ago

Actual behaviour

See in the Modified column seconds ago

Usage in other apps

I made the thing very general, so apps can use it aswell. Requirements:

  • Object has class live-relative-timestamp
  • Milliseconds timestamp is in attribute data-timestamp
  • Then the text() of the object is updated every 30 seconds.

Testing helper

For faster time updating on testing, you can apply the following patch:

diff --git a/core/js/js.js b/core/js/js.js
index f5f427f..c6cda3d 100644
--- a/core/js/js.js
+++ b/core/js/js.js
@@ -1664,9 +1664,9 @@ function initCore() {
        // Update live timestamps every 30 seconds
        setInterval(function() {
                $('.live-relative-timestamp').each(function() {
-                       $(this).text(OC.Util.relativeModifiedDate(parseInt($(this).attr('data-timestamp'), 10)));
+                       $(this).text(OC.Util.relativeModifiedDate(parseInt($(this).attr('data-timestamp'), 10) - 3600000));
                });
-       }, 30 * 1000)
+       }, 5 * 1000)
 }

 $(document).ready(initCore);

Then timestamps get 1 hour older after 5 seconds.

@jancborchardt @MorrisJobke @rullzer @ChristophWurst

@nickvergessen
Copy link
Member Author

Other sample from activity nextcloud/activity#38

$('.live-relative-timestamp').each(function() {
$(this).text(OC.Util.relativeModifiedDate(parseInt($(this).attr('data-timestamp'), 10)));
});
}, 30 * 1000)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be a semicolon.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@MorrisJobke
Copy link
Member

Tested and works 👍

@nickvergessen nickvergessen force-pushed the issue-1083-update-live-relative-timestamps branch from 15b48c4 to 80e8d3d Compare September 1, 2016 07:02
@rullzer
Copy link
Member

rullzer commented Sep 1, 2016

Very awesome stuff! Works like a charm here!
LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review Waiting for reviews enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants