fix: Move upgrade button to top of editor (#2687)
This commit is contained in:
@@ -277,7 +277,15 @@ export class CardElementManager {
|
||||
const toggleDiagnostics = (): void => {
|
||||
const viewManager = this._api.getViewManager();
|
||||
if (viewManager.getView()?.view === 'diagnostics') {
|
||||
viewManager.setViewDefault();
|
||||
if (viewManager.canSetViewDefault()) {
|
||||
// Clear the view when no default one can be built, to return the card
|
||||
// to what it showed before diagnostics (e.g. an initialization error).
|
||||
viewManager.setViewDefault();
|
||||
} else {
|
||||
// Won't be a blank card: will show the issue that stopped camera
|
||||
// initialization, or the loading indicator if that is still running.
|
||||
viewManager.reset();
|
||||
}
|
||||
} else {
|
||||
viewManager.setViewByParameters({
|
||||
params: { view: 'diagnostics' },
|
||||
|
||||
@@ -74,6 +74,7 @@ export interface ViewManagerInterface {
|
||||
hasView(): boolean;
|
||||
reset(): void;
|
||||
|
||||
canSetViewDefault(): boolean;
|
||||
setViewDefault(options?: ViewFactoryOptions): void;
|
||||
setViewByParameters(options?: ViewFactoryOptions): void;
|
||||
|
||||
|
||||
@@ -62,6 +62,12 @@ export class ViewManager implements ViewManagerInterface {
|
||||
}
|
||||
}
|
||||
|
||||
// Whether a default view will be built at all. A view-creation request made
|
||||
// while this is false is silently ignored.
|
||||
public canSetViewDefault(): boolean {
|
||||
return this._isAllowedToProposeView();
|
||||
}
|
||||
|
||||
setViewDefault = (options?: ViewFactoryOptions): void =>
|
||||
this._setViewGeneric(
|
||||
this._viewFactory.getViewDefault.bind(this._viewFactory),
|
||||
@@ -116,7 +122,11 @@ export class ViewManager implements ViewManagerInterface {
|
||||
viewFactoryFunc: (options?: ViewFactoryOptions) => View | null,
|
||||
options?: ViewFactoryOptions,
|
||||
): void {
|
||||
if (!this._isAllowedToProposeView()) {
|
||||
const isDiagnosticsRequest = options?.params?.view === 'diagnostics';
|
||||
|
||||
// Diagnostics requires no camera, and is what the user is asked to open
|
||||
// when the card is broken.
|
||||
if (!isDiagnosticsRequest && !this._isAllowedToProposeView()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -131,8 +141,13 @@ export class ViewManager implements ViewManagerInterface {
|
||||
// does not linger invisibly and re-pop on the next evaluation cycle,
|
||||
// and that a stale media_query failure from an abandoned gallery /
|
||||
// viewer doesn't follow the user into an unrelated view.
|
||||
this._api.getIssueManager().reset('view_incompatible');
|
||||
this._api.getIssueManager().reset('media_query');
|
||||
//
|
||||
// Diagnostics is the exception: those issues are part of what its report
|
||||
// shows, so opening it must not erase them.
|
||||
if (!isDiagnosticsRequest) {
|
||||
this._api.getIssueManager().reset('view_incompatible');
|
||||
this._api.getIssueManager().reset('media_query');
|
||||
}
|
||||
} catch (e) {
|
||||
if (!this._view) {
|
||||
view = this._getFailSafeView(viewFactoryFunc);
|
||||
|
||||
Reference in New Issue
Block a user