Skip to content

Commit d249f21

Browse files
committed
wip make conversation props readonly
1 parent 471b117 commit d249f21

File tree

3 files changed

+26
-8
lines changed

3 files changed

+26
-8
lines changed

packages/js-sdk/src/Dm3Sdk.ts

+12-4
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ export class Dm3Sdk {
100100
profile: SignedUserProfile;
101101
accountAddress: string;
102102
}) {
103+
console.log('hello sdk');
104+
103105
const tld =
104106
this._tld ??
105107
new Tld(
@@ -131,14 +133,19 @@ export class Dm3Sdk {
131133
);
132134

133135
await beConnector.login(profile);
134-
135-
this.storageApi = this.storageApi ?? new EncryptedCloudStorage(
136+
const encCS = new EncryptedCloudStorage(
136137
beConnector,
137138
account,
138139
this.profileKeys,
139-
).getCloudStorage();
140+
);
141+
console.log('encCS', encCS.account);
142+
this.storageApi = encCS.getCloudStorage();
140143

141144
console.log('this.storageApi', this.storageApi);
145+
console.log(
146+
'SAPI account',
147+
(this.storageApi as unknown as EncryptedCloudStorage).account,
148+
);
142149

143150
const conversations = new Conversations(
144151
this.storageApi,
@@ -148,6 +155,7 @@ export class Dm3Sdk {
148155
profileKeys,
149156
this.addressEnsSubdomain,
150157
);
158+
await conversations._init();
151159

152160
return new Dm3(conversations, tld);
153161
}
@@ -163,7 +171,7 @@ export class Dm3Sdk {
163171
this.defaultDeliveryService,
164172
);
165173

166-
console.log('lc', lc, typeof lc.login);
174+
console.log('lcgoo', lc, typeof lc.login);
167175
const loginResult = await lc.login();
168176

169177
console.log('loginResult', loginResult);

packages/js-sdk/src/conversation/Conversations.ts

+10
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,16 @@ export class Conversations {
4040
this.list = [];
4141
}
4242

43+
public async _init() {
44+
const conversations = await this.storageApi.getConversations(10, 0);
45+
await Promise.all(
46+
conversations.map((conversation) =>
47+
this._addConversation(conversation),
48+
),
49+
);
50+
console.log('tinit done');
51+
}
52+
4353
public async addConversation(_ensName: string) {
4454
const contactTldName = normalizeEnsName(_ensName);
4555

packages/js-sdk/src/storage/EncryptedCloudStorage.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ import {
99
encryptAsymmetric,
1010
} from '@dm3-org/dm3-lib-crypto';
1111
export class EncryptedCloudStorage {
12-
private backendConnector: IBackendConnector;
13-
private account: Account;
14-
private profileKeys: ProfileKeys;
12+
private readonly backendConnector: IBackendConnector;
13+
public readonly account: Account;
14+
private readonly profileKeys: ProfileKeys;
1515

1616
constructor(
1717
backendConnector: IBackendConnector,
1818
account: Account,
1919
profileKeys: ProfileKeys,
2020
) {
21-
if(!account.ensName) {
21+
if (!account.ensName) {
2222
throw new Error('Account must have an ENS name');
2323
}
2424

0 commit comments

Comments
 (0)