Skip to content

Commit

Permalink
Fix issue with retrieving MediatorBookmarks name wich contains white …
Browse files Browse the repository at this point in the history
…spaces

- Prevent from executing roles Command multiple times (reference #68)
  • Loading branch information
piotrzarzycki21 committed Nov 25, 2024
1 parent 637bc2d commit de58b94
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ package controller
var leftMenuNavModel:LeftMenuNavigationModel = mainMediator.view["model"] as LeftMenuNavigationModel;
var bookmarksNav:Object = mainMediator.view.viewBookmarksNavigation;
var bookmarksList:ArrayList = new ArrayList();
var appWhiteSpaceRegExp:RegExp = new RegExp(/\s+/gi);

var groups:Array = [];
for each (var bookmark:BookmarkVO in bookmarks)
Expand Down Expand Up @@ -72,7 +71,7 @@ package controller
groups.forEach(function(group:Object, index:int, arr:Array):void{

var menuItem:NavigationLinkVO = new NavigationLinkVO(group.name, "", "mdi mdi-apps mdi-24px",
MediatorBookmarks.NAME + group.name.replace(appWhiteSpaceRegExp, ""), group);
MediatorBookmarks.getMediatorName(group.name), group);
bookmarksList.addItem(menuItem);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package controller.roles.executeRoles
{
var bookmarksProxy:ProxyBookmarks = facade.retrieveProxy(ProxyBookmarks.NAME) as ProxyBookmarks;

var bookmarksMediatorName:String = MediatorBookmarks.NAME + bookmarksProxy.selectedGroup;
var bookmarksMediatorName:String = MediatorBookmarks.getMediatorName(bookmarksProxy.selectedGroup);
if (facade.hasMediator(bookmarksMediatorName))
{
var bookmarksMediator:MediatorBookmarks = facade.retrieveMediator(bookmarksMediatorName) as MediatorBookmarks;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ package mediator.bookmarks
super(mediatorName, component);
}

public static function getMediatorName(bookmarkGroup:String):String
{
var appWhiteSpaceRegExp:RegExp = new RegExp(/\s+/gi);

return MediatorBookmarks.NAME + bookmarkGroup.replace(appWhiteSpaceRegExp, "");
}

override public function onRegister():void
{
super.onRegister();
Expand All @@ -57,8 +64,6 @@ package mediator.bookmarks
this.view.currentState = this.bookmarksProxy.selectedGroup == "Browse My Server" ?
BROWSE_MY_SERVER_VIEW_STATE : BOOKMARKS_VIEW_STATE;
}

sendNotification(ApplicationConstants.COMMAND_EXECUTE_BOOKMARKS_ROLES);
}

override public function onRemove():void
Expand Down Expand Up @@ -137,8 +142,6 @@ package mediator.bookmarks

this.cleanUpBookmarksList();
this.updateListOfBookmarks();

sendNotification(ApplicationConstants.COMMAND_EXECUTE_ROLES);
}
else if (view["currentState"] == BROWSE_MY_SERVER_VIEW_STATE)
{
Expand All @@ -148,6 +151,8 @@ package mediator.bookmarks
facade.registerMediator(new MediatorBrowseMyServer(view.browseMyServerView));
view.title = "Browse My Server";
}

sendNotification(ApplicationConstants.COMMAND_EXECUTE_ROLES);
}

private function updateListOfBookmarks():void
Expand Down

0 comments on commit de58b94

Please sign in to comment.