chore(web): change license wording and other things (#11309)

This commit is contained in:
Alex 2024-07-26 10:34:35 -05:00 committed by GitHub
parent bc20710c6d
commit ef7a6bb246
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
40 changed files with 1045 additions and 518 deletions

View file

@ -1,5 +1,5 @@
import { browser } from '$app/environment';
import { licenseStore } from '$lib/stores/license.store';
import { purchaseStore } from '$lib/stores/purchase.store';
import { serverInfo } from '$lib/stores/server-info.store';
import { preferences as preferences$, user as user$ } from '$lib/stores/user.store';
import { getAboutInfo, getMyPreferences, getMyUser, getStorage } from '@immich/sdk';
@ -26,7 +26,7 @@ export const loadUser = async () => {
// Check for license status
if (serverInfo.licensed || user.license?.activatedAt) {
licenseStore.setLicenseStatus(true);
purchaseStore.setPurchaseStatus(true);
}
}
return user;

View file

@ -1,11 +1,11 @@
import { PUBLIC_IMMICH_BUY_HOST, PUBLIC_IMMICH_PAY_HOST } from '$env/static/public';
import type { ImmichLicense } from '$lib/constants';
import type { ImmichProduct } from '$lib/constants';
import { serverConfig } from '$lib/stores/server-config.store';
import { setServerLicense, setUserLicense, type LicenseResponseDto } from '@immich/sdk';
import { get } from 'svelte/store';
import { loadUser } from './auth';
export const activateLicense = async (licenseKey: string, activationKey: string): Promise<LicenseResponseDto> => {
export const activateProduct = async (licenseKey: string, activationKey: string): Promise<LicenseResponseDto> => {
// Send server key to user activation if user is not admin
const user = await loadUser();
const isServerActivation = user?.isAdmin && licenseKey.search('IMSV') !== -1;
@ -21,7 +21,7 @@ export const getActivationKey = async (licenseKey: string): Promise<string> => {
return response.text();
};
export const getLicenseLink = (license: ImmichLicense) => {
export const getLicenseLink = (license: ImmichProduct) => {
const url = new URL('/', PUBLIC_IMMICH_BUY_HOST);
url.searchParams.append('productId', license);
url.searchParams.append('instanceUrl', get(serverConfig).externalDomain || window.origin);

View file

@ -0,0 +1,32 @@
import { preferences } from '$lib/stores/user.store';
import { updateMyPreferences } from '@immich/sdk';
import { DateTime } from 'luxon';
import { get } from 'svelte/store';
export const getButtonVisibility = (): boolean => {
const myPreferences = get(preferences);
if (!myPreferences) {
return true;
}
const { purchase } = myPreferences;
const now = DateTime.now();
const hideUntilDate = DateTime.fromISO(purchase.hideBuyButtonUntil);
const dayLeft = Number(now.diff(hideUntilDate, 'days').days.toFixed(0));
return dayLeft > 0;
};
export const setSupportBadgeVisibility = async (value: boolean) => {
const response = await updateMyPreferences({
userPreferencesUpdateDto: {
purchase: {
showSupportBadge: value,
},
},
});
preferences.set(response);
};