Kinda fix networks
This commit is contained in:
@@ -13,6 +13,7 @@ import { p2postApi } from '@/modules/p2post/api/p2postApi';
|
||||
const friends = ref([])
|
||||
const activeFriend = ref(null)
|
||||
const myUsers = ref([])
|
||||
const currentUser = ref({"pubkey":null})
|
||||
|
||||
const relays = ref([])
|
||||
|
||||
@@ -20,31 +21,39 @@ async function getRelays(){
|
||||
relays.value = await p2privateApi.getNetworks()
|
||||
}
|
||||
|
||||
async function getFriends(){
|
||||
async function getFriends(user){
|
||||
const result = await p2privateApi.getFriends()
|
||||
for (const f of result){
|
||||
const m1 = {id:1, senderId:'me', content:"test Meeeeeeeeeeeeeeeeeeeeee", timestamp:new Date(), status:"SENT"}
|
||||
const m2 = {id:2, senderId:'peer', content:"test Peer", status:"RECEIVED", timestamp:new Date(), files:[{name:'file1', type:'image/jpeg', size:123}]}
|
||||
const mes = [m1,m2]
|
||||
const fr = {nickname:'Nickname', unreadCount:5, publicKey:f.pubkey, isOnline:true, messages:mes}
|
||||
const chat = await p2privateApi.getChat(user.pubkey, f.pubkey)
|
||||
const messages = []
|
||||
for (const m of chat){
|
||||
if (m.from === user.pubkey){
|
||||
var senderId = "me"
|
||||
}else{
|
||||
var senderId = "peer"
|
||||
}
|
||||
var message = {id:m.hash, senderId:senderId, content:m.content, timestamp:m.timestamp, status:"SENT"}
|
||||
messages.push(message)
|
||||
}
|
||||
const fr = {nickname:'Nickname', unreadCount:5, publicKey:f.pubkey, isOnline:true, messages:messages}
|
||||
friends.value.push(fr)
|
||||
}
|
||||
}
|
||||
|
||||
async function getMyUsers(){
|
||||
myUsers.value = await p2postApi.getMyUsers()
|
||||
const randomIndex = Math.floor(Math.random() * myUsers.value.length);
|
||||
currentUser.value = myUsers.value[randomIndex]
|
||||
getFriends(currentUser.value)
|
||||
}
|
||||
|
||||
const inputMessageText = ref("")
|
||||
async function createMessage(){
|
||||
const randomIndex = Math.floor(Math.random() * myUsers.value.length);
|
||||
const randomUser = myUsers.value[randomIndex]
|
||||
await p2privateApi.createMessage(randomUser.pubkey, activeFriend.value.publicKey, inputMessageText.value, [])
|
||||
await p2privateApi.createMessage(currentUser.value.pubkey, activeFriend.value.publicKey, inputMessageText.value, [])
|
||||
}
|
||||
|
||||
onMounted(()=>{
|
||||
getRelays()
|
||||
getFriends()
|
||||
getMyUsers()
|
||||
})
|
||||
|
||||
@@ -109,6 +118,7 @@ onMounted(()=>{
|
||||
<UsersIcon class="w-5 h-5 mr-2" />
|
||||
Friends ({{friends.length}})
|
||||
</h3>
|
||||
<span class="text-sm">{{ currentUser.pubkey }}</span>
|
||||
</div>
|
||||
|
||||
<div class="flex-1 overflow-y-auto p-4 space-y-2">
|
||||
|
||||
Reference in New Issue
Block a user