Skip to content

Commit 5cdba1d

Browse files
committed
chore: replace deprecated attr, generate types, fix invalid query
1 parent b0f6a75 commit 5cdba1d

16 files changed

Lines changed: 32 additions & 32 deletions

File tree

src/headless/plugins/bosh/utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ async function initBOSHSession() {
1919
const id = BOSH_SESSION_ID;
2020
if (!bosh_session) {
2121
bosh_session = new Model({ id });
22-
bosh_session.browserStorage = createStore(id, 'session');
22+
bosh_session.storage = createStore(id, 'session');
2323
await new Promise((resolve) => bosh_session.fetch({ 'success': resolve, 'error': resolve }));
2424
}
2525

src/headless/plugins/disco/entity.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,25 +31,25 @@ class DiscoEntity extends Model {
3131

3232
this.dataforms = new Collection();
3333
let id = `converse.dataforms-${this.get('jid')}`;
34-
this.dataforms.browserStorage = createStore(id, 'session');
34+
this.dataforms.storage = createStore(id, 'session');
3535

3636
this.features = new Collection();
3737
id = `converse.features-${this.get('jid')}`;
38-
this.features.browserStorage = createStore(id, 'session');
38+
this.features.storage = createStore(id, 'session');
3939
this.listenTo(this.features, 'add', this.onFeatureAdded);
4040

4141
this.fields = new Collection();
4242
id = `converse.fields-${this.get('jid')}`;
43-
this.fields.browserStorage = createStore(id, 'session');
43+
this.fields.storage = createStore(id, 'session');
4444
this.listenTo(this.fields, 'add', this.onFieldAdded);
4545

4646
this.items = new Collection();
4747
id = `converse.items-${this.get('jid')}`;
48-
this.items.browserStorage = createStore(id, 'session');
48+
this.items.storage = createStore(id, 'session');
4949

5050
this.identities = new Collection();
5151
id = `converse.identities-${this.get('jid')}`;
52-
this.identities.browserStorage = createStore(id, 'session');
52+
this.identities.storage = createStore(id, 'session');
5353

5454
this.fetchFeatures(options);
5555
}
@@ -109,12 +109,12 @@ class DiscoEntity extends Model {
109109
if (options.ignore_cache) {
110110
await this.queryInfo(options);
111111
} else {
112-
const store_id = this.features.browserStorage.name;
112+
const store_id = this.features.storage.name;
113113

114114
// Checking only whether features have been cached, even though
115115
// there are other things that should be cached as well. We assume
116116
// that if features have been cached, everything else has been also.
117-
const result = await this.features.browserStorage.store.getItem(store_id);
117+
const result = await this.features.storage.store.getItem(store_id);
118118
if ((result && result.length === 0) || result === null) {
119119
await this.queryInfo();
120120
} else {

src/headless/plugins/disco/utils.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export async function initializeDisco() {
6868
const bare_jid = _converse.session.get('bare_jid');
6969
const id = `converse.disco-entities-${bare_jid}`;
7070

71-
disco_entities.browserStorage = createStore(id, 'session');
71+
disco_entities.storage = createStore(id, 'session');
7272
const collection = await disco_entities.fetchEntities();
7373

7474
const domain = _converse.session.get('domain');
@@ -99,7 +99,7 @@ export function initStreamFeatures() {
9999
api.promises.add('streamFeaturesAdded');
100100

101101
const stream_features = new Collection();
102-
stream_features.browserStorage = createStore(id, 'session');
102+
stream_features.storage = createStore(id, 'session');
103103
Object.assign(_converse, { stream_features }); // XXX: DEPRECATED
104104
Object.assign(_converse.state, { stream_features });
105105
}

src/headless/plugins/muc/muc.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -452,22 +452,22 @@ class MUC extends ModelWithVCard(ModelWithMessages(ColorAwareModel(ChatBoxBase))
452452
}, {}),
453453
),
454454
);
455-
this.features.browserStorage = createStore(id, 'session');
456-
this.features.listenTo(_converse, 'beforeLogout', () => this.features.browserStorage.flush());
455+
this.features.storage = createStore(id, 'session');
456+
this.features.listenTo(_converse, 'beforeLogout', () => this.features.storage.flush());
457457

458458
id = `converse.muc-config-${bare_jid}-${this.get('jid')}`;
459459
this.config = new Model(/** @type {import('./types').MUCConfigAttributes} */ ({ id }));
460-
this.config.browserStorage = createStore(id, 'session');
461-
this.config.listenTo(_converse, 'beforeLogout', () => this.config.browserStorage.flush());
460+
this.config.storage = createStore(id, 'session');
461+
this.config.listenTo(_converse, 'beforeLogout', () => this.config.storage.flush());
462462
}
463463

464464
initOccupants() {
465465
this.occupants = new _converse.exports.MUCOccupants();
466466
const bare_jid = _converse.session.get('bare_jid');
467467
const id = `converse.occupants-${bare_jid}${this.get('jid')}`;
468-
this.occupants.browserStorage = createStore(id, 'session');
468+
this.occupants.storage = createStore(id, 'session');
469469
this.occupants.chatroom = this;
470-
this.occupants.listenTo(_converse, 'beforeLogout', () => this.occupants.browserStorage.flush());
470+
this.occupants.listenTo(_converse, 'beforeLogout', () => this.occupants.storage.flush());
471471
}
472472

473473
fetchOccupants() {

src/headless/plugins/omemo/plugin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ converse.plugins.add('converse-omemo', {
9595
delete _converse.state.devicelists_v2;
9696
}
9797
if (_converse.state.omemo_active_states) {
98-
_converse.state.omemo_active_states.browserStorage?.clear();
98+
_converse.state.omemo_active_states.storage?.clear();
9999
}
100100
}
101101
// Drop the in-memory reference so it's re-fetched from storage on

src/headless/plugins/pubsub/api.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,8 +350,8 @@ export default {
350350
throw await parseErrorStanza(error);
351351
}
352352

353-
const items = Array.from(response.querySelectorAll('> pubsub > items > item'));
354-
const set = response.querySelector('> pubsub > set');
353+
const items = Array.from(response.querySelectorAll('pubsub > items > item'));
354+
const set = response.querySelector('pubsub > set');
355355
return {
356356
items,
357357
rsm: set ? new RSM({ ...(rsm_options ?? {}), xml: set }) : undefined,

src/headless/types/plugins/mam/types.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { RSMQueryOptions } from 'shared/types';
22
import { RSM } from '../../shared/rsm';
3+
import BaseMessage from '../../shared/message';
34
export type MAMQueryOptions = {
45
end?: string;
56
start?: string;
@@ -13,7 +14,7 @@ export type ArchiveQueryOptions = FetchArchivedMessagesOptions & {
1314
is_groupchat?: boolean;
1415
};
1516
export type MAMQueryResult = {
16-
messages: any[];
17+
messages: BaseMessage[];
1718
rsm?: RSM;
1819
complete?: boolean;
1920
error?: Error;

src/headless/types/plugins/pubsub/api.d.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ declare namespace _default {
4444
function create(jid: string, node: string, config: import("./types").PubSubConfigOptions): Promise<void>;
4545
/**
4646
* Subscribes the local user to a PubSub node.
47-
*
4847
* @method _converse.api.pubsub.subscribe
4948
* @param {string} jid - PubSub service JID.
5049
* @param {string} node - The node to subscribe to
@@ -76,13 +75,13 @@ declare namespace _default {
7675
* XEP-0059 Result Set Management (`rsm`).
7776
*
7877
* @method _converse.api.pubsub.items.get
79-
* @param {string} jid - The JID of the pubsub service where the node
78+
* @param {string|null} jid - The JID of the pubsub service where the node
8079
* resides. Pass a falsy value to query your own PEP service (bare JID).
8180
* @param {string} node - The node to retrieve items from
8281
* @param {import('./types').PubSubItemsOptions} [options]
8382
* @returns {Promise<import('./types').PubSubItemsResult>}
8483
*/
85-
function get(jid: string, node: string, options?: import("./types").PubSubItemsOptions): Promise<import("./types").PubSubItemsResult>;
84+
function get(jid: string | null, node: string, options?: import("./types").PubSubItemsOptions): Promise<import("./types").PubSubItemsResult>;
8685
}
8786
}
8887
}

src/headless/types/plugins/pubsub/types.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { RSMQueryOptions } from 'shared/types.js';
1+
import { RSMQueryOptions } from 'shared/types';
22
export type PubSubConfigOptions = {
33
access_model?: 'authorize' | 'open' | 'presence' | 'roster' | 'whitelist';
44
dataform_xslt?: string;

src/headless/types/utils/types.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export type MediaURLMetadata = MediaURLIndexes & {
2828
};
2929
export type StorageType = 'persistent' | 'session';
3030
export type StorageModel = IEventEmitter & {
31-
browserStorage: PersistentStorage;
31+
storage: PersistentStorage;
3232
};
3333
export {};
3434
//# sourceMappingURL=types.d.ts.map

0 commit comments

Comments
 (0)