Skip to content

Commit 1effbe7

Browse files
authored
fix: links without paths can be navigated (#462)
* chore: remove unnecessary any cast * chore: fix return type on isTruthy * fix: links without paths can be navigated Fixes #461
1 parent b37f7c0 commit 1effbe7

File tree

4 files changed

+3
-4
lines changed

4 files changed

+3
-4
lines changed

src/components/object-info/links-table.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ const Row: React.FC<RowProps> = ({ onLinkClick, startIndex, index, rowHeight, li
5454
key={key}
5555
className={`pv2 pointer items-center f7 ${styles.rowGrid} bb b--near-white`}
5656
style={{ position: 'absolute', top: key * rowHeight, width: '100%', backgroundColor }}
57-
onClick={() => { onLinkClick(link as any) }}
57+
onClick={() => { onLinkClick(link) }}
5858
>
5959
<div className={`mid-gray tr pr1 f7 ${styles.gridCellRow} monospace}`}>
6060
{key}

src/lib/helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export function isFalsy <T> (str: T | null | string | undefined): str is null {
1919
return false
2020
}
2121

22-
export function isTruthy <T> (str: T | null | string | undefined): boolean {
22+
export function isTruthy <T> (str: T | null | string | undefined): str is string {
2323
return !isFalsy(str)
2424
}
2525

src/lib/normalise-dag-node.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export function normaliseDagPb (node: PBNode, cid: string, type: CodecType): Nor
9393
*/
9494
export function normaliseDagPbLinks (links: PBLink[], sourceCid: string): NormalizedDagLink[] {
9595
return links.map((link, index) => ({
96-
path: link.Name ?? `Links/${index}`,
96+
path: isTruthy(link.Name) ? link.Name : `Links/${index}`,
9797
source: sourceCid,
9898
target: toCidStrOrNull(link.Hash) ?? '',
9999
size: BigInt(link.Tsize ?? 0),

src/lib/resolve-ipld-path.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ export async function ipldGetNodeAndRemainder (helia: Helia, sourceCid: CID | st
9797
const encodedValue = await getRawBlock(helia, cidInstance)
9898
const value = codecWrapper.decode(encodedValue)
9999

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

0 commit comments

Comments
 (0)