Compare commits

..
Author SHA1 Message Date
Ajay Bura adf53caeff Fix crash in room without create state event 2022-05-12 13:19:34 +05:30
13 changed files with 658 additions and 743 deletions

No files matched your search

+1 -1
View File
@@ -21,7 +21,7 @@ jobs:
path: dist
retention-days: 1
- name: Get PR info
uses: actions/github-script@v6.1.0
uses: actions/github-script@v6.0.0
with:
script: |
var fs = require('fs');
+2 -2
View File
@@ -14,7 +14,7 @@ jobs:
# workflow_run action (https://github.com/actions/download-artifact/issues/60)
# so instead we get this mess:
- name: Download artifact
uses: actions/github-script@v6.1.0
uses: actions/github-script@v6.0.0
with:
script: |
var artifacts = await github.rest.actions.listWorkflowRunArtifacts({
@@ -48,7 +48,7 @@ jobs:
run: unzip -d dist previewbuild.zip && rm previewbuild.zip && unzip pr.json.zip && rm pr.json.zip
- name: Read PR Info
id: readctx
uses: actions/github-script@v6.1.0
uses: actions/github-script@v6.0.0
with:
script: |
var fs = require('fs');
+1 -1
View File
@@ -15,7 +15,7 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v3.0.2
- name: Build Docker image
uses: docker/build-push-action@v3.0.0
uses: docker/build-push-action@v2.10.0
with:
context: .
push: false
+3 -3
View File
@@ -46,17 +46,17 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v3.0.2
- name: Login to Docker Hub
uses: docker/login-action@v2.0.0
uses: docker/login-action@v1.14.1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4.0.1
uses: docker/metadata-action@v3.8.0
with:
images: ajbura/cinny
- name: Build and push Docker image
uses: docker/build-push-action@v3.0.0
uses: docker/build-push-action@v2.10.0
with:
context: .
push: true
-2
View File
@@ -26,8 +26,6 @@ A tarball of pre-compiled version of the app is provided with each [release](htt
You can serve the application with a webserver of your choosing by simply copying `dist/` directory to the webroot.
### Building from source
> We recommend using a version manager as versions change very quickly. You will likely need to switch
between multiple Node.js versions based on the needs of different projects you're working on. [NVM on windows](https://github.com/coreybutler/nvm-windows#installation--upgrades) on Windows and [nvm](https://github.com/nvm-sh/nvm) on Linux/macOS are pretty good choices. Also recommended nodejs version is 16.15.0 LTS.
Execute the following commands to compile the app from its source code:
+1 -2
View File
@@ -7,6 +7,5 @@
"kde.org",
"matrix.org",
"chat.mozilla.org"
],
"allowCustomHomeservers": true
]
}
+615 -650
View File
File diff suppressed because it is too large. Load diff
+10 -10
View File
@@ -1,11 +1,11 @@
{
"name": "cinny",
"version": "2.0.3",
"version": "2.0.0",
"description": "Yet another matrix client",
"main": "index.js",
"engines": {
"npm": ">=6.14.8 <8.5.5",
"node": ">=14.15.0 <17.9.0"
"npm": ">=6.14.11",
"node": ">=14.6.0"
},
"scripts": {
"start": "webpack serve --config ./webpack.dev.js --open",
@@ -16,7 +16,7 @@
"license": "MIT",
"dependencies": {
"@fontsource/inter": "^4.5.10",
"@fontsource/roboto": "^4.5.7",
"@fontsource/roboto": "^4.5.5",
"@matrix-org/olm": "https://gitlab.matrix.org/api/v4/projects/27/packages/npm/@matrix-org/olm/-/@matrix-org/olm-3.2.8.tgz",
"@tippyjs/react": "^4.2.6",
"babel-polyfill": "^6.26.0",
@@ -29,7 +29,7 @@
"html-react-parser": "^1.4.12",
"katex": "^0.15.3",
"linkifyjs": "^2.1.9",
"matrix-js-sdk": "^17.2.0",
"matrix-js-sdk": "^17.1.0",
"micromark": "^3.0.10",
"micromark-extension-gfm": "^2.0.1",
"micromark-extension-math": "^2.0.2",
@@ -49,9 +49,9 @@
"twemoji": "^14.0.2"
},
"devDependencies": {
"@babel/core": "^7.18.0",
"@babel/preset-env": "^7.18.0",
"@babel/preset-react": "^7.17.12",
"@babel/core": "^7.17.10",
"@babel/preset-env": "^7.17.10",
"@babel/preset-react": "^7.16.7",
"assert": "^2.0.0",
"babel-loader": "^8.2.5",
"browserify-fs": "^1.0.0",
@@ -61,7 +61,7 @@
"crypto-browserify": "^3.12.0",
"css-loader": "^6.7.1",
"css-minimizer-webpack-plugin": "^3.4.1",
"eslint": "^8.15.0",
"eslint": "^8.14.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jsx-a11y": "^6.4.1",
@@ -79,7 +79,7 @@
"style-loader": "^3.3.1",
"url": "^0.11.0",
"util": "^0.12.4",
"webpack": "^5.72.1",
"webpack": "^5.72.0",
"webpack-cli": "^4.9.2",
"webpack-dev-server": "^4.9.0",
"webpack-merge": "^5.7.3"
+2 -11
View File
@@ -123,26 +123,17 @@ const MessageReplyWrapper = React.memo(({ roomTimeline, eventId }) => {
const eTimeline = await mx.getEventTimeline(timelineSet, eventId);
await roomTimeline.decryptAllEventsOfTimeline(eTimeline);
let mEvent = eTimeline.getTimelineSet().findEventById(eventId);
const editedList = roomTimeline.editedTimeline.get(mEvent.getId());
if (editedList) {
mEvent = editedList[editedList.length - 1];
}
const mEvent = eTimeline.getTimelineSet().findEventById(eventId);
const rawBody = mEvent.getContent().body;
const username = getUsernameOfRoomMember(mEvent.sender);
if (isMountedRef.current === false) return;
const fallbackBody = mEvent.isRedacted() ? '*** This message has been deleted ***' : '*** Unable to load reply ***';
let parsedBody = parseReply(rawBody)?.body ?? rawBody ?? fallbackBody;
if (editedList && parsedBody.startsWith(' * ')) {
parsedBody = parsedBody.slice(3);
}
setReply({
to: username,
color: colorMXID(mEvent.getSender()),
body: parsedBody,
body: parseReply(rawBody)?.body ?? rawBody ?? fallbackBody,
event: mEvent,
});
} catch {
+5 -7
View File
@@ -93,13 +93,12 @@ function Homeserver({ onChange }) {
const result = await (await fetch(configFileUrl, { method: 'GET' })).json();
const selectedHs = result?.defaultHomeserver;
const hsList = result?.homeserverList;
const allowCustom = result?.allowCustomHomeservers ?? true;
if (!hsList?.length > 0 || selectedHs < 0 || selectedHs >= hsList?.length) {
throw new Error();
}
setHs({ selected: hsList[selectedHs], list: hsList, allowCustom: allowCustom });
setHs({ selected: hsList[selectedHs], list: hsList });
} catch {
setHs({ selected: 'matrix.org', list: ['matrix.org'], allowCustom: true });
setHs({ selected: 'matrix.org', list: ['matrix.org'] });
}
}, []);
@@ -107,15 +106,14 @@ function Homeserver({ onChange }) {
const { value } = e.target;
setProcess({ isLoading: false });
debounce._(async () => {
setHs({ ...hs, selected: value.trim() });
setHs({ selected: value.trim(), list: hs.list });
}, 700)();
};
return (
<>
<div className="homeserver-form">
<Input name="homeserver" onChange={handleHsInput} value={hs?.selected} forwardRef={hsRef} label="Homeserver"
disabled={hs === null || !hs.allowCustom} />
<Input name="homeserver" onChange={handleHsInput} value={hs?.selected} forwardRef={hsRef} label="Homeserver" />
<ContextMenu
placement="right"
content={(hideMenu) => (
@@ -128,7 +126,7 @@ function Homeserver({ onChange }) {
onClick={() => {
hideMenu();
hsRef.current.value = hsName;
setHs({ ...hs, selected: hsName });
setHs({ selected: hsName, list: hs.list });
}}
>
{hsName}
+15 -46
View File
@@ -2,60 +2,25 @@ import { openSearch, toggleRoomSettings } from '../action/navigation';
import navigation from '../state/navigation';
import { markAsRead } from '../action/notifications';
function shouldFocusMessageField(code) {
// do not focus on F keys
if (/^F\d+$/.test(code)) return false;
// do not focus on numlock/scroll lock
if (
code.metaKey
|| code.startsWith('OS')
|| code.startsWith('Meta')
|| code.startsWith('Shift')
|| code.startsWith('Alt')
|| code.startsWith('Control')
|| code.startsWith('Arrow')
|| code === 'Tab'
|| code === 'Space'
|| code === 'Enter'
|| code === 'NumLock'
|| code === 'ScrollLock'
) {
return false;
}
return true;
}
function listenKeyboard(event) {
// Ctrl/Cmd +
if (event.ctrlKey || event.metaKey) {
// open search modal
if (event.code === 'KeyK') {
// k - for search Modal
if (event.keyCode === 75) {
event.preventDefault();
if (navigation.isRawModalVisible) return;
openSearch();
}
// focus message field on paste
if (event.code === 'KeyV') {
if (navigation.isRawModalVisible) return;
const msgTextarea = document.getElementById('message-textarea');
const { activeElement } = document;
if (activeElement !== msgTextarea
&& ['input', 'textarea'].includes(activeElement.tagName.toLowerCase())
) return;
msgTextarea?.focus();
}
}
if (!event.ctrlKey && !event.altKey && !event.metaKey) {
if (!event.ctrlKey && !event.altKey) {
if (navigation.isRawModalVisible) return;
if (['input', 'textarea'].includes(document.activeElement.tagName.toLowerCase())) {
if (['text', 'textarea'].includes(document.activeElement.type)) {
return;
}
if (event.code === 'Escape') {
// esc
if (event.keyCode === 27) {
if (navigation.isRoomSettings) {
toggleRoomSettings();
return;
@@ -66,12 +31,16 @@ function listenKeyboard(event) {
}
}
// focus the text field on most keypresses
if (shouldFocusMessageField(event.code)) {
// press any key to focus and type in message field
const msgTextarea = document.getElementById('message-textarea');
msgTextarea?.focus();
// Don't allow these keys to type/focus message field
if ((event.keyCode !== 8 && event.keyCode < 48)
|| (event.keyCode >= 91 && event.keyCode <= 93)
|| (event.keyCode >= 112 && event.keyCode <= 183)) {
return;
}
// press any key to focus and type in message field
const msgTextarea = document.getElementById('message-textarea');
msgTextarea?.focus();
}
}
+1 -1
View File
@@ -1,5 +1,5 @@
const cons = {
version: '2.0.3',
version: '2.0.0',
secretKey: {
ACCESS_TOKEN: 'cinny_access_token',
DEVICE_ID: 'cinny_device_id',
+2 -7
View File
@@ -14,7 +14,7 @@ class Navigation extends EventEmitter {
this.isRoomSettings = false;
this.recentRooms = [];
this.rawModelStack = [];
this.isRawModalVisible = false;
}
_setSpacePath(roomId) {
@@ -47,13 +47,8 @@ class Navigation extends EventEmitter {
}
}
get isRawModalVisible() {
return this.rawModelStack.length > 0;
}
setIsRawModalVisible(visible) {
if (visible) this.rawModelStack.push(true);
else this.rawModelStack.pop();
this.isRawModalVisible = visible;
}
navigate(action) {