Skip to content

Commit 2224b71

Browse files
Merge pull request #782 from Adamant-im/fix/chat-and-contacts-style
fix: layout fixes
2 parents caef2c9 + d983e02 commit 2224b71

File tree

16 files changed

+586
-553
lines changed

16 files changed

+586
-553
lines changed

src/components/AChat/AChatForm.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ import { computed, nextTick } from 'vue'
4747
import ChatEmojis from '@/components/Chat/ChatEmojis.vue'
4848
import { isMobile } from '@/lib/display-mobile'
4949
import { mdiSend } from '@mdi/js'
50-
import { useChatStateStore } from '@/stores/chat-state'
50+
import { useChatStateStore } from '@/stores/modal-state'
5151
5252
export default {
5353
components: { ChatEmojis },

src/components/BuyTokensDialog.vue

Lines changed: 61 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<template>
2-
<v-dialog v-model="show" width="320" :class="className">
2+
<v-dialog v-model="show" width="320">
33
<v-card>
44
<v-card-title class="a-text-header">
5-
{{ $t('home.buy_tokens_btn') }}
5+
{{ t('home.buy_tokens_btn') }}
66
</v-card-title>
77

88
<v-divider class="a-divider" />
@@ -14,15 +14,15 @@
1414
<icon><exchanger-icon /></icon>
1515
</template>
1616

17-
<v-list-item-title>{{ $t('home.buy_tokens_exchanger') }}</v-list-item-title>
17+
<v-list-item-title>{{ t('home.buy_tokens_exchanger') }}</v-list-item-title>
1818
</v-list-item>
1919

2020
<v-list-item avatar @click="openLink(admLink)">
2121
<template #prepend>
2222
<icon><adamant-icon /></icon>
2323
</template>
2424

25-
<v-list-item-title>{{ $t('home.buy_tokens_anonymously') }}</v-list-item-title>
25+
<v-list-item-title>{{ t('home.buy_tokens_anonymously') }}</v-list-item-title>
2626
</v-list-item>
2727

2828
<v-list-item
@@ -34,7 +34,7 @@
3434
</template>
3535

3636
<v-list-item-title>{{
37-
$t('home.exchanges_on', { aggregator: 'CoinMarketCap' })
37+
t('home.exchanges_on', { aggregator: 'CoinMarketCap' })
3838
}}</v-list-item-title>
3939
</v-list-item>
4040

@@ -47,7 +47,7 @@
4747
</template>
4848

4949
<v-list-item-title>{{
50-
$t('home.exchanges_on', { aggregator: 'CoinGecko' })
50+
t('home.exchanges_on', { aggregator: 'CoinGecko' })
5151
}}</v-list-item-title>
5252
</v-list-item>
5353
</v-list>
@@ -56,64 +56,70 @@
5656
</v-dialog>
5757
</template>
5858

59-
<script>
59+
<script setup lang="ts">
60+
import { computed } from 'vue'
61+
import { useI18n } from 'vue-i18n'
62+
import { useRouter } from 'vue-router'
63+
6064
import validateAddress from '@/lib/validateAddress'
65+
import { websiteUriToOnion } from '@/lib/uri'
66+
6167
import AdamantIcon from '@/components/icons/common/Adamant.vue'
6268
import CoingeckoIcon from '@/components/icons/common/Coingecko.vue'
6369
import CoinmarketcapIcon from '@/components/icons/common/Coinmarketcap.vue'
6470
import ExchangerIcon from '@/components/icons/common/Exchanger.vue'
6571
import Icon from '@/components/icons/BaseIcon.vue'
66-
import { websiteUriToOnion } from '@/lib/uri'
6772
68-
export default {
69-
components: {
70-
AdamantIcon,
71-
CoingeckoIcon,
72-
CoinmarketcapIcon,
73-
ExchangerIcon,
74-
Icon
73+
const props = defineProps({
74+
modelValue: {
75+
type: Boolean,
76+
required: true
7577
},
76-
props: {
77-
modelValue: {
78-
type: Boolean,
79-
required: true
80-
},
81-
adamantAddress: {
82-
type: String,
83-
default: undefined,
84-
validator: (v) => validateAddress('ADM', v)
85-
}
86-
},
87-
emits: ['update:modelValue'],
88-
computed: {
89-
className: () => 'buy-tokens-dialog',
90-
admLink() {
91-
return websiteUriToOnion(
92-
this.adamantAddress
93-
? `${this.$t('home.buy_tokens_btn_link')}?wallet=${this.adamantAddress}`
94-
: `${this.$t('home.buy_tokens_btn_link')}`
95-
)
96-
},
97-
show: {
98-
get() {
99-
return this.modelValue
100-
},
101-
set(value) {
102-
this.$emit('update:modelValue', value)
103-
}
104-
}
78+
adamantAddress: {
79+
type: String,
80+
default: undefined,
81+
validator: (v: string) => validateAddress('ADM', v)
82+
}
83+
})
84+
85+
const emit = defineEmits<{
86+
(e: 'update:modelValue', value: boolean): void
87+
}>()
88+
89+
const { t } = useI18n()
90+
const router = useRouter()
91+
92+
const show = computed({
93+
get() {
94+
return props.modelValue
10595
},
106-
methods: {
107-
openLink(link) {
108-
if (link.startsWith('U')) {
109-
this.$router.push({
110-
name: 'Chat',
111-
params: { partnerId: link }
112-
})
113-
} else {
114-
window.open(link, '_blank', 'resizable,scrollbars,status,noopener')
115-
}
116-
}
96+
set(value) {
97+
emit('update:modelValue', value)
11798
}
99+
})
100+
101+
const admLink = computed(() =>
102+
websiteUriToOnion(
103+
props.adamantAddress
104+
? `${t('home.buy_tokens_btn_link')}?wallet=${props.adamantAddress}`
105+
: `${t('home.buy_tokens_btn_link')}`
106+
)
107+
)
108+
109+
const closeDialog = () => {
110+
show.value = false
111+
}
112+
113+
const openLink = (link: string) => {
114+
if (link.startsWith('U')) {
115+
router.push({
116+
name: 'Chat',
117+
params: { partnerId: link }
118+
})
119+
} else {
120+
window.open(link, '_blank', 'resizable,scrollbars,status,noopener')
121+
}
122+
123+
closeDialog()
118124
}
119125
</script>

src/components/Chat/Chat.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ import { useRouter } from 'vue-router'
307307
import { useStore } from 'vuex'
308308
import { useChatsSpinner } from '@/hooks/useChatsSpinner'
309309
import ProgressIndicator from '@/components/ProgressIndicator.vue'
310-
import { useChatStateStore } from '@/stores/chat-state'
310+
import { useChatStateStore } from '@/stores/modal-state'
311311
312312
const validationErrors = {
313313
emptyMessage: 'EMPTY_MESSAGE',

src/components/Chat/ChatMenu.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ import CryptoIcon from '@/components/icons/CryptoIcon.vue'
6161
import IconBox from '@/components/icons/IconBox.vue'
6262
import UploadFile from '../UploadFile.vue'
6363
import { mdiFile, mdiImage, mdiPlusCircleOutline } from '@mdi/js'
64-
import { useChatStateStore } from '@/stores/chat-state'
64+
import { useChatStateStore } from '@/stores/modal-state'
6565
import type { FileData } from '@/lib/files'
6666
import { CoinSymbol } from '@/store/modules/wallets/types'
6767

src/components/Chat/Chats.vue

Lines changed: 8 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,7 @@ import {
9191
ref,
9292
watch
9393
} from 'vue'
94-
import { useChatStateStore } from '@/stores/chat-state'
95-
import { storeToRefs } from 'pinia'
94+
import { useChatStateStore } from '@/stores/modal-state'
9695
import { useStore } from 'vuex'
9796
import { useI18n } from 'vue-i18n'
9897
import { useChatsSpinner } from '@/hooks/useChatsSpinner'
@@ -111,51 +110,30 @@ const props = withDefaults(
111110
)
112111
113112
const store = useStore()
113+
const chatStateStore = useChatStateStore()
114114
const router = useRouter()
115+
const route = useRoute()
115116
const { t } = useI18n()
116117
const showSpinner = useChatsSpinner()
117-
const route = useRoute()
118-
const chatStateStore = useChatStateStore()
119118
120119
const className = 'chats-view'
121120
122-
const {
123-
actionsDropdownMessageId,
124-
isShowPartnerInfoDialog,
125-
isShowFreeTokensDialog,
126-
isChatMenuOpen,
127-
isEmojiPickerOpen
128-
} = storeToRefs(chatStateStore)
129121
const { setShowChatStartDialog } = chatStateStore
130122
123+
const isShowChatStartDialog = computed({
124+
get: () => chatStateStore.isShowChatStartDialog,
125+
set: (value) => setShowChatStartDialog(value)
126+
})
127+
131128
const lastPartnerId = ref<string | null>(null)
132129
const savedRoute = ref(null)
133130
const loading = ref(false)
134131
const noMoreChats = ref(false)
135132
const loadingSeparator = ref<InstanceType<typeof ChatPreview>[]>([])
136-
137133
const chatPagePartnerId = computed(() => {
138134
// We assume partnerId to always be a string
139135
return route.params.partnerId as string
140136
})
141-
const isSnackbarShowing = computed(() => store.state.snackbar.show)
142-
const noActiveNodesDialog = computed(() => store.state.chat.noActiveNodesDialog)
143-
const isShowChatStartDialog = computed({
144-
get: () => chatStateStore.isShowChatStartDialog,
145-
set: (value) => setShowChatStartDialog(value)
146-
})
147-
const canPressEscape = computed(() => {
148-
return (
149-
!noActiveNodesDialog.value &&
150-
!isShowChatStartDialog.value &&
151-
!isShowFreeTokensDialog.value &&
152-
!isSnackbarShowing.value &&
153-
!isShowPartnerInfoDialog.value &&
154-
!isChatMenuOpen.value &&
155-
!isEmojiPickerOpen.value &&
156-
actionsDropdownMessageId.value === -1
157-
)
158-
})
159137
const isFulfilled = computed(() => store.state.chat.isFulfilled)
160138
const lastMessages = computed(() => store.getters['chat/lastMessages'])
161139
const separatorIndex = computed(() => {
@@ -189,13 +167,11 @@ onBeforeMount(() => {
189167
})
190168
191169
onMounted(() => {
192-
document.addEventListener('keydown', onKeydownHandler)
193170
setShowChatStartDialog(props.showNewContact)
194171
attachScrollListener()
195172
})
196173
197174
onBeforeUnmount(() => {
198-
document.removeEventListener('keydown', onKeydownHandler)
199175
destroyScrollListener()
200176
})
201177
@@ -213,20 +189,6 @@ const checkIsActive = (contactId: string) => {
213189
return route.name !== 'Chats' && contactId === lastPartnerId.value
214190
}
215191
216-
const onKeydownHandler = (e: KeyboardEvent) => {
217-
if (canPressEscape.value) {
218-
if (e.key === 'Escape') {
219-
if (route.query.from?.includes('chats')) {
220-
router.push(route.query.from as string)
221-
return
222-
}
223-
router.push({
224-
name: 'Chats'
225-
})
226-
}
227-
}
228-
}
229-
230192
const openChat = (partnerId: string, messageText?: string) => {
231193
router.push({
232194
name: 'Chat',

0 commit comments

Comments
 (0)