Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
Kayak UI 0.11
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Microhacks
Bevy Forks
Kayak UI 0.11
Commits
a28080db
Commit
a28080db
authored
2 years ago
by
John Mitchell
Browse files
Options
Downloads
Patches
Plain Diff
Fixed root context not working.
parent
cdab7228
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/context.rs
+2
-4
2 additions, 4 deletions
src/context.rs
src/context_entities.rs
+3
-3
3 additions, 3 deletions
src/context_entities.rs
src/widget_context.rs
+12
-6
12 additions, 6 deletions
src/widget_context.rs
with
17 additions
and
13 deletions
src/context.rs
+
2
−
4
View file @
a28080db
...
...
@@ -227,10 +227,8 @@ impl KayakRootContext {
parent_id
:
Option
<
Entity
>
,
context_entity
:
Entity
,
)
{
if
let
Some
(
parent_id
)
=
parent_id
{
self
.context_entities
.add_context_entity
::
<
T
>
(
parent_id
,
context_entity
);
}
self
.context_entities
.add_context_entity
::
<
T
>
(
parent_id
,
context_entity
);
}
/// Returns a new/existing widget entity.
...
...
This diff is collapsed.
Click to expand it.
src/context_entities.rs
+
3
−
3
View file @
a28080db
...
...
@@ -8,7 +8,7 @@ use dashmap::DashMap;
#[derive(Debug,
Clone)]
pub
struct
ContextEntities
{
ce
:
Arc
<
DashMap
<
Entity
,
DashMap
<
TypeId
,
Entity
>>>
,
ce
:
Arc
<
DashMap
<
Option
<
Entity
>
,
DashMap
<
TypeId
,
Entity
>>>
,
}
impl
ContextEntities
{
...
...
@@ -20,7 +20,7 @@ impl ContextEntities {
pub
fn
add_context_entity
<
T
:
Default
+
'static
>
(
&
self
,
parent_id
:
Entity
,
parent_id
:
Option
<
Entity
>
,
context_entity
:
Entity
,
)
{
if
!
self
.ce
.contains_key
(
&
parent_id
)
{
...
...
@@ -30,7 +30,7 @@ impl ContextEntities {
inner
.insert
(
T
::
default
()
.type_id
(),
context_entity
);
}
pub
fn
get_context_entity
<
T
:
Default
+
'static
>
(
&
self
,
parent_id
:
Entity
)
->
Option
<
Entity
>
{
pub
fn
get_context_entity
<
T
:
Default
+
'static
>
(
&
self
,
parent_id
:
Option
<
Entity
>
)
->
Option
<
Entity
>
{
if
!
self
.ce
.contains_key
(
&
parent_id
)
{
return
None
;
}
...
...
This diff is collapsed.
Click to expand it.
src/widget_context.rs
+
12
−
6
View file @
a28080db
...
...
@@ -72,10 +72,8 @@ impl KayakWidgetContext {
parent_id
:
Option
<
Entity
>
,
context_entity
:
Entity
,
)
{
if
let
Some
(
parent_id
)
=
parent_id
{
self
.context_entities
.add_context_entity
::
<
T
>
(
parent_id
,
context_entity
);
}
self
.context_entities
.add_context_entity
::
<
T
>
(
parent_id
,
context_entity
);
}
/// Finds the closest matching context entity by traversing up the tree.
...
...
@@ -86,7 +84,7 @@ impl KayakWidgetContext {
// Check self first..
if
let
Some
(
entity
)
=
self
.context_entities
.get_context_entity
::
<
T
>
(
current_entity
)
.get_context_entity
::
<
T
>
(
Some
(
current_entity
)
)
{
return
Some
(
entity
);
}
...
...
@@ -97,12 +95,20 @@ impl KayakWidgetContext {
while
parent
.is_some
()
{
if
let
Some
(
entity
)
=
self
.context_entities
.get_context_entity
::
<
T
>
(
parent
.unwrap
()
.0
)
.get_context_entity
::
<
T
>
(
Some
(
parent
.unwrap
()
.0
)
)
{
return
Some
(
entity
);
}
parent
=
tree
.get_parent
(
parent
.unwrap
());
}
// Finally check root AKA no parent.
if
let
Some
(
entity
)
=
self
.context_entities
.get_context_entity
::
<
T
>
(
None
)
{
return
Some
(
entity
);
}
}
None
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment