-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
react: enable useLinkHandle and useUnlinkHandle hooks
- Loading branch information
Showing
15 changed files
with
170 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
"@lens-protocol/api-bindings": minor | ||
"@lens-protocol/domain": minor | ||
"@lens-protocol/react": minor | ||
"@lens-protocol/react-web": minor | ||
--- | ||
|
||
Added useLinkHandle and useUnlinkHandle hooks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 55 additions & 2 deletions
57
packages/api-bindings/src/apollo/cache/type-policies/createProfileTypePolicy.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,60 @@ | ||
import { StrictTypedTypePolicies } from '../../../lens'; | ||
import { FieldFunctionOptions } from '@apollo/client'; | ||
import { ProfileId } from '@lens-protocol/domain/entities'; | ||
|
||
import { HandleInfo, StrictTypedTypePolicies } from '../../../lens'; | ||
import { getPendingLinkHandleTx, getPendingUnlinkHandleTx } from '../transactions'; | ||
|
||
function buildHandleInfo({ | ||
fullHandle, | ||
profileId, | ||
}: { | ||
fullHandle: string; | ||
profileId: ProfileId; | ||
}): HandleInfo { | ||
return { | ||
__typename: 'HandleInfo', | ||
id: '', | ||
fullHandle: fullHandle, | ||
namespace: '', | ||
localName: '', | ||
ownedBy: '', | ||
suggestedFormatted: { full: '', localName: '' }, | ||
linkedTo: { | ||
nftTokenId: profileId, | ||
contract: { | ||
__typename: 'NetworkAddress', | ||
address: '', | ||
chainId: 1, | ||
}, | ||
}, | ||
}; | ||
} | ||
|
||
export function createProfileTypePolicy(): StrictTypedTypePolicies['Profile'] { | ||
return { | ||
fields: {}, | ||
fields: { | ||
handle: { | ||
read( | ||
existing: HandleInfo | undefined, | ||
{ readField }: FieldFunctionOptions, | ||
): HandleInfo | undefined { | ||
const profileId = readField('id') as ProfileId; | ||
const pendingLinkHandleTx = getPendingLinkHandleTx(); | ||
const pendingUnLinkHandleTx = getPendingUnlinkHandleTx(); | ||
|
||
if (pendingLinkHandleTx) { | ||
return buildHandleInfo({ | ||
profileId, | ||
fullHandle: pendingLinkHandleTx.request.fullHandle, | ||
}); | ||
} | ||
if (pendingUnLinkHandleTx) { | ||
return undefined; | ||
} | ||
|
||
return existing; | ||
}, | ||
}, | ||
}, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.