Skip to content
This repository was archived by the owner on Aug 30, 2025. It is now read-only.

Commit ed52271

Browse files
committed
chore: mettre à jour la version de l'application à 7.12.3 et corriger la gestion des couleurs dans les sujets
1 parent 1373c38 commit ed52271

File tree

6 files changed

+59
-48
lines changed

6 files changed

+59
-48
lines changed

.github/ISSUE_TEMPLATE/bug.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ body:
6161
attributes:
6262
label: Version utilisée
6363
description: Paramètres (de Papillon) -> Version affichée en bas de la page
64-
placeholder: "7.12.2"
64+
placeholder: "7.12.3"
6565
validations:
6666
required: true
6767

android/app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ android {
8989
minSdkVersion rootProject.ext.minSdkVersion
9090
targetSdkVersion rootProject.ext.targetSdkVersion
9191
versionCode 71220
92-
versionName "7.12.2"
92+
versionName "7.12.3"
9393
}
9494
signingConfigs {
9595
debug {

ios/Papillon/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<key>CFBundlePackageType</key>
2020
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
2121
<key>CFBundleShortVersionString</key>
22-
<string>7.12.2</string>
22+
<string>7.12.3</string>
2323
<key>CFBundleSignature</key>
2424
<string>????</string>
2525
<key>CFBundleURLTypes</key>

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "papillonvex",
3-
"version": "7.12.2",
3+
"version": "7.12.3",
44
"main": "node_modules/expo/AppEntry.js",
55
"scripts": {
66
"start": "expo start",

src/services/shared/Subject.ts

Lines changed: 53 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,14 @@ export const COLORS_LIST = [
2727
];
2828

2929
// @ts-expect-error
30-
export const getRandColor = (usedColors) => {
30+
export const getRandColor = (usedColors?) => {
3131
const availableColors = COLORS_LIST.filter(
32-
(color) => !usedColors.includes(color)
32+
(color) => {
33+
if(usedColors.length > 0) {
34+
return !usedColors.includes(color);
35+
}
36+
return true;
37+
}
3338
);
3439
return (
3540
availableColors[Math.floor(Math.random() * availableColors.length)] ||
@@ -105,46 +110,52 @@ const getClosestGradeEmoji = (subjectName) => {
105110

106111
// @ts-expect-error
107112
export const getSubjectData = (entry) => {
108-
const state = useCurrentAccount.getState();
109-
const { account, mutateProperty } = state;
110-
const subject = entry
111-
.trim()
112-
.toLowerCase()
113-
.normalize("NFD")
114-
.replace(/[\u0300-\u036f]/g, "");
115-
116-
if (!subject) {
117-
return { color: "#888888", pretty: "Matière inconnue", emoji: "❓" };
118-
}
119-
120-
const allSubjects = account?.personalization?.subjects || {};
121-
122-
// Check if the subject already exists
123-
const existingSubject = allSubjects[subject];
124-
if (existingSubject) {
125-
return existingSubject;
113+
try {
114+
const state = useCurrentAccount.getState();
115+
const { account, mutateProperty } = state;
116+
const subject = entry
117+
.trim()
118+
.toLowerCase()
119+
.normalize("NFD")
120+
.replace(/[\u0300-\u036f]/g, "");
121+
122+
if (!subject) {
123+
return { color: "#888888", pretty: "Matière inconnue", emoji: "❓" };
124+
}
125+
126+
const allSubjects = account?.personalization?.subjects || {};
127+
128+
// Check if the subject already exists
129+
const existingSubject = allSubjects[subject];
130+
if (existingSubject) {
131+
return existingSubject;
132+
}
133+
134+
const formattedCoursName = findObjectByPronoteString(subject);
135+
const usedColors = new Set(
136+
Object.values(allSubjects).map((subj) => subj.color)
137+
);
138+
const color = getRandColor(Array.from(usedColors));
139+
const emoji = getClosestGradeEmoji(subject);
140+
141+
const newSubject = { color, pretty: formattedCoursName.pretty, emoji };
142+
143+
// Check for existing subject with the same pretty name
144+
const existing = Object.values(allSubjects).find(
145+
(subj) => subj.pretty === formattedCoursName.pretty
146+
);
147+
if (existing) {
148+
return existing;
149+
}
150+
151+
mutateProperty("personalization", {
152+
subjects: { ...allSubjects, [subject]: newSubject },
153+
});
154+
155+
return newSubject;
126156
}
127-
128-
const formattedCoursName = findObjectByPronoteString(subject);
129-
const usedColors = new Set(
130-
Object.values(allSubjects).map((subj) => subj.color)
131-
);
132-
const color = getRandColor(Array.from(usedColors));
133-
const emoji = getClosestGradeEmoji(subject);
134-
135-
const newSubject = { color, pretty: formattedCoursName.pretty, emoji };
136-
137-
// Check for existing subject with the same pretty name
138-
const existing = Object.values(allSubjects).find(
139-
(subj) => subj.pretty === formattedCoursName.pretty
140-
);
141-
if (existing) {
142-
return existing;
157+
catch (error) {
158+
console.error("Error in getSubjectData:", error);
159+
return { color: getRandColor(), pretty: entry.toString(), emoji: getClosestGradeEmoji(entry) };
143160
}
144-
145-
mutateProperty("personalization", {
146-
subjects: { ...allSubjects, [subject]: newSubject },
147-
});
148-
149-
return newSubject;
150161
};

0 commit comments

Comments
 (0)