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: refresh profile following after a follow or unfollow #938

Merged
merged 1 commit into from
May 14, 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
7 changes: 7 additions & 0 deletions .changeset/grumpy-bottles-relate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@lens-protocol/react": patch
"@lens-protocol/react-native": patch
"@lens-protocol/react-web": patch
---

**fix:** refresh profile following after a follow or unfollow
7 changes: 5 additions & 2 deletions packages/react/src/shared.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,14 @@ export function createSharedDependencies(userConfig: BaseConfig): SharedDependen
[TransactionKind.CREATE_POST]: new RefreshCurrentProfileResponder(profileCacheManager),
[TransactionKind.CREATE_PROFILE]: new CreateProfileResponder(apolloClient),
[TransactionKind.CREATE_QUOTE]: new RefreshCurrentProfileResponder(profileCacheManager),
[TransactionKind.FOLLOW_PROFILE]: new FollowProfileResponder(profileCacheManager),
[TransactionKind.FOLLOW_PROFILE]: new FollowProfileResponder(apolloClient, profileCacheManager),
[TransactionKind.LINK_HANDLE]: new LinkHandleResponder(apolloClient, profileCacheManager),
[TransactionKind.MIRROR_PUBLICATION]: new RefreshCurrentProfileResponder(profileCacheManager),
[TransactionKind.UNBLOCK_PROFILE]: new UnblockProfilesResponder(profileCacheManager),
[TransactionKind.UNFOLLOW_PROFILE]: new UnfollowProfileResponder(profileCacheManager),
[TransactionKind.UNFOLLOW_PROFILE]: new UnfollowProfileResponder(
apolloClient,
profileCacheManager,
),
[TransactionKind.UNLINK_HANDLE]: new LinkHandleResponder(apolloClient, profileCacheManager),
[TransactionKind.UPDATE_FOLLOW_POLICY]: new RefreshCurrentProfileResponder(profileCacheManager),
[TransactionKind.UPDATE_PROFILE_DETAILS]: new RefreshCurrentProfileResponder(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { FollowingDocument, SafeApolloClient } from '@lens-protocol/api-bindings';
import { FollowRequest } from '@lens-protocol/domain/use-cases/profile';
import {
ITransactionResponder,
Expand All @@ -7,9 +8,17 @@ import {
import { IProfileCacheManager } from '../../../profile/adapters/IProfileCacheManager';

export class FollowProfileResponder implements ITransactionResponder<FollowRequest> {
constructor(private readonly profileCacheManager: IProfileCacheManager) {}
constructor(
private readonly apolloClient: SafeApolloClient,
private readonly profileCacheManager: IProfileCacheManager,
) {}

async commit({ request }: TransactionData<FollowRequest>) {
await this.profileCacheManager.fetchProfileById(request.profileId);
await Promise.all([
this.profileCacheManager.fetchProfileById(request.profileId),
this.apolloClient.refetchQueries({
include: [FollowingDocument],
}),
]);
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { FollowingDocument, SafeApolloClient } from '@lens-protocol/api-bindings';
import { UnfollowRequest } from '@lens-protocol/domain/use-cases/profile';
import {
TransactionData,
Expand All @@ -7,9 +8,17 @@ import {
import { IProfileCacheManager } from '../../../profile/adapters/IProfileCacheManager';

export class UnfollowProfileResponder implements ITransactionResponder<UnfollowRequest> {
constructor(private readonly profileCacheManager: IProfileCacheManager) {}
constructor(
private readonly apolloClient: SafeApolloClient,
private readonly profileCacheManager: IProfileCacheManager,
) {}

async commit({ request }: TransactionData<UnfollowRequest>) {
await this.profileCacheManager.fetchProfileById(request.profileId);
await Promise.all([
this.profileCacheManager.fetchProfileById(request.profileId),
this.apolloClient.refetchQueries({
include: [FollowingDocument],
}),
]);
}
}
Loading