-
Notifications
You must be signed in to change notification settings - Fork 17
feat: open Explorer UI from SDK scene #9472
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from all commits
ff1d39c
73083b7
6536614
ac4351c
02b083a
14ef374
c69ac33
70fab29
554bb09
aef0c1d
8d16d00
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| using Cysharp.Threading.Tasks; | ||
| using DCL.Communities; | ||
| using DCL.CrdtEcsBridge.JsModulesImplementation; | ||
| using DCL.Diagnostics; | ||
| using DCL.ExplorePanel; | ||
| using DCL.UI; | ||
| using Decentraland.Kernel.Apis; | ||
| using MVC; | ||
| using System; | ||
|
|
||
| namespace DCL.Infrastructure.CrdtEcsBridge.JsModulesImplementation.RestrictedActions | ||
| { | ||
| /// <summary> | ||
| /// Implementation of <see cref="IExplorerUiActions" />. The sibling asmref compiles it into | ||
| /// DCL.Social (not into SceneRuntime like the rest of this folder) because it references | ||
| /// <see cref="ExplorePanelController" />, and DCL.Social already depends on SceneRuntime. | ||
| /// </summary> | ||
| public class ExplorerUiActions : IExplorerUiActions | ||
| { | ||
| private readonly IMVCManager mvcManager; | ||
|
|
||
| private bool isExplorePanelOpen; | ||
|
|
||
| public ExplorerUiActions(IMVCManager mvcManager) | ||
| { | ||
| this.mvcManager = mvcManager; | ||
| mvcManager.OnViewShowed += OnViewShowed; | ||
| mvcManager.OnViewClosed += OnViewClosed; | ||
| } | ||
|
|
||
| public void Dispose() | ||
| { | ||
| mvcManager.OnViewShowed -= OnViewShowed; | ||
| mvcManager.OnViewClosed -= OnViewClosed; | ||
| } | ||
|
|
||
| public OpenExplorerUiResult OpenSection(ExploreSections section) | ||
| { | ||
| // Communities availability depends on the user identity (feature flag + wallets allowlist), | ||
| // so it cannot be gated through FeaturesRegistry like the other sections. | ||
| if (section == ExploreSections.Communities && !CommunitiesFeatureAccess.Instance.IsUserAllowedCached()) | ||
| { | ||
| ReportHub.Log(ReportCategory.RESTRICTED_ACTIONS, "OpenSection: the Communities feature is not available for this user"); | ||
| return OpenExplorerUiResult.RejectedFeatureDisabled; | ||
| } | ||
|
|
||
| if (isExplorePanelOpen) | ||
| return OpenExplorerUiResult.WasAlreadyOpen; | ||
|
|
||
| OpenSectionAsync(section).Forget(); | ||
| return OpenExplorerUiResult.Opened; | ||
| } | ||
|
|
||
| private async UniTask OpenSectionAsync(ExploreSections section) | ||
| { | ||
| try | ||
| { | ||
| await UniTask.SwitchToMainThread(); | ||
| await mvcManager.ShowAsync(ExplorePanelController.IssueCommand(new ExplorePanelParameter(section))); | ||
| } | ||
| catch (OperationCanceledException) { } | ||
| catch (Exception e) { ReportHub.LogException(e, ReportCategory.RESTRICTED_ACTIONS); } | ||
| } | ||
|
|
||
| private void OnViewShowed(IController controller) | ||
| { | ||
| if (controller is ExplorePanelController) | ||
| isExplorePanelOpen = true; | ||
| } | ||
|
|
||
| private void OnViewClosed(IController controller) | ||
| { | ||
| if (controller is ExplorePanelController) | ||
| isExplorePanelOpen = false; | ||
| } | ||
| } | ||
| } | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| { | ||
| "reference": "GUID:f56000518aba31544aa96f4739e50a64" | ||
| } |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| using DCL.UI; | ||
| using Decentraland.Kernel.Apis; | ||
| using System; | ||
|
|
||
| namespace DCL.CrdtEcsBridge.JsModulesImplementation | ||
| { | ||
| public interface IExplorerUiActions : IDisposable | ||
| { | ||
| OpenExplorerUiResult OpenSection(ExploreSections section); | ||
| } | ||
| } |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P2] Race in
isExplorePanelOpenguard. Between theisExplorePanelOpencheck (line 47) andOnViewShowedfiring, a rapid second call passes the guard and queues a duplicateShowAsync. Both returnOpenedto the scene. The MVC manager handles double-show gracefully (TC6 documents both verdicts as acceptable), so this isn't a functional bug, but setting the flag eagerly would make theWasAlreadyOpenverdict more accurate.If
ShowAsyncfails beforeOnViewShowedfires, reset the flag in the catch blocks ofOpenSectionAsync: