-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(oracles): Created a new oracle view for the v2 oracles
- Loading branch information
1 parent
0fe7a90
commit 1aca4a4
Showing
66 changed files
with
1,449 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { DocumentReference, doc } from "firebase/firestore"; | ||
import { constructHomebrewCollectionDocPath } from "../_getRef"; | ||
import { firestore } from "config/firebase.config"; | ||
import { DictKey, OracleTablesCollection } from "@datasworn/core"; | ||
|
||
function constructHomebrewOracleDocPath(homebrewId: string) { | ||
return `${constructHomebrewCollectionDocPath(homebrewId)}/oracles/oracles`; | ||
} | ||
|
||
export function getHomebrewOraclesDoc(homebrewId: string) { | ||
return doc( | ||
firestore, | ||
constructHomebrewOracleDocPath(homebrewId) | ||
) as DocumentReference<Record<DictKey, OracleTablesCollection>>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { OracleTablesCollection } from "@datasworn/core"; | ||
import { getHomebrewOraclesDoc } from "./_getRef"; | ||
import { onSnapshot } from "firebase/firestore"; | ||
|
||
export function listenToHomebrewOracles( | ||
homebrewId: string, | ||
updateOracles: ( | ||
homebrewId: string, | ||
oracles: Record<string, OracleTablesCollection> | ||
) => void, | ||
onError: (error: unknown) => void, | ||
onLoaded: () => void | ||
) { | ||
return onSnapshot( | ||
getHomebrewOraclesDoc(homebrewId), | ||
(snapshot) => { | ||
const doc = snapshot.data(); | ||
if (doc) { | ||
updateOracles(homebrewId, doc); | ||
} else { | ||
onLoaded(); | ||
} | ||
}, | ||
(error) => { | ||
console.error(error); | ||
onError(error); | ||
} | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { OracleTablesCollection } from "@datasworn/core"; | ||
import { createApiFunction } from "api-calls/createApiFunction"; | ||
import { PartialWithFieldValue, setDoc } from "firebase/firestore"; | ||
import { getHomebrewOraclesDoc } from "./_getRef"; | ||
|
||
export const updateHomebrewOracles = createApiFunction< | ||
{ | ||
homebrewId: string; | ||
oracles: PartialWithFieldValue<Record<string, OracleTablesCollection>>; | ||
}, | ||
void | ||
>((params) => { | ||
const { homebrewId, oracles } = params; | ||
|
||
return new Promise((resolve, reject) => { | ||
setDoc(getHomebrewOraclesDoc(homebrewId), oracles, { merge: true }) | ||
.then(() => { | ||
resolve(); | ||
}) | ||
.catch(reject); | ||
}); | ||
}, "Failed to update oracles."); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 35 additions & 2 deletions
37
src/components/features/charactersAndCampaigns/LinkedDialog/LinkedDialog.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 30 additions & 9 deletions
39
...ures/charactersAndCampaigns/LinkedDialog/LinkedDialogContent/LinkedDialogContentTitle.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.