Use
This commit is contained in:
@@ -58,6 +58,7 @@ import type {
|
||||
import { type CollectionUser } from "ente-media/collection";
|
||||
import type { RemotePullOpts } from "ente-new/photos/components/gallery";
|
||||
import { PublicLinkCreated } from "ente-new/photos/components/share/PublicLinkCreated";
|
||||
import { useSettingsSnapshot } from "ente-new/photos/components/utils/use-snapshot";
|
||||
import { avatarTextColor } from "ente-new/photos/services/avatar";
|
||||
import {
|
||||
createPublicURL,
|
||||
@@ -1105,6 +1106,8 @@ const PublicShare: React.FC<PublicShareProps> = ({
|
||||
setBlockingLoad,
|
||||
onRemotePull,
|
||||
}) => {
|
||||
const { customDomain } = useSettingsSnapshot();
|
||||
|
||||
const {
|
||||
show: showPublicLinkCreated,
|
||||
props: publicLinkCreatedVisibilityProps,
|
||||
@@ -1126,11 +1129,15 @@ const PublicShare: React.FC<PublicShareProps> = ({
|
||||
void appendCollectionKeyToShareURL(
|
||||
publicURL.url,
|
||||
collection.key,
|
||||
).then((url) => setResolvedURL(url));
|
||||
).then((url) =>
|
||||
setResolvedURL(
|
||||
substituteCustomDomainIfNeeded(url, customDomain),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
setResolvedURL(undefined);
|
||||
}
|
||||
}, [collection.key, publicURL]);
|
||||
}, [collection.key, publicURL, customDomain]);
|
||||
|
||||
const handleCopyLink = () => {
|
||||
if (resolvedURL) void navigator.clipboard.writeText(resolvedURL);
|
||||
@@ -1164,6 +1171,16 @@ const PublicShare: React.FC<PublicShareProps> = ({
|
||||
);
|
||||
};
|
||||
|
||||
const substituteCustomDomainIfNeeded = (
|
||||
url: string,
|
||||
customDomain: string | undefined,
|
||||
) => {
|
||||
if (!customDomain) return url;
|
||||
const u = new URL(url);
|
||||
u.host = customDomain;
|
||||
return u.href;
|
||||
};
|
||||
|
||||
type EnablePublicShareOptionsProps = {
|
||||
setPublicURL: (value: PublicURL) => void;
|
||||
onLinkCreated: () => void;
|
||||
|
||||
@@ -90,6 +90,7 @@ import {
|
||||
isDevBuildAndUser,
|
||||
pullSettings,
|
||||
updateCFProxyDisabledPreference,
|
||||
updateCustomDomain,
|
||||
updateMapEnabled,
|
||||
} from "ente-new/photos/services/settings";
|
||||
import {
|
||||
@@ -987,38 +988,13 @@ const DomainSettings: React.FC<NestedSidebarDrawerVisibilityProps> = ({
|
||||
onClose,
|
||||
onRootClose,
|
||||
}) => {
|
||||
// const { showMiniDialog } = useBaseContext();
|
||||
|
||||
const { customDomain, customDomainCNAME } = useSettingsSnapshot();
|
||||
|
||||
// const handleSubmit = useCallback(async (newName: string) => {
|
||||
// const newFileName = [newName, extension].filter((x) => !!x).join(".");
|
||||
// if (newFileName != fileName) {
|
||||
// await onRename(newFileName);
|
||||
// }
|
||||
// onClose();
|
||||
// };
|
||||
const handleSubmit = useCallback(() => {
|
||||
// customDomain
|
||||
// showMiniDialog(
|
||||
// mapEnabled
|
||||
// ? confirmDisableMapsDialogAttributes(() =>
|
||||
// updateMapEnabled(false),
|
||||
// )
|
||||
// : confirmEnableMapsDialogAttributes(() =>
|
||||
// updateMapEnabled(true),
|
||||
// ),
|
||||
// ),
|
||||
// [showMiniDialog, mapEnabled],
|
||||
}, []);
|
||||
|
||||
const handleRootClose = () => {
|
||||
onClose();
|
||||
onRootClose();
|
||||
};
|
||||
|
||||
// const customDomain = "";
|
||||
|
||||
return (
|
||||
<TitledNestedSidebarDrawer
|
||||
{...{ open, onClose }}
|
||||
@@ -1037,7 +1013,7 @@ const DomainSettings: React.FC<NestedSidebarDrawerVisibilityProps> = ({
|
||||
submitButtonTitle={
|
||||
customDomain ? pt("Update") : pt("Set")
|
||||
}
|
||||
onSubmit={handleSubmit}
|
||||
onSubmit={updateCustomDomain}
|
||||
/>
|
||||
</DomainItem>
|
||||
<Divider sx={{ mt: 4, mb: 1 }} />
|
||||
|
||||
@@ -8,7 +8,11 @@ import log from "ente-base/log";
|
||||
import { updateShouldDisableCFUploadProxy } from "ente-gallery/services/upload";
|
||||
import { nullToUndefined } from "ente-utils/transform";
|
||||
import { z } from "zod/v4";
|
||||
import { fetchFeatureFlags, updateRemoteFlag } from "./remote-store";
|
||||
import {
|
||||
fetchFeatureFlags,
|
||||
updateRemoteFlag,
|
||||
updateRemoteValue,
|
||||
} from "./remote-store";
|
||||
|
||||
/**
|
||||
* In-memory flags that tracks various settings.
|
||||
@@ -222,6 +226,17 @@ export const isDevBuildAndUser = () => isDevBuild && isDevUserViaEmail();
|
||||
const isDevUserViaEmail = () =>
|
||||
!!savedPartialLocalUser()?.email?.endsWith("@ente.io");
|
||||
|
||||
/**
|
||||
* Persist the user's custom domain preference both locally and on remote.
|
||||
*
|
||||
* Setting the value to a blank string is equivalent to deleting the custom
|
||||
* domain value altogether.
|
||||
*/
|
||||
export const updateCustomDomain = async (customDomain: string) => {
|
||||
await updateRemoteValue("customDomain", customDomain);
|
||||
return pullSettings();
|
||||
};
|
||||
|
||||
/**
|
||||
* Persist the user's map enabled preference both locally and on remote.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user