Skip to content
This repository has been archived by the owner on Dec 14, 2023. It is now read-only.

"getFiles" getting triggered more than once on iOS #35

Open
dexter2019 opened this issue Oct 7, 2018 · 2 comments
Open

"getFiles" getting triggered more than once on iOS #35

dexter2019 opened this issue Oct 7, 2018 · 2 comments

Comments

@dexter2019
Copy link

dexter2019 commented Oct 7, 2018

Describe the bug
On iOS the "getFiles" is getting triggered more than once.

To Reproduce
Just add Nativescript mediafilepicker plugin in a sample app and try to log something on "getFiles" event. Then try picking some media/image from the Photo Library.

Expected behavior
The event should get triggered once. As of now if you choose 2-3 images and clikc on "Done" the event is getting triggered more than once.

NativeScript Info(please run tns info):
Component nativescript has 4.2.4 version and is up to date.
✔ Component tns-core-modules has 4.3.0-2018-09-07-01 version and is up to date.
✔ Component tns-android has 4.2.0 version and is up to date.
✔ Component tns-ios has 4.3.0-2018-09-05-01 version and is up to date.

Sample Code(please provide minimum code to reproduce problem):

var observableModule = require("tns-core-modules/data/observable");
var mPicker = require("nativescript-mediafilepicker");
var mediafilepicker = new mPicker.Mediafilepicker();

function HomeViewModel() {
var viewModel = observableModule.fromObject({
onButtonTap: function () {
//console.log("Button was pressed");

  let options = {
    android: {
      isNeedCamera: true,
      maxNumberFiles: 4,
      isNeedFolderList: true
    }, ios: {
      isCaptureMood: false,
      maxNumberFiles: 4
    }
  };

  mediafilepicker.openImagePicker(options);
  mediafilepicker.on("getFiles", function (res) {
    let results = res.object.get('results');
    console.log("called");

    


  });

},

});

return viewModel;
}

module.exports = HomeViewModel;

Additional context
Add any other context about the problem here.

@dexter2019
Copy link
Author

dexter2019 commented Oct 7, 2018

Infact every time you open the Photo Library by tapping the "button" and press "cancel" from the photos folder, the cancel event is triggering more than once for each press on "cancel". first time you press on cancel the "cancel" event will get triggered once. Second time you press cancel, "cancel" event will get triggered twice and so on..

see the log below:

CONSOLE LOG file:///app/textEditor/text-editor-model.js:346:28: Picker cancel
CONSOLE LOG file:///app/textEditor/text-editor-model.js:346:28: Picker cancel
CONSOLE LOG file:///app/textEditor/text-editor-model.js:346:28: Picker cancel
CONSOLE LOG file:///app/textEditor/text-editor-model.js:346:28: Picker cancel
CONSOLE LOG file:///app/textEditor/text-editor-model.js:346:28: Picker cancel
CONSOLE LOG file:///app/textEditor/text-editor-model.js:346:28: Picker cancel
CONSOLE LOG file:///app/textEditor/text-editor-model.js:346:28: Picker cancel
CONSOLE LOG file:///app/textEditor/text-editor-model.js:346:28: Picker cancel
CONSOLE LOG file:///app/textEditor/text-editor-model.js:346:28: Picker cancel
CONSOLE LOG file:///app/textEditor/text-editor-model.js:346:28: Picker cancel
CONSOLE LOG file:///app/textEditor/text-editor-model.js:346:28: Picker cancel
CONSOLE LOG file:///app/textEditor/text-editor-model.js:346:28: Picker cancel
CONSOLE LOG file:///app/textEditor/text-editor-model.js:346:28: Picker cancel
CONSOLE LOG file:///app/textEditor/text-editor-model.js:346:28: Picker cancel
CONSOLE LOG file:///app/textEditor/text-editor-model.js:346:28: Picker cancel
CONSOLE LOG file:///app/textEditor/text-editor-model.js:346:28: Picker cancel
CONSOLE LOG file:///app/textEditor/text-editor-model.js:346:28: Picker cancel
CONSOLE LOG file:///app/textEditor/text-editor-model.js:346:28: Picker cancel
CONSOLE LOG file:///app/textEditor/text-editor-model.js:346:28: Picker cancel
CONSOLE LOG file:///app/textEditor/text-editor-model.js:346:28: Picker cancel
CONSOLE LOG file:///app/textEditor/text-editor-model.js:346:28: Picker cancel

@jibon57
Copy link
Owner

jibon57 commented Oct 8, 2018

@dexter2019 you will need to call new mPicker.Mediafilepicker() inside click method. Something like this

var observableModule = require("tns-core-modules/data/observable");
var mPicker = require("nativescript-mediafilepicker");
var mediafilepicker;

function HomeViewModel() {
var viewModel = observableModule.fromObject({
onButtonTap: function () {
//console.log("Button was pressed");

  let options = {
    android: {
      isNeedCamera: true,
      maxNumberFiles: 4,
      isNeedFolderList: true
    }, ios: {
      isCaptureMood: false,
      maxNumberFiles: 4
    }
  };
  mediafilepicker = new mPicker.Mediafilepicker();

  mediafilepicker.openImagePicker(options);
  mediafilepicker.on("getFiles", function (res) {
    let results = res.object.get('results');
    console.log("called");

    


  });

},

});

return viewModel;
}

module.exports = HomeViewModel;

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants