Skip to content

Commit a1dedc6

Browse files
author
MStarRobotics
committed
refactor: Humanize codebase structure and comments
1 parent f22c4a2 commit a1dedc6

File tree

9 files changed

+744
-864
lines changed

9 files changed

+744
-864
lines changed

App.tsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ import RecipeResult from './components/RecipeResult';
55
import SavedRecipesModal from './components/SavedRecipesModal';
66
import { formatEther, type Address } from 'viem';
77
import { RecipeFormData, SavedRecipe, LoadingState, AuthProfile } from './types';
8-
import { generateRecipe, generateImageForRecipe } from './services/geminiService';
8+
import { generateRecipe, generateImageForRecipe } from './services/contentEngine';
99
import { LANGUAGES, COOKING_TIMES, DISH_TYPES, RECIPE_GENERATION_MESSAGES, IMAGE_GENERATION_MESSAGES } from './constants';
1010
import { connectWallet, recordRecipeOnchain, fetchOnchainCookbook, resolveBasename, fetchMembershipPrice, checkLifetimeMembership, purchaseLifetimeMembership, DEFAULT_MEMBERSHIP_PRICE_WEI } from './services/baseRegistry';
1111
import { clearPersistedToken, fetchAuthenticatedProfile, isMetaMaskAvailable, linkWalletToGoogleAccount, persistAuthToken, requestNonce, retrievePersistedToken, signMessageWithWallet, verifySignature, logout as logoutSession } from './services/authService';
1212
import type { User } from 'firebase/auth';
13-
import { firebaseSignOut, isFirebaseReady, signInWithFirebaseCustomToken, signInWithGooglePopup, subscribeToFirebaseAuth } from './services/firebaseClient';
13+
import { logout, isReady, loginCustomToken, loginWithGoogle, subscribeAuth } from './services/authAdapter';
1414
import { preloadGoogleIdentity, revokeGoogleIdentityToken, signInWithGoogleIdentity, type GoogleIdentityProfile } from './services/googleIdentity';
1515

1616
const detectScript = (text: string): 'Latin' | 'Devanagari' | 'Bengali' | 'Mixed' | 'Neutral' | 'Unknown' => {
@@ -145,7 +145,7 @@ const App: React.FC = () => {
145145
// Helper: handle Firebase custom token after account link
146146
const handleFirebaseCustomToken = React.useCallback(async (token: string): Promise<void> => {
147147
try {
148-
await signInWithFirebaseCustomToken(token);
148+
await loginCustomToken(token);
149149
setGoogleAuthStatus('GOOGLE ACCOUNT LINKED WITH WALLET');
150150
} catch (firebaseError) {
151151
console.error('Failed to activate Firebase custom token', firebaseError);
@@ -156,7 +156,7 @@ const App: React.FC = () => {
156156
// Helper: activate Firebase for wallet sign-in
157157
const activateFirebaseForWallet = React.useCallback(async (token: string): Promise<void> => {
158158
try {
159-
await signInWithFirebaseCustomToken(token);
159+
await loginCustomToken(token);
160160
setGoogleAuthStatus('WALLET SIGNED IN WITH FIREBASE');
161161
} catch (firebaseError) {
162162
console.error('Failed to activate Firebase session for wallet login', firebaseError);
@@ -350,7 +350,7 @@ const App: React.FC = () => {
350350
const [isWalletBusy, setIsWalletBusy] = React.useState(false);
351351

352352
React.useEffect(() => {
353-
const unsubscribe = subscribeToFirebaseAuth((user) => {
353+
const unsubscribe = subscribeAuth((user) => {
354354
setFirebaseUser(user);
355355
});
356356
return () => {
@@ -702,15 +702,15 @@ const App: React.FC = () => {
702702
const handleGoogleAuthToggle = React.useCallback(async () => {
703703
playSound();
704704

705-
if (isFirebaseReady()) {
705+
if (isReady()) {
706706
try {
707707
if (firebaseUser) {
708-
await firebaseSignOut();
708+
await logout();
709709
setGoogleAuthStatus('GOOGLE SIGNED OUT');
710710
return;
711711
}
712712

713-
const credential = await signInWithGooglePopup();
713+
const credential = await loginWithGoogle();
714714
const descriptor = credential.user.email ?? credential.user.displayName ?? credential.user.uid;
715715
setGoogleAuthStatus(`GOOGLE SIGNED IN AS ${descriptor}`.toUpperCase());
716716
if (authToken) {
@@ -756,10 +756,10 @@ const App: React.FC = () => {
756756
return;
757757
}
758758

759-
if (isFirebaseReady()) {
759+
if (isReady()) {
760760
try {
761761
if (!firebaseUser) {
762-
const credential = await signInWithGooglePopup();
762+
const credential = await loginWithGoogle();
763763
const descriptor = credential.user.email ?? credential.user.displayName ?? credential.user.uid;
764764
setGoogleAuthStatus(`GOOGLE SIGNED IN AS ${descriptor}`.toUpperCase());
765765
await linkGoogleAccountToWallet({ firebaseUser: credential.user });

0 commit comments

Comments
 (0)