Skip to content

Commit

Permalink
use localized timezone for file downloads (#364)
Browse files Browse the repository at this point in the history
* use localized timezone for file downloads

* update filename for host and client + fix game infos

* force rebuild

* force rebuild revert
  • Loading branch information
ZeldaZach committed Feb 26, 2019
1 parent e6fb649 commit 18277b6
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 7 deletions.
9 changes: 7 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"helmet": "^3.15.0",
"html-webpack-plugin": "3.2.0",
"jsonfile": "^5.0.0",
"luxon": "^1.11.3",
"node-schedule": "^1.3.2",
"prop-types": "^15.7.2",
"react": "^16.8.3",
Expand Down
8 changes: 8 additions & 0 deletions public/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import _ from "NodePackages/utils/utils";
import EventEmitter from "NodePackages/ee/ee";
import {STRINGS} from "./config";
import eio from "engine.io-client";
import { DateTime } from "luxon";

function message(msg) {
let args = JSON.parse(msg);
Expand Down Expand Up @@ -50,6 +51,7 @@ let App = {
sort: "rarity",
log: {},
cardSize: "normal",
game: {},

get didGameStart() {
// both round === 0 and round is undefined
Expand Down Expand Up @@ -160,6 +162,12 @@ let App = {

return { requestChange, value };
},
updateFileName() {
const savename = App.state.game.type === "draft" ? App.state.game.sets[0] + "-draft" : App.state.game.type;
// Timezone based on each individual drafter
App.state.filename = savename + "-" + DateTime.local().toFormat("yyyy-MM-dd_TT").replace(/:/g, "-");
App.save("filename", App.state.filename);
}
};

export default App;
3 changes: 0 additions & 3 deletions public/src/cards.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,6 @@ let events = {

create() {
let {type, seats, title, isPrivate, fourPack, modernOnly, totalChaos} = App.state;
let savename = App.state.type === "draft" ? App.state.sets[0] + "-draft" : App.state.type;
App.state.filename = savename + "-" + new Date().toISOString().slice(0, -5).replace(/-/g,"").replace(/:/g,"").replace("T","-");
App.save("filename", App.state.filename);
seats = Number(seats);
let options = { type, seats, title, isPrivate, fourPack, modernOnly, totalChaos };

Expand Down
4 changes: 2 additions & 2 deletions public/src/game/StartPanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ const StartPanel = () => (
<fieldset className='start-controls fieldset'>
<legend className='legend game-legend'>Game</legend>
<span>
<div>Type: {App.state.type}</div>
<div>Infos: {App.state.packsInfo}</div>
<div>Type: {App.state.game.type}</div>
<div>Infos: {App.state.game.packsInfo}</div>
{(App.state.isHost && !App.state.didGameStart)
? <StartControls/>
: <div />}
Expand Down
1 change: 1 addition & 0 deletions public/src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ function route() {
App.state.players = [];
App.send("join", id);
App.state.chat = true;
App.updateFileName();
break;
case "":
component = (
Expand Down
6 changes: 6 additions & 0 deletions src/game.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,12 @@ module.exports = class Game extends Room {
}

meta(state = {}) {
state.game = {
type: this.type,
packsInfo: this.packsInfo,
sets: this.sets
};

state.players = this.players.map(p => ({
hash: p.hash,
name: p.name,
Expand Down

0 comments on commit 18277b6

Please sign in to comment.