-
1. Re: Publish collection name rejection
areohbee Apr 23, 2012 9:24 PM (in response to optimator999)I'm outside my area of experience. Although the following would certainly be critical:
* renamePublishedCollection
* reparentPublishedCollection
I can't see any function for initial creation/naming either though. Hmmmmm..... another hole?
I suppose you could create an asynchronous task to poll the server for existing names, and if the results are not in yet, return false, "hang on..." from validatePublishedCollectionName, else compare entered value to existing names...
Sorry if I've not been much help,
Rob
-
2. Re: Publish collection name rejection
optimator999 Apr 24, 2012 5:26 AM (in response to areohbee)Hey Rob! Thanks for the reply. I'm not sure about this, but here's how I solved it: From within updateCollectionSettings when I determine there is a name collision I use the following code to remove the collection:
local catalog = import "LrApplication".activeCatalog()
LrTasks.startAsyncTask( function()
catalog:withWriteAccessDo( "Remove invalid collection", function()
info.publishedCollection:delete()
end)
end)
It works. Not sure it's the best solution, but I'm running with it for now.
-
3. Re: Publish collection name rejection
areohbee Apr 24, 2012 3:28 PM (in response to optimator999)It seems my previously proposed solution would be better - so the user sees "bad name", instead of having their collection disappear.
But I suppose as long as you prompt the user so it doesn't just seem flaky...
-
4. Re: Publish collection name rejection
Don McKee Apr 24, 2012 5:00 PM (in response to optimator999)Like Rob said, it looks like you're expected to do the server-side verification in
renamePublishedCollection( publishSettings, info )
reparentPublishedCollection( publishSettings, info )
The doc states, "If your plug-in is unable to update the remote service for any reason, you should throw a Lua error from this function; this causes Lightroom to revert the change."
-Don
-
5. Re: Publish collection name rejection
optimator999 Apr 25, 2012 2:24 AM (in response to Don McKee)I tried to hook into renamePublishedCollection and reparentPublishedCollection but it appears that those methods don't fire when the Published Collection is created. I indeed got them to fire when I'm renaming or reparenting aPublished Collection, but I can't find any other way to prevent the creation of a Published Collection other than in updateCollectionSettings.
-
6. Re: Publish collection name rejection
areohbee Apr 25, 2012 3:36 AM (in response to optimator999)1 person found this helpfulWhy not:
function PS:validatePublishedCollectionName( name )
if nameInfoLoaded then
if duplicateName( name ) then
return false, "duplicate name"
else
return true
end
else
return false, "Contacting server to check collection name..."
end
end
Then, in "start dialog" method, create the task that loads name info from server.
in "end dialog" method, kill the task, if it doesn't die by itself...
Although a little rough for you, 'twould be smooth as silk for your users.
?
-
7. Re: Publish collection name rejection
optimator999 Apr 25, 2012 4:55 AM (in response to areohbee)Rob, yes! That's a great way to go. Although, I'll still have to implement the other code (collection appears and then dissapears) because, while I can obtain a list of collections from the service for the user and ensure the the uniqueness among the user's collection, I still must ensure the unqiueness of the name across ALL service users - and then only way to do that is to contact the service with the proposed name.
-
8. Re: Publish collection name rejection
areohbee Apr 25, 2012 5:14 AM (in response to optimator999)1 person found this helpfulThe only trick is keeping multiple instances of the name checking task from running if user is yanking the plugin manager around and reloading the plugin...
Lightroom does NOT stop tasks from running automatically even if you reload the plugin.
So, make sure you have a shutdown module: LrShutdownPlugin = ... defined in Info.lua - have it set a global shutdown flag that you check in your task.
I mean, this only makes sense if the task is going to have loops with sleeps and such.... - if it's a one shot and it's done, then there is no opportunity to check the shutdown flag.
Rob