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

Commit c357c6c

Browse files
committed
Release 0.4.2
1 parent 02536a8 commit c357c6c

File tree

5 files changed

+95
-5
lines changed

5 files changed

+95
-5
lines changed

dist/parse-react.js

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Parse + React
3-
* v0.4.1
3+
* v0.4.2
44
*/
55
(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){
66
/*
@@ -1606,6 +1606,7 @@ module.exports = ObjectStore;
16061606
*/
16071607

16081608
var flatten = _dereq_('./flatten');
1609+
var Id = _dereq_('./Id');
16091610
var LocalSubscriptions = _dereq_('./LocalSubscriptions');
16101611
var Parse = _dereq_('./StubParse');
16111612
var SubscriptionManager = _dereq_('./SubscriptionManager');
@@ -1663,6 +1664,8 @@ var patches = {
16631664
return promise;
16641665
} };
16651666

1667+
var pointerMethods = ['equalTo', 'notEqualTo', 'containedIn', 'notContainedIn'];
1668+
16661669
var ParsePatches = {
16671670
applyPatches: function applyPatches() {
16681671
if (!Parse.Object.prototype.toPlainObject) {
@@ -1674,6 +1677,32 @@ var ParsePatches = {
16741677
if (!Parse.Query.prototype.observeOne) {
16751678
Parse.Query.prototype.observeOne = patches.observeOne;
16761679
}
1680+
pointerMethods.forEach(function (method) {
1681+
var old = Parse.Query.prototype[method];
1682+
Parse.Query.prototype[method] = function (attr, value) {
1683+
var patchedValue = value;
1684+
if (Array.isArray(value)) {
1685+
patchedValue = value.map(function (v) {
1686+
if (v && v.id && v.id instanceof Id) {
1687+
return {
1688+
__type: 'Pointer',
1689+
className: v.id.className,
1690+
objectId: v.id.objectId
1691+
};
1692+
}
1693+
return v;
1694+
});
1695+
} else if (value && value.id && value.id instanceof Id) {
1696+
patchedValue = {
1697+
__type: 'Pointer',
1698+
className: value.id.className,
1699+
objectId: value.id.objectId
1700+
};
1701+
}
1702+
1703+
return old.call(this, attr, patchedValue);
1704+
};
1705+
});
16771706
Parse.User.prototype.signUp = patches.signUp;
16781707
Parse.User.prototype.logIn = patches.logIn;
16791708
Parse.User.prototype._linkWith = patches._linkWith;
@@ -1683,7 +1712,7 @@ var ParsePatches = {
16831712

16841713
module.exports = ParsePatches;
16851714

1686-
},{"./LocalSubscriptions":5,"./StubParse":13,"./SubscriptionManager":15,"./flatten":18}],12:[function(_dereq_,module,exports){
1715+
},{"./Id":4,"./LocalSubscriptions":5,"./StubParse":13,"./SubscriptionManager":15,"./flatten":18}],12:[function(_dereq_,module,exports){
16871716
(function (process){
16881717
/*
16891718
* Copyright (c) 2015, Parse, LLC. All rights reserved.
@@ -1969,10 +1998,26 @@ function matchesKeyConstraints(object, key, constraints) {
19691998
return false;
19701999
}
19712000
break;
2001+
case '$nearSphere':
2002+
var distance = compareTo.radiansTo(object[key]);
2003+
var max = constraints.$maxDistance || Infinity;
2004+
return distance <= max;
2005+
case '$within':
2006+
var southWest = compareTo.$box[0];
2007+
var northEast = compareTo.$box[1];
2008+
if (southWest.latitude > northEast.latitude || southWest.longitude > northEast.longitude) {
2009+
// Invalid box, crosses the date line
2010+
return false;
2011+
}
2012+
return object[key].latitude > southWest.latitude && object[key].latitude < northEast.latitude && object[key].longitude > southWest.longitude && object[key].longitude < northEast.longitude;
19722013
case '$options':
19732014
// Not a query type, but a way to add options to $regex. Ignore and
19742015
// avoid the default
19752016
break;
2017+
case '$maxDistance':
2018+
// Not a query type, but a way to add a cap to $nearSphere. Ignore and
2019+
// avoid the default
2020+
break;
19762021
case '$select':
19772022
return false;
19782023
case '$dontSelect':

dist/parse-react.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/ParsePatches.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
*/
2828

2929
var flatten = require('./flatten');
30+
var Id = require('./Id');
3031
var LocalSubscriptions = require('./LocalSubscriptions');
3132
var Parse = require('./StubParse');
3233
var SubscriptionManager = require('./SubscriptionManager');
@@ -84,6 +85,8 @@ var patches = {
8485
return promise;
8586
} };
8687

88+
var pointerMethods = ['equalTo', 'notEqualTo', 'containedIn', 'notContainedIn'];
89+
8790
var ParsePatches = {
8891
applyPatches: function applyPatches() {
8992
if (!Parse.Object.prototype.toPlainObject) {
@@ -95,6 +98,32 @@ var ParsePatches = {
9598
if (!Parse.Query.prototype.observeOne) {
9699
Parse.Query.prototype.observeOne = patches.observeOne;
97100
}
101+
pointerMethods.forEach(function (method) {
102+
var old = Parse.Query.prototype[method];
103+
Parse.Query.prototype[method] = function (attr, value) {
104+
var patchedValue = value;
105+
if (Array.isArray(value)) {
106+
patchedValue = value.map(function (v) {
107+
if (v && v.id && v.id instanceof Id) {
108+
return {
109+
__type: 'Pointer',
110+
className: v.id.className,
111+
objectId: v.id.objectId
112+
};
113+
}
114+
return v;
115+
});
116+
} else if (value && value.id && value.id instanceof Id) {
117+
patchedValue = {
118+
__type: 'Pointer',
119+
className: value.id.className,
120+
objectId: value.id.objectId
121+
};
122+
}
123+
124+
return old.call(this, attr, patchedValue);
125+
};
126+
});
98127
Parse.User.prototype.signUp = patches.signUp;
99128
Parse.User.prototype.logIn = patches.logIn;
100129
Parse.User.prototype._linkWith = patches._linkWith;

lib/QueryTools.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,10 +282,26 @@ function matchesKeyConstraints(object, key, constraints) {
282282
return false;
283283
}
284284
break;
285+
case '$nearSphere':
286+
var distance = compareTo.radiansTo(object[key]);
287+
var max = constraints.$maxDistance || Infinity;
288+
return distance <= max;
289+
case '$within':
290+
var southWest = compareTo.$box[0];
291+
var northEast = compareTo.$box[1];
292+
if (southWest.latitude > northEast.latitude || southWest.longitude > northEast.longitude) {
293+
// Invalid box, crosses the date line
294+
return false;
295+
}
296+
return object[key].latitude > southWest.latitude && object[key].latitude < northEast.latitude && object[key].longitude > southWest.longitude && object[key].longitude < northEast.longitude;
285297
case '$options':
286298
// Not a query type, but a way to add options to $regex. Ignore and
287299
// avoid the default
288300
break;
301+
case '$maxDistance':
302+
// Not a query type, but a way to add a cap to $nearSphere. Ignore and
303+
// avoid the default
304+
break;
289305
case '$select':
290306
return false;
291307
case '$dontSelect':

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "parse-react",
3-
"version": "0.4.1",
3+
"version": "0.4.2",
44
"description": "Use Parse data in React applications",
55
"homepage": "https://github.com/ParsePlatform/ParseReact",
66
"keywords": [

0 commit comments

Comments
 (0)