minor improvements
This commit is contained in:
parent
826f9a1b0f
commit
b2cac4f629
|
@ -17,7 +17,7 @@ import { getData, LS_KEYS } from 'utils/storage/localStorage';
|
|||
import SubmitButton from './SubmitButton';
|
||||
import MessageDialog from './MessageDialog';
|
||||
import { Collection } from 'types/collection';
|
||||
import { transformShareURLForHost } from 'utils/collection';
|
||||
import { appendCollectionKeyToShareURL } from 'utils/collection';
|
||||
import { Row, Value } from './Container';
|
||||
import { CodeBlock } from './CodeBlock';
|
||||
import { ButtonVariant, getVariantColor } from './pages/gallery/LinkButton';
|
||||
|
@ -46,7 +46,7 @@ function CollectionShare(props: Props) {
|
|||
useEffect(() => {
|
||||
const main = async () => {
|
||||
if (props.collection?.publicURLs?.[0]?.url) {
|
||||
const t = await transformShareURLForHost(
|
||||
const t = await appendCollectionKeyToShareURL(
|
||||
props.collection?.publicURLs?.[0]?.url,
|
||||
props.collection.key
|
||||
);
|
||||
|
@ -92,8 +92,12 @@ function CollectionShare(props: Props) {
|
|||
try {
|
||||
galleryContext.startLoading();
|
||||
const publicURL = await createShareableURL(props.collection);
|
||||
const sharableURL = await appendCollectionKeyToShareURL(
|
||||
publicURL.url,
|
||||
props.collection.key
|
||||
);
|
||||
galleryContext.finishLoading();
|
||||
setPublicShareUrl(publicURL.url);
|
||||
setPublicShareUrl(sharableURL);
|
||||
await galleryContext.syncWithRemote(false, true);
|
||||
} catch (e) {
|
||||
const errorMessage = handleSharingErrors(e);
|
||||
|
@ -275,8 +279,7 @@ function CollectionShare(props: Props) {
|
|||
</Table>
|
||||
</>
|
||||
)}
|
||||
{props.collection.sharees?.length === 0 &&
|
||||
props.collection.publicURLs?.length === 0 && (
|
||||
{props.collection.sharees?.length === 0 && !publicShareUrl && (
|
||||
<div style={{ marginTop: '12px' }}>
|
||||
{constants.ZERO_SHAREES()}
|
||||
</div>
|
||||
|
|
|
@ -109,7 +109,7 @@ export async function downloadCollection(
|
|||
}
|
||||
}
|
||||
|
||||
export async function transformShareURLForHost(
|
||||
export async function appendCollectionKeyToShareURL(
|
||||
url: string,
|
||||
collectionKey: string
|
||||
) {
|
||||
|
@ -117,10 +117,12 @@ export async function transformShareURLForHost(
|
|||
if (!url) {
|
||||
return null;
|
||||
}
|
||||
const host = window.location.host;
|
||||
const sharableURL = new URL(url);
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
const host = window.location.host;
|
||||
sharableURL.host = host;
|
||||
sharableURL.pathname = '/shared-album';
|
||||
}
|
||||
sharableURL.hash = await worker.toHex(collectionKey);
|
||||
sharableURL.protocol = 'http';
|
||||
return sharableURL.href;
|
||||
|
|
Loading…
Reference in a new issue