Skip to content

Commit 6510b96

Browse files
committed
Typing fixes - the addon compiles now
1 parent 6a32ef5 commit 6510b96

File tree

6 files changed

+14
-17
lines changed

6 files changed

+14
-17
lines changed

addons/dexie-cloud/src/authentication/authenticate.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export async function loadAccessToken(
4242
throw new Error(`Refresh token has expired`);
4343
}
4444
const refreshedLogin = await refreshAccessToken(
45-
db.cloud.options.databaseUrl,
45+
db.cloud.options!.databaseUrl,
4646
db.cloud.currentUser.value
4747
);
4848
await db.table("$logins").update(claims.sub, {

addons/dexie-cloud/src/authentication/login.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@ import { AuthPersistedContext } from "./AuthPersistedContext";
44
import { setCurrentUser } from "./setCurrentUser";
55

66
export async function login(db: DexieCloudDB) {
7-
if (db.cloud.currentUser.isLoggedIn) return;
7+
if (db.cloud.currentUser.value.isLoggedIn) return;
88
const context = new AuthPersistedContext(db, {
99
claims: {},
1010
lastLogin: new Date(0),
1111
});
1212
await authenticate(
13-
db.cloud.options.databaseUrl,
13+
db.cloud.options!.databaseUrl,
1414
context,
1515
dummyAuthDialog, // TODO: Fixthis!
16-
db.cloud.options.fetchTokens
16+
db.cloud.options!.fetchTokens
1717
);
1818
await context.save();
1919
await setCurrentUser(db, context);

addons/dexie-cloud/src/authentication/setCurrentUser.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,18 @@ import { getNumUnsyncedMutationsObservable } from "../sync/numUnsyncedMutations"
2121
* @param newUser
2222
*/
2323
export async function setCurrentUser(db: DexieCloudDB, user: AuthPersistedContext) {
24-
const currentUserObservable = db.cloud.currentUserObservable;
24+
const currentUserObservable = db.cloud.currentUser;
2525
if (!currentUserObservable)
2626
throw new Error(`Given Dexie instance doesn't have the dexie-cloud addon.`);
27-
if (user.userId === db.cloud.currentUser.userId) return; // Already this user.
27+
if (user.userId === db.cloud.currentUserId) return; // Already this user.
2828

2929
// Yes, I know, we're calling authenticate() again (if you were following login.ts and came here.)
3030
// But this function can also be called from db.ready!
3131
const authenticationPromise = authenticate(
32-
db.cloud.options.databaseUrl,
32+
db.cloud.options!.databaseUrl,
3333
user,
3434
dummyAuthDialog, // TODO: Fixthis!
35-
db.cloud.options.fetchTokens
35+
db.cloud.options!.fetchTokens
3636
);
3737

3838
// Wait til all readwrite transactions have ended and there is nothing more to sync
@@ -44,7 +44,7 @@ export async function setCurrentUser(db: DexieCloudDB, user: AuthPersistedContex
4444
const safeToChangeUser = outstandingTxAndUnsyncedChangesCombo.pipe(
4545
filter(
4646
([txSet, numOps]) =>
47-
makeArray(txSet.values()).every((tx) => tx.db !== db.backendDB()) &&
47+
makeArray(txSet.values()).every((tx) => tx.db !== db.dx.backendDB()) &&
4848
numOps === 0
4949
)
5050
);
+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
export const Styles: { [styleAlias: string]: Partial<CSSStyleDeclaration> } = {
1+
export const Styles: { [styleAlias: string]: Partial<CSSStyleDeclaration> | any} = {
22
Error: {
33
color: "red",
44
},
5+
DialogOuter: {}
56
};

addons/dexie-cloud/src/default-ui/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export default class LoginGui extends Component<Props, LoginState> {
1919
}
2020

2121
componentDidMount() {
22-
this.subscription = from(this.props.db.cloud.loginStateObservable).subscribe({
22+
this.subscription = from(this.props.db.cloud.loginState).subscribe({
2323
next: (state) => this.setState(state),
2424
error: (error) =>
2525
this.setState({ type: "error", message: error?.message || error }),

addons/dexie-cloud/test/unit/test-dexie-cloud-client.ts

+2-6
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,10 @@ db.version(1).stores({
1919

2020

2121
promisedTest("basic-test", async ()=>{
22-
await new Dexie("argur", {addons: []}).delete();
23-
await db.cloud.configure({
22+
await Dexie.delete(db.name);
23+
db.cloud.configure({
2424
databaseUrl: "http://localhost:3000/z8qgl998z",
2525
requireAuth: true
26-
}).then(x => {
27-
console.log("db.cloud configure succeeded");
28-
}).catch(error => {
29-
console.log("db.cloud.configure failed");
3026
});
3127
console.log("Waiting for open to resolve");
3228
await db.open();

0 commit comments

Comments
 (0)