Skip to content

Commit 179f872

Browse files
committed
fix: disable typing and message request on sogs without write
1 parent 336baf6 commit 179f872

File tree

6 files changed

+34
-6
lines changed

6 files changed

+34
-6
lines changed

stylesheets/_session.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ textarea {
7979
overflow: hidden;
8080
outline: none;
8181
color: $textAndBorderColor;
82-
border: 2px solid $textAndBorderColor;
82+
border: 1px solid $textAndBorderColor;
8383
}
8484

8585
width: auto;

ts/components/conversation/TypingAnimation.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const StyledTypingContainer = styled.div`
1414

1515
const StyledTypingDot = styled.div<{ index: number }>`
1616
border-radius: 50%;
17-
background-color: var(--color-text-subtle); // TODO Theming update
17+
background-color: var(--color-text-subtle); // TODO Theming update
1818
1919
height: 6px;
2020
width: 6px;

ts/components/conversation/message/message-content/MessageAvatar.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { PubKey } from '../../../../session/types';
99
import { openConversationWithMessages } from '../../../../state/ducks/conversations';
1010
import { updateUserDetailsModal } from '../../../../state/ducks/modalDialog';
1111
import {
12+
getIsTypingEnabled,
1213
getMessageAvatarProps,
1314
getSelectedConversationKey,
1415
} from '../../../../state/selectors/conversations';
@@ -37,6 +38,8 @@ export const MessageAvatar = (props: Props) => {
3738
const avatarProps = useSelector(state => getMessageAvatarProps(state as any, messageId));
3839
const selectedConvoKey = useSelector(getSelectedConversationKey);
3940

41+
const isTypingEnabled = useSelector(getIsTypingEnabled);
42+
4043
if (!avatarProps) {
4144
return null;
4245
}
@@ -75,6 +78,11 @@ export const MessageAvatar = (props: Props) => {
7578
}
7679
}
7780

81+
if (isPublic && !isTypingEnabled) {
82+
window.log.info('onMessageAvatarClick: no typing enabled. Dropping...');
83+
return;
84+
}
85+
7886
if (isPublic && selectedConvoKey) {
7987
const convoOpen = getConversationController().get(selectedConvoKey);
8088
const room = OpenGroupData.getV2OpenGroupRoom(convoOpen.id);

ts/models/conversation.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,23 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
416416
toRet.currentNotificationSetting = currentNotificationSetting;
417417
}
418418

419+
if (this.isOpenGroupV2()) {
420+
const room = OpenGroupData.getV2OpenGroupRoom(this.id);
421+
if (room && isArray(room.capabilities) && room.capabilities.length) {
422+
toRet.capabilities = room.capabilities;
423+
}
424+
425+
if (this.get('writeCapability')) {
426+
toRet.writeCapability = this.get('writeCapability');
427+
}
428+
if (this.get('readCapability')) {
429+
toRet.readCapability = this.get('readCapability');
430+
}
431+
if (this.get('uploadCapability')) {
432+
toRet.uploadCapability = this.get('uploadCapability');
433+
}
434+
}
435+
419436
const lastMessageText = this.get('lastMessage');
420437
if (lastMessageText && lastMessageText.length) {
421438
const lastMessageStatus = this.get('lastMessageStatus');

ts/state/ducks/conversations.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,11 @@ export interface ReduxConversationType {
268268
isApproved?: boolean;
269269
didApproveMe?: boolean;
270270

271-
/** Should only be present on open groups - the key (stored as hex) that should be used when sending messages to an open group */
272-
blindedPublicKey?: string;
271+
// Should only be present on opengroups - the capabilities we have on this room.
272+
capabilities?: Array<string>;
273+
readCapability?: boolean;
274+
writeCapability?: boolean;
275+
uploadCapability?: boolean;
273276
}
274277

275278
export interface NotificationForConvoOption {

ts/state/selectors/conversations.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,9 @@ export const getIsTypingEnabled = createSelector(
8585
if (!selectedConvo) {
8686
return false;
8787
}
88-
const { isBlocked, isKickedFromGroup, left } = selectedConvo;
88+
const { isBlocked, isKickedFromGroup, left, isPublic, writeCapability } = selectedConvo;
8989

90-
return !(isBlocked || isKickedFromGroup || left);
90+
return !(isBlocked || isKickedFromGroup || left || (isPublic && !writeCapability));
9191
}
9292
);
9393
/**

0 commit comments

Comments
 (0)