Inline
This commit is contained in:
@@ -68,7 +68,6 @@ import {
|
||||
import {
|
||||
appendCollectionKeyToShareURL,
|
||||
getDeviceLimitOptions,
|
||||
shareExpiryOptions,
|
||||
} from "utils/collection";
|
||||
import * as Yup from "yup";
|
||||
|
||||
@@ -1620,6 +1619,37 @@ const ManageLinkExpiry: React.FC<ManageLinkExpiryProps> = ({
|
||||
);
|
||||
};
|
||||
|
||||
export const shareExpiryOptions = () => [
|
||||
{ label: t("never"), value: () => 0 },
|
||||
{ label: t("after_time.hour"), value: () => microsecsAfter("hour") },
|
||||
{ label: t("after_time.day"), value: () => microsecsAfter("day") },
|
||||
{ label: t("after_time.week"), value: () => microsecsAfter("week") },
|
||||
{ label: t("after_time.month"), value: () => microsecsAfter("month") },
|
||||
{ label: t("after_time.year"), value: () => microsecsAfter("year") },
|
||||
];
|
||||
|
||||
const microsecsAfter = (after: "hour" | "day" | "week" | "month" | "year") => {
|
||||
let date = new Date();
|
||||
switch (after) {
|
||||
case "hour":
|
||||
date = new Date(date.getTime() + 60 * 60 * 1000);
|
||||
break;
|
||||
case "day":
|
||||
date.setDate(date.getDate() + 1);
|
||||
break;
|
||||
case "week":
|
||||
date.setDate(date.getDate() + 7);
|
||||
break;
|
||||
case "month":
|
||||
date.setMonth(date.getMonth() + 1);
|
||||
break;
|
||||
case "year":
|
||||
date.setFullYear(date.getFullYear() + 1);
|
||||
break;
|
||||
}
|
||||
return date.getTime() * 1000;
|
||||
};
|
||||
|
||||
interface ManageDeviceLimitProps {
|
||||
publicShareProp: PublicURL;
|
||||
collection: Collection;
|
||||
|
||||
@@ -21,7 +21,6 @@ import { updateMagicMetadata } from "@/new/photos/services/magic-metadata";
|
||||
import { safeDirectoryName } from "@/new/photos/utils/native-fs";
|
||||
import { CustomError } from "@ente/shared/error";
|
||||
import { LS_KEYS, getData } from "@ente/shared/storage/localStorage";
|
||||
import { getUnixTimeInMicroSecondsWithDelta } from "@ente/shared/time";
|
||||
import type { User } from "@ente/shared/user/types";
|
||||
import bs58 from "bs58";
|
||||
import { t } from "i18next";
|
||||
@@ -199,30 +198,6 @@ export function getDeviceLimitOptions() {
|
||||
return [0, 2, 5, 10, 25, 50].map((i) => _intSelectOption(i));
|
||||
}
|
||||
|
||||
export const shareExpiryOptions = () => [
|
||||
{ label: t("never"), value: () => 0 },
|
||||
{
|
||||
label: t("after_time.hour"),
|
||||
value: () => getUnixTimeInMicroSecondsWithDelta({ hours: 1 }),
|
||||
},
|
||||
{
|
||||
label: t("after_time.day"),
|
||||
value: () => getUnixTimeInMicroSecondsWithDelta({ days: 1 }),
|
||||
},
|
||||
{
|
||||
label: t("after_time.week"),
|
||||
value: () => getUnixTimeInMicroSecondsWithDelta({ days: 7 }),
|
||||
},
|
||||
{
|
||||
label: t("after_time.month"),
|
||||
value: () => getUnixTimeInMicroSecondsWithDelta({ months: 1 }),
|
||||
},
|
||||
{
|
||||
label: t("after_time.year"),
|
||||
value: () => getUnixTimeInMicroSecondsWithDelta({ years: 1 }),
|
||||
},
|
||||
];
|
||||
|
||||
export const changeCollectionVisibility = async (
|
||||
collection: Collection,
|
||||
visibility: ItemVisibility,
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
export interface TimeDelta {
|
||||
hours?: number;
|
||||
days?: number;
|
||||
months?: number;
|
||||
years?: number;
|
||||
}
|
||||
|
||||
export function getUnixTimeInMicroSecondsWithDelta(delta: TimeDelta): number {
|
||||
let date = new Date();
|
||||
if (delta?.hours) {
|
||||
date = new Date(date.getTime() + delta.hours * 60 * 60 * 1000);
|
||||
}
|
||||
if (delta?.days) {
|
||||
date.setDate(date.getDate() + delta.days);
|
||||
}
|
||||
if (delta?.months) {
|
||||
date.setMonth(date.getMonth() + delta.months);
|
||||
}
|
||||
if (delta?.years) {
|
||||
date.setFullYear(date.getFullYear() + delta.years);
|
||||
}
|
||||
return date.getTime() * 1000;
|
||||
}
|
||||
Reference in New Issue
Block a user