Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Remove dead code (#9035)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonBrandner committed Jul 11, 2022
1 parent d1928d2 commit 19e514d
Show file tree
Hide file tree
Showing 28 changed files with 6 additions and 412 deletions.
27 changes: 0 additions & 27 deletions src/HtmlUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,33 +109,6 @@ export function unicodeToShortcode(char: string): string {
return shortcodes?.length ? `:${shortcodes[0]}:` : '';
}

export function processHtmlForSending(html: string): string {
const contentDiv = document.createElement('div');
contentDiv.innerHTML = html;

if (contentDiv.children.length === 0) {
return contentDiv.innerHTML;
}

let contentHTML = "";
for (let i = 0; i < contentDiv.children.length; i++) {
const element = contentDiv.children[i];
if (element.tagName.toLowerCase() === 'p') {
contentHTML += element.innerHTML;
// Don't add a <br /> for the last <p>
if (i !== contentDiv.children.length - 1) {
contentHTML += '<br />';
}
} else {
const temp = document.createElement('div');
temp.appendChild(element.cloneNode(true));
contentHTML += temp.innerHTML;
}
}

return contentHTML;
}

/*
* Given an untrusted HTML string, return a React node with an sanitized version
* of that HTML.
Expand Down
8 changes: 0 additions & 8 deletions src/Keyboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,3 @@ export function isOnlyCtrlOrCmdKeyEvent(ev) {
return ev.ctrlKey && !ev.altKey && !ev.metaKey && !ev.shiftKey;
}
}

export function isOnlyCtrlOrCmdIgnoreShiftKeyEvent(ev) {
if (IS_MAC) {
return ev.metaKey && !ev.altKey && !ev.ctrlKey;
} else {
return ev.ctrlKey && !ev.altKey && !ev.metaKey;
}
}
32 changes: 0 additions & 32 deletions src/RoomNotifs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,38 +35,6 @@ export enum RoomNotifState {
Mute = 'mute',
}

export const BADGE_STATES = [RoomNotifState.AllMessages, RoomNotifState.AllMessagesLoud];
export const MENTION_BADGE_STATES = [...BADGE_STATES, RoomNotifState.MentionsOnly];

export function shouldShowNotifBadge(roomNotifState: RoomNotifState): boolean {
return BADGE_STATES.includes(roomNotifState);
}

export function shouldShowMentionBadge(roomNotifState: RoomNotifState): boolean {
return MENTION_BADGE_STATES.includes(roomNotifState);
}

export function aggregateNotificationCount(rooms: Room[]): {count: number, highlight: boolean} {
return rooms.reduce<{count: number, highlight: boolean}>((result, room) => {
const roomNotifState = getRoomNotifsState(room.roomId);
const highlight = room.getUnreadNotificationCount(NotificationCountType.Highlight) > 0;
// use helper method to include highlights in the previous version of the room
const notificationCount = getUnreadNotificationCount(room);

const notifBadges = notificationCount > 0 && shouldShowNotifBadge(roomNotifState);
const mentionBadges = highlight && shouldShowMentionBadge(roomNotifState);
const badges = notifBadges || mentionBadges;

if (badges) {
result.count += notificationCount;
if (highlight) {
result.highlight = true;
}
}
return result;
}, { count: 0, highlight: false });
}

export function getRoomNotifsState(roomId: string): RoomNotifState {
if (MatrixClientPeg.get().isGuest()) return RoomNotifState.AllMessages;

Expand Down
19 changes: 0 additions & 19 deletions src/Rooms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,25 +44,6 @@ export function getDisplayAliasForAliasSet(canonicalAlias: string, altAliases: s
return canonicalAlias || altAliases?.[0];
}

export function looksLikeDirectMessageRoom(room: Room, myUserId: string): boolean {
const myMembership = room.getMyMembership();
const me = room.getMember(myUserId);

if (myMembership == "join" || myMembership === "ban" || (me && me.isKicked())) {
// Used to split rooms via tags
const tagNames = Object.keys(room.tags);
// Used for 1:1 direct messages
// Show 1:1 chats in separate "Direct Messages" section as long as they haven't
// been moved to a different tag section
const totalMemberCount = room.currentState.getJoinedMemberCount() +
room.currentState.getInvitedMemberCount();
if (totalMemberCount === 2 && !tagNames.length) {
return true;
}
}
return false;
}

export function guessAndSetDMRoom(room: Room, isDirect: boolean): Promise<void> {
let newTarget;
if (isDirect) {
Expand Down
4 changes: 0 additions & 4 deletions src/ScalarMessaging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,3 @@ export function stopListening(): void {
logger.error(e);
}
}

export function setOpenManagerUrl(url: string): void {
openManagerUrl = url;
}
18 changes: 0 additions & 18 deletions src/UserAddress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,6 @@ export enum AddressType {
MatrixRoomId = "mx-room-id",
}

export const addressTypes = [AddressType.Email, AddressType.MatrixRoomId, AddressType.MatrixUserId];

// PropType definition for an object describing
// an address that can be invited to a room (which
// could be a third party identifier or a matrix ID)
// along with some additional information about the
// address / target.
export interface IUserAddress {
addressType: AddressType;
address: string;
displayName?: string;
avatarMxc?: string;
// true if the address is known to be a valid address (eg. is a real
// user we've seen) or false otherwise (eg. is just an address the
// user has entered)
isKnown?: boolean;
}

export function getAddressType(inputText: string): AddressType | null {
if (emailRegex.test(inputText)) {
return AddressType.Email;
Expand Down
1 change: 0 additions & 1 deletion src/components/structures/ContextMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,6 @@ export function createMenu(ElementClass, props) {
// re-export the semantic helper components for simplicity
export { ContextMenuButton } from "../../accessibility/context_menu/ContextMenuButton";
export { ContextMenuTooltipButton } from "../../accessibility/context_menu/ContextMenuTooltipButton";
export { MenuGroup } from "../../accessibility/context_menu/MenuGroup";
export { MenuItem } from "../../accessibility/context_menu/MenuItem";
export { MenuItemCheckbox } from "../../accessibility/context_menu/MenuItemCheckbox";
export { MenuItemRadio } from "../../accessibility/context_menu/MenuItemRadio";
Expand Down
4 changes: 1 addition & 3 deletions src/components/views/dialogs/AnalyticsLearnMoreDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ interface IProps {
hasCancel?: boolean;
}

const AnalyticsLearnMoreDialog: React.FC<IProps> = ({
export const AnalyticsLearnMoreDialog: React.FC<IProps> = ({
onFinished,
analyticsOwner,
privacyPolicyUrl,
Expand Down Expand Up @@ -105,5 +105,3 @@ export const showDialog = (props: Omit<IProps, "cookiePolicyUrl" | "analyticsOwn
...props,
}, "mx_AnalyticsLearnMoreDialog_wrapper");
};

export default AnalyticsLearnMoreDialog;
13 changes: 0 additions & 13 deletions src/components/views/location/shareLocation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,3 @@ export const shareLocation = (
handleShareError(error, openMenu, shareType);
}
};

export function textForLocation(
uri: string,
ts: number,
description: string | null,
): string {
const date = new Date(ts).toISOString();
if (description) {
return `Location "${description}" ${uri} at ${date}`;
} else {
return `Location ${uri} at ${date}`;
}
}
2 changes: 0 additions & 2 deletions src/components/views/rooms/CollapsibleButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,3 @@ export const CollapsibleButton = ({ title, children, className, iconClassName, .
{ children }
</AccessibleTooltipButton>;
};

export default CollapsibleButton;
2 changes: 0 additions & 2 deletions src/components/views/settings/KeyboardShortcut.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,3 @@ export const KeyboardShortcut: React.FC<IKeyboardShortcutProps> = ({ value }) =>
<KeyboardKey name={value.key} last />
</div>;
};

export default KeyboardShortcut;
2 changes: 0 additions & 2 deletions src/components/views/spaces/SpaceTreeLevel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -371,5 +371,3 @@ const SpaceTreeLevel: React.FC<ITreeLevelProps> = ({
}) }
</ul>;
};

export default SpaceTreeLevel;
10 changes: 0 additions & 10 deletions src/effects/ICanvasEffect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,6 @@
See the License for the specific language governing permissions and
limitations under the License.
*/
/**
* Defines the constructor of a canvas based room effect
*/
export interface ICanvasEffectConstructable {
/**
* @param {{[key:string]:any}} options? Optional animation options
* @returns ICanvasEffect Returns a new instance of the canvas effect
*/
new(options?: { [key: string]: any }): ICanvasEffect;
}

/**
* Defines the interface of a canvas based room effect
Expand Down
19 changes: 0 additions & 19 deletions src/events/forward/types.ts

This file was deleted.

19 changes: 0 additions & 19 deletions src/events/types.ts

This file was deleted.

6 changes: 0 additions & 6 deletions src/linkify-matrix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import linkifyElement from 'linkify-element';
import linkifyString from 'linkify-string';
import { RoomMember } from 'matrix-js-sdk/src/models/room-member';

import { baseUrl } from "./utils/permalinks/MatrixToPermalinkConstructor";
import {
parsePermalink,
tryTransformEntityToPermalink,
Expand Down Expand Up @@ -144,11 +143,6 @@ export const ELEMENT_URL_PATTERN =
"(?:app|beta|staging|develop)\\.element\\.io/" +
")(#.*)";

export const MATRIXTO_URL_PATTERN = "^(?:https?://)?(?:www\\.)?matrix\\.to/#/(([#@!+]).*)";
export const MATRIXTO_MD_LINK_PATTERN =
'\\[([^\\]]*)\\]\\((?:https?://)?(?:www\\.)?matrix\\.to/#/([#@!+][^\\)]*)\\)';
export const MATRIXTO_BASE_URL= baseUrl;

export const options = {
events: function(href: string, type: Type | string): Partial<GlobalEventHandlers> {
switch (type) {
Expand Down
3 changes: 0 additions & 3 deletions src/notifications/ContentRules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ export interface IContentRules {
externalRules: IAnnotatedPushRule[];
}

export const SCOPE = "global";
export const KIND = "content";

export class ContentRules {
/**
* Extract the keyword rules from a list of rules, and parse them
Expand Down
2 changes: 0 additions & 2 deletions src/settings/SettingsStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,6 @@ interface IHandlerMap {
[level: SettingLevel]: SettingsHandler;
}

export type LabsFeatureState = "labs" | "disable" | "enable" | string;

/**
* Controls and manages application settings by providing varying levels at which the
* setting value may be specified. The levels are then used to determine what the setting
Expand Down
9 changes: 0 additions & 9 deletions src/stores/room-list/previews/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@ export function isSelf(event: MatrixEvent): boolean {
return event.getSender() === selfUserId;
}

export function isSelfTarget(event: MatrixEvent): boolean {
const selfUserId = MatrixClientPeg.get().getUserId();
return event.getStateKey() === selfUserId;
}

export function shouldPrefixMessagesIn(roomId: string, tagId: TagID): boolean {
if (tagId !== DefaultTagID.DM) return true;

Expand All @@ -44,7 +39,3 @@ export function shouldPrefixMessagesIn(roomId: string, tagId: TagID): boolean {
export function getSenderName(event: MatrixEvent): string {
return event.sender ? event.sender.name : event.getSender();
}

export function getTargetName(event: MatrixEvent): string {
return event.target ? event.target.name : event.getStateKey();
}
38 changes: 0 additions & 38 deletions src/utils/Receipt.ts

This file was deleted.

36 changes: 0 additions & 36 deletions src/utils/drawable.ts

This file was deleted.

Loading

0 comments on commit 19e514d

Please sign in to comment.