bookish-press 0.10.0 → 0.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -15,7 +15,13 @@ async function addEditor() {
|
|
|
15
15
|
const { createUser } = await import("../../models/CRUD");
|
|
16
16
|
const uid = await createUser(email);
|
|
17
17
|
if (uid === null) newEditorError = "couldn't add editor";
|
|
18
|
-
else
|
|
18
|
+
else {
|
|
19
|
+
// The server only reveals the emails of people who already
|
|
20
|
+
// share a saved book, and this one isn't saved yet. We know
|
|
21
|
+
// the email anyway, so show it now.
|
|
22
|
+
emails.update((known) => new Map(known).set(uid, email));
|
|
23
|
+
change([...uids, uid]);
|
|
24
|
+
}
|
|
19
25
|
} finally {
|
|
20
26
|
loading = undefined;
|
|
21
27
|
}
|
|
@@ -6,7 +6,7 @@ import Format from "../chapter/Format.svelte";
|
|
|
6
6
|
import Note from "../editor/Note.svelte";
|
|
7
7
|
import Instructions from "./Instructions.svelte";
|
|
8
8
|
import Link from "../Link.svelte";
|
|
9
|
-
import { PUBLIC_CONTEXT } from "$env/
|
|
9
|
+
import { PUBLIC_CONTEXT } from "$app/env/public";
|
|
10
10
|
import Button from "../app/Button.svelte";
|
|
11
11
|
import Feedback from "../app/Feedback.svelte";
|
|
12
12
|
let auth = getUser();
|
package/dist/models/CRUD.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { db, functions } from './Firebase';
|
|
1
|
+
import { auth, db, functions } from './Firebase';
|
|
2
2
|
import { collection, getDocs, getDoc, setDoc, doc, addDoc, query, where, deleteDoc, onSnapshot, } from 'firebase/firestore';
|
|
3
3
|
import { httpsCallable } from 'firebase/functions';
|
|
4
4
|
import Edition from './book/Edition';
|
|
@@ -78,6 +78,11 @@ export function listenToChapters(bookID, editionID, react) {
|
|
|
78
78
|
export async function getUserEmails(uids) {
|
|
79
79
|
if (!functions)
|
|
80
80
|
throw Error("Can't publish, no connection to Firebase functions.");
|
|
81
|
+
// The function only answers signed-in users, and a page load can get here
|
|
82
|
+
// before Firebase has restored the sign-in, so wait for it.
|
|
83
|
+
await auth?.authStateReady();
|
|
84
|
+
if (!auth?.currentUser)
|
|
85
|
+
return null;
|
|
81
86
|
const getUserEmails = httpsCallable(functions, 'getUserEmailsGen2');
|
|
82
87
|
const result = await getUserEmails({
|
|
83
88
|
uids,
|
package/dist/models/Firebase.js
CHANGED
|
@@ -3,8 +3,7 @@ import { connectAuthEmulator, getAuth } from 'firebase/auth';
|
|
|
3
3
|
import { connectFirestoreEmulator, getFirestore } from 'firebase/firestore';
|
|
4
4
|
import { connectFunctionsEmulator, getFunctions } from 'firebase/functions';
|
|
5
5
|
import { connectStorageEmulator, getStorage } from 'firebase/storage';
|
|
6
|
-
import { PUBLIC_READER, PUBLIC_CONTEXT, PUBLIC_FIREBASE_API_KEY, PUBLIC_FIREBASE_AUTH_DOMAIN, PUBLIC_FIREBASE_PROJECT_ID, PUBLIC_FIREBASE_STORAGE_BUCKET, PUBLIC_FIREBASE_MESSAGING_SENDER_ID, PUBLIC_FIREBASE_APP_ID, } from '$env/
|
|
7
|
-
import { env } from '$env/dynamic/public';
|
|
6
|
+
import { PUBLIC_READER, PUBLIC_CONTEXT, PUBLIC_FIREBASE_API_KEY, PUBLIC_FIREBASE_AUTH_DOMAIN, PUBLIC_FIREBASE_PROJECT_ID, PUBLIC_FIREBASE_STORAGE_BUCKET, PUBLIC_FIREBASE_MESSAGING_SENDER_ID, PUBLIC_FIREBASE_APP_ID, PUBLIC_EMULATOR_AUTH, PUBLIC_EMULATOR_FIRESTORE, PUBLIC_EMULATOR_STORAGE, PUBLIC_EMULATOR_FUNCTIONS, } from '$app/env/public';
|
|
8
7
|
const isReader = PUBLIC_READER === 'true';
|
|
9
8
|
// Some feedback about context
|
|
10
9
|
if (!isReader && PUBLIC_CONTEXT !== 'prod')
|
|
@@ -25,26 +24,16 @@ export const auth = isReader ? undefined : getAuth(app);
|
|
|
25
24
|
export const db = isReader ? undefined : getFirestore();
|
|
26
25
|
export const storage = isReader ? undefined : getStorage(app);
|
|
27
26
|
export const functions = isReader ? undefined : getFunctions(app);
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
* available in every context (e.g. unit tests), hence the guard. */
|
|
32
|
-
function emulatorPort(name, fallback) {
|
|
33
|
-
try {
|
|
34
|
-
return (env?.[name] ??
|
|
35
|
-
fallback);
|
|
36
|
-
}
|
|
37
|
-
catch {
|
|
38
|
-
return fallback;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
27
|
+
// Emulator ports default to the firebase.json values, but test runs override
|
|
28
|
+
// them (see firebase.test.json) so they don't collide with other emulator
|
|
29
|
+
// suites running on this machine.
|
|
41
30
|
if (!isReader && PUBLIC_CONTEXT === 'local') {
|
|
42
31
|
if (db)
|
|
43
|
-
connectFirestoreEmulator(db, 'localhost', parseInt(
|
|
32
|
+
connectFirestoreEmulator(db, 'localhost', parseInt(PUBLIC_EMULATOR_FIRESTORE ?? '8080'));
|
|
44
33
|
if (auth)
|
|
45
|
-
connectAuthEmulator(auth, `http://localhost:${
|
|
34
|
+
connectAuthEmulator(auth, `http://localhost:${PUBLIC_EMULATOR_AUTH ?? '9099'}`);
|
|
46
35
|
if (storage)
|
|
47
|
-
connectStorageEmulator(storage, 'localhost', parseInt(
|
|
36
|
+
connectStorageEmulator(storage, 'localhost', parseInt(PUBLIC_EMULATOR_STORAGE ?? '9199'));
|
|
48
37
|
if (functions)
|
|
49
|
-
connectFunctionsEmulator(functions, 'localhost', parseInt(
|
|
38
|
+
connectFunctionsEmulator(functions, 'localhost', parseInt(PUBLIC_EMULATOR_FUNCTIONS ?? '5001'));
|
|
50
39
|
}
|