feat: add and close #187

This commit is contained in:
Xylight committed 2023-11-14 17:31:11 -08:00
1 parent 4047b43451
commit c60c8b8c3a
5 files changed
+33 -23

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "photon-lemmy", "name": "photon-lemmy",
"version": "1.20.3", "version": "1.21.0",
"private": true, "private": true,
"scripts": { "scripts": {
"dev": "vite dev", "dev": "vite dev",
+23 -22
View File
@@ -1,20 +1,20 @@
<script lang="ts"> <script lang="ts">
import type { PostView } from "lemmy-js-client" import type { PostView } from 'lemmy-js-client'
import { isImage, isVideo } from "$lib/ui/image.js" import { isImage, isVideo } from '$lib/ui/image.js'
import { getInstance } from "$lib/lemmy.js" import { getInstance } from '$lib/lemmy.js'
import PostActions from "$lib/components/lemmy/post/PostActions.svelte" import PostActions from '$lib/components/lemmy/post/PostActions.svelte'
import { userSettings } from "$lib/settings.js" import { userSettings } from '$lib/settings.js'
import PostLink from "$lib/components/lemmy/post/PostLink.svelte" import PostLink from '$lib/components/lemmy/post/PostLink.svelte'
import PostMeta from "$lib/components/lemmy/post/PostMeta.svelte" import PostMeta from '$lib/components/lemmy/post/PostMeta.svelte'
import { Material, toast } from "mono-svelte" import { Material, toast } from 'mono-svelte'
import Markdown from "$lib/components/markdown/Markdown.svelte" import Markdown from '$lib/components/markdown/Markdown.svelte'
import ExpandableImage from "$lib/components/ui/ExpandableImage.svelte" import ExpandableImage from '$lib/components/ui/ExpandableImage.svelte'
import { bestImageURL, postLink } from "$lib/components/lemmy/post/helpers.js" import { bestImageURL, postLink } from '$lib/components/lemmy/post/helpers.js'
import Empty from "$lib/components/helper/Empty.svelte" import Empty from '$lib/components/helper/Empty.svelte'
import { publishedToDate } from "$lib/components/util/date.js" import { publishedToDate } from '$lib/components/util/date.js'
import { Icon, VideoCamera } from "svelte-hero-icons" import { Icon, VideoCamera } from 'svelte-hero-icons'
import PostMedia from "$lib/components/lemmy/post/media/PostMedia.svelte" import PostMedia from '$lib/components/lemmy/post/media/PostMedia.svelte'
import PostMediaCompact from "$lib/components/lemmy/post/media/PostMediaCompact.svelte" import PostMediaCompact from '$lib/components/lemmy/post/media/PostMediaCompact.svelte'
export let post: PostView export let post: PostView
export let actions: boolean = true export let actions: boolean = true
@@ -25,7 +25,7 @@
</script> </script>
<Material <Material
color={view != "card" ? "none" : "distinct"} color={view != 'card' ? 'none' : 'distinct'}
padding="none" padding="none"
class="relative max-w-full min-w-0 w-full group class="relative max-w-full min-w-0 w-full group
{view != 'card' ? 'bg-transparent !border-0' : 'p-5'} {view == 'compact' {view != 'card' ? 'bg-transparent !border-0' : 'p-5'} {view == 'compact'
@@ -57,8 +57,9 @@
> >
<slot name="badges" slot="badges" /> <slot name="badges" slot="badges" />
</PostMeta> </PostMeta>
{#if post.post.embed_title != post.post.name || view == "compact"} {#if post.post.embed_title != post.post.name || view == 'compact'}
<a <a
target={$userSettings.openLinksInNewTab ? '_blank' : ''}
href="/post/{getInstance()}/{post.post.id}" href="/post/{getInstance()}/{post.post.id}"
class="font-medium max-w-full w-full break-words text-base" class="font-medium max-w-full w-full break-words text-base"
style="word-break: break-word;" style="word-break: break-word;"
@@ -70,7 +71,7 @@
{/if} {/if}
</div> </div>
<PostMedia bind:post={post.post} {view} /> <PostMedia bind:post={post.post} {view} />
{#if post.post.body && !post.post.nsfw && view != "compact"} {#if post.post.body && !post.post.nsfw && view != 'compact'}
<div <div
class="text-sm relative overflow-hidden class="text-sm relative overflow-hidden
bg-gradient-to-b text-transparent from-slate-600 via-slate-600 bg-gradient-to-b text-transparent from-slate-600 via-slate-600
@@ -81,7 +82,7 @@
</div> </div>
{/if} {/if}
</div> </div>
{#if view == "list" || view == "compact"} {#if view == 'list' || view == 'compact'}
<PostMediaCompact {view} bind:post={post.post} /> <PostMediaCompact {view} bind:post={post.post} />
{/if} {/if}
</div> </div>
@@ -91,8 +92,8 @@
bind:post bind:post
on:edit={(e) => { on:edit={(e) => {
toast({ toast({
content: "The post was edited successfully.", content: 'The post was edited successfully.',
type: "success", type: 'success',
}) })
}} }}
/> />
@@ -89,6 +89,7 @@
size="sm" size="sm"
href="/post/{getInstance()}/{post.post.id}" href="/post/{getInstance()}/{post.post.id}"
class="!text-inherit h-8 px-3" class="!text-inherit h-8 px-3"
target={$userSettings.openLinksInNewTab ? '_blank' : ''}
> >
<Icon slot="prefix" src={ChatBubbleOvalLeft} mini size="14" /> <Icon slot="prefix" src={ChatBubbleOvalLeft} mini size="14" />
<FormattedNumber number={post.counts.comments} /> <FormattedNumber number={post.counts.comments} />
+3
View File
@@ -72,6 +72,8 @@ interface Settings {
newWidth: boolean newWidth: boolean
markPostsAsRead: boolean markPostsAsRead: boolean
separateVotes: boolean separateVotes: boolean
openLinksInNewTab: boolean
} }
export const defaultSettings: Settings = { export const defaultSettings: Settings = {
@@ -120,6 +122,7 @@ export const defaultSettings: Settings = {
newWidth: true, newWidth: true,
markPostsAsRead: true, markPostsAsRead: true,
separateVotes: false, separateVotes: false,
openLinksInNewTab: false
} }
export const userSettings = writable(defaultSettings) export const userSettings = writable(defaultSettings)
+5
View File
@@ -109,6 +109,11 @@
bind:selected={$userSettings.separateVotes} bind:selected={$userSettings.separateVotes}
/> />
</Setting> </Setting>
<ToggleSetting
bind:checked={$userSettings.openLinksInNewTab}
title="Open posts in new tab"
description="Rather than opening posts in the same tab, open a separate one."
/>
<ToggleSetting <ToggleSetting
bind:checked={$userSettings.displayNames} bind:checked={$userSettings.displayNames}
title="Use display name" title="Use display name"