-
Notifications
You must be signed in to change notification settings - Fork 909
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
Some UX improvements #2425
Merged
Merged
Some UX improvements #2425
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
42aacdc
Some UX improvements (plus .gitignore tweak)
glenn2223 9667ae2
Prettier adjustments
glenn2223 b91bda9
Revert `.gitignore` change
glenn2223 1288b31
Fix & actual prettier-ing
glenn2223 39c565f
Use localised date/time format
glenn2223 5ab358e
Use weekday(Mon-Sun), for recent emails
glenn2223 9f1a3ae
Remove unnecessary log
glenn2223 6628137
Add key to prevent console error
glenn2223 14362ed
Add a key to "more" span
bengotow File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -389,27 +389,40 @@ const DateUtils = { | |
* | ||
* The returned date/time format depends on how long ago the timestamp is. | ||
*/ | ||
shortTimeString(datetime) { | ||
shortTimeString(datetime: Date) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This all looks great, thank you for updating it to use the new browser standard APIs! |
||
const now = moment(); | ||
const diff = now.diff(datetime, 'days', true); | ||
const isSameDay = now.isSame(datetime, 'days'); | ||
let format = null; | ||
const opts: Intl.DateTimeFormatOptions = { | ||
hour12: !AppEnv.config.get('core.workspace.use24HourClock'), | ||
}; | ||
|
||
if (diff <= 1 && isSameDay) { | ||
// Time if less than 1 day old | ||
format = DateUtils.getTimeFormat(null); | ||
} else if (diff < 2 && !isSameDay) { | ||
// Month and day with time if up to 2 days ago | ||
format = `MMM D, ${DateUtils.getTimeFormat(null)}`; | ||
} else if (diff >= 2 && diff < 365) { | ||
// Month and day up to 1 year old | ||
format = 'MMM D'; | ||
opts.hour = 'numeric'; | ||
opts.minute = '2-digit'; | ||
} else if (diff < 5 && !isSameDay) { | ||
// Weekday with time if up to 2 days ago | ||
//opts.month = 'short'; | ||
//opts.day = 'numeric'; | ||
opts.weekday = 'short'; | ||
opts.hour = 'numeric'; | ||
opts.minute = '2-digit'; | ||
} else { | ||
// Month, day and year if over a year old | ||
format = 'MMM D YYYY'; | ||
if (diff < 365) { | ||
// Month and day up to 1 year old | ||
opts.month = 'short'; | ||
opts.day = 'numeric'; | ||
} else { | ||
// Month, day and year if over a year old | ||
opts.year = 'numeric'; | ||
opts.month = 'short'; | ||
opts.day = 'numeric'; | ||
} | ||
return datetime.toLocaleDateString(navigator.language, opts); | ||
} | ||
|
||
return moment(datetime).format(format); | ||
return datetime.toLocaleTimeString(navigator.language, opts); | ||
}, | ||
|
||
/** | ||
|
@@ -418,11 +431,14 @@ const DateUtils = { | |
* @param {Date} datetime - Timestamp | ||
* @return {String} Formated date/time | ||
*/ | ||
mediumTimeString(datetime) { | ||
let format = 'MMMM D, YYYY, '; | ||
format += DateUtils.getTimeFormat({ seconds: false, upperCase: true, timeZone: false }); | ||
|
||
return moment(datetime).format(format); | ||
mediumTimeString(datetime: Date) { | ||
return datetime.toLocaleTimeString(navigator.language, { | ||
hour12: !AppEnv.config.get('core.workspace.use24HourClock'), | ||
year: 'numeric', | ||
month: 'long', | ||
day: 'numeric', | ||
second: undefined, | ||
}); | ||
}, | ||
|
||
/** | ||
|
@@ -431,13 +447,20 @@ const DateUtils = { | |
* @param {Date} datetime - Timestamp | ||
* @return {String} Formated date/time | ||
*/ | ||
fullTimeString(datetime) { | ||
let format = 'dddd, MMMM Do YYYY, '; | ||
format += DateUtils.getTimeFormat({ seconds: true, upperCase: true, timeZone: true }); | ||
|
||
return moment(datetime) | ||
.tz(tz) | ||
.format(format); | ||
fullTimeString(datetime: Date) { | ||
// ISSUE: this does drop ordinal. There is this: | ||
// -> new Intl.PluralRules(LOCALE, { type: "ordinal" }).select(dateTime.getDay()) | ||
// which may work with the below regex, though localisation is required | ||
// `(?<!\d)${dateTime.getDay()}(?!\d)` replace `$1${localise(ordinal)}` | ||
|
||
return datetime.toLocaleTimeString(navigator.language, { | ||
hour12: !AppEnv.config.get('core.workspace.use24HourClock'), | ||
year: 'numeric', | ||
month: 'long', | ||
day: 'numeric', | ||
weekday: 'long', | ||
second: undefined, | ||
}); | ||
}, | ||
}; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This looks good, cool that updating the metadata actually causes it to send immediately. I'll try this a couple times once we merge just to stress test it a bit, but it seems safe to me.