Highlight new files#1610
Conversation
andyhuang91
left a comment
There was a problem hiding this comment.
I really like the idea of highlighting files that are recently modified. Having the loading icon, row highlighting, and bolding the time might be a little much. Is bolding the time necessary?
| } | ||
|
|
||
| function isRecentlyModified(mtime) { | ||
| return new Date().getTime() / 1000 - mtime <= RECENTLY_MODIFIED_SECONDS; |
There was a problem hiding this comment.
Date.now() is equivalent to new Date().getTime()
| return _.sortBy(props.files, 'isDirectory').reverse(); | ||
| } | ||
|
|
||
| function recentlyModifiedTooltip() { |
There was a problem hiding this comment.
This doesn't have to be a function. You can create it once and assign it to a variable.
const recentlyModifiedTooltip = <Tooltip />;
<OverlayTrigger overlay={recentlyModifiedTooltip} />
| <UITable | ||
| data={getFiles() || []} | ||
| keyGetter={(file) => file.name} | ||
| rowClassName={({mtime}) => { return isRecentlyModified(mtime) ? 'bg-info-light' : null; }} |
There was a problem hiding this comment.
This will only update if something else causes this component to re-render. Is this the behavior that you want?
There was a problem hiding this comment.
The app globally refreshes this data every 60 seconds, and when the window regains focus, so this shouldn't get out of sync.
| label="" | ||
| id="icon" | ||
| key="icon" | ||
| cellData={(file) => isRecentlyModified(file.mtime) && |
There was a problem hiding this comment.
Because this depends on the current time, you should evaluate this once at the beginning of the render function instead of calling it 3 times.
Users want a way to determine if a file is currently being written to, especially in cases where downloading an incomplete file such as a heap dump would be undesirable.
The task file browser will highlight files that have been modified in the last 60 seconds.