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

Profile urls #723

Merged
merged 3 commits into from
Sep 26, 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
14 changes: 11 additions & 3 deletions src/lib/components/Profile/DrawerEditProfile.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
import DrawerAddCategory from '$lib/components/Browse/DrawerAddCategory.svelte'
import IconLink from '$lib/assets/icons/IconLink.svelte'
import { category_list } from '$lib/stores/channelStore'
import { createEffect } from '$lib/utils'
import { createEffect, objectMonitor } from '$lib/utils'

export let showDrawer: boolean
export let profile: any

let isProfileUpdated = objectMonitor($page.data.profile)

let inputFields = [...profile.urls]

Expand Down Expand Up @@ -82,7 +84,13 @@
}
}, [$page.params])

console.info('profile', profile)
$: useOueryEffect(() => {
if(isProfileUpdated($page.data.profile)){
if (submitBtn) submitBtn.disabled = false
toggleDrawer()
}
}, [$page.data.profile])

</script>

<div class="drawer drawer-end absolute w-full z-20 top-0 right-0">
Expand Down Expand Up @@ -168,7 +176,7 @@
<IconLink />
</div>
</div>
{#if index === inputFields.length - 1}
{#if index === inputFields.length - 1 && inputFields.length < 10}
<button
type="button"
class="btn btn-primary text-white"
Expand Down
9 changes: 4 additions & 5 deletions src/lib/components/Profile/Elements/UserDetails.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,18 @@
{profile.bio || ''}
</div>
{/if}

<div class="pt-4 mb-2">
<div class="flex gap-2 justify-center items-center p-4">
<div class="flex gap-2 justify-center items-center lg:overflow-hidden overflow-auto max-w-full ">
{#each profile.urls || [] as url, index (index)}
{#if url}
<div class="tooltip" data-tip={url}>
<Favicon {url} />
</div>
<Favicon {url} />
{/if}
{/each}
</div>

{#if profile.category?.length}
<div class="flex gap-2 justify-center">
<div class="flex gap-2 justify-center mt-8">
{#each profile.category as category}
<div class="tooltip" data-tip={category}>
<img src={$category_list[category]} alt="" class="h-7 w-7 m-1" />
Expand Down
6 changes: 3 additions & 3 deletions src/lib/components/Profile/Favicon.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
</script>

{#if faviconUrl}
<a class="link link-info" href={url} target="_blank" rel="noreferrer">
<img class="w-10 h-10" src={faviconUrl} alt="Favicon" />
<a class="link link-info w-10 tooltip" href={url} data-tip={url} target="_blank" rel="noreferrer">
<img class="w-full" src={faviconUrl} alt="Favicon" />
</a>
{:else}
<a class="link link-info" href={url} target="_blank" rel="noreferrer">
<a class="w-10 h-10 link link-info tooltip" href={url} data-tip={url} target="_blank" rel="noreferrer">
<IconLink />
</a>
{/if}
6 changes: 6 additions & 0 deletions src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,3 +339,9 @@ export const dataURLtoFile = (dataurl: string, filename: string) => {
}
return new File([u8arr], filename, { type: mime })
}

export const objectMonitor = (object:any) => {
return (currentState:any) => {
return JSON.stringify(object) !== JSON.stringify(currentState)
}
}