-
Notifications
You must be signed in to change notification settings - Fork 17
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
feat!: Add more helpful descriptions to recommended files #849
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: Christopher Ng <chrng8@gmail.com>
Signed-off-by: Christopher Ng <chrng8@gmail.com>
@@ -78,6 +79,21 @@ export default { | |||
type: Boolean, | |||
default: false, | |||
}, | |||
timestamp: { | |||
type: Number, | |||
default: null, |
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.
Can this ever be null? If not its easier to require it.
default: null, | |
required: true, |
if (this.reason === 'recently-edited') { | ||
return t('recommendations', 'Last updated {timeAgo}', { timeAgo: this.formattedTime }) | ||
} | ||
if (this.reason === 'recently-shared') { | ||
return t('recommendations', 'Shared with you {timeAgo}', { timeAgo: this.formattedTime }) | ||
} | ||
if (this.reason === 'recently-commented') { | ||
return t('recommendations', 'Last commented on {timeAgo}', { timeAgo: this.formattedTime }) | ||
} | ||
return null |
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.
So timestamp must be available as a prop as otherwise this will fail if timestamp is null but reason is one of those.
setup(props) { | ||
if (!props.timestamp) { | ||
return | ||
} | ||
const { formattedTime } = useFormatDateTime(props.timestamp * 1000, { | ||
ignoreSeconds: true, | ||
}) | ||
return { | ||
formattedTime, | ||
} |
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 is not how setup context work. Setup is executed once before the mount / after creation of the component. So if the props are changed you do not get the formatted time.
So if timestamp is required it should look like:
setup(props) { | |
if (!props.timestamp) { | |
return | |
} | |
const { formattedTime } = useFormatDateTime(props.timestamp * 1000, { | |
ignoreSeconds: true, | |
}) | |
return { | |
formattedTime, | |
} | |
setup(props) { | |
const { formattedTime } = useFormatDateTime(computed(() => props.timestamp * 1000), { | |
ignoreSeconds: true, | |
}) | |
return { | |
formattedTime, | |
} |
Close #841