diff --git a/imports/api/collections/Players.js b/imports/api/collections/Players.js index e429750..4c668bd 100644 --- a/imports/api/collections/Players.js +++ b/imports/api/collections/Players.js @@ -2,7 +2,12 @@ import { Mongo } from "meteor/mongo"; let Players = new Mongo.Collection("players"); -let collection = Players.rawCollection(); -collection.ensureIndex({ name: 1, roomId: 1, }, { unique: true }); +// TODO: there's probably a better way to do this +try { + let collection = Players.rawCollection(); + collection.ensureIndex({ name: 1, roomId: 1, }, { unique: true }); +} catch (e) { + +} export default Players; diff --git a/imports/api/collections/Rooms.js b/imports/api/collections/Rooms.js index b64830c..08e1a6e 100644 --- a/imports/api/collections/Rooms.js +++ b/imports/api/collections/Rooms.js @@ -2,7 +2,11 @@ import { Mongo } from "meteor/mongo"; let Rooms = new Mongo.Collection("rooms"); -let collection = Rooms.rawCollection(); -collection.ensureIndex({ joinCode: 1 }, { unique: true }); +try { + let collection = Rooms.rawCollection(); + collection.ensureIndex({ joinCode: 1 }, { unique: true }); +} catch (e) { + +} export default Rooms; diff --git a/imports/api/methods/joinGame.js b/imports/api/methods/joinGame.js index 46f3fe2..f498b13 100644 --- a/imports/api/methods/joinGame.js +++ b/imports/api/methods/joinGame.js @@ -10,7 +10,7 @@ Meteor.methods({ check(name, String); name = name.trim(); - let room = Rooms.findOne({ joinCode: code }); + let room = Rooms.findOne({ joinCode: code.toLowerCase() }); if (room === undefined) { throw new Meteor.Error("room-not-found"); } diff --git a/imports/api/methods/newGame.js b/imports/api/methods/newGame.js index e030acc..378ee8f 100644 --- a/imports/api/methods/newGame.js +++ b/imports/api/methods/newGame.js @@ -16,7 +16,7 @@ Meteor.methods({ let remainingAttempts = 10; let joinCode; while (roomId === null && remainingAttempts > 0) { - joinCode = Random.hexString(6); + joinCode = Random.hexString(6).toLowerCase(); let started = new Date(); try { diff --git a/imports/api/publications/index.js b/imports/api/publications/index.js index 3588be7..615d60b 100644 --- a/imports/api/publications/index.js +++ b/imports/api/publications/index.js @@ -1 +1 @@ -// import './links' +import "./players"; diff --git a/imports/api/publications/players.js b/imports/api/publications/players.js new file mode 100644 index 0000000..611d227 --- /dev/null +++ b/imports/api/publications/players.js @@ -0,0 +1,6 @@ +import { Meteor } from "meteor/meteor"; +import Players from "../collections/Players.js"; + +Meteor.publish("players", (roomId) => { + return Players.find({ roomId }); +}); diff --git a/imports/ui/App.vue b/imports/ui/App.vue index eb9a81e..b4ea005 100644 --- a/imports/ui/App.vue +++ b/imports/ui/App.vue @@ -2,7 +2,8 @@
@@ -10,8 +11,9 @@