-
Notifications
You must be signed in to change notification settings - Fork 10
fix(eid-wallet): show an incoming social request on the home screen, and stop × from declining it #1164
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
Merged
Merged
fix(eid-wallet): show an incoming social request on the home screen, and stop × from declining it #1164
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
f146295
fix(eid-wallet): close the social request sheet instead of declining it
Bekiboo 55d6cf6
fix(eid-wallet): surface an incoming social request on the home screen
Bekiboo 85e8282
fix(eid-wallet): address review on the incoming request prompt
Bekiboo f2e43d5
fix(eid-wallet): give the ePassport request sheet the same way out
Bekiboo 2236b55
fix(eid-wallet): let the user out of a request that will not delete
Bekiboo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
61 changes: 61 additions & 0 deletions
61
infrastructure/eid-wallet/src/lib/utils/pendingSocialRequest.ts
This file contains hidden or 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,61 @@ | ||
| import { | ||
| type BindingDocParsed, | ||
| fetchUnsignedSocialDocs, | ||
| } from "./socialBinding"; | ||
|
|
||
| /** | ||
| * Requests the user closed without answering, for this app session. Shared | ||
| * because the home screen and the ePassport sheet both prompt for the same | ||
| * documents, so closing one must not leave the other still asking. | ||
| */ | ||
| const dismissedDocIds = new Set<string>(); | ||
|
|
||
| export function dismissSocialRequest(docId: string): void { | ||
| dismissedDocIds.add(docId); | ||
| } | ||
|
|
||
| export function dismissedSocialRequests(): ReadonlySet<string> { | ||
| return dismissedDocIds; | ||
| } | ||
|
|
||
| export interface PendingSocialRequest { | ||
| docId: string; | ||
| parsed: BindingDocParsed; | ||
| signerEname: string; | ||
| } | ||
|
|
||
| /** | ||
| * The pending social connection request to prompt for next, or null. | ||
| * | ||
| * Oldest first, so a backlog is worked through in the order it arrived. | ||
| * `dismissedDocIds` holds the requests the user closed without answering; | ||
| * they stay in the vault and in the bindings list, they just don't prompt | ||
| * again. Envelopes fetchUnsignedSocialDocs hides stay hidden. | ||
| */ | ||
| export async function findPendingSocialRequest( | ||
| ownGqlUrl: string, | ||
| callerEname: string, | ||
| dismissedDocIds: ReadonlySet<string> = new Set<string>(), | ||
| ): Promise<PendingSocialRequest | null> { | ||
| const edges = await fetchUnsignedSocialDocs(ownGqlUrl, callerEname); | ||
|
|
||
| let oldest: PendingSocialRequest | null = null; | ||
| let oldestSentAt = ""; | ||
|
|
||
| for (const edge of edges) { | ||
| if (dismissedDocIds.has(edge.node.id)) continue; | ||
| const parsed = edge.node.parsed; | ||
| const signature = parsed?.signatures?.[0]; | ||
| if (!parsed || !signature?.signer) continue; | ||
| const sentAt = signature.timestamp ?? ""; | ||
| if (oldest !== null && sentAt >= oldestSentAt) continue; | ||
| oldest = { | ||
| docId: edge.node.id, | ||
| parsed, | ||
| signerEname: signature.signer, | ||
| }; | ||
| oldestSentAt = sentAt; | ||
| } | ||
|
|
||
| return oldest; | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.