mirror of
https://github.com/inaturalist/iNaturalistReactNative.git
synced 2026-08-02 18:37:06 -04:00
MOB-1557: fix consumers that type useCurrentUser as a live realm object
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user