Skip to content

Commit

Permalink
fix: sonar issues
Browse files Browse the repository at this point in the history
  • Loading branch information
KestasVenslauskas committed Feb 22, 2024
1 parent 46ede40 commit cf0de16
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 27 deletions.
1 change: 1 addition & 0 deletions android/app/src/debug/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

<application
android:usesCleartextTraffic="true"
android:allowBackup="false"
tools:targetApi="28"
tools:ignore="GoogleAppIndexingWarning">
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" android:exported="false" />
Expand Down
16 changes: 2 additions & 14 deletions app/components/videoComponent/TheoMediaPlayer.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
import React, {useCallback, useEffect, useMemo, useState} from 'react';
import {
ActivityIndicator,
BackHandler,
ImageBackground,
Platform,
StyleSheet,
View,
ViewStyle,
} from 'react-native';
import React, {useCallback, useEffect, useState} from 'react';
import {ActivityIndicator, BackHandler, ImageBackground, Platform, StyleSheet, View} from 'react-native';
import {
PlayerConfiguration,
SourceDescription,
Expand All @@ -19,7 +11,6 @@ import {
Event,
TimeUpdateEvent,
AspectRatio,
ABRStrategyType,
ReadyStateChangeEvent,
PresentationMode,
} from 'react-native-theoplayer';
Expand Down Expand Up @@ -102,9 +93,6 @@ const TheoMediaPlayer: React.FC<React.PropsWithChildren<Props>> = ({
isPausedByUser,
setIsPausedByUser,

isFullScreen,
setIsFullScreen,

setVideoBaseData,
registerFullScreenListener,
unregisterFullScreenListener,
Expand Down
2 changes: 1 addition & 1 deletion app/components/videoComponent/VideoComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ interface Props {
const MAX_ERROR_COUNT = 3;
const ERROR_DELAY = 1000;

const VideoComponent: React.FC<React.PropsWithChildren<Props>> = (props) => {
const VideoComponent: React.FC<PropsWithChildren<Props>> = (props) => {
const {colors, strings} = useTheme();
const {isLoading, data, load} = useVideoData(props.streamData);

Expand Down
15 changes: 5 additions & 10 deletions app/util/useFirebaseMessaging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ import notifee, {
EventType,
Event,
AndroidCategory,
AndroidBadgeIconType,
AndroidStyle,
AndroidBigPictureStyle,
} from '@notifee/react-native';

const INITIAL_URL_STORAGE_KEY = 'initialUrl';
Expand Down Expand Up @@ -54,11 +52,8 @@ const _handleInitialNotification = async () => {
};

const _onNotificationEvent = async ({type, detail}: Event) => {
switch (type) {
case EventType.PRESS:
detail.notification;
_handleNotificationOpen(detail.notification?.data as NotificationData, false);
break;
if (type === EventType.PRESS) {
_handleNotificationOpen(detail.notification?.data as NotificationData, false);
}
};

Expand Down Expand Up @@ -100,15 +95,15 @@ const useFirebaseMessaging = (isNavigationReady: boolean) => {

const unsubscribeOnMessage = messaging().onMessage(async (remoteMessage) => {
if (remoteMessage.notification) {
const iosFCMOptions = remoteMessage.data?.fcm_options as any;
const iosFCMOptions: any = remoteMessage.data?.fcm_options;

notifee.displayNotification({
id: remoteMessage.messageId,
title: remoteMessage.notification.title,
body: remoteMessage.notification.body,
data: remoteMessage.data,
ios: {
attachments: !!iosFCMOptions?.image
attachments: iosFCMOptions?.image
? [
{
url: iosFCMOptions?.image as string,
Expand All @@ -117,7 +112,7 @@ const useFirebaseMessaging = (isNavigationReady: boolean) => {
: [],
},
android: {
style: !!remoteMessage.notification.android?.imageUrl
style: remoteMessage.notification.android?.imageUrl
? {
type: AndroidStyle.BIGPICTURE,
picture: remoteMessage.notification.android?.imageUrl!,
Expand Down
6 changes: 4 additions & 2 deletions app/util/useFirebaseTopicSubscription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,31 @@ const useFirebaseTopicSubscription = () => {
const subscribeToTopic = useCallback(
async (topicSlug: string) => {
if (subscriptions.indexOf(topicSlug) === -1) {
const originalSubscriptions = [...subscriptions];
const list = [...subscriptions, topicSlug];
setSubscriptions(list);
messaging()
.subscribeToTopic(topicSlug)
.then(() => AsyncStorage.setItem(TOPICS_STORAGE_KEY, JSON.stringify(list)))
.then(() => console.log('Subscribed to topic: ' + topicSlug))
//revert if failed
.catch(() => setSubscriptions(subscriptions));
.catch(() => setSubscriptions(originalSubscriptions));
}
},
[subscriptions],
);

const unsubscribeFromTopic = useCallback(
async (topicSlug: string) => {
const originalSubscriptions = [...subscriptions];
const list = subscriptions.filter((item) => item !== topicSlug);
setSubscriptions(list);
messaging()
.unsubscribeFromTopic(topicSlug)
.then(() => AsyncStorage.setItem(TOPICS_STORAGE_KEY, JSON.stringify(list)))
.then(() => console.log('Unsubscribed from topic: ' + topicSlug))
//revert if failed
.catch(() => setSubscriptions(subscriptions));
.catch(() => setSubscriptions(originalSubscriptions));
},
[subscriptions],
);
Expand Down

0 comments on commit cf0de16

Please sign in to comment.