mirror of
https://github.com/mudabbir-ahmad/MAD-Treasure-Hunt.git
synced 2026-10-08 03:00:20 +00:00
Fixed an issue where departments could interact and see caches from other departments for org accounts. Fixed this issue.
This commit is contained in:
1 parent
909cbb9de6
commit
41b0b723ca
4 files changed
+34
-22
No files matched your search
@@ -13,6 +13,9 @@ const LeaderboardScreen = ({navigation, route}) => {
|
||||
const isAdmin = session.isAcceptedAdmin;
|
||||
const isBusiness = Boolean(session.isBusiness);
|
||||
const selectedDepartment = route?.params?.department || null;
|
||||
const effectiveSGid = isBusiness
|
||||
? ((isAdmin && selectedDepartment?.SGid) ? selectedDepartment.SGid : (isAdmin ? null : session.currentSGid))
|
||||
: null;
|
||||
const {getLobby, getSubgroup, getTeams, getTeamMembers, getGroupMembers, getCaches, getUser, deleteTeam, resetPlayerProgress, resetTeamProgress, getSubgroups} = useGameHook();
|
||||
|
||||
// State ----------------------
|
||||
@@ -34,10 +37,6 @@ const LeaderboardScreen = ({navigation, route}) => {
|
||||
|
||||
const group = await getLobby(session.currentGid);
|
||||
|
||||
const effectiveSGid = isBusiness
|
||||
? ((isAdmin && selectedDepartment?.SGid) ? selectedDepartment.SGid : (isAdmin ? null : session.currentSGid))
|
||||
: null;
|
||||
|
||||
let isTeams = Boolean(group?.TeamsEnabled);
|
||||
if (effectiveSGid !== null && effectiveSGid !== undefined) {
|
||||
const subgroup = await getSubgroup(effectiveSGid);
|
||||
@@ -117,7 +116,7 @@ const LeaderboardScreen = ({navigation, route}) => {
|
||||
}
|
||||
|
||||
setLoading(false);
|
||||
}, [session.currentGid, session.currentTid, session.currentSGid, isBusiness, isAdmin, selectedDepartment, selectedDepartment?.SGid]);
|
||||
}, [session.currentGid, session.currentTid, session.currentSGid, isBusiness, isAdmin, selectedDepartment, selectedDepartment?.SGid, effectiveSGid]);
|
||||
|
||||
useEffect(() => { loadData(); }, [loadData]);
|
||||
|
||||
@@ -144,7 +143,7 @@ const LeaderboardScreen = ({navigation, route}) => {
|
||||
text: 'Reset',
|
||||
style: 'destructive',
|
||||
onPress: async () => {
|
||||
await resetPlayerProgress(session.currentGid, player.uid);
|
||||
await resetPlayerProgress(session.currentGid, player.uid, effectiveSGid);
|
||||
Alert.alert('Done', `Progress for ${player.name} has been reset.`);
|
||||
await loadData();
|
||||
},
|
||||
@@ -159,7 +158,7 @@ const LeaderboardScreen = ({navigation, route}) => {
|
||||
text: 'Reset',
|
||||
style: 'destructive',
|
||||
onPress: async () => {
|
||||
await resetTeamProgress(session.currentGid, team.tid);
|
||||
await resetTeamProgress(session.currentGid, team.tid, effectiveSGid);
|
||||
Alert.alert('Done', `Progress for team "${team.name}" has been reset.`);
|
||||
await loadData();
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user