handle visibility and crew share in party save
This commit is contained in:
parent
e263c426b6
commit
f8e585519b
1 changed files with 40 additions and 1 deletions
|
|
@ -30,7 +30,9 @@
|
||||||
useDeleteParty,
|
useDeleteParty,
|
||||||
useRemixParty,
|
useRemixParty,
|
||||||
useFavoriteParty,
|
useFavoriteParty,
|
||||||
useUnfavoriteParty
|
useUnfavoriteParty,
|
||||||
|
useSharePartyWithCrew,
|
||||||
|
useRemovePartyShare
|
||||||
} from '$lib/api/mutations/party.mutations'
|
} from '$lib/api/mutations/party.mutations'
|
||||||
|
|
||||||
// TanStack Query mutations - Job
|
// TanStack Query mutations - Job
|
||||||
|
|
@ -158,6 +160,8 @@
|
||||||
const remixPartyMutation = useRemixParty()
|
const remixPartyMutation = useRemixParty()
|
||||||
const favoritePartyMutation = useFavoriteParty()
|
const favoritePartyMutation = useFavoriteParty()
|
||||||
const unfavoritePartyMutation = useUnfavoriteParty()
|
const unfavoritePartyMutation = useUnfavoriteParty()
|
||||||
|
const sharePartyWithCrewMutation = useSharePartyWithCrew()
|
||||||
|
const removePartyShareMutation = useRemovePartyShare()
|
||||||
|
|
||||||
// TanStack Query mutations - Job
|
// TanStack Query mutations - Job
|
||||||
const updateJobMutation = useUpdatePartyJob()
|
const updateJobMutation = useUpdatePartyJob()
|
||||||
|
|
@ -443,9 +447,14 @@
|
||||||
function openSettingsPanel() {
|
function openSettingsPanel() {
|
||||||
if (!canEdit()) return
|
if (!canEdit()) return
|
||||||
|
|
||||||
|
// Check if party is currently shared with a crew
|
||||||
|
const isSharedWithCrew = party.shares?.some((s) => s.shareableType === 'crew') ?? false
|
||||||
|
|
||||||
const initialValues: PartyEditValues = {
|
const initialValues: PartyEditValues = {
|
||||||
name: party.name ?? '',
|
name: party.name ?? '',
|
||||||
description: party.description ?? null,
|
description: party.description ?? null,
|
||||||
|
visibility: party.visibility ?? 'public',
|
||||||
|
sharedWithCrew: isSharedWithCrew,
|
||||||
fullAuto: party.fullAuto ?? false,
|
fullAuto: party.fullAuto ?? false,
|
||||||
autoGuard: party.autoGuard ?? false,
|
autoGuard: party.autoGuard ?? false,
|
||||||
autoSummon: party.autoSummon ?? false,
|
autoSummon: party.autoSummon ?? false,
|
||||||
|
|
@ -463,9 +472,11 @@
|
||||||
initialValues,
|
initialValues,
|
||||||
element: userElement,
|
element: userElement,
|
||||||
onSave: async (values) => {
|
onSave: async (values) => {
|
||||||
|
// Update party details including visibility
|
||||||
await updatePartyDetails({
|
await updatePartyDetails({
|
||||||
name: values.name,
|
name: values.name,
|
||||||
description: values.description,
|
description: values.description,
|
||||||
|
visibility: values.visibility,
|
||||||
fullAuto: values.fullAuto,
|
fullAuto: values.fullAuto,
|
||||||
autoGuard: values.autoGuard,
|
autoGuard: values.autoGuard,
|
||||||
autoSummon: values.autoSummon,
|
autoSummon: values.autoSummon,
|
||||||
|
|
@ -477,6 +488,34 @@
|
||||||
videoUrl: values.videoUrl,
|
videoUrl: values.videoUrl,
|
||||||
raidId: values.raidId
|
raidId: values.raidId
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Handle crew share toggle
|
||||||
|
const wasShared = party.shares?.some((s) => s.shareableType === 'crew') ?? false
|
||||||
|
if (values.sharedWithCrew && !wasShared) {
|
||||||
|
// Share with crew
|
||||||
|
try {
|
||||||
|
await sharePartyWithCrewMutation.mutateAsync({
|
||||||
|
partyId: party.id,
|
||||||
|
shortcode: party.shortcode
|
||||||
|
})
|
||||||
|
} catch (err: any) {
|
||||||
|
console.error('Failed to share with crew:', err)
|
||||||
|
}
|
||||||
|
} else if (!values.sharedWithCrew && wasShared) {
|
||||||
|
// Remove crew share
|
||||||
|
const share = party.shares?.find((s) => s.shareableType === 'crew')
|
||||||
|
if (share) {
|
||||||
|
try {
|
||||||
|
await removePartyShareMutation.mutateAsync({
|
||||||
|
partyId: party.id,
|
||||||
|
shareId: share.id,
|
||||||
|
shortcode: party.shortcode
|
||||||
|
})
|
||||||
|
} catch (err: any) {
|
||||||
|
console.error('Failed to remove share:', err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue