Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion App.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
} from './src/notifications/notificationService';

import IncomingWorkOverlay from './src/components/IncomingWorkOverlay';
import { clearIncomingWork } from './src/redux/workSlice';
import { clearIncomingWork, showIncomingWork } from './src/redux/workSlice';

function AppContainer() {
const dispatch = useDispatch();
Expand All @@ -29,6 +29,9 @@ function AppContainer() {
state => state.work?.incomingWork
);

// Track current logged in worker for real-time listener
const workerId = useSelector(state => state.auth?.user?.id);

/* NOTIFICATION INIT */
useEffect(() => {
const initNotifications = async () => {
Expand Down Expand Up @@ -66,6 +69,32 @@ function AppContainer() {
initNotifications();
}, []);

/* SUPABASE REALTIME NOTIFICATIONS */
useEffect(() => {
if (!workerId) return;

console.log(`Setting up Supabase real-time listener for worker ${workerId}...`);
const channel = supabase.channel('worker_notifications');

const subscription = channel
.on('broadcast', { event: `new_task_worker_${workerId}` }, (payload) => {
const jobDetails = payload.payload;
console.log('Received new task broadcast:', jobDetails);

// Show IncomingWorkOverlay and play ringtone
dispatch(showIncomingWork(jobDetails));
RingtoneService.startRingtone();
})
.subscribe((status) => {
console.log(`Supabase Realtime status for worker ${workerId}:`, status);
});

return () => {
console.log(`Unsubscribing from worker_notifications for worker ${workerId}`);
supabase.removeChannel(channel);
};
}, [workerId, dispatch]);

/* UI*/
return (
<SafeAreaProvider>
Expand Down
40 changes: 23 additions & 17 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,19 @@ android {
compileSdk rootProject.ext.compileSdkVersion

namespace "com.workers"

defaultConfig {
applicationId "com.workers"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 4
versionName "1.0.3"
}


packagingOptions {
pickFirst '**/libworklets.so'
}

signingConfigs {
debug {
storeFile file('debug.keystore')
Expand All @@ -95,26 +100,27 @@ android {
}

release {
storeFile file(GOBUILD_UPLOAD_STORE_FILE)
storePassword GOBUILD_UPLOAD_STORE_PASSWORD
keyAlias GOBUILD_UPLOAD_KEY_ALIAS
keyPassword GOBUILD_UPLOAD_KEY_PASSWORD
}

}
buildTypes {
debug {
signingConfig signingConfigs.debug
storeFile file(GOBUILD_UPLOAD_STORE_FILE)
storePassword GOBUILD_UPLOAD_STORE_PASSWORD
keyAlias GOBUILD_UPLOAD_KEY_ALIAS
keyPassword GOBUILD_UPLOAD_KEY_PASSWORD
}
}
release {
signingConfig signingConfigs.release
minifyEnabled false
shrinkResources false
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"

buildTypes {
debug {
signingConfig signingConfigs.debug
}

release {
signingConfig signingConfigs.release
minifyEnabled false
shrinkResources false
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
}

}

dependencies {
// The version of react-native is set by the React Native Gradle Plugin
Expand Down
2 changes: 2 additions & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.WAKE_LOCK"/>

<application
Expand Down
Binary file added android/build_log.txt
Binary file not shown.
81 changes: 79 additions & 2 deletions package-lock.json

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

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"dependencies": {
"@notifee/react-native": "^9.1.8",
"@react-native-async-storage/async-storage": "^2.2.0",
"@react-native-community/geolocation": "^3.4.0",
"@react-native-firebase/app": "^23.8.3",
"@react-native-firebase/messaging": "^23.8.3",
"@react-native/new-app-screen": "0.82.1",
Expand All @@ -26,6 +27,7 @@
"buffer": "^6.0.3",
"react": "19.1.1",
"react-native": "0.82.1",
"react-native-calendars": "^1.1314.0",
"react-native-dotenv": "^3.4.11",
"react-native-flash-message": "^0.4.2",
"react-native-fs": "^2.20.0",
Expand Down
7 changes: 7 additions & 0 deletions src/api/Api.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import axios from "axios";

const Api = axios.create({
baseURL: "http://192.168.29.153:3000",
timeout: 5000,
});
export default Api ;
1 change: 0 additions & 1 deletion src/screens/AuthScreens/Login.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,6 @@ const styles = StyleSheet.create({
marginBottom: 20,
gap: 10,
top: 10,
marginBottom: 30
},

loginText: {
Expand Down
Loading