From d6d1b0eeef7307a2931dd48d50aede0b318a36f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marcin=20miko=C5=82ajczak?= Date: Tue, 14 Sep 2021 09:30:37 +0200 Subject: [PATCH 01/12] Fix typo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: marcin mikołajczak --- src/app/pages/App.jsx | 8 ++++---- src/client/state/auth.js | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/app/pages/App.jsx b/src/app/pages/App.jsx index 0df840db..bb265056 100644 --- a/src/app/pages/App.jsx +++ b/src/app/pages/App.jsx @@ -3,7 +3,7 @@ import { BrowserRouter, Switch, Route, Redirect, } from 'react-router-dom'; -import { isAuthanticated } from '../../client/state/auth'; +import { isAuthenticated } from '../../client/state/auth'; import Auth from '../templates/auth/Auth'; import Client from '../templates/client/Client'; @@ -13,13 +13,13 @@ function App() { - { isAuthanticated() ? : } + { isAuthenticated() ? : } - { isAuthanticated() ? : } + { isAuthenticated() ? : } - { isAuthanticated() ? : } + { isAuthenticated() ? : } diff --git a/src/client/state/auth.js b/src/client/state/auth.js index c919f640..fbc23f6f 100644 --- a/src/client/state/auth.js +++ b/src/client/state/auth.js @@ -4,7 +4,7 @@ function getSecret(key) { return localStorage.getItem(key); } -const isAuthanticated = () => getSecret(cons.secretKey.ACCESS_TOKEN) !== null; +const isAuthenticated = () => getSecret(cons.secretKey.ACCESS_TOKEN) !== null; const secret = { accessToken: getSecret(cons.secretKey.ACCESS_TOKEN), @@ -14,6 +14,6 @@ const secret = { }; export { - isAuthanticated, + isAuthenticated, secret, }; From cd5b7b17f6dc8660b1ac869dbb9fde40b16b559e Mon Sep 17 00:00:00 2001 From: Ajay Bura <32841439+ajbura@users.noreply.github.com> Date: Wed, 15 Sep 2021 17:17:31 +0530 Subject: [PATCH 02/12] Added more options to run locally --- README.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e4995d9a..6679eaf3 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,11 @@ Cinny is a [Matrix](https://matrix.org) client focusing primarily on simple, ele ## Building and Running +### Running pre-compiled + +A tarball of pre-compiled version of the app is provided with each [release](https://github.com/ajbura/cinny/releases). +You can serve the application with a webserver of your choosing by simply copying `dist/` directory to the webroot. + ### Building from source Execute the following commands to compile the app from its source code: @@ -44,10 +49,12 @@ docker run -p 8080:80 cinny:latest This will forward your `localhost` port 8080 to the container's port 80. You can visit the app in your browser by navigating to `http://localhost:8080`. +Alternatively you can just pull the [DockerHub image](https://hub.docker.com/r/ajbura/cinny) by `docker pull ajbura/cinny`. + ## License Copyright (c) 2021 Ajay Bura (ajbura) and other contributors Code licensed under the MIT License: -Graphics licensed under CC-BY 4.0: \ No newline at end of file +Graphics licensed under CC-BY 4.0: From 26f68a890eea5a386f56bdef110d1c9c880112f7 Mon Sep 17 00:00:00 2001 From: jamesjulich <51384945+jamesjulich@users.noreply.github.com> Date: Mon, 20 Sep 2021 11:02:15 -0500 Subject: [PATCH 03/12] Added chip component. --- src/app/atoms/chip/Chip.jsx | 34 ++++++++++++++++++++++++++++++++++ src/app/atoms/chip/Chip.scss | 23 +++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 src/app/atoms/chip/Chip.jsx create mode 100644 src/app/atoms/chip/Chip.scss diff --git a/src/app/atoms/chip/Chip.jsx b/src/app/atoms/chip/Chip.jsx new file mode 100644 index 00000000..3cededff --- /dev/null +++ b/src/app/atoms/chip/Chip.jsx @@ -0,0 +1,34 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import './Chip.scss'; + +import Text from '../text/Text'; +import RawIcon from '../system-icons/RawIcon'; + +function Chip({ + iconSrc, iconColor, text, children, +}) { + return ( +
+ {iconSrc != null && } + {(text != null && text !== '') && {text}} + {children} +
+ ); +} + +Chip.propTypes = { + iconSrc: PropTypes.string, + iconColor: PropTypes.string, + text: PropTypes.string, + children: PropTypes.element, +}; + +Chip.defaultProps = { + iconSrc: null, + iconColor: null, + text: null, + children: null, +}; + +export default Chip; diff --git a/src/app/atoms/chip/Chip.scss b/src/app/atoms/chip/Chip.scss new file mode 100644 index 00000000..96e91bef --- /dev/null +++ b/src/app/atoms/chip/Chip.scss @@ -0,0 +1,23 @@ +.chip { + height: 28px; + width: fit-content; + width: -moz-fit-content; + background: var(--bg-surface-low); + + display: flex; + flex-direction: row; + align-items: center; + + padding: var(--sp-ultra-tight) var(--sp-extra-tight); + box-sizing: border-box; + border-radius: var(--bo-radius); + border: 1px solid var(--bg-surface-border); + + & .text-b2 { + color: var(--tc-surface-high); + } + + & .ic-raw-small { + margin-right: var(--sp-extra-tight); + } +} \ No newline at end of file From c96d5560943d8d8b7793d246ebe255deff00fb9b Mon Sep 17 00:00:00 2001 From: Ajay Bura Date: Thu, 23 Sep 2021 16:40:52 +0530 Subject: [PATCH 04/12] Updated Chip.scss property ordering --- src/app/atoms/chip/Chip.scss | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/src/app/atoms/chip/Chip.scss b/src/app/atoms/chip/Chip.scss index 96e91bef..c53f5ba7 100644 --- a/src/app/atoms/chip/Chip.scss +++ b/src/app/atoms/chip/Chip.scss @@ -1,23 +1,19 @@ .chip { - height: 28px; - width: fit-content; - width: -moz-fit-content; - background: var(--bg-surface-low); - - display: flex; + padding: var(--sp-ultra-tight) var(--sp-extra-tight); + + display: inline-flex; flex-direction: row; align-items: center; - - padding: var(--sp-ultra-tight) var(--sp-extra-tight); - box-sizing: border-box; + + background: var(--bg-surface-low); border-radius: var(--bo-radius); border: 1px solid var(--bg-surface-border); - & .text-b2 { - color: var(--tc-surface-high); - } - - & .ic-raw-small { + & > .ic-raw { margin-right: var(--sp-extra-tight); + [dir=rtl] & { + margin-right: 0; + margin-left: var(--sp-extra-tight); + } } } \ No newline at end of file From ecc4a40eeaeea2a7f04865f9b0766a9a0969056e Mon Sep 17 00:00:00 2001 From: Gero Gerke Date: Thu, 30 Sep 2021 16:16:43 +0200 Subject: [PATCH 05/12] Disallow sending to rooms with insufficient powerlevel Fixes #123 --- src/app/organisms/room/RoomViewInput.jsx | 8 ++++++++ src/app/organisms/room/RoomViewInput.scss | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/src/app/organisms/room/RoomViewInput.jsx b/src/app/organisms/room/RoomViewInput.jsx index edad9c99..20886c24 100644 --- a/src/app/organisms/room/RoomViewInput.jsx +++ b/src/app/organisms/room/RoomViewInput.jsx @@ -327,7 +327,15 @@ function RoomViewInput({ if (file !== null) roomsInput.setAttachment(roomId, file); } + const myPowerlevel = roomTimeline.room.getMember(mx.getUserId()).powerLevel; + const canISend = roomTimeline.room.currentState.hasSufficientPowerLevelFor('events_default', myPowerlevel); + function renderInputs() { + if (!canISend) { + return ( +

You do not have permission to post to this room

+ ); + } return ( <>
diff --git a/src/app/organisms/room/RoomViewInput.scss b/src/app/organisms/room/RoomViewInput.scss index 112a4c4a..a9d58f4f 100644 --- a/src/app/organisms/room/RoomViewInput.scss +++ b/src/app/organisms/room/RoomViewInput.scss @@ -3,6 +3,12 @@ display: flex; min-height: 48px; + &__disallowed { + color: var(--tc-surface-low); + flex: 1; + text-align: center; + } + &__space { min-width: 0; align-self: center; From 7d032bb6840b93156c308b14a631c3c2f9e466fd Mon Sep 17 00:00:00 2001 From: Gero Gerke Date: Thu, 30 Sep 2021 17:24:28 +0200 Subject: [PATCH 06/12] Improve message when there are no public rooms on a server --- src/app/organisms/public-rooms/PublicRooms.jsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/app/organisms/public-rooms/PublicRooms.jsx b/src/app/organisms/public-rooms/PublicRooms.jsx index b8f92449..b7d2dbb5 100644 --- a/src/app/organisms/public-rooms/PublicRooms.jsx +++ b/src/app/organisms/public-rooms/PublicRooms.jsx @@ -137,7 +137,7 @@ function PublicRooms({ isOpen, searchTerm, onRequestClose }) { updateNextBatch(result.next_batch); updateIsSearching(false); updateIsViewMore(false); - if (totalRooms.length === 0) { + if (totalRooms.length === 0 && inputRoomName !== '') { updateSearchQuery({ error: `No result found for "${inputRoomName}" on ${inputHs}`, alias: isInputAlias ? inputRoomName : null, @@ -241,12 +241,20 @@ function PublicRooms({ isOpen, searchTerm, onRequestClose }) { ) } { - typeof searchQuery.name !== 'undefined' && !isSearching && ( + typeof searchQuery.name !== 'undefined' && !isSearching && publicRooms.length !== 0 && ( searchQuery.name === '' ? {`Public rooms on ${searchQuery.homeserver}.`} : {`Search result for "${searchQuery.name}" on ${searchQuery.homeserver}.`} ) } + { + typeof searchQuery.name !== 'undefined' && !isSearching && publicRooms.length === 0 + && ( +
+ {`There are no public rooms on ${searchQuery.homeserver}.`} +
+ ) + } { searchQuery.error && ( <> {searchQuery.error} From 1dd7f0371d9bef934295b5fb8d9b9df93713d089 Mon Sep 17 00:00:00 2001 From: kfiven <33421343+kfiven@users.noreply.github.com> Date: Thu, 30 Sep 2021 20:56:39 +0530 Subject: [PATCH 07/12] Changed p to Text component --- src/app/organisms/room/RoomViewInput.jsx | 2 +- src/app/organisms/room/RoomViewInput.scss | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/app/organisms/room/RoomViewInput.jsx b/src/app/organisms/room/RoomViewInput.jsx index 20886c24..6c354eda 100644 --- a/src/app/organisms/room/RoomViewInput.jsx +++ b/src/app/organisms/room/RoomViewInput.jsx @@ -333,7 +333,7 @@ function RoomViewInput({ function renderInputs() { if (!canISend) { return ( -

You do not have permission to post to this room

+ You do not have permission to post to this room ); } return ( diff --git a/src/app/organisms/room/RoomViewInput.scss b/src/app/organisms/room/RoomViewInput.scss index a9d58f4f..9e0f1a91 100644 --- a/src/app/organisms/room/RoomViewInput.scss +++ b/src/app/organisms/room/RoomViewInput.scss @@ -4,7 +4,6 @@ min-height: 48px; &__disallowed { - color: var(--tc-surface-low); flex: 1; text-align: center; } From 8e5a5baf52d5329c5a7e97633c1707cb72b4aa79 Mon Sep 17 00:00:00 2001 From: Ajay Bura Date: Sun, 3 Oct 2021 09:53:54 +0530 Subject: [PATCH 08/12] Better error handling when server room list is private Signed-off-by: Ajay Bura --- .../organisms/public-rooms/PublicRooms.jsx | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/app/organisms/public-rooms/PublicRooms.jsx b/src/app/organisms/public-rooms/PublicRooms.jsx index b7d2dbb5..23401298 100644 --- a/src/app/organisms/public-rooms/PublicRooms.jsx +++ b/src/app/organisms/public-rooms/PublicRooms.jsx @@ -137,16 +137,22 @@ function PublicRooms({ isOpen, searchTerm, onRequestClose }) { updateNextBatch(result.next_batch); updateIsSearching(false); updateIsViewMore(false); - if (totalRooms.length === 0 && inputRoomName !== '') { + if (totalRooms.length === 0) { updateSearchQuery({ - error: `No result found for "${inputRoomName}" on ${inputHs}`, + error: inputRoomName === '' + ? `No public rooms on ${inputHs}` + : `No result found for "${inputRoomName}" on ${inputHs}`, alias: isInputAlias ? inputRoomName : null, }); } } catch (e) { updatePublicRooms([]); + let err = 'Something went wrong!'; + if (e?.httpStatus >= 400 && e?.httpStatus < 500) { + err = e.message; + } updateSearchQuery({ - error: 'Something went wrong!', + error: err, alias: isInputAlias ? inputRoomName : null, }); updateIsSearching(false); @@ -241,20 +247,12 @@ function PublicRooms({ isOpen, searchTerm, onRequestClose }) { ) } { - typeof searchQuery.name !== 'undefined' && !isSearching && publicRooms.length !== 0 && ( + typeof searchQuery.name !== 'undefined' && !isSearching && ( searchQuery.name === '' ? {`Public rooms on ${searchQuery.homeserver}.`} : {`Search result for "${searchQuery.name}" on ${searchQuery.homeserver}.`} ) } - { - typeof searchQuery.name !== 'undefined' && !isSearching && publicRooms.length === 0 - && ( -
- {`There are no public rooms on ${searchQuery.homeserver}.`} -
- ) - } { searchQuery.error && ( <> {searchQuery.error} From ea47750ea4afe57bf8327926e0edf620d8e092f4 Mon Sep 17 00:00:00 2001 From: Ajay Bura Date: Mon, 4 Oct 2021 10:58:28 +0530 Subject: [PATCH 09/12] Made ContextMenu animation little fast (#114) Signed-off-by: Ajay Bura --- src/app/atoms/context-menu/ContextMenu.jsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/app/atoms/context-menu/ContextMenu.jsx b/src/app/atoms/context-menu/ContextMenu.jsx index 023ee38b..69734518 100644 --- a/src/app/atoms/context-menu/ContextMenu.jsx +++ b/src/app/atoms/context-menu/ContextMenu.jsx @@ -31,6 +31,7 @@ function ContextMenu({ interactive arrow={false} maxWidth={maxWidth} + duration={200} > {render(isVisible ? hideMenu : showMenu)} From aefed73f5a8561d2a657ccf62a2411b24b3c6463 Mon Sep 17 00:00:00 2001 From: Ajay Bura Date: Mon, 4 Oct 2021 11:01:27 +0530 Subject: [PATCH 10/12] Revert dark theme color changes Signed-off-by: Ajay Bura --- src/index.scss | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/index.scss b/src/index.scss index f565170d..2b56022b 100644 --- a/src/index.scss +++ b/src/index.scss @@ -168,10 +168,10 @@ .dark-theme, .butter-theme { /* background color | --bg-[background type]: value */ - --bg-surface: hsl(208, 8%, 16%); - --bg-surface-transparent: hsla(208, 8%, 16%, 0); - --bg-surface-low: hsl(208, 8%, 12%); - --bg-surface-low-transparent: hsla(208, 8%, 12%, 0); + --bg-surface: hsl(208, 8%, 20%); + --bg-surface-transparent: hsla(208, 8%, 20%, 0); + --bg-surface-low: hsl(208, 8%, 16%); + --bg-surface-low-transparent: hsla(208, 8%, 16%, 0); --bg-surface-hover: rgba(255, 255, 255, 3%); --bg-surface-active: rgba(255, 255, 255, 5%); --bg-surface-border: rgba(0, 0, 0, 20%); From 808fc8dc0d8f7f6b142d0ccf9f719b24c3a6af82 Mon Sep 17 00:00:00 2001 From: Ajay Bura Date: Wed, 6 Oct 2021 12:35:51 +0530 Subject: [PATCH 11/12] Fix Password don't match on register page Signed-off-by: Ajay Bura --- src/app/templates/auth/Auth.jsx | 38 ++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/src/app/templates/auth/Auth.jsx b/src/app/templates/auth/Auth.jsx index cf4b51d7..3d97ca51 100644 --- a/src/app/templates/auth/Auth.jsx +++ b/src/app/templates/auth/Auth.jsx @@ -32,6 +32,7 @@ const EMAIL_REGEX = /([a-z0-9]+[_a-z0-9.-][a-z0-9]+)@([a-z0-9-]+(?:.[a-z0-9-]+). const BAD_EMAIL_ERROR = 'Invalid email address'; function isValidInput(value, regex) { + if (typeof regex === 'string') return regex === value; return regex.test(value); } function renderErrorMessage(error) { @@ -39,24 +40,25 @@ function renderErrorMessage(error) { $error.textContent = error; $error.style.display = 'block'; } -function showBadInputError($input, error) { +function showBadInputError($input, error, stopAutoFocus) { renderErrorMessage(error); - $input.focus(); + if (!stopAutoFocus) $input.focus(); const myInput = $input; myInput.style.border = '1px solid var(--bg-danger)'; myInput.style.boxShadow = 'none'; document.getElementById('auth_submit-btn').disabled = true; } -function validateOnChange(e, regex, error) { - if (!isValidInput(e.target.value, regex) && e.target.value) { - showBadInputError(e.target, error); - return; +function validateOnChange(targetInput, regex, error, stopAutoFocus) { + if (!isValidInput(targetInput.value, regex) && targetInput.value) { + showBadInputError(targetInput, error, stopAutoFocus); + return false; } document.getElementById('auth_error').style.display = 'none'; - e.target.style.removeProperty('border'); - e.target.style.removeProperty('box-shadow'); + targetInput.style.removeProperty('border'); + targetInput.style.removeProperty('box-shadow'); document.getElementById('auth_submit-btn').disabled = false; + return true; } /** @@ -195,8 +197,8 @@ function Auth({ type }) { (type === 'login' - ? validateOnChange(e, LOCALPART_LOGIN_REGEX, BAD_LOCALPART_ERROR) - : validateOnChange(e, LOCALPART_SIGNUP_REGEX, BAD_LOCALPART_ERROR))} + ? validateOnChange(e.target, LOCALPART_LOGIN_REGEX, BAD_LOCALPART_ERROR) + : validateOnChange(e.target, LOCALPART_SIGNUP_REGEX, BAD_LOCALPART_ERROR))} id="auth_username" label="Username" required @@ -212,7 +214,15 @@ function Auth({ type }) {
validateOnChange(e, ((type === 'login') ? PASSWORD_REGEX : PASSWORD_STRENGHT_REGEX), BAD_PASSWORD_ERROR)} + onChange={(e) => { + const isValidPass = validateOnChange(e.target, ((type === 'login') ? PASSWORD_REGEX : PASSWORD_STRENGHT_REGEX), BAD_PASSWORD_ERROR); + if (type === 'register' && isValidPass) { + validateOnChange( + confirmPasswordRef.current, passwordRef.current.value, + CONFIRM_PASSWORD_ERROR, true, + ); + } + }} id="auth_password" type="password" label="Password" @@ -233,7 +243,9 @@ function Auth({ type }) {
validateOnChange(e, new RegExp(`^(${passwordRef.current.value})$`), CONFIRM_PASSWORD_ERROR)} + onChange={(e) => { + validateOnChange(e.target, passwordRef.current.value, CONFIRM_PASSWORD_ERROR); + }} id="auth_confirmPassword" type="password" label="Confirm password" @@ -251,7 +263,7 @@ function Auth({ type }) {
validateOnChange(e, EMAIL_REGEX, BAD_EMAIL_ERROR)} + onChange={(e) => validateOnChange(e.target, EMAIL_REGEX, BAD_EMAIL_ERROR)} id="auth_email" type="email" label="Email" From 0ebda9d2247f52c9612242aa415e5da3ab2d9f7b Mon Sep 17 00:00:00 2001 From: Ajay Bura Date: Wed, 6 Oct 2021 12:42:48 +0530 Subject: [PATCH 12/12] v1.3.2 Signed-off-by: Ajay Bura --- package-lock.json | 2 +- package.json | 2 +- src/app/organisms/settings/Settings.jsx | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 43b60803..b4e48653 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "cinny", - "version": "1.3.1", + "version": "1.3.2", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index b62fc796..a5f99451 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cinny", - "version": "1.3.1", + "version": "1.3.2", "description": "Yet another matrix client", "main": "index.js", "engines": { diff --git a/src/app/organisms/settings/Settings.jsx b/src/app/organisms/settings/Settings.jsx index cda2f3ac..1917bd2f 100644 --- a/src/app/organisms/settings/Settings.jsx +++ b/src/app/organisms/settings/Settings.jsx @@ -104,7 +104,7 @@ function AboutSection() {
Cinny - v1.3.1 + v1.3.2 Yet another matrix client