Skip to content

Commit

Permalink
Update to v1.1.3
Browse files Browse the repository at this point in the history
Added 
- Logging toggle

Changes
- Change some labels

Fix
- Fix when copying content of logs, it crash
- Fix when trying to open log page, it loads everything
  • Loading branch information
Angelix1 authored Feb 29, 2024
1 parent ba2d2ae commit 3411ae8
Show file tree
Hide file tree
Showing 8 changed files with 212 additions and 179 deletions.
15 changes: 10 additions & 5 deletions plugins/antied/Settings.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ const togglePatch = [
label: "Toggle Message Update",
subLabel: "Logs edited message",
},
{
id: "enableLogging",
default: false,
label: "Toggle Antied Logging",
subLabel: "Save Logs to plugin's storage",
},
{
id: "logWarning",
default: false,
Expand Down Expand Up @@ -239,12 +245,11 @@ export default () => {

return (
<ScrollView>
<View style={{ marginTop: 20, marginBottom: 20 }}>

<View style={{ marginTop: 20, marginBottom: 20 }}>
<FormSection title="Plugin Setting" style={[styles.header]}>
<FormRow
label="Antied Logging Page"
leading={<FormRow.Icon source={getAssetIDByName("ic_edit_24px")} />}
label="Anti Edit & Delete Logs"
leading={<FormRow.Icon source={getAssetIDByName("ic_audit_log_24px")} />}
trailing={FormRow.Arrow}
onPress={() =>
navigation.push("VendettaCustomPage", {
Expand Down Expand Up @@ -507,4 +512,4 @@ export default () => {
</View>
</ScrollView>
)
}
}
17 changes: 9 additions & 8 deletions plugins/antied/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ const { FormRow, FormIcon } = Forms
makeDefaults(storage, {
switches: {
customizeable: false,
enableMD: true,
enableMU: true,
enableMD: true,
enableMU: true,
enableLogging: false,
useBackgroundColor: false,
ignoreBots: false,
minimalistic: true,
Expand Down Expand Up @@ -64,10 +65,10 @@ let deletedMessageArray = {};

export default {
onLoad: () => {
patches.push(
sillyPatch(),
fluxDispatchPatch(deletedMessageArray),
updateRowsPatch(deletedMessageArray),
patches.push(
sillyPatch(),
fluxDispatchPatch(deletedMessageArray),
updateRowsPatch(deletedMessageArray),
selfEditPatch(),
createMessageRecord(),
messageRecordDefault(),
Expand Down Expand Up @@ -157,7 +158,7 @@ export default {

ActionSheet.hideActionSheet()
if(storage?.inputs?.historyToast?.length > 0 || storage?.inputs?.historyToast != "") {
showToast(`[ANTI ED] ${storage?.inputs?.historyToast}`, getAssetIDByName("ic_edit_24px"))
showToast(`[ANTI ED] ${storage?.inputs?.historyToast}`, getAssetIDByName("ic_edit_24px"))
}
}
}/>
Expand Down Expand Up @@ -187,4 +188,4 @@ export default {
}
},
settings: Settings
}
}
2 changes: 1 addition & 1 deletion plugins/antied/manifest.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "Anti [Edit|Delete] v1.0.0",
"name": "Anti [Edit|Delete] v1.1.3",
"description": "Keeps deleted messages and logs edited messages, until you restart/reloads the app",
"authors": [
{
Expand Down
260 changes: 141 additions & 119 deletions plugins/antied/pages/log.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,129 +161,151 @@ export default () => {

const snipLength = Number(storage?.inputs?.logLength || 60);

return (<>
<ScrollView>
<FormRow
label="Nuke logs"
trailing={<FormRow.Icon source={getAssetIDByName("ic_trash_24px")} />}
onPress={() => {
dialog.show({
title: "Nuke logs",
body: "Nuke the Log?",
confirmText: "Yash",
cancelText: "nu uh",
confirmColor: "brand",
onConfirm: () => {
storage.log = [];
setLog([])
showToast("[ANTIED] hmm yum, i ate all of it")
}
})
}}
/>

<View style={styles.main_container}>
{
(log.length < 1) ?
(<>
<View style={styles.item_container}>
<FormRow label="Only us chicken here, go touch some grass"/>
</View>
</>):
log.map((data) => {
const { type, author, content, edited, where } = data;
return (<>
<View style={styles.item_container}>
function MessageThing({ data }) {
const { type, author, content, edited, where } = data;

return (<>
<View style={styles.item_container}>
<TouchableOpacity
style={styles.avatar_container}
onPress={() => Profiles.showUserProfile({ userId: author["id"] }) }
onPressIn={onPressIn}
onPressOut={onPressOut}
>
<Animated.View style={[animatedScaleStyle]}>
<Image
source={{
uri: (
(author.avatar) ?
`https://cdn.discordapp.com/avatars/${author?.id}/${author.avatar}.png` :
"https://cdn.discordapp.com/embed/avatars/2.png"
)
}}
style={styles.author_avatar}
/>
</Animated.View>
</TouchableOpacity>

<View style={styles.text_container}>
<View style={styles.log_header}>
<View style={styles.log_sub_header}>
<Text style={[styles.main_text, styles.author_name]}>
{
`${author["username"]}`
}
</Text>
{
<View style={{ paddingLeft: "2px" }}>{
((type == "MessageUpdate") ?
<FormRow.Icon source={getAssetIDByName("pencil")} /> :
<FormRow.Icon source={getAssetIDByName("ic_message_delete")} />
)
}</View>
}
<TouchableOpacity
style={styles.avatar_container}
onPress={() => Profiles.showUserProfile({ userId: author["id"] }) }
onPressIn={onPressIn}
onPressOut={onPressOut}
>
<Animated.View style={[animatedScaleStyle]}>
<Image
source={{
uri: (
(author.avatar) ?
`https://cdn.discordapp.com/avatars/${author?.id}/${author.avatar}.png` :
"https://cdn.discordapp.com/embed/avatars/2.png"
)
}}
style={styles.author_avatar}
onPress={() => {
if(
type == "MessageUpdate" &&
data.where.guild &&
data.where.channel &&
data.where.messageLink
) {
openURL(`https://discord.com/channels/${data.where.guild}/${data.where.channel}/${data.where.messageLink}`)
}
else {
showToast("Cannot find target Message")
}
}}
>
<View style={{paddingLeft: "2px" }}>
<FormRow.Icon
source={getAssetIDByName("ic_show_media")}
/>
</Animated.View>
</View>
</TouchableOpacity>

<View style={styles.text_container}>
<View style={styles.log_header}>
<View style={styles.log_sub_header}>
<Text style={[styles.main_text, styles.author_name]}>
{
`${author["username"]}`
}
</Text>
{
((type == "MessageUpdate") ?
<FormRow.Icon source={getAssetIDByName("pencil")} /> :
<FormRow.Icon source={getAssetIDByName("ic_message_delete")} />
)
}
<TouchableOpacity
onPress={() => {
if(data.where.guild && data.where.channel && data.where.messageLink) {
openURL(`https://discord.com/channels/${data.where.guild}/${data.where.channel}/${data.where.messageLink}`)
}
else {
showToast("On Direct Message")
}
}}
>
<FormRow.Icon
source={getAssetIDByName("ic_show_media")}
/>
</TouchableOpacity>

</View>
</View>
<TouchableOpacity
onPress={() => {
let clip = author.username;

clip += ` (${author.id}):\n`;
clip =+ `>>> ${content}`;
if(edited) {
clip += `\n\n${edited}`
}


clipboard.setString(clip);
showToast("Log content copied")
}}
style={styles.text_container}
>
<View>
{
(edited?.length > 0) ? (<>
<Text style={[styles.main_text, styles.old_message]}>
{shortenString(content, snipLength)}
</Text>
<Text style={[styles.main_text, styles.message_content]}>
{shortenString(edited, snipLength)}
</Text>
</>) :
(<Text style={styles.message_content}>
{shortenString(content, snipLength)}
</Text>
)
}
</View>
</TouchableOpacity>
</View>
</View>
</>)
})
}
</View>
<TouchableOpacity
onPress={() => {
let clip = author.username;
clip += ` (${author.id}):\n`;
clip += `>>> ${content}`;
if(edited) {
clip += `\n\n${edited}`
}

clipboard.setString(clip);
showToast("Log content copied")
}}
style={styles.text_container}
>
<View>
{
(edited?.length > 0) ? (<>
<Text style={[styles.main_text, styles.old_message]}>
{shortenString(content, snipLength)}
</Text>
<Text style={[styles.main_text, styles.message_content]}>
{shortenString(edited, snipLength)}
</Text>
</>) :
(
<Text style={styles.message_content}>
{shortenString(content, snipLength)}
</Text>
)
}
</View>
</TouchableOpacity>
</View>
</View>
</>)
}

return (<>
<ScrollView>
{
(!storage?.switches?.enableLogging) && (<>
<FormRow label="To save log of edited/deleted messages, go to plugin setting > patches > Toggle Antied Logging"/>
</>)
}
{
(log?.length > 0) ? (<>
<FormRow
label="Nuke logs"
trailing={<FormRow.Icon source={getAssetIDByName("ic_trash_24px")} />}
onPress={() => {
dialog.show({
title: "Nuke logs",
body: "Nuke the Log?",
confirmText: "Yash",
cancelText: "nu uh",
confirmColor: "brand",
onConfirm: () => {
storage.log = [];
setLog([])
showToast("[ANTIED] Logs cleared")
}
})
}}
/>
</>) : (<>
<FormRow label="Only us chicken here, go touch some grass"/>
</>)
}
{
(log.length > 0) && (<>
<View style={styles.main_container}>
<ReactNative.FlatList
style={{ paddingHorizontal: 10 }}
contentContainerStyle={{ paddingBottom: 20 }}
data={log}
renderItem={({ item }) => <MessageThing data={item} />}
removeClippedSubviews={true}
/>
</View>
</>)
}
</ScrollView>
</>)
};
};
Loading

0 comments on commit 3411ae8

Please sign in to comment.