Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
jcbrand committed Jan 10, 2025
1 parent 427244c commit 94c1141
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 26 deletions.
1 change: 0 additions & 1 deletion src/headless/plugins/roster/contact.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ class RosterContact extends ColorAwareModel(Model) {
return this;
}


/**
* Remove this contact from the roster
* @param {boolean} unauthorize - Whether to also unauthorize the
Expand Down
6 changes: 4 additions & 2 deletions src/headless/plugins/roster/contacts.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,14 +280,16 @@ class RosterContacts extends Collection {
/**
* Fetch the roster from the XMPP server
* @emits _converse#roster
* @param {boolean} [full=false] - Whether to fetch the full roster or just the changes.
* @returns {promise}
*/
async fetchFromServer () {
async fetchFromServer (full=false) {
const stanza = $iq({
'type': 'get',
'id': u.getUniqueId('roster'),
}).c('query', { xmlns: Strophe.NS.ROSTER });
if (this.rosterVersioningSupported()) {

if (this.rosterVersioningSupported() && !full) {
stanza.attrs({ 'ver': this.data.get('version') });
}

Expand Down
9 changes: 0 additions & 9 deletions src/headless/types/plugins/roster/contact.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,6 @@ declare class RosterContact extends RosterContact_base {
presence: any;
getStatus(): any;
openChat(): void;
/**
* Return a string of tab-separated values that are to be used when
* matching against filter text.
*
* The goal is to be able to filter against the VCard fullname,
* roster nickname and JID.
* @returns {string} Lower-cased, tab-separated values
*/
getFilterCriteria(): string;
getDisplayName(): any;
getFullname(): any;
/**
Expand Down
7 changes: 7 additions & 0 deletions src/headless/types/utils/array.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* @template {any} T
* @param {Array<T>} arr
* @returns {Array<T>} A new array containing only unique elements from the input array.
*/
export function unique<T extends unknown>(arr: Array<T>): Array<T>;
//# sourceMappingURL=array.d.ts.map
1 change: 1 addition & 0 deletions src/headless/types/utils/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ declare const _default: {
arrayBufferToBase64(ab: any): string;
base64ToArrayBuffer(b64: any): ArrayBufferLike;
hexToArrayBuffer(hex: any): ArrayBufferLike;
unique<T extends unknown>(arr: Array<T>): Array<T>;
} & CommonUtils & PluginUtils;
export default _default;
export type CommonUtils = Record<string, Function>;
Expand Down
16 changes: 9 additions & 7 deletions src/plugins/rosterview/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,21 +151,23 @@ export function shouldShowGroup (group, model) {
export function populateContactsMap (contacts_map, contact) {
const { labels } = _converse;

const contact_groups = u.unique(contact.get('groups') ?? []);
const contact_groups = /** @type {string[]} */(u.unique(contact.get('groups') ?? []));

if (contact.get('requesting')) {
contact_groups.push(labels.HEADER_REQUESTING_CONTACTS);
contact_groups.push(/** @type {string} */(labels.HEADER_REQUESTING_CONTACTS));
} else if (contact.get('ask') === 'subscribe') {
contact_groups.push(labels.HEADER_PENDING_CONTACTS);
contact_groups.push(/** @type {string} */(labels.HEADER_PENDING_CONTACTS));
} else if (contact.get('subscription') === 'none') {
contact_groups.push(labels.HEADER_UNSAVED_CONTACTS);
contact_groups.push(/** @type {string} */(labels.HEADER_UNSAVED_CONTACTS));
} else if (!api.settings.get('roster_groups')) {
contact_groups.push(labels.HEADER_CURRENT_CONTACTS);
contact_groups.push(/** @type {string} */(labels.HEADER_CURRENT_CONTACTS));
} else {
contact_groups.push(labels.HEADER_UNGROUPED);
contact_groups.push(/** @type {string} */(labels.HEADER_UNGROUPED));
}

for (const name of contact_groups) {
if (contacts_map[name]?.includes(contact)) {
continue;
}
contacts_map[name] ? contacts_map[name].push(contact) : (contacts_map[name] = [contact]);
}

Expand Down
5 changes: 2 additions & 3 deletions src/types/plugins/rosterview/templates/roster_item.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export function tplRemoveLink(el: RosterContact): import("lit").TemplateResult<1>;
declare function _default(el: RosterContact): import("lit").TemplateResult<1>;
export function tplRemoveLink(el: import("../contactview").default): import("lit").TemplateResult<1>;
declare function _default(el: import("../contactview").default): import("lit").TemplateResult<1>;
export default _default;
export type RosterContact = import("../contactview").default;
//# sourceMappingURL=roster_item.d.ts.map
12 changes: 8 additions & 4 deletions src/types/plugins/rosterview/utils.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,23 @@ export function highlightRosterItem(jid: string): void;
*/
export function toggleGroup(ev: Event, name: string): void;
/**
* @param {RosterContact} contact
* @param {RosterContact|XMPPStatus} contact
* @param {string} groupname
* @returns {boolean}
*/
export function isContactFiltered(contact: RosterContact, groupname: string): boolean;
export function isContactFiltered(contact: RosterContact | XMPPStatus, groupname: string): boolean;
/**
* @param {RosterContact} contact
* @param {string} groupname
* @param {Model} model
* @returns {boolean}
*/
export function shouldShowContact(contact: RosterContact, groupname: string, model: Model): boolean;
export function shouldShowGroup(group: any, model: any): boolean;
/**
* @param {string} group
* @param {Model} model
*/
export function shouldShowGroup(group: string, model: Model): boolean;
/**
* Populates a contacts map with the given contact, categorizing it into appropriate groups.
* @param {import('./types').ContactsMap} contacts_map
Expand Down Expand Up @@ -55,5 +59,5 @@ export function getNamesAutoCompleteList(query: string): Promise<{
export type Model = import("@converse/skeletor").Model;
export type RosterContact = import("@converse/headless").RosterContact;
export type RosterContacts = import("@converse/headless").RosterContacts;
export type XMPPStatus = import("@converse/headless").XMPPStatus;
import { XMPPStatus } from "@converse/headless";
//# sourceMappingURL=utils.d.ts.map

0 comments on commit 94c1141

Please sign in to comment.