MOB-1557: fix consumers that type useCurrentUser as a live realm object

This commit is contained in:
sepeterson
2026-07-17 14:57:52 -05:00
parent 9b040fd6e6
commit d74e95701f
4 changed files with 7 additions and 16 deletions

View File

@@ -11,7 +11,7 @@ import {
useMyObservations,
} from "providers/MyObservationsContext";
import React, { useCallback, useState } from "react";
import type { RealmTaxon, RealmUser } from "realmModels/types";
import type { RealmTaxon } from "realmModels/types";
import { taxonDisplayName } from "sharedHelpers/taxon";
import { useCurrentUser, useTranslation } from "sharedHooks";
import useTaxonSearch from "sharedHooks/useTaxonSearch";
@@ -21,7 +21,7 @@ const SearchMyObservationsTaxon = ( ) => {
const navigation = useNavigation( );
const { state, dispatch } = useMyObservations( );
const { searchedTaxon } = state;
const currentUser = useCurrentUser( ) as RealmUser | null;
const currentUser = useCurrentUser( );
const [taxonQuery, setTaxonQuery] = useState( ( ) => (
searchedTaxon

View File

@@ -8,7 +8,6 @@ import {
useMyObservations,
} from "providers/MyObservationsContext";
import React from "react";
import type { RealmUser } from "realmModels/types";
import { taxonDisplayName } from "sharedHelpers/taxon";
import { useCurrentUser, useTranslation } from "sharedHooks";
@@ -17,10 +16,7 @@ const SearchedTaxonBanner = ( ) => {
const { state, dispatch } = useMyObservations( );
const { searchedTaxon } = state;
// The Realm `User` class doesn't declare its schema fields as typed
// instance properties (see realmModels/User.ts), so cast to the typed
// RealmUser interface to access the user's name-display prefs.
const currentUser = useCurrentUser( ) as RealmUser | null;
const currentUser = useCurrentUser( );
if ( !searchedTaxon ) return null;

View File

@@ -16,14 +16,8 @@ interface Props {
withdrawn?: boolean;
}
// TODO replace when we've properly typed Realm object
interface User {
prefers_common_names?: boolean;
prefers_scientific_name_first?: boolean;
}
const DisagreementText = ( { taxon, username, withdrawn }: Props ) => {
const currentUser = useCurrentUser( ) as User;
const currentUser = useCurrentUser( );
const showTaxonName = useCallback( ( fontComponent: FC ) => (
<DisplayTaxonName

View File

@@ -10,7 +10,8 @@ import {
useReducer,
} from "react";
import Observation from "realmModels/Observation";
import type { RealmObservation, RealmTaxon, RealmUser } from "realmModels/types";
import type { RealmObservation, RealmTaxon } from "realmModels/types";
import type { UserPojo } from "realmModels/User";
import User from "realmModels/User";
import { log } from "sharedHelpers/logger";
import safeRealmWrite from "sharedHelpers/safeRealmWrite";
@@ -133,7 +134,7 @@ interface UseObsDetailsSharedLogicParams {
markDeletedLocally: ( ) => void;
setRemoteObsWasDeleted: ( deleted: boolean ) => void;
fetchRemoteObservationError: { status?: number } | null;
currentUser: RealmUser | null;
currentUser: UserPojo | null;
belongsToCurrentUser: boolean;
isRefetching: boolean;
refetchRemoteObservation: ( ) => void;