mirror of
https://github.com/immich-app/immich.git
synced 2025-12-22 17:24:56 +03:00
chore(web): change license wording and other things (#11309)
This commit is contained in:
32
web/src/lib/utils/purchase-utils.ts
Normal file
32
web/src/lib/utils/purchase-utils.ts
Normal 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);
|
||||
};
|
||||
Reference in New Issue
Block a user