pr iteration, don't assume js-sdk stores group stuff other than groupId
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
parent
561b9699fc
commit
9ee78de7e5
2 changed files with 8 additions and 19 deletions
|
@ -223,7 +223,8 @@ const sanitizeHtmlParams = {
|
||||||
case '+':
|
case '+':
|
||||||
attribs.href = '#/group/' + entity;
|
attribs.href = '#/group/' + entity;
|
||||||
break;
|
break;
|
||||||
case '#': case '!':
|
case '#':
|
||||||
|
case '!':
|
||||||
attribs.href = '#/room/' + entity;
|
attribs.href = '#/room/' + entity;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,33 +58,22 @@ export default class CommunityProvider extends AutocompleteProvider {
|
||||||
let completions = [];
|
let completions = [];
|
||||||
const {command, range} = this.getCurrentCommand(query, selection, force);
|
const {command, range} = this.getCurrentCommand(query, selection, force);
|
||||||
if (command) {
|
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 {
|
try {
|
||||||
return FlairStore.getGroupProfileCached(cli, groupId);
|
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({
|
return Promise.resolve({
|
||||||
name,
|
name: '',
|
||||||
groupId,
|
groupId,
|
||||||
avatarUrl,
|
avatarUrl: '',
|
||||||
shortDescription: '', // js-sdk doesn't store this
|
shortDescription: '',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
})));
|
})));
|
||||||
|
|
||||||
this.matcher.setObjects(groups);
|
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];
|
const matchedString = command[0];
|
||||||
completions = this.matcher.match(matchedString);
|
completions = this.matcher.match(matchedString);
|
||||||
|
@ -104,7 +93,6 @@ export default class CommunityProvider extends AutocompleteProvider {
|
||||||
),
|
),
|
||||||
range,
|
range,
|
||||||
}))
|
}))
|
||||||
.filter((completion) => !!completion.completion && completion.completion.length > 0)
|
|
||||||
.slice(0, 4);
|
.slice(0, 4);
|
||||||
}
|
}
|
||||||
return completions;
|
return completions;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue