Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
fabienSvstr committed Feb 25, 2025
1 parent b7806cb commit 6894d93
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
11 changes: 8 additions & 3 deletions client/src/views/menu/MenuPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
<sidebar-menu
v-if="userInfo"
:user-info="userInfo"
@sidebar-width="sidebarWidth"
@sidebar-width-changed="onSidebarWidthChanged"
/>
{{ sidebarWidth }}
<tab-menu
v-if="userInfo"
v-show="menuMode === MenuMode.Tabs"
Expand All @@ -32,17 +31,23 @@ const sidebarWidth = ref<number>(0);
const userInfo: Ref<ClientInfo | null> = ref(null);
const menuMode = ref<MenuMode>(MenuMode.Sidebar);

function onSidebarWidthChanged(value: number): void {
sidebarWidth.value = value;
setToastOffset(value);
console.log(value);
}

async function updateWindowWidth(): Promise<void> {
if (window.innerWidth <= 768) {
setToastOffset(0);
menuMode.value = MenuMode.Tabs;
} else {
setToastOffset(sidebarWidth.value);
menuMode.value = MenuMode.Sidebar;
}
}

onMounted(async () => {

const infoResult = await parsecGetClientInfo();

if (infoResult.ok) {
Expand Down
16 changes: 6 additions & 10 deletions client/src/views/menu/SidebarMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -403,8 +403,8 @@ defineProps<{
userInfo: ClientInfo;
}>();

const emit = defineEmits<{
(event:'sidebarWidth', value: number): void;
const emits = defineEmits<{
(event:'sidebarWidthChanged', value: number): void;
}>();

const isManagement = currentRouteIsOrganizationManagementRoute;
Expand All @@ -431,8 +431,6 @@ const MAX_WIDTH = 370;

const watchSidebarWidthCancel = watch(computedWidth, async (value: number) => {
sidebarWidthProperty.value = `${value}px`;
// set toast offset
setToastOffset(value);

if (timeoutId !== undefined) {
clearTimeout(timeoutId);
Expand All @@ -448,6 +446,8 @@ const watchSidebarWidthCancel = watch(computedWidth, async (value: number) => {
);
timeoutId = undefined;
}, 2000);

emits('sidebarWidthChanged', value);
});

const currentWorkspace = computed(() => {
Expand Down Expand Up @@ -502,6 +502,7 @@ function onMove(detail: GestureDetail): void {
} else {
computedWidth.value = detail.currentX;
}
emits('sidebarWidthChanged', computedWidth.value);
}

onMounted(async () => {
Expand All @@ -525,6 +526,7 @@ onMounted(async () => {
computedWidth.value = savedSidebarData.width;
}
sidebarWidthProperty.value = `${computedWidth.value}px`;
emits('sidebarWidthChanged', computedWidth.value);
menusVisible.value.favorites = savedSidebarData.favoritesVisible ?? true;
menusVisible.value.recentWorkspaces = savedSidebarData.workspacesVisible ?? true;
menusVisible.value.recentFiles = savedSidebarData.recentFilesVisible ?? true;
Expand All @@ -534,7 +536,6 @@ onMounted(async () => {
isExpired.value = connInfo.isExpired;
}

emit('sidebarWidth', computedWidth.value);
await loadAll();
if (divider.value) {
const gesture = createGesture({
Expand All @@ -561,13 +562,8 @@ onUnmounted(async () => {
clearTimeout(timeoutId);
}
watchSidebarWidthCancel();
setToastOffset(0);
});

function setToastOffset(width: number): void {
window.document.documentElement.style.setProperty('--ms-toast-offset', `${width}px`);
}

async function goToWorkspace(workspace: WorkspaceInfo): Promise<void> {
recentDocumentManager.addWorkspace(workspace);
await recentDocumentManager.saveToStorage(storageManager);
Expand Down

0 comments on commit 6894d93

Please sign in to comment.