From 068cc87525d415c1792350b2adaa658d81888071 Mon Sep 17 00:00:00 2001 From: Alexander Embiricos Date: Sat, 27 Feb 2016 17:40:07 -0800 Subject: [PATCH 1/7] gitignore vim --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index daeba5f9..af1c6841 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ *~ node_modules -.DS_Store +*.swp +DS_Store From 1047a68fe798979e823c4fca42ce5cacae88f7f9 Mon Sep 17 00:00:00 2001 From: Alexander Embiricos Date: Sat, 27 Feb 2016 17:41:19 -0800 Subject: [PATCH 2/7] del ex --- public/index.html | 1 - scratch.md | 4 ++++ 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 scratch.md diff --git a/public/index.html b/public/index.html index 21340e72..380b5081 100644 --- a/public/index.html +++ b/public/index.html @@ -13,7 +13,6 @@
- From 6240f5df584019bb4ddeb183711fc360ab65230c Mon Sep 17 00:00:00 2001 From: Alexander Embiricos Date: Mon, 29 Feb 2016 23:05:01 -0800 Subject: [PATCH 5/7] functional --- public/index.html | 82 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 75 insertions(+), 7 deletions(-) diff --git a/public/index.html b/public/index.html index 4b73487f..fe2b7ed4 100644 --- a/public/index.html +++ b/public/index.html @@ -16,12 +16,49 @@ From 79bd3fc5714381a880164b1b911bd1d42c4d93a9 Mon Sep 17 00:00:00 2001 From: Alexander Embiricos Date: Mon, 29 Feb 2016 23:10:02 -0800 Subject: [PATCH 6/7] optimistic posting --- public/index.html | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/public/index.html b/public/index.html index fe2b7ed4..55387878 100644 --- a/public/index.html +++ b/public/index.html @@ -38,6 +38,14 @@ }, handleCommentSubmit: function(comment) { + // Optimistically set an id on the new comment. It will be replaced by an + // id generated by the server. In a production application you would likely + // not use Date.now() for this and would have a more robust system in place. + comment.id = Date.now(); + var comments = this.state.data; + var newComments = comments.concat([comment]); + this.setState({data: newComments}); // use optimistic data before ajax call + $.ajax({ url: this.props.url, dataType: 'json', @@ -45,9 +53,10 @@ data: comment, cache: false, success: function(data) { - this.setState({data: data}); + this.setState({data: data}); // update to real data on success }.bind(this), error: function(xhr, status, err) { + this.setState({data: comments}); // if something went wrong go back to old data console.error(this.props.url, status, err.toString()); }.bind(this) }); From bc5cb57069692f34ebca65cd83cecf357ad8fc2e Mon Sep 17 00:00:00 2001 From: Alexander Embiricos Date: Mon, 29 Feb 2016 23:10:28 -0800 Subject: [PATCH 7/7] cleanup --- .swm | Bin 12288 -> 0 bytes .swn | Bin 12288 -> 0 bytes .swo | Bin 12288 -> 0 bytes 3 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 .swm delete mode 100644 .swn delete mode 100644 .swo diff --git a/.swm b/.swm deleted file mode 100644 index 9901625fc141d90e7b66be80879d3c5548f8a525..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12288 zcmeI2zi-qq6vy343>}~dMwUl8q_*58ceDs8YCBa3BtQam3=oFIF}=|IFm}?rE-)hg z07h08CPpR(CjJEe1a?*=o^y9SKt(K75#np*>*x3K>}P#4S#jLGf8!Qi_0|Qq)2V=W9&TrOojlf_ERFUOQ|h=Jv6CM@2~iLLfnz4H&|kaU>$;*Bmd?}J zGyP+(k8&UY0w4eaAOHd&00JNY0)LZ0rRT(R-oX516DKEj?iV|8VL$)`KmY_l00ck) z1V8`;KmY_l00jO)0#PEwOFr~}b_aj{|35wdzgrYSvesDVSZ_}W@qo3!I>DM}edFY> ztS>A#{|)Ok>lNz-Ysku3XdnOrAOHd&00JNY0w4eaAn@N2==ORaKX@r$sh*8S-k{2} zpZ%#fwaLLijnh3l)S?Ogwrk4#knO6DU16n3b!B}aEq5M2tR>n!(#8uC-KkT#OV?GV z1KPOO+X@CeB(6e!`_@R`s7O|ws;)}I8}@Y_XQ|}; o+p01{+D?s<{A!}~dMwUl8q_*58ceDs8YCBa3BtQam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