Skip to content

Commit

Permalink
merge: v1.1.1 (#88)
Browse files Browse the repository at this point in the history
  • Loading branch information
Damego authored Sep 2, 2023
2 parents 5e53da7 + f538a79 commit 6a9a6b2
Showing 13 changed files with 192 additions and 23 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -110,4 +110,5 @@ dist
test.js
test.ts
test.jsx
test.tsx
test.tsx
android/
15 changes: 13 additions & 2 deletions app.config.js
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ export default {
expo: {
name: 'ЕТИС мобайл' + (IS_DEV ? ' (DEV)' : ''),
slug: 'etis-mobile',
version: '1.1.0',
version: '1.1.1',
owner: 'damego',
orientation: 'portrait',
icon: './assets/icon.png',
@@ -23,7 +23,7 @@ export default {
supportsTablet: true,
},
android: {
versionCode: 10100007,
versionCode: 10101000,
adaptiveIcon: {
foregroundImage: './assets/adaptive-icon.png',
backgroundColor: '#FFFFFF',
@@ -41,6 +41,17 @@ export default {
projectId: 'a3b11e9a-6c2e-4082-81e8-58bc2324b582',
},
},
hooks: {
postPublish: [
{
file: "sentry-expo/upload-sourcemaps",
config: {
organization: "etismobile",
project: "etis-mobile"
}
}
]
},
plugins: [
['./src/plugins/copyDrawable.js', './assets/tab_icons'],
['./src/plugins/disabledForcedDarkModeAndroid.ts', {}],
11 changes: 11 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -2,5 +2,16 @@ module.exports = function (api) {
api.cache(true);
return {
presets: ['babel-preset-expo'],
plugins: [
[
require.resolve('babel-plugin-module-resolver'),
{
root: ['.'],
alias: {
'react-native-device-info': './src/plugins/react-native-device-info.js',
},
},
],
],
};
};
70 changes: 70 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -59,15 +59,16 @@
"react-native-pager-view": "6.2.0",
"react-native-popover-view": "^5.1.8",
"react-native-quick-actions": "^0.3.13",
"react-native-recaptcha-that-works": "github:Damego/react-native-recaptcha-that-works",
"react-native-radio-buttons-group": "^3.0.3",
"react-native-recaptcha-that-works": "github:Damego/react-native-recaptcha-that-works",
"react-native-safe-area-context": "4.6.3",
"react-native-screens": "~3.22.0",
"react-native-tab-view": "^3.5.2",
"react-native-web": "~0.19.6",
"react-native-webview": "13.2.2",
"react-redux": "^8.1.2",
"sentry-expo": "~7.0.1",
"sp-react-native-in-app-updates": "^1.3.1",
"uuid": "^9.0.0"
},
"devDependencies": {
2 changes: 2 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@ import StackNavigator from './navigation/StackNavigator';
import setupStore from './redux';
import { loadStorage } from './redux/storageLoader';
import { defineFetchTask } from './tasks/signs';
import { checkUpdate } from './utils/inappUpdate';
import { registerForPushNotificationsAsync, setNotificationHandler } from './utils/notifications';
import { addShortcuts } from './utils/shortcuts';

@@ -31,6 +32,7 @@ const App = () => {

useEffect(() => {
registerForPushNotificationsAsync();
checkUpdate();
}, []);

if (!fontsLoaded) {
19 changes: 10 additions & 9 deletions src/parser/certificate.ts
Original file line number Diff line number Diff line change
@@ -38,7 +38,7 @@ const parseAnnounceText = (item: cheerio.Cheerio) =>
item
.contents()
.map(function (index, element) {
if (element.name === 'br' && element.next.name === "br") return '\n';
if (element.name === 'br' && element.next.name === 'br') return '\n';
return item.find(element).text();
})
.toArray()
@@ -47,17 +47,18 @@ const parseAnnounceText = (item: cheerio.Cheerio) =>

function parseAnnounces(html: string): ICertificateAnnounce {
const $ = cheerio.load(html);
const selector = $('.span9 font');
const selector = $('.span9').children().filter('font');

const firstItem = selector.eq(0);
const lastItem = selector.eq(1);
if (!lastItem) {
return { footer: firstItem.html() };
} else {
return {
header: parseAnnounceText(firstItem),
footer: parseAnnounceText(lastItem),
};

if (selector.length === 1) {
return { footer: parseAnnounceText(firstItem) };
}
return {
header: parseAnnounceText(firstItem),
footer: parseAnnounceText(lastItem),
};
}

export function cutCertificateHTML(html: string): string {
5 changes: 3 additions & 2 deletions src/parser/teachers.ts
Original file line number Diff line number Diff line change
@@ -3,9 +3,10 @@ import { load } from 'cheerio';
import { ITeacher, TeacherType } from '../models/teachers';
import { getTextField } from './utils';

/* https://regex101.com/r/gvUVMt/3 */
/* https://regex101.com/r/gvUVMt/4 */
/* duplicated in sentry.ts */
const subjectRegex =
/([а-яА-Я\w\s":.,+-]+ (?:\([а-яА-Я\s]+\) )?(?:\[[а-яА-Я\s,]+] )?)\(([а-яА-Я\s,.]+)\)/s;
/([а-яА-Я\w\s":.,+#-]+ (?:\([а-яА-Я\w\s]+\) )?(?:\[[а-яА-Я\w\s,]+] )?)\(([а-яА-Я\s,.-]+)\)/s;
const groupTeachers = (data: ITeacher[]) => {
const dataGrouped = {};
data.forEach((val) => {
5 changes: 5 additions & 0 deletions src/plugins/react-native-device-info.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import Constants from 'expo-constants';

export const getVersion = () => {
return Constants.expoConfig?.version;
};
5 changes: 5 additions & 0 deletions src/screens/shortTeachPlan/ShortTeachPlan.tsx
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@ import { useAppDispatch, useAppSelector } from '../../hooks';
import { GetResultType, RequestType } from '../../models/results';
import { ISessionTeachPlan } from '../../models/teachPlan';
import { setAuthorizing } from '../../redux/reducers/authSlice';
import { checkSubjectNames } from '../../utils/sentry';
import CalendarSchedule from './CalendarSchedule';
import SessionCard from './SessionCard';

@@ -40,6 +41,10 @@ const ShortTeachPlan = () => {
setLoading(false);
};

useEffect(() => {
if (data) checkSubjectNames(data);
}, [data]);

useEffect(() => {
if (!isAuthorizing) loadData();
}, [isAuthorizing]);
10 changes: 4 additions & 6 deletions src/screens/timeTable/Pair.tsx
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@ export default function Pair({ pair }: { pair: IPair }) {
<Text style={globalStyles.textColor}>{pair.time}</Text>
</View>

<View style={{ flexDirection: 'column' }}>
<View style={{ flexDirection: 'column', flex: 1 }}>
{pair.lessons.map((lesson, ind) => (
<Lesson data={lesson} key={lesson.subject + ind} />
))}
@@ -45,13 +45,11 @@ const styles = StyleSheet.create({
marginBottom: '1%',
},
pairTimeContainer: {
paddingRight: '2%',
paddingVertical: 2,
marginVertical: 2,
marginRight: '2%',
alignItems: 'center',
},
lessonContainer: {
flex: 1,
},
lessonContainer: {},
lessonInfoText: {
fontWeight: '500',
},
37 changes: 37 additions & 0 deletions src/utils/inappUpdate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import Constants from 'expo-constants';
import { Platform } from 'react-native';
import SpInAppUpdates, {
AndroidInAppUpdateExtras,
AndroidInstallStatus,
IAUUpdateKind,
StartUpdateOptions,
} from 'sp-react-native-in-app-updates';

const HIGH_PRIORITY_UPDATE = 5; // Arbitrary, depends on how you handle priority in the Play Console
export const checkUpdate = () => {
const inAppUpdates = new SpInAppUpdates(false);
console.log('[INAPP] Checking store version');
inAppUpdates.checkNeedsUpdate({ curVersion: Constants.expoConfig.version }).then((result) => {
console.log('[INAPP] result: ' + JSON.stringify(result));
if (result.shouldUpdate) {
if (Platform.OS === 'android') {
const updateOptions: StartUpdateOptions = {
updateType:
(result?.other as AndroidInAppUpdateExtras)?.updatePriority <= HIGH_PRIORITY_UPDATE // TODO: implement flexible
? IAUUpdateKind.IMMEDIATE
: IAUUpdateKind.FLEXIBLE,
};
if (updateOptions.updateType === IAUUpdateKind.FLEXIBLE) {
inAppUpdates.addStatusUpdateListener((ev) => {
console.debug(`[INAPP] status: ${JSON.stringify(ev)}`);
if (ev.status === AndroidInstallStatus.DOWNLOADED) console.log('[INAPP] downloaded');
});
}
inAppUpdates.startUpdate(updateOptions); // https://github.com/SudoPlz/sp-react-native-in-app-updates/blob/master/src/types.ts#L78
}
}
});
return inAppUpdates;
};

export const installUpdate = (spInAppUpdates: SpInAppUpdates) => spInAppUpdates.installUpdate();
30 changes: 28 additions & 2 deletions src/utils/sentry.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import * as Sentry from '@sentry/react-native';
import * as SentryExpo from 'sentry-expo';

import { ISessionTeachPlan } from '../models/teachPlan';

export default () => {
console.log('[SENTRY] Initializing...');

@@ -11,8 +14,31 @@ export default () => {
SentryExpo.init({
dsn,
tracesSampleRate: 1.0,
enableInExpoDevelopment: false,
debug: false, // If `true`, Sentry will try to print out useful debugging information if something goes wrong with sending the event. Set it to `false` in production
integrations: __DEV__
? [
new SentryExpo.Native.ReactNativeTracing({
shouldCreateSpanForRequest: (url) => {
return !url.startsWith(`http://`);
},
}),
]
: [],
enableInExpoDevelopment: true,
debug: __DEV__, // If `true`, Sentry will try to print out useful debugging information if something goes wrong with sending the event. Set it to `false` in production
});
}
};

const subjectRegex = /([а-яА-Я\w\s":.,+#-]+(?: \([а-яА-Я\w\s]+\))?(?: \[[а-яА-Я\w\s,]+])?)/s;
export const checkSubjectNames = (teachPlan: ISessionTeachPlan[]) => {
const incorrectDisciplines = teachPlan
?.map((session) => session.disciplines.map((discipline) => discipline.name))
.flat()
.filter((name) => !subjectRegex.test(name));
if (incorrectDisciplines?.length != 0) {
Sentry.captureMessage(
`Disciplines mismatched w/ regex: ${JSON.stringify(incorrectDisciplines)}`,
'error'
);
}
};

0 comments on commit 6a9a6b2

Please sign in to comment.