From b5f22001b13292768ede9a20a275892e904f1433 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Thu, 23 Jan 2020 17:22:39 -0700 Subject: [PATCH 1/4] Fix copy --- src/components/views/dialogs/InviteDialog.js | 2 +- src/i18n/strings/en_EN.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/views/dialogs/InviteDialog.js b/src/components/views/dialogs/InviteDialog.js index a96028e71b..54a067d716 100644 --- a/src/components/views/dialogs/InviteDialog.js +++ b/src/components/views/dialogs/InviteDialog.js @@ -985,7 +985,7 @@ export default class InviteDialog extends React.PureComponent { title = _t("Direct Messages"); helpText = _t( - "If you can't find someone, ask them for their username, or share your " + + "If you can't find someone, ask them for their username, share your " + "username (%(userId)s) or profile link.", {userId}, {a: (sub) => {sub}}, diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 099b64dd49..e59805ccd7 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -1472,7 +1472,7 @@ "Recently Direct Messaged": "Recently Direct Messaged", "Show more": "Show more", "Direct Messages": "Direct Messages", - "If you can't find someone, ask them for their username, or share your username (%(userId)s) or profile link.": "If you can't find someone, ask them for their username, or share your username (%(userId)s) or profile link.", + "If you can't find someone, ask them for their username, share your username (%(userId)s) or profile link.": "If you can't find someone, ask them for their username, share your username (%(userId)s) or profile link.", "Go": "Go", "If you can't find someone, ask them for their username (e.g. @user:server.com) or share this room.": "If you can't find someone, ask them for their username (e.g. @user:server.com) or share this room.", "You added a new device '%(displayName)s', which is requesting encryption keys.": "You added a new device '%(displayName)s', which is requesting encryption keys.", From 442ab9f30170743c26523ca867ac9d2821a979e4 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Thu, 23 Jan 2020 17:27:37 -0700 Subject: [PATCH 2/4] Clear the filter when a suggestion is accepted/added --- src/components/views/dialogs/InviteDialog.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/components/views/dialogs/InviteDialog.js b/src/components/views/dialogs/InviteDialog.js index 54a067d716..42319b1842 100644 --- a/src/components/views/dialogs/InviteDialog.js +++ b/src/components/views/dialogs/InviteDialog.js @@ -713,11 +713,16 @@ export default class InviteDialog extends React.PureComponent { }; _toggleMember = (member: Member) => { + let filterText = this.state.filterText; const targets = this.state.targets.map(t => t); // cheap clone for mutation const idx = targets.indexOf(member); - if (idx >= 0) targets.splice(idx, 1); - else targets.push(member); - this.setState({targets}); + if (idx >= 0) { + targets.splice(idx, 1); + } else { + targets.push(member); + filterText = ""; // clear the filter when the user accepts a suggestion + } + this.setState({targets, filterText}); }; _removeMember = (member: Member) => { @@ -917,7 +922,7 @@ export default class InviteDialog extends React.PureComponent { key={"input"} rows={1} onChange={this._updateFilter} - defaultValue={this.state.filterText} + value={this.state.filterText} ref={this._editorRef} onPaste={this._onPaste} /> From 32f9a4e6231cefbdb9790afcfcd10d2ab5f56ea9 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Thu, 23 Jan 2020 17:35:36 -0700 Subject: [PATCH 3/4] Add some debugging around the recently DM'd users The suggestions are relatively stable, but the recents have some issues. Adding logging to the suggestions would also destroy the console log with thousands of messages whereas recents aren't too bad. --- src/components/views/dialogs/InviteDialog.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/components/views/dialogs/InviteDialog.js b/src/components/views/dialogs/InviteDialog.js index 42319b1842..de11dbf9fa 100644 --- a/src/components/views/dialogs/InviteDialog.js +++ b/src/components/views/dialogs/InviteDialog.js @@ -338,19 +338,31 @@ export default class InviteDialog extends React.PureComponent { const recents = []; for (const userId in rooms) { // Filter out user IDs that are already in the room / should be excluded - if (excludedTargetIds.includes(userId)) continue; + if (excludedTargetIds.includes(userId)) { + console.warn(`[Invite:Recents] Excluding ${userId} from recents`); + continue; + } const room = rooms[userId]; const member = room.getMember(userId); - if (!member) continue; // just skip people who don't have memberships for some reason + if (!member) { + // just skip people who don't have memberships for some reason + console.warn(`[Invite:Recents] ${userId} is missing a member object in their own DM (${room.roomId})`); + continue; + } const lastEventTs = room.timeline && room.timeline.length ? room.timeline[room.timeline.length - 1].getTs() : 0; - if (!lastEventTs) continue; // something weird is going on with this room + if (!lastEventTs) { + // something weird is going on with this room + console.warn(`[Invite:Recents] ${userId} (${room.roomId}) has a weird last timestamp: ${lastEventTs}`); + continue; + } recents.push({userId, user: member, lastActive: lastEventTs}); } + if (!recents) console.warn("[Invite:Recents] No recents to suggest!"); // Sort the recents by last active to save us time later recents.sort((a, b) => b.lastActive - a.lastActive); From abc2808b62d1cacb94d7a4e2403c5ee5f74faab8 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Fri, 24 Jan 2020 08:57:03 -0700 Subject: [PATCH 4/4] Fix i18n post-merge --- src/i18n/strings/en_EN.json | 1 - 1 file changed, 1 deletion(-) diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 3c758ecbfb..eb06518c7a 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -1475,7 +1475,6 @@ "Suggestions": "Suggestions", "Recently Direct Messaged": "Recently Direct Messaged", "Show more": "Show more", - "Direct Messages": "Direct Messages", "If you can't find someone, ask them for their username, share your username (%(userId)s) or profile link.": "If you can't find someone, ask them for their username, share your username (%(userId)s) or profile link.", "Go": "Go", "If you can't find someone, ask them for their username (e.g. @user:server.com) or share this room.": "If you can't find someone, ask them for their username (e.g. @user:server.com) or share this room.",