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
@@ -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