diff --git a/src/ts/core/messageDataGenerator.ts b/src/ts/core/messageDataGenerator.ts index 492e2f15..c7154211 100644 --- a/src/ts/core/messageDataGenerator.ts +++ b/src/ts/core/messageDataGenerator.ts @@ -29,11 +29,9 @@ class MessageDataGenerator { ): SbsMessageWrapperOptionsForTweets { const translations = TranslationKeyProvider.fromTweetAnalyzer(analyzer); const tweetText = ShareTextGenerator.generateShareText(analyzer); - const { meta } = analyzer; return { ...translations, - ...meta, isAlert: analyzer.tweet.hasAnyProblem, isExpanded: options.alwaysDetailedView, diff --git a/src/ts/core/parser/tweetParser.ts b/src/ts/core/parser/tweetParser.ts index 3a488058..bcc89def 100644 --- a/src/ts/core/parser/tweetParser.ts +++ b/src/ts/core/parser/tweetParser.ts @@ -1,6 +1,4 @@ import type { BasicTweetProps, Tweet } from "twi-ext"; -import { getReactProps } from "./utility"; -import { isFocalTweetOuterReactPropsData } from "../../../types/core/reactProps/reactProps.guard"; /** * React props of the tweet. @@ -23,15 +21,6 @@ class TweetParser { public parse(): BasicTweetProps { return this.tweet.props; } - - /** - * Check whether the tweet is focal. - * @returns whether the tweet is focal - */ - public get isFocal(): boolean { - const tweetReactProps = getReactProps(this.tweet.element); - return isFocalTweetOuterReactPropsData(tweetReactProps); - } } export { TweetParser }; diff --git a/src/ts/core/propsAnalyzer.ts b/src/ts/core/propsAnalyzer.ts index b3ba94a6..f41d49bb 100644 --- a/src/ts/core/propsAnalyzer.ts +++ b/src/ts/core/propsAnalyzer.ts @@ -18,10 +18,6 @@ interface TweetAnalysisResult extends ProfileAnalysisResult { possiblySensitive: boolean; searchability: "searchable" | "unsearchable" | "possiblyUnsearchable"; }; - - meta: { - isFocal: boolean; - }; } class PropsAnalyzer { @@ -65,10 +61,6 @@ class PropsAnalyzer { return { ...userAnalysisResult, - meta: { - isFocal: parser.isFocal - }, - tweet: { ageRestriction, hasAnyProblem: searchability !== "searchable" || userAnalysisResult.user.hasAnyProblem, diff --git a/src/ts/core/sbsMessageWrapper.ts b/src/ts/core/sbsMessageWrapper.ts index f3ae9d45..af203448 100644 --- a/src/ts/core/sbsMessageWrapper.ts +++ b/src/ts/core/sbsMessageWrapper.ts @@ -14,7 +14,6 @@ interface SbsMessageWrapperOptionsForTweets { notes: TranslationKey[]; isAlert: boolean; - isFocal: boolean; isExpanded: boolean; isTweetButtonShown: boolean; isNoteShown: boolean; @@ -51,7 +50,7 @@ class SbsMessageWrapper { this.tweet = options.tweet; sbsMessage.details = options.details; sbsMessage.notes = options.notes; - sbsMessage.isFocalMode = options.isFocal; + sbsMessage.isFocalMode = options.tweet.metadata.isFocalMode; sbsMessage.isExpanded = options.isExpanded; sbsMessage.isTweetButtonShown = options.isTweetButtonShown; sbsMessage.isNoteShown = options.isNoteShown; diff --git a/src/types/core/reactProps/reactProps.d.ts b/src/types/core/reactProps/reactProps.d.ts index 84ba5d45..ee1cf7c6 100644 --- a/src/types/core/reactProps/reactProps.d.ts +++ b/src/types/core/reactProps/reactProps.d.ts @@ -1,59 +1,8 @@ -type ProfileInterstitialType = "" | "sensitive_media" | "fake_account" | "offensive_profile_content" | "timeout"; -interface UserProps { - possibly_sensitive?: boolean | null; - screen_name: string; - profile_interstitial_type: ProfileInterstitialType; - withheld_in_countries: string[]; -} - /** @see {isCellInnerDivProps} ts-auto-guard:type-guard */ -interface CellInnerDivProps { +export interface CellInnerDivProps { children: { _owner?: { key: string; }; }; } - -/** @see {isFocalTweetOuterReactPropsData} ts-auto-guard:type-guard */ -export interface FocalTweetOuterReactPropsData { - children: [ - [ - unknown, - { - props: { - children: [ - { - props: { - children: [ - unknown, - unknown, - { - props: { - children: [ - unknown, - unknown, - unknown, - unknown, - unknown, - unknown, - unknown, - { - props: { - loggedInUser: { - screen_name: string; - }; - }; - } - ]; - }; - } - ]; - }; - } - ]; - }; - } - ] - ]; -} diff --git a/src/types/core/reactProps/reactProps.guard.ts b/src/types/core/reactProps/reactProps.guard.ts index f261bc26..328b00aa 100644 --- a/src/types/core/reactProps/reactProps.guard.ts +++ b/src/types/core/reactProps/reactProps.guard.ts @@ -2,7 +2,7 @@ * Generated type guards for "reactProps.d.ts". * WARNING: Do not manually change this file. */ -import { CellInnerDivProps, FocalTweetOuterReactPropsData } from "./reactProps"; +import { CellInnerDivProps } from "./reactProps"; export function isCellInnerDivProps(obj: unknown): obj is CellInnerDivProps { const typedObj = obj as CellInnerDivProps @@ -20,45 +20,3 @@ export function isCellInnerDivProps(obj: unknown): obj is CellInnerDivProps { typeof typedObj["children"]["_owner"]["key"] === "string") ) } - -export function isFocalTweetOuterReactPropsData(obj: unknown): obj is FocalTweetOuterReactPropsData { - const typedObj = obj as FocalTweetOuterReactPropsData - return ( - (typedObj !== null && - typeof typedObj === "object" || - typeof typedObj === "function") && - Array.isArray(typedObj["children"]) && - Array.isArray(typedObj["children"][0]) && - (typedObj["children"][0][1] !== null && - typeof typedObj["children"][0][1] === "object" || - typeof typedObj["children"][0][1] === "function") && - (typedObj["children"][0][1]["props"] !== null && - typeof typedObj["children"][0][1]["props"] === "object" || - typeof typedObj["children"][0][1]["props"] === "function") && - Array.isArray(typedObj["children"][0][1]["props"]["children"]) && - (typedObj["children"][0][1]["props"]["children"][0] !== null && - typeof typedObj["children"][0][1]["props"]["children"][0] === "object" || - typeof typedObj["children"][0][1]["props"]["children"][0] === "function") && - (typedObj["children"][0][1]["props"]["children"][0]["props"] !== null && - typeof typedObj["children"][0][1]["props"]["children"][0]["props"] === "object" || - typeof typedObj["children"][0][1]["props"]["children"][0]["props"] === "function") && - Array.isArray(typedObj["children"][0][1]["props"]["children"][0]["props"]["children"]) && - (typedObj["children"][0][1]["props"]["children"][0]["props"]["children"][2] !== null && - typeof typedObj["children"][0][1]["props"]["children"][0]["props"]["children"][2] === "object" || - typeof typedObj["children"][0][1]["props"]["children"][0]["props"]["children"][2] === "function") && - (typedObj["children"][0][1]["props"]["children"][0]["props"]["children"][2]["props"] !== null && - typeof typedObj["children"][0][1]["props"]["children"][0]["props"]["children"][2]["props"] === "object" || - typeof typedObj["children"][0][1]["props"]["children"][0]["props"]["children"][2]["props"] === "function") && - Array.isArray(typedObj["children"][0][1]["props"]["children"][0]["props"]["children"][2]["props"]["children"]) && - (typedObj["children"][0][1]["props"]["children"][0]["props"]["children"][2]["props"]["children"][7] !== null && - typeof typedObj["children"][0][1]["props"]["children"][0]["props"]["children"][2]["props"]["children"][7] === "object" || - typeof typedObj["children"][0][1]["props"]["children"][0]["props"]["children"][2]["props"]["children"][7] === "function") && - (typedObj["children"][0][1]["props"]["children"][0]["props"]["children"][2]["props"]["children"][7]["props"] !== null && - typeof typedObj["children"][0][1]["props"]["children"][0]["props"]["children"][2]["props"]["children"][7]["props"] === "object" || - typeof typedObj["children"][0][1]["props"]["children"][0]["props"]["children"][2]["props"]["children"][7]["props"] === "function") && - (typedObj["children"][0][1]["props"]["children"][0]["props"]["children"][2]["props"]["children"][7]["props"]["loggedInUser"] !== null && - typeof typedObj["children"][0][1]["props"]["children"][0]["props"]["children"][2]["props"]["children"][7]["props"]["loggedInUser"] === "object" || - typeof typedObj["children"][0][1]["props"]["children"][0]["props"]["children"][2]["props"]["children"][7]["props"]["loggedInUser"] === "function") && - typeof typedObj["children"][0][1]["props"]["children"][0]["props"]["children"][2]["props"]["children"][7]["props"]["loggedInUser"]["screen_name"] === "string" - ) -}