bookish-press 0.11.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 change([...uids, uid]);
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
  }
@@ -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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bookish-press",
3
3
  "private": false,
4
- "version": "0.11.0",
4
+ "version": "0.11.1",
5
5
  "type": "module",
6
6
  "description": "A platform for reading and writing readable, accessible, beautiful online books.",
7
7
  "license": "MIT",