tangled
alpha
login
or
join now
dunkirk.sh
/
pstream-ng
1
fork
atom
pstream is dead; long live pstream
taciturnaxolotl.github.io/pstream-ng/
1
fork
atom
overview
issues
pulls
pipelines
what happened to my prettier config ðŸ˜
Pas
1 month ago
9af6e36d
cb6675f6
+38
-14
6 changed files
expand all
collapse all
unified
split
src
backend
accounts
import.ts
hooks
auth
useMigration.ts
pages
migration
MigrationDownload.tsx
MigrationUpload.tsx
stores
progress
index.ts
watchHistory
index.ts
+1
-1
src/backend/accounts/import.ts
···
6
6
import { BookmarkInput } from "./bookmarks";
7
7
import { ProgressInput } from "./progress";
8
8
import { SettingsInput } from "./settings";
9
9
-
import { WatchHistoryInput, watchHistoryItemsToInputs } from "./watchHistory";
9
9
+
import { WatchHistoryInput } from "./watchHistory";
10
10
11
11
export function importProgress(
12
12
url: string,
+9
-2
src/hooks/auth/useMigration.ts
···
18
18
importSettings,
19
19
importWatchHistory,
20
20
} from "@/backend/accounts/import";
21
21
-
import { watchHistoryItemsToInputs } from "@/backend/accounts/watchHistory";
22
21
// import { getLoginChallengeToken, loginAccount } from "@/backend/accounts/login";
23
22
import { progressMediaItemToInputs } from "@/backend/accounts/progress";
24
23
import {
25
24
getRegisterChallengeToken,
26
25
registerAccount,
27
26
} from "@/backend/accounts/register";
27
27
+
import { watchHistoryItemsToInputs } from "@/backend/accounts/watchHistory";
28
28
// import { removeSession } from "@/backend/accounts/sessions";
29
29
// import { getSettings } from "@/backend/accounts/settings";
30
30
// import {
···
186
186
bytesToBase64(keys.seed),
187
187
);
188
188
189
189
-
await importData(backendUrl, account, progress, watchHistory, bookmarks, groupOrder);
189
189
+
await importData(
190
190
+
backendUrl,
191
191
+
account,
192
192
+
progress,
193
193
+
watchHistory,
194
194
+
bookmarks,
195
195
+
groupOrder,
196
196
+
);
190
197
191
198
return account;
192
199
},
+6
-3
src/pages/migration/MigrationDownload.tsx
···
108
108
console.error("Error during data download:", error);
109
109
setStatus("error");
110
110
}
111
111
-
}, [
111
111
+
}, [
112
112
bookmarks,
113
113
progress,
114
114
watchHistory,
···
174
174
175
175
<div className="p-4 bg-background rounded-lg">
176
176
<div className="flex items-center gap-2">
177
177
-
<Icon icon={Icons.HISTORY} className="text-xl" />
177
177
+
<Icon icon={Icons.CLOCK} className="text-xl" />
178
178
<span className="font-medium">
179
179
{t("migration.preview.items.watchHistory")}
180
180
</span>
181
181
</div>
182
182
<div className="text-xl font-bold mt-2">
183
183
-
{Object.keys(persistedWatchHistory.items || watchHistory).length}
183
183
+
{
184
184
+
Object.keys(persistedWatchHistory.items || watchHistory)
185
185
+
.length
186
186
+
}
184
187
</div>
185
188
</div>
186
189
+11
-4
src/pages/migration/MigrationUpload.tsx
···
10
10
importSettings,
11
11
importWatchHistory,
12
12
} from "@/backend/accounts/import";
13
13
-
import { watchHistoryItemsToInputs } from "@/backend/accounts/watchHistory";
14
13
import { progressMediaItemToInputs } from "@/backend/accounts/progress";
14
14
+
import { watchHistoryItemsToInputs } from "@/backend/accounts/watchHistory";
15
15
import { Button } from "@/components/buttons/Button";
16
16
import { Icon, Icons } from "@/components/Icon";
17
17
import { SettingsCard } from "@/components/layout/SettingsCard";
···
157
157
typeof item.watchedAt === "number"
158
158
? item.watchedAt
159
159
: Date.now(),
160
160
-
completed: typeof item.completed === "boolean" ? item.completed : false,
160
160
+
completed:
161
161
+
typeof item.completed === "boolean"
162
162
+
? item.completed
163
163
+
: false,
161
164
episodeId: item.episodeId,
162
165
seasonId: item.seasonId,
163
166
seasonNumber: item.seasonNumber,
···
214
217
uploadedData.watchHistory &&
215
218
Object.keys(uploadedData.watchHistory).length > 0
216
219
) {
217
217
-
const watchHistoryInputs = watchHistoryItemsToInputs(uploadedData.watchHistory);
220
220
+
const watchHistoryInputs = watchHistoryItemsToInputs(
221
221
+
uploadedData.watchHistory,
222
222
+
);
218
223
importPromises.push(
219
224
importWatchHistory(backendUrl, user.account, watchHistoryInputs),
220
225
);
···
296
301
}, [
297
302
replaceBookmarks,
298
303
replaceProgress,
304
304
+
replaceWatchHistory,
299
305
uploadedData,
300
306
user.account,
301
307
handleBackendImport,
···
494
500
uploadedData,
495
501
replaceBookmarks,
496
502
replaceProgress,
503
503
+
replaceWatchHistory,
497
504
setGroupOrder,
498
505
preferencesStore,
499
506
subtitleStore,
···
639
646
640
647
<div className="p-4 bg-background rounded-lg">
641
648
<div className="flex items-center gap-2">
642
642
-
<Icon icon={Icons.HISTORY} className="text-xl" />
649
649
+
<Icon icon={Icons.CLOCK} className="text-xl" />
643
650
<span className="font-medium">
644
651
{t("migration.preview.items.watchHistory")}
645
652
</span>
+6
-2
src/stores/progress/index.ts
···
142
142
watched: 0,
143
143
};
144
144
145
145
-
const wasCompleted = item.progress.duration > 0 && item.progress.watched / item.progress.duration > 0.9;
145
145
+
const wasCompleted =
146
146
+
item.progress.duration > 0 &&
147
147
+
item.progress.watched / item.progress.duration > 0.9;
146
148
item.progress = { ...progress };
147
149
148
150
// Update watch history only if becoming completed
···
178
180
};
179
181
180
182
const episodeItem = item.episodes[meta.episode.tmdbId];
181
181
-
const wasCompleted = episodeItem.progress.duration > 0 && episodeItem.progress.watched / episodeItem.progress.duration > 0.9;
183
183
+
const wasCompleted =
184
184
+
episodeItem.progress.duration > 0 &&
185
185
+
episodeItem.progress.watched / episodeItem.progress.duration > 0.9;
182
186
episodeItem.progress = { ...progress };
183
187
184
188
// Update watch history only if becoming completed
+5
-2
src/stores/watchHistory/index.ts
···
76
76
77
77
// Only add/update if this is a completion or if the item doesn't exist yet
78
78
const existingItem = s.items[key];
79
79
-
const shouldUpdate = !existingItem || (completed && !existingItem.completed);
79
79
+
const shouldUpdate =
80
80
+
!existingItem || (completed && !existingItem.completed);
80
81
81
82
if (!shouldUpdate) return;
82
83
···
128
129
// add to updateQueue
129
130
updateId += 1;
130
131
s.updateQueue.push({
131
131
-
tmdbId: existingItem.episodeId ? existingItem.seasonId || id.split("-")[0] : id,
132
132
+
tmdbId: existingItem.episodeId
133
133
+
? existingItem.seasonId || id.split("-")[0]
134
134
+
: id,
132
135
title: existingItem.title,
133
136
year: existingItem.year,
134
137
poster: existingItem.poster,