feat: maidata hash lookup#13
Open
HakureiYoru wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds a “maidata hash status” check on the frontend so the uploader can query the API before uploading, preventing duplicate chart uploads and informing users about score inheritance.
Changes:
- Added a new
maichart.hashStatus(hash)endpoint builder for the API-side hash-status route. - Extended
ChartUploaderto compute multiple MD5 hash candidates formaidata.txt, query hash status, and block uploads when a chart already exists. - Added new i18n strings (zh/ko/ja/en) for hash-checking status, errors, and a “View” action.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
src/config/api.ts |
Adds a hashStatus endpoint builder for querying chart existence by maidata hash. |
src/components/user/ChartUploader.tsx |
Implements client-side hash candidate generation + API lookup, UI status display, and upload blocking on duplicates. |
public/i18n/zh.json |
Adds localized strings for hash lookup status/messages. |
public/i18n/ko.json |
Adds localized strings for hash lookup status/messages. |
public/i18n/ja.json |
Adds localized strings for hash lookup status/messages. |
public/i18n/en.json |
Adds localized strings for hash lookup status/messages. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+1
to
3
| import { useRef, useState } from 'react'; | ||
| import { toast } from 'react-toastify'; | ||
| import axios, { AxiosError } from 'axios'; |
Comment on lines
+93
to
+95
| const [hashLookup, setHashLookup] = useState<HashLookupState>({ status: 'idle' }); | ||
| const hashLookupSeq = useRef(0); | ||
| const hashLookupAbort = useRef<AbortController | null>(null); |
Comment on lines
+224
to
+227
| if (hashLookup.status === 'exists') { | ||
| toast.error(loc('MaidataAlreadyExists', 'This chart already exists on the site'), { autoClose: false }); | ||
| return; | ||
| } |
Comment on lines
+335
to
+341
| <a | ||
| className="text-blue-300 hover:text-blue-200 underline" | ||
| href={`/song?id=${encodeURIComponent(hashLookup.chart.id)}`} | ||
| > | ||
| {loc('View', 'View')} | ||
| </a> | ||
| )} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
需要在api侧开新的hash status