Skip to content

feat: maidata hash lookup#13

Open
HakureiYoru wants to merge 1 commit into
mainfrom
maidata-hash-status
Open

feat: maidata hash lookup#13
HakureiYoru wants to merge 1 commit into
mainfrom
maidata-hash-status

Conversation

@HakureiYoru

Copy link
Copy Markdown
Collaborator

需要在api侧开新的hash status

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ChartUploader to compute multiple MD5 hash candidates for maidata.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>
)}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants