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

fix: links without paths can be navigated #462

Merged
merged 3 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/object-info/links-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const Row: React.FC<RowProps> = ({ onLinkClick, startIndex, index, rowHeight, li
key={key}
className={`pv2 pointer items-center f7 ${styles.rowGrid} bb b--near-white`}
style={{ position: 'absolute', top: key * rowHeight, width: '100%', backgroundColor }}
onClick={() => { onLinkClick(link as any) }}
onClick={() => { onLinkClick(link) }}
>
<div className={`mid-gray tr pr1 f7 ${styles.gridCellRow} monospace}`}>
{key}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export function isFalsy <T> (str: T | null | string | undefined): str is null {
return false
}

export function isTruthy <T> (str: T | null | string | undefined): boolean {
export function isTruthy <T> (str: T | null | string | undefined): str is string {
return !isFalsy(str)
}

Expand Down
2 changes: 1 addition & 1 deletion src/lib/normalise-dag-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export function normaliseDagPb (node: PBNode, cid: string, type: CodecType): Nor
*/
export function normaliseDagPbLinks (links: PBLink[], sourceCid: string): NormalizedDagLink[] {
return links.map((link, index) => ({
path: link.Name ?? `Links/${index}`,
path: isTruthy(link.Name) ? link.Name : `Links/${index}`,
source: sourceCid,
target: toCidStrOrNull(link.Hash) ?? '',
size: BigInt(link.Tsize ?? 0),
Expand Down
1 change: 0 additions & 1 deletion src/lib/resolve-ipld-path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ export async function ipldGetNodeAndRemainder (helia: Helia, sourceCid: CID | st
const encodedValue = await getRawBlock(helia, cidInstance)
const value = codecWrapper.decode(encodedValue)

// @ts-expect-error - limiting code changes, ignore this error
const codecWrapperResolveResult = await codecWrapper.resolve(isTruthy(path) ? path : '/', encodedValue)
// TODO: there was a type error previously uncaught
const resolveValue: any = {}
Expand Down
Loading