This repository was archived by the owner on Jun 13, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +25
-3
lines changed
Sources/ParseLiveQuery/Internal Expand file tree Collapse file tree 1 file changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -16,14 +16,36 @@ import Parse
1616extension Dictionary where Key: StringLiteralConvertible , Value: AnyObject {
1717 init ( query: PFQuery ) {
1818 self . init ( )
19-
2019 let queryState = query. valueForKey ( " state " )
2120 if let className = queryState? . valueForKey ( " parseClassName " ) {
2221 self [ " className " ] = className as? Value
2322 }
24-
2523 if let conditions: [ String : AnyObject ] = queryState? . valueForKey ( " conditions " ) as? [ String : AnyObject ] {
26- self [ " where " ] = conditions as? Value
24+ self [ " where " ] = conditions. encodedQueryDictionary as? Value
25+ }
26+ }
27+ }
28+
29+ extension Dictionary where Key: StringLiteralConvertible , Value: AnyObject {
30+ var encodedQueryDictionary : Dictionary {
31+ var encodedQueryDictionary = Dictionary ( )
32+ for (key, val) in self {
33+ if let dict = val as? [ String : AnyObject ] {
34+ encodedQueryDictionary [ key] = dict. encodedQueryDictionary as? Value
35+ } else if let geoPoint = val as? PFGeoPoint {
36+ encodedQueryDictionary [ key] = geoPoint. encodedDictionary as? Value
37+ } else {
38+ encodedQueryDictionary [ key] = val
39+ }
2740 }
41+ return encodedQueryDictionary
42+ }
43+ }
44+
45+ extension PFGeoPoint {
46+ var encodedDictionary : [ String : AnyObject ] {
47+ return [ " __type " : " GeoPoint " ,
48+ " latitude " : latitude,
49+ " longitude " : longitude]
2850 }
2951}
You can’t perform that action at this time.
0 commit comments