Skip to content
This repository has been archived by the owner on Jan 26, 2021. It is now read-only.

Commit

Permalink
Release 0.4.2
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewimm committed Jul 1, 2015
1 parent 02536a8 commit c357c6c
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 5 deletions.
49 changes: 47 additions & 2 deletions dist/parse-react.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Parse + React
* v0.4.1
* v0.4.2
*/
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.ParseReact = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
/*
Expand Down Expand Up @@ -1606,6 +1606,7 @@ module.exports = ObjectStore;
*/

var flatten = _dereq_('./flatten');
var Id = _dereq_('./Id');
var LocalSubscriptions = _dereq_('./LocalSubscriptions');
var Parse = _dereq_('./StubParse');
var SubscriptionManager = _dereq_('./SubscriptionManager');
Expand Down Expand Up @@ -1663,6 +1664,8 @@ var patches = {
return promise;
} };

var pointerMethods = ['equalTo', 'notEqualTo', 'containedIn', 'notContainedIn'];

var ParsePatches = {
applyPatches: function applyPatches() {
if (!Parse.Object.prototype.toPlainObject) {
Expand All @@ -1674,6 +1677,32 @@ var ParsePatches = {
if (!Parse.Query.prototype.observeOne) {
Parse.Query.prototype.observeOne = patches.observeOne;
}
pointerMethods.forEach(function (method) {
var old = Parse.Query.prototype[method];
Parse.Query.prototype[method] = function (attr, value) {
var patchedValue = value;
if (Array.isArray(value)) {
patchedValue = value.map(function (v) {
if (v && v.id && v.id instanceof Id) {
return {
__type: 'Pointer',
className: v.id.className,
objectId: v.id.objectId
};
}
return v;
});
} else if (value && value.id && value.id instanceof Id) {
patchedValue = {
__type: 'Pointer',
className: value.id.className,
objectId: value.id.objectId
};
}

return old.call(this, attr, patchedValue);
};
});
Parse.User.prototype.signUp = patches.signUp;
Parse.User.prototype.logIn = patches.logIn;
Parse.User.prototype._linkWith = patches._linkWith;
Expand All @@ -1683,7 +1712,7 @@ var ParsePatches = {

module.exports = ParsePatches;

},{"./LocalSubscriptions":5,"./StubParse":13,"./SubscriptionManager":15,"./flatten":18}],12:[function(_dereq_,module,exports){
},{"./Id":4,"./LocalSubscriptions":5,"./StubParse":13,"./SubscriptionManager":15,"./flatten":18}],12:[function(_dereq_,module,exports){
(function (process){
/*
* Copyright (c) 2015, Parse, LLC. All rights reserved.
Expand Down Expand Up @@ -1969,10 +1998,26 @@ function matchesKeyConstraints(object, key, constraints) {
return false;
}
break;
case '$nearSphere':
var distance = compareTo.radiansTo(object[key]);
var max = constraints.$maxDistance || Infinity;
return distance <= max;
case '$within':
var southWest = compareTo.$box[0];
var northEast = compareTo.$box[1];
if (southWest.latitude > northEast.latitude || southWest.longitude > northEast.longitude) {
// Invalid box, crosses the date line
return false;
}
return object[key].latitude > southWest.latitude && object[key].latitude < northEast.latitude && object[key].longitude > southWest.longitude && object[key].longitude < northEast.longitude;
case '$options':
// Not a query type, but a way to add options to $regex. Ignore and
// avoid the default
break;
case '$maxDistance':
// Not a query type, but a way to add a cap to $nearSphere. Ignore and
// avoid the default
break;
case '$select':
return false;
case '$dontSelect':
Expand Down
4 changes: 2 additions & 2 deletions dist/parse-react.min.js

Large diffs are not rendered by default.

29 changes: 29 additions & 0 deletions lib/ParsePatches.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
*/

var flatten = require('./flatten');
var Id = require('./Id');
var LocalSubscriptions = require('./LocalSubscriptions');
var Parse = require('./StubParse');
var SubscriptionManager = require('./SubscriptionManager');
Expand Down Expand Up @@ -84,6 +85,8 @@ var patches = {
return promise;
} };

var pointerMethods = ['equalTo', 'notEqualTo', 'containedIn', 'notContainedIn'];

var ParsePatches = {
applyPatches: function applyPatches() {
if (!Parse.Object.prototype.toPlainObject) {
Expand All @@ -95,6 +98,32 @@ var ParsePatches = {
if (!Parse.Query.prototype.observeOne) {
Parse.Query.prototype.observeOne = patches.observeOne;
}
pointerMethods.forEach(function (method) {
var old = Parse.Query.prototype[method];
Parse.Query.prototype[method] = function (attr, value) {
var patchedValue = value;
if (Array.isArray(value)) {
patchedValue = value.map(function (v) {
if (v && v.id && v.id instanceof Id) {
return {
__type: 'Pointer',
className: v.id.className,
objectId: v.id.objectId
};
}
return v;
});
} else if (value && value.id && value.id instanceof Id) {
patchedValue = {
__type: 'Pointer',
className: value.id.className,
objectId: value.id.objectId
};
}

return old.call(this, attr, patchedValue);
};
});
Parse.User.prototype.signUp = patches.signUp;
Parse.User.prototype.logIn = patches.logIn;
Parse.User.prototype._linkWith = patches._linkWith;
Expand Down
16 changes: 16 additions & 0 deletions lib/QueryTools.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,10 +282,26 @@ function matchesKeyConstraints(object, key, constraints) {
return false;
}
break;
case '$nearSphere':
var distance = compareTo.radiansTo(object[key]);
var max = constraints.$maxDistance || Infinity;
return distance <= max;
case '$within':
var southWest = compareTo.$box[0];
var northEast = compareTo.$box[1];
if (southWest.latitude > northEast.latitude || southWest.longitude > northEast.longitude) {
// Invalid box, crosses the date line
return false;
}
return object[key].latitude > southWest.latitude && object[key].latitude < northEast.latitude && object[key].longitude > southWest.longitude && object[key].longitude < northEast.longitude;
case '$options':
// Not a query type, but a way to add options to $regex. Ignore and
// avoid the default
break;
case '$maxDistance':
// Not a query type, but a way to add a cap to $nearSphere. Ignore and
// avoid the default
break;
case '$select':
return false;
case '$dontSelect':
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "parse-react",
"version": "0.4.1",
"version": "0.4.2",
"description": "Use Parse data in React applications",
"homepage": "https://github.com/ParsePlatform/ParseReact",
"keywords": [
Expand Down

0 comments on commit c357c6c

Please sign in to comment.