Skip to content

Commit

Permalink
Update proposals
Browse files Browse the repository at this point in the history
  • Loading branch information
prevetal committed Feb 16, 2024
1 parent c941274 commit 7971976
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 42 deletions.
22 changes: 2 additions & 20 deletions src/components/proposal/HeadInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<span>{{ $t('message.account_proposals_status_rejected') }}</span>
</div>

<div class="suspicious" v-if="checkSuspicious(props.proposal.title)">
<div class="suspicious" v-if="checkProposalSuspicious(props.proposal)">
<svg class="icon"><use xlink:href="@/assets/sprite.svg#ic_suspicious"></use></svg>
<span>{{ $t('message.account_proposals_suspicious_tooltip') }}</span>
</div>
Expand Down Expand Up @@ -64,29 +64,11 @@

<script setup>
import { useGlobalStore } from '@/stores'
import { checkProposalSuspicious } from '@/utils'
const props = defineProps(['proposal']),
store = useGlobalStore()
// Check Suspicious
function checkSuspicious(title) {
let result = false,
forbiddenWords = ['Airdrop', '\ud83d\udc8e', '\ud83d\udca5', '\u2705']
// Convert a string to an array of words and characters
let titleArr = title.toLowerCase().split('')
for (let char of titleArr) {
// Checking if there is an element in the array of prohibited words and characters
if (forbiddenWords.includes(char)) {
result = true
}
}
return result
}
</script>


Expand Down
23 changes: 2 additions & 21 deletions src/components/proposals/ProposalsItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
</div>
</div>

<div class="suspicious" v-if="checkSuspicious(props.proposal.title)">
<div class="suspicious" v-if="checkProposalSuspicious(props.proposal)">
<svg class="icon"><use xlink:href="@/assets/sprite.svg#ic_suspicious"></use></svg>

<div class="tooltip">
Expand Down Expand Up @@ -156,7 +156,7 @@
<script setup>
import { useGlobalStore } from '@/stores'
import { formatTimeAgo } from '@vueuse/core'
import { formatTokenName, formatTokenAmount } from '@/utils'
import { formatTokenName, formatTokenAmount, checkProposalSuspicious } from '@/utils'
const store = useGlobalStore(),
Expand All @@ -173,25 +173,6 @@
}
// Check Suspicious
function checkSuspicious(title) {
let result = false,
forbiddenWords = ['Airdrop', '\ud83d\udc8e', '\ud83d\udca5', '\u2705']
// Convert a string to an array of words and characters
let titleArr = title.toLowerCase().split('')
for (let char of titleArr) {
// Checking if there is an element in the array of prohibited words and characters
if (forbiddenWords.includes(char)) {
result = true
}
}
return result
}
// Get progress percents
function getProgressPercents(value) {
let sum = props.proposal.tally_no + props.proposal.tally_no_with_veto + props.proposal.tally_yes
Expand Down
33 changes: 32 additions & 1 deletion src/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,4 +233,35 @@ export const formatTokenPrice = (price, tokenName) => {
: formatPrice = price

return formatPrice
}
}


// Check Suspicious
export const checkProposalSuspicious = (proposal) => {
let result = false,
forbiddenWords = ['Airdrop', '\ud83d\udc8e', '\ud83d\udca5', '\u2705', '\ud83e\ude82']

// Check title
// Convert a string to an array of words and characters
let titleArr = proposal.title.toLowerCase().split('')

for (let char of titleArr) {
// Checking if there is an element in the array of prohibited words and characters
if (forbiddenWords.includes(char)) {
result = true
}
}

// Check description
// Convert a string to an array of words and characters
let descArr = proposal.description.toLowerCase().split('')

for (let char of descArr) {
// Checking if there is an element in the array of prohibited words and characters
if (forbiddenWords.includes(char)) {
result = true
}
}

return result
}

0 comments on commit 7971976

Please sign in to comment.