refactor: use crypto.randomUUID vs uuid.v4 (#249)
* refactor: use randomUUID vs uuidv4 * chore: don't import the node version * chore: no need to non-null assert here
This commit is contained in:
1 parent
83ef175444
commit
605e2be72d
4 files changed
+4
-26
No files matched your search
@@ -45,7 +45,6 @@
|
||||
"tauri-plugin-log-api": "github:tauri-apps/tauri-plugin-log#v1",
|
||||
"tauri-plugin-store-api": "github:tauri-apps/tauri-plugin-store",
|
||||
"typescript": "^5.3.3",
|
||||
"uuid": "^9.0.1",
|
||||
"vite-plugin-svgr": "^4.2.0",
|
||||
"wavesurfer.js": "^7.6.1",
|
||||
"zustand": "^4.4.7"
|
||||
@@ -53,7 +52,6 @@
|
||||
"devDependencies": {
|
||||
"@biomejs/biome": "^1.5.0",
|
||||
"@tauri-apps/cli": "^1.5.9",
|
||||
"@types/uuid": "^9.0.7",
|
||||
"@vitejs/plugin-react": "^4.2.1",
|
||||
"eslint": "^8.56.0",
|
||||
"eslint-plugin-react": "^7.33.2",
|
||||
|
||||
Generated
-15
@@ -104,9 +104,6 @@ dependencies:
|
||||
typescript:
|
||||
specifier: ^5.3.3
|
||||
version: 5.3.3
|
||||
uuid:
|
||||
specifier: ^9.0.1
|
||||
version: 9.0.1
|
||||
vite-plugin-svgr:
|
||||
specifier: ^4.2.0
|
||||
version: 4.2.0(typescript@5.3.3)(vite@5.0.11)
|
||||
@@ -124,9 +121,6 @@ devDependencies:
|
||||
'@tauri-apps/cli':
|
||||
specifier: ^1.5.9
|
||||
version: 1.5.9
|
||||
'@types/uuid':
|
||||
specifier: ^9.0.7
|
||||
version: 9.0.7
|
||||
'@vitejs/plugin-react':
|
||||
specifier: ^4.2.1
|
||||
version: 4.2.1(vite@5.0.11)
|
||||
@@ -1609,10 +1603,6 @@ packages:
|
||||
resolution: {integrity: sha512-dqId9J8K/vGi5Zr7oo212BGii5m3q5Hxlkwy3WpYuKPklmBEvsbMYYyLxAQpSffdLl/gdW0XUpKWFvYmyoWCoQ==}
|
||||
dev: false
|
||||
|
||||
/@types/uuid@9.0.7:
|
||||
resolution: {integrity: sha512-WUtIVRUZ9i5dYXefDEAI7sh9/O7jGvHg7Df/5O/gtH3Yabe5odI3UWopVR1qbPXQtvOxWu3mM4XxlYeZtMWF4g==}
|
||||
dev: true
|
||||
|
||||
/@ungap/structured-clone@1.2.0:
|
||||
resolution: {integrity: sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==}
|
||||
|
||||
@@ -4192,11 +4182,6 @@ packages:
|
||||
react: 18.2.0
|
||||
dev: false
|
||||
|
||||
/uuid@9.0.1:
|
||||
resolution: {integrity: sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==}
|
||||
hasBin: true
|
||||
dev: false
|
||||
|
||||
/vfile-message@4.0.2:
|
||||
resolution: {integrity: sha512-jRDZ1IMLttGj41KcZvlrYAaI3CfqpLpfpf+Mfig13viT6NKvRzWZ+lXz0Y5D60w6uJIBAOGq9mSHf0gktF0duw==}
|
||||
dependencies:
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { RecommendedServerInfo } from "@jellyfin/sdk";
|
||||
import { Store } from "tauri-plugin-store-api";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
|
||||
interface ServerInfo extends RecommendedServerInfo {
|
||||
id: string;
|
||||
|
||||
@@ -5,7 +5,6 @@ import { version as appVer } from "../../../package.json";
|
||||
// Initial custom axios client to use tauri's http module
|
||||
import axios from "axios";
|
||||
import axiosTauriApiAdapter from "axios-tauri-api-adapter";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
|
||||
export const axiosClient = axios.create({
|
||||
adapter: axiosTauriApiAdapter,
|
||||
@@ -15,13 +14,10 @@ export const axiosClient = axios.create({
|
||||
timeout: 60000,
|
||||
});
|
||||
|
||||
let deviceId = localStorage.getItem("deviceId");
|
||||
const deviceId = localStorage.getItem("deviceId") || crypto.randomUUID();
|
||||
|
||||
if (!deviceId) {
|
||||
const randomId = uuidv4();
|
||||
localStorage.setItem("deviceId", randomId);
|
||||
|
||||
deviceId = randomId;
|
||||
if (!localStorage.getItem("deviceId")) {
|
||||
localStorage.setItem("deviceId", deviceId);
|
||||
}
|
||||
|
||||
const jellyfin = new Jellyfin({
|
||||
@@ -31,7 +27,7 @@ const jellyfin = new Jellyfin({
|
||||
},
|
||||
deviceInfo: {
|
||||
name: "JellyPlayer",
|
||||
id: deviceId!,
|
||||
id: deviceId,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user