From b13dae1fc66144d37206317e1f9923df4cab090d Mon Sep 17 00:00:00 2001 From: Robin Townsend Date: Wed, 31 Mar 2021 22:45:53 -0400 Subject: [PATCH 1/4] Ignore punctuation when filtering rooms Signed-off-by: Robin Townsend --- .../room-list/filters/NameFilterCondition.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/stores/room-list/filters/NameFilterCondition.ts b/src/stores/room-list/filters/NameFilterCondition.ts index 88edaecfb6..ad487139d5 100644 --- a/src/stores/room-list/filters/NameFilterCondition.ts +++ b/src/stores/room-list/filters/NameFilterCondition.ts @@ -66,12 +66,17 @@ export class NameFilterCondition extends EventEmitter implements IFilterConditio return this.matches(room.name); } - public matches(val: string): boolean { + private normalize(val: string): string { // Note: we have to match the filter with the removeHiddenChars() room name because the // function strips spaces and other characters (M becomes RN for example, in lowercase). - // We also doubly convert to lowercase to work around oddities of the library. - const noSecretsFilter = removeHiddenChars(this.search.toLowerCase()).toLowerCase(); - const noSecretsName = removeHiddenChars(val.toLowerCase()).toLowerCase(); - return noSecretsName.includes(noSecretsFilter); + return removeHiddenChars(val.toLowerCase()) + // Strip all punctuation + .replace(/[\\'!"#$%&()*+,\-./:;<=>?@[\]^_`{|}~\u2000-\u206f\u2e00-\u2e7f]/g, "") + // We also doubly convert to lowercase to work around oddities of the library. + .toLowerCase(); + } + + public matches(val: string): boolean { + return this.normalize(val).includes(this.normalize(this.search)); } } From d547cd5db8f0cb1306619cc2ab19a378361f9a69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Tue, 6 Apr 2021 07:52:02 +0200 Subject: [PATCH 2/4] Show drop file UI only if dragging a file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- src/components/structures/RoomView.tsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/components/structures/RoomView.tsx b/src/components/structures/RoomView.tsx index a180afba29..9cebecd944 100644 --- a/src/components/structures/RoomView.tsx +++ b/src/components/structures/RoomView.tsx @@ -1137,10 +1137,11 @@ export default class RoomView extends React.Component { ev.stopPropagation(); ev.preventDefault(); - this.setState({ - dragCounter: this.state.dragCounter + 1, - draggingFile: true, - }); + this.setState({dragCounter: this.state.dragCounter + 1}); + + if (ev.dataTransfer.types.includes("Files") || ev.dataTransfer.types.includes("application/x-moz-file")) { + this.setState({draggingFile: true}); + } }; private onDragLeave = ev => { From a9853c4f8f4dbee719bf44340cfa216556899f6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Thu, 8 Apr 2021 19:05:35 +0200 Subject: [PATCH 3/4] Clone author's deps fork for Netlify previews MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- scripts/fetchdep.sh | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/scripts/fetchdep.sh b/scripts/fetchdep.sh index 850eef25ec..fe1f49c361 100755 --- a/scripts/fetchdep.sh +++ b/scripts/fetchdep.sh @@ -22,15 +22,26 @@ clone() { } # Try the PR author's branch in case it exists on the deps as well. -# If BUILDKITE_BRANCH is set, it will contain either: +# First we check if BUILDKITE_BRANCH is defined, +# if it isn't we can assume this is a Netlify build +if [ -z ${BUILDKITE_BRANCH+x} ]; then + # Netlify doesn't give us info about the fork so we have to get it from GitHub API + apiEndpoint="https://api.github.com/repos/matrix-org/matrix-react-sdk/pulls/" + apiEndpoint+=$REVIEW_ID + head=$(curl $apiEndpoint | jq -r '.head.label') +else + head=$BUILDKITE_BRANCH +fi + +# If head is set, it will contain either: # * "branch" when the author's branch and target branch are in the same repo -# * "author:branch" when the author's branch is in their fork +# * "fork:branch" when the author's branch is in their fork or if this is a Netlify build # We can split on `:` into an array to check. -BUILDKITE_BRANCH_ARRAY=(${BUILDKITE_BRANCH//:/ }) -if [[ "${#BUILDKITE_BRANCH_ARRAY[@]}" == "1" ]]; then +BRANCH_ARRAY=(${head//:/ }) +if [[ "${#BRANCH_ARRAY[@]}" == "1" ]]; then clone $deforg $defrepo $BUILDKITE_BRANCH -elif [[ "${#BUILDKITE_BRANCH_ARRAY[@]}" == "2" ]]; then - clone ${BUILDKITE_BRANCH_ARRAY[0]} $defrepo ${BUILDKITE_BRANCH_ARRAY[1]} +elif [[ "${#BRANCH_ARRAY[@]}" == "2" ]]; then + clone ${BRANCH_ARRAY[0]} $defrepo ${BRANCH_ARRAY[1]} fi # Try the target branch of the push or PR. clone $deforg $defrepo $BUILDKITE_PULL_REQUEST_BASE_BRANCH From dacffdd62e545fa57797c91bb735630eb494e51f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Fri, 9 Apr 2021 07:57:25 +0200 Subject: [PATCH 4/4] Add some comments MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- src/components/structures/RoomView.tsx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/components/structures/RoomView.tsx b/src/components/structures/RoomView.tsx index 9cebecd944..7168b7d139 100644 --- a/src/components/structures/RoomView.tsx +++ b/src/components/structures/RoomView.tsx @@ -1137,8 +1137,13 @@ export default class RoomView extends React.Component { ev.stopPropagation(); ev.preventDefault(); + // We always increment the counter no matter the types, because dragging is + // still happening. If we didn't, the drag counter would get out of sync. this.setState({dragCounter: this.state.dragCounter + 1}); + // See: + // https://docs.w3cub.com/dom/datatransfer/types + // https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Recommended_drag_types#file if (ev.dataTransfer.types.includes("Files") || ev.dataTransfer.types.includes("application/x-moz-file")) { this.setState({draggingFile: true}); } @@ -1165,6 +1170,9 @@ export default class RoomView extends React.Component { ev.dataTransfer.dropEffect = 'none'; + // See: + // https://docs.w3cub.com/dom/datatransfer/types + // https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Recommended_drag_types#file if (ev.dataTransfer.types.includes("Files") || ev.dataTransfer.types.includes("application/x-moz-file")) { ev.dataTransfer.dropEffect = 'copy'; }