chuni: Changes to make compatible with old CHUNITHM

This commit is contained in:
cd6c1fd2d946dff292b101ca3305fc7f31d2dce5 2020-04-17 17:12:11 +08:00 committed by Tau
parent 94ed27503a
commit e61b103221
2 changed files with 45 additions and 2 deletions

View File

@ -37,7 +37,10 @@ export class SqlUserCourseRepository implements UserCourseRepository {
.from("cm_user_course")
.where("profile_id", profileId);
if (page) {
/**
* UserCourse has no paging before CHUNITHM Amazon
*/
if (page && !isNaN(page.limit)) {
stmt.limit(page.limit).offset(page.offset);
}

View File

@ -56,7 +56,47 @@ export class SqlUserDataExRepository implements UserDataExRepository {
const row = await this._txn.fetchRow(stmt);
if (row === undefined) {
throw new Error("UserDataEx record not found");
/**
* When upgrading from CHUNITHM Star Plus & earlier
* to Amazon, there is no UserDataEx, so we return
* a "default" row.
*/
return {
compatibleCmVersion: "",
medal: 0,
mapIconId: 0,
voiceId: 0,
ext1: 0,
ext2: 0,
ext3: 0,
ext4: 0,
ext5: 0,
ext6: 0,
ext7: 0,
ext8: 0,
ext9: 0,
ext10: 0,
ext11: 0,
ext12: 0,
ext13: 0,
ext14: 0,
ext15: 0,
ext16: 0,
ext17: 0,
ext18: 0,
ext19: 0,
ext20: 0,
extStr1: "",
extStr2: "",
extStr3: "",
extStr4: "",
extStr5: "",
extLong1: 0n,
extLong2: 0n,
extLong3: 0n,
extLong4: 0n,
extLong5: 0n,
};
}
return readRow(row);