Browse Source

Fix chat context menu rights

master
morethanwords 4 years ago
parent
commit
a7a5400c3e
  1. 13
      src/components/chat/contextMenu.ts
  2. 14
      src/lib/appManagers/appChatsManager.ts
  3. 36
      src/lib/appManagers/appDialogsManager.ts
  4. 1
      src/lib/appManagers/appMessagesManager.ts

13
src/components/chat/contextMenu.ts

@ -2,11 +2,11 @@ import appChatsManager from "../../lib/appManagers/appChatsManager";
import appImManager from "../../lib/appManagers/appImManager"; import appImManager from "../../lib/appManagers/appImManager";
import appMessagesManager from "../../lib/appManagers/appMessagesManager"; import appMessagesManager from "../../lib/appManagers/appMessagesManager";
import appPeersManager from "../../lib/appManagers/appPeersManager"; import appPeersManager from "../../lib/appManagers/appPeersManager";
import appSidebarRight from "../sidebarRight";
import $rootScope from "../../lib/rootScope"; import $rootScope from "../../lib/rootScope";
import { findUpClassName } from "../../lib/utils"; import { findUpClassName } from "../../lib/utils";
import { parseMenuButtonsTo, attachContextMenuListener, positionMenu, openBtnMenu } from "../misc"; import { attachContextMenuListener, openBtnMenu, parseMenuButtonsTo, positionMenu } from "../misc";
import { PopupButton, PopupPeer } from "../popup"; import { PopupButton, PopupPeer } from "../popup";
import appSidebarRight from "../sidebarRight";
export class ChatContextMenu { export class ChatContextMenu {
private element = document.getElementById('bubble-contextmenu') as HTMLDivElement; private element = document.getElementById('bubble-contextmenu') as HTMLDivElement;
@ -50,13 +50,10 @@ export class ChatContextMenu {
this.buttons.copy.style.display = message.message ? '' : 'none'; this.buttons.copy.style.display = message.message ? '' : 'none';
if($rootScope.myID == peerID || (peerID < 0 && appChatsManager.hasRights(-peerID, 'pin'))) { this.buttons.pin.classList.toggle('hide', peerID < 0 && !appChatsManager.hasRights(-peerID, 'pin'));
this.buttons.pin.style.display = '';
} else {
this.buttons.pin.style.display = 'none';
}
this.buttons.edit.style.display = appMessagesManager.canEditMessage(msgID) ? '' : 'none'; this.buttons.edit.style.display = appMessagesManager.canEditMessage(msgID) ? '' : 'none';
this.buttons.reply.classList.toggle('hide', peerID < 0 && !appChatsManager.hasRights(-peerID, 'send'));
this.buttons.delete.classList.toggle('hide', peerID < 0 && appPeersManager.isBroadcast(peerID) && !appChatsManager.hasRights(-peerID, 'deleteRevoke'));
let side: 'left' | 'right' = bubble.classList.contains('is-in') ? 'left' : 'right'; let side: 'left' | 'right' = bubble.classList.contains('is-in') ? 'left' : 'right';
positionMenu(e, this.element, side); positionMenu(e, this.element, side);

14
src/lib/appManagers/appChatsManager.ts

@ -1,12 +1,12 @@
import { isObject, safeReplaceObject, copy, numberWithCommas, getAbbreviation } from "../utils"; import { InputChannel, InputChatPhoto, InputPeer, Updates } from "../../layer";
import { RichTextProcessor } from "../richtextprocessor";
import appUsersManager from "./appUsersManager";
import apiManager from '../mtproto/mtprotoworker'; import apiManager from '../mtproto/mtprotoworker';
import { RichTextProcessor } from "../richtextprocessor";
import $rootScope from "../rootScope";
import searchIndexManager from "../searchIndexManager";
import { copy, getAbbreviation, isObject, numberWithCommas, safeReplaceObject } from "../utils";
import apiUpdatesManager from "./apiUpdatesManager"; import apiUpdatesManager from "./apiUpdatesManager";
import appProfileManager from "./appProfileManager"; import appProfileManager from "./appProfileManager";
import searchIndexManager from "../searchIndexManager"; import appUsersManager from "./appUsersManager";
import { InputPeer, InputChannel, Updates, InputChatPhoto } from "../../layer";
import $rootScope from "../rootScope";
export type Channel = { export type Channel = {
_: 'channel', _: 'channel',
@ -194,7 +194,7 @@ export class AppChatsManager {
// good // good
case 'pin': { case 'pin': {
if(chat._ == 'channel') { if(chat._ == 'channel') {
return chat.admin_rights ? !!myFlags.pin_messages || !!myFlags.post_messages : !myFlags.pin_messages; return chat.admin_rights ? !!myFlags.pin_messages || !!myFlags.post_messages : !!myFlags.pin_messages;
} else { } else {
if(myFlags.pin_messages && !chat.pFlags.admin) { if(myFlags.pin_messages && !chat.pFlags.admin) {
return false; return false;

36
src/lib/appManagers/appDialogsManager.ts

@ -1,24 +1,24 @@
import { findUpClassName, escapeRegExp, cancelEvent, positionElementByIndex } from "../utils";
import appImManager, { AppImManager } from "./appImManager";
import appPeersManager from './appPeersManager';
import appMessagesManager, { Dialog, MyDialogFilter as DialogFilter } from "./appMessagesManager";
import appUsersManager, { User } from "./appUsersManager";
import { RichTextProcessor } from "../richtextprocessor";
import { putPreloader, attachContextMenuListener } from "../../components/misc";
//import Scrollable from "../../components/scrollable";
import Scrollable, { ScrollableX } from "../../components/scrollable";
import { logger, LogLevels } from "../logger";
import appChatsManager from "./appChatsManager";
import AvatarElement from "../../components/avatar"; import AvatarElement from "../../components/avatar";
import appStateManager from "./appStateManager"; import DialogsContextMenu from "../../components/dialogsContextMenu";
import { horizontalMenu } from "../../components/horizontalMenu"; import { horizontalMenu } from "../../components/horizontalMenu";
import { attachContextMenuListener, putPreloader } from "../../components/misc";
import { ripple } from "../../components/ripple"; import { ripple } from "../../components/ripple";
import { isSafari } from "../../helpers/userAgent"; //import Scrollable from "../../components/scrollable";
import Scrollable, { ScrollableX } from "../../components/scrollable";
import appSidebarLeft from "../../components/sidebarLeft";
import { formatDateAccordingToToday } from "../../helpers/date"; import { formatDateAccordingToToday } from "../../helpers/date";
import $rootScope from "../rootScope";
import { isTouchSupported } from "../../helpers/touchSupport"; import { isTouchSupported } from "../../helpers/touchSupport";
import DialogsContextMenu from "../../components/dialogsContextMenu"; import { isSafari } from "../../helpers/userAgent";
import appSidebarLeft from "../../components/sidebarLeft"; import { logger, LogLevels } from "../logger";
import { RichTextProcessor } from "../richtextprocessor";
import $rootScope from "../rootScope";
import { cancelEvent, escapeRegExp, findUpClassName, positionElementByIndex } from "../utils";
import appChatsManager from "./appChatsManager";
import appImManager, { AppImManager } from "./appImManager";
import appMessagesManager, { Dialog, MyDialogFilter as DialogFilter } from "./appMessagesManager";
import appPeersManager from './appPeersManager';
import appStateManager from "./appStateManager";
import appUsersManager, { User } from "./appUsersManager";
type DialogDom = { type DialogDom = {
avatarEl: AvatarElement, avatarEl: AvatarElement,
@ -742,8 +742,8 @@ export class AppDialogsManager {
const lastMessage = appMessagesManager.getMessage(dialog.top_message); const lastMessage = appMessagesManager.getMessage(dialog.top_message);
if(lastMessage._ != 'messageEmpty' && !lastMessage.deleted && if(lastMessage._ != 'messageEmpty' && !lastMessage.deleted &&
lastMessage.fromID == $rootScope.myID && lastMessage.peerID != $rootScope.myID && lastMessage.fromID == $rootScope.myID && lastMessage.peerID != $rootScope.myID/* &&
dialog.read_outbox_max_id) { // maybe comment, 06.20.2020 dialog.read_outbox_max_id */) { // maybe comment, 06.20.2020
const outgoing = (lastMessage.pFlags && lastMessage.pFlags.unread) const outgoing = (lastMessage.pFlags && lastMessage.pFlags.unread)
/* && dialog.read_outbox_max_id != 0 */; // maybe uncomment, 31.01.2020 /* && dialog.read_outbox_max_id != 0 */; // maybe uncomment, 31.01.2020

1
src/lib/appManagers/appMessagesManager.ts

@ -1054,6 +1054,7 @@ export class AppMessagesManager {
flags |= 1 << 10; flags |= 1 << 10;
flags |= 1 << 2; flags |= 1 << 2;
attachType = 'voice'; attachType = 'voice';
pFlags.media_unread = true;
} }
let attribute: DocumentAttribute.documentAttributeAudio = { let attribute: DocumentAttribute.documentAttributeAudio = {

Loading…
Cancel
Save