pr iteration, don't assume js-sdk stores group stuff other than groupId
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>pull/21833/head
parent
561b9699fc
commit
9ee78de7e5
|
@ -223,7 +223,8 @@ const sanitizeHtmlParams = {
|
|||
case '+':
|
||||
attribs.href = '#/group/' + entity;
|
||||
break;
|
||||
case '#': case '!':
|
||||
case '#':
|
||||
case '!':
|
||||
attribs.href = '#/room/' + entity;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -58,33 +58,22 @@ export default class CommunityProvider extends AutocompleteProvider {
|
|||
let completions = [];
|
||||
const {command, range} = this.getCurrentCommand(query, selection, force);
|
||||
if (command) {
|
||||
const joinedGroups = cli.getGroups().filter(({myMembership}) => myMembership !== 'invite');
|
||||
const joinedGroups = cli.getGroups().filter(({myMembership}) => myMembership === 'join');
|
||||
|
||||
const groups = (await Promise.all(joinedGroups.map(async ({avatarUrl, groupId, name=''}) => {
|
||||
const groups = (await Promise.all(joinedGroups.map(async ({groupId}) => {
|
||||
try {
|
||||
return FlairStore.getGroupProfileCached(cli, groupId);
|
||||
} catch (e) { // if FlairStore failed, rely on js-sdk's store which lacks info
|
||||
} catch (e) { // if FlairStore failed, fall back to just groupId
|
||||
return Promise.resolve({
|
||||
name,
|
||||
name: '',
|
||||
groupId,
|
||||
avatarUrl,
|
||||
shortDescription: '', // js-sdk doesn't store this
|
||||
avatarUrl: '',
|
||||
shortDescription: '',
|
||||
});
|
||||
}
|
||||
})));
|
||||
|
||||
this.matcher.setObjects(groups);
|
||||
// this.matcher.setObjects(joinedGroups);
|
||||
// this.matcher.setObjects(joinedGroups.map(({groupId}) => {
|
||||
// const groupProfile = GroupStore.getSummary(groupId).profile;
|
||||
// if (groupProfile) {
|
||||
// return {
|
||||
// groupId,
|
||||
// name: groupProfile.name || '',
|
||||
// avatarUrl: groupProfile.avatar_url,
|
||||
// };
|
||||
// }
|
||||
// })).filter(Boolean);
|
||||
|
||||
const matchedString = command[0];
|
||||
completions = this.matcher.match(matchedString);
|
||||
|
@ -104,7 +93,6 @@ export default class CommunityProvider extends AutocompleteProvider {
|
|||
),
|
||||
range,
|
||||
}))
|
||||
.filter((completion) => !!completion.completion && completion.completion.length > 0)
|
||||
.slice(0, 4);
|
||||
}
|
||||
return completions;
|
||||
|
|
Loading…
Reference in New Issue