Combu.UserFile.Upda...
 
Notifications
Clear all

Combu.UserFile.Update to Page 2

6 Posts
2 Users
0 Reactions
936 Views
(@tsuyoiraion)
Posts: 11
Active Member
Topic starter
 

 I'm currently working on an app that has multiple galleries, how can I save to separate pages? I want to load from the page like below: 

//loading page 2, 5 files max

UserFile.Load (CombuManager.localUser.id, false, 2, 5, (UserFile[] files, int recordCount, int pageCount, string error) => {

 

Thoughts?

 
Posted : 04/10/2017 12:53 am
(@skaredcreations)
Posts: 805
Prominent Member Admin
 

You're right, there isn't currently a way to understand in what App is registered a User. For now you could use a simple trick by using a key in customData to store your App details (we will expand the User class to support per App customData and registration in a future update).

For example:

// to encode
 var appData = new Hashtable();
 appData.Add("coins", "1234");
 user.customData["myapp"] = appData.toJson();
 
 // to decode
 if (user.customData.ContainsKey("myapp") && user.customData["myapp"] != null)
 {
     var appData = user.customData["myapp"].ToString().hashtableFromJson();
     if (appData != null)
     {
         var coins = appData["coins"].ToString();
     }
 }

And for Load you could for example try the long-parameters overload that accepts also an array of SearchCustomData where you will pass with a SearchCustomData object with key "myapp" and op "Disequals" and an empty string as value.

FRANCESCO CROCETTI @ SKARED CREATIONS

 
Posted : 04/10/2017 2:29 am
(@tsuyoiraion)
Posts: 11
Active Member
Topic starter
 

Ok *over my head* lol

So your saying there is no way to save to page 2? what are the separate pages for then?

Do I need to save certain images as a specific string to call back into my for instance, 2nd gallery?

 

 
Posted : 04/10/2017 2:53 am
(@skaredcreations)
Posts: 805
Prominent Member Admin
 

Ops.. I probably misunderstood what you were asking and I confused your code UserFile.Load with User.Load, sorry my bad... but still I don't understand what you mean with "save to page 2", the code you posted should load the 5 records of the 2nd page (the pagination of records is something necessary if you think that the table could have many records into it and you don't want to load thousands of records at once for performance reason).

About how to set the "gallery" to which the UserFile belongs to, you could use the UserFile's customData (it's a Hashtable just like the customData of User class), though there isn't currently the possibility to filter by customData in Load (may be we will add this feature like we did in User.Load to filter out customData).

FRANCESCO CROCETTI @ SKARED CREATIONS

 
Posted : 04/10/2017 12:05 pm
(@tsuyoiraion)
Posts: 11
Active Member
Topic starter
 

Oh I see so the files all save into one location and the pages aren't separate file locations, gotcha.

 

Was thinking I could save to page 2 and then load from there, as you can see in the example image i linked in my last post, i have two separate galleries I want to load images into and each needs to display different images based on the value i set. So gallery one is avatar and gallery two is my gallery.

 

I need to be able to upload to and load from both galleries, displaying the proper images when refreshed after upload.

 

For the avatar image displayed on the profile screen I was able to search through the collected gallery images using file.name
(saved custom data string to playerprefs for this instance)

 

foreach (var file in files) {

if(file.name == PlayerPrefs.GetString("ProCustomDataActive")){

profilePic.GetComponent<FilePathUrlInfo>().LoadFilePathUrl(file);

 

I could do it this way but then i'd have to load every file instead of a max of 5 and then search through them frown

 
Posted : 04/10/2017 6:30 pm
(@skaredcreations)
Posts: 805
Prominent Member Admin
 

Yep as I said it will be implemented a system to search in customData of UserFile just we already do into User.Load, this will be the final code:

// Assign a gallery to UserFile
file.customData["gallery"] = "gallery1";

// Filter UserFiles by customData
UserFile.Load(CombuManager.localUser.id, false, new SearchCustomData[]
{
    new SearchCustomData("gallery", eSearchOperator.Equals, "gallery1")
}, 1, int.MaxValue, (UserFile[] files, int recordCount, int pageCount, string error) => {
    // ...
});

 

For now until we will release this update you could work around (for testing purpose) by requesting the full list of all UserFiles belonging to any gallery (page=1, limit=int.MaxValue) and then filter it out in a cycle to add it to one list or the other.

FRANCESCO CROCETTI @ SKARED CREATIONS

 
Posted : 04/10/2017 8:45 pm
Share: