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

Commit 3db731e

Browse files
committed
2 parents 0b39df0 + 6ffee95 commit 3db731e

File tree

14 files changed

+232
-218
lines changed

14 files changed

+232
-218
lines changed

App.tsx

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import { isExpoGo } from "@/utils/native/expoGoAlert";
1212
import { atobPolyfill, btoaPolyfill } from "js-base64";
1313
import { registerBackgroundTasks } from "@/background/BackgroundTasks";
1414
import { SoundHapticsProvider } from "@/hooks/Theme_Sound_Haptics";
15-
import { PapillonNavigation } from "@/router/refs";
1615
import * as Device from "expo-device";
1716
import * as ScreenOrientation from "expo-screen-orientation";
1817
import {getToLoadFonts} from "@/consts/Fonts";
@@ -55,30 +54,6 @@ export default function App () {
5554
configureOrientation();
5655
}, []);
5756

58-
const handleNotificationPress = async (notification: any) => {
59-
if (notification?.data) {
60-
const accountID = notification.data.accountID;
61-
if (accountID) {
62-
useAccounts.getState().setLastOpenedAccountID(accountID);
63-
64-
setTimeout(() => {
65-
PapillonNavigation.current?.navigate(
66-
notification.data.page,
67-
notification.data.parameters,
68-
);
69-
}, 1000);
70-
}
71-
}
72-
};
73-
74-
const checkInitialNotification = async () => {
75-
const notifee = (await import("@notifee/react-native")).default;
76-
const initialNotification = await notifee.getInitialNotification();
77-
if (initialNotification) {
78-
await handleNotificationPress(initialNotification.notification);
79-
}
80-
};
81-
8257
const getBackgroundTimeLimit = useCallback((service: keyof typeof BACKGROUND_LIMITS) => {
8358
return BACKGROUND_LIMITS[service] ?? DEFAULT_BACKGROUND_TIME;
8459
}, []);
@@ -112,11 +87,6 @@ export default function App () {
11287
await AsyncStorage.removeItem("@background_timestamp");
11388
}, [currentAccount, switchTo, getBackgroundTimeLimit]);
11489

115-
116-
useEffect(() => {
117-
if (!isExpoGo()) checkInitialNotification();
118-
}, []);
119-
12090
useEffect(() => {
12191
const subscription = AppState.addEventListener("change", async (nextAppState) => {
12292
if (appState === nextAppState) return;

package-lock.json

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

src/background/BackgroundTasks.ts

Lines changed: 21 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -12,50 +12,20 @@ import { fetchLessons } from "./data/Lessons";
1212
import { fetchAttendance } from "./data/Attendance";
1313
import { fetchEvaluation } from "./data/Evaluation";
1414
import { papillonNotify } from "./Notifications";
15-
1615
import { useFlagsStore } from "@/stores/flags";
1716

18-
const notifeeEvent = async () => {
19-
const notifee = (await import("@notifee/react-native")).default;
20-
const EventType = (await import("@notifee/react-native")).EventType;
21-
22-
// Gestion des badges quand app en arrière-plan
23-
notifee.onBackgroundEvent(async ({ type, detail }) => {
24-
const { notification, pressAction } = detail;
25-
26-
switch (type) {
27-
case EventType.ACTION_PRESS:
28-
console.log(`[Notifee] Action press: ${pressAction?.id}`);
29-
break;
30-
case EventType.DISMISSED:
31-
let badgeCount = await notifee.getBadgeCount();
32-
badgeCount = Math.max(badgeCount - 1, 0);
33-
await notifee.setBadgeCount(badgeCount);
34-
break;
35-
}
36-
});
17+
let isBackgroundFetchRunning = false;
18+
const BACKGROUND_TASK_NAME = "background-fetch";
3719

38-
// Gestion des badges quand app en premier plan
39-
notifee.onForegroundEvent(async ({ type, detail }) => {
40-
const { notification, pressAction } = detail;
41-
42-
switch (type) {
43-
case EventType.ACTION_PRESS:
44-
console.log(`[Notifee] Action press: ${pressAction?.id}`);
45-
break;
46-
case EventType.DISMISSED:
47-
let badgeCount = await notifee.getBadgeCount();
48-
badgeCount = Math.max(badgeCount - 1, 0);
49-
await notifee.setBadgeCount(badgeCount);
50-
break;
51-
}
52-
});
20+
const fetch = async (label: string, fn: () => Promise<any>) => {
21+
try {
22+
info(`▶️ Running background ${label}`, "BACKGROUND");
23+
await fn();
24+
} catch (e) {
25+
error(`❌ ${label} fetch failed: ${e}`, "BACKGROUND");
26+
}
5327
};
5428

55-
if (!isExpoGo()) notifeeEvent();
56-
57-
let isBackgroundFetchRunning = false;
58-
5929
const backgroundFetch = async () => {
6030
const disableBackgroundTasks = useFlagsStore.getState().defined("disablebackgroundtasks");
6131
if (disableBackgroundTasks) {
@@ -99,18 +69,12 @@ const backgroundFetch = async () => {
9969
account.personalization.notifications;
10070

10171
if (notificationsTypesPermissions?.enabled) {
102-
info("▶️ Running background News", "BACKGROUND");
103-
await fetchNews();
104-
info("▶️ Running background Homeworks", "BACKGROUND");
105-
await fetchHomeworks();
106-
info("▶️ Running background Grades", "BACKGROUND");
107-
await fetchGrade();
108-
info("▶️ Running background Lessons", "BACKGROUND");
109-
await fetchLessons();
110-
info("▶️ Running background Attendance", "BACKGROUND");
111-
await fetchAttendance();
112-
info("▶️ Running background Evaluation", "BACKGROUND");
113-
await fetchEvaluation();
72+
await fetch("News", fetchNews);
73+
await fetch("Homeworks", fetchHomeworks);
74+
await fetch("Grades", fetchGrade);
75+
await fetch("Lessons", fetchLessons);
76+
await fetch("Attendance", fetchAttendance);
77+
await fetch("Evaluation", fetchEvaluation);
11478
}
11579
}
11680

@@ -127,14 +91,14 @@ const backgroundFetch = async () => {
12791
}
12892
};
12993

130-
if (!isExpoGo()) TaskManager.defineTask("background-fetch", backgroundFetch);
94+
if (!isExpoGo()) TaskManager.defineTask(BACKGROUND_TASK_NAME, backgroundFetch);
13195

13296
const unsetBackgroundFetch = async () =>
133-
await BackgroundFetch.unregisterTaskAsync("background-fetch");
97+
await BackgroundFetch.unregisterTaskAsync(BACKGROUND_TASK_NAME);
13498

13599
const setBackgroundFetch = async () =>
136-
await BackgroundFetch.registerTaskAsync("background-fetch", {
137-
minimumInterval: 60 * 15,
100+
await BackgroundFetch.registerTaskAsync(BACKGROUND_TASK_NAME, {
101+
minimumInterval: 60 * (__DEV__ ? 1 : 15),
138102
stopOnTerminate: false,
139103
startOnBoot: true,
140104
});
@@ -152,11 +116,11 @@ const registerBackgroundTasks = async () => {
152116
}
153117

154118
const isRegistered = await TaskManager.isTaskRegisteredAsync(
155-
"background-fetch"
119+
BACKGROUND_TASK_NAME
156120
);
157121

158122
if (isRegistered) {
159-
warn(
123+
info(
160124
"⚠️ Background task already registered. Unregister background task...",
161125
"BACKGROUND"
162126
);

src/background/Notifications.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -124,19 +124,12 @@ const papillonNotify = async (
124124
// Add timestamp for Android
125125
const timestamp = new Date().getTime();
126126

127-
// Get badge count
128-
let badgeCount = await notifee.getBadgeCount();
129-
if (channelId !== "Status") {
130-
badgeCount++;
131-
}
132-
133127
// Display a notification
134128
await notifee.displayNotification({
135129
...props,
136130
android: {
137131
channelId,
138132
timestamp,
139-
badgeCount,
140133
showTimestamp: channelId !== "Status" ? true : false,
141134
showChronometer: channelId === "Status" ? true : false,
142135
smallIcon: "@mipmap/ic_launcher_foreground",
@@ -148,7 +141,6 @@ const papillonNotify = async (
148141
},
149142
ios: {
150143
threadId: channelId,
151-
badgeCount,
152144
sound: channelId !== "Status" ? "default" : "",
153145
}
154146
});

src/consts/LatexVocabulary.ts

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,50 @@
11
export const latexVocabulary: Record<string, string> = {
2-
"": "\\in",
3-
"": "\\notin",
4-
"": "\\forall",
5-
"": "\\exists",
6-
"": "\\emptyset",
7-
"": "\\cup",
8-
"": "\\cap",
9-
"": "\\subset",
10-
"": "\\subseteq",
11-
"": "\\supset",
12-
"": "\\supseteq",
13-
"π": "\\pi",
14-
"": "\\sum",
15-
"√": "\\sqrt{}",
16-
"": "\\infty",
17-
"": "\\to",
18-
"": "\\Rightarrow",
19-
"": "\\leftrightarrow",
20-
"±": "\\pm",
21-
"": "\\leq",
22-
"": "\\geq",
23-
"": "\\neq",
24-
"×": "\\times",
25-
"÷": "\\div",
26-
"α": "\\alpha",
27-
"β": "\\beta",
28-
"γ": "\\gamma",
29-
"θ": "\\theta",
30-
"λ": "\\lambda",
31-
"μ": "\\mu",
32-
"σ": "\\sigma",
33-
"φ": "\\phi",
34-
"ω": "\\omega",
35-
"": "\\approx",
36-
"": "\\equiv",
37-
"": "\\triangleq",
38-
"": "\\perp",
39-
"": "\\angle",
40-
"": "\\parallel",
41-
"": "\\partial",
42-
"": "\\nabla",
43-
"": "\\land",
44-
"": "\\lor",
45-
"¬": "\\neg",
46-
"": "\\vdash",
47-
"": "\\models",
48-
"": "\\top",
49-
"": "\\veebar"
50-
} as const;
2+
"\\in": "",
3+
"\\notin": "",
4+
"\\forall": "",
5+
"\\exists": "",
6+
"\\emptyset": "",
7+
"\\cup": "",
8+
"\\cap": "",
9+
"\\subset": "",
10+
"\\subseteq": "",
11+
"\\supset": "",
12+
"\\supseteq": "",
13+
"\\pi": "π",
14+
"\\sum": "",
15+
"\\sqrt{}": "√",
16+
"\\infty": "",
17+
"\\to": "",
18+
"\\Rightarrow": "",
19+
"\\leftrightarrow": "",
20+
"\\pm": "±",
21+
"\\leq": "",
22+
"\\geq": "",
23+
"\\neq": "",
24+
"\\times": "×",
25+
"\\div": "÷",
26+
"\\alpha": "α",
27+
"\\beta": "β",
28+
"\\gamma": "γ",
29+
"\\theta": "θ",
30+
"\\lambda": "λ",
31+
"\\mu": "μ",
32+
"\\sigma": "σ",
33+
"\\phi": "φ",
34+
"\\omega": "ω",
35+
"\\approx": "",
36+
"\\equiv": "",
37+
"\\triangleq": "",
38+
"\\perp": "",
39+
"\\angle": "",
40+
"\\parallel": "",
41+
"\\partial": "",
42+
"\\nabla": "",
43+
"\\land": "",
44+
"\\lor": "",
45+
"\\neg": "¬",
46+
"\\vdash": "",
47+
"\\models": "",
48+
"\\top": "",
49+
"\\veebar": ""
50+
} as const;

src/utils/format/format_pronote_homeworks.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,13 @@ const IGNORED_TAGS = new Set([
2323
const TAG_REGEX = /<\/?([a-zA-Z]+)(?:\s[^>]*)?>|([^<]+)/g;
2424
const NUMERIC_ENTITY_REGEX = /&#(\d+);/g;
2525
const NAMED_ENTITY_REGEX = /&([a-zA-Z]+);/g;
26-
const UNICODE_SYMBOLS_REGEX = /[\u2200-\u22FF\u03B1-\u03C9]/g;
26+
const LATEX_REGEX = /\\[a-zA-Z]+(?:\{\})?/g;
2727
const MULTI_NEWLINE_REGEX = /\n{2,}/g;
2828

2929
const HTML_ENTITIES: Record<string, string> = {
3030
"&nbsp;": " ",
3131
"&quot;": "\"",
32-
"&#039;": "'",
33-
...latexVocabulary,
32+
"&#039;": "'"
3433
};
3534

3635
const DECODE_CACHE = new Map<string, string>();
@@ -126,7 +125,10 @@ function decodeHtmlEntities (text: string): string {
126125
NAMED_ENTITY_REGEX,
127126
(_, entity) => HTML_ENTITIES[`&${entity};`] || `&${entity};`
128127
)
129-
.replace(UNICODE_SYMBOLS_REGEX, (match) => HTML_ENTITIES[match] || match);
128+
.replace(LATEX_REGEX, (match) => {
129+
match = match.replace("{}", "");
130+
return latexVocabulary[match] || match;
131+
});
130132
}
131133

132134
export default parse_homeworks;

src/utils/logger/logger.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ export interface Log {
125125
date: string;
126126
from?: string;
127127
message: string;
128+
formattedDate?: string;
128129
}
129130

130131
async function get_logs (): Promise<Log[]> {

src/views/account/Grades/Modals/GradeReaction.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ const GradeReaction: Screen<"GradeReaction"> = ({ navigation, route }) => {
206206
<View ref={composerRef} style={[
207207
styles.cameraContainer,
208208
{
209-
marginTop: inset.top + 75,
209+
marginTop: inset.top,
210210
maxHeight: isTablet ? "65%" : "75%",
211211
}
212212
]}

src/views/account/Grades/Subject/Subject.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,9 @@ const Subject: React.FC<SubjectProps> = ({
112112
textTransform: "uppercase",
113113
}}
114114
>
115-
{sortings[sorting]?.label}
115+
{typeof sortings[sorting] === "string"
116+
? sortings[sorting]
117+
: sortings[sorting]?.label}
116118
</NativeText>
117119
{isLoading && (
118120
<PapillonSpinner

src/views/account/Grades/Subject/SubjectList.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ interface SubjectItemProps {
2020
index?: number;
2121
}
2222

23+
interface renderGradeItemProps {
24+
item: Grade;
25+
index: number;
26+
}
27+
2328
const SubjectItem: React.FC<SubjectItemProps> = ({
2429
subject,
2530
allGrades,
@@ -41,7 +46,7 @@ const SubjectItem: React.FC<SubjectItemProps> = ({
4146
return null;
4247
}
4348

44-
const renderGradeItem = useCallback(({ item, index }) => (
49+
const renderGradeItem = useCallback(({ item, index }: renderGradeItemProps) => (
4550
<SubjectGradeItem
4651
subject={subject}
4752
grade={item}
@@ -50,7 +55,7 @@ const SubjectItem: React.FC<SubjectItemProps> = ({
5055
/>
5156
), [subject, allGrades, navigation]);
5257

53-
const keyExtractor = useCallback((item) => item.id, []);
58+
const keyExtractor = useCallback((item: Grade) => item.id, []);
5459

5560
return (
5661
<NativeList

0 commit comments

Comments
 (0)