Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Poseidon281 committed Jun 7, 2024
2 parents 9c96a04 + 6ac624e commit ad00b96
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
1 change: 1 addition & 0 deletions lang/en/dashboard/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
'add_group' => 'Add Group',
'delete_group' => 'Delete Current Group',
'move_server' => 'Move Server',
'all_servers' => "All Servers",

'content_tabs' => 'Content tabs',
'overview' => 'Overview',
Expand Down
23 changes: 18 additions & 5 deletions resources/scripts/components/dashboard/DashboardContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,15 @@ export default () => {
if (!error) clearFlashes('dashboard');
}, [error]);

useEffect(() => {
const storedCurrentGroup = localStorage.getItem(`currentGroup:${uuid}`);
if (storedCurrentGroup && groups[storedCurrentGroup]) {
setCurrentGroup(storedCurrentGroup);
} else {
setCurrentGroup('default');
}
}, [uuid, groups]);

useEffect(() => {
const savedGroups = localStorage.getItem(`groups:${uuid}`);
if (savedGroups) {
Expand All @@ -72,8 +81,8 @@ export default () => {
}, [uuid]);

useEffect(() => {
localStorage.setItem(`groups:${uuid}`, JSON.stringify(groups));
}, [groups]);
localStorage.setItem(`currentGroup:${uuid}`, currentGroup);
}, [uuid, currentGroup]);

const addGroup = () => {
if (newGroupName && !groups[newGroupName]) {
Expand Down Expand Up @@ -102,7 +111,11 @@ export default () => {
if (currentGroup) {
updatedGroups[currentGroup] = updatedGroups[currentGroup].filter((uuid) => uuid !== serverUuid);
}
updatedGroups[targetGroup].push(serverUuid);
if (!updatedGroups[targetGroup].includes(serverUuid)) {
if (currentGroup !== targetGroup) {
updatedGroups[targetGroup].push(serverUuid);
}
}
setGroups(updatedGroups);
setShowMoveOptions((prevState) => ({ ...prevState, [serverUuid]: false }));
};
Expand Down Expand Up @@ -158,7 +171,7 @@ export default () => {
>
{Object.keys(groups).map((group) => (
<option key={group} value={group}>
{group}
{group === 'default' ? t('all_servers') : group}
</option>
))}
</select>
Expand Down Expand Up @@ -229,7 +242,7 @@ export default () => {
>
{Object.keys(groups).map((group) => (
<option key={group} value={group}>
{group}
{group === 'default' ? t('all_servers') : group}
</option>
))}
</select>
Expand Down

0 comments on commit ad00b96

Please sign in to comment.