Skip to content

Commit

Permalink
feature/PB-33915_When-a-an-unexpected-error-is-displayed-the-try-agai…
Browse files Browse the repository at this point in the history
…n-button-...
  • Loading branch information
scadra committed Jul 22, 2024
1 parent bcfdfa6 commit 8f93106
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 13 deletions.
4 changes: 3 additions & 1 deletion passbolt/Models/Messaging/AllowedTopics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@ public class AllowedTopics
public const string BACKGROUND_SET_SECURITY_TOKEN = "passbolt.background.set-security-token";
public const string BACKGROUND_SET_LOCALE = "passbolt.background.set-locale";
public const string RENDERED_READY = "passbolt.rendered.is-ready";
public const string RENDERED_STARTED = "passbolt.rendered.started";
public const string BACKGROUND_GET_COOKIE = "passbolt.background.get-cookie";
public const string BACKGROUND_ROTATE_KEY = "passbolt.background.rotate-private-key";
public const string RENDERED_RELOAD = "passbolt.tab.reload";

private static List<string> topics = new List<string>() { BACKGROUND_READY, ERROR, BACKGROUND_DOWNLOAD_FILE, BACKGROUND_STORE_PASSPHRASE, BACKGROUND_SET_THEME, BACKGROUND_SET_SECURITY_TOKEN, BACKGROUND_SET_LOCALE, RENDERED_READY, BACKGROUND_AFTER_LOGOUT, BACKGROUND_GET_COOKIE, BACKGROUND_ROTATE_KEY };
private static List<string> topics = new List<string>() { BACKGROUND_READY, ERROR, BACKGROUND_DOWNLOAD_FILE, BACKGROUND_STORE_PASSPHRASE, BACKGROUND_SET_THEME, BACKGROUND_SET_SECURITY_TOKEN, BACKGROUND_SET_LOCALE, RENDERED_READY, BACKGROUND_AFTER_LOGOUT, BACKGROUND_GET_COOKIE, BACKGROUND_ROTATE_KEY, RENDERED_RELOAD, RENDERED_STARTED };
private static List<string> requestIds = new List<string>();
private static Dictionary<string, string> pendingRequests = new Dictionary<string, string>();

Expand Down
39 changes: 27 additions & 12 deletions passbolt/Models/Messaging/Webviews/RenderedTopic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ namespace passbolt.Models.Messaging
{
public class RenderedTopic : WebviewTopic
{
private List<string> topics = new List<string>();
private List<string> topics = new List<string>();
private bool isRefreshed = false;

public RenderedTopic(WebView2 background, WebView2 rendered, LocalFolderService localFolderService, RenderedWebviewService renderedWebviewService) : base(background, rendered, localFolderService, renderedWebviewService) {
topics.AddRange(ListHelper.GetClassContantsToList(typeof(AccountRecoveryTopics)));
Expand All @@ -41,7 +42,7 @@ public RenderedTopic(WebView2 background, WebView2 rendered, LocalFolderService
topics.AddRange(ListHelper.GetClassContantsToList(typeof(LocaleTopics)));
topics.AddRange(ListHelper.GetClassContantsToList(typeof(KeyringTopics)));
topics.AddRange(ListHelper.GetClassContantsToList(typeof(MfaTopics)));
topics.AddRange(ListHelper.GetClassContantsToList(typeof(PownedPasswordTopics)));
topics.AddRange(ListHelper.GetClassContantsToList(typeof(PownedPasswordTopics)));
topics.AddRange(ListHelper.GetClassContantsToList(typeof(PasswordExpiryTopics)));
topics.AddRange(ListHelper.GetClassContantsToList(typeof(PasswordGeneratorTopics)));
topics.AddRange(ListHelper.GetClassContantsToList(typeof(PasswordPoliciesTopics)));
Expand All @@ -51,11 +52,13 @@ public RenderedTopic(WebView2 background, WebView2 rendered, LocalFolderService
topics.AddRange(ListHelper.GetClassContantsToList(typeof(SecretTopics)));
topics.AddRange(ListHelper.GetClassContantsToList(typeof(SettingTopics)));
topics.AddRange(ListHelper.GetClassContantsToList(typeof(ShareTopics)));
topics.AddRange(ListHelper.GetClassContantsToList(typeof(TagTopics)));
topics.AddRange(ListHelper.GetClassContantsToList(typeof(TagTopics)));
topics.AddRange(ListHelper.GetClassContantsToList(typeof(ThemeTopics)));
topics.AddRange(ListHelper.GetClassContantsToList(typeof(UserTopics)));
topics.AddRange(ListHelper.GetClassContantsToList(typeof(UserTopics)));
topics.AddRange(ListHelper.GetClassContantsToList(typeof(UserTopics)));
topics.Add(AllowedTopics.RENDERED_READY);
topics.Add(AllowedTopics.RENDERED_RELOAD);
topics.Add(AllowedTopics.RENDERED_STARTED);
}


Expand All @@ -69,7 +72,7 @@ public override async void ProceedMessage(IPC ipc)
{
new UnauthorizedTopicException("Rendered webview");
return;
}
}
else if (CanOpenToBrowser(ipc))
{
var url = (string)ipc.message;
Expand All @@ -78,14 +81,26 @@ public override async void ProceedMessage(IPC ipc)
else if (topics.Contains(ipc.topic))
{
AllowedTopics.AddRequestId(ipc.requestId);
}

if (ipc.topic == RbacTopics.FIND_ME)
{
//We intercept the requestId and save it to map the response
AllowedTopics.AddPendingRequest(ipc.requestId, RbacTopics.FIND_ME);
}

if(ipc.topic == AllowedTopics.RENDERED_STARTED)
{
if(this.isRefreshed)
{
rendered.CoreWebView2.PostWebMessageAsJson(SerializationHelper.SerializeToJson(new IPC(AllowedTopics.BACKGROUND_READY)));
this.isRefreshed = false;
}
}
if (ipc.topic == RbacTopics.FIND_ME)
{
//We intercept the requestId and save it to map the response
AllowedTopics.AddPendingRequest(ipc.requestId, RbacTopics.FIND_ME);
}
if(ipc.topic == AllowedTopics.RENDERED_RELOAD)
{
rendered.CoreWebView2.Reload();
this.isRefreshed = true;
return;
}

background.CoreWebView2.PostWebMessageAsJson(SerializationHelper.SerializeToJson(ipc));
}
Expand Down
1 change: 1 addition & 0 deletions passbolt/Webviews/Rendered/src/AppAuthentication.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class AppAuthentication extends Component {
*/
async listen() {
await localStorage.clear();
this.props.port.emit("passbolt.rendered.started");
this.props.port.on("passbolt.background.is-ready", this.handleBackgroundReady);
}

Expand Down
1 change: 1 addition & 0 deletions passbolt/Webviews/Rendered/src/AppImport.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class AppImport extends Component {
}

async componentDidMount() {
this.props.port.emit("passbolt.rendered.started");
await localStorage.clear();
}

Expand Down

0 comments on commit 8f93106

Please sign in to comment.