Browse Source

Fake & scam badge

master
Eduard Kuzmenko 3 years ago
parent
commit
fea9019d8e
  1. 8
      src/components/chat/topbar.ts
  2. 8
      src/components/generateFakeIcon.ts
  3. 18
      src/components/generateTitleIcons.ts
  4. 7
      src/components/peerProfile.ts
  5. 2
      src/lang.ts
  6. 9
      src/lib/appManagers/appDialogsManager.ts
  7. 5
      src/scss/partials/_chatlist.scss
  8. 4
      src/scss/partials/_profile.scss
  9. 11
      src/scss/style.scss

8
src/components/chat/topbar.ts

@ -41,15 +41,14 @@ import replaceContent from "../../helpers/dom/replaceContent"; @@ -41,15 +41,14 @@ import replaceContent from "../../helpers/dom/replaceContent";
import { ChatFull, Chat as MTChat, GroupCall } from "../../layer";
import PopupPickUser from "../popups/pickUser";
import PopupPeer from "../popups/peer";
import generateVerifiedIcon from "../generateVerifiedIcon";
import { fastRaf } from "../../helpers/schedulers";
import AppEditContactTab from "../sidebarRight/tabs/editContact";
import appMediaPlaybackController from "../appMediaPlaybackController";
import { NULL_PEER_ID } from "../../lib/mtproto/mtproto_config";
import IS_GROUP_CALL_SUPPORTED from "../../environment/groupCallSupport";
import IS_CALL_SUPPORTED from "../../environment/callSupport";
import { CallType } from "../../lib/calls/types";
import PopupMute from "../popups/mute";
import generateTitleIcons from "../generateTitleIcons";
type ButtonToVerify = {element?: HTMLElement, verify: () => boolean};
@ -809,10 +808,7 @@ export default class ChatTopbar { @@ -809,10 +808,7 @@ export default class ChatTopbar {
replaceContent(this.title, titleEl);
if(this.chat.type === 'chat') {
const peer = this.appPeersManager.getPeer(this.peerId);
if(peer?.pFlags?.verified) {
this.title.append(generateVerifiedIcon());
}
this.title.append(...generateTitleIcons(this.peerId));
}
}

8
src/components/generateFakeIcon.ts

@ -0,0 +1,8 @@ @@ -0,0 +1,8 @@
import { _i18n } from "../lib/langPack";
export default function generateFakeIcon(isScam?: boolean) {
const span = document.createElement('span');
span.classList.add('badge-fake');
_i18n(span, isScam ? 'ScamMessage' : 'FakeMessage');
return span;
}

18
src/components/generateTitleIcons.ts

@ -0,0 +1,18 @@ @@ -0,0 +1,18 @@
import { Chat, User } from "../layer";
import appPeersManager from "../lib/appManagers/appPeersManager";
import generateFakeIcon from "./generateFakeIcon";
import generateVerifiedIcon from "./generateVerifiedIcon";
export default function generateTitleIcons(peerId: PeerId) {
const elements: Element[] = [];
const peer = appPeersManager.getPeer(peerId);
if(peer?.pFlags?.verified) {
elements.push(generateVerifiedIcon());
}
if((peer as Chat.channel).pFlags.fake || (peer as User.user).pFlags.scam) {
elements.push(generateFakeIcon((peer as User.user).pFlags.scam));
}
return elements;
}

7
src/components/peerProfile.ts

@ -23,7 +23,7 @@ import RichTextProcessor from "../lib/richtextprocessor"; @@ -23,7 +23,7 @@ import RichTextProcessor from "../lib/richtextprocessor";
import rootScope from "../lib/rootScope";
import AvatarElement from "./avatar";
import CheckboxField from "./checkboxField";
import generateVerifiedIcon from "./generateVerifiedIcon";
import generateTitleIcons from "./generateTitleIcons";
import PeerProfileAvatars from "./peerProfileAvatars";
import PeerTitle from "./peerTitle";
import Row from "./row";
@ -357,10 +357,7 @@ export default class PeerProfile { @@ -357,10 +357,7 @@ export default class PeerProfile {
dialog: this.isDialog,
}).element);
const peer = appPeersManager.getPeer(peerId);
if(peer?.pFlags?.verified) {
this.name.append(generateVerifiedIcon());
}
this.name.append(...generateTitleIcons(peerId));
this.setPeerStatus(true);
}

2
src/lang.ts

@ -690,6 +690,8 @@ const lang = { @@ -690,6 +690,8 @@ const lang = {
"ReportChatPersonalDetails": "Personal Details",
"VoipPeerIncompatible": "**%1$s**'s app is using an incompatible protocol. They need to update their app before you can call them.",
"TelegramFeaturesUrl": "https://t.me/TelegramTips",
"ScamMessage": "SCAM",
"FakeMessage": "FAKE",
// * macos
"AccountSettings.Filters": "Chat Folders",

9
src/lib/appManagers/appDialogsManager.ts

@ -23,7 +23,7 @@ import appPeersManager from './appPeersManager'; @@ -23,7 +23,7 @@ import appPeersManager from './appPeersManager';
import appImManager from "./appImManager";
import appMessagesManager, { Dialog, MyMessage } from "./appMessagesManager";
import appStateManager, { State } from "./appStateManager";
import appUsersManager from "./appUsersManager";
import appUsersManager, { User } from "./appUsersManager";
import Button from "../../components/button";
import SetTransition from "../../components/singleTransition";
import appDraftsManager, { MyDraftMessage } from "./appDraftsManager";
@ -53,7 +53,6 @@ import { MyDocument } from "./appDocsManager"; @@ -53,7 +53,6 @@ import { MyDocument } from "./appDocsManager";
import { setSendingStatus } from "../../components/sendingStatus";
import SortedList, { SortedElementBase } from "../../helpers/sortedList";
import debounce from "../../helpers/schedulers/debounce";
import generateVerifiedIcon from "../../components/generateVerifiedIcon";
import { NULL_PEER_ID } from "../mtproto/mtproto_config";
import groupCallActiveIcon from "../../components/groupCallActiveIcon";
import { Chat, NotifyPeer } from "../../layer";
@ -61,6 +60,7 @@ import IS_GROUP_CALL_SUPPORTED from "../../environment/groupCallSupport"; @@ -61,6 +60,7 @@ import IS_GROUP_CALL_SUPPORTED from "../../environment/groupCallSupport";
import mediaSizes from "../../helpers/mediaSizes";
import appNavigationController, { NavigationItem } from "../../components/appNavigationController";
import assumeType from "../../helpers/assumeType";
import generateTitleIcons from "../../components/generateTitleIcons";
export type DialogDom = {
avatarEl: AvatarElement,
@ -1851,10 +1851,7 @@ export class AppDialogsManager { @@ -1851,10 +1851,7 @@ export class AppDialogsManager {
// for muted icon
titleSpanContainer.classList.add('tgico'); // * эта строка будет актуальна только для !container, но ладно
const peer = appPeersManager.getPeer(peerId);
if(peer?.pFlags?.verified) {
titleSpanContainer.append(generateVerifiedIcon());
}
titleSpanContainer.append(...generateTitleIcons(peerId));
//}
const span = document.createElement('span');

5
src/scss/partials/_chatlist.scss

@ -269,6 +269,11 @@ ul.chatlist { @@ -269,6 +269,11 @@ ul.chatlist {
color: #fff;
}
.badge-fake {
color: #fff;
border-color: #fff;
}
b {
color: #fff !important;
}

4
src/scss/partials/_profile.scss

@ -309,6 +309,10 @@ @@ -309,6 +309,10 @@
.sidebar-left-section-content > & {
justify-content: center;
}
.badge-fake {
align-self: center;
}
}
&-subtitle {

11
src/scss/style.scss

@ -1608,6 +1608,17 @@ hr { @@ -1608,6 +1608,17 @@ hr {
margin-left: .125rem;
}
.badge-fake {
color: var(--danger-color);
border: 1px solid var(--danger-color);
padding: .125rem .25rem;
border-radius: .185rem;
font-size: .625rem;
font-weight: 500;
line-height: 1 !important;
margin: 0 .25rem;
}
.movable-element {
--size: .5rem;
position: relative;

Loading…
Cancel
Save