Skip to content

Commit

Permalink
Fix pronoundb
Browse files Browse the repository at this point in the history
  • Loading branch information
acquitelol committed Apr 3, 2023
1 parent 4febdd7 commit 1b5bf44
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 26 deletions.
Binary file modified .DS_Store
Binary file not shown.
8 changes: 6 additions & 2 deletions src/components/Settings/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ import { Icons, Miscellaneous, Constants } from "../../common";
import { findByProps } from '@vendetta/metro';
import { semanticColors } from '@vendetta/ui';
import IntelligentImage from '../Dependent/IntelligentImage';
import { getDebugInfo } from '@vendetta/debug';

const { FormRow, FormSwitch, FormDivider } = Forms;
const { ScrollView, View, Text } = General;

const Router = findByProps('transitionToGuild')
const Router = findByProps('transitionToGuild', "openURL")
const optionalMargin = parseInt(getDebugInfo()?.discord?.version.split(".")[0]) > 163 ? 15 : 0;

const styles = stylesheet.createThemedStyleSheet({
icon: {
Expand Down Expand Up @@ -71,6 +73,7 @@ export default () => {
leading={<FormRow.Icon style={styles.icon} source={Icons.Settings.Locale} />}
trailing={<FormSwitch
value={storage.isTimestamp}
style={{ marginLeft: -optionalMargin }}
onValueChange={() => {
storage.isTimestamp = !storage.isTimestamp
setTimestampPreview(storage.isTimestamp)
Expand All @@ -85,6 +88,7 @@ export default () => {
leading={<FormRow.Icon style={styles.icon} source={Icons.Settings.Edit} />}
trailing={<FormSwitch
value={storage.isRole}
style={{ marginLeft: -optionalMargin }}
onValueChange={() => {
storage.isRole = !storage.isRole
setRolePreview(storage.isRole)
Expand Down Expand Up @@ -142,7 +146,7 @@ export default () => {
subLabel={`Open the ${manifest.name} website externally at \`https://pronoundb.org\`.`}
onLongPress={() => Miscellaneous.displayToast(`Opens the PronounDB website in an external page which allows you to link your Discord account to PronounDB.`, 'tooltip')}
leading={<FormRow.Icon style={styles.icon} source={Icons.Settings.External} />}
trailing={() => <FormRow.Arrow />}
trailing={() => <FormRow.Arrow style={{ marginLeft: -optionalMargin }} />}
onPress={() => {
/**
* Simply opens the PronounDB website externally to the user using the Router.
Expand Down
42 changes: 18 additions & 24 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,44 +66,38 @@ export default {
const rows = JSON.parse(args[1]);

for ( const row of rows ) {
if (row.type === 1) {
row.message.shouldShowRoleDot = true
row.message.shouldShowRoleOnName = true
}

if (row.type !== 1
|| !row?.message?.authorId
|| !PM.map[row?.message?.authorId]
|| PM.referenceMap[PM.map[row?.message?.authorId]] === "unspecified"
) continue;

/**
* @param pronoun: The pronoun that will be displayed to the user. This should not be invalid.
*/
const pronoun = PM.referenceMap[PM.map[row.message.authorId]];

/**
* Checks if the user has enabled the @arg isTimestamp option in settings & if there is a valid timestamp on the message
* If this is true, then modify the @arg timestamp only and continue to the next row, without executing the rest of the loop.
* @param {string} pronoun: The main pronoun in @plainText ~ This *should not be undefined*
*/
const pronoun: string = PM.referenceMap[PM.map[row.message.authorId]];

if (storage.isTimestamp && row.message.timestamp) {
row.message.timestamp += (" • " + pronoun);
continue;
}

if (!row.message.opTagText) {
/**
* Sets the @arg opTagText to the @var pronoun defined above.
*/
row.message.opTagText = pronoun;

/**
* Afterwards set the @arg text and @arg background color to a @arg {processed and themed} color
* using the @arg background color to determine a @arg text color with a custom implementation.
*/
row.message.opTagTextColor = ReactNative.processColor(styles.opTagTextColor.color);
row.message.opTagBackgroundColor = ReactNative.processColor(styles.opTagBackgroundColor.color);
} else if (!row.message.tagText) {
/**
* Set the @arg tagText to the @var pronoun defined above.
*/
row.message.tagText = pronoun
if (row.message.opTagText) {
row.message.tagText = (
row.message.tagText
? row.message.tagText + " • "
: ""
+ row.message.opTagText)
}

row.message.opTagText = pronoun;
row.message.opTagTextColor = ReactNative.processColor(styles.opTagTextColor.color);
row.message.opTagBackgroundColor = ReactNative.processColor(styles.opTagBackgroundColor.color);
}

/**
Expand Down

0 comments on commit 1b5bf44

Please sign in to comment.