forked from firka/student-legacy
added handling for 404 grade colors
This commit is contained in:
parent
30f24d5d33
commit
84537fdcef
@ -336,6 +336,8 @@ class FilcAPI {
|
|||||||
|
|
||||||
if (res.statusCode == 200) {
|
if (res.statusCode == 200) {
|
||||||
return (jsonDecode(res.body) as Map);
|
return (jsonDecode(res.body) as Map);
|
||||||
|
} else if (res.statusCode == 404) {
|
||||||
|
return {"public_id": ""};
|
||||||
} else {
|
} else {
|
||||||
throw "HTTP ${res.statusCode}: ${res.body}";
|
throw "HTTP ${res.statusCode}: ${res.body}";
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,25 @@ class ShareProvider extends ChangeNotifier {
|
|||||||
|
|
||||||
if (gradeColorsJson != null) {
|
if (gradeColorsJson != null) {
|
||||||
SharedTheme theme = SharedTheme.fromJson(
|
SharedTheme theme = SharedTheme.fromJson(
|
||||||
themeJson, SharedGradeColors.fromJson(gradeColorsJson));
|
themeJson,
|
||||||
|
SharedGradeColors.fromJson(gradeColorsJson["public_id"] != ''
|
||||||
|
? gradeColorsJson
|
||||||
|
: {
|
||||||
|
"public_id": "0",
|
||||||
|
"is_public": false,
|
||||||
|
"nickname": "Anonymous",
|
||||||
|
"five_color":
|
||||||
|
SettingsProvider.defaultSettings().gradeColors[4].value,
|
||||||
|
"four_color":
|
||||||
|
SettingsProvider.defaultSettings().gradeColors[3].value,
|
||||||
|
"three_color":
|
||||||
|
SettingsProvider.defaultSettings().gradeColors[2].value,
|
||||||
|
"two_color":
|
||||||
|
SettingsProvider.defaultSettings().gradeColors[1].value,
|
||||||
|
"one_color":
|
||||||
|
SettingsProvider.defaultSettings().gradeColors[0].value,
|
||||||
|
}),
|
||||||
|
);
|
||||||
return theme;
|
return theme;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -93,7 +111,25 @@ class ShareProvider extends ChangeNotifier {
|
|||||||
|
|
||||||
if (gradeColorsJson != null) {
|
if (gradeColorsJson != null) {
|
||||||
SharedTheme theme = SharedTheme.fromJson(
|
SharedTheme theme = SharedTheme.fromJson(
|
||||||
t, SharedGradeColors.fromJson(gradeColorsJson));
|
t,
|
||||||
|
SharedGradeColors.fromJson(gradeColorsJson["public_id"] != ''
|
||||||
|
? gradeColorsJson
|
||||||
|
: {
|
||||||
|
"public_id": "0",
|
||||||
|
"is_public": false,
|
||||||
|
"nickname": "Anonymous",
|
||||||
|
"five_color":
|
||||||
|
SettingsProvider.defaultSettings().gradeColors[4].value,
|
||||||
|
"four_color":
|
||||||
|
SettingsProvider.defaultSettings().gradeColors[3].value,
|
||||||
|
"three_color":
|
||||||
|
SettingsProvider.defaultSettings().gradeColors[2].value,
|
||||||
|
"two_color":
|
||||||
|
SettingsProvider.defaultSettings().gradeColors[1].value,
|
||||||
|
"one_color":
|
||||||
|
SettingsProvider.defaultSettings().gradeColors[0].value,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
themes.add(theme);
|
themes.add(theme);
|
||||||
}
|
}
|
||||||
@ -134,8 +170,25 @@ class ShareProvider extends ChangeNotifier {
|
|||||||
Map? gradeColorsJson = await FilcAPI.getSharedGradeColors(id);
|
Map? gradeColorsJson = await FilcAPI.getSharedGradeColors(id);
|
||||||
|
|
||||||
if (gradeColorsJson != null) {
|
if (gradeColorsJson != null) {
|
||||||
SharedGradeColors gradeColors =
|
SharedGradeColors gradeColors = SharedGradeColors.fromJson(
|
||||||
SharedGradeColors.fromJson(gradeColorsJson);
|
gradeColorsJson["public_id"] != ''
|
||||||
|
? gradeColorsJson
|
||||||
|
: {
|
||||||
|
"public_id": "0",
|
||||||
|
"is_public": false,
|
||||||
|
"nickname": "Anonymous",
|
||||||
|
"five_color":
|
||||||
|
SettingsProvider.defaultSettings().gradeColors[4].value,
|
||||||
|
"four_color":
|
||||||
|
SettingsProvider.defaultSettings().gradeColors[3].value,
|
||||||
|
"three_color":
|
||||||
|
SettingsProvider.defaultSettings().gradeColors[2].value,
|
||||||
|
"two_color":
|
||||||
|
SettingsProvider.defaultSettings().gradeColors[1].value,
|
||||||
|
"one_color":
|
||||||
|
SettingsProvider.defaultSettings().gradeColors[0].value,
|
||||||
|
},
|
||||||
|
);
|
||||||
return gradeColors;
|
return gradeColors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user