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

feat!: Add more helpful descriptions to recommended files #849

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Pytal
Copy link
Member

@Pytal Pytal commented Feb 27, 2025

Close #841

image

Signed-off-by: Christopher Ng <chrng8@gmail.com>
Signed-off-by: Christopher Ng <chrng8@gmail.com>
@Pytal Pytal added enhancement New feature or request 3. to review design labels Feb 27, 2025
@Pytal Pytal added this to the Nextcloud 32 milestone Feb 27, 2025
@Pytal Pytal self-assigned this Feb 27, 2025
@@ -78,6 +79,21 @@ export default {
type: Boolean,
default: false,
},
timestamp: {
type: Number,
default: null,
Copy link
Contributor

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.

Suggested change
default: null,
required: true,

Comment on lines +118 to +127
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
Copy link
Contributor

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.

Comment on lines +87 to +96
setup(props) {
if (!props.timestamp) {
return
}
const { formattedTime } = useFormatDateTime(props.timestamp * 1000, {
ignoreSeconds: true,
})
return {
formattedTime,
}
Copy link
Contributor

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:

Suggested change
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,
}

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

Successfully merging this pull request may close these issues.

Show timestamps for recommended files
2 participants