Skip to content

Commit

Permalink
chore: switch from broken imports to globalThis ref for mongo types
Browse files Browse the repository at this point in the history
  • Loading branch information
TheQueenIsDead committed May 15, 2024
1 parent f4c5217 commit 29b8cf9
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions app/src/context/StorageContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,16 @@ import { MongoHistoryLog } from '../models/models'

import * as Realm from "realm-web";
// @ts-ignore
import InsertOneResult = Realm.Services.MongoDB.InsertOneResult;
import DeleteResult = Realm.Services.MongoDB.DeleteResult;
const {
BSON: { ObjectId },
} = Realm;

interface StorageContextType {
config: Config;
history: MongoHistoryLog[];
pushHistoryLog: (log: MongoHistoryLog) => Promise<InsertOneResult<any>>;
pushHistoryLog: (log: MongoHistoryLog) => Promise<globalThis.Realm.Services.MongoDB.InsertOneResult<any>>;
saveConfig: (config: Config) => Promise<void>;
deleteHistoryLog: (log: MongoHistoryLog) => Promise<DeleteResult>;
deleteHistoryLog: (log: MongoHistoryLog) => Promise<globalThis.Realm.Services.MongoDB.DeleteResult>;
}

const defaultContextValue: StorageContextType = {
Expand All @@ -27,9 +25,9 @@ const defaultContextValue: StorageContextType = {
wage: 0,
}, // Assuming an empty object can be a default state
history: [],
pushHistoryLog: async (): Promise<InsertOneResult<any>> => { return new Promise(() => {})},
pushHistoryLog: async (): Promise<globalThis.Realm.Services.MongoDB.InsertOneResult<any>> => { return new Promise(() => {})},
saveConfig: async () => {},
deleteHistoryLog: async (): Promise<DeleteResult> => { return new Promise(() => {})}
deleteHistoryLog: async (): Promise<globalThis.Realm.Services.MongoDB.DeleteResult> => { return new Promise(() => {})}
};

const StorageContext = createContext<StorageContextType>(defaultContextValue);
Expand Down Expand Up @@ -70,7 +68,8 @@ export const StorageProvider: React.FC<{children: ReactNode}> = ({ children }) =
}
return history
}
const pushHistoryLog = async (log: MongoHistoryLog): Promise<InsertOneResult<any>> => {
// const pushHistoryLog = async (log: MongoHistoryLog): Promise<InsertOneResult<any>> => {
const pushHistoryLog = async (log: MongoHistoryLog): Promise<globalThis.Realm.Services.MongoDB.InsertOneResult<any>> => {

if (currentUser === null) {
throw 'could not push to database'
Expand Down

0 comments on commit 29b8cf9

Please sign in to comment.