Block sharing if subscription does not support it
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
<script lang="ts">
|
||||
import type { FSNavigator } from "./FSNavigator";
|
||||
import { fs_node_icon, fs_share_hotlink_url, fs_share_url, fs_update, type FSNode, type FSPermissions } from "lib/FilesystemAPI.svelte";
|
||||
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";
|
||||
|
||||
let { nav }: {
|
||||
nav: FSNavigator;
|
||||
@@ -19,13 +20,33 @@ let is_parent = $state(false)
|
||||
let parent_node: FSNode = $state()
|
||||
|
||||
let dialog: Dialog = $state()
|
||||
let dialog_not_allowed: Dialog = $state()
|
||||
export const open = async (e: MouseEvent, p: FSNode[]) => {
|
||||
path = p
|
||||
base = path[path.length-1]
|
||||
|
||||
const user = await get_user()
|
||||
if (user.subscription.file_sharing === false && base.created_by === user.id) {
|
||||
|
||||
}
|
||||
|
||||
share_url = fs_share_url(path)
|
||||
if (share_url === "") {
|
||||
// File is not public, make public
|
||||
await make_public()
|
||||
try {
|
||||
await make_public()
|
||||
} catch (err) {
|
||||
if (fs_check_is_error(err, "sharing_not_allowed")) {
|
||||
if (e.target instanceof HTMLButtonElement) {
|
||||
dialog_not_allowed.open(e.target.getBoundingClientRect())
|
||||
} else {
|
||||
dialog_not_allowed.open((e.target as HTMLElement).parentElement.getBoundingClientRect())
|
||||
}
|
||||
return
|
||||
} else {
|
||||
alert("Error file making file public: "+err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
await share()
|
||||
@@ -85,6 +106,16 @@ const share = async () => {
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
<Dialog bind:this={dialog_not_allowed}>
|
||||
<div class="dialog_inner">
|
||||
<div class="highlight_yellow" transition:fade>
|
||||
Sharing is not allowed on free accounts. Upgrade to premium to
|
||||
enable this feature
|
||||
</div>
|
||||
</div>
|
||||
</Dialog>
|
||||
|
||||
<Dialog bind:this={dialog}>
|
||||
<div class="dialog_inner">
|
||||
{#if toast !== ""}
|
||||
|
||||
Reference in New Issue
Block a user