## License
-Copyright (c) 2021 Ajay Bura (ajbura) and other contributors
+Copyright (c) 2021 Ajay Bura (ajbura) and contributors
Code licensed under the MIT License: <http://opensource.org/licenses/MIT>
import initMatrix from '../../../client/initMatrix';
import cons from '../../../client/state/cons';
import { redactEvent, sendReaction } from '../../../client/action/roomTimeline';
-import { getUsername, getUsernameOfRoomMember, doesRoomHaveUnread } from '../../../util/matrixUtil';
+import { getUsername, getUsernameOfRoomMember } from '../../../util/matrixUtil';
import colorMXID from '../../../util/colorMXID';
import { diffMinutes, isNotInSameDay, getEventCords } from '../../../util/common';
import { openEmojiBoard, openProfileViewer, openReadReceipts } from '../../../client/action/navigation';
const [onPagination, setOnPagination] = useState(null);
const [editEvent, setEditEvent] = useState(null);
const mx = initMatrix.matrixClient;
+ const noti = initMatrix.notifications;
function autoLoadTimeline() {
if (timelineScroll.isScrollable() === true) return;
function trySendingReadReceipt() {
const { room, timeline } = roomTimeline;
if (
- (doesRoomHaveUnread(room) || initMatrix.notifications.hasNoti(roomId))
+ (noti.doesRoomHaveUnread(room) || noti.hasNoti(roomId))
&& timeline.length !== 0) {
mx.sendReadReceipt(timeline[timeline.length - 1]);
}
}).catch((err) => {
const msg = err.message || err.error;
if (['M_USER_IN_USE', 'M_INVALID_USERNAME', 'M_EXCLUSIVE'].indexOf(err.errcode) > -1) {
- actions.setErrors({ username: err.errCode === 'M_USER_IN_USE' ? 'Username is already taken' : msg });
+ actions.setErrors({ username: err.errcode === 'M_USER_IN_USE' ? 'Username is already taken' : msg });
} else if (msg) actions.setErrors({ other: msg });
actions.setSubmitting(false);
sessionStore: new sdk.WebStorageSessionStore(global.localStorage),
cryptoStore: new sdk.IndexedDBCryptoStore(global.indexedDB, 'crypto-store'),
deviceId: secret.deviceId,
+ timelineSupport: true,
});
await this.matrixClient.initCrypto();
overflow: visible;
-webkit-appearance: button;
}
-textarea, input[type="text"] {
+textarea,
+input,
+input[type=text]
+input[type=username]
+input[type=password]
+input[type=email] {
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
}
}
-function doesRoomHaveUnread(room) {
- const userId = initMatrix.matrixClient.getUserId();
- const readUpToId = room.getEventReadUpTo(userId);
- const supportEvents = ['m.room.message', 'm.room.encrypted', 'm.sticker'];
-
- if (room.timeline.length
- && room.timeline[room.timeline.length - 1].sender
- && room.timeline[room.timeline.length - 1].sender.userId === userId
- && room.timeline[room.timeline.length - 1].getType() !== 'm.room.member') {
- return false;
- }
-
- for (let i = room.timeline.length - 1; i >= 0; i -= 1) {
- const event = room.timeline[i];
-
- if (event.getId() === readUpToId) return false;
-
- if (supportEvents.includes(event.getType())) {
- return true;
- }
- }
- return true;
-}
-
function getPowerLabel(powerLevel) {
if (powerLevel > 9000) return 'Goku';
if (powerLevel > 100) return 'Founder';
export {
getBaseUrl, getUsername, getUsernameOfRoomMember,
- isRoomAliasAvailable, doesRoomHaveUnread, getPowerLabel,
+ isRoomAliasAvailable, getPowerLabel,
};