mirror of
https://github.com/sussy-code/smov.git
synced 2024-12-30 16:17:41 +01:00
commit
3b3457532a
5 changed files with 2040 additions and 2006 deletions
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "movie-web",
|
"name": "movie-web",
|
||||||
"version": "3.0.1",
|
"version": "3.0.2",
|
||||||
"private": true,
|
"private": true,
|
||||||
"homepage": "https://movie.squeezebox.dev",
|
"homepage": "https://movie.squeezebox.dev",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -85,4 +85,4 @@
|
||||||
"vite-plugin-checker": "^0.5.6",
|
"vite-plugin-checker": "^0.5.6",
|
||||||
"vite-plugin-package-version": "^1.0.2"
|
"vite-plugin-package-version": "^1.0.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,3 +1,3 @@
|
||||||
export const DISCORD_LINK = "https://discord.gg/Jhqt4Xzpfb";
|
export const DISCORD_LINK = "https://discord.gg/Jhqt4Xzpfb";
|
||||||
export const GITHUB_LINK = "https://github.com/movie-web/movie-web";
|
export const GITHUB_LINK = "https://github.com/movie-web/movie-web";
|
||||||
export const APP_VERSION = "3.0.1";
|
export const APP_VERSION = "3.0.2";
|
||||||
|
|
|
@ -11,6 +11,52 @@ function fromBinary(str: string): Uint8Array {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function importV2Data({ data, time }: { data: any; time: Date }) {
|
||||||
|
const savedTime = localStorage.getItem("mw-migration-date");
|
||||||
|
if (savedTime) {
|
||||||
|
if (new Date(savedTime) >= time) {
|
||||||
|
// has already migrated this or something newer, skip
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// restore migration data
|
||||||
|
if (data.bookmarks)
|
||||||
|
localStorage.setItem("mw-bookmarks", JSON.stringify(data.bookmarks));
|
||||||
|
if (data.videoProgress)
|
||||||
|
localStorage.setItem("video-progress", JSON.stringify(data.videoProgress));
|
||||||
|
|
||||||
|
localStorage.setItem("mw-migration-date", time.toISOString());
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function EmbedMigration() {
|
||||||
|
let hasReceivedMigrationData = false;
|
||||||
|
|
||||||
|
const onMessage = (e: any) => {
|
||||||
|
const data = e.data;
|
||||||
|
if (data && data.isMigrationData && !hasReceivedMigrationData) {
|
||||||
|
hasReceivedMigrationData = true;
|
||||||
|
const didImport = importV2Data({
|
||||||
|
data: data.data,
|
||||||
|
time: data.date,
|
||||||
|
});
|
||||||
|
if (didImport) window.location.reload();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
window.addEventListener("message", onMessage);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
window.removeEventListener("message", onMessage);
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
return <iframe src="https://movie.squeezebox.dev" hidden />;
|
||||||
|
}
|
||||||
|
|
||||||
export function V2MigrationView() {
|
export function V2MigrationView() {
|
||||||
const [done, setDone] = useState(false);
|
const [done, setDone] = useState(false);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -28,24 +74,10 @@ export function V2MigrationView() {
|
||||||
);
|
);
|
||||||
const timeOfMigration = new Date(params.get("m-time") as string);
|
const timeOfMigration = new Date(params.get("m-time") as string);
|
||||||
|
|
||||||
const savedTime = localStorage.getItem("mw-migration-date");
|
importV2Data({
|
||||||
if (savedTime) {
|
data,
|
||||||
if (new Date(savedTime) >= timeOfMigration) {
|
time: timeOfMigration,
|
||||||
// has already migrated this or something newer, skip
|
});
|
||||||
setDone(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// restore migration data
|
|
||||||
if (data.bookmarks)
|
|
||||||
localStorage.setItem("mw-bookmarks", JSON.stringify(data.bookmarks));
|
|
||||||
if (data.videoProgress)
|
|
||||||
localStorage.setItem(
|
|
||||||
"video-progress",
|
|
||||||
JSON.stringify(data.videoProgress)
|
|
||||||
);
|
|
||||||
localStorage.setItem("mw-migration-date", timeOfMigration.toISOString());
|
|
||||||
|
|
||||||
// finished
|
// finished
|
||||||
setDone(true);
|
setDone(true);
|
||||||
|
|
|
@ -14,6 +14,7 @@ import { useAutoAnimate } from "@formkit/auto-animate/react";
|
||||||
import { useHistory } from "react-router-dom";
|
import { useHistory } from "react-router-dom";
|
||||||
import { Modal, ModalCard } from "@/components/layout/Modal";
|
import { Modal, ModalCard } from "@/components/layout/Modal";
|
||||||
import { Button } from "@/components/Button";
|
import { Button } from "@/components/Button";
|
||||||
|
import { EmbedMigration } from "../other/v2Migration";
|
||||||
|
|
||||||
function Bookmarks() {
|
function Bookmarks() {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
@ -172,6 +173,7 @@ function NewDomainModal() {
|
||||||
export function HomeView() {
|
export function HomeView() {
|
||||||
return (
|
return (
|
||||||
<div className="mb-16 mt-32">
|
<div className="mb-16 mt-32">
|
||||||
|
<EmbedMigration />
|
||||||
<NewDomainModal />
|
<NewDomainModal />
|
||||||
<Bookmarks />
|
<Bookmarks />
|
||||||
<Watched />
|
<Watched />
|
||||||
|
|
Loading…
Reference in a new issue