Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow original songs to be derived from another song #1587

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion VocaDbModel/Domain/Songs/Song.cs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ public virtual DateTime? FirstAlbumDate
/// This method also tests that the song type isn't "Original", because original songs aren't supposed to have parent songs.
/// </summary>
[MemberNotNullWhen(true, nameof(OriginalVersion))]
public virtual bool HasOriginalVersion => SongType != SongType.Original && OriginalVersion != null;
public virtual bool HasOriginalVersion => OriginalVersion != null;

public virtual IList<SongHit> Hits
{
Expand Down
4 changes: 2 additions & 2 deletions VocaDbWeb/Models/SongModels.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public SongDetails(SongDetailsContract contract, IUserPermissionContext userCont
Contract = contract;
AdditionalNames = contract.AdditionalNames;
Albums = contract.Albums;
AlternateVersions = contract.AlternateVersions.Where(a => a.SongType != SongType.Original).ToArray();
AlternateVersions = contract.AlternateVersions;
ArtistString = contract.ArtistString;
BrowsedAlbumId = contract.Album?.Id;
CanEdit = EntryPermissionManager.CanEdit(userContext, contract.Song);
Expand All @@ -58,7 +58,7 @@ public SongDetails(SongDetailsContract contract, IUserPermissionContext userCont
Name = contract.Song.Name;
NicoId = contract.Song.NicoId;
Notes = contract.Notes;
OriginalVersion = (contract.Song.SongType != SongType.Original ? contract.OriginalVersion : null);
OriginalVersion = contract.OriginalVersion;
Pools = contract.Pools;
PublishDate = contract.Song.PublishDate;
RatingScore = contract.Song.RatingScore;
Expand Down
9 changes: 2 additions & 7 deletions VocaDbWeb/New/types/DataContracts/Song/SongDetailsForApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,7 @@ export class SongDetailsForApi {
constructor(readonly contract: SongDetailsContract, primaryPV: PVContract | undefined) {
this.additionalNames = contract.additionalNames;
this.albums = contract.albums;
this.alternateVersions = contract.alternateVersions.filter(
(a) => a.songType !== SongType.Original
);
this.alternateVersions = contract.alternateVersions;
this.artistString = contract.artistString;
this.browsedAlbumId = contract.album?.id;
this.canEditPersonalDescription = contract.canEditPersonalDescription;
Expand All @@ -101,10 +99,7 @@ export class SongDetailsForApi {
this.minMilliBpm = contract.minMilliBpm;
this.name = contract.song.name;
this.notes = contract.notes;

this.originalVersion =
contract.song.songType !== SongType.Original ? contract.originalVersion : undefined;

this.originalVersion = contract.originalVersion;
this.personalDescriptionAuthor = contract.personalDescriptionAuthor;
this.personalDescriptionText = contract.personalDescriptionText;
this.pools = contract.pools;
Expand Down
11 changes: 2 additions & 9 deletions VocaDbWeb/Scripts/DataContracts/Song/SongDetailsForApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,7 @@ export class SongDetailsForApi {
) {
this.additionalNames = contract.additionalNames;
this.albums = contract.albums;
this.alternateVersions = contract.alternateVersions.filter(
(a) => a.songType !== SongType.Original,
);
this.alternateVersions = contract.alternateVersions;
this.artistString = contract.artistString;
this.browsedAlbumId = contract.album?.id;
this.canEditPersonalDescription = contract.canEditPersonalDescription;
Expand All @@ -105,12 +103,7 @@ export class SongDetailsForApi {
this.minMilliBpm = contract.minMilliBpm;
this.name = contract.song.name;
this.notes = contract.notes;

this.originalVersion =
contract.song.songType !== SongType.Original
? contract.originalVersion
: undefined;

this.originalVersion = contract.originalVersion;
this.personalDescriptionAuthor = contract.personalDescriptionAuthor;
this.personalDescriptionText = contract.personalDescriptionText;
this.pools = contract.pools;
Expand Down
2 changes: 2 additions & 0 deletions VocaDbWeb/Scripts/Stores/Song/SongCreateStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ export class SongCreateStore {
}

@computed get canHaveOriginalVersion(): boolean {
// Having a original/base version for an original song is uncommon.
// Hide the base version selector as that's more suited for this simplified interface.
return this.songType !== SongType.Original;
}

Expand Down
2 changes: 1 addition & 1 deletion VocaDbWeb/Scripts/Stores/Song/SongDetailsStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ export class SongDetailsStore {

this.tagUsages = new TagListStore(data.tagUsages);

if (data.songType !== SongType.Original && !this.originalVersion.entry) {
if (!this.originalVersion.entry) {
this.getOriginal(data.linkedPages);
}
Comment on lines -311 to 313
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This will cause original songs that have unofficial links to another original song on VocaDB (or UtaiteDB/TouhouDB) to have the latter song considered the original version (this would only be shown in the UI and wouldn't be reflected in the database).

Example: https://vocadb.net/S/201986 (this one actually doesn't matter in the end as the song will have a properly defined demo version).

Could also be checked with an SQL query to the database.

}
Expand Down
2 changes: 1 addition & 1 deletion VocaDbWeb/Scripts/Stores/Song/SongEditStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ export class SongEditStore {
}

@computed get canHaveOriginalVersion(): boolean {
return this.songType !== SongType.Original;
return true;
}

@computed get showInstrumentalNote(): boolean {
Expand Down