From 4511890803076368b044fbc43f81f08295e5de87 Mon Sep 17 00:00:00 2001 From: Joshua Tag Howard Date: Mon, 18 Nov 2024 01:27:17 +0000 Subject: [PATCH] Fix some issues with mobile and new arch --- .vscode/settings.json | 1 + packages/common/lib/api/scalars/GlobalId.ts | 2 +- packages/common/lib/error/control.ts | 4 ++-- packages/common/lib/error/luxon.ts | 7 ++++--- packages/common/lib/error/option.ts | 4 ++-- packages/mobile/app.config.ts | 15 ++++++++++++--- packages/mobile/babel.config.cjs | 6 ++++-- packages/mobile/src/common/auth.ts | 3 +-- packages/mobile/src/common/storage-tokens.ts | 1 + packages/mobile/src/context/urql.tsx | 2 +- packages/mobile/src/graphql/graphql.ts | 9 +++++++++ .../root/ProfileScreen/ProfileFooter.tsx | 2 +- 12 files changed, 39 insertions(+), 17 deletions(-) create mode 100644 packages/mobile/src/common/storage-tokens.ts diff --git a/.vscode/settings.json b/.vscode/settings.json index 47da776c9..6aa631f8d 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -31,6 +31,7 @@ "codegen", "collapsable", "cooldown", + "DANCEBLUE", "datasource", "ddns", "Errorable", diff --git a/packages/common/lib/api/scalars/GlobalId.ts b/packages/common/lib/api/scalars/GlobalId.ts index 5bdd5fc98..49c5426b4 100644 --- a/packages/common/lib/api/scalars/GlobalId.ts +++ b/packages/common/lib/api/scalars/GlobalId.ts @@ -2,7 +2,7 @@ import { GraphQLScalarType, Kind } from "graphql"; import type { Result } from "ts-results-es"; import { Err, Ok } from "ts-results-es"; -import { InvalidArgumentError } from "../../error/direct.js"; +import { InvalidArgumentError } from "../../error/index.js"; import { arrayToBase64String, base64StringToArray, diff --git a/packages/common/lib/error/control.ts b/packages/common/lib/error/control.ts index 1cf5642b0..dd8aeef31 100644 --- a/packages/common/lib/error/control.ts +++ b/packages/common/lib/error/control.ts @@ -1,8 +1,8 @@ -import type { AuthorizationRule } from "@ukdanceblue/common"; -import { prettyPrintAuthorizationRule } from "@ukdanceblue/common"; import type { GraphQLResolveInfo } from "graphql"; import type { Path } from "graphql/jsutils/Path.js"; +import type { AuthorizationRule } from "../authorization/accessControl.js"; +import { prettyPrintAuthorizationRule } from "../authorization/accessControl.js"; import { ConcreteError } from "./error.js"; import * as ErrorCode from "./errorCode.js"; diff --git a/packages/common/lib/error/luxon.ts b/packages/common/lib/error/luxon.ts index 046d7d801..642b80d9a 100644 --- a/packages/common/lib/error/luxon.ts +++ b/packages/common/lib/error/luxon.ts @@ -2,7 +2,8 @@ import type { DateTime, Duration, Interval } from "luxon"; import type { Result } from "ts-results-es"; import { Err, Ok } from "ts-results-es"; -import { ConcreteError, ErrorCode } from "./index.js"; +import { ConcreteError } from "./error.js"; +import { LuxonError as ErrorCodeLuxonError } from "./errorCode.js"; export class LuxonError extends ConcreteError { constructor( @@ -22,8 +23,8 @@ export class LuxonError extends ConcreteError { return this.value.invalidExplanation ?? this.message; } - get tag(): ErrorCode.LuxonError { - return ErrorCode.LuxonError; + get tag(): ErrorCodeLuxonError { + return ErrorCodeLuxonError; } readonly expose = true; diff --git a/packages/common/lib/error/option.ts b/packages/common/lib/error/option.ts index 1e94c86d2..1731f75e4 100644 --- a/packages/common/lib/error/option.ts +++ b/packages/common/lib/error/option.ts @@ -3,7 +3,7 @@ import { Err, None, Ok, Some } from "ts-results-es"; import type { NotFoundError } from "./direct.js"; import type { ConcreteError } from "./error.js"; -import { ErrorCode } from "./index.js"; +import { NotFound as ErrorCodeNotFound } from "./errorCode.js"; export function optionOf(value: T | null | undefined): Option { return value == null ? None : Some(value); @@ -17,7 +17,7 @@ export function extractNotFound( ): Result, E> { return result.isErr() ? result.orElse((error) => - error.tag === ErrorCode.NotFound ? Ok(None) : Err(error) + error.tag === ErrorCodeNotFound ? Ok(None) : Err(error) ) : result.map((value) => optionOf(value)); } diff --git a/packages/mobile/app.config.ts b/packages/mobile/app.config.ts index 42c2a3de8..7dbaa95a3 100644 --- a/packages/mobile/app.config.ts +++ b/packages/mobile/app.config.ts @@ -18,16 +18,16 @@ To bump the app's version: const bundleVersion: Version = { major: 2, minor: 8, - patch: 0, + patch: 1, } as const; const nativeVersion: Version = { major: 2, minor: 8, - patch: 0, + patch: 1, } as const; // Both the sum of version.patch + buildsThisVersion and the sum of baseBuildCount + buildsThisVersion must increase each time a native build is submitted. -const baseBuildCount = 44; +const baseBuildCount = 45; const buildsThisVersion = 1; /* @@ -93,6 +93,7 @@ export default ({ config }: ConfigContext): ExpoConfig => { iosBuildString: buildNumber, runtimeVersion, qualifiedName, + allowHttp: IS_DEV, }); }; @@ -112,6 +113,7 @@ function makeExpoConfig({ iosBuildString, runtimeVersion, qualifiedName, + allowHttp, }: { baseConfig: Partial; name: "DB DEV CLIENT" | "DanceBlue"; @@ -121,6 +123,7 @@ function makeExpoConfig({ iosBuildString: SemVer; runtimeVersion: SemVer; qualifiedName: DanceBlueQualifiedName; + allowHttp: boolean; }): ExpoConfig { const iosConfig = baseConfig.ios ?? {}; const androidConfig = baseConfig.android ?? {}; @@ -130,6 +133,12 @@ function makeExpoConfig({ androidConfig.versionCode = androidBuildNumber; iosConfig.bundleIdentifier = qualifiedName; + iosConfig.infoPlist = { + ...iosConfig.infoPlist, + NSAppTransportSecurity: { + NSAllowsArbitraryLoads: allowHttp, + }, + }; androidConfig.package = qualifiedName; return { diff --git a/packages/mobile/babel.config.cjs b/packages/mobile/babel.config.cjs index 3c3466dd8..b4e0d07b8 100644 --- a/packages/mobile/babel.config.cjs +++ b/packages/mobile/babel.config.cjs @@ -1,8 +1,10 @@ /** - * + * @param {import('@babel/core').ConfigAPI} api * @returns {import('@babel/core').TransformOptions} */ -module.exports = function babel() { +module.exports = function babel(api) { + api.cache.forever(); + return { presets: ["babel-preset-expo"], plugins: ["react-native-reanimated/plugin"], diff --git a/packages/mobile/src/common/auth.ts b/packages/mobile/src/common/auth.ts index fc6cc5077..cfdb38a69 100644 --- a/packages/mobile/src/common/auth.ts +++ b/packages/mobile/src/common/auth.ts @@ -12,8 +12,7 @@ import { useLoading } from "@/context/useLoading"; import { API_BASE_URL } from "./apiUrl"; import { Logger } from "./logger/Logger"; - -export const DANCEBLUE_TOKEN_KEY = "danceblue-auth-token"; +import { DANCEBLUE_TOKEN_KEY } from "./storage-tokens"; function getLoginUrl(source: AuthSource): string { let urlComponent = ""; diff --git a/packages/mobile/src/common/storage-tokens.ts b/packages/mobile/src/common/storage-tokens.ts new file mode 100644 index 000000000..c5b5382c2 --- /dev/null +++ b/packages/mobile/src/common/storage-tokens.ts @@ -0,0 +1 @@ +export const DANCEBLUE_TOKEN_KEY = "danceblue-auth-token"; diff --git a/packages/mobile/src/context/urql.tsx b/packages/mobile/src/context/urql.tsx index 1d38352a2..23d68034a 100644 --- a/packages/mobile/src/context/urql.tsx +++ b/packages/mobile/src/context/urql.tsx @@ -5,7 +5,7 @@ import { createContext, useContext, useMemo, useReducer } from "react"; import { cacheExchange, Client, fetchExchange, Provider } from "urql"; import { API_BASE_URL } from "@/common/apiUrl"; -import { DANCEBLUE_TOKEN_KEY } from "@/common/auth"; +import { DANCEBLUE_TOKEN_KEY } from "@/common/storage-tokens"; const invalidateCacheContext = createContext<() => void>(() => undefined); diff --git a/packages/mobile/src/graphql/graphql.ts b/packages/mobile/src/graphql/graphql.ts index e1ee12a90..4636cc546 100644 --- a/packages/mobile/src/graphql/graphql.ts +++ b/packages/mobile/src/graphql/graphql.ts @@ -415,6 +415,15 @@ export const FundraisingEntryResolverStringFilterKeys = { export type FundraisingEntryResolverStringFilterKeys = (typeof FundraisingEntryResolverStringFilterKeys)[keyof typeof FundraisingEntryResolverStringFilterKeys]; +export const FundraisingEntryType = { + Cash: "Cash", + Check: "Check", + Legacy: "Legacy", + Online: "Online", +} as const; + +export type FundraisingEntryType = + (typeof FundraisingEntryType)[keyof typeof FundraisingEntryType]; export const ImageResolverAllKeys = { Alt: "alt", CreatedAt: "createdAt", diff --git a/packages/mobile/src/navigation/root/ProfileScreen/ProfileFooter.tsx b/packages/mobile/src/navigation/root/ProfileScreen/ProfileFooter.tsx index 814186720..f4ef811b0 100644 --- a/packages/mobile/src/navigation/root/ProfileScreen/ProfileFooter.tsx +++ b/packages/mobile/src/navigation/root/ProfileScreen/ProfileFooter.tsx @@ -20,7 +20,7 @@ import { universalCatch } from "@/common/logging"; import type { FragmentType } from "@/graphql/index"; import { getFragmentData } from "@/graphql/index"; -import { ProfileScreenAuthFragment } from "."; +import { ProfileScreenAuthFragment } from "./ProfileScreen"; export const ProfileFooter = ({ profileScreenAuthFragment,