list method
Groups this account is in, light enough for a picker. Pass an item's
id as the phone of any chat send method.
Implementation
Future<List<WhatsappChatSummary>> list() async {
final result = await wpClient.evaluateJs(
'''(async function() {
var chats = await window.WPP.chat.list({onlyGroups: true});
return chats.map(function(c) {
var meta = c.groupMetadata || {};
var admin = null;
try {
if (meta.participants && typeof meta.participants.iAmAdmin === 'function') {
admin = !!meta.participants.iAmAdmin();
}
} catch (e) {}
var count = null;
try { count = meta.participants ? meta.participants.length : null; } catch (e) {}
return {
id: c.id && c.id._serialized ? c.id._serialized : String(c.id),
name: c.name || meta.subject || c.formattedTitle || '',
announce: !!meta.announce,
isAdmin: admin,
memberCount: count
};
});
})()''',
methodName: "groupList",
);
return WhatsappChatSummary.parseList(result);
}