Update utils

This commit is contained in:
jeffvli
2022-10-24 22:09:58 -07:00
parent 663b951cd7
commit 921c688c94
11 changed files with 68 additions and 17 deletions
@@ -0,0 +1,11 @@
export const constrainSidebarWidth = (num: number) => {
if (num < 165) {
return 165;
}
if (num > 400) {
return 400;
}
return num;
};
+28
View File
@@ -0,0 +1,28 @@
// export const encryptString = (str: string) => {
// return cryptr;
// // const iv = crypto.randomBytes(16);
// // const key = crypto.randomBytes(32);
// // const cipher = crypto.createCipheriv('aes-256-cbc', key, iv);
// // let data = cipher.update(str, 'utf-8', 'hex');
// // data += cipher.final('hex');
// // return { data, iv, key };
// };
// export const decryptString = ({
// data,
// key,
// iv,
// }: {
// data: string;
// iv: string;
// key: string;
// }) => {
// const decipher = crypto.createDecipheriv('aes-256-cbc', key, iv);
// let decryptedData = decipher.update(data, 'hex', 'utf-8');
// decryptedData += decipher.final('utf8');
// return decryptedData;
// };
@@ -1,9 +0,0 @@
const getJellyfinImageUrl = (baseUrl: string, item: any, size?: number) => {
return (
`${baseUrl}/Items` +
`/${item.Id}` +
`/Images/Primary${
size ? `?width=${size}&height=${size}` : '?height=350'
}&quality=90`
);
};
+8 -6
View File
@@ -1,6 +1,8 @@
export * from './randomString';
export * from './normalizeServerUrl';
export * from './getJellyfinStreamUrl';
export * from './getSubsonicStreamUrl';
export * from './getServerFolderAuth';
export * from './setLocalStorageSettings';
export * from './random-string';
export * from './normalize-server-url';
export * from './jellyfin';
export * from './subsonic';
export * from './server-folder-auth';
export * from './set-local-storage-setttings';
export * from './constrain-sidebar-width';
export * from './title-case';
@@ -1,4 +1,18 @@
import { Song } from '../api/types';
import { Song } from '@/renderer/api/types';
export const getJellyfinImageUrl = (
baseUrl: string,
item: any,
size?: number
) => {
return (
`${baseUrl}/Items` +
`/${item.Id}` +
`/Images/Primary${
size ? `?width=${size}&height=${size}` : '?height=350'
}&quality=90`
);
};
export const getJellyfinStreamUrl = (
auth: any,
@@ -1,4 +1,4 @@
import { Song } from '../api/types';
import { Song } from '@/renderer/api/types';
export const getSubsonicStreamUrl = (
auth: any,
+5
View File
@@ -0,0 +1,5 @@
export const titleCase = (str: string) => {
return str.replace(/\w\S*/g, (txt) => {
return txt.charAt(0).toUpperCase() + txt.slice(1).toLowerCase();
});
};