Skip to content

Commit

Permalink
Fix video autoclose (hcengineering#6843)
Browse files Browse the repository at this point in the history
Signed-off-by: Kristina Fefelova <[email protected]>
  • Loading branch information
kristina-fefelova authored Oct 9, 2024
1 parent 4f213c4 commit 1107328
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
<div class="antiHSpacer" />
{:else if secondaryNotifyMarker}
<div class="antiHSpacer" />
<NotifyMarker count={0} kind="simple" />
<NotifyMarker count={0} kind="with-dot" />
<div class="antiHSpacer" />
{/if}
</svelte:fragment>
Expand Down
11 changes: 8 additions & 3 deletions plugins/love-resources/src/components/ControlExt.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,8 @@
}
function checkActiveVideo (loc: Location, video: boolean, room: Ref<Room> | undefined): void {
const isOpened = $sidebarStore.widgetsState.has(love.ids.VideoWidget)
const widgetState = $sidebarStore.widgetsState.get(love.ids.VideoWidget)
const isOpened = widgetState !== undefined
if (room === undefined) {
if (isOpened) {
Expand All @@ -319,11 +320,15 @@
{
room
},
loc.path[2] !== loveId
{ active: loc.path[2] !== loveId, openedByUser: false }
)
}
if (loc.path[2] === loveId && $sidebarStore.widget === love.ids.VideoWidget) {
if (
loc.path[2] === loveId &&
$sidebarStore.widget === love.ids.VideoWidget &&
widgetState?.openedByUser !== true
) {
minimizeSidebar()
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
-->
<script lang="ts">
export let count: number = 0
export let kind: 'primary' | 'simple' = 'primary'
export let kind: 'primary' | 'simple' | 'with-dot' = 'primary'
export let size: 'xx-small' | 'x-small' | 'small' | 'medium' = 'small'
const maxNumber = 9
Expand All @@ -34,6 +34,10 @@
<div class="notifyMarker {size} {kind}" />
{/if}

{#if kind === 'with-dot'}
<div class="notifyMarker {size} {kind}">●</div>
{/if}

<style lang="scss">
.notifyMarker {
display: flex;
Expand All @@ -44,6 +48,7 @@
font-weight: 700;
&.simple,
&.with-dot,
&.primary {
background-color: var(--global-higlight-Color);
color: var(--global-on-accent-TextColor);
Expand All @@ -70,5 +75,10 @@
height: 1.25rem;
font-size: 0.625rem;
}
&.with-dot {
font-weight: 400;
font-size: 0.25rem;
}
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
if (selected === widget._id) {
minimizeSidebar(true)
} else {
openWidget(widget, $sidebarStore.widgetsState.get(widget._id)?.data, true)
openWidget(widget, $sidebarStore.widgetsState.get(widget._id)?.data, { active: true, openedByUser: true })
}
}
Expand Down
12 changes: 10 additions & 2 deletions plugins/workbench-resources/src/sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export interface WidgetState {
tabs: WidgetTab[]
tab?: string
closedByUser?: boolean
openedByUser?: boolean
}

export interface SidebarState {
Expand Down Expand Up @@ -97,16 +98,23 @@ function setSidebarStateToLocalStorage (state: SidebarState): void {
)
}

export function openWidget (widget: Widget, data?: Record<string, any>, active = true): void {
export function openWidget (
widget: Widget,
data?: Record<string, any>,
params?: { active: boolean, openedByUser: boolean }
): void {
const state = get(sidebarStore)
const { widgetsState } = state
const widgetState = widgetsState.get(widget._id)
const active = params?.active ?? true
const openedByUser = params?.openedByUser ?? false

widgetsState.set(widget._id, {
_id: widget._id,
data: data ?? widgetState?.data,
tab: widgetState?.tab,
tabs: widgetState?.tabs ?? []
tabs: widgetState?.tabs ?? [],
openedByUser
})

Analytics.handleEvent('workbench.OpenSidebarWidget', { widget: widget._id })
Expand Down

0 comments on commit 1107328

Please sign in to comment.