-
Notifications
You must be signed in to change notification settings - Fork 530
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
10 changed files
with
225 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<script lang="ts"> | ||
import DomainButton from '$lib/navigation/DomainButton.svelte'; | ||
import { goto } from '$app/navigation'; | ||
import { page } from '$app/stores'; | ||
interface Props { | ||
href: string; | ||
isNavCollapsed: boolean; | ||
} | ||
const { href, isNavCollapsed }: Props = $props(); | ||
const label = 'Feeds'; | ||
</script> | ||
|
||
<DomainButton | ||
isSelected={$page.url.pathname === href} | ||
{isNavCollapsed} | ||
tooltipLabel={label} | ||
onmousedown={async () => await goto(href)} | ||
> | ||
<img class="icon" src="/images/domain-icons/working-branches.svg" alt="" /> | ||
{#if !isNavCollapsed} | ||
<span class="text-14 text-semibold" class:collapsed-txt={isNavCollapsed}>{label}</span> | ||
{/if} | ||
</DomainButton> | ||
|
||
<style lang="postcss"> | ||
.icon { | ||
border-radius: var(--radius-s); | ||
height: 20px; | ||
width: 20px; | ||
flex-shrink: 0; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<script lang="ts"> | ||
import { getContext } from '@gitbutler/shared/context'; | ||
import Interest from '@gitbutler/shared/redux/interest/Interest.svelte'; | ||
import { FeedService } from '@gitbutler/shared/redux/posts/service'; | ||
import { postSelectors, postRepliesSelectors } from '@gitbutler/shared/redux/posts/slice'; | ||
import { useStore } from '@gitbutler/shared/redux/utils'; | ||
type Props = { | ||
postId: string; | ||
}; | ||
const { postId }: Props = $props(); | ||
const feedService = getContext(FeedService); | ||
const store = useStore(); | ||
const postWithRepliesInterest = $derived(feedService.getPostWithRepliesInterest(postId)); | ||
const post = $derived(postSelectors.selectById($store, postId)); | ||
const postReplies = $derived(postRepliesSelectors.selectById($store, postId)); | ||
let postCardRef = $state<HTMLDivElement | undefined>(undefined); | ||
$effect(() => console.log(post)); | ||
$effect(() => console.log(postReplies)); | ||
</script> | ||
|
||
<Interest interest={postWithRepliesInterest} reference={postCardRef} onlyInView /> | ||
|
||
{#if post} | ||
<div class="card card__content" bind:this={postCardRef}> | ||
<p>{post.uuid}</p> | ||
<p>{post.content}</p> | ||
{#if postReplies} | ||
<p>There is {postReplies.replyIds.length} replies</p> | ||
{:else} | ||
<p>Loading replies count...</p> | ||
{/if} | ||
</div> | ||
{:else} | ||
<p>Loading...</p> | ||
{/if} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,40 @@ | ||
<script lang="ts"> | ||
import Post from '$lib/posts/Post.svelte'; | ||
import ScrollableContainer from '$lib/scroll/ScrollableContainer.svelte'; | ||
import { getContext } from '@gitbutler/shared/context'; | ||
import Interest from '@gitbutler/shared/redux/interest/Interest.svelte'; | ||
import { FeedService } from '@gitbutler/shared/redux/posts/service'; | ||
import { feedSelectors } from '@gitbutler/shared/redux/posts/slice'; | ||
import { useStore } from '@gitbutler/shared/redux/utils'; | ||
import Button from '@gitbutler/ui/Button.svelte'; | ||
const store = useStore(); | ||
const feedService = getContext(FeedService); | ||
const feedInterest = feedService.getFeedInterest(); | ||
const feed = $derived(feedSelectors.selectById($store, 'all')); | ||
$inspect(feed); | ||
$effect(() => console.log(feed)); | ||
let newPostContent = $state(''); | ||
function createPost() { | ||
feedService.createPost(newPostContent); | ||
newPostContent = ''; | ||
} | ||
</script> | ||
|
||
<Interest interest={feedInterest} /> | ||
<ScrollableContainer> | ||
<div> | ||
<input type="text" bind:value={newPostContent} /> | ||
<Button onclick={createPost}>Create</Button> | ||
</div> | ||
|
||
<div> | ||
{#if feed} | ||
{#each feed.postIds as postId (postId)} | ||
<Post {postId} /> | ||
{/each} | ||
{/if} | ||
</div> | ||
</ScrollableContainer> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,45 @@ | ||
<script lang="ts"> | ||
import type { Interest } from '$lib/redux/interest'; | ||
import type { Interest } from '$lib/redux/interest/intrestStore'; | ||
type Props = { | ||
interest: Interest; | ||
// ref?: HTMLElement; | ||
reference?: HTMLElement; | ||
onlyInView?: boolean; | ||
}; | ||
const { interest }: Props = $props(); | ||
const { interest, reference: ref, onlyInView }: Props = $props(); | ||
let inView = $state(false); | ||
$effect(() => { | ||
if (ref && onlyInView) { | ||
inView = false; | ||
const observer = new IntersectionObserver( | ||
(entries) => { | ||
inView = entries[0].isIntersecting; | ||
}, | ||
{ | ||
root: null | ||
} | ||
); | ||
observer.observe(ref); | ||
return () => { | ||
inView = false; | ||
observer.disconnect(); | ||
}; | ||
} | ||
}); | ||
$effect(() => { | ||
const unsubscribe = interest._subscribe(); | ||
const shouldSubscribe = !onlyInView || inView; | ||
if (interest && shouldSubscribe) { | ||
const unsubscribe = interest._subscribe(); | ||
// It is vitally important that we return the unsubscribe function | ||
return unsubscribe; | ||
// It is vitally important that we return the unsubscribe function | ||
return unsubscribe; | ||
} | ||
}); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters