Skip to content

Commit d230675

Browse files
committed
🐛 bug fix
1 parent 5b51eeb commit d230675

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/lib/messages/created.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Object.entries = function (obj) { //eslint-disable-line no-extend-native
1616
function convertDate(e){return format(e.toDate(), "yyyyMMdd")}
1717
function convertTime(e){return format(e.toDate(), "HHmm")}
1818
function stringifyCatch(c){return Object.entries(c).map(([k, v]) => [k, v].join(" ")).join(" ")}
19+
function prependSign(number){return `${Math.sign(number) > 0 ? "+" : ""}${number}` }
1920

2021
export default functions.firestore.document("users/{userId}/messages/{messageId}")
2122
.onCreate(async (snap, {params: {userId, messageId}, eventId}) => {
@@ -63,7 +64,7 @@ export default functions.firestore.document("users/{userId}/messages/{messageId}
6364
break
6465

6566
case "DCA": {
66-
const {AD, QI, AC, TS, ZO, GE, GP, DU, CA, ME, GS, fishingStart, startFishingSpot, endFishingSpot} = m
67+
const {AD, QI, AC, TS, ZO, GE, GP, DU, ME, GS, fishingStart, startFishingSpot, endFishingSpot} = m
6768
message = {
6869
...message,
6970
XR: boat.XR,
@@ -73,16 +74,16 @@ export default functions.firestore.document("users/{userId}/messages/{messageId}
7374
BD: convertDate(fishingStart),
7475
BT: convertTime(fishingStart),
7576
ZO,
76-
LT: `+${startFishingSpot.latitude.toString()}`, //LT/+63.400
77-
LG: `+${startFishingSpot.longitude.toString()}`, //LG/+010.400
77+
LT: prependSign(startFishingSpot.latitude), //LT/+63.400
78+
LG: prependSign(startFishingSpot.longitude), //LG/+010.400
7879
GE,
7980
GP,
80-
XT: `+${endFishingSpot.latitude.toString()}`, //Same as LT
81-
XG: `+${endFishingSpot.longitude.toString()}`, //Same as LG
81+
XG: prependSign(endFishingSpot.longitude), //Same as LG
82+
XT: prependSign(endFishingSpot.latitude), //Same as LT
8283
DU,
83-
CA: stringifyCatch(CA),
8484
GS
8585
}
86+
if(m.CA) m.CA = stringifyCatch(m.CA)
8687
if(["OTB", "OTM", "SSC", "GEN", "TBS"].includes(GE)){
8788
message = {...message, ME}
8889
}

0 commit comments

Comments
 (0)