Skip to content

Commit

Permalink
Merge pull request #619 from sitaradev/profile-fixes-2
Browse files Browse the repository at this point in the history
Profile fixes 2
  • Loading branch information
gagansuie authored Jul 12, 2023
2 parents 3b35c88 + 70b9130 commit e343d4d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 22 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"format": "prettier --plugin-search-dir . --write ."
},
"devDependencies": {
"@playwright/test": "1.35.1",
"@playwright/test": "1.36.0",
"@sveltejs/adapter-cloudflare": "^2.2.0",
"@sveltejs/kit": "^1.10.0",
"@sveltejs/svelte-virtual-list": "^3.0.1",
Expand Down
32 changes: 16 additions & 16 deletions src/lib/components/Profile/LoadMore.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
let listElement: any
let skip = 0
let s_skip = 0
let sSkip = 0
let list: any[] = []
let s_list: any = null
let sList: any = null
let loading = false
let allLoaded = false
let s_allLoaded = false
let sAllLoaded = false
let query = ''
onMount(async () => {
Expand All @@ -29,11 +29,11 @@
if (dataSource && !loading && !allLoaded) {
loading = true
if (query) {
if (!s_allLoaded) {
s_skip += s_limit
let resp = await searchDataSource(query, s_skip, s_limit)
s_allLoaded = resp.length === 0
s_list = [...s_list, ...resp]
if (!sAllLoaded) {
sSkip += s_limit
let resp = await searchDataSource(query, sSkip, s_limit)
sAllLoaded = resp.length === 0
sList = [...sList, ...resp]
}
} else {
skip += limit
Expand All @@ -50,11 +50,11 @@
const search = async () => {
loading = true
s_allLoaded = false
s_list = []
s_skip = 0
s_list = await searchDataSource(query, s_skip, s_limit)
s_allLoaded = s_list.length < s_limit ? true : false
sAllLoaded = false
sList = []
sSkip = 0
sList = await searchDataSource(query, sSkip, s_limit)
sAllLoaded = sList.length < s_limit ? true : false
loading = false
}
Expand All @@ -64,7 +64,7 @@
$: useOueryEffect(() => {
if (!query) {
s_list = null
sList = null
}
}, [query])
Expand All @@ -74,15 +74,15 @@
return
}
query = ''
s_list = null
sList = null
skip = 0
loading = true
list = await dataSource(skip, limit)
allLoaded = list.length < limit ? true : false
loading = false
}, [count])
$: main_list = s_list || list
$: main_list = sList || list
</script>

<div>
Expand Down
11 changes: 6 additions & 5 deletions src/lib/components/Profile/TopSection.svelte
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
<script lang="ts">
import IconMore from '$lib/assets/icons/IconMore.svelte'
import { page } from '$app/stores'
import { onMount } from 'svelte'
import { follower_count, following_count } from '$lib/stores/profileStore'
import { enhance } from '$app/forms'
import { put, del } from '$lib/api'
import { get } from '$lib/api'
import { createEffect } from '$lib/utils'
export let profile: any,
showDrawer = false
const useOueryEffect = createEffect()
$: auth = {
userId: $page.data.user?.userId,
token: $page.data.user?.token
Expand All @@ -21,7 +23,6 @@
const refreash = async () => {
$follower_count = await get(`follows/count?source=${profile._id}&sourceType=source1`, auth)
$following_count = await get(`follows/count?source=${profile._id}&sourceType=source2`, auth)
if ($page.data.user?.userId) {
isFollowed = await get(`follows/relationship?source=${profile._id}`, auth)
subValues = isFollowed
Expand All @@ -41,9 +42,9 @@
refreash()
}
onMount(async () => {
$: useOueryEffect(async () => {
refreash()
})
}, [profile._id])
$: currentUser = $page.data.user?.user
$: subValues
Expand Down

0 comments on commit e343d4d

Please sign in to comment.