Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🔧 vue3 composition api #6703

Merged
merged 11 commits into from
Aug 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 2 additions & 13 deletions components/bsx/Offer/OfferTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ withDefaults(
const { $route } = useNuxtApp()
const { urlPrefix, tokenId } = usePrefix()
const { accountId } = useAuth()
const { replaceUrl } = useReplaceUrl()

const itemsPerPage = ref(20)
const currentPage = ref(parseInt($route.query?.page as string) || 1)
Expand All @@ -188,21 +189,9 @@ const tellFrens = (caller: string, withdraw: boolean) => {
}

watch(currentPage, (val) => {
replaceUrl(String(val))
replaceUrl({ page: String(val) })
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GIga cHad Enerygy

})

const replaceUrl = (value: string, key = 'page') => {
const { $route, $router, $consola } = useNuxtApp()
if ($route.query[key] !== value) {
$router
.replace({
path: String($route.path),
query: { ...$route.query, [key]: value },
})
.catch($consola.warn /*Navigation Duplicate err fix later */)
}
}

const currentBlock = ref(async () => {
const { apiInstance } = useApi()
const api = await apiInstance.value
Expand Down
101 changes: 42 additions & 59 deletions components/rmrk/Gallery/EmotionList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<NeoButton
v-for="emoji in emotes.slice(0, DISPLAYED_EMOJI)"
:key="emoji.key"
variant="is-outlined"
variant="secondary"
no-shadow
class="emoji-box mb-2"
@click.native="$emit('selected', emoji.parsed)">
Expand All @@ -28,77 +28,60 @@
</div>
</template>

<script lang="ts">
import { Component, Prop, Provide, Vue } from 'nuxt-property-decorator'
<script lang="ts" setup>
import orderBy from 'lodash/orderBy'

import { Emotion } from '../service/scheme'
import EmotionModal from './EmotionModal.vue'
import { NeoButton, NeoIcon, NeoTooltip } from '@kodadot1/brick'
import Identity from '@/components/identity/IdentityIndex.vue'

const issuerId = (emotion: Emotion) => emotion.caller
const DISPLAYED_EMOJI = 5
const { $buefy } = useNuxtApp()
const instance = getCurrentInstance()

interface GroupedEmotion {
[x: string]: Emotion[]
}

interface Emoji {
key: string
count: number
issuers: string[]
parsed: string
}
const props = defineProps<{
emotions: []
}>()

@Component({
components: {
Identity: () => import('@/components/identity/IdentityIndex.vue'),
NeoIcon,
NeoTooltip,
NeoButton,
},
})
export default class EmotionList extends Vue {
@Prop() public emotions!: GroupedEmotion
@Provide() DISPLAYED_EMOJI = 5

/**
* parse emoji from codepoint to emoji
* @param codepoint Emoji Codepoint
* @returns Emoticon 👨🏻‍🌾
*/
parseEmoji(codepoint): string {
if (codepoint) {
const toInt = codepoint.split('-').map((code) => parseInt(code, 16))
return String.fromCodePoint.apply(String, toInt)
}

return ''
/**
* parse emoji from codepoint to emoji
* @param codepoint Emoji Codepoint
* @returns Emoticon 👨🏻‍🌾
*/
const parseEmoji = (codepoint): string => {
if (codepoint) {
const toInt = codepoint.split('-').map((code) => parseInt(code, 16))
return String.fromCodePoint.apply(String, toInt)
}

openEmotionModal(): void {
this.$buefy.modal.open({
parent: this,
component: EmotionModal,
canCancel: ['escape', 'outside'],
hasModalCard: true,
props: {
emotes: this.emotes,
},
})
}

get emotes(): Emoji[] {
const mapping = Object.entries(this.emotions).map(([key, emotions]) => ({
key,
count: emotions.length,
issuers: emotions.map(issuerId),
parsed: this.parseEmoji(key),
}))
const orderByCount = orderBy(mapping, ['count'], ['desc'])
return ''
}

return orderByCount
}
const openEmotionModal = () => {
$buefy.modal.open({
parent: instance?.proxy,
component: EmotionModal,
canCancel: ['escape', 'outside'],
hasModalCard: true,
props: {
emotes: emotes.value,
},
})
}

const emotes = computed(() => {
const mapping = Object.entries(props.emotions).map(([key, emotions]) => ({
key,
count: emotions.length,
issuers: emotions.map(issuerId),
parsed: parseEmoji(key),
}))
const orderByCount = orderBy(mapping, ['count'], ['desc'])

return orderByCount
})
</script>

<style lang="scss">
Expand Down
Loading