Fix:
* Breadcrumbs too wide in deeply nested directories * Sharedialog copies link and calls navigator.share at the same time * Link copy feedback is not clear * Show embed code when public read * Hide hidden files from audio playlist
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
<script lang="ts">
|
||||
import type { FSNavigator } from "./FSNavigator";
|
||||
import { fs_check_is_error, fs_node_icon, fs_share_hotlink_url, fs_share_url, fs_update, type FSNode, type FSPermissions } from "lib/FilesystemAPI.svelte";
|
||||
import { copy_text } from "util/Util";
|
||||
import CopyButton from "layout/CopyButton.svelte";
|
||||
import Dialog from "layout/Dialog.svelte";
|
||||
import { fade } from "svelte/transition";
|
||||
import { get_user } from "lib/NovaAPI";
|
||||
import Button from "layout/Button.svelte";
|
||||
|
||||
let { nav }: {
|
||||
nav: FSNavigator;
|
||||
@@ -13,10 +13,8 @@ let { nav }: {
|
||||
|
||||
let path: FSNode[]
|
||||
let base: FSNode = $state()
|
||||
let toast = $state("")
|
||||
let share_url = $state("")
|
||||
let direct_share_url = $state("")
|
||||
let is_parent = $state(false)
|
||||
let parent_node: FSNode = $state()
|
||||
|
||||
let dialog: Dialog = $state()
|
||||
@@ -71,15 +69,19 @@ const make_public = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
let share_parent = $state(false)
|
||||
let navigator_share = $state(false)
|
||||
const share = async () => {
|
||||
// If the base node does not have a public ID then the file is shared
|
||||
// through a parent node. In that case we ask the user if it was their
|
||||
// intention to share the parent directory
|
||||
is_parent = base.id === undefined
|
||||
if (is_parent) {
|
||||
// If the base node is not shared then the file is shared through a parent
|
||||
// node. In that case we ask the user if it was their intention to share the
|
||||
// parent directory
|
||||
share_parent = !base.is_shared()
|
||||
navigator_share = navigator.share !== undefined
|
||||
|
||||
if (!base.is_shared()) {
|
||||
// Walk path backwards looking for the last public ID
|
||||
for (let i = path.length - 1; i >= 0; i--) {
|
||||
if (path[i].id !== undefined && path[i].id !== "me") {
|
||||
if (path[i].is_shared()) {
|
||||
parent_node = path[i]
|
||||
break
|
||||
}
|
||||
@@ -88,25 +90,21 @@ const share = async () => {
|
||||
|
||||
share_url = fs_share_url(path)
|
||||
direct_share_url = fs_share_hotlink_url(path)
|
||||
}
|
||||
|
||||
const nav_share = async (url: string) => {
|
||||
try {
|
||||
await navigator.share({
|
||||
title: base.name,
|
||||
text: "I would like to share '" + base.name + "' with you",
|
||||
url: share_url,
|
||||
url: url,
|
||||
})
|
||||
} catch(_) {
|
||||
if (copy_text(share_url)) {
|
||||
toast = "Link copied to clipboard"
|
||||
setTimeout(() => {toast = ""}, 10000)
|
||||
} else {
|
||||
alert("Could not copy text")
|
||||
}
|
||||
} catch(err) {
|
||||
alert("navigator share not available: "+ err)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
<Dialog bind:this={dialog_not_allowed}>
|
||||
<div class="dialog_inner">
|
||||
<div class="highlight_yellow" transition:fade>
|
||||
@@ -118,15 +116,13 @@ const share = async () => {
|
||||
|
||||
<Dialog bind:this={dialog}>
|
||||
<div class="dialog_inner">
|
||||
{#if toast !== ""}
|
||||
<div class="highlight_green" transition:fade>{toast}</div>
|
||||
<div class="separator" transition:fade></div>
|
||||
{/if}
|
||||
|
||||
<div>Sharing link</div>
|
||||
<div class="link_copy">
|
||||
<div class="button_container">
|
||||
<CopyButton text={share_url}>Copy</CopyButton>
|
||||
{#if navigator_share}
|
||||
<Button icon="share" label="Share" click={() => {nav_share(share_url)}}/>
|
||||
{/if}
|
||||
</div>
|
||||
<a href="{share_url}">{share_url}</a>
|
||||
</div>
|
||||
@@ -135,11 +131,14 @@ const share = async () => {
|
||||
<div class="link_copy">
|
||||
<div class="button_container">
|
||||
<CopyButton text={direct_share_url}>Copy</CopyButton>
|
||||
{#if navigator_share}
|
||||
<Button icon="share" label="Share" click={() => {nav_share(direct_share_url)}}/>
|
||||
{/if}
|
||||
</div>
|
||||
<a href="{direct_share_url}">{direct_share_url}</a>
|
||||
</div>
|
||||
|
||||
{#if is_parent}
|
||||
{#if share_parent}
|
||||
<div class="separator"></div>
|
||||
<div>
|
||||
This link also gives access to
|
||||
|
||||
Reference in New Issue
Block a user