Skip to content

Commit

Permalink
Merge pull request #8856 from brave/issue-15935
Browse files Browse the repository at this point in the history
Do not show ipfs items if the ipfs daemon is not launched
  • Loading branch information
spylogsster authored May 20, 2021
2 parents 3f14bec + 0810e5a commit 714505e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion browser/ui/toolbar/brave_app_menu_model.cc
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ class SidebarMenuModel : public ui::SimpleMenuModel,
// The length of the key is divided to this constant and the last part is taken.
int kKeyTrimRate = 5;

bool IsIpfsServiceLaunched(content::BrowserContext* browser_context) {
auto* service = ipfs::IpfsServiceFactory::GetForContext(browser_context);
return service && service->IsDaemonLaunched();
}

ipfs::IpnsKeysManager* GetIpnsKeysManager(
content::BrowserContext* browser_context) {
DCHECK(browser_context);
Expand Down Expand Up @@ -290,11 +295,13 @@ bool BraveAppMenuModel::IsCommandIdEnabled(int id) const {
}
return true;
}

switch (id) {
case IDC_APP_MENU_IPFS_IMPORT_LOCAL_FILE:
case IDC_APP_MENU_IPFS:
case IDC_APP_MENU_IPFS_IMPORT_LOCAL_FOLDER:
return ipfs::IsIpfsMenuEnabled(browser_context);
return ipfs::IsIpfsMenuEnabled(browser_context) &&
IsIpfsServiceLaunched(browser_context);
}
#endif
return AppMenuModel::IsCommandIdEnabled(id);
Expand Down

0 comments on commit 714505e

Please sign in to comment.