Skip to content

Conversation

@Turbo87
Copy link
Member

@Turbo87 Turbo87 commented Jan 20, 2026

This resolves the two "load owners" TODO comments. The owners list is loaded in routes/crates/[crate_id]/+layout.ts? so that it can be shared with all subpages. This will allow the crate header to only show the "Settings" tab if the authenticated user (still TODO) is part of the owners list, similar to the Ember.js app.

Related

@Turbo87 Turbo87 requested a review from a team January 20, 2026 12:27
@Turbo87 Turbo87 force-pushed the svelte-load-owners branch from 12c8c8b to 8d25d04 Compare January 20, 2026 12:28
crate: Crate;
version: Version;
keywords?: Keyword[];
owners?: Owner[];
Copy link
Member

Choose a reason for hiding this comment

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

I'm quite curious: why does owners need to be optional? Is it for the loading stage? I don't think crates can be without owners, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

good point. there is no reason to make it optional since both usages of the component supply the prop. I've changed it to non-optional. 👍

Copy link
Member

@JayanAXHF JayanAXHF Jan 20, 2026

Choose a reason for hiding this comment

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

Alright, wonderful. Would the same apply to the requestedVersion prop as well?

Copy link
Member Author

Choose a reason for hiding this comment

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

Would the same apply to the requestedVersion prop as well?

nope, because that one isn't used by https://github.com/rust-lang/crates.io/blob/main/svelte/src/routes/crates/%5Bcrate_id%5D/%2Bpage.svelte#L11-L17, only by the route that includes the version number.

Copy link
Contributor

@eth3lbert eth3lbert Jan 21, 2026

Choose a reason for hiding this comment

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

This change would force us to load it before rendering the page. However, we could potentially treat it as a loading state when the owners list is empty.

@Turbo87 Turbo87 force-pushed the svelte-load-owners branch 3 times, most recently from c9bce48 to dfb216f Compare January 21, 2026 13:12
let crateName = params.crate_id;

let { crate, categories, keywords, defaultVersion } = await loadCrate(client, crateName);
let [crateData, owners] = await Promise.all([loadCrate(client, crateName), loadOwners(client, crateName)]);
Copy link
Contributor

Choose a reason for hiding this comment

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

Not a blocker: I guess this makes the behavior slightly different from the Ember version, as we now need to wait for owners to load before we can render the page. However, I think it's fine to merge this if you want to migrate first and retrofit it later.

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah, that was a deliberate decision. we don't have any kind of loading state for the owners list, so it felt a bit strange to load that data async. do you think we should return ownersPromise instead?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, I think using an ownerPromise or an empty list as a loading state would be better(if we want to avoid blocking).

Copy link
Member Author

Choose a reason for hiding this comment

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

I've added a second commit that implements this. is this what you had in mind?

@Turbo87 Turbo87 force-pushed the svelte-load-owners branch from dfb216f to b9f0b38 Compare January 22, 2026 06:03
@Turbo87 Turbo87 force-pushed the svelte-load-owners branch from b9f0b38 to cfb4ebe Compare January 22, 2026 06:05
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.

4 participants