Skip to content

Commit

Permalink
Migrate to Lens v3
Browse files Browse the repository at this point in the history
  • Loading branch information
Yoginth committed Dec 6, 2024
1 parent 93dd7c3 commit 2348028
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ interface FeatureFlagProviderProps {
}

const FeatureFlagProvider: FC<FeatureFlagProviderProps> = ({ children }) => {
const { authenticationId, id } = getCurrentSession();
const { authenticationId, address } = getCurrentSession();

return (
<FlagProvider
config={{
appName: "production",
environment: "production",
clientKey: UNLEASH_API_TOKEN,
context: { sessionId: authenticationId, userId: id },
context: { sessionId: authenticationId, userId: address },
refreshInterval: 15,
url: "https://unleash.hey.xyz/api/frontend"
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const GET_VERIFIED_MEMBERS_QUERY_KEY = "getVerifiedMembers";
const GET_FIAT_RATES_QUERY_KEY = "getFiatRates";

const PreferencesProvider: FC = () => {
const { id: sessionAccountId } = getCurrentSession();
const { address: sessionAccountAddress } = getCurrentSession();
const { setTheme } = useAccountThemeStore();
const { setVerifiedMembers } = useVerifiedMembersStore();
const { setAllowedTokens } = useAllowedTokensStore();
Expand Down Expand Up @@ -85,9 +85,9 @@ const PreferencesProvider: FC = () => {
};

useQuery({
enabled: Boolean(sessionAccountId),
enabled: Boolean(sessionAccountAddress),
queryFn: getPreferencesData,
queryKey: [GET_PREFERENCES_QUERY_KEY, sessionAccountId || ""]
queryKey: [GET_PREFERENCES_QUERY_KEY, sessionAccountAddress || ""]
});
useQuery({
queryFn: getVerifiedMembers,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const CollectAction: FC<CollectActionProps> = ({
post
}) => {
const collectModule = getCollectModuleData(postAction as any);
const { id: sessionAccountId } = getCurrentSession();
const { address: sessionAccountAddress } = getCurrentSession();

const { isSuspended } = useAccountStatus();
const { addTransaction, isFollowPending, hasOptimisticallyCollected } =
Expand Down Expand Up @@ -145,7 +145,7 @@ const CollectAction: FC<CollectActionProps> = ({
);
setAllowed(allowedAmount > amount);
},
skip: !assetAddress || !sessionAccountId,
skip: !assetAddress || !sessionAccountAddress,
variables: {
request: {
currencies: assetAddress,
Expand Down Expand Up @@ -223,7 +223,7 @@ const CollectAction: FC<CollectActionProps> = ({
}
};

if (!sessionAccountId) {
if (!sessionAccountAddress) {
return (
<LoginButton
className="mt-5 w-full justify-center"
Expand Down
2 changes: 2 additions & 0 deletions apps/web/src/helpers/getCurrentSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ import { hydrateAuthTokens } from "src/store/persisted/useAuthStore";
* @returns {Object} Current session
*/
const getCurrentSession = (): {
authenticationId: string;
owner: string;
address: string;
} => {
const { accessToken } = hydrateAuthTokens();
const currentSession = parseJwt(accessToken || "");

return {
authenticationId: currentSession?.sid,
owner: currentSession?.sub,
address: currentSession?.act.sub
};
Expand Down
2 changes: 2 additions & 0 deletions packages/helpers/parseJwt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const parseJwt = (
): {
sub: string;
exp: number;
sid: string;
act: { sub: string };
} => {
try {
Expand All @@ -26,6 +27,7 @@ const parseJwt = (
return {
sub: "",
exp: 0,
sid: "",
act: { sub: "" }
};
}
Expand Down

0 comments on commit 2348028

Please sign in to comment.