Skip to content

Commit f54ca33

Browse files
committed
Fix states
1 parent 1f75dfd commit f54ca33

1 file changed

Lines changed: 15 additions & 16 deletions

File tree

src/routes/(authenticated)/shares/user/EditShare.svelte

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,12 @@
132132
133133
$effect(() => {
134134
// Nice instant state update to indicate what is happening to the share limits
135-
if (isUniformRestrictions) {
136135
shares.forEach((share) => {
137-
share.permissions = uniformPermissions;
138-
share.limits = uniformLimits;
136+
share.permissions = { ...uniformPermissions };
137+
share.limits = { ...uniformLimits };
139138
});
140-
}
141139
});
140+
142141
</script>
143142

144143
<Drawer.Root
@@ -235,15 +234,15 @@
235234
Change restrictions for individual shockers
236235
</p>
237236
<div class="flex flex-col gap-8 overflow-x-auto">
238-
{#each shares as share}
237+
{#each shares as share, i (share.id)}
239238
<div class="flex flex-col gap-2 border-1 border-neutral-800 p-4 rounded-md">
240239
<div class="flex justify-between">
241240
<span>
242-
<Badge>{share.name}</Badge>
241+
<Badge>{shares[i].name}</Badge>
243242
</span>
244243
<PauseToggle
245-
shockerId={share.id}
246-
bind:paused={share.paused}
244+
shockerId={shares[i].id}
245+
bind:paused={shares[i].paused}
247246
userShareUserId={userShare.id}
248247
onPausedChange={(paused) => {
249248
userShare.shares.forEach((s) => {
@@ -255,21 +254,21 @@
255254
/>
256255
</div>
257256
<div>
258-
<Label class="mb-3 text-sm">Intensity: {share.limits.intensity}%</Label>
257+
<Label class="mb-3 text-sm">Intensity: {shares[i].limits.intensity}%</Label>
259258
<Slider
260259
type="single"
261-
bind:value={share.limits.intensity}
260+
bind:value={shares[i].limits.intensity}
262261
min={0}
263262
max={100}
264263
step={1}
265264
/>
266265
</div>
267266

268267
<div>
269-
<Label class="mb-3 text-sm">Duration: {share.limits.duration / 1000}s</Label>
268+
<Label class="mb-3 text-sm">Duration: {shares[i].limits.duration / 1000}s</Label>
270269
<Slider
271270
type="single"
272-
bind:value={share.limits.duration}
271+
bind:value={shares[i].limits.duration}
273272
min={0}
274273
max={30_000}
275274
step={100}
@@ -279,10 +278,10 @@
279278
<br />
280279

281280
<div class="flex gap-3">
282-
<PermissionSwitch icon={Zap} bind:enabled={share.permissions.shock} />
283-
<PermissionSwitch icon={Waves} bind:enabled={share.permissions.vibrate} />
284-
<PermissionSwitch icon={Volume2} bind:enabled={share.permissions.sound} />
285-
<PermissionSwitch icon={Volume2} bind:enabled={share.permissions.live} />
281+
<PermissionSwitch icon={Zap} bind:enabled={shares[i].permissions.shock} />
282+
<PermissionSwitch icon={Waves} bind:enabled={shares[i].permissions.vibrate} />
283+
<PermissionSwitch icon={Volume2} bind:enabled={shares[i].permissions.sound} />
284+
<PermissionSwitch icon={Volume2} bind:enabled={shares[i].permissions.live} />
286285
</div>
287286
</div>
288287
{/each}

0 commit comments

Comments
 (0)